Add the import wizard to settings, fix Chromium Edge

This commit is contained in:
ownedbywuigi 2026-04-01 18:01:58 +01:00
commit 78baea7a1d
6 changed files with 116 additions and 9 deletions

View file

@ -55,6 +55,27 @@ function getDataFolder(subfoldersWin, subfoldersOSX, subfoldersUnix) {
return FileUtils.getDir(dirServiceID, subfolders, false);
}
function getChromiumEdgeDataFolder() {
if (AppConstants.platform != "win") {
return null;
}
// Probe all common Edge Chromium channels so migration appears even when
// users run Beta/Dev/Canary instead of Stable.
let microsoftDir = FileUtils.getDir("LocalAppData", ["Microsoft"], false);
let channelFolders = ["Edge", "Edge Beta", "Edge Dev", "Edge SxS"];
for (let channelFolder of channelFolders) {
let candidate = microsoftDir.clone();
candidate.append(channelFolder);
candidate.append("User Data");
if (candidate.exists() && candidate.isReadable() && candidate.isDirectory()) {
return candidate;
}
}
return null;
}
/**
* Convert Chrome time format to Date object
*
@ -541,10 +562,8 @@ var componentsArray = [ChromeProfileMigrator, ChromiumProfileMigrator];
* Chromium Edge migration
**/
function ChromiumEdgeProfileMigrator() {
let edgeUserDataFolder = getDataFolder(["Microsoft", "Edge"],
["Microsoft Edge"],
["microsoft-edge"]);
this._chromeUserDataFolder = edgeUserDataFolder.exists() ? edgeUserDataFolder : null;
let edgeUserDataFolder = getChromiumEdgeDataFolder();
this._chromeUserDataFolder = edgeUserDataFolder;
}
ChromiumEdgeProfileMigrator.prototype = Object.create(ChromeProfileMigrator.prototype);
@ -552,6 +571,69 @@ ChromiumEdgeProfileMigrator.prototype.classDescription = "Chromium Edge Profile
ChromiumEdgeProfileMigrator.prototype.contractID = "@mozilla.org/profile/migrator;1?app=browser&type=chromiumedge";
ChromiumEdgeProfileMigrator.prototype.classID = Components.ID("{a3380b9d-ef2f-4a5f-84d9-df2e8a90b06d}");
ChromiumEdgeProfileMigrator.prototype.getResources = function(aProfile) {
if (!this._chromeUserDataFolder || !aProfile) {
return [];
}
let profileFolder = this._chromeUserDataFolder.clone();
profileFolder.append(aProfile.id);
if (!profileFolder.exists() || !profileFolder.isDirectory()) {
return [];
}
let possibleResources = [
GetBookmarksResource(profileFolder),
GetHistoryResource(profileFolder),
GetCookiesResource(profileFolder),
];
// Newer Edge stores cookies under the profile's Network subfolder.
if (!possibleResources[2]) {
let networkFolder = profileFolder.clone();
networkFolder.append("Network");
possibleResources[2] = GetCookiesResource(networkFolder);
}
if (AppConstants.platform == "win") {
possibleResources.push(GetWindowsPasswordsResource(profileFolder));
}
return possibleResources.filter(r => r != null);
};
Object.defineProperty(ChromiumEdgeProfileMigrator.prototype, "sourceProfiles", {
get: function() {
if ("__sourceProfiles" in this) {
return this.__sourceProfiles;
}
if (!this._chromeUserDataFolder) {
return [];
}
let profiles = [];
let entries = this._chromeUserDataFolder.directoryEntries;
while (entries.hasMoreElements()) {
let entry = entries.getNext().QueryInterface(Ci.nsIFile);
if (!entry.isDirectory()) {
continue;
}
let name = entry.leafName;
if (name == "Default" || name.startsWith("Profile ")) {
profiles.push({ id: name, name });
}
}
this.__sourceProfiles = profiles.filter(profile => {
let resources = this.getResources(profile);
return resources && resources.length > 0;
});
return this.__sourceProfiles;
}
});
if (AppConstants.platform == "win") {
componentsArray.push(ChromiumEdgeProfileMigrator);
}

View file

@ -688,7 +688,7 @@ this.MigrationUtils = Object.freeze({
// Canary uses the same description as Chrome so we can't distinguish them.
const APP_DESC_TO_KEY = {
"Internet Explorer": "ie",
"Microsoft Edge": "edge",
"Microsoft Edge": "chromiumedge",
"Safari": "safari",
"Basilisk": "firefox",
"Firefox": "firefox",

View file

@ -5,6 +5,7 @@
Components.utils.import("resource://gre/modules/Downloads.jsm");
Components.utils.import("resource://gre/modules/FileUtils.jsm");
Components.utils.import("resource://gre/modules/Task.jsm");
Components.utils.import("resource:///modules/MigrationUtils.jsm");
Components.utils.import("resource:///modules/ShellService.jsm");
Components.utils.import("resource:///modules/TransientPrefs.jsm");
@ -75,6 +76,8 @@ var gMainPane = {
gMainPane.setHomePageToBookmark);
setEventListener("restoreDefaultHomePage", "command",
gMainPane.restoreDefaultHomePage);
setEventListener("openMigrationWizard", "command",
gMainPane.openMigrationWizard);
setEventListener("chooseFolder", "command",
gMainPane.chooseFolder);
@ -244,6 +247,11 @@ var gMainPane = {
homePage.value = homePage.defaultValue;
},
openMigrationWizard: function ()
{
MigrationUtils.showMigrationWizard(window, [MigrationUtils.MIGRATION_ENTRYPOINT_PLACES]);
},
// DOWNLOADS
/*

View file

@ -244,6 +244,20 @@
</radiogroup>
</groupbox>
<!-- Import -->
<groupbox id="importGroup"
data-category="paneGeneral"
hidden="true">
<caption><label>&importGroup.label;</label></caption>
<hbox>
<button id="openMigrationWizard"
class="content-cell-item"
label="&importBrowserData.label;"
accesskey="&importBrowserData.accesskey;"/>
</hbox>
</groupbox>
<!-- Tab preferences -->
<groupbox data-category="paneGeneral"
hidden="true" align="start">

View file

@ -10,10 +10,10 @@
<!ENTITY importFromIE.label "Microsoft Internet Explorer">
<!ENTITY importFromIE.accesskey "M">
<!ENTITY importFromEdge.label "Microsoft Edge">
<!ENTITY importFromEdge.accesskey "E">
<!ENTITY importFromChromiumEdge.label "Chromium Edge">
<!ENTITY importFromChromiumEdge.accesskey "h">
<!ENTITY importFromEdge.label "Microsoft Edge (old)">
<!ENTITY importFromEdge.accesskey "O">
<!ENTITY importFromChromiumEdge.label "Microsoft Edge (new)">
<!ENTITY importFromChromiumEdge.accesskey "N">
<!ENTITY importFromNothing.label "Dont import anything">
<!ENTITY importFromNothing.accesskey "D">
<!ENTITY importFromSafari.label "Safari">

View file

@ -19,8 +19,11 @@
<!ENTITY chooseBookmark.accesskey "B">
<!ENTITY restoreDefault.label "Restore to Default">
<!ENTITY restoreDefault.accesskey "R">
<!ENTITY importBrowserData.label "Import Browser Data…">
<!ENTITY importBrowserData.accesskey "I">
<!ENTITY downloads.label "Downloads">
<!ENTITY importGroup.label "Import">
<!ENTITY saveTo.label "Save files to">
<!ENTITY saveTo.accesskey "v">