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

Side by Side Diff: chrome/browser/ui/views/bookmarks/bookmark_context_menu_controller_views.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: 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
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/ui/views/bookmarks/bookmark_context_menu_controller_vie ws.h" 5 #include "chrome/browser/ui/views/bookmarks/bookmark_context_menu_controller_vie ws.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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 case IDC_BOOKMARK_BAR_EDIT: 122 case IDC_BOOKMARK_BAR_EDIT:
123 UserMetrics::RecordAction( 123 UserMetrics::RecordAction(
124 UserMetricsAction("BookmarkBar_ContextMenu_Edit")); 124 UserMetricsAction("BookmarkBar_ContextMenu_Edit"));
125 125
126 if (selection_.size() != 1) { 126 if (selection_.size() != 1) {
127 NOTREACHED(); 127 NOTREACHED();
128 return; 128 return;
129 } 129 }
130 130
131 if (selection_[0]->is_url()) { 131 if (selection_[0]->is_url()) {
132 #if defined(WEBUI_BOOKMARK_EDITOR)
Rick Byers 2011/08/04 18:26:07 You've really had to sprinkle this #ifdef in a lot
flackr 2011/08/12 18:11:24 I completely agree. As we discussed I think a slig
133 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_);
134 DCHECK(browser);
135 browser->OpenBookmarkManagerEditNode(selection_[0]->id());
136 #else
132 BookmarkEditor::Show(parent_widget_->GetNativeWindow(), profile_, 137 BookmarkEditor::Show(parent_widget_->GetNativeWindow(), profile_,
133 parent_, BookmarkEditor::EditDetails(selection_[0]), 138 parent_, BookmarkEditor::EditDetails(selection_[0]),
134 BookmarkEditor::SHOW_TREE); 139 BookmarkEditor::SHOW_TREE);
140 #endif
135 } else { 141 } else {
136 BookmarkFolderEditorController::Show(profile_, 142 BookmarkFolderEditorController::Show(profile_,
137 parent_widget_->GetNativeWindow(), selection_[0], -1, 143 parent_widget_->GetNativeWindow(), selection_[0], -1,
138 BookmarkFolderEditorController::EXISTING_BOOKMARK); 144 BookmarkFolderEditorController::EXISTING_BOOKMARK);
139 } 145 }
140 break; 146 break;
141 147
142 case IDC_BOOKMARK_BAR_REMOVE: { 148 case IDC_BOOKMARK_BAR_REMOVE: {
143 UserMetrics::RecordAction( 149 UserMetrics::RecordAction(
144 UserMetricsAction("BookmarkBar_ContextMenu_Remove")); 150 UserMetricsAction("BookmarkBar_ContextMenu_Remove"));
145 151
146 delegate_->WillRemoveBookmarks(selection_); 152 delegate_->WillRemoveBookmarks(selection_);
147 for (size_t i = 0; i < selection_.size(); ++i) { 153 for (size_t i = 0; i < selection_.size(); ++i) {
148 model->Remove(selection_[i]->parent(), 154 model->Remove(selection_[i]->parent(),
149 selection_[i]->parent()->GetIndexOf(selection_[i])); 155 selection_[i]->parent()->GetIndexOf(selection_[i]));
150 } 156 }
151 delegate_->DidRemoveBookmarks(); 157 delegate_->DidRemoveBookmarks();
152 selection_.clear(); 158 selection_.clear();
153 break; 159 break;
154 } 160 }
155 161
156 case IDC_BOOKMARK_BAR_ADD_NEW_BOOKMARK: { 162 case IDC_BOOKMARK_BAR_ADD_NEW_BOOKMARK: {
157 UserMetrics::RecordAction( 163 UserMetrics::RecordAction(
158 UserMetricsAction("BookmarkBar_ContextMenu_Add")); 164 UserMetricsAction("BookmarkBar_ContextMenu_Add"));
159 165
166 #if defined(WEBUI_BOOKMARK_EDITOR)
167 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_);
168 DCHECK(browser);
169 browser->OpenBookmarkManagerAddNodeIn(selection_[0]->id());
170 #else
160 // TODO: this should honor the index from GetParentForNewNodes. 171 // TODO: this should honor the index from GetParentForNewNodes.
161 BookmarkEditor::Show( 172 BookmarkEditor::Show(
162 parent_widget_->GetNativeWindow(), profile_, 173 parent_widget_->GetNativeWindow(), profile_,
163 bookmark_utils::GetParentForNewNodes(parent_, selection_, NULL), 174 bookmark_utils::GetParentForNewNodes(parent_, selection_, NULL),
164 BookmarkEditor::EditDetails(), BookmarkEditor::SHOW_TREE); 175 BookmarkEditor::EditDetails(), BookmarkEditor::SHOW_TREE);
176 #endif
165 break; 177 break;
166 } 178 }
167 179
168 case IDC_BOOKMARK_BAR_NEW_FOLDER: { 180 case IDC_BOOKMARK_BAR_NEW_FOLDER: {
169 UserMetrics::RecordAction( 181 UserMetrics::RecordAction(
170 UserMetricsAction("BookmarkBar_ContextMenu_NewFolder")); 182 UserMetricsAction("BookmarkBar_ContextMenu_NewFolder"));
171 int index; 183 int index;
172 const BookmarkNode* parent = 184 const BookmarkNode* parent =
173 bookmark_utils::GetParentForNewNodes(parent_, selection_, &index); 185 bookmark_utils::GetParentForNewNodes(parent_, selection_, &index);
174 BookmarkFolderEditorController::Show(profile_, 186 BookmarkFolderEditorController::Show(profile_,
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 return model; 301 return model;
290 } 302 }
291 303
292 bool BookmarkContextMenuControllerViews::HasURLs() const { 304 bool BookmarkContextMenuControllerViews::HasURLs() const {
293 for (size_t i = 0; i < selection_.size(); ++i) { 305 for (size_t i = 0; i < selection_.size(); ++i) {
294 if (bookmark_utils::NodeHasURLs(selection_[i])) 306 if (bookmark_utils::NodeHasURLs(selection_[i]))
295 return true; 307 return true;
296 } 308 }
297 return false; 309 return false;
298 } 310 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698