Chromium Code Reviews| 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 |