зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1672486 - Remove browser.toolbars.bookmarks.2h2020 pref in migration r=mak
Depends on D127589 Differential Revision: https://phabricator.services.mozilla.com/D127590
This commit is contained in:
Родитель
94e39dce35
Коммит
0081d252a0
|
@ -12,7 +12,6 @@ const { FileUtils } = ChromeUtils.import(
|
|||
"resource://gre/modules/FileUtils.jsm"
|
||||
);
|
||||
const { OS } = ChromeUtils.import("resource://gre/modules/osfile.jsm");
|
||||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
const { MigrationUtils, MigratorPrototype } = ChromeUtils.import(
|
||||
"resource:///modules/MigrationUtils.jsm"
|
||||
);
|
||||
|
@ -202,18 +201,6 @@ Bookmarks.prototype = {
|
|||
|
||||
if (toolbarBMs.length) {
|
||||
let parentGuid = PlacesUtils.bookmarks.toolbarGuid;
|
||||
if (
|
||||
!Services.prefs.getBoolPref("browser.toolbars.bookmarks.2h2020") &&
|
||||
!MigrationUtils.isStartupMigration &&
|
||||
PlacesUtils.getChildCountForFolder(
|
||||
PlacesUtils.bookmarks.toolbarGuid
|
||||
) > PlacesUIUtils.NUM_TOOLBAR_BOOKMARKS_TO_UNHIDE
|
||||
) {
|
||||
parentGuid = await MigrationUtils.createImportedBookmarksFolder(
|
||||
"360se",
|
||||
parentGuid
|
||||
);
|
||||
}
|
||||
await MigrationUtils.insertManyBookmarksWrapper(toolbarBMs, parentGuid);
|
||||
PlacesUIUtils.maybeToggleBookmarkToolbarVisibilityAfterMigration();
|
||||
}
|
||||
|
|
|
@ -108,11 +108,8 @@ ChromeProfileMigrator.prototype.getResources = async function Chrome_getResource
|
|||
if (chromeUserDataPath) {
|
||||
let profileFolder = OS.Path.join(chromeUserDataPath, aProfile.id);
|
||||
if (await OS.File.exists(profileFolder)) {
|
||||
let localePropertySuffix = MigrationUtils._getLocalePropertyForBrowser(
|
||||
this.getBrowserKey()
|
||||
).replace(/^source-name-/, "");
|
||||
let possibleResourcePromises = [
|
||||
GetBookmarksResource(profileFolder, localePropertySuffix),
|
||||
GetBookmarksResource(profileFolder),
|
||||
GetHistoryResource(profileFolder),
|
||||
GetCookiesResource(profileFolder),
|
||||
];
|
||||
|
@ -214,7 +211,7 @@ Object.defineProperty(ChromeProfileMigrator.prototype, "sourceLocked", {
|
|||
},
|
||||
});
|
||||
|
||||
async function GetBookmarksResource(aProfileFolder, aLocalePropertySuffix) {
|
||||
async function GetBookmarksResource(aProfileFolder) {
|
||||
let bookmarksPath = OS.Path.join(aProfileFolder, "Bookmarks");
|
||||
if (!(await OS.File.exists(bookmarksPath))) {
|
||||
return null;
|
||||
|
@ -243,18 +240,6 @@ async function GetBookmarksResource(aProfileFolder, aLocalePropertySuffix) {
|
|||
roots.bookmark_bar.children,
|
||||
errorGatherer
|
||||
);
|
||||
if (
|
||||
!Services.prefs.getBoolPref("browser.toolbars.bookmarks.2h2020") &&
|
||||
!MigrationUtils.isStartupMigration &&
|
||||
PlacesUtils.getChildCountForFolder(
|
||||
PlacesUtils.bookmarks.toolbarGuid
|
||||
) > PlacesUIUtils.NUM_TOOLBAR_BOOKMARKS_TO_UNHIDE
|
||||
) {
|
||||
parentGuid = await MigrationUtils.createImportedBookmarksFolder(
|
||||
aLocalePropertySuffix,
|
||||
parentGuid
|
||||
);
|
||||
}
|
||||
await MigrationUtils.insertManyBookmarksWrapper(
|
||||
bookmarks,
|
||||
parentGuid
|
||||
|
@ -267,17 +252,6 @@ async function GetBookmarksResource(aProfileFolder, aLocalePropertySuffix) {
|
|||
// Bookmark menu
|
||||
let parentGuid = PlacesUtils.bookmarks.menuGuid;
|
||||
let bookmarks = convertBookmarks(roots.other.children, errorGatherer);
|
||||
if (
|
||||
!Services.prefs.getBoolPref("browser.toolbars.bookmarks.2h2020") &&
|
||||
!MigrationUtils.isStartupMigration &&
|
||||
PlacesUtils.getChildCountForFolder(PlacesUtils.bookmarks.menuGuid) >
|
||||
PlacesUIUtils.NUM_TOOLBAR_BOOKMARKS_TO_UNHIDE
|
||||
) {
|
||||
parentGuid = await MigrationUtils.createImportedBookmarksFolder(
|
||||
aLocalePropertySuffix,
|
||||
parentGuid
|
||||
);
|
||||
}
|
||||
await MigrationUtils.insertManyBookmarksWrapper(
|
||||
bookmarks,
|
||||
parentGuid
|
||||
|
|
|
@ -8,7 +8,6 @@ const { AppConstants } = ChromeUtils.import(
|
|||
"resource://gre/modules/AppConstants.jsm"
|
||||
);
|
||||
const { OS } = ChromeUtils.import("resource://gre/modules/osfile.jsm");
|
||||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
const { XPCOMUtils } = ChromeUtils.import(
|
||||
"resource://gre/modules/XPCOMUtils.jsm"
|
||||
);
|
||||
|
@ -397,32 +396,10 @@ EdgeBookmarksMigrator.prototype = {
|
|||
let { toplevelBMs, toolbarBMs } = this._fetchBookmarksFromDB();
|
||||
if (toplevelBMs.length) {
|
||||
let parentGuid = PlacesUtils.bookmarks.menuGuid;
|
||||
if (
|
||||
!Services.prefs.getBoolPref("browser.toolbars.bookmarks.2h2020") &&
|
||||
!MigrationUtils.isStartupMigration &&
|
||||
PlacesUtils.getChildCountForFolder(parentGuid) >
|
||||
PlacesUIUtils.NUM_TOOLBAR_BOOKMARKS_TO_UNHIDE
|
||||
) {
|
||||
parentGuid = await MigrationUtils.createImportedBookmarksFolder(
|
||||
"Edge",
|
||||
parentGuid
|
||||
);
|
||||
}
|
||||
await MigrationUtils.insertManyBookmarksWrapper(toplevelBMs, parentGuid);
|
||||
}
|
||||
if (toolbarBMs.length) {
|
||||
let parentGuid = PlacesUtils.bookmarks.toolbarGuid;
|
||||
if (
|
||||
!Services.prefs.getBoolPref("browser.toolbars.bookmarks.2h2020") &&
|
||||
!MigrationUtils.isStartupMigration &&
|
||||
PlacesUtils.getChildCountForFolder(parentGuid) >
|
||||
PlacesUIUtils.NUM_TOOLBAR_BOOKMARKS_TO_UNHIDE
|
||||
) {
|
||||
parentGuid = await MigrationUtils.createImportedBookmarksFolder(
|
||||
"Edge",
|
||||
parentGuid
|
||||
);
|
||||
}
|
||||
await MigrationUtils.insertManyBookmarksWrapper(toolbarBMs, parentGuid);
|
||||
PlacesUIUtils.maybeToggleBookmarkToolbarVisibilityAfterMigration();
|
||||
}
|
||||
|
|
|
@ -431,17 +431,6 @@ Bookmarks.prototype = {
|
|||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
!Services.prefs.getBoolPref("browser.toolbars.bookmarks.2h2020") &&
|
||||
!MigrationUtils.isStartupMigration &&
|
||||
PlacesUtils.getChildCountForFolder(aDestFolderGuid) >
|
||||
PlacesUIUtils.NUM_TOOLBAR_BOOKMARKS_TO_UNHIDE
|
||||
) {
|
||||
aDestFolderGuid = await MigrationUtils.createImportedBookmarksFolder(
|
||||
this.importedAppLabel,
|
||||
aDestFolderGuid
|
||||
);
|
||||
}
|
||||
await MigrationUtils.insertManyBookmarksWrapper(bookmarks, aDestFolderGuid);
|
||||
},
|
||||
|
||||
|
|
|
@ -603,64 +603,6 @@ var MigrationUtils = Object.seal({
|
|||
return l10n.formatValue(aKey, aArgs);
|
||||
},
|
||||
|
||||
_getLocalePropertyForBrowser(browserId) {
|
||||
switch (browserId) {
|
||||
case "chromium-edge":
|
||||
case "edge":
|
||||
return "source-name-edge";
|
||||
case "ie":
|
||||
return "source-name-ie";
|
||||
case "safari":
|
||||
return "source-name-safari";
|
||||
case "canary":
|
||||
return "source-name-canary";
|
||||
case "chrome":
|
||||
return "source-name-chrome";
|
||||
case "chrome-beta":
|
||||
return "source-name-chrome-beta";
|
||||
case "chrome-dev":
|
||||
return "source-name-chrome-dev";
|
||||
case "chromium":
|
||||
return "source-name-chromium";
|
||||
case "chromium-edge-beta":
|
||||
return "source-name-chromium-edge-beta";
|
||||
case "firefox":
|
||||
return "source-name-firefox";
|
||||
case "360se":
|
||||
return "source-name-360se";
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Helper for creating a folder for imported bookmarks from a particular
|
||||
* migration source. The folder is created at the end of the given folder.
|
||||
*
|
||||
* @param sourceNameStr
|
||||
* the source name (first letter capitalized). This is used
|
||||
* for reading the localized source name from the migration
|
||||
* bundle (e.g. if aSourceNameStr is Mosaic, this will try to read
|
||||
* sourceNameMosaic from the migration bundle).
|
||||
* @param parentGuid
|
||||
* the GUID of the folder in which the new folder should be created.
|
||||
* @return the GUID of the new folder.
|
||||
*/
|
||||
async createImportedBookmarksFolder(sourceNameStr, parentGuid) {
|
||||
let source = await this.getLocalizedString(
|
||||
"source-name-" + sourceNameStr.toLowerCase()
|
||||
);
|
||||
let title = await this.getLocalizedString("imported-bookmarks-source", {
|
||||
source,
|
||||
});
|
||||
return (
|
||||
await PlacesUtils.bookmarks.insert({
|
||||
type: PlacesUtils.bookmarks.TYPE_FOLDER,
|
||||
parentGuid,
|
||||
title,
|
||||
})
|
||||
).guid;
|
||||
},
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
|
|
@ -8,7 +8,6 @@ const { FileUtils } = ChromeUtils.import(
|
|||
"resource://gre/modules/FileUtils.jsm"
|
||||
);
|
||||
const { OS } = ChromeUtils.import("resource://gre/modules/osfile.jsm");
|
||||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
const { XPCOMUtils } = ChromeUtils.import(
|
||||
"resource://gre/modules/XPCOMUtils.jsm"
|
||||
);
|
||||
|
@ -146,34 +145,12 @@ Bookmarks.prototype = {
|
|||
}
|
||||
case this.MENU_COLLECTION: {
|
||||
folderGuid = PlacesUtils.bookmarks.menuGuid;
|
||||
if (
|
||||
!Services.prefs.getBoolPref("browser.toolbars.bookmarks.2h2020") &&
|
||||
!MigrationUtils.isStartupMigration &&
|
||||
PlacesUtils.getChildCountForFolder(folderGuid) >
|
||||
PlacesUIUtils.NUM_TOOLBAR_BOOKMARKS_TO_UNHIDE
|
||||
) {
|
||||
folderGuid = await MigrationUtils.createImportedBookmarksFolder(
|
||||
"Safari",
|
||||
folderGuid
|
||||
);
|
||||
}
|
||||
this._histogramBookmarkRoots |=
|
||||
MigrationUtils.SOURCE_BOOKMARK_ROOTS_BOOKMARKS_MENU;
|
||||
break;
|
||||
}
|
||||
case this.TOOLBAR_COLLECTION: {
|
||||
folderGuid = PlacesUtils.bookmarks.toolbarGuid;
|
||||
if (
|
||||
!Services.prefs.getBoolPref("browser.toolbars.bookmarks.2h2020") &&
|
||||
!MigrationUtils.isStartupMigration &&
|
||||
PlacesUtils.getChildCountForFolder(folderGuid) >
|
||||
PlacesUIUtils.NUM_TOOLBAR_BOOKMARKS_TO_UNHIDE
|
||||
) {
|
||||
folderGuid = await MigrationUtils.createImportedBookmarksFolder(
|
||||
"Safari",
|
||||
folderGuid
|
||||
);
|
||||
}
|
||||
this._histogramBookmarkRoots |=
|
||||
MigrationUtils.SOURCE_BOOKMARK_ROOTS_BOOKMARKS_TOOLBAR;
|
||||
break;
|
||||
|
|
|
@ -42,7 +42,7 @@ add_task(async function setup_initialBookmarks() {
|
|||
});
|
||||
});
|
||||
|
||||
async function testBookmarks(migratorKey, subDirs, folderName) {
|
||||
async function testBookmarks(migratorKey, subDirs) {
|
||||
if (AppConstants.platform == "macosx") {
|
||||
subDirs.unshift("Application Support");
|
||||
} else if (AppConstants.platform == "win") {
|
||||
|
@ -117,23 +117,13 @@ async function testBookmarks(migratorKey, subDirs, folderName) {
|
|||
Assert.ok(await migrator.isSourceAvailable());
|
||||
|
||||
let itemsSeen = { bookmarks: 0, folders: 0 };
|
||||
let gotImportedFolderWrapper = false;
|
||||
let listener = events => {
|
||||
for (let event of events) {
|
||||
// "From " comes from the string `importedBookmarksFolder`
|
||||
if (
|
||||
event.title.startsWith("From ") &&
|
||||
itemsSeen[
|
||||
event.itemType == PlacesUtils.bookmarks.TYPE_FOLDER
|
||||
) {
|
||||
Assert.equal(event.title, folderName, "Bookmark folder name");
|
||||
gotImportedFolderWrapper = true;
|
||||
} else {
|
||||
itemsSeen[
|
||||
event.itemType == PlacesUtils.bookmarks.TYPE_FOLDER
|
||||
? "folders"
|
||||
: "bookmarks"
|
||||
]++;
|
||||
}
|
||||
? "folders"
|
||||
: "bookmarks"
|
||||
]++;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -166,11 +156,6 @@ async function testBookmarks(migratorKey, subDirs, folderName) {
|
|||
|
||||
Assert.equal(itemsSeen.bookmarks, 200, "Should have seen 200 bookmarks.");
|
||||
Assert.equal(itemsSeen.folders, 10, "Should have seen 10 folders.");
|
||||
Assert.equal(
|
||||
gotImportedFolderWrapper,
|
||||
!Services.prefs.getBoolPref("browser.toolbars.bookmarks.2h2020"),
|
||||
"Should only get a 'From BrowserX' folder when the 2h2020 pref is disabled"
|
||||
);
|
||||
Assert.equal(
|
||||
MigrationUtils._importQuantities.bookmarks,
|
||||
itemsSeen.bookmarks + itemsSeen.folders,
|
||||
|
@ -182,7 +167,7 @@ async function testBookmarks(migratorKey, subDirs, folderName) {
|
|||
add_task(async function test_Chrome() {
|
||||
let subDirs =
|
||||
AppConstants.platform == "linux" ? ["google-chrome"] : ["Google", "Chrome"];
|
||||
await testBookmarks("chrome", subDirs, "From Google Chrome");
|
||||
await testBookmarks("chrome", subDirs);
|
||||
});
|
||||
|
||||
add_task(async function test_ChromiumEdge() {
|
||||
|
@ -194,5 +179,5 @@ add_task(async function test_ChromiumEdge() {
|
|||
AppConstants.platform == "macosx"
|
||||
? ["Microsoft Edge"]
|
||||
: ["Microsoft", "Edge"];
|
||||
await testBookmarks("chromium-edge", subDirs, "From Microsoft Edge");
|
||||
await testBookmarks("chromium-edge", subDirs);
|
||||
});
|
||||
|
|
|
@ -545,12 +545,6 @@ add_task(async function() {
|
|||
);
|
||||
Assert.ok(bookmarksMigrator.exists, "Should recognize db we just created");
|
||||
|
||||
let source = await MigrationUtils.getLocalizedString("source-name-edge");
|
||||
let sourceLabel = await MigrationUtils.getLocalizedString(
|
||||
"imported-bookmarks-source",
|
||||
{ source }
|
||||
);
|
||||
|
||||
let seenBookmarks = [];
|
||||
let listener = events => {
|
||||
for (let event of events) {
|
||||
|
@ -598,9 +592,9 @@ add_task(async function() {
|
|||
"Should have seen 5 items being bookmarked."
|
||||
);
|
||||
Assert.equal(
|
||||
seenBookmarks.filter(bm => bm.title != sourceLabel).length,
|
||||
seenBookmarks.length,
|
||||
MigrationUtils._importQuantities.bookmarks,
|
||||
"Telemetry should have items except for 'From Microsoft Edge' folders"
|
||||
"Telemetry should have items"
|
||||
);
|
||||
|
||||
let menuParents = seenBookmarks.filter(
|
||||
|
@ -631,15 +625,10 @@ add_task(async function() {
|
|||
.filter(item => item.ParentId == "921dc8a0-6c83-40ef-8df1-9bd1c5c56aaf")
|
||||
.map(item => item.Title);
|
||||
|
||||
let importParentFolderName = sourceLabel;
|
||||
|
||||
for (let bookmark of seenBookmarks) {
|
||||
let shouldBeInMenu = expectedTitlesInMenu.includes(bookmark.title);
|
||||
let shouldBeInToolbar = expectedTitlesInToolbar.includes(bookmark.title);
|
||||
if (
|
||||
bookmark.title == "Folder" ||
|
||||
bookmark.title == importParentFolderName
|
||||
) {
|
||||
if (bookmark.title == "Folder") {
|
||||
Assert.equal(
|
||||
bookmark.itemType,
|
||||
PlacesUtils.bookmarks.TYPE_FOLDER,
|
||||
|
@ -694,11 +683,6 @@ add_task(async function() {
|
|||
someItem => bookmark.title == someItem.Title
|
||||
);
|
||||
if (!dbItem) {
|
||||
Assert.equal(
|
||||
bookmark.title,
|
||||
importParentFolderName,
|
||||
"Only the extra layer of folders isn't in the input we stuck in the DB."
|
||||
);
|
||||
Assert.ok(
|
||||
[menuParentGuid, toolbarParentGuid].includes(bookmark.guid),
|
||||
"This item should be one of the containers"
|
||||
|
@ -762,9 +746,9 @@ add_task(async function() {
|
|||
"Should have seen 3 items being bookmarked (2 items + 1 folder)."
|
||||
);
|
||||
Assert.equal(
|
||||
seenBookmarks.filter(bm => bm.title != sourceLabel).length,
|
||||
seenBookmarks.length,
|
||||
MigrationUtils._importQuantities.bookmarks,
|
||||
"Telemetry should have items except for 'From Microsoft Edge' folders"
|
||||
"Telemetry should have items"
|
||||
);
|
||||
let readingListContainerLabel = await MigrationUtils.getLocalizedString(
|
||||
"imported-edge-reading-list"
|
||||
|
|
|
@ -78,23 +78,9 @@ import-done-description = The following items were successfully imported:
|
|||
|
||||
import-close-source-browser = Please ensure the selected browser is closed before continuing.
|
||||
|
||||
# Displays which browser the bookmarks are being imported from
|
||||
#
|
||||
# Variables:
|
||||
# $source (String): The browser the user has chosen to import bookmarks from.
|
||||
imported-bookmarks-source = From { $source }
|
||||
|
||||
source-name-ie = Internet Explorer
|
||||
source-name-edge = Microsoft Edge
|
||||
source-name-edge-beta = Microsoft Edge Beta
|
||||
source-name-safari = Safari
|
||||
source-name-canary = Google Chrome Canary
|
||||
source-name-chrome = Google Chrome
|
||||
source-name-chrome-beta = Google Chrome Beta
|
||||
source-name-chrome-dev = Google Chrome Dev
|
||||
source-name-chromium = Chromium
|
||||
source-name-firefox = Mozilla Firefox
|
||||
source-name-360se = 360 Secure Browser
|
||||
|
||||
imported-safari-reading-list = Reading List (From Safari)
|
||||
imported-edge-reading-list = Reading List (From Edge)
|
||||
|
|
Загрузка…
Ссылка в новой задаче