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

Unified Diff: trunk/src/chrome/browser/ui/views/wrench_menu.h

Issue 26546004: Revert 227675 "reland "views: change WrenchMenu to use each mode..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: trunk/src/chrome/browser/ui/views/wrench_menu.h
===================================================================
--- trunk/src/chrome/browser/ui/views/wrench_menu.h (revision 227696)
+++ trunk/src/chrome/browser/ui/views/wrench_menu.h (working copy)
@@ -59,12 +59,11 @@
void RemoveObserver(WrenchMenuObserver* observer);
// MenuDelegate overrides:
- virtual const gfx::Font* GetLabelFont(int command_id) const OVERRIDE;
+ virtual const gfx::Font* GetLabelFont(int index) const OVERRIDE;
virtual bool GetForegroundColor(int command_id,
bool is_hovered,
SkColor* override_color) const OVERRIDE;
- virtual string16 GetTooltipText(int command_id,
- const gfx::Point& p) const OVERRIDE;
+ virtual string16 GetTooltipText(int id, const gfx::Point& p) const OVERRIDE;
virtual bool IsTriggerableEvent(views::MenuItemView* menu,
const ui::Event& e) OVERRIDE;
virtual bool GetDropFormats(
@@ -81,7 +80,7 @@
DropPosition position,
const ui::DropTargetEvent& event) OVERRIDE;
virtual bool ShowContextMenu(views::MenuItemView* source,
- int command_id,
+ int id,
const gfx::Point& p,
ui::MenuSourceType source_type) OVERRIDE;
virtual bool CanDrag(views::MenuItemView* menu) OVERRIDE;
@@ -89,11 +88,10 @@
ui::OSExchangeData* data) OVERRIDE;
virtual int GetDragOperations(views::MenuItemView* sender) OVERRIDE;
virtual int GetMaxWidthForMenu(views::MenuItemView* menu) OVERRIDE;
- virtual bool IsItemChecked(int command_id) const OVERRIDE;
- virtual bool IsCommandEnabled(int command_id) const OVERRIDE;
- virtual void ExecuteCommand(int command_id, int mouse_event_flags) OVERRIDE;
- virtual bool GetAccelerator(int command_id,
- ui::Accelerator* accelerator) OVERRIDE;
+ virtual bool IsItemChecked(int id) const OVERRIDE;
+ virtual bool IsCommandEnabled(int id) const OVERRIDE;
+ virtual void ExecuteCommand(int id, int mouse_event_flags) OVERRIDE;
+ virtual bool GetAccelerator(int id, ui::Accelerator* accelerator) OVERRIDE;
virtual void WillShowMenu(views::MenuItemView* menu) OVERRIDE;
virtual void WillHideMenu(views::MenuItemView* menu) OVERRIDE;
@@ -111,24 +109,26 @@
class ZoomView;
typedef std::pair<ui::MenuModel*,int> Entry;
- typedef std::map<int,Entry> CommandIDToEntry;
+ typedef std::map<int,Entry> IDToEntry;
const ui::NativeTheme* GetNativeTheme() const;
// Populates |parent| with all the child menus in |model|. Recursively invokes
- // |PopulateMenu| for any submenu.
+ // |PopulateMenu| for any submenu. |next_id| is incremented for every menu
+ // that is created.
void PopulateMenu(views::MenuItemView* parent,
- ui::MenuModel* model);
+ ui::MenuModel* model,
+ int* next_id);
// Adds a new menu to |parent| to represent the MenuModel/index pair passed
- // in. The returned item's MenuItemView::GetCommand() is the same as that of
- // |model|->GetCommandIdAt(|index|).
+ // in.
// Fur button containing menu items a |height| override can be specified with
// a number bigger then 0.
views::MenuItemView* AppendMenuItem(views::MenuItemView* parent,
ui::MenuModel* model,
int index,
ui::MenuModel::ItemType menu_type,
+ int* next_id,
int height);
// Invoked from the cut/copy/paste menus. Cancels the current active menu and
@@ -139,18 +139,26 @@
// the bookmark model isn't loaded.
void CreateBookmarkMenu();
- // Returns the index of the MenuModel/index pair representing the |command_id|
- // in |command_id_to_entry_|.
- int ModelIndexFromCommandId(int command_id) const;
+ // Returns true if |id| identifies a bookmark menu item.
+ bool is_bookmark_command(int id) const {
+ return bookmark_menu_delegate_.get() && id >= first_bookmark_command_id_;
+ }
+ // Returns true if |id| identifies a recent tabs menu item.
+ bool is_recent_tabs_command(int id) const {
+ return (recent_tabs_menu_model_delegate_.get() &&
+ id >= first_recent_tabs_command_id_ &&
+ id <= last_recent_tabs_command_id_);
+ }
+
// The views menu. Owned by |menu_runner_|.
views::MenuItemView* root_;
scoped_ptr<views::MenuRunner> menu_runner_;
- // Maps from the command ID in model to the model/index pair the item came
- // from.
- CommandIDToEntry command_id_to_entry_;
+ // Maps from the ID as understood by MenuItemView to the model/index pair the
+ // item came from.
+ IDToEntry id_to_entry_;
// Browser the menu is being shown for.
Browser* browser_;
@@ -174,6 +182,13 @@
// Used for managing "Recent tabs" menu items.
scoped_ptr<RecentTabsMenuModelDelegate> recent_tabs_menu_model_delegate_;
+ // First ID to use for the items representing bookmarks in the bookmark menu.
+ int first_bookmark_command_id_;
+
+ // First/last IDs to use for the items of the recent tabs sub-menu.
+ int first_recent_tabs_command_id_;
+ int last_recent_tabs_command_id_;
+
content::NotificationRegistrar registrar_;
const bool use_new_menu_;

Powered by Google App Engine
This is Rietveld 408576698