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

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

Issue 11567003: Adding a new folder/url to the BMB via right-click insert it at the location clicked (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: update unit test Created 8 years 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 | « no previous file | chrome/browser/ui/views/bookmarks/bookmark_editor_view_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/bookmarks/bookmark_utils.cc
diff --git a/chrome/browser/bookmarks/bookmark_utils.cc b/chrome/browser/bookmarks/bookmark_utils.cc
index 1b5a2d2ee79fd8e12aeb6557d5b06e39d7634716..9cf1bd458c7630dd1efac7c512aeb1271de8ed51 100644
--- a/chrome/browser/bookmarks/bookmark_utils.cc
+++ b/chrome/browser/bookmarks/bookmark_utils.cc
@@ -85,10 +85,14 @@ const BookmarkNode* CreateNewNode(BookmarkModel* model,
const string16& new_title,
const GURL& new_url) {
const BookmarkNode* node;
+ // When create the new one to right-clicked folder, add it to the next to the
+ // folder's position.
+ int insert_index =
+ parent == details.parent_node ? details.index : parent->child_count();
if (details.type == BookmarkEditor::EditDetails::NEW_URL) {
- node = model->AddURL(parent, parent->child_count(), new_title, new_url);
+ node = model->AddURL(parent, insert_index, new_title, new_url);
} else if (details.type == BookmarkEditor::EditDetails::NEW_FOLDER) {
- node = model->AddFolder(parent, parent->child_count(), new_title);
+ node = model->AddFolder(parent, insert_index, new_title);
for (size_t i = 0; i < details.urls.size(); ++i) {
model->AddURL(node, node->child_count(), details.urls[i].second,
details.urls[i].first);
« no previous file with comments | « no previous file | chrome/browser/ui/views/bookmarks/bookmark_editor_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698