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

Unified Diff: components/bookmarks/browser/bookmark_utils.cc

Issue 2367533003: Always add bookmarks to the mobile node on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactored GetParentForNewNodes into bookmark_utils Created 4 years, 2 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: components/bookmarks/browser/bookmark_utils.cc
diff --git a/components/bookmarks/browser/bookmark_utils.cc b/components/bookmarks/browser/bookmark_utils.cc
index 6fef26dca622b878efc9909c23a3e94531a3d0b1..0183e4ea5ac3a2512d4c0a7435980beb22dfa73d 100644
--- a/components/bookmarks/browser/bookmark_utils.cc
+++ b/components/bookmarks/browser/bookmark_utils.cc
@@ -498,7 +498,7 @@ void AddIfNotBookmarked(BookmarkModel* model,
if (IsBookmarkedByUser(model, url))
return; // Nothing to do, a user bookmark with that url already exists.
model->client()->RecordAction(base::UserMetricsAction("BookmarkAdded"));
- const BookmarkNode* parent = model->GetParentForNewNodes();
+ const BookmarkNode* parent = GetParentForNewNodes(model);
model->AddURL(parent, parent->child_count(), title, url);
}
@@ -569,4 +569,18 @@ bool HasDescendantsOf(const std::vector<const BookmarkNode*>& list,
return false;
}
+const BookmarkNode* GetParentForNewNodes(BookmarkModel* model) {
+ std::vector<const BookmarkNode*> nodes =
+ GetMostRecentlyModifiedUserFolders(model, 1);
+ DCHECK(!nodes.empty()); // This list is always padded with default folders.
+#if defined(OS_ANDROID)
+ // Default cross-platform node. We should instead return the mobile node as
+ // default on Android.
+ if (nodes[0] == model->bookmark_bar_node() && nodes[0]->child_count() == 0) {
sky 2016/10/10 21:02:24 Your check should be more of are all the permance
kraush 2016/10/10 22:18:05 Will do! I'll iterate over all the children of the
+ return model->mobile_node();
+ }
+#endif
+ return nodes[0];
+}
+
} // namespace bookmarks

Powered by Google App Engine
This is Rietveld 408576698