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

Side by Side Diff: chrome/browser/views/bookmark_editor_view.cc

Issue 122027: Remove the Menu object, converting all the remaining callers to use Menu2. I'... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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 | « chrome/browser/views/bookmark_editor_view.h ('k') | chrome/browser/views/bookmark_table_view.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/views/bookmark_editor_view.h" 5 #include "chrome/browser/views/bookmark_editor_view.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 switch (sender->GetID()) { 180 switch (sender->GetID()) {
181 case kNewGroupButtonID: 181 case kNewGroupButtonID:
182 NewGroup(); 182 NewGroup();
183 break; 183 break;
184 184
185 default: 185 default:
186 NOTREACHED(); 186 NOTREACHED();
187 } 187 }
188 } 188 }
189 189
190 void BookmarkEditorView::ExecuteCommand(int id) { 190 bool BookmarkEditorView::IsCommandIdChecked(int command_id) const {
191 return false;
192 }
193
194 bool BookmarkEditorView::IsCommandIdEnabled(int command_id) const {
195 return (command_id != IDS_EDIT || !running_menu_for_root_);
196 }
197
198 bool BookmarkEditorView::GetAcceleratorForCommandId(
199 int command_id,
200 views::Accelerator* accelerator) {
201 return GetWidget()->GetAccelerator(command_id, accelerator);
202 }
203
204 void BookmarkEditorView::ExecuteCommand(int command_id) {
191 DCHECK(tree_view_->GetSelectedNode()); 205 DCHECK(tree_view_->GetSelectedNode());
192 if (id == IDS_EDIT) { 206 if (command_id == IDS_EDIT) {
193 tree_view_->StartEditing(tree_view_->GetSelectedNode()); 207 tree_view_->StartEditing(tree_view_->GetSelectedNode());
194 } else { 208 } else {
195 DCHECK(id == IDS_BOOMARK_EDITOR_NEW_FOLDER_MENU_ITEM); 209 DCHECK(command_id == IDS_BOOMARK_EDITOR_NEW_FOLDER_MENU_ITEM);
196 NewGroup(); 210 NewGroup();
197 } 211 }
198 } 212 }
199 213
200 bool BookmarkEditorView::IsCommandEnabled(int id) const {
201 return (id != IDS_EDIT || !running_menu_for_root_);
202 }
203
204 void BookmarkEditorView::Show(HWND parent_hwnd) { 214 void BookmarkEditorView::Show(HWND parent_hwnd) {
205 views::Window::CreateChromeWindow(parent_hwnd, gfx::Rect(), this); 215 views::Window::CreateChromeWindow(parent_hwnd, gfx::Rect(), this);
206 UserInputChanged(); 216 UserInputChanged();
207 if (show_tree_ && bb_model_->IsLoaded()) 217 if (show_tree_ && bb_model_->IsLoaded())
208 ExpandAndSelect(); 218 ExpandAndSelect();
209 window()->Show(); 219 window()->Show();
210 // Select all the text in the name Textfield. 220 // Select all the text in the name Textfield.
211 title_tf_.SelectAll(); 221 title_tf_.SelectAll();
212 // Give focus to the name Textfield. 222 // Give focus to the name Textfield.
213 title_tf_.RequestFocus(); 223 title_tf_.RequestFocus();
214 } 224 }
215 225
216 void BookmarkEditorView::Close() { 226 void BookmarkEditorView::Close() {
217 DCHECK(window()); 227 DCHECK(window());
218 window()->Close(); 228 window()->Close();
219 } 229 }
220 230
221 void BookmarkEditorView::ShowContextMenu(View* source, 231 void BookmarkEditorView::ShowContextMenu(View* source,
222 int x, 232 int x,
223 int y, 233 int y,
224 bool is_mouse_gesture) { 234 bool is_mouse_gesture) {
225 DCHECK(source == tree_view_); 235 DCHECK(source == tree_view_);
226 if (!tree_view_->GetSelectedNode()) 236 if (!tree_view_->GetSelectedNode())
227 return; 237 return;
228 running_menu_for_root_ = 238 running_menu_for_root_ =
229 (tree_model_->GetParent(tree_view_->GetSelectedNode()) == 239 (tree_model_->GetParent(tree_view_->GetSelectedNode()) ==
230 tree_model_->GetRoot()); 240 tree_model_->GetRoot());
231 context_menu_.reset(views::Menu::Create(this, views::Menu::TOPLEFT, 241 if (!context_menu_contents_.get()) {
232 GetWidget()->GetNativeView())); 242 context_menu_contents_.reset(new views::SimpleMenuModel(this));
233 context_menu_->AppendMenuItemWithLabel(IDS_EDIT, 243 context_menu_contents_->AddItemWithStringId(IDS_EDIT, IDS_EDIT);
234 l10n_util::GetString(IDS_EDIT)); 244 context_menu_contents_->AddItemWithStringId(
235 context_menu_->AppendMenuItemWithLabel( 245 IDS_BOOMARK_EDITOR_NEW_FOLDER_MENU_ITEM,
236 IDS_BOOMARK_EDITOR_NEW_FOLDER_MENU_ITEM, 246 IDS_BOOMARK_EDITOR_NEW_FOLDER_MENU_ITEM);
237 l10n_util::GetString(IDS_BOOMARK_EDITOR_NEW_FOLDER_MENU_ITEM)); 247 context_menu_.reset(new views::Menu2(context_menu_contents_.get()));
238 context_menu_->RunMenuAt(x, y); 248 }
249 context_menu_->RunContextMenuAt(gfx::Point(x, y));
239 } 250 }
240 251
241 void BookmarkEditorView::Init() { 252 void BookmarkEditorView::Init() {
242 bb_model_ = profile_->GetBookmarkModel(); 253 bb_model_ = profile_->GetBookmarkModel();
243 DCHECK(bb_model_); 254 DCHECK(bb_model_);
244 bb_model_->AddObserver(this); 255 bb_model_->AddObserver(this);
245 256
246 url_tf_.SetParentOwned(false); 257 url_tf_.SetParentOwned(false);
247 title_tf_.SetParentOwned(false); 258 title_tf_.SetParentOwned(false);
248 259
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 break; 550 break;
540 } 551 }
541 } 552 }
542 DCHECK(child_bb_node); 553 DCHECK(child_bb_node);
543 bb_model_->SetTitle(child_bb_node, child_b_node->GetTitle()); 554 bb_model_->SetTitle(child_bb_node, child_b_node->GetTitle());
544 } 555 }
545 ApplyNameChangesAndCreateNewGroups(child_bb_node, child_b_node, 556 ApplyNameChangesAndCreateNewGroups(child_bb_node, child_b_node,
546 parent_b_node, parent_bb_node); 557 parent_b_node, parent_bb_node);
547 } 558 }
548 } 559 }
OLDNEW
« no previous file with comments | « chrome/browser/views/bookmark_editor_view.h ('k') | chrome/browser/views/bookmark_table_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698