Bug 591884 - Make IE importer fallback to the default Links folder to support toolbar favorites in versions >= 7

r=felipe
This commit is contained in:
Marco Bonardo 2012-03-09 11:13:14 +01:00
Родитель fa0bd04455
Коммит e20386539d
9 изменённых файлов: 106 добавлений и 1 удалений

Просмотреть файл

@ -43,6 +43,8 @@ include $(DEPTH)/config/autoconf.mk
DIRS = public src DIRS = public src
TEST_DIRS += tests
include $(topsrcdir)/config/rules.mk include $(topsrcdir)/config/rules.mk
# Needed for preprocessor removal of IE Profile Migrator label - bug 236901 # Needed for preprocessor removal of IE Profile Migrator label - bug 236901

Просмотреть файл

@ -1412,6 +1412,9 @@ nsIEProfileMigrator::CopyFavoritesBatched(bool aReplace)
// Locate the Links toolbar folder, we want to replace the Personal Toolbar // Locate the Links toolbar folder, we want to replace the Personal Toolbar
// content with Favorites in this folder. // content with Favorites in this folder.
// On versions minor or equal to IE6 the folder name is stored in the
// LinksFolderName registry key, but in newer versions it may be just a
// Links subfolder inside the default Favorites folder.
nsCOMPtr<nsIWindowsRegKey> regKey = nsCOMPtr<nsIWindowsRegKey> regKey =
do_CreateInstance("@mozilla.org/windows-registry-key;1"); do_CreateInstance("@mozilla.org/windows-registry-key;1");
if (regKey && if (regKey &&
@ -1421,9 +1424,14 @@ nsIEProfileMigrator::CopyFavoritesBatched(bool aReplace)
nsAutoString linksFolderName; nsAutoString linksFolderName;
if (NS_SUCCEEDED(regKey->ReadStringValue( if (NS_SUCCEEDED(regKey->ReadStringValue(
NS_LITERAL_STRING("LinksFolderName"), NS_LITERAL_STRING("LinksFolderName"),
linksFolderName))) linksFolderName))) {
personalToolbarFolderName = linksFolderName; personalToolbarFolderName = linksFolderName;
}
else {
personalToolbarFolderName.AssignLiteral("Links");
}
} }
folder = bookmarksMenuFolderId; folder = bookmarksMenuFolderId;
} }

Просмотреть файл

@ -0,0 +1,15 @@
# 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/.
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = browser/components/migration/tests
include $(DEPTH)/config/autoconf.mk
XPCSHELL_TESTS = unit
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -0,0 +1,16 @@
<!DOCTYPE NETSCAPE-Bookmark-file-1>
<!-- This is an automatically generated file.
It will be read and overwritten.
DO NOT EDIT! -->
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks Menu</H1>
<DL><p>
<DT><A HREF="http://example.com/" ADD_DATE="1233157972" LAST_MODIFIED="1233157984">example</A>
<DT><H3 ADD_DATE="1233157910" LAST_MODIFIED="1233157972" PERSONAL_TOOLBAR_FOLDER="true">Bookmarks Toolbar</H3>
<DD>Add bookmarks to this folder to see them displayed on the Bookmarks Toolbar
<DL><p>
<DT><A HREF="http://example.com/" ADD_DATE="1233157972" LAST_MODIFIED="1233157984">example</A>
</DL><p>
</DL><p>

Просмотреть файл

@ -0,0 +1,28 @@
/* 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/. */
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
const IMIGRATOR = Ci.nsIBrowserProfileMigrator;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
"resource://gre/modules/PlacesUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "FileUtils",
"resource://gre/modules/FileUtils.jsm");
// Initialize profile.
let gProfD = do_get_profile();
function newMigratorFor(aKey) {
let cid = "@mozilla.org/profile/migrator;1?app=browser&type=" + aKey;
return Cc[cid].createInstance(Ci.nsIBrowserProfileMigrator);
}
let (bookmarkshtml = do_get_file("bookmarks.html")) {
bookmarkshtml.copyTo(gProfD, "bookmarks.html");
}

Просмотреть файл

@ -0,0 +1,28 @@
/* 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/. */
function run_test() {
let migrator = newMigratorFor("ie");
// Sanity check for the source.
do_check_true(migrator.sourceExists);
// Ensure bookmarks migration is available.
let availableSources = migrator.getMigrateData("FieldOfFlowers", false);
do_check_true((availableSources & IMIGRATOR.BOOKMARKS) > 0);
// Needed to enforce bookmarks replacing.
let startup = {
doStartup: function () {},
get directory() do_get_profile()
}
migrator.migrate(IMIGRATOR.BOOKMARKS, startup, "FieldOfFlowers");
// Check that at least two bookmark have been added to the menu and the
// toolbar. The first one comes from bookmarks.html, the others from IE.
do_check_true(PlacesUtils.bookmarks
.getIdForItemAt(PlacesUtils.bookmarksMenuFolderId, 1) > 0);
do_check_true(PlacesUtils.bookmarks
.getIdForItemAt(PlacesUtils.toolbarFolderId, 1) > 0);
}

Просмотреть файл

@ -0,0 +1,6 @@
[DEFAULT]
head = head_migration.js
tail =
[test_IE_bookmarks.js]
skip-if = os != "win"

Просмотреть файл

@ -139,6 +139,7 @@ if [ "$ENABLE_TESTS" ]; then
browser/components/shell/test/Makefile browser/components/shell/test/Makefile
browser/components/feeds/test/Makefile browser/components/feeds/test/Makefile
browser/components/feeds/test/chrome/Makefile browser/components/feeds/test/chrome/Makefile
browser/components/migration/tests/Makefile
browser/components/places/tests/Makefile browser/components/places/tests/Makefile
browser/components/places/tests/chrome/Makefile browser/components/places/tests/chrome/Makefile
browser/components/places/tests/browser/Makefile browser/components/places/tests/browser/Makefile

Просмотреть файл

@ -72,6 +72,7 @@ skip-if = os == "android"
skip-if = os == "android" skip-if = os == "android"
[include:browser/components/dirprovider/tests/unit/xpcshell.ini] [include:browser/components/dirprovider/tests/unit/xpcshell.ini]
[include:browser/components/feeds/test/unit/xpcshell.ini] [include:browser/components/feeds/test/unit/xpcshell.ini]
[include:browser/components/migration/tests/unit/xpcshell.ini]
[include:browser/components/places/tests/unit/xpcshell.ini] [include:browser/components/places/tests/unit/xpcshell.ini]
[include:browser/components/privatebrowsing/test/unit/xpcshell.ini] [include:browser/components/privatebrowsing/test/unit/xpcshell.ini]
[include:browser/components/shell/test/unit/xpcshell.ini] [include:browser/components/shell/test/unit/xpcshell.ini]