mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-08-15 08:53:07 +09:00
Add the import wizard to settings, fix Chromium Edge
This commit is contained in:
parent
75af6c218d
commit
78baea7a1d
6 changed files with 116 additions and 9 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -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">
|
||||
|
|
|
|||
|
|
@ -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 "Don’t import anything">
|
||||
<!ENTITY importFromNothing.accesskey "D">
|
||||
<!ENTITY importFromSafari.label "Safari">
|
||||
|
|
|
|||
|
|
@ -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">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue