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

Unified Diff: chrome/utility/importer/bookmark_html_reader.cc

Issue 2968923003: Fixed importing of empty folders from HTML bookmarks file (Closed)
Patch Set: Fixed review issues Created 3 years, 5 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
Index: chrome/utility/importer/bookmark_html_reader.cc
diff --git a/chrome/utility/importer/bookmark_html_reader.cc b/chrome/utility/importer/bookmark_html_reader.cc
index 8e524b83ee7e7f5953531805c254d847f6cab2e1..ae39a99ef3a776bed8ba413e5d0a4d579e7fb0e4 100644
--- a/chrome/utility/importer/bookmark_html_reader.cc
+++ b/chrome/utility/importer/bookmark_html_reader.cc
@@ -121,6 +121,7 @@ void ImportBookmarksFile(
bool last_folder_on_toolbar = false;
bool last_folder_is_empty = true;
bool has_subfolder = false;
+ bool has_last_folder = false;
base::Time last_folder_add_date;
std::vector<base::string16> path;
size_t toolbar_folder_index = 0;
@@ -153,6 +154,7 @@ void ImportBookmarksFile(
&last_folder,
&last_folder_on_toolbar,
&last_folder_add_date)) {
+ has_last_folder = true;
continue;
}
@@ -207,8 +209,9 @@ void ImportBookmarksFile(
entry.path.assign(path.begin() + toolbar_folder_index - 1, path.end());
} else {
// Add this bookmark to the list of |bookmarks|.
- if (!has_subfolder && !last_folder.empty()) {
+ if (!has_subfolder && has_last_folder) {
path.push_back(last_folder);
+ has_last_folder = false;
last_folder.clear();
}
entry.path.assign(path.begin(), path.end());
@@ -226,8 +229,9 @@ void ImportBookmarksFile(
// Bookmarks in sub-folder are encapsulated with <DL> tag.
if (base::StartsWith(line, "<DL>", base::CompareCase::INSENSITIVE_ASCII)) {
has_subfolder = true;
- if (!last_folder.empty()) {
+ if (has_last_folder) {
path.push_back(last_folder);
+ has_last_folder = false;
last_folder.clear();
}
if (last_folder_on_toolbar && !toolbar_folder_index)
« no previous file with comments | « chrome/test/data/bookmark_html_reader/empty_folder.html ('k') | chrome/utility/importer/bookmark_html_reader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698