| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef CHROME_BROWSER_UI_VIEWS_TOOLBAR_WRENCH_MENU_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_TOOLBAR_WRENCH_MENU_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_WRENCH_MENU_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_WRENCH_MENU_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 class WrenchMenu : public views::MenuDelegate, | 36 class WrenchMenu : public views::MenuDelegate, |
| 37 public BaseBookmarkModelObserver, | 37 public BaseBookmarkModelObserver, |
| 38 public content::NotificationObserver { | 38 public content::NotificationObserver { |
| 39 public: | 39 public: |
| 40 enum RunFlags { | 40 enum RunFlags { |
| 41 // Indicates that the menu was opened for a drag-and-drop operation. | 41 // Indicates that the menu was opened for a drag-and-drop operation. |
| 42 FOR_DROP = 1 << 0, | 42 FOR_DROP = 1 << 0, |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 WrenchMenu(Browser* browser, int run_flags); | 45 WrenchMenu(Browser* browser, int run_flags); |
| 46 virtual ~WrenchMenu(); | 46 ~WrenchMenu() override; |
| 47 | 47 |
| 48 void Init(ui::MenuModel* model); | 48 void Init(ui::MenuModel* model); |
| 49 | 49 |
| 50 // Shows the menu relative to the specified view. | 50 // Shows the menu relative to the specified view. |
| 51 void RunMenu(views::MenuButton* host); | 51 void RunMenu(views::MenuButton* host); |
| 52 | 52 |
| 53 // Closes the menu if it is open, otherwise does nothing. | 53 // Closes the menu if it is open, otherwise does nothing. |
| 54 void CloseMenu(); | 54 void CloseMenu(); |
| 55 | 55 |
| 56 // Whether the menu is currently visible to the user. | 56 // Whether the menu is currently visible to the user. |
| 57 bool IsShowing(); | 57 bool IsShowing(); |
| 58 | 58 |
| 59 bool for_drop() const { return (run_flags_ & FOR_DROP) != 0; } | 59 bool for_drop() const { return (run_flags_ & FOR_DROP) != 0; } |
| 60 | 60 |
| 61 void AddObserver(WrenchMenuObserver* observer); | 61 void AddObserver(WrenchMenuObserver* observer); |
| 62 void RemoveObserver(WrenchMenuObserver* observer); | 62 void RemoveObserver(WrenchMenuObserver* observer); |
| 63 | 63 |
| 64 // MenuDelegate overrides: | 64 // MenuDelegate overrides: |
| 65 virtual const gfx::FontList* GetLabelFontList(int command_id) const override; | 65 const gfx::FontList* GetLabelFontList(int command_id) const override; |
| 66 virtual bool GetShouldUseDisabledEmphasizedForegroundColor( | 66 bool GetShouldUseDisabledEmphasizedForegroundColor( |
| 67 int command_id) const override; | 67 int command_id) const override; |
| 68 virtual base::string16 GetTooltipText(int command_id, | 68 base::string16 GetTooltipText(int command_id, |
| 69 const gfx::Point& p) const override; | 69 const gfx::Point& p) const override; |
| 70 virtual bool IsTriggerableEvent(views::MenuItemView* menu, | 70 bool IsTriggerableEvent(views::MenuItemView* menu, |
| 71 const ui::Event& e) override; | 71 const ui::Event& e) override; |
| 72 virtual bool GetDropFormats( | 72 bool GetDropFormats( |
| 73 views::MenuItemView* menu, | 73 views::MenuItemView* menu, |
| 74 int* formats, | 74 int* formats, |
| 75 std::set<ui::OSExchangeData::CustomFormat>* custom_formats) override; | 75 std::set<ui::OSExchangeData::CustomFormat>* custom_formats) override; |
| 76 virtual bool AreDropTypesRequired(views::MenuItemView* menu) override; | 76 bool AreDropTypesRequired(views::MenuItemView* menu) override; |
| 77 virtual bool CanDrop(views::MenuItemView* menu, | 77 bool CanDrop(views::MenuItemView* menu, |
| 78 const ui::OSExchangeData& data) override; | 78 const ui::OSExchangeData& data) override; |
| 79 virtual int GetDropOperation(views::MenuItemView* item, | 79 int GetDropOperation(views::MenuItemView* item, |
| 80 const ui::DropTargetEvent& event, | 80 const ui::DropTargetEvent& event, |
| 81 DropPosition* position) override; | 81 DropPosition* position) override; |
| 82 virtual int OnPerformDrop(views::MenuItemView* menu, | 82 int OnPerformDrop(views::MenuItemView* menu, |
| 83 DropPosition position, | 83 DropPosition position, |
| 84 const ui::DropTargetEvent& event) override; | 84 const ui::DropTargetEvent& event) override; |
| 85 virtual bool ShowContextMenu(views::MenuItemView* source, | 85 bool ShowContextMenu(views::MenuItemView* source, |
| 86 int command_id, | 86 int command_id, |
| 87 const gfx::Point& p, | 87 const gfx::Point& p, |
| 88 ui::MenuSourceType source_type) override; | 88 ui::MenuSourceType source_type) override; |
| 89 virtual bool CanDrag(views::MenuItemView* menu) override; | 89 bool CanDrag(views::MenuItemView* menu) override; |
| 90 virtual void WriteDragData(views::MenuItemView* sender, | 90 void WriteDragData(views::MenuItemView* sender, |
| 91 ui::OSExchangeData* data) override; | 91 ui::OSExchangeData* data) override; |
| 92 virtual int GetDragOperations(views::MenuItemView* sender) override; | 92 int GetDragOperations(views::MenuItemView* sender) override; |
| 93 virtual int GetMaxWidthForMenu(views::MenuItemView* menu) override; | 93 int GetMaxWidthForMenu(views::MenuItemView* menu) override; |
| 94 virtual bool IsItemChecked(int command_id) const override; | 94 bool IsItemChecked(int command_id) const override; |
| 95 virtual bool IsCommandEnabled(int command_id) const override; | 95 bool IsCommandEnabled(int command_id) const override; |
| 96 virtual void ExecuteCommand(int command_id, int mouse_event_flags) override; | 96 void ExecuteCommand(int command_id, int mouse_event_flags) override; |
| 97 virtual bool GetAccelerator(int command_id, | 97 bool GetAccelerator(int command_id, |
| 98 ui::Accelerator* accelerator) const override; | 98 ui::Accelerator* accelerator) const override; |
| 99 virtual void WillShowMenu(views::MenuItemView* menu) override; | 99 void WillShowMenu(views::MenuItemView* menu) override; |
| 100 virtual void WillHideMenu(views::MenuItemView* menu) override; | 100 void WillHideMenu(views::MenuItemView* menu) override; |
| 101 virtual bool ShouldCloseOnDragComplete() override; | 101 bool ShouldCloseOnDragComplete() override; |
| 102 | 102 |
| 103 // BaseBookmarkModelObserver overrides: | 103 // BaseBookmarkModelObserver overrides: |
| 104 virtual void BookmarkModelChanged() override; | 104 void BookmarkModelChanged() override; |
| 105 | 105 |
| 106 // content::NotificationObserver overrides: | 106 // content::NotificationObserver overrides: |
| 107 virtual void Observe(int type, | 107 void Observe(int type, |
| 108 const content::NotificationSource& source, | 108 const content::NotificationSource& source, |
| 109 const content::NotificationDetails& details) override; | 109 const content::NotificationDetails& details) override; |
| 110 | 110 |
| 111 private: | 111 private: |
| 112 class CutCopyPasteView; | 112 class CutCopyPasteView; |
| 113 class RecentTabsMenuModelDelegate; | 113 class RecentTabsMenuModelDelegate; |
| 114 class ZoomView; | 114 class ZoomView; |
| 115 | 115 |
| 116 typedef std::pair<ui::MenuModel*,int> Entry; | 116 typedef std::pair<ui::MenuModel*,int> Entry; |
| 117 typedef std::map<int,Entry> CommandIDToEntry; | 117 typedef std::map<int,Entry> CommandIDToEntry; |
| 118 | 118 |
| 119 // Populates |parent| with all the child menus in |model|. Recursively invokes | 119 // Populates |parent| with all the child menus in |model|. Recursively invokes |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 | 181 |
| 182 // The bit mask of RunFlags. | 182 // The bit mask of RunFlags. |
| 183 const int run_flags_; | 183 const int run_flags_; |
| 184 | 184 |
| 185 ObserverList<WrenchMenuObserver> observer_list_; | 185 ObserverList<WrenchMenuObserver> observer_list_; |
| 186 | 186 |
| 187 DISALLOW_COPY_AND_ASSIGN(WrenchMenu); | 187 DISALLOW_COPY_AND_ASSIGN(WrenchMenu); |
| 188 }; | 188 }; |
| 189 | 189 |
| 190 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_WRENCH_MENU_H_ | 190 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_WRENCH_MENU_H_ |
| OLD | NEW |