diff options
Diffstat (limited to 'chrome/browser/bookmarks/bookmark_context_menu_controller.h')
-rw-r--r-- | chrome/browser/bookmarks/bookmark_context_menu_controller.h | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/chrome/browser/bookmarks/bookmark_context_menu_controller.h b/chrome/browser/bookmarks/bookmark_context_menu_controller.h index 3812e28..e2e2194 100644 --- a/chrome/browser/bookmarks/bookmark_context_menu_controller.h +++ b/chrome/browser/bookmarks/bookmark_context_menu_controller.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -8,6 +8,7 @@ #include <vector> #include "app/gfx/native_widget_types.h" +#include "app/menus/simple_menu_model.h" #include "base/basictypes.h" #include "chrome/browser/bookmarks/bookmark_model_observer.h" @@ -24,23 +25,17 @@ class BookmarkContextMenuControllerDelegate { // Closes the bookmark context menu. virtual void CloseMenu() = 0; - // Methods that add items to the underlying menu. - virtual void AddItem(int command_id) = 0; - virtual void AddItemWithStringId(int command_id, int string_id) = 0; - virtual void AddSeparator() = 0; - virtual void AddCheckboxItem(int command_id) = 0; + // Sent before any command from the menu is executed. + virtual void WillExecuteCommand() {} - // Sent before bookmarks are removed. - virtual void WillRemoveBookmarks( - const std::vector<const BookmarkNode*>& bookmarks) {} - - // Sent after bookmarks have been removed. - virtual void DidRemoveBookmarks() {} + // Sent after any command from the menu is executed. + virtual void DidExecuteCommand() {} }; // BookmarkContextMenuController creates and manages state for the context menu // shown for any bookmark item. -class BookmarkContextMenuController : public BookmarkModelObserver { +class BookmarkContextMenuController : public BookmarkModelObserver, + public menus::SimpleMenuModel::Delegate { public: // Used to configure what the context menu shows. enum ConfigurationType { @@ -75,15 +70,35 @@ class BookmarkContextMenuController : public BookmarkModelObserver { void BuildMenu(); - void ExecuteCommand(int id); - bool IsItemChecked(int id) const; - bool IsCommandEnabled(int id) const; + menus::SimpleMenuModel* menu_model() { + return menu_model_.get(); + } + + + // menus::SimpleMenuModel::Delegate implementation: + virtual bool IsCommandIdChecked(int command_id) const; + virtual bool IsCommandIdEnabled(int command_id) const; + virtual bool GetAcceleratorForCommandId( + int command_id, + menus::Accelerator* accelerator) { + return false; + } + virtual void ExecuteCommand(int command_id); // Accessors: Profile* profile() const { return profile_; } PageNavigator* navigator() const { return navigator_; } private: + // Adds a IDS_* style command to the menu. + void AddItem(int id); + // Adds a IDS_* style command to the menu with a different localized string. + void AddItem(int id, int localization_id); + // Adds a separator to the menu. + void AddSeparator(); + // Adds a checkable item to the menu. + void AddCheckboxItem(int id); + // BookmarkModelObserver methods. Any change to the model results in closing // the menu. virtual void Loaded(BookmarkModel* model) {} @@ -129,6 +144,7 @@ class BookmarkContextMenuController : public BookmarkModelObserver { std::vector<const BookmarkNode*> selection_; ConfigurationType configuration_; BookmarkModel* model_; + scoped_ptr<menus::SimpleMenuModel> menu_model_; DISALLOW_COPY_AND_ASSIGN(BookmarkContextMenuController); }; |