2012-05-29 15:52:43 +00:00
|
|
|
/* 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/. */
|
2012-03-21 19:20:47 +00:00
|
|
|
|
2022-10-27 23:52:49 +00:00
|
|
|
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
|
2023-03-21 15:18:34 +00:00
|
|
|
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
|
2012-03-21 19:20:47 +00:00
|
|
|
|
2022-06-06 22:46:22 +00:00
|
|
|
const lazy = {};
|
|
|
|
|
2022-07-20 22:34:21 +00:00
|
|
|
ChromeUtils.defineESModuleGetters(lazy, {
|
2023-06-23 12:25:55 +00:00
|
|
|
AMBrowserExtensionsImport: "resource://gre/modules/AddonManager.sys.mjs",
|
2023-04-11 19:06:24 +00:00
|
|
|
LoginHelper: "resource://gre/modules/LoginHelper.sys.mjs",
|
2022-11-22 15:30:56 +00:00
|
|
|
PlacesUIUtils: "resource:///modules/PlacesUIUtils.sys.mjs",
|
2023-04-11 19:06:24 +00:00
|
|
|
PlacesUtils: "resource://gre/modules/PlacesUtils.sys.mjs",
|
Bug 1792365 - Convert toolkit/modules consumers to use ES module imports directly. r=webdriver-reviewers,perftest-reviewers,geckoview-reviewers,extension-reviewers,preferences-reviewers,desktop-theme-reviewers,application-update-reviewers,pip-reviewers,credential-management-reviewers,robwu,Gijs,sgalich,bytesized,AlexandruIonescu,dao,m_kato
Differential Revision: https://phabricator.services.mozilla.com/D158094
2022-09-29 06:52:34 +00:00
|
|
|
Sqlite: "resource://gre/modules/Sqlite.sys.mjs",
|
2023-04-11 19:06:24 +00:00
|
|
|
setTimeout: "resource://gre/modules/Timer.sys.mjs",
|
Bug 1836773 - Support the new MigrationResource in the migration wizard. r=mconley,willdurand,fluent-reviewers,desktop-theme-reviewers,flod
Enables support for migrating extensions from Chrome once we have the
API to match and install extensions from the add-ons store.
Adds a new ProgressState object to delineate between various progress
states. This new object has four properties: value, message, linkURL,
and linkText. See migration-wizard-constants for more information.
MigrationWizard.#onShowingProgress uses the new ProgressState object
to handle the new LOADING, SUCCESS, ERROR and INFO values for progress.
This has the added benefit of updating the UI on error cases for the
existing resource groups.
Adds a new details object parameter to MigratorBase.migrate which is
currently used in the Chrome extensions import case.
See ChromeProfileMigrator.GetExtensionsResource for an example of
creating this details object.
See MigrationWizardParent.#doBrowserMigration for example usage of this
details object.
Adds support-text links under each resource type group in the markup.
This is currently used only by extensions in the partial matching and
no matching extensions cases.
Refactor MigrationUtils.installExtensionsWrapper to return an array
with the progress state (LOADING, SUCCESS, ERROR, INFO) and any
imported extensions.
Depends on D180005
Differential Revision: https://phabricator.services.mozilla.com/D180876
2023-06-21 20:24:56 +00:00
|
|
|
MigrationWizardConstants:
|
|
|
|
"chrome://browser/content/migration/migration-wizard-constants.mjs",
|
2022-07-20 22:34:21 +00:00
|
|
|
});
|
2012-03-21 19:20:47 +00:00
|
|
|
|
2023-10-11 20:09:21 +00:00
|
|
|
ChromeUtils.defineLazyGetter(
|
|
|
|
lazy,
|
|
|
|
"gCanGetPermissionsOnPlatformPromise",
|
|
|
|
() => {
|
|
|
|
let fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
|
|
|
|
return fp.isModeSupported(Ci.nsIFilePicker.modeGetFolder);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2015-09-15 18:19:45 +00:00
|
|
|
var gMigrators = null;
|
2023-04-13 20:15:03 +00:00
|
|
|
var gFileMigrators = null;
|
2015-09-15 18:19:45 +00:00
|
|
|
var gProfileStartup = null;
|
2020-06-02 06:46:09 +00:00
|
|
|
var gL10n = null;
|
2012-04-14 09:50:44 +00:00
|
|
|
|
2018-02-15 19:55:10 +00:00
|
|
|
let gForceExitSpinResolve = false;
|
2016-11-30 11:48:03 +00:00
|
|
|
let gKeepUndoData = false;
|
|
|
|
let gUndoData = null;
|
|
|
|
|
2020-06-02 06:46:09 +00:00
|
|
|
function getL10n() {
|
|
|
|
if (!gL10n) {
|
2023-11-02 22:03:26 +00:00
|
|
|
gL10n = new Localization(["browser/migrationWizard.ftl"]);
|
2012-04-14 09:50:44 +00:00
|
|
|
}
|
2020-06-02 06:46:09 +00:00
|
|
|
return gL10n;
|
2012-04-14 09:50:44 +00:00
|
|
|
}
|
2012-03-21 19:20:47 +00:00
|
|
|
|
2022-12-13 17:01:24 +00:00
|
|
|
const MIGRATOR_MODULES = Object.freeze({
|
|
|
|
EdgeProfileMigrator: {
|
|
|
|
moduleURI: "resource:///modules/EdgeProfileMigrator.sys.mjs",
|
|
|
|
platforms: ["win"],
|
|
|
|
},
|
|
|
|
FirefoxProfileMigrator: {
|
|
|
|
moduleURI: "resource:///modules/FirefoxProfileMigrator.sys.mjs",
|
|
|
|
platforms: ["linux", "macosx", "win"],
|
|
|
|
},
|
|
|
|
IEProfileMigrator: {
|
|
|
|
moduleURI: "resource:///modules/IEProfileMigrator.sys.mjs",
|
|
|
|
platforms: ["win"],
|
|
|
|
},
|
|
|
|
SafariProfileMigrator: {
|
|
|
|
moduleURI: "resource:///modules/SafariProfileMigrator.sys.mjs",
|
|
|
|
platforms: ["macosx"],
|
|
|
|
},
|
|
|
|
|
|
|
|
// The following migrators are all variants of the ChromeProfileMigrator
|
|
|
|
|
|
|
|
BraveProfileMigrator: {
|
|
|
|
moduleURI: "resource:///modules/ChromeProfileMigrator.sys.mjs",
|
|
|
|
platforms: ["linux", "macosx", "win"],
|
|
|
|
},
|
|
|
|
CanaryProfileMigrator: {
|
|
|
|
moduleURI: "resource:///modules/ChromeProfileMigrator.sys.mjs",
|
|
|
|
platforms: ["macosx", "win"],
|
|
|
|
},
|
|
|
|
ChromeProfileMigrator: {
|
|
|
|
moduleURI: "resource:///modules/ChromeProfileMigrator.sys.mjs",
|
|
|
|
platforms: ["linux", "macosx", "win"],
|
|
|
|
},
|
|
|
|
ChromeBetaMigrator: {
|
|
|
|
moduleURI: "resource:///modules/ChromeProfileMigrator.sys.mjs",
|
|
|
|
platforms: ["linux", "win"],
|
|
|
|
},
|
|
|
|
ChromeDevMigrator: {
|
|
|
|
moduleURI: "resource:///modules/ChromeProfileMigrator.sys.mjs",
|
|
|
|
platforms: ["linux"],
|
|
|
|
},
|
|
|
|
ChromiumProfileMigrator: {
|
|
|
|
moduleURI: "resource:///modules/ChromeProfileMigrator.sys.mjs",
|
|
|
|
platforms: ["linux", "macosx", "win"],
|
|
|
|
},
|
|
|
|
Chromium360seMigrator: {
|
|
|
|
moduleURI: "resource:///modules/ChromeProfileMigrator.sys.mjs",
|
|
|
|
platforms: ["win"],
|
|
|
|
},
|
|
|
|
ChromiumEdgeMigrator: {
|
|
|
|
moduleURI: "resource:///modules/ChromeProfileMigrator.sys.mjs",
|
|
|
|
platforms: ["macosx", "win"],
|
|
|
|
},
|
|
|
|
ChromiumEdgeBetaMigrator: {
|
|
|
|
moduleURI: "resource:///modules/ChromeProfileMigrator.sys.mjs",
|
|
|
|
platforms: ["macosx", "win"],
|
|
|
|
},
|
|
|
|
OperaProfileMigrator: {
|
|
|
|
moduleURI: "resource:///modules/ChromeProfileMigrator.sys.mjs",
|
|
|
|
platforms: ["linux", "macosx", "win"],
|
|
|
|
},
|
|
|
|
VivaldiProfileMigrator: {
|
|
|
|
moduleURI: "resource:///modules/ChromeProfileMigrator.sys.mjs",
|
|
|
|
platforms: ["linux", "macosx", "win"],
|
|
|
|
},
|
|
|
|
OperaGXProfileMigrator: {
|
|
|
|
moduleURI: "resource:///modules/ChromeProfileMigrator.sys.mjs",
|
2022-12-13 17:01:27 +00:00
|
|
|
platforms: ["macosx", "win"],
|
2022-12-13 17:01:24 +00:00
|
|
|
},
|
2023-01-31 15:30:58 +00:00
|
|
|
|
|
|
|
InternalTestingProfileMigrator: {
|
|
|
|
moduleURI: "resource:///modules/InternalTestingProfileMigrator.sys.mjs",
|
|
|
|
platforms: ["linux", "macosx", "win"],
|
|
|
|
},
|
2022-12-13 17:01:24 +00:00
|
|
|
});
|
|
|
|
|
2023-04-13 20:15:03 +00:00
|
|
|
const FILE_MIGRATOR_MODULES = Object.freeze({
|
|
|
|
PasswordFileMigrator: {
|
|
|
|
moduleURI: "resource:///modules/FileMigrators.sys.mjs",
|
|
|
|
},
|
2023-05-30 13:37:54 +00:00
|
|
|
BookmarksFileMigrator: {
|
|
|
|
moduleURI: "resource:///modules/FileMigrators.sys.mjs",
|
|
|
|
},
|
2023-04-13 20:15:03 +00:00
|
|
|
});
|
|
|
|
|
2022-12-06 17:50:39 +00:00
|
|
|
/**
|
|
|
|
* The singleton MigrationUtils service. This service is the primary mechanism
|
|
|
|
* by which migrations from other browsers to this browser occur. The singleton
|
|
|
|
* instance of this class is exported from this module as `MigrationUtils`.
|
|
|
|
*/
|
2022-12-06 17:50:39 +00:00
|
|
|
class MigrationUtils {
|
2023-03-21 15:18:34 +00:00
|
|
|
constructor() {
|
|
|
|
XPCOMUtils.defineLazyPreferenceGetter(
|
|
|
|
this,
|
|
|
|
"HISTORY_MAX_AGE_IN_DAYS",
|
|
|
|
"browser.migrate.history.maxAgeInDays",
|
|
|
|
180
|
|
|
|
);
|
2023-06-09 17:39:51 +00:00
|
|
|
|
|
|
|
ChromeUtils.registerWindowActor("MigrationWizard", {
|
|
|
|
parent: {
|
|
|
|
esModuleURI: "resource:///actors/MigrationWizardParent.sys.mjs",
|
|
|
|
},
|
|
|
|
|
|
|
|
child: {
|
|
|
|
esModuleURI: "resource:///actors/MigrationWizardChild.sys.mjs",
|
|
|
|
events: {
|
|
|
|
"MigrationWizard:RequestState": { wantUntrusted: true },
|
|
|
|
"MigrationWizard:BeginMigration": { wantUntrusted: true },
|
|
|
|
"MigrationWizard:RequestSafariPermissions": { wantUntrusted: true },
|
|
|
|
"MigrationWizard:SelectSafariPasswordFile": { wantUntrusted: true },
|
2023-09-13 21:28:21 +00:00
|
|
|
"MigrationWizard:OpenAboutAddons": { wantUntrusted: true },
|
2023-10-18 19:16:38 +00:00
|
|
|
"MigrationWizard:PermissionsNeeded": { wantUntrusted: true },
|
2023-10-11 20:09:21 +00:00
|
|
|
"MigrationWizard:GetPermissions": { wantUntrusted: true },
|
2024-06-08 03:53:10 +00:00
|
|
|
"MigrationWizard:OpenURL": { wantUntrusted: true },
|
2023-06-09 17:39:51 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
includeChrome: true,
|
|
|
|
allFrames: true,
|
|
|
|
matches: [
|
|
|
|
"about:welcome",
|
|
|
|
"about:welcome?*",
|
|
|
|
"about:preferences",
|
2024-02-29 10:09:59 +00:00
|
|
|
"about:settings",
|
2023-06-09 17:39:51 +00:00
|
|
|
"chrome://browser/content/migration/migration-dialog-window.html",
|
2023-06-23 19:23:51 +00:00
|
|
|
"chrome://browser/content/spotlight.html",
|
2024-01-04 15:40:22 +00:00
|
|
|
"about:firefoxview",
|
2023-06-09 17:39:51 +00:00
|
|
|
],
|
|
|
|
});
|
2023-10-11 20:09:21 +00:00
|
|
|
|
2024-01-17 15:54:00 +00:00
|
|
|
ChromeUtils.defineLazyGetter(this, "IS_LINUX_SNAP_PACKAGE", () => {
|
2023-10-11 20:09:21 +00:00
|
|
|
if (
|
|
|
|
AppConstants.platform != "linux" ||
|
|
|
|
!Cc["@mozilla.org/gio-service;1"]
|
|
|
|
) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
let gIOSvc = Cc["@mozilla.org/gio-service;1"].getService(
|
|
|
|
Ci.nsIGIOService
|
|
|
|
);
|
|
|
|
return gIOSvc.isRunningUnderSnap;
|
|
|
|
});
|
2023-03-21 15:18:34 +00:00
|
|
|
}
|
|
|
|
|
2022-12-06 17:50:39 +00:00
|
|
|
resourceTypes = Object.freeze({
|
2022-12-13 17:01:24 +00:00
|
|
|
ALL: 0x0000,
|
|
|
|
/* 0x01 used to be used for settings, but was removed. */
|
|
|
|
COOKIES: 0x0002,
|
|
|
|
HISTORY: 0x0004,
|
|
|
|
FORMDATA: 0x0008,
|
|
|
|
PASSWORDS: 0x0010,
|
|
|
|
BOOKMARKS: 0x0020,
|
|
|
|
OTHERDATA: 0x0040,
|
|
|
|
SESSION: 0x0080,
|
2023-05-16 19:12:21 +00:00
|
|
|
PAYMENT_METHODS: 0x0100,
|
2023-06-21 20:24:56 +00:00
|
|
|
EXTENSIONS: 0x0200,
|
2022-12-06 17:50:39 +00:00
|
|
|
});
|
2012-04-14 09:50:44 +00:00
|
|
|
|
2012-03-21 19:20:47 +00:00
|
|
|
/**
|
|
|
|
* Helper for implementing simple asynchronous cases of migration resources'
|
2024-08-29 15:21:53 +00:00
|
|
|
* ``migrate(aCallback)`` (see MigratorBase). If your ``migrate`` method
|
2012-03-21 19:20:47 +00:00
|
|
|
* just waits for some file to be read, for example, and then migrates
|
|
|
|
* everything right away, you can wrap the async-function with this helper
|
|
|
|
* and not worry about notifying the callback.
|
|
|
|
*
|
2022-12-06 17:50:39 +00:00
|
|
|
* @example
|
|
|
|
* // For example, instead of writing:
|
2012-03-21 19:20:47 +00:00
|
|
|
* setTimeout(function() {
|
|
|
|
* try {
|
|
|
|
* ....
|
|
|
|
* aCallback(true);
|
|
|
|
* }
|
|
|
|
* catch() {
|
|
|
|
* aCallback(false);
|
|
|
|
* }
|
|
|
|
* }, 0);
|
|
|
|
*
|
2022-12-06 17:50:39 +00:00
|
|
|
* // You may write:
|
2012-03-21 19:20:47 +00:00
|
|
|
* setTimeout(MigrationUtils.wrapMigrateFunction(function() {
|
|
|
|
* if (importingFromMosaic)
|
|
|
|
* throw Cr.NS_ERROR_UNEXPECTED;
|
|
|
|
* }, aCallback), 0);
|
|
|
|
*
|
2022-12-06 17:50:39 +00:00
|
|
|
* // ... and aCallback will be called with aSuccess=false when importing
|
|
|
|
* // from Mosaic, or with aSuccess=true otherwise.
|
2012-03-21 19:20:47 +00:00
|
|
|
*
|
2022-12-06 17:50:38 +00:00
|
|
|
* @param {Function} aFunction
|
|
|
|
* the function that will be called sometime later. If aFunction
|
|
|
|
* throws when it's called, aCallback(false) is called, otherwise
|
|
|
|
* aCallback(true) is called.
|
|
|
|
* @param {Function} aCallback
|
2024-08-29 15:21:53 +00:00
|
|
|
* the callback function passed to ``migrate``.
|
2022-12-06 17:50:38 +00:00
|
|
|
* @returns {Function}
|
|
|
|
* the wrapped function.
|
2012-03-21 19:20:47 +00:00
|
|
|
*/
|
2022-12-06 17:50:39 +00:00
|
|
|
wrapMigrateFunction(aFunction, aCallback) {
|
2023-05-20 12:26:49 +00:00
|
|
|
return function () {
|
2012-03-21 19:20:47 +00:00
|
|
|
let success = false;
|
|
|
|
try {
|
|
|
|
aFunction.apply(null, arguments);
|
|
|
|
success = true;
|
2016-12-31 02:47:25 +00:00
|
|
|
} catch (ex) {
|
2023-01-20 17:49:21 +00:00
|
|
|
console.error(ex);
|
2012-03-21 19:20:47 +00:00
|
|
|
}
|
|
|
|
// Do not change this to call aCallback directly in try try & catch
|
|
|
|
// blocks, because if aCallback throws, we may end up calling aCallback
|
|
|
|
// twice.
|
|
|
|
aCallback(success);
|
2016-10-18 15:03:06 +00:00
|
|
|
};
|
2022-12-06 17:50:39 +00:00
|
|
|
}
|
2012-03-21 19:20:47 +00:00
|
|
|
|
2012-04-14 09:50:44 +00:00
|
|
|
/**
|
2020-06-02 06:46:09 +00:00
|
|
|
* Gets localized string corresponding to l10n-id
|
2012-04-14 09:50:44 +00:00
|
|
|
*
|
2022-12-06 17:50:38 +00:00
|
|
|
* @param {string} aKey
|
|
|
|
* The key of the id of the localization to retrieve.
|
|
|
|
* @param {object} [aArgs=undefined]
|
|
|
|
* An optional map of arguments to the id.
|
|
|
|
* @returns {Promise<string>}
|
|
|
|
* A promise that resolves to the retrieved localization.
|
2012-04-14 09:50:44 +00:00
|
|
|
*/
|
2022-12-06 17:50:39 +00:00
|
|
|
getLocalizedString(aKey, aArgs) {
|
2020-06-02 06:46:09 +00:00
|
|
|
let l10n = getL10n();
|
|
|
|
return l10n.formatValue(aKey, aArgs);
|
2022-12-06 17:50:39 +00:00
|
|
|
}
|
2012-04-14 09:50:44 +00:00
|
|
|
|
2016-10-03 15:17:06 +00:00
|
|
|
/**
|
|
|
|
* Get all the rows corresponding to a select query from a database, without
|
|
|
|
* requiring a lock on the database. If fetching data fails (because someone
|
|
|
|
* else tried to write to the DB at the same time, for example), we will
|
|
|
|
* retry the fetch after a 100ms timeout, up to 10 times.
|
|
|
|
*
|
2022-12-06 17:50:38 +00:00
|
|
|
* @param {string} path
|
|
|
|
* The file path to the database we want to open.
|
|
|
|
* @param {string} description
|
|
|
|
* A developer-readable string identifying what kind of database we're
|
|
|
|
* trying to open.
|
|
|
|
* @param {string} selectQuery
|
|
|
|
* The SELECT query to use to fetch the rows.
|
2023-01-23 15:44:10 +00:00
|
|
|
* @param {Promise} [testDelayPromise]
|
|
|
|
* An optional promise to await for after the first loop, used in tests.
|
2016-10-03 15:17:06 +00:00
|
|
|
*
|
2022-12-06 17:50:38 +00:00
|
|
|
* @returns {Promise<object[]|Error>}
|
|
|
|
* A promise that resolves to an array of rows. The promise will be
|
|
|
|
* rejected if the read/fetch failed even after retrying.
|
2016-10-03 15:17:06 +00:00
|
|
|
*/
|
2023-01-23 15:44:10 +00:00
|
|
|
getRowsFromDBWithoutLocks(
|
|
|
|
path,
|
|
|
|
description,
|
|
|
|
selectQuery,
|
|
|
|
testDelayPromise = null
|
|
|
|
) {
|
2016-10-03 15:17:06 +00:00
|
|
|
let dbOptions = {
|
|
|
|
readOnly: true,
|
|
|
|
ignoreLockingMode: true,
|
|
|
|
path,
|
|
|
|
};
|
|
|
|
|
|
|
|
const RETRYLIMIT = 10;
|
|
|
|
const RETRYINTERVAL = 100;
|
|
|
|
return (async function innerGetRows() {
|
|
|
|
let rows = null;
|
2023-01-23 15:44:10 +00:00
|
|
|
for (let retryCount = RETRYLIMIT; retryCount; retryCount--) {
|
2016-10-03 15:17:06 +00:00
|
|
|
// Attempt to get the rows. If this succeeds, we will bail out of the loop,
|
|
|
|
// close the database in a failsafe way, and pass the rows back.
|
|
|
|
// If fetching the rows throws, we will wait RETRYINTERVAL ms
|
|
|
|
// and try again. This will repeat a maximum of RETRYLIMIT times.
|
|
|
|
let db;
|
|
|
|
let didOpen = false;
|
2023-01-23 15:44:10 +00:00
|
|
|
let previousExceptionMessage = null;
|
2016-10-03 15:17:06 +00:00
|
|
|
try {
|
2022-06-06 22:46:22 +00:00
|
|
|
db = await lazy.Sqlite.openConnection(dbOptions);
|
2016-10-03 15:17:06 +00:00
|
|
|
didOpen = true;
|
|
|
|
rows = await db.execute(selectQuery);
|
2023-01-23 15:44:10 +00:00
|
|
|
break;
|
2016-10-03 15:17:06 +00:00
|
|
|
} catch (ex) {
|
2023-01-23 15:44:10 +00:00
|
|
|
if (previousExceptionMessage != ex.message) {
|
2023-01-20 17:49:21 +00:00
|
|
|
console.error(ex);
|
2016-10-03 15:17:06 +00:00
|
|
|
}
|
2023-01-23 15:44:10 +00:00
|
|
|
previousExceptionMessage = ex.message;
|
2023-07-04 20:43:09 +00:00
|
|
|
if (ex.name == "NS_ERROR_FILE_CORRUPTED") {
|
|
|
|
break;
|
|
|
|
}
|
2016-10-03 15:17:06 +00:00
|
|
|
} finally {
|
|
|
|
try {
|
|
|
|
if (didOpen) {
|
|
|
|
await db.close();
|
|
|
|
}
|
|
|
|
} catch (ex) {}
|
|
|
|
}
|
2023-01-23 15:44:10 +00:00
|
|
|
await Promise.all([
|
|
|
|
new Promise(resolve => lazy.setTimeout(resolve, RETRYINTERVAL)),
|
|
|
|
testDelayPromise,
|
|
|
|
]);
|
2016-10-03 15:17:06 +00:00
|
|
|
}
|
|
|
|
if (!rows) {
|
|
|
|
throw new Error(
|
|
|
|
"Couldn't get rows from the " + description + " database."
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return rows;
|
|
|
|
})();
|
2022-12-06 17:50:39 +00:00
|
|
|
}
|
2016-10-03 15:17:06 +00:00
|
|
|
|
2022-12-06 17:50:39 +00:00
|
|
|
get #migrators() {
|
2016-10-18 15:03:06 +00:00
|
|
|
if (!gMigrators) {
|
|
|
|
gMigrators = new Map();
|
2022-12-13 17:01:24 +00:00
|
|
|
for (let [symbol, { moduleURI, platforms }] of Object.entries(
|
|
|
|
MIGRATOR_MODULES
|
|
|
|
)) {
|
|
|
|
if (platforms.includes(AppConstants.platform)) {
|
2023-05-20 12:26:53 +00:00
|
|
|
let { [symbol]: migratorClass } =
|
|
|
|
ChromeUtils.importESModule(moduleURI);
|
2022-12-13 17:01:24 +00:00
|
|
|
if (gMigrators.has(migratorClass.key)) {
|
|
|
|
console.error(
|
|
|
|
"A pre-existing migrator exists with key " +
|
|
|
|
`${migratorClass.key}. Not registering.`
|
|
|
|
);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
gMigrators.set(migratorClass.key, new migratorClass());
|
|
|
|
}
|
|
|
|
}
|
2016-10-18 15:03:06 +00:00
|
|
|
}
|
|
|
|
return gMigrators;
|
2022-12-06 17:50:39 +00:00
|
|
|
}
|
2012-03-21 19:20:47 +00:00
|
|
|
|
2023-04-13 20:15:03 +00:00
|
|
|
get #fileMigrators() {
|
|
|
|
if (!gFileMigrators) {
|
|
|
|
gFileMigrators = new Map();
|
|
|
|
for (let [symbol, { moduleURI }] of Object.entries(
|
|
|
|
FILE_MIGRATOR_MODULES
|
|
|
|
)) {
|
|
|
|
let { [symbol]: migratorClass } = ChromeUtils.importESModule(moduleURI);
|
|
|
|
if (gFileMigrators.has(migratorClass.key)) {
|
|
|
|
console.error(
|
|
|
|
"A pre-existing file migrator exists with key " +
|
|
|
|
`${migratorClass.key}. Not registering.`
|
|
|
|
);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
gFileMigrators.set(migratorClass.key, new migratorClass());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return gFileMigrators;
|
|
|
|
}
|
|
|
|
|
2022-12-06 17:50:39 +00:00
|
|
|
forceExitSpinResolve() {
|
2018-02-15 19:55:10 +00:00
|
|
|
gForceExitSpinResolve = true;
|
2022-12-06 17:50:39 +00:00
|
|
|
}
|
2018-02-15 19:55:10 +00:00
|
|
|
|
2022-12-06 17:50:39 +00:00
|
|
|
spinResolve(promise) {
|
2018-01-12 17:06:21 +00:00
|
|
|
if (!(promise instanceof Promise)) {
|
|
|
|
return promise;
|
|
|
|
}
|
|
|
|
let done = false;
|
|
|
|
let result = null;
|
|
|
|
let error = null;
|
2018-02-15 19:55:10 +00:00
|
|
|
gForceExitSpinResolve = false;
|
2018-01-12 17:06:21 +00:00
|
|
|
promise
|
|
|
|
.catch(e => {
|
|
|
|
error = e;
|
|
|
|
})
|
|
|
|
.then(r => {
|
|
|
|
result = r;
|
|
|
|
done = true;
|
|
|
|
});
|
|
|
|
|
2021-03-02 22:11:58 +00:00
|
|
|
Services.tm.spinEventLoopUntil(
|
2024-03-11 15:26:28 +00:00
|
|
|
"MigrationUtils.sys.mjs:MU_spinResolve",
|
2021-03-02 22:11:58 +00:00
|
|
|
() => done || gForceExitSpinResolve
|
|
|
|
);
|
2018-02-15 19:55:10 +00:00
|
|
|
if (!done) {
|
|
|
|
throw new Error("Forcefully exited event loop.");
|
|
|
|
} else if (error) {
|
2018-01-12 17:06:21 +00:00
|
|
|
throw error;
|
|
|
|
} else {
|
|
|
|
return result;
|
|
|
|
}
|
2022-12-06 17:50:39 +00:00
|
|
|
}
|
2018-01-12 17:06:21 +00:00
|
|
|
|
2022-12-06 17:50:38 +00:00
|
|
|
/**
|
2012-03-21 19:20:47 +00:00
|
|
|
* Returns the migrator for the given source, if any data is available
|
2023-10-11 20:09:21 +00:00
|
|
|
* for this source, or if permissions are required in order to read
|
|
|
|
* data from this source. Returns null otherwise.
|
2012-03-21 19:20:47 +00:00
|
|
|
*
|
2022-12-06 17:50:38 +00:00
|
|
|
* @param {string} aKey
|
2022-12-06 17:50:39 +00:00
|
|
|
* Internal name of the migration source. See `availableMigratorKeys`
|
2022-12-06 17:50:38 +00:00
|
|
|
* for supported values by OS.
|
2023-10-11 20:09:21 +00:00
|
|
|
* @returns {Promise<MigratorBase|null>}
|
2022-12-06 17:50:38 +00:00
|
|
|
* A profile migrator implementing nsIBrowserProfileMigrator, if it can
|
|
|
|
* import any data, null otherwise.
|
2012-03-21 19:20:47 +00:00
|
|
|
*/
|
2022-12-06 17:50:39 +00:00
|
|
|
async getMigrator(aKey) {
|
2022-12-13 17:01:24 +00:00
|
|
|
let migrator = this.#migrators.get(aKey);
|
|
|
|
if (!migrator) {
|
|
|
|
console.error(`Could not find a migrator class for key ${aKey}`);
|
|
|
|
return null;
|
2012-03-21 19:20:47 +00:00
|
|
|
}
|
|
|
|
|
2015-08-11 15:53:10 +00:00
|
|
|
try {
|
2023-10-11 20:09:21 +00:00
|
|
|
if (!migrator) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (
|
|
|
|
(await migrator.isSourceAvailable()) ||
|
|
|
|
(!(await migrator.hasPermissions()) && migrator.canGetPermissions())
|
|
|
|
) {
|
|
|
|
return migrator;
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
2017-05-28 18:57:46 +00:00
|
|
|
} catch (ex) {
|
2023-01-20 17:49:21 +00:00
|
|
|
console.error(ex);
|
2017-05-28 18:57:46 +00:00
|
|
|
return null;
|
|
|
|
}
|
2022-12-06 17:50:39 +00:00
|
|
|
}
|
2012-03-21 19:20:47 +00:00
|
|
|
|
2023-04-13 20:15:03 +00:00
|
|
|
getFileMigrator(aKey) {
|
|
|
|
let migrator = this.#fileMigrators.get(aKey);
|
|
|
|
if (!migrator) {
|
|
|
|
console.error(`Could not find a file migrator class for key ${aKey}`);
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return migrator;
|
|
|
|
}
|
|
|
|
|
2022-12-13 17:01:24 +00:00
|
|
|
/**
|
|
|
|
* Returns true if a migrator is registered with key aKey. No check is made
|
|
|
|
* to determine if a profile exists that the migrator can migrate from.
|
|
|
|
*
|
|
|
|
* @param {string} aKey
|
|
|
|
* Internal name of the migration source. See `availableMigratorKeys`
|
|
|
|
* for supported values by OS.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
migratorExists(aKey) {
|
|
|
|
return this.#migrators.has(aKey);
|
|
|
|
}
|
|
|
|
|
2016-05-24 10:44:49 +00:00
|
|
|
/**
|
|
|
|
* Figure out what is the default browser, and if there is a migrator
|
|
|
|
* for it, return that migrator's internal name.
|
2022-12-06 17:50:38 +00:00
|
|
|
*
|
2016-05-24 10:44:49 +00:00
|
|
|
* For the time being, the "internal name" of a migrator is its contract-id
|
|
|
|
* trailer (e.g. ie for @mozilla.org/profile/migrator;1?app=browser&type=ie),
|
|
|
|
* but it will soon be exposed properly.
|
2022-12-06 17:50:38 +00:00
|
|
|
*
|
|
|
|
* @returns {string}
|
2016-05-24 10:44:49 +00:00
|
|
|
*/
|
|
|
|
getMigratorKeyForDefaultBrowser() {
|
|
|
|
// Canary uses the same description as Chrome so we can't distinguish them.
|
2020-01-10 21:40:30 +00:00
|
|
|
// Edge Beta on macOS uses "Microsoft Edge" with no "beta" indication.
|
2016-05-24 10:44:49 +00:00
|
|
|
const APP_DESC_TO_KEY = {
|
|
|
|
"Internet Explorer": "ie",
|
2016-06-29 18:37:48 +00:00
|
|
|
"Microsoft Edge": "edge",
|
2016-05-24 10:44:49 +00:00
|
|
|
Safari: "safari",
|
|
|
|
Firefox: "firefox",
|
2016-11-01 11:57:30 +00:00
|
|
|
Nightly: "firefox",
|
2022-11-01 15:58:29 +00:00
|
|
|
Opera: "opera",
|
2022-11-14 18:02:21 +00:00
|
|
|
Vivaldi: "vivaldi",
|
2022-12-01 14:49:38 +00:00
|
|
|
"Opera GX": "opera-gx",
|
2021-11-23 05:26:09 +00:00
|
|
|
"Brave Web Browser": "brave", // Windows, Linux
|
|
|
|
Brave: "brave", // OS X
|
2016-05-24 10:44:49 +00:00
|
|
|
"Google Chrome": "chrome", // Windows, Linux
|
|
|
|
Chrome: "chrome", // OS X
|
|
|
|
Chromium: "chromium", // Windows, OS X
|
|
|
|
"Chromium Web Browser": "chromium", // Linux
|
2021-12-22 10:48:49 +00:00
|
|
|
"360\u5b89\u5168\u6d4f\u89c8\u5668": "chromium-360se",
|
2016-05-24 10:44:49 +00:00
|
|
|
};
|
|
|
|
|
2016-09-23 15:27:20 +00:00
|
|
|
let key = "";
|
2016-05-24 10:44:49 +00:00
|
|
|
try {
|
2016-10-18 15:03:06 +00:00
|
|
|
let browserDesc = Cc["@mozilla.org/uriloader/external-protocol-service;1"]
|
|
|
|
.getService(Ci.nsIExternalProtocolService)
|
|
|
|
.getApplicationDescription("http");
|
2016-09-23 15:27:20 +00:00
|
|
|
key = APP_DESC_TO_KEY[browserDesc] || "";
|
2016-11-01 11:57:30 +00:00
|
|
|
// Handle devedition, as well as "FirefoxNightly" on OS X.
|
|
|
|
if (!key && browserDesc.startsWith("Firefox")) {
|
|
|
|
key = "firefox";
|
|
|
|
}
|
2016-12-31 02:47:25 +00:00
|
|
|
} catch (ex) {
|
2023-01-20 17:49:21 +00:00
|
|
|
console.error("Could not detect default browser: ", ex);
|
2016-05-24 10:44:49 +00:00
|
|
|
}
|
2016-09-23 15:27:20 +00:00
|
|
|
|
|
|
|
return key;
|
2022-12-06 17:50:39 +00:00
|
|
|
}
|
2016-05-24 10:44:49 +00:00
|
|
|
|
2022-12-06 17:50:38 +00:00
|
|
|
/**
|
|
|
|
* True if we're in the process of a startup migration.
|
|
|
|
*
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2015-09-23 09:36:21 +00:00
|
|
|
get isStartupMigration() {
|
|
|
|
return gProfileStartup != null;
|
2022-12-06 17:50:39 +00:00
|
|
|
}
|
2012-03-21 19:20:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* In the case of startup migration, this is set to the nsIProfileStartup
|
|
|
|
* instance passed to ProfileMigrator's migrate.
|
|
|
|
*
|
|
|
|
* @see showMigrationWizard
|
2022-12-06 17:50:38 +00:00
|
|
|
* @type {nsIProfileStartup|null}
|
2012-03-21 19:20:47 +00:00
|
|
|
*/
|
2015-09-23 09:36:21 +00:00
|
|
|
get profileStartup() {
|
|
|
|
return gProfileStartup;
|
2022-12-06 17:50:39 +00:00
|
|
|
}
|
2012-03-21 19:20:47 +00:00
|
|
|
|
|
|
|
/**
|
Bug 1855280 - Remove the ability to switch to the old migration wizard. r=kpatenio,omc-reviewers,settings-reviewers,credential-management-reviewers,negin,aminomancer,mtigley
This removes the pref to re-enable the legacy wizard, and all of the things that used
to read from it.
It also disables the ability to use the legacy wizard from about:welcome with the
aboutWelcomeBehavior feature.
It also removes the closeMigrationWizard utility from BrowserTestUtils, since that
effectively became a thin-wrapper around BrowserTestUtils.removeTab.
Finally, this patch also removes some documentation about the legacy migration wizard,
and tests that specifically check the legacy dialog behaviour.
Differential Revision: https://phabricator.services.mozilla.com/D190716
2023-10-16 18:24:42 +00:00
|
|
|
* Show the migration wizard in about:preferences, or if there is not an existing
|
|
|
|
* browser window open, in a new top-level dialog window.
|
2022-12-13 17:01:25 +00:00
|
|
|
*
|
|
|
|
* NB: If you add new consumers, please add a migration entry point constant to
|
|
|
|
* MIGRATION_ENTRYPOINTS and supply that entrypoint with the entrypoint property
|
|
|
|
* in the aOptions argument.
|
2012-03-21 19:20:47 +00:00
|
|
|
*
|
2022-12-06 17:50:38 +00:00
|
|
|
* @param {Window} [aOpener=null]
|
|
|
|
* optional; the window that asks to open the wizard.
|
2022-12-13 17:01:25 +00:00
|
|
|
* @param {object} [aOptions=null]
|
|
|
|
* optional named arguments for the migration wizard.
|
2023-03-20 19:45:34 +00:00
|
|
|
* @param {string} [aOptions.entrypoint=undefined]
|
2022-12-13 17:01:25 +00:00
|
|
|
* migration entry point constant. See MIGRATION_ENTRYPOINTS.
|
|
|
|
* @param {string} [aOptions.migratorKey=undefined]
|
|
|
|
* The key for which migrator to use automatically. This is the key that is exposed
|
|
|
|
* as a static getter on the migrator class.
|
|
|
|
* @param {MigratorBase} [aOptions.migrator=undefined]
|
|
|
|
* A migrator instance to use automatically.
|
|
|
|
* @param {boolean} [aOptions.isStartupMigration=undefined]
|
|
|
|
* True if this is a startup migration.
|
|
|
|
* @param {boolean} [aOptions.skipSourceSelection=undefined]
|
|
|
|
* True if the source selection page of the wizard should be skipped.
|
|
|
|
* @param {string} [aOptions.profileId]
|
|
|
|
* An identifier for the profile to use when migrating.
|
2023-01-31 15:30:57 +00:00
|
|
|
* @returns {Promise<undefined>}
|
Bug 1855280 - Remove the ability to switch to the old migration wizard. r=kpatenio,omc-reviewers,settings-reviewers,credential-management-reviewers,negin,aminomancer,mtigley
This removes the pref to re-enable the legacy wizard, and all of the things that used
to read from it.
It also disables the ability to use the legacy wizard from about:welcome with the
aboutWelcomeBehavior feature.
It also removes the closeMigrationWizard utility from BrowserTestUtils, since that
effectively became a thin-wrapper around BrowserTestUtils.removeTab.
Finally, this patch also removes some documentation about the legacy migration wizard,
and tests that specifically check the legacy dialog behaviour.
Differential Revision: https://phabricator.services.mozilla.com/D190716
2023-10-16 18:24:42 +00:00
|
|
|
* If an about:preferences tab can be opened, this will resolve when
|
2023-01-31 15:30:57 +00:00
|
|
|
* that tab has been switched to. Otherwise, this will resolve
|
Bug 1855280 - Remove the ability to switch to the old migration wizard. r=kpatenio,omc-reviewers,settings-reviewers,credential-management-reviewers,negin,aminomancer,mtigley
This removes the pref to re-enable the legacy wizard, and all of the things that used
to read from it.
It also disables the ability to use the legacy wizard from about:welcome with the
aboutWelcomeBehavior feature.
It also removes the closeMigrationWizard utility from BrowserTestUtils, since that
effectively became a thin-wrapper around BrowserTestUtils.removeTab.
Finally, this patch also removes some documentation about the legacy migration wizard,
and tests that specifically check the legacy dialog behaviour.
Differential Revision: https://phabricator.services.mozilla.com/D190716
2023-10-16 18:24:42 +00:00
|
|
|
* just after opening the top-level dialog window.
|
2012-03-21 19:20:47 +00:00
|
|
|
*/
|
2022-12-13 17:01:25 +00:00
|
|
|
showMigrationWizard(aOpener, aOptions) {
|
2023-06-15 16:33:43 +00:00
|
|
|
// When migration is kicked off from about:welcome, there are
|
|
|
|
// a few different behaviors that we want to test, controlled
|
|
|
|
// by a preference that is instrumented for Nimbus. The pref
|
|
|
|
// has the following possible states:
|
|
|
|
//
|
|
|
|
// "autoclose":
|
|
|
|
// The user will be directed to the migration wizard in
|
|
|
|
// about:preferences, but once the wizard is dismissed,
|
|
|
|
// the tab will close.
|
|
|
|
//
|
|
|
|
// "standalone":
|
|
|
|
// The migration wizard will open in a new top-level content
|
|
|
|
// window.
|
|
|
|
//
|
|
|
|
// "default" / other
|
|
|
|
// The user will be directed to the migration wizard in
|
|
|
|
// about:preferences. The tab will not close once the
|
|
|
|
// user closes the wizard.
|
|
|
|
let aboutWelcomeBehavior = Services.prefs.getCharPref(
|
|
|
|
"browser.migrate.content-modal.about-welcome-behavior",
|
|
|
|
"default"
|
|
|
|
);
|
|
|
|
|
Bug 1855280 - Remove the ability to switch to the old migration wizard. r=kpatenio,omc-reviewers,settings-reviewers,credential-management-reviewers,negin,aminomancer,mtigley
This removes the pref to re-enable the legacy wizard, and all of the things that used
to read from it.
It also disables the ability to use the legacy wizard from about:welcome with the
aboutWelcomeBehavior feature.
It also removes the closeMigrationWizard utility from BrowserTestUtils, since that
effectively became a thin-wrapper around BrowserTestUtils.removeTab.
Finally, this patch also removes some documentation about the legacy migration wizard,
and tests that specifically check the legacy dialog behaviour.
Differential Revision: https://phabricator.services.mozilla.com/D190716
2023-10-16 18:24:42 +00:00
|
|
|
let entrypoint = aOptions.entrypoint || this.MIGRATION_ENTRYPOINTS.UNKNOWN;
|
|
|
|
Services.telemetry
|
|
|
|
.getHistogramById("FX_MIGRATION_ENTRY_POINT_CATEGORICAL")
|
|
|
|
.add(entrypoint);
|
2023-06-09 17:39:51 +00:00
|
|
|
|
Bug 1855280 - Remove the ability to switch to the old migration wizard. r=kpatenio,omc-reviewers,settings-reviewers,credential-management-reviewers,negin,aminomancer,mtigley
This removes the pref to re-enable the legacy wizard, and all of the things that used
to read from it.
It also disables the ability to use the legacy wizard from about:welcome with the
aboutWelcomeBehavior feature.
It also removes the closeMigrationWizard utility from BrowserTestUtils, since that
effectively became a thin-wrapper around BrowserTestUtils.removeTab.
Finally, this patch also removes some documentation about the legacy migration wizard,
and tests that specifically check the legacy dialog behaviour.
Differential Revision: https://phabricator.services.mozilla.com/D190716
2023-10-16 18:24:42 +00:00
|
|
|
let openStandaloneWindow = blocking => {
|
|
|
|
let features = "dialog,centerscreen,resizable=no";
|
2023-06-09 17:39:51 +00:00
|
|
|
|
Bug 1855280 - Remove the ability to switch to the old migration wizard. r=kpatenio,omc-reviewers,settings-reviewers,credential-management-reviewers,negin,aminomancer,mtigley
This removes the pref to re-enable the legacy wizard, and all of the things that used
to read from it.
It also disables the ability to use the legacy wizard from about:welcome with the
aboutWelcomeBehavior feature.
It also removes the closeMigrationWizard utility from BrowserTestUtils, since that
effectively became a thin-wrapper around BrowserTestUtils.removeTab.
Finally, this patch also removes some documentation about the legacy migration wizard,
and tests that specifically check the legacy dialog behaviour.
Differential Revision: https://phabricator.services.mozilla.com/D190716
2023-10-16 18:24:42 +00:00
|
|
|
if (blocking) {
|
|
|
|
features += ",modal";
|
2023-01-17 20:30:58 +00:00
|
|
|
}
|
2023-01-31 15:30:57 +00:00
|
|
|
|
Bug 1855280 - Remove the ability to switch to the old migration wizard. r=kpatenio,omc-reviewers,settings-reviewers,credential-management-reviewers,negin,aminomancer,mtigley
This removes the pref to re-enable the legacy wizard, and all of the things that used
to read from it.
It also disables the ability to use the legacy wizard from about:welcome with the
aboutWelcomeBehavior feature.
It also removes the closeMigrationWizard utility from BrowserTestUtils, since that
effectively became a thin-wrapper around BrowserTestUtils.removeTab.
Finally, this patch also removes some documentation about the legacy migration wizard,
and tests that specifically check the legacy dialog behaviour.
Differential Revision: https://phabricator.services.mozilla.com/D190716
2023-10-16 18:24:42 +00:00
|
|
|
Services.ww.openWindow(
|
|
|
|
aOpener,
|
|
|
|
"chrome://browser/content/migration/migration-dialog-window.html",
|
|
|
|
"_blank",
|
|
|
|
features,
|
|
|
|
{
|
|
|
|
options: aOptions,
|
2023-04-05 21:40:46 +00:00
|
|
|
}
|
Bug 1855280 - Remove the ability to switch to the old migration wizard. r=kpatenio,omc-reviewers,settings-reviewers,credential-management-reviewers,negin,aminomancer,mtigley
This removes the pref to re-enable the legacy wizard, and all of the things that used
to read from it.
It also disables the ability to use the legacy wizard from about:welcome with the
aboutWelcomeBehavior feature.
It also removes the closeMigrationWizard utility from BrowserTestUtils, since that
effectively became a thin-wrapper around BrowserTestUtils.removeTab.
Finally, this patch also removes some documentation about the legacy migration wizard,
and tests that specifically check the legacy dialog behaviour.
Differential Revision: https://phabricator.services.mozilla.com/D190716
2023-10-16 18:24:42 +00:00
|
|
|
);
|
|
|
|
return Promise.resolve();
|
|
|
|
};
|
|
|
|
|
|
|
|
if (aOptions.isStartupMigration) {
|
|
|
|
// Record that the uninstaller requested a profile refresh
|
|
|
|
if (Services.env.get("MOZ_UNINSTALLER_PROFILE_REFRESH")) {
|
|
|
|
Services.env.set("MOZ_UNINSTALLER_PROFILE_REFRESH", "");
|
2024-10-18 16:24:05 +00:00
|
|
|
Glean.migration.uninstallerProfileRefresh.set(true);
|
2023-01-31 15:30:57 +00:00
|
|
|
}
|
|
|
|
|
Bug 1855280 - Remove the ability to switch to the old migration wizard. r=kpatenio,omc-reviewers,settings-reviewers,credential-management-reviewers,negin,aminomancer,mtigley
This removes the pref to re-enable the legacy wizard, and all of the things that used
to read from it.
It also disables the ability to use the legacy wizard from about:welcome with the
aboutWelcomeBehavior feature.
It also removes the closeMigrationWizard utility from BrowserTestUtils, since that
effectively became a thin-wrapper around BrowserTestUtils.removeTab.
Finally, this patch also removes some documentation about the legacy migration wizard,
and tests that specifically check the legacy dialog behaviour.
Differential Revision: https://phabricator.services.mozilla.com/D190716
2023-10-16 18:24:42 +00:00
|
|
|
openStandaloneWindow(true /* blocking */);
|
2023-01-31 15:30:57 +00:00
|
|
|
return Promise.resolve();
|
|
|
|
}
|
2023-07-04 15:36:56 +00:00
|
|
|
|
Bug 1855280 - Remove the ability to switch to the old migration wizard. r=kpatenio,omc-reviewers,settings-reviewers,credential-management-reviewers,negin,aminomancer,mtigley
This removes the pref to re-enable the legacy wizard, and all of the things that used
to read from it.
It also disables the ability to use the legacy wizard from about:welcome with the
aboutWelcomeBehavior feature.
It also removes the closeMigrationWizard utility from BrowserTestUtils, since that
effectively became a thin-wrapper around BrowserTestUtils.removeTab.
Finally, this patch also removes some documentation about the legacy migration wizard,
and tests that specifically check the legacy dialog behaviour.
Differential Revision: https://phabricator.services.mozilla.com/D190716
2023-10-16 18:24:42 +00:00
|
|
|
if (aOpener?.openPreferences) {
|
|
|
|
if (aOptions.entrypoint == this.MIGRATION_ENTRYPOINTS.NEWTAB) {
|
|
|
|
if (aboutWelcomeBehavior == "autoclose") {
|
|
|
|
return aOpener.openPreferences("general-migrate-autoclose");
|
|
|
|
} else if (aboutWelcomeBehavior == "standalone") {
|
|
|
|
openStandaloneWindow(false /* blocking */);
|
|
|
|
return Promise.resolve();
|
|
|
|
}
|
2023-01-17 20:30:58 +00:00
|
|
|
}
|
Bug 1855280 - Remove the ability to switch to the old migration wizard. r=kpatenio,omc-reviewers,settings-reviewers,credential-management-reviewers,negin,aminomancer,mtigley
This removes the pref to re-enable the legacy wizard, and all of the things that used
to read from it.
It also disables the ability to use the legacy wizard from about:welcome with the
aboutWelcomeBehavior feature.
It also removes the closeMigrationWizard utility from BrowserTestUtils, since that
effectively became a thin-wrapper around BrowserTestUtils.removeTab.
Finally, this patch also removes some documentation about the legacy migration wizard,
and tests that specifically check the legacy dialog behaviour.
Differential Revision: https://phabricator.services.mozilla.com/D190716
2023-10-16 18:24:42 +00:00
|
|
|
return aOpener.openPreferences("general-migrate");
|
2022-11-30 21:21:25 +00:00
|
|
|
}
|
Bug 1855280 - Remove the ability to switch to the old migration wizard. r=kpatenio,omc-reviewers,settings-reviewers,credential-management-reviewers,negin,aminomancer,mtigley
This removes the pref to re-enable the legacy wizard, and all of the things that used
to read from it.
It also disables the ability to use the legacy wizard from about:welcome with the
aboutWelcomeBehavior feature.
It also removes the closeMigrationWizard utility from BrowserTestUtils, since that
effectively became a thin-wrapper around BrowserTestUtils.removeTab.
Finally, this patch also removes some documentation about the legacy migration wizard,
and tests that specifically check the legacy dialog behaviour.
Differential Revision: https://phabricator.services.mozilla.com/D190716
2023-10-16 18:24:42 +00:00
|
|
|
|
|
|
|
// If somehow we failed to open about:preferences, fall back to opening
|
|
|
|
// the top-level window.
|
|
|
|
openStandaloneWindow(false /* blocking */);
|
2023-01-31 15:30:57 +00:00
|
|
|
return Promise.resolve();
|
2022-12-06 17:50:39 +00:00
|
|
|
}
|
2012-05-28 09:43:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the migration wizard for startup-migration. This should only be
|
|
|
|
* called by ProfileMigrator (see ProfileMigrator.js), which implements
|
2018-01-12 17:06:21 +00:00
|
|
|
* nsIProfileMigrator. This runs asynchronously if we are running an
|
|
|
|
* automigration.
|
2012-05-28 09:43:59 +00:00
|
|
|
*
|
2022-12-06 17:50:38 +00:00
|
|
|
* @param {nsIProfileStartup} aProfileStartup
|
|
|
|
* the nsIProfileStartup instance provided to ProfileMigrator.migrate.
|
|
|
|
* @param {string|null} [aMigratorKey=null]
|
|
|
|
* If set, the migration wizard will import from the corresponding
|
|
|
|
* migrator, bypassing the source-selection page. Otherwise, the
|
|
|
|
* source-selection page will be displayed, either with the default
|
|
|
|
* browser selected, if it could be detected and if there is a
|
|
|
|
* migrator for it, or with the first option selected as a fallback
|
|
|
|
* @param {string|null} [aProfileToMigrate=null]
|
|
|
|
* If set, the migration wizard will import from the profile indicated.
|
|
|
|
* @throws
|
|
|
|
* if aMigratorKey is invalid or if it points to a non-existent
|
|
|
|
* source.
|
2012-05-28 09:43:59 +00:00
|
|
|
*/
|
2022-12-06 17:50:39 +00:00
|
|
|
startupMigration(aProfileStartup, aMigratorKey, aProfileToMigrate) {
|
2018-10-11 17:04:59 +00:00
|
|
|
this.spinResolve(
|
|
|
|
this.asyncStartupMigration(
|
|
|
|
aProfileStartup,
|
|
|
|
aMigratorKey,
|
|
|
|
aProfileToMigrate
|
2019-07-05 07:53:32 +00:00
|
|
|
)
|
2018-10-11 17:04:59 +00:00
|
|
|
);
|
2022-12-06 17:50:39 +00:00
|
|
|
}
|
2018-01-12 17:06:21 +00:00
|
|
|
|
2022-12-06 17:50:39 +00:00
|
|
|
async asyncStartupMigration(
|
2018-01-12 17:06:21 +00:00
|
|
|
aProfileStartup,
|
|
|
|
aMigratorKey,
|
|
|
|
aProfileToMigrate
|
|
|
|
) {
|
2012-05-28 09:43:59 +00:00
|
|
|
if (!aProfileStartup) {
|
|
|
|
throw new Error(
|
|
|
|
"an profile-startup instance is required for startup-migration"
|
|
|
|
);
|
2012-03-21 19:20:47 +00:00
|
|
|
}
|
2012-05-28 09:43:59 +00:00
|
|
|
gProfileStartup = aProfileStartup;
|
2012-03-21 19:20:47 +00:00
|
|
|
|
2022-12-13 17:01:25 +00:00
|
|
|
let skipSourceSelection = false,
|
2012-05-28 09:43:59 +00:00
|
|
|
migrator = null,
|
|
|
|
migratorKey = "";
|
|
|
|
if (aMigratorKey) {
|
2018-01-12 17:06:21 +00:00
|
|
|
migrator = await this.getMigrator(aMigratorKey);
|
2012-03-21 19:20:47 +00:00
|
|
|
if (!migrator) {
|
2012-05-28 09:43:59 +00:00
|
|
|
// aMigratorKey must point to a valid source, so, if it doesn't
|
|
|
|
// cleanup and throw.
|
|
|
|
this.finishMigration();
|
|
|
|
throw new Error(
|
|
|
|
"startMigration was asked to open auto-migrate from " +
|
|
|
|
"a non-existent source: " +
|
|
|
|
aMigratorKey
|
|
|
|
);
|
2012-03-21 19:20:47 +00:00
|
|
|
}
|
2012-05-28 09:43:59 +00:00
|
|
|
migratorKey = aMigratorKey;
|
2022-12-13 17:01:25 +00:00
|
|
|
skipSourceSelection = true;
|
2016-12-31 02:47:25 +00:00
|
|
|
} else {
|
2016-05-24 10:44:49 +00:00
|
|
|
let defaultBrowserKey = this.getMigratorKeyForDefaultBrowser();
|
2012-05-28 09:43:59 +00:00
|
|
|
if (defaultBrowserKey) {
|
2018-01-12 17:06:21 +00:00
|
|
|
migrator = await this.getMigrator(defaultBrowserKey);
|
2012-05-28 09:43:59 +00:00
|
|
|
if (migrator) {
|
|
|
|
migratorKey = defaultBrowserKey;
|
2019-07-05 07:53:32 +00:00
|
|
|
}
|
2012-03-21 19:20:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-14 10:42:15 +00:00
|
|
|
if (!migrator) {
|
2018-01-12 17:06:21 +00:00
|
|
|
let migrators = await Promise.all(
|
2022-12-06 17:50:39 +00:00
|
|
|
this.availableMigratorKeys.map(key => this.getMigrator(key))
|
2018-01-12 17:06:21 +00:00
|
|
|
);
|
2012-06-14 10:42:15 +00:00
|
|
|
// If there's no migrator set so far, ensure that there is at least one
|
|
|
|
// migrator available before opening the wizard.
|
2016-02-08 12:54:38 +00:00
|
|
|
// Note that we don't need to check the default browser first, because
|
|
|
|
// if that one existed we would have used it in the block above this one.
|
2018-01-12 17:06:21 +00:00
|
|
|
if (!migrators.some(m => m)) {
|
2016-02-08 12:54:38 +00:00
|
|
|
// None of the keys produced a usable migrator, so finish up here:
|
2012-06-14 10:42:15 +00:00
|
|
|
this.finishMigration();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-01 18:00:53 +00:00
|
|
|
let isRefresh =
|
2022-12-13 17:01:25 +00:00
|
|
|
migrator &&
|
|
|
|
skipSourceSelection &&
|
|
|
|
migratorKey == AppConstants.MOZ_APP_NAME;
|
2016-06-01 18:00:53 +00:00
|
|
|
|
2022-12-13 17:01:25 +00:00
|
|
|
let entrypoint = this.MIGRATION_ENTRYPOINTS.FIRSTRUN;
|
2016-06-01 18:00:53 +00:00
|
|
|
if (isRefresh) {
|
2022-12-13 17:01:25 +00:00
|
|
|
entrypoint = this.MIGRATION_ENTRYPOINTS.FXREFRESH;
|
2015-10-07 12:34:46 +00:00
|
|
|
}
|
2012-05-28 09:43:59 +00:00
|
|
|
|
2022-12-13 17:01:25 +00:00
|
|
|
this.showMigrationWizard(null, {
|
|
|
|
entrypoint,
|
2015-10-07 12:34:46 +00:00
|
|
|
migratorKey,
|
|
|
|
migrator,
|
2022-12-13 17:01:25 +00:00
|
|
|
isStartupMigration: !!aProfileStartup,
|
|
|
|
skipSourceSelection,
|
|
|
|
profileId: aProfileToMigrate,
|
|
|
|
});
|
2022-12-06 17:50:39 +00:00
|
|
|
}
|
2012-03-21 19:20:47 +00:00
|
|
|
|
2022-12-06 17:50:39 +00:00
|
|
|
/**
|
|
|
|
* This is only pseudo-private because some tests and helper functions
|
|
|
|
* still expect to be able to directly access it.
|
|
|
|
*/
|
|
|
|
_importQuantities = {
|
2016-10-22 13:40:48 +00:00
|
|
|
bookmarks: 0,
|
|
|
|
logins: 0,
|
|
|
|
history: 0,
|
2023-05-16 19:12:21 +00:00
|
|
|
cards: 0,
|
2023-06-22 13:48:51 +00:00
|
|
|
extensions: 0,
|
2022-12-06 17:50:39 +00:00
|
|
|
};
|
2016-10-22 13:40:48 +00:00
|
|
|
|
2020-10-20 15:28:28 +00:00
|
|
|
getImportedCount(type) {
|
|
|
|
if (!this._importQuantities.hasOwnProperty(type)) {
|
|
|
|
throw new Error(
|
|
|
|
`Unknown import data type "${type}" passed to getImportedCount`
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return this._importQuantities[type];
|
2022-12-06 17:50:39 +00:00
|
|
|
}
|
2020-10-20 15:28:28 +00:00
|
|
|
|
2016-10-22 13:40:48 +00:00
|
|
|
insertBookmarkWrapper(bookmark) {
|
|
|
|
this._importQuantities.bookmarks++;
|
2022-06-06 22:46:22 +00:00
|
|
|
let insertionPromise = lazy.PlacesUtils.bookmarks.insert(bookmark);
|
2016-11-30 11:48:03 +00:00
|
|
|
if (!gKeepUndoData) {
|
|
|
|
return insertionPromise;
|
|
|
|
}
|
|
|
|
// If we keep undo data, add a promise handler that stores the undo data once
|
|
|
|
// the bookmark has been inserted in the DB, and then returns the bookmark.
|
|
|
|
let { parentGuid } = bookmark;
|
|
|
|
return insertionPromise.then(bm => {
|
|
|
|
let { guid, lastModified, type } = bm;
|
|
|
|
gUndoData.get("bookmarks").push({
|
2018-01-22 23:22:35 +00:00
|
|
|
parentGuid,
|
|
|
|
guid,
|
|
|
|
lastModified,
|
|
|
|
type,
|
2016-11-30 11:48:03 +00:00
|
|
|
});
|
|
|
|
return bm;
|
|
|
|
});
|
2022-12-06 17:50:39 +00:00
|
|
|
}
|
2016-10-22 13:40:48 +00:00
|
|
|
|
2017-03-13 23:46:16 +00:00
|
|
|
insertManyBookmarksWrapper(bookmarks, parent) {
|
2022-06-06 22:46:22 +00:00
|
|
|
let insertionPromise = lazy.PlacesUtils.bookmarks.insertTree({
|
2017-03-13 23:46:16 +00:00
|
|
|
guid: parent,
|
|
|
|
children: bookmarks,
|
|
|
|
});
|
|
|
|
return insertionPromise.then(
|
|
|
|
insertedItems => {
|
|
|
|
this._importQuantities.bookmarks += insertedItems.length;
|
|
|
|
if (gKeepUndoData) {
|
|
|
|
let bmData = gUndoData.get("bookmarks");
|
|
|
|
for (let bm of insertedItems) {
|
|
|
|
let { parentGuid, guid, lastModified, type } = bm;
|
|
|
|
bmData.push({ parentGuid, guid, lastModified, type });
|
2019-07-05 07:53:32 +00:00
|
|
|
}
|
2017-03-13 23:46:16 +00:00
|
|
|
}
|
2022-11-22 15:30:56 +00:00
|
|
|
if (parent == lazy.PlacesUtils.bookmarks.toolbarGuid) {
|
|
|
|
lazy.PlacesUIUtils.maybeToggleBookmarkToolbarVisibility(
|
|
|
|
true /* aForceVisible */
|
2023-05-19 12:17:17 +00:00
|
|
|
).catch(console.error);
|
2022-11-22 15:30:56 +00:00
|
|
|
}
|
2017-03-13 23:46:16 +00:00
|
|
|
},
|
2023-01-20 17:49:21 +00:00
|
|
|
ex => console.error(ex)
|
2017-03-13 23:46:16 +00:00
|
|
|
);
|
2022-12-06 17:50:39 +00:00
|
|
|
}
|
2017-03-13 23:46:16 +00:00
|
|
|
|
2018-03-20 12:36:31 +00:00
|
|
|
insertVisitsWrapper(pageInfos) {
|
2019-01-29 12:06:05 +00:00
|
|
|
let now = new Date();
|
|
|
|
// Ensure that none of the dates are in the future. If they are, rewrite
|
|
|
|
// them to be now. This means we don't loose history entries, but they will
|
|
|
|
// be valid for the history store.
|
|
|
|
for (let pageInfo of pageInfos) {
|
|
|
|
for (let visit of pageInfo.visits) {
|
|
|
|
if (visit.date && visit.date > now) {
|
|
|
|
visit.date = now;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-03-20 12:36:31 +00:00
|
|
|
this._importQuantities.history += pageInfos.length;
|
2016-11-30 11:56:25 +00:00
|
|
|
if (gKeepUndoData) {
|
2022-12-06 17:50:39 +00:00
|
|
|
this.#updateHistoryUndo(pageInfos);
|
2016-11-30 11:56:25 +00:00
|
|
|
}
|
2022-06-06 22:46:22 +00:00
|
|
|
return lazy.PlacesUtils.history.insertMany(pageInfos);
|
2022-12-06 17:50:39 +00:00
|
|
|
}
|
2016-10-22 13:40:48 +00:00
|
|
|
|
2018-01-04 23:10:54 +00:00
|
|
|
async insertLoginsWrapper(logins) {
|
|
|
|
this._importQuantities.logins += logins.length;
|
2022-06-06 22:46:22 +00:00
|
|
|
let inserted = await lazy.LoginHelper.maybeImportLogins(logins);
|
2018-01-04 23:10:54 +00:00
|
|
|
// Note that this means that if we import a login that has a newer password
|
|
|
|
// than we know about, we will update the login, and an undo of the import
|
|
|
|
// will not revert this. This seems preferable over removing the login
|
|
|
|
// outright or storing the old password in the undo file.
|
|
|
|
if (gKeepUndoData) {
|
|
|
|
for (let { guid, timePasswordChanged } of inserted) {
|
|
|
|
gUndoData.get("logins").push({ guid, timePasswordChanged });
|
|
|
|
}
|
|
|
|
}
|
2022-12-06 17:50:39 +00:00
|
|
|
}
|
2018-01-04 23:10:54 +00:00
|
|
|
|
2022-11-03 22:34:18 +00:00
|
|
|
/**
|
|
|
|
* Iterates through the favicons, sniffs for a mime type,
|
|
|
|
* and uses the mime type to properly import the favicon.
|
2022-12-06 17:50:38 +00:00
|
|
|
*
|
2024-05-01 20:40:50 +00:00
|
|
|
* Note: You may not want to await on the returned promise, especially if by
|
|
|
|
* doing so there's risk of interrupting the migration of more critical
|
|
|
|
* data (e.g. bookmarks).
|
|
|
|
*
|
2022-12-06 17:50:38 +00:00
|
|
|
* @param {object[]} favicons
|
2022-11-03 22:34:18 +00:00
|
|
|
* An array of Objects with these properties:
|
|
|
|
* {Uint8Array} faviconData: The binary data of a favicon
|
|
|
|
* {nsIURI} uri: The URI of the associated page
|
|
|
|
*/
|
2024-05-01 20:40:50 +00:00
|
|
|
async insertManyFavicons(favicons) {
|
2022-11-03 22:34:18 +00:00
|
|
|
let sniffer = Cc["@mozilla.org/image/loader;1"].createInstance(
|
|
|
|
Ci.nsIContentSniffer
|
|
|
|
);
|
2024-05-01 20:40:50 +00:00
|
|
|
|
2022-11-03 22:34:18 +00:00
|
|
|
for (let faviconDataItem of favicons) {
|
2024-05-01 20:40:50 +00:00
|
|
|
try {
|
|
|
|
// getMIMETypeFromContent throws error if could not get the mime type
|
|
|
|
// from the data.
|
|
|
|
let mimeType = sniffer.getMIMETypeFromContent(
|
|
|
|
null,
|
|
|
|
faviconDataItem.faviconData,
|
|
|
|
faviconDataItem.faviconData.length
|
|
|
|
);
|
|
|
|
|
2024-10-08 02:27:16 +00:00
|
|
|
let dataURL = await new Promise((resolve, reject) => {
|
2024-05-01 20:40:50 +00:00
|
|
|
let buffer = new Uint8ClampedArray(faviconDataItem.faviconData);
|
|
|
|
let blob = new Blob([buffer], { type: mimeType });
|
|
|
|
let reader = new FileReader();
|
|
|
|
reader.addEventListener("load", () => resolve(reader.result));
|
|
|
|
reader.addEventListener("error", reject);
|
|
|
|
reader.readAsDataURL(blob);
|
|
|
|
});
|
2024-05-15 21:42:59 +00:00
|
|
|
|
|
|
|
let fakeFaviconURI = Services.io.newURI(
|
|
|
|
"fake-favicon-uri:" + faviconDataItem.uri.spec
|
|
|
|
);
|
2024-10-08 02:27:16 +00:00
|
|
|
lazy.PlacesUtils.favicons
|
|
|
|
.setFaviconForPage(
|
|
|
|
faviconDataItem.uri,
|
|
|
|
fakeFaviconURI,
|
|
|
|
Services.io.newURI(dataURL)
|
|
|
|
)
|
|
|
|
.catch(console.warn);
|
2024-05-01 20:40:50 +00:00
|
|
|
} catch (e) {
|
|
|
|
// Even if error happens for favicon, continue the process.
|
|
|
|
console.warn(e);
|
|
|
|
}
|
2022-11-03 22:34:18 +00:00
|
|
|
}
|
2022-12-06 17:50:39 +00:00
|
|
|
}
|
2022-11-03 22:34:18 +00:00
|
|
|
|
2023-05-16 19:12:21 +00:00
|
|
|
async insertCreditCardsWrapper(cards) {
|
|
|
|
this._importQuantities.cards += cards.length;
|
2023-05-26 11:36:33 +00:00
|
|
|
let { formAutofillStorage } = ChromeUtils.importESModule(
|
|
|
|
"resource://autofill/FormAutofillStorage.sys.mjs"
|
2023-05-16 19:12:21 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
await formAutofillStorage.initialize();
|
|
|
|
for (let card of cards) {
|
2023-05-25 20:16:04 +00:00
|
|
|
try {
|
|
|
|
await formAutofillStorage.creditCards.add(card);
|
|
|
|
} catch (e) {
|
|
|
|
console.error("Failed to insert credit card due to error: ", e, card);
|
|
|
|
}
|
2023-05-16 19:12:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Bug 1836773 - Support the new MigrationResource in the migration wizard. r=mconley,willdurand,fluent-reviewers,desktop-theme-reviewers,flod
Enables support for migrating extensions from Chrome once we have the
API to match and install extensions from the add-ons store.
Adds a new ProgressState object to delineate between various progress
states. This new object has four properties: value, message, linkURL,
and linkText. See migration-wizard-constants for more information.
MigrationWizard.#onShowingProgress uses the new ProgressState object
to handle the new LOADING, SUCCESS, ERROR and INFO values for progress.
This has the added benefit of updating the UI on error cases for the
existing resource groups.
Adds a new details object parameter to MigratorBase.migrate which is
currently used in the Chrome extensions import case.
See ChromeProfileMigrator.GetExtensionsResource for an example of
creating this details object.
See MigrationWizardParent.#doBrowserMigration for example usage of this
details object.
Adds support-text links under each resource type group in the markup.
This is currently used only by extensions in the partial matching and
no matching extensions cases.
Refactor MigrationUtils.installExtensionsWrapper to return an array
with the progress state (LOADING, SUCCESS, ERROR, INFO) and any
imported extensions.
Depends on D180005
Differential Revision: https://phabricator.services.mozilla.com/D180876
2023-06-21 20:24:56 +00:00
|
|
|
/**
|
2023-06-23 12:25:55 +00:00
|
|
|
* Responsible for calling the AddonManager API that ultimately installs the
|
|
|
|
* matched add-ons.
|
Bug 1836773 - Support the new MigrationResource in the migration wizard. r=mconley,willdurand,fluent-reviewers,desktop-theme-reviewers,flod
Enables support for migrating extensions from Chrome once we have the
API to match and install extensions from the add-ons store.
Adds a new ProgressState object to delineate between various progress
states. This new object has four properties: value, message, linkURL,
and linkText. See migration-wizard-constants for more information.
MigrationWizard.#onShowingProgress uses the new ProgressState object
to handle the new LOADING, SUCCESS, ERROR and INFO values for progress.
This has the added benefit of updating the UI on error cases for the
existing resource groups.
Adds a new details object parameter to MigratorBase.migrate which is
currently used in the Chrome extensions import case.
See ChromeProfileMigrator.GetExtensionsResource for an example of
creating this details object.
See MigrationWizardParent.#doBrowserMigration for example usage of this
details object.
Adds support-text links under each resource type group in the markup.
This is currently used only by extensions in the partial matching and
no matching extensions cases.
Refactor MigrationUtils.installExtensionsWrapper to return an array
with the progress state (LOADING, SUCCESS, ERROR, INFO) and any
imported extensions.
Depends on D180005
Differential Revision: https://phabricator.services.mozilla.com/D180876
2023-06-21 20:24:56 +00:00
|
|
|
*
|
2023-06-23 12:25:55 +00:00
|
|
|
* @param {string} migratorKey a migrator key that we pass to
|
|
|
|
* `AMBrowserExtensionsImport` as the "browser
|
|
|
|
* identifier" used to match add-ons
|
|
|
|
* @param {string[]} extensionIDs a list of extension IDs from another browser
|
2024-08-23 16:43:56 +00:00
|
|
|
* @returns {(lazy.MigrationWizardConstants.PROGRESS_VALUE|string[])[]}
|
|
|
|
* An array whose first element is a `MigrationWizardConstants.PROGRESS_VALUE`
|
|
|
|
* and second element is an array of imported add-on ids.
|
Bug 1836773 - Support the new MigrationResource in the migration wizard. r=mconley,willdurand,fluent-reviewers,desktop-theme-reviewers,flod
Enables support for migrating extensions from Chrome once we have the
API to match and install extensions from the add-ons store.
Adds a new ProgressState object to delineate between various progress
states. This new object has four properties: value, message, linkURL,
and linkText. See migration-wizard-constants for more information.
MigrationWizard.#onShowingProgress uses the new ProgressState object
to handle the new LOADING, SUCCESS, ERROR and INFO values for progress.
This has the added benefit of updating the UI on error cases for the
existing resource groups.
Adds a new details object parameter to MigratorBase.migrate which is
currently used in the Chrome extensions import case.
See ChromeProfileMigrator.GetExtensionsResource for an example of
creating this details object.
See MigrationWizardParent.#doBrowserMigration for example usage of this
details object.
Adds support-text links under each resource type group in the markup.
This is currently used only by extensions in the partial matching and
no matching extensions cases.
Refactor MigrationUtils.installExtensionsWrapper to return an array
with the progress state (LOADING, SUCCESS, ERROR, INFO) and any
imported extensions.
Depends on D180005
Differential Revision: https://phabricator.services.mozilla.com/D180876
2023-06-21 20:24:56 +00:00
|
|
|
*/
|
2023-06-23 12:25:55 +00:00
|
|
|
async installExtensionsWrapper(migratorKey, extensionIDs) {
|
|
|
|
const totalExtensions = extensionIDs.length;
|
|
|
|
|
|
|
|
let importedAddonIDs = [];
|
|
|
|
try {
|
|
|
|
const result = await lazy.AMBrowserExtensionsImport.stageInstalls(
|
|
|
|
migratorKey,
|
|
|
|
extensionIDs
|
|
|
|
);
|
|
|
|
importedAddonIDs = result.importedAddonIDs;
|
|
|
|
} catch (e) {
|
|
|
|
console.error(`Failed to import extensions: ${e}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
this._importQuantities.extensions += importedAddonIDs.length;
|
|
|
|
|
|
|
|
if (!importedAddonIDs.length) {
|
Bug 1836773 - Support the new MigrationResource in the migration wizard. r=mconley,willdurand,fluent-reviewers,desktop-theme-reviewers,flod
Enables support for migrating extensions from Chrome once we have the
API to match and install extensions from the add-ons store.
Adds a new ProgressState object to delineate between various progress
states. This new object has four properties: value, message, linkURL,
and linkText. See migration-wizard-constants for more information.
MigrationWizard.#onShowingProgress uses the new ProgressState object
to handle the new LOADING, SUCCESS, ERROR and INFO values for progress.
This has the added benefit of updating the UI on error cases for the
existing resource groups.
Adds a new details object parameter to MigratorBase.migrate which is
currently used in the Chrome extensions import case.
See ChromeProfileMigrator.GetExtensionsResource for an example of
creating this details object.
See MigrationWizardParent.#doBrowserMigration for example usage of this
details object.
Adds support-text links under each resource type group in the markup.
This is currently used only by extensions in the partial matching and
no matching extensions cases.
Refactor MigrationUtils.installExtensionsWrapper to return an array
with the progress state (LOADING, SUCCESS, ERROR, INFO) and any
imported extensions.
Depends on D180005
Differential Revision: https://phabricator.services.mozilla.com/D180876
2023-06-21 20:24:56 +00:00
|
|
|
return [
|
2023-06-28 16:46:19 +00:00
|
|
|
lazy.MigrationWizardConstants.PROGRESS_VALUE.WARNING,
|
2023-06-23 12:25:55 +00:00
|
|
|
importedAddonIDs,
|
Bug 1836773 - Support the new MigrationResource in the migration wizard. r=mconley,willdurand,fluent-reviewers,desktop-theme-reviewers,flod
Enables support for migrating extensions from Chrome once we have the
API to match and install extensions from the add-ons store.
Adds a new ProgressState object to delineate between various progress
states. This new object has four properties: value, message, linkURL,
and linkText. See migration-wizard-constants for more information.
MigrationWizard.#onShowingProgress uses the new ProgressState object
to handle the new LOADING, SUCCESS, ERROR and INFO values for progress.
This has the added benefit of updating the UI on error cases for the
existing resource groups.
Adds a new details object parameter to MigratorBase.migrate which is
currently used in the Chrome extensions import case.
See ChromeProfileMigrator.GetExtensionsResource for an example of
creating this details object.
See MigrationWizardParent.#doBrowserMigration for example usage of this
details object.
Adds support-text links under each resource type group in the markup.
This is currently used only by extensions in the partial matching and
no matching extensions cases.
Refactor MigrationUtils.installExtensionsWrapper to return an array
with the progress state (LOADING, SUCCESS, ERROR, INFO) and any
imported extensions.
Depends on D180005
Differential Revision: https://phabricator.services.mozilla.com/D180876
2023-06-21 20:24:56 +00:00
|
|
|
];
|
|
|
|
}
|
2023-06-23 12:25:55 +00:00
|
|
|
if (totalExtensions == importedAddonIDs.length) {
|
Bug 1836773 - Support the new MigrationResource in the migration wizard. r=mconley,willdurand,fluent-reviewers,desktop-theme-reviewers,flod
Enables support for migrating extensions from Chrome once we have the
API to match and install extensions from the add-ons store.
Adds a new ProgressState object to delineate between various progress
states. This new object has four properties: value, message, linkURL,
and linkText. See migration-wizard-constants for more information.
MigrationWizard.#onShowingProgress uses the new ProgressState object
to handle the new LOADING, SUCCESS, ERROR and INFO values for progress.
This has the added benefit of updating the UI on error cases for the
existing resource groups.
Adds a new details object parameter to MigratorBase.migrate which is
currently used in the Chrome extensions import case.
See ChromeProfileMigrator.GetExtensionsResource for an example of
creating this details object.
See MigrationWizardParent.#doBrowserMigration for example usage of this
details object.
Adds support-text links under each resource type group in the markup.
This is currently used only by extensions in the partial matching and
no matching extensions cases.
Refactor MigrationUtils.installExtensionsWrapper to return an array
with the progress state (LOADING, SUCCESS, ERROR, INFO) and any
imported extensions.
Depends on D180005
Differential Revision: https://phabricator.services.mozilla.com/D180876
2023-06-21 20:24:56 +00:00
|
|
|
return [
|
|
|
|
lazy.MigrationWizardConstants.PROGRESS_VALUE.SUCCESS,
|
2023-06-23 12:25:55 +00:00
|
|
|
importedAddonIDs,
|
Bug 1836773 - Support the new MigrationResource in the migration wizard. r=mconley,willdurand,fluent-reviewers,desktop-theme-reviewers,flod
Enables support for migrating extensions from Chrome once we have the
API to match and install extensions from the add-ons store.
Adds a new ProgressState object to delineate between various progress
states. This new object has four properties: value, message, linkURL,
and linkText. See migration-wizard-constants for more information.
MigrationWizard.#onShowingProgress uses the new ProgressState object
to handle the new LOADING, SUCCESS, ERROR and INFO values for progress.
This has the added benefit of updating the UI on error cases for the
existing resource groups.
Adds a new details object parameter to MigratorBase.migrate which is
currently used in the Chrome extensions import case.
See ChromeProfileMigrator.GetExtensionsResource for an example of
creating this details object.
See MigrationWizardParent.#doBrowserMigration for example usage of this
details object.
Adds support-text links under each resource type group in the markup.
This is currently used only by extensions in the partial matching and
no matching extensions cases.
Refactor MigrationUtils.installExtensionsWrapper to return an array
with the progress state (LOADING, SUCCESS, ERROR, INFO) and any
imported extensions.
Depends on D180005
Differential Revision: https://phabricator.services.mozilla.com/D180876
2023-06-21 20:24:56 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
return [
|
|
|
|
lazy.MigrationWizardConstants.PROGRESS_VALUE.INFO,
|
2023-06-23 12:25:55 +00:00
|
|
|
importedAddonIDs,
|
Bug 1836773 - Support the new MigrationResource in the migration wizard. r=mconley,willdurand,fluent-reviewers,desktop-theme-reviewers,flod
Enables support for migrating extensions from Chrome once we have the
API to match and install extensions from the add-ons store.
Adds a new ProgressState object to delineate between various progress
states. This new object has four properties: value, message, linkURL,
and linkText. See migration-wizard-constants for more information.
MigrationWizard.#onShowingProgress uses the new ProgressState object
to handle the new LOADING, SUCCESS, ERROR and INFO values for progress.
This has the added benefit of updating the UI on error cases for the
existing resource groups.
Adds a new details object parameter to MigratorBase.migrate which is
currently used in the Chrome extensions import case.
See ChromeProfileMigrator.GetExtensionsResource for an example of
creating this details object.
See MigrationWizardParent.#doBrowserMigration for example usage of this
details object.
Adds support-text links under each resource type group in the markup.
This is currently used only by extensions in the partial matching and
no matching extensions cases.
Refactor MigrationUtils.installExtensionsWrapper to return an array
with the progress state (LOADING, SUCCESS, ERROR, INFO) and any
imported extensions.
Depends on D180005
Differential Revision: https://phabricator.services.mozilla.com/D180876
2023-06-21 20:24:56 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2016-11-30 11:48:03 +00:00
|
|
|
initializeUndoData() {
|
|
|
|
gKeepUndoData = true;
|
2020-03-13 23:38:52 +00:00
|
|
|
gUndoData = new Map([
|
|
|
|
["bookmarks", []],
|
|
|
|
["visits", []],
|
|
|
|
["logins", []],
|
|
|
|
]);
|
2022-12-06 17:50:39 +00:00
|
|
|
}
|
2016-11-30 11:48:03 +00:00
|
|
|
|
2022-12-06 17:50:39 +00:00
|
|
|
async #postProcessUndoData(state) {
|
2016-11-30 11:48:03 +00:00
|
|
|
if (!state) {
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
let bookmarkFolders = state
|
|
|
|
.get("bookmarks")
|
2022-06-06 22:46:22 +00:00
|
|
|
.filter(b => b.type == lazy.PlacesUtils.bookmarks.TYPE_FOLDER);
|
2016-11-30 11:48:03 +00:00
|
|
|
|
|
|
|
let bookmarkFolderData = [];
|
|
|
|
let bmPromises = bookmarkFolders.map(({ guid }) => {
|
|
|
|
// Ignore bookmarks where the promise doesn't resolve (ie that are missing)
|
|
|
|
// Also check that the bookmark fetch returns isn't null before adding it.
|
2022-06-06 22:46:22 +00:00
|
|
|
return lazy.PlacesUtils.bookmarks.fetch(guid).then(
|
2020-03-13 23:38:52 +00:00
|
|
|
bm => bm && bookmarkFolderData.push(bm),
|
|
|
|
() => {}
|
|
|
|
);
|
2016-11-30 11:48:03 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
await Promise.all(bmPromises);
|
|
|
|
let folderLMMap = new Map(
|
|
|
|
bookmarkFolderData.map(b => [b.guid, b.lastModified])
|
|
|
|
);
|
|
|
|
for (let bookmark of bookmarkFolders) {
|
|
|
|
let lastModified = folderLMMap.get(bookmark.guid);
|
|
|
|
// If the bookmark was deleted, the map will be returning null, so check:
|
|
|
|
if (lastModified) {
|
|
|
|
bookmark.lastModified = lastModified;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return state;
|
2022-12-06 17:50:39 +00:00
|
|
|
}
|
2016-11-30 11:48:03 +00:00
|
|
|
|
|
|
|
stopAndRetrieveUndoData() {
|
|
|
|
let undoData = gUndoData;
|
|
|
|
gUndoData = null;
|
|
|
|
gKeepUndoData = false;
|
2022-12-06 17:50:39 +00:00
|
|
|
return this.#postProcessUndoData(undoData);
|
|
|
|
}
|
2016-11-30 11:48:03 +00:00
|
|
|
|
2022-12-06 17:50:39 +00:00
|
|
|
#updateHistoryUndo(pageInfos) {
|
2016-11-30 11:56:25 +00:00
|
|
|
let visits = gUndoData.get("visits");
|
|
|
|
let visitMap = new Map(visits.map(v => [v.url, v]));
|
2018-03-20 12:36:31 +00:00
|
|
|
for (let pageInfo of pageInfos) {
|
|
|
|
let visitCount = pageInfo.visits.length;
|
2017-02-20 16:06:27 +00:00
|
|
|
let first, last;
|
|
|
|
if (visitCount > 1) {
|
2018-03-20 12:36:31 +00:00
|
|
|
let dates = pageInfo.visits.map(v => v.date);
|
|
|
|
first = Math.min.apply(Math, dates);
|
|
|
|
last = Math.max.apply(Math, dates);
|
2017-02-20 16:06:27 +00:00
|
|
|
} else {
|
2018-03-20 12:36:31 +00:00
|
|
|
first = last = pageInfo.visits[0].date;
|
2017-02-20 16:06:27 +00:00
|
|
|
}
|
2018-03-20 12:36:31 +00:00
|
|
|
let url = pageInfo.url;
|
|
|
|
if (url instanceof Ci.nsIURI) {
|
|
|
|
url = pageInfo.url.spec;
|
|
|
|
} else if (typeof url != "string") {
|
|
|
|
pageInfo.url.href;
|
|
|
|
}
|
|
|
|
|
2016-11-30 11:56:25 +00:00
|
|
|
try {
|
|
|
|
new URL(url);
|
|
|
|
} catch (ex) {
|
|
|
|
// This won't save and we won't need to 'undo' it, so ignore this URL.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!visitMap.has(url)) {
|
|
|
|
visitMap.set(url, { url, visitCount, first, last });
|
|
|
|
} else {
|
|
|
|
let currentData = visitMap.get(url);
|
|
|
|
currentData.visitCount += visitCount;
|
|
|
|
currentData.first = Math.min(currentData.first, first);
|
|
|
|
currentData.last = Math.max(currentData.last, last);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gUndoData.set("visits", Array.from(visitMap.values()));
|
2022-12-06 17:50:39 +00:00
|
|
|
}
|
2016-11-30 11:56:25 +00:00
|
|
|
|
2012-03-21 19:20:47 +00:00
|
|
|
/**
|
|
|
|
* Cleans up references to migrators and nsIProfileInstance instances.
|
|
|
|
*/
|
2022-12-06 17:50:39 +00:00
|
|
|
finishMigration() {
|
2012-03-21 19:20:47 +00:00
|
|
|
gMigrators = null;
|
|
|
|
gProfileStartup = null;
|
2020-06-02 06:46:09 +00:00
|
|
|
gL10n = null;
|
2022-12-06 17:50:39 +00:00
|
|
|
}
|
2022-12-06 14:46:42 +00:00
|
|
|
|
2022-12-06 17:50:39 +00:00
|
|
|
get availableMigratorKeys() {
|
2022-12-13 17:01:24 +00:00
|
|
|
return [...this.#migrators.keys()];
|
2022-12-06 17:50:39 +00:00
|
|
|
}
|
2022-12-06 14:46:42 +00:00
|
|
|
|
2023-04-13 20:15:03 +00:00
|
|
|
get availableFileMigrators() {
|
|
|
|
return [...this.#fileMigrators.values()];
|
|
|
|
}
|
|
|
|
|
2022-12-06 17:50:39 +00:00
|
|
|
/**
|
|
|
|
* Enum for the entrypoint that is being used to start migration.
|
|
|
|
* Callers can use the MIGRATION_ENTRYPOINTS getter to use these.
|
|
|
|
*
|
2023-10-23 16:08:06 +00:00
|
|
|
* These values are what's written into the
|
|
|
|
* FX_MIGRATION_ENTRY_POINT_CATEGORICAL histogram after a migration.
|
2022-12-06 17:50:39 +00:00
|
|
|
*
|
|
|
|
* @see MIGRATION_ENTRYPOINTS
|
|
|
|
* @readonly
|
2023-10-23 16:08:06 +00:00
|
|
|
* @enum {string}
|
2022-12-06 17:50:39 +00:00
|
|
|
*/
|
|
|
|
#MIGRATION_ENTRYPOINTS_ENUM = Object.freeze({
|
|
|
|
/** The entrypoint was not supplied */
|
2023-03-20 19:45:34 +00:00
|
|
|
UNKNOWN: "unknown",
|
2022-12-06 17:50:39 +00:00
|
|
|
|
|
|
|
/** Migration is occurring at startup */
|
2023-03-20 19:45:34 +00:00
|
|
|
FIRSTRUN: "firstrun",
|
2022-12-06 17:50:39 +00:00
|
|
|
|
|
|
|
/** Migration is occurring at after a profile refresh */
|
2023-03-20 19:45:34 +00:00
|
|
|
FXREFRESH: "fxrefresh",
|
2022-12-06 17:50:39 +00:00
|
|
|
|
|
|
|
/** Migration is being started from the Library window */
|
2023-03-20 19:45:34 +00:00
|
|
|
PLACES: "places",
|
2022-12-06 17:50:39 +00:00
|
|
|
|
|
|
|
/** Migration is being started from our password management UI */
|
2023-03-20 19:45:34 +00:00
|
|
|
PASSWORDS: "passwords",
|
2022-12-06 17:50:39 +00:00
|
|
|
|
|
|
|
/** Migration is being started from the default about:home/about:newtab */
|
2023-03-20 19:45:34 +00:00
|
|
|
NEWTAB: "newtab",
|
2022-12-06 14:46:42 +00:00
|
|
|
|
2022-12-06 17:50:39 +00:00
|
|
|
/** Migration is being started from the File menu */
|
2023-03-20 19:45:34 +00:00
|
|
|
FILE_MENU: "file_menu",
|
2022-12-06 17:50:39 +00:00
|
|
|
|
|
|
|
/** Migration is being started from the Help menu */
|
2023-03-20 19:45:34 +00:00
|
|
|
HELP_MENU: "help_menu",
|
2022-12-06 17:50:39 +00:00
|
|
|
|
|
|
|
/** Migration is being started from the Bookmarks Toolbar */
|
2023-03-20 19:45:34 +00:00
|
|
|
BOOKMARKS_TOOLBAR: "bookmarks_toolbar",
|
2023-03-15 00:35:16 +00:00
|
|
|
|
|
|
|
/** Migration is being started from about:preferences */
|
2023-03-20 19:45:34 +00:00
|
|
|
PREFERENCES: "preferences",
|
2023-07-18 13:42:11 +00:00
|
|
|
|
2024-01-04 15:40:22 +00:00
|
|
|
/** Migration is being started from about:firefoxview */
|
2023-07-18 13:42:11 +00:00
|
|
|
FIREFOX_VIEW: "firefox_view",
|
2022-12-06 17:50:39 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an enum that should be used to record the entrypoint for
|
|
|
|
* starting a migration.
|
|
|
|
*
|
|
|
|
* @returns {number}
|
|
|
|
*/
|
|
|
|
get MIGRATION_ENTRYPOINTS() {
|
|
|
|
return this.#MIGRATION_ENTRYPOINTS_ENUM;
|
|
|
|
}
|
|
|
|
|
2023-03-20 19:45:34 +00:00
|
|
|
/**
|
2023-10-23 16:08:06 +00:00
|
|
|
* Enum for the numeric value written to the FX_MIGRATION_SOURCE_BROWSER.
|
|
|
|
* histogram
|
2022-12-06 17:50:39 +00:00
|
|
|
*
|
|
|
|
* @see getSourceIdForTelemetry
|
|
|
|
* @readonly
|
|
|
|
* @enum {number}
|
|
|
|
*/
|
|
|
|
#SOURCE_NAME_TO_ID_MAPPING_ENUM = Object.freeze({
|
2015-10-07 12:34:46 +00:00
|
|
|
nothing: 1,
|
|
|
|
firefox: 2,
|
|
|
|
edge: 3,
|
|
|
|
ie: 4,
|
|
|
|
chrome: 5,
|
2020-01-10 21:13:50 +00:00
|
|
|
"chrome-beta": 5,
|
|
|
|
"chrome-dev": 5,
|
2015-10-07 12:34:46 +00:00
|
|
|
chromium: 6,
|
|
|
|
canary: 7,
|
|
|
|
safari: 8,
|
2021-12-22 10:48:49 +00:00
|
|
|
"chromium-360se": 9,
|
2020-01-22 18:35:11 +00:00
|
|
|
"chromium-edge": 10,
|
2020-01-10 21:40:30 +00:00
|
|
|
"chromium-edge-beta": 10,
|
2021-11-23 05:26:09 +00:00
|
|
|
brave: 11,
|
2022-11-01 15:58:29 +00:00
|
|
|
opera: 12,
|
2022-12-01 14:49:38 +00:00
|
|
|
"opera-gx": 14,
|
2022-11-14 18:02:21 +00:00
|
|
|
vivaldi: 13,
|
2022-12-06 17:50:39 +00:00
|
|
|
});
|
|
|
|
|
2015-10-07 12:34:46 +00:00
|
|
|
getSourceIdForTelemetry(sourceName) {
|
2022-12-06 17:50:39 +00:00
|
|
|
return this.#SOURCE_NAME_TO_ID_MAPPING_ENUM[sourceName] || 0;
|
|
|
|
}
|
2023-03-21 15:18:34 +00:00
|
|
|
|
|
|
|
get HISTORY_MAX_AGE_IN_MILLISECONDS() {
|
|
|
|
return this.HISTORY_MAX_AGE_IN_DAYS * 24 * 60 * 60 * 1000;
|
|
|
|
}
|
2023-10-11 20:09:21 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Determines whether or not the underlying platform supports creating
|
|
|
|
* native file pickers that can do folder selection, which is a
|
|
|
|
* pre-requisite for getting read-access permissions for data from other
|
|
|
|
* browsers that we can import from.
|
|
|
|
*
|
|
|
|
* @returns {Promise<boolean>}
|
|
|
|
*/
|
|
|
|
canGetPermissionsOnPlatform() {
|
|
|
|
return lazy.gCanGetPermissionsOnPlatformPromise;
|
|
|
|
}
|
2022-12-06 17:50:39 +00:00
|
|
|
}
|
2022-12-06 14:46:42 +00:00
|
|
|
|
2022-12-06 17:50:39 +00:00
|
|
|
const MigrationUtilsSingleton = new MigrationUtils();
|
|
|
|
|
|
|
|
export { MigrationUtilsSingleton as MigrationUtils };
|