Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Unified Diff: chrome/browser/importer/firefox2_importer.cc

Issue 6979007: Many fixes to bookmark importing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Happy tests =) Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/importer/firefox2_importer.h ('k') | chrome/browser/importer/firefox3_importer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/importer/firefox2_importer.cc
diff --git a/chrome/browser/importer/firefox2_importer.cc b/chrome/browser/importer/firefox2_importer.cc
index b14105aebb4c00bd01a0b458f8952dea2e41bdd8..0e1899e644e93194d3ce60df4599544ef9768990 100644
--- a/chrome/browser/importer/firefox2_importer.cc
+++ b/chrome/browser/importer/firefox2_importer.cc
@@ -148,8 +148,6 @@ TemplateURL* Firefox2Importer::CreateTemplateURL(const string16& title,
void Firefox2Importer::ImportBookmarksFile(
const FilePath& file_path,
const std::set<GURL>& default_urls,
- bool import_to_bookmark_bar,
- const string16& first_folder_name,
Importer* importer,
std::vector<ProfileWriter::BookmarkEntry>* bookmarks,
std::vector<TemplateURL*>* template_urls,
@@ -160,7 +158,7 @@ void Firefox2Importer::ImportBookmarksFile(
base::SplitString(content, '\n', &lines);
std::vector<ProfileWriter::BookmarkEntry> toolbar_bookmarks;
- string16 last_folder = first_folder_name;
+ string16 last_folder;
bool last_folder_on_toolbar = false;
bool last_folder_is_empty = true;
bool has_subfolder = false;
@@ -214,22 +212,18 @@ void Firefox2Importer::ImportBookmarksFile(
entry.url = url;
entry.title = title;
- if (import_to_bookmark_bar && toolbar_folder) {
- // Flatten the items in toolbar.
+ if (toolbar_folder) {
+ // The toolbar folder should be at the top level.
entry.in_toolbar = true;
- entry.path.assign(path.begin() + toolbar_folder, path.end());
+ entry.path.assign(path.begin() + toolbar_folder - 1, path.end());
toolbar_bookmarks.push_back(entry);
} else {
- // Insert the item into the "Imported from Firefox" folder.
+ // Add this bookmark to the list of |bookmarks|.
if (!has_subfolder && !last_folder.empty()) {
path.push_back(last_folder);
last_folder.clear();
}
entry.path.assign(path.begin(), path.end());
- if (import_to_bookmark_bar) {
- DCHECK(!entry.path.empty());
- entry.path.erase(entry.path.begin());
- }
bookmarks->push_back(entry);
}
@@ -252,7 +246,7 @@ void Firefox2Importer::ImportBookmarksFile(
// Bookmarks in sub-folder are encapsulated with <DL> tag.
if (StartsWithASCII(line, "<DL>", false)) {
has_subfolder = true;
- if (last_folder.length() != 0) {
+ if (!last_folder.empty()) {
path.push_back(last_folder);
last_folder.clear();
}
@@ -274,18 +268,17 @@ void Firefox2Importer::ImportBookmarksFile(
entry.is_folder = true;
entry.creation_time = last_folder_add_date;
entry.title = folder_title;
- if (import_to_bookmark_bar && toolbar_folder) {
- // Flatten the folder in toolbar.
- entry.in_toolbar = true;
- entry.path.assign(path.begin() + toolbar_folder, path.end());
- toolbar_bookmarks.push_back(entry);
+ if (toolbar_folder) {
+ // The toolbar folder should be at the top level.
+ // Make sure we don't add the toolbar folder itself if it is empty.
+ if (toolbar_folder <= path.size()) {
+ entry.in_toolbar = true;
+ entry.path.assign(path.begin() + toolbar_folder - 1, path.end());
+ toolbar_bookmarks.push_back(entry);
+ }
} else {
- // Insert the folder into the "Imported from Firefox" folder.
+ // Add this folder to the list of |bookmarks|.
entry.path.assign(path.begin(), path.end());
- if (import_to_bookmark_bar) {
- DCHECK(!entry.path.empty());
- entry.path.erase(entry.path.begin());
- }
bookmarks->push_back(entry);
}
@@ -315,22 +308,16 @@ void Firefox2Importer::ImportBookmarks() {
FilePath file = source_path_;
if (!parsing_bookmarks_html_file_)
file = file.AppendASCII("bookmarks.html");
- string16 first_folder_name = bridge_->GetLocalizedString(
- parsing_bookmarks_html_file_ ? IDS_BOOKMARK_GROUP :
- IDS_BOOKMARK_GROUP_FROM_FIREFOX);
- ImportBookmarksFile(file, default_urls, import_to_bookmark_bar(),
- first_folder_name, this, &bookmarks, &template_urls,
+ ImportBookmarksFile(file, default_urls, this, &bookmarks, &template_urls,
&favicons);
// Write data into profile.
if (!bookmarks.empty() && !cancelled()) {
- int options = 0;
- if (import_to_bookmark_bar())
- options |= ProfileWriter::IMPORT_TO_BOOKMARK_BAR;
- if (bookmark_bar_disabled())
- options |= ProfileWriter::BOOKMARK_BAR_DISABLED;
- bridge_->AddBookmarks(bookmarks, first_folder_name, options);
+ string16 first_folder_name = bridge_->GetLocalizedString(
+ parsing_bookmarks_html_file_ ? IDS_BOOKMARK_GROUP :
+ IDS_BOOKMARK_GROUP_FROM_FIREFOX);
+ bridge_->AddBookmarks(bookmarks, first_folder_name);
}
if (!parsing_bookmarks_html_file_ && !template_urls.empty() &&
!cancelled()) {
« no previous file with comments | « chrome/browser/importer/firefox2_importer.h ('k') | chrome/browser/importer/firefox3_importer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698