Commit a3f2b1c5 authored by steven100695's avatar steven100695
Browse files

Bug 1788919 - Convert browser/components/migration JSM modules to ESMs....

Bug 1788919 - Convert browser/components/migration JSM modules to ESMs. r=mconley,credential-management-reviewers,sgalich

Differential Revision: https://phabricator.services.mozilla.com/D158655
parent a293b113
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ ChromeUtils.defineESModuleGetters(this, {
  LightweightThemeConsumer:
    "resource://gre/modules/LightweightThemeConsumer.sys.mjs",
  Log: "resource://gre/modules/Log.sys.mjs",
  MigrationUtils: "resource:///modules/MigrationUtils.sys.mjs",
  NewTabUtils: "resource://gre/modules/NewTabUtils.sys.mjs",
  PictureInPicture: "resource://gre/modules/PictureInPicture.sys.mjs",
  PlacesTransactions: "resource://gre/modules/PlacesTransactions.sys.mjs",
@@ -70,7 +71,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
  HomePage: "resource:///modules/HomePage.jsm",
  LoginHelper: "resource://gre/modules/LoginHelper.jsm",
  LoginManagerParent: "resource://gre/modules/LoginManagerParent.jsm",
  MigrationUtils: "resource:///modules/MigrationUtils.jsm",
  NetUtil: "resource://gre/modules/NetUtil.jsm",
  OpenInTabsUtils: "resource:///modules/OpenInTabsUtils.jsm",
  PageActions: "resource:///modules/PageActions.jsm",
+3 −10
Original line number Diff line number Diff line
@@ -2,16 +2,9 @@
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

"use strict";
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";

var EXPORTED_SYMBOLS = ["Qihoo360seMigrationUtils"];

const { XPCOMUtils } = ChromeUtils.importESModule(
  "resource://gre/modules/XPCOMUtils.sys.mjs"
);
const { MigrationUtils } = ChromeUtils.import(
  "resource:///modules/MigrationUtils.jsm"
);
import { MigrationUtils } from "resource:///modules/MigrationUtils.sys.mjs";

const lazy = {};

@@ -122,7 +115,7 @@ Bookmarks.prototype = {
  },
};

var Qihoo360seMigrationUtils = {
export var Qihoo360seMigrationUtils = {
  async getAlternativeBookmarks({ bookmarksPath, localState }) {
    let lastModificationDate = new Date(0);
    let path = bookmarksPath;
+2 −8
Original line number Diff line number Diff line
@@ -2,18 +2,12 @@
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

"use strict";

/**
 * Class to handle encryption and decryption of logins stored in Chrome/Chromium
 * on macOS.
 */

var EXPORTED_SYMBOLS = ["ChromeMacOSLoginCrypto"];

const { XPCOMUtils } = ChromeUtils.importESModule(
  "resource://gre/modules/XPCOMUtils.sys.mjs"
);
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";

const lazy = {};

@@ -71,7 +65,7 @@ const IV = new Uint8Array(kCCBlockSizeAES128).fill(32);
 * relies on OS encryption key storage in Keychain. The algorithms here are
 * specific to what is needed for Chrome login storage on macOS.
 */
class ChromeMacOSLoginCrypto {
export class ChromeMacOSLoginCrypto {
  /**
   * @param {string} serviceName of the Keychain Item to use to derive a key.
   * @param {string} accountName of the Keychain Item to use to derive a key.
+9 −10
Original line number Diff line number Diff line
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";

var EXPORTED_SYMBOLS = ["ChromeMigrationUtils"];
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";

import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";

const { XPCOMUtils } = ChromeUtils.importESModule(
  "resource://gre/modules/XPCOMUtils.sys.mjs"
);
const { AppConstants } = ChromeUtils.importESModule(
  "resource://gre/modules/AppConstants.sys.mjs"
);
const lazy = {};

ChromeUtils.defineESModuleGetters(lazy, {
  MigrationUtils: "resource:///modules/MigrationUtils.sys.mjs",
});

XPCOMUtils.defineLazyModuleGetters(lazy, {
  LoginHelper: "resource://gre/modules/LoginHelper.jsm",
  MigrationUtils: "resource:///modules/MigrationUtils.jsm",
  OS: "resource://gre/modules/osfile.jsm",
});

const S100NS_FROM1601TO1970 = 0x19db1ded53e8000;
const S100NS_PER_MS = 10;

var ChromeMigrationUtils = {
export var ChromeMigrationUtils = {
  // Supported browsers with importable logins.
  CONTEXTUAL_LOGIN_IMPORT_BROWSERS: ["chrome", "chromium-edge", "chromium"],

+24 −52
Original line number Diff line number Diff line
@@ -4,36 +4,33 @@
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

"use strict";

const AUTH_TYPE = {
  SCHEME_HTML: 0,
  SCHEME_BASIC: 1,
  SCHEME_DIGEST: 2,
};

const { XPCOMUtils } = ChromeUtils.importESModule(
  "resource://gre/modules/XPCOMUtils.sys.mjs"
);
const { AppConstants } = ChromeUtils.importESModule(
  "resource://gre/modules/AppConstants.sys.mjs"
);
const { MigratorPrototype, MigrationUtils } = ChromeUtils.import(
  "resource:///modules/MigrationUtils.jsm"
);
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";

import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";

import {
  MigratorPrototype,
  MigrationUtils,
} from "resource:///modules/MigrationUtils.sys.mjs";

const lazy = {};

ChromeUtils.defineESModuleGetters(lazy, {
  ChromeMigrationUtils: "resource:///modules/ChromeMigrationUtils.sys.mjs",
  PlacesUIUtils: "resource:///modules/PlacesUIUtils.sys.mjs",
  PlacesUtils: "resource://gre/modules/PlacesUtils.sys.mjs",
  Qihoo360seMigrationUtils: "resource:///modules/360seMigrationUtils.sys.mjs",
});

XPCOMUtils.defineLazyModuleGetters(lazy, {
  ChromeMigrationUtils: "resource:///modules/ChromeMigrationUtils.jsm",
  NetUtil: "resource://gre/modules/NetUtil.jsm",
  OS: "resource://gre/modules/osfile.jsm",
  Qihoo360seMigrationUtils: "resource:///modules/360seMigrationUtils.jsm",
});

/**
@@ -77,7 +74,7 @@ function convertBookmarks(items, errorAccumulator) {
  return itemsToInsert;
}

function ChromeProfileMigrator() {
export function ChromeProfileMigrator() {
  this._chromeUserDataPathSuffix = "Chrome";
}

@@ -515,13 +512,13 @@ ChromeProfileMigrator.prototype._GetPasswordsResource = async function(
      let crypto;
      try {
        if (AppConstants.platform == "win") {
          let { ChromeWindowsLoginCrypto } = ChromeUtils.import(
            "resource:///modules/ChromeWindowsLoginCrypto.jsm"
          let { ChromeWindowsLoginCrypto } = ChromeUtils.importESModule(
            "resource:///modules/ChromeWindowsLoginCrypto.sys.mjs"
          );
          crypto = new ChromeWindowsLoginCrypto(_chromeUserDataPathSuffix);
        } else if (AppConstants.platform == "macosx") {
          let { ChromeMacOSLoginCrypto } = ChromeUtils.import(
            "resource:///modules/ChromeMacOSLoginCrypto.jsm"
          let { ChromeMacOSLoginCrypto } = ChromeUtils.importESModule(
            "resource:///modules/ChromeMacOSLoginCrypto.sys.mjs"
          );
          crypto = new ChromeMacOSLoginCrypto(
            _keychainServiceName,
@@ -628,7 +625,7 @@ ChromeProfileMigrator.prototype.classID = Components.ID(
/**
 *  Chromium migration
 **/
function ChromiumProfileMigrator() {
export function ChromiumProfileMigrator() {
  this._chromeUserDataPathSuffix = "Chromium";
  this._keychainServiceName = "Chromium Safe Storage";
  this._keychainAccountName = "Chromium";
@@ -645,17 +642,11 @@ ChromiumProfileMigrator.prototype.classID = Components.ID(
  "{8cece922-9720-42de-b7db-7cef88cb07ca}"
);

var EXPORTED_SYMBOLS = [
  "ChromeProfileMigrator",
  "ChromiumProfileMigrator",
  "BraveProfileMigrator",
];

/**
 * Chrome Canary
 * Not available on Linux
 **/
function CanaryProfileMigrator() {
export function CanaryProfileMigrator() {
  this._chromeUserDataPathSuffix = "Canary";
}
CanaryProfileMigrator.prototype = Object.create(
@@ -669,14 +660,10 @@ CanaryProfileMigrator.prototype.classID = Components.ID(
  "{4bf85aa5-4e21-46ca-825f-f9c51a5e8c76}"
);

if (AppConstants.platform == "win" || AppConstants.platform == "macosx") {
  EXPORTED_SYMBOLS.push("CanaryProfileMigrator");
}

/**
 * Chrome Dev - Linux only (not available in Mac and Windows)
 */
function ChromeDevMigrator() {
export function ChromeDevMigrator() {
  this._chromeUserDataPathSuffix = "Chrome Dev";
}
ChromeDevMigrator.prototype = Object.create(ChromeProfileMigrator.prototype);
@@ -687,11 +674,7 @@ ChromeDevMigrator.prototype.classID = Components.ID(
  "{7370a02a-4886-42c3-a4ec-d48c726ec30a}"
);

if (AppConstants.platform != "win" && AppConstants.platform != "macosx") {
  EXPORTED_SYMBOLS.push("ChromeDevMigrator");
}

function ChromeBetaMigrator() {
export function ChromeBetaMigrator() {
  this._chromeUserDataPathSuffix = "Chrome Beta";
}
ChromeBetaMigrator.prototype = Object.create(ChromeProfileMigrator.prototype);
@@ -702,15 +685,12 @@ ChromeBetaMigrator.prototype.classID = Components.ID(
  "{47f75963-840b-4950-a1f0-d9c1864f8b8e}"
);

if (AppConstants.platform != "macosx") {
  EXPORTED_SYMBOLS.push("ChromeBetaMigrator");
}

function BraveProfileMigrator() {
export function BraveProfileMigrator() {
  this._chromeUserDataPathSuffix = "Brave";
  this._keychainServiceName = "Brave Browser Safe Storage";
  this._keychainAccountName = "Brave Browser";
}

BraveProfileMigrator.prototype = Object.create(ChromeProfileMigrator.prototype);
BraveProfileMigrator.prototype.classDescription = "Brave Browser Migrator";
BraveProfileMigrator.prototype.contractID =
@@ -719,7 +699,7 @@ BraveProfileMigrator.prototype.classID = Components.ID(
  "{4071880a-69e4-4c83-88b4-6c589a62801d}"
);

function ChromiumEdgeMigrator() {
export function ChromiumEdgeMigrator() {
  this._chromeUserDataPathSuffix = "Edge";
  this._keychainServiceName = "Microsoft Edge Safe Storage";
  this._keychainAccountName = "Microsoft Edge";
@@ -733,7 +713,7 @@ ChromiumEdgeMigrator.prototype.classID = Components.ID(
  "{3c7f6b7c-baa9-4338-acfa-04bf79f1dcf1}"
);

function ChromiumEdgeBetaMigrator() {
export function ChromiumEdgeBetaMigrator() {
  this._chromeUserDataPathSuffix = "Edge Beta";
  this._keychainServiceName = "Microsoft Edge Safe Storage";
  this._keychainAccountName = "Microsoft Edge";
@@ -749,11 +729,7 @@ ChromiumEdgeBetaMigrator.prototype.classID = Components.ID(
  "{0fc3d48a-c1c3-4871-b58f-a8b47d1555fb}"
);

if (AppConstants.platform == "macosx" || AppConstants.platform == "win") {
  EXPORTED_SYMBOLS.push("ChromiumEdgeMigrator", "ChromiumEdgeBetaMigrator");
}

function Chromium360seMigrator() {
export function Chromium360seMigrator() {
  this._chromeUserDataPathSuffix = "360 SE";
}
Chromium360seMigrator.prototype = Object.create(
@@ -766,7 +742,3 @@ Chromium360seMigrator.prototype.contractID =
Chromium360seMigrator.prototype.classID = Components.ID(
  "{2e1a182e-ce4f-4dc9-a22c-d4125b931552}"
);

if (AppConstants.platform == "win") {
  EXPORTED_SYMBOLS.push("Chromium360seMigrator");
}
Loading