diff options
author | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-26 18:38:05 +0000 |
---|---|---|
committer | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-26 18:38:05 +0000 |
commit | 7fc7241105ea8e5532005611b374736a4e0bcba2 (patch) | |
tree | 3f0e3a2d0e70d6241c376815e71b1273b72ef461 /chrome/browser/importer/firefox3_importer.cc | |
parent | b6f8e3831bc67964a85de79a62ab6d680e89a2b8 (diff) | |
download | chromium_src-7fc7241105ea8e5532005611b374736a4e0bcba2.zip chromium_src-7fc7241105ea8e5532005611b374736a4e0bcba2.tar.gz chromium_src-7fc7241105ea8e5532005611b374736a4e0bcba2.tar.bz2 |
Many fixes to bookmark importing.
In particular:
* All bookmarks are imported to the toolbar -- nothing goes to Other Bookmarks. If there are initially no bookmarks on the toolbar, we try to reduce nesting of the imported bookmarks as much as possible. If there are already bookmarks on the toolbar, all the imported bookmarks end up in a new folder -- e.g. "Imported from Safari" -- on the toolbar.
* All importers explicitly include a containing folder for bookmarks in the toolbar.
o The ProfileWriter is responsible for stripping this folder off when the bookmarks should be imported directly to the toolbar.
* All importers do *not* include a containing folder for the remaining bookmarks.
o The ProfileWriter is responsible for creating this folder as appropriate. In fact, this is how things used to work previously, too, since the folder name needed to be uniquified. This CL makes the logic much clearer though (I hope).
* All importers should now be able to handle importing empty folders.
* The ProfileWriter no longer takes in a bitset of options for importing bookmarks. These options were all either set identically by all clients, or could be more accurately computed locally.
* Some implementation details for ProfileWriter have been removed from the header file. Others have just been completely nuked from orbit, and replaced by simpler code (again, I hope).
BUG=79427,79433,71351
TEST=unit_tests --gtest_filter=*Import*
Review URL: http://codereview.chromium.org/6979007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86861 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/importer/firefox3_importer.cc')
-rw-r--r-- | chrome/browser/importer/firefox3_importer.cc | 48 |
1 files changed, 21 insertions, 27 deletions
diff --git a/chrome/browser/importer/firefox3_importer.cc b/chrome/browser/importer/firefox3_importer.cc index 606549f..0411dc7 100644 --- a/chrome/browser/importer/firefox3_importer.cc +++ b/chrome/browser/importer/firefox3_importer.cc @@ -208,8 +208,8 @@ void Firefox3Importer::ImportBookmarks() { BookmarkItem* item = list[i]; if (item->type == TYPE_FOLDER) { - // Folders are added implicitly on adding children, - // so now we pass only empty folders to add them explicitly. + // Folders are added implicitly on adding children, so we only explicitly + // add empty folders. if (!item->empty_folder) continue; } else if (item->type == TYPE_BOOKMARK) { @@ -232,31 +232,28 @@ void Firefox3Importer::ImportBookmarks() { bool is_in_toolbar = false; while (child->parent >= 0) { BookmarkItem* parent = list[child->parent]; - if (parent->id == toolbar_folder_id) { - // This bookmark entry should be put in the bookmark bar. - // But we put it in the Firefox group after first run, so - // that do not mess up the bookmark bar. - if (import_to_bookmark_bar()) { - is_in_toolbar = true; - } else { - path.insert(path.begin(), parent->title); - path.insert(path.begin(), firefox_folder); - } - found_path = true; + if (livemark_id.find(parent->id) != livemark_id.end()) { + // Don't import live bookmarks. break; - } else if (parent->id == menu_folder_id || - parent->id == unsorted_folder_id) { - // After the first run, the item will be placed in a folder in - // the "Other bookmarks". - if (!import_to_bookmark_bar()) - path.insert(path.begin(), firefox_folder); + } + + if (parent->id != menu_folder_id) { + // To avoid excessive nesting, omit the name for the bookmarks menu + // folder. + path.insert(path.begin(), parent->title); + } + + if (parent->id == toolbar_folder_id) + is_in_toolbar = true; + + if (parent->id == toolbar_folder_id || + parent->id == menu_folder_id || + parent->id == unsorted_folder_id) { + // We've reached a root node, hooray! found_path = true; break; - } else if (livemark_id.find(parent->id) != livemark_id.end()) { - // If the entry is under a livemark folder, we don't import it. - break; } - path.insert(path.begin(), parent->title); + child = parent; } @@ -291,10 +288,7 @@ void Firefox3Importer::ImportBookmarks() { if (!bookmarks.empty() && !cancelled()) { const string16& first_folder_name = bridge_->GetLocalizedString(IDS_BOOKMARK_GROUP_FROM_FIREFOX); - int options = 0; - if (import_to_bookmark_bar()) - options = ProfileWriter::IMPORT_TO_BOOKMARK_BAR; - bridge_->AddBookmarks(bookmarks, first_folder_name, options); + bridge_->AddBookmarks(bookmarks, first_folder_name); } if (!template_urls.empty() && !cancelled()) { bridge_->SetKeywords(template_urls, -1, false); |