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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/bookmarks/bookmark_utils.h" 5 #include "chrome/browser/bookmarks/bookmark_utils.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 node->url(), languages, net::kFormatUrlOmitNothing, 78 node->url(), languages, net::kFormatUrlOmitNothing,
79 net::UnescapeRule::NORMAL, NULL, NULL, NULL), words); 79 net::UnescapeRule::NORMAL, NULL, NULL, NULL), words);
80 } 80 }
81 81
82 const BookmarkNode* CreateNewNode(BookmarkModel* model, 82 const BookmarkNode* CreateNewNode(BookmarkModel* model,
83 const BookmarkNode* parent, 83 const BookmarkNode* parent,
84 const BookmarkEditor::EditDetails& details, 84 const BookmarkEditor::EditDetails& details,
85 const string16& new_title, 85 const string16& new_title,
86 const GURL& new_url) { 86 const GURL& new_url) {
87 const BookmarkNode* node; 87 const BookmarkNode* node;
88 // When create the new one to right-clicked folder, add it to the next to the
89 // folder's position.
90 int insert_index =
91 parent == details.parent_node ? details.index : parent->child_count();
88 if (details.type == BookmarkEditor::EditDetails::NEW_URL) { 92 if (details.type == BookmarkEditor::EditDetails::NEW_URL) {
89 node = model->AddURL(parent, parent->child_count(), new_title, new_url); 93 node = model->AddURL(parent, insert_index, new_title, new_url);
90 } else if (details.type == BookmarkEditor::EditDetails::NEW_FOLDER) { 94 } else if (details.type == BookmarkEditor::EditDetails::NEW_FOLDER) {
91 node = model->AddFolder(parent, parent->child_count(), new_title); 95 node = model->AddFolder(parent, insert_index, new_title);
92 for (size_t i = 0; i < details.urls.size(); ++i) { 96 for (size_t i = 0; i < details.urls.size(); ++i) {
93 model->AddURL(node, node->child_count(), details.urls[i].second, 97 model->AddURL(node, node->child_count(), details.urls[i].second,
94 details.urls[i].first); 98 details.urls[i].first);
95 } 99 }
96 model->SetDateFolderModified(parent, Time::Now()); 100 model->SetDateFolderModified(parent, Time::Now());
97 } else { 101 } else {
98 NOTREACHED(); 102 NOTREACHED();
99 return NULL; 103 return NULL;
100 } 104 }
101 105
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 void DisableBookmarkBarViewAnimationsForTesting(bool disabled) { 526 void DisableBookmarkBarViewAnimationsForTesting(bool disabled) {
523 g_bookmark_bar_view_animations_disabled = disabled; 527 g_bookmark_bar_view_animations_disabled = disabled;
524 } 528 }
525 529
526 bool IsBookmarkBarViewAnimationsDisabled() { 530 bool IsBookmarkBarViewAnimationsDisabled() {
527 return g_bookmark_bar_view_animations_disabled; 531 return g_bookmark_bar_view_animations_disabled;
528 } 532 }
529 #endif 533 #endif
530 534
531 } // namespace bookmark_utils 535 } // namespace bookmark_utils
OLDNEW
« 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