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

Side by Side Diff: chrome/browser/bookmarks/bookmark_context_menu_controller.cc

Issue 7572022: Use bookmark manager to add/edit bookmark pages with webui_dialogs=1. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Windows build compatibility. Created 9 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « build/common.gypi ('k') | chrome/browser/bookmarks/bookmark_editor.h » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_context_menu_controller.h" 5 #include "chrome/browser/bookmarks/bookmark_context_menu_controller.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "chrome/app/chrome_command_ids.h" 8 #include "chrome/app/chrome_command_ids.h"
9 #include "chrome/browser/bookmarks/bookmark_editor.h" 9 #include "chrome/browser/bookmarks/bookmark_editor.h"
10 #include "chrome/browser/bookmarks/bookmark_folder_editor_controller.h" 10 #include "chrome/browser/bookmarks/bookmark_folder_editor_controller.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 case IDC_BOOKMARK_BAR_EDIT: 132 case IDC_BOOKMARK_BAR_EDIT:
133 UserMetrics::RecordAction( 133 UserMetrics::RecordAction(
134 UserMetricsAction("BookmarkBar_ContextMenu_Edit")); 134 UserMetricsAction("BookmarkBar_ContextMenu_Edit"));
135 135
136 if (selection_.size() != 1) { 136 if (selection_.size() != 1) {
137 NOTREACHED(); 137 NOTREACHED();
138 break; 138 break;
139 } 139 }
140 140
141 if (selection_[0]->is_url()) { 141 if (selection_[0]->is_url()) {
142 #if defined(WEBUI_DIALOGS)
143 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_);
144 DCHECK(browser);
145 browser->OpenBookmarkManagerEditNode(selection_[0]->id());
146 #else
142 BookmarkEditor::Show(parent_window_, profile_, parent_, 147 BookmarkEditor::Show(parent_window_, profile_, parent_,
143 BookmarkEditor::EditDetails(selection_[0]), 148 BookmarkEditor::EditDetails(selection_[0]),
144 BookmarkEditor::SHOW_TREE); 149 BookmarkEditor::SHOW_TREE);
150 #endif
145 } else { 151 } else {
146 BookmarkFolderEditorController::Show(profile_, parent_window_, 152 BookmarkFolderEditorController::Show(profile_, parent_window_,
147 selection_[0], -1, 153 selection_[0], -1,
148 BookmarkFolderEditorController::EXISTING_BOOKMARK); 154 BookmarkFolderEditorController::EXISTING_BOOKMARK);
149 } 155 }
150 break; 156 break;
151 157
152 case IDC_BOOKMARK_BAR_REMOVE: { 158 case IDC_BOOKMARK_BAR_REMOVE: {
153 UserMetrics::RecordAction( 159 UserMetrics::RecordAction(
154 UserMetricsAction("BookmarkBar_ContextMenu_Remove")); 160 UserMetricsAction("BookmarkBar_ContextMenu_Remove"));
155 161
156 for (size_t i = 0; i < selection_.size(); ++i) { 162 for (size_t i = 0; i < selection_.size(); ++i) {
157 int index = selection_[i]->parent()->GetIndexOf(selection_[i]); 163 int index = selection_[i]->parent()->GetIndexOf(selection_[i]);
158 if (index > -1) 164 if (index > -1)
159 model_->Remove(selection_[i]->parent(), index); 165 model_->Remove(selection_[i]->parent(), index);
160 } 166 }
161 selection_.clear(); 167 selection_.clear();
162 break; 168 break;
163 } 169 }
164 170
165 case IDC_BOOKMARK_BAR_ADD_NEW_BOOKMARK: { 171 case IDC_BOOKMARK_BAR_ADD_NEW_BOOKMARK: {
166 UserMetrics::RecordAction( 172 UserMetrics::RecordAction(
167 UserMetricsAction("BookmarkBar_ContextMenu_Add")); 173 UserMetricsAction("BookmarkBar_ContextMenu_Add"));
168 174
175 #if defined(WEBUI_DIALOGS)
176 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_);
177 DCHECK(browser);
178 browser->OpenBookmarkManagerAddNodeIn(selection_[0]->id());
179 #else
169 // TODO: this should honor the index from GetParentForNewNodes. 180 // TODO: this should honor the index from GetParentForNewNodes.
170 BookmarkEditor::Show( 181 BookmarkEditor::Show(
171 parent_window_, profile_, 182 parent_window_, profile_,
172 bookmark_utils::GetParentForNewNodes(parent_, selection_, NULL), 183 bookmark_utils::GetParentForNewNodes(parent_, selection_, NULL),
173 BookmarkEditor::EditDetails(), BookmarkEditor::SHOW_TREE); 184 BookmarkEditor::EditDetails(), BookmarkEditor::SHOW_TREE);
185 #endif
174 break; 186 break;
175 } 187 }
176 188
177 case IDC_BOOKMARK_BAR_NEW_FOLDER: { 189 case IDC_BOOKMARK_BAR_NEW_FOLDER: {
178 UserMetrics::RecordAction( 190 UserMetrics::RecordAction(
179 UserMetricsAction("BookmarkBar_ContextMenu_NewFolder")); 191 UserMetricsAction("BookmarkBar_ContextMenu_NewFolder"));
180 int index; 192 int index;
181 const BookmarkNode* parent = 193 const BookmarkNode* parent =
182 bookmark_utils::GetParentForNewNodes(parent_, selection_, &index); 194 bookmark_utils::GetParentForNewNodes(parent_, selection_, &index);
183 BookmarkFolderEditorController::Show(profile_, parent_window_, parent, 195 BookmarkFolderEditorController::Show(profile_, parent_window_, parent,
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 delegate_->CloseMenu(); 316 delegate_->CloseMenu();
305 } 317 }
306 318
307 bool BookmarkContextMenuController::HasURLs() const { 319 bool BookmarkContextMenuController::HasURLs() const {
308 for (size_t i = 0; i < selection_.size(); ++i) { 320 for (size_t i = 0; i < selection_.size(); ++i) {
309 if (bookmark_utils::NodeHasURLs(selection_[i])) 321 if (bookmark_utils::NodeHasURLs(selection_[i]))
310 return true; 322 return true;
311 } 323 }
312 return false; 324 return false;
313 } 325 }
OLDNEW
« no previous file with comments | « build/common.gypi ('k') | chrome/browser/bookmarks/bookmark_editor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698