| Index: chrome/browser/ui/views/wrench_menu.h
|
| diff --git a/chrome/browser/ui/views/wrench_menu.h b/chrome/browser/ui/views/wrench_menu.h
|
| index 44613be2ebf90da6962c8d98b608babbf08aace2..8d14ec824670260faee906f9c277cd600dc25f07 100644
|
| --- a/chrome/browser/ui/views/wrench_menu.h
|
| +++ b/chrome/browser/ui/views/wrench_menu.h
|
| @@ -11,6 +11,7 @@
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/observer_list.h"
|
| #include "chrome/browser/bookmarks/base_bookmark_model_observer.h"
|
| +#include "chrome/browser/ui/views/menu_items_changed_delegate.h"
|
| #include "content/public/browser/notification_observer.h"
|
| #include "content/public/browser/notification_registrar.h"
|
| #include "ui/base/models/menu_model.h"
|
| @@ -18,6 +19,7 @@
|
|
|
| class BookmarkMenuDelegate;
|
| class Browser;
|
| +class RecentTabsMenuModelDelegate;
|
| class WrenchMenuObserver;
|
|
|
| namespace ui {
|
| @@ -34,6 +36,7 @@ class View;
|
|
|
| // WrenchMenu adapts the WrenchMenuModel to view's menu related classes.
|
| class WrenchMenu : public views::MenuDelegate,
|
| + public MenuItemsChangedDelegate,
|
| public BaseBookmarkModelObserver,
|
| public content::NotificationObserver {
|
| public:
|
| @@ -59,7 +62,7 @@ class WrenchMenu : public views::MenuDelegate,
|
| void RemoveObserver(WrenchMenuObserver* observer);
|
|
|
| // MenuDelegate overrides:
|
| - virtual const gfx::Font* GetLabelFont(int index) const OVERRIDE;
|
| + virtual const gfx::Font* GetLabelFont(int id) const OVERRIDE;
|
| virtual bool GetForegroundColor(int command_id,
|
| bool is_hovered,
|
| SkColor* override_color) const OVERRIDE;
|
| @@ -95,6 +98,15 @@ class WrenchMenu : public views::MenuDelegate,
|
| virtual void WillShowMenu(views::MenuItemView* menu) OVERRIDE;
|
| virtual void WillHideMenu(views::MenuItemView* menu) OVERRIDE;
|
|
|
| + // MenuItemsChangedDelegate overrides:
|
| + void OnItemAdded(views::MenuItemView* parent, int menu_index,
|
| + ui::MenuModel* model, int model_index,
|
| + int item_id) OVERRIDE;
|
| + void OnItemRemoved(views::MenuItemView* parent, int menu_index,
|
| + int item_id) OVERRIDE;
|
| + virtual void UpdateMapOfMenuItemIdAndModel(
|
| + ui::MenuModel* model, std::vector<int>& item_ids) OVERRIDE;
|
| +
|
| // BaseBookmarkModelObserver overrides:
|
| virtual void BookmarkModelChanged() OVERRIDE;
|
|
|
| @@ -104,8 +116,9 @@ class WrenchMenu : public views::MenuDelegate,
|
| const content::NotificationDetails& details) OVERRIDE;
|
|
|
| private:
|
| + friend class RecentTabsMenuModelDelegate;
|
| +
|
| class CutCopyPasteView;
|
| - class RecentTabsMenuModelDelegate;
|
| class ZoomView;
|
|
|
| typedef std::pair<ui::MenuModel*,int> Entry;
|
| @@ -120,16 +133,17 @@ class WrenchMenu : public views::MenuDelegate,
|
| ui::MenuModel* model,
|
| int* next_id);
|
|
|
| - // Adds a new menu to |parent| to represent the MenuModel/index pair passed
|
| - // in.
|
| + // Adds a new menu to |parent| at |menu_index| to represent the
|
| + // MenuModel/model_index pair passed 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);
|
| + views::MenuItemView* AddMenuItem(views::MenuItemView* parent,
|
| + int menu_index,
|
| + ui::MenuModel* model,
|
| + int model_index,
|
| + ui::MenuModel::ItemType menu_type,
|
| + int* next_id,
|
| + int height);
|
|
|
| // Invoked from the cut/copy/paste menus. Cancels the current active menu and
|
| // activates the menu item in |model| at |index|.
|
| @@ -140,16 +154,10 @@ class WrenchMenu : public views::MenuDelegate,
|
| void CreateBookmarkMenu();
|
|
|
| // 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_;
|
| - }
|
| + bool IsBookmarkCommand(int id) const;
|
|
|
| // 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_);
|
| - }
|
| + bool IsRecentTabsCommand(int id) const;
|
|
|
| // The views menu. Owned by |menu_runner_|.
|
| views::MenuItemView* root_;
|
| @@ -182,11 +190,7 @@ class WrenchMenu : public views::MenuDelegate,
|
| // 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_;
|
| + // ID of the last item in the recent tabs submenu.
|
| int last_recent_tabs_command_id_;
|
|
|
| content::NotificationRegistrar registrar_;
|
|
|