| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_TOOLBAR_BACK_FORWARD_MENU_MODEL_H_ | 5 #ifndef CHROME_BROWSER_UI_TOOLBAR_BACK_FORWARD_MENU_MODEL_H_ |
| 6 #define CHROME_BROWSER_UI_TOOLBAR_BACK_FORWARD_MENU_MODEL_H_ | 6 #define CHROME_BROWSER_UI_TOOLBAR_BACK_FORWARD_MENU_MODEL_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 class BackForwardMenuModel : public ui::MenuModel { | 41 class BackForwardMenuModel : public ui::MenuModel { |
| 42 public: | 42 public: |
| 43 // These are IDs used to identify individual UI elements within the | 43 // These are IDs used to identify individual UI elements within the |
| 44 // browser window using View::GetViewByID. | 44 // browser window using View::GetViewByID. |
| 45 enum ModelType { | 45 enum ModelType { |
| 46 FORWARD_MENU = 1, | 46 FORWARD_MENU = 1, |
| 47 BACKWARD_MENU = 2 | 47 BACKWARD_MENU = 2 |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 BackForwardMenuModel(Browser* browser, ModelType model_type); | 50 BackForwardMenuModel(Browser* browser, ModelType model_type); |
| 51 virtual ~BackForwardMenuModel(); | 51 ~BackForwardMenuModel() override; |
| 52 | 52 |
| 53 // MenuModel implementation. | 53 // MenuModel implementation. |
| 54 virtual bool HasIcons() const override; | 54 bool HasIcons() const override; |
| 55 // Returns how many items the menu should show, including history items, | 55 // Returns how many items the menu should show, including history items, |
| 56 // chapter-stops, separators and the Show Full History link. This function | 56 // chapter-stops, separators and the Show Full History link. This function |
| 57 // uses GetHistoryItemCount() and GetChapterStopCount() internally to figure | 57 // uses GetHistoryItemCount() and GetChapterStopCount() internally to figure |
| 58 // out the total number of items to show. | 58 // out the total number of items to show. |
| 59 virtual int GetItemCount() const override; | 59 int GetItemCount() const override; |
| 60 virtual ItemType GetTypeAt(int index) const override; | 60 ItemType GetTypeAt(int index) const override; |
| 61 virtual ui::MenuSeparatorType GetSeparatorTypeAt(int index) const override; | 61 ui::MenuSeparatorType GetSeparatorTypeAt(int index) const override; |
| 62 virtual int GetCommandIdAt(int index) const override; | 62 int GetCommandIdAt(int index) const override; |
| 63 virtual base::string16 GetLabelAt(int index) const override; | 63 base::string16 GetLabelAt(int index) const override; |
| 64 virtual bool IsItemDynamicAt(int index) const override; | 64 bool IsItemDynamicAt(int index) const override; |
| 65 virtual bool GetAcceleratorAt(int index, | 65 bool GetAcceleratorAt(int index, ui::Accelerator* accelerator) const override; |
| 66 ui::Accelerator* accelerator) const override; | 66 bool IsItemCheckedAt(int index) const override; |
| 67 virtual bool IsItemCheckedAt(int index) const override; | 67 int GetGroupIdAt(int index) const override; |
| 68 virtual int GetGroupIdAt(int index) const override; | 68 bool GetIconAt(int index, gfx::Image* icon) override; |
| 69 virtual bool GetIconAt(int index, gfx::Image* icon) override; | 69 ui::ButtonMenuItemModel* GetButtonMenuItemAt(int index) const override; |
| 70 virtual ui::ButtonMenuItemModel* GetButtonMenuItemAt( | 70 bool IsEnabledAt(int index) const override; |
| 71 int index) const override; | 71 MenuModel* GetSubmenuModelAt(int index) const override; |
| 72 virtual bool IsEnabledAt(int index) const override; | 72 void HighlightChangedTo(int index) override; |
| 73 virtual MenuModel* GetSubmenuModelAt(int index) const override; | 73 void ActivatedAt(int index) override; |
| 74 virtual void HighlightChangedTo(int index) override; | 74 void ActivatedAt(int index, int event_flags) override; |
| 75 virtual void ActivatedAt(int index) override; | 75 void MenuWillShow() override; |
| 76 virtual void ActivatedAt(int index, int event_flags) override; | |
| 77 virtual void MenuWillShow() override; | |
| 78 | 76 |
| 79 // Is the item at |index| a separator? | 77 // Is the item at |index| a separator? |
| 80 bool IsSeparator(int index) const; | 78 bool IsSeparator(int index) const; |
| 81 | 79 |
| 82 // Set the delegate for triggering OnIconChanged. | 80 // Set the delegate for triggering OnIconChanged. |
| 83 virtual void SetMenuModelDelegate( | 81 void SetMenuModelDelegate( |
| 84 ui::MenuModelDelegate* menu_model_delegate) override; | 82 ui::MenuModelDelegate* menu_model_delegate) override; |
| 85 virtual ui::MenuModelDelegate* GetMenuModelDelegate() const override; | 83 ui::MenuModelDelegate* GetMenuModelDelegate() const override; |
| 86 | 84 |
| 87 protected: | 85 protected: |
| 88 ui::MenuModelDelegate* menu_model_delegate() { return menu_model_delegate_; } | 86 ui::MenuModelDelegate* menu_model_delegate() { return menu_model_delegate_; } |
| 89 | 87 |
| 90 private: | 88 private: |
| 91 friend class BackFwdMenuModelTest; | 89 friend class BackFwdMenuModelTest; |
| 92 FRIEND_TEST_ALL_PREFIXES(BackFwdMenuModelTest, BasicCase); | 90 FRIEND_TEST_ALL_PREFIXES(BackFwdMenuModelTest, BasicCase); |
| 93 FRIEND_TEST_ALL_PREFIXES(BackFwdMenuModelTest, MaxItemsTest); | 91 FRIEND_TEST_ALL_PREFIXES(BackFwdMenuModelTest, MaxItemsTest); |
| 94 FRIEND_TEST_ALL_PREFIXES(BackFwdMenuModelTest, ChapterStops); | 92 FRIEND_TEST_ALL_PREFIXES(BackFwdMenuModelTest, ChapterStops); |
| 95 FRIEND_TEST_ALL_PREFIXES(BackFwdMenuModelTest, EscapeLabel); | 93 FRIEND_TEST_ALL_PREFIXES(BackFwdMenuModelTest, EscapeLabel); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 // Used for loading favicons. | 204 // Used for loading favicons. |
| 207 base::CancelableTaskTracker cancelable_task_tracker_; | 205 base::CancelableTaskTracker cancelable_task_tracker_; |
| 208 | 206 |
| 209 // Used for receiving notifications when an icon is changed. | 207 // Used for receiving notifications when an icon is changed. |
| 210 ui::MenuModelDelegate* menu_model_delegate_; | 208 ui::MenuModelDelegate* menu_model_delegate_; |
| 211 | 209 |
| 212 DISALLOW_COPY_AND_ASSIGN(BackForwardMenuModel); | 210 DISALLOW_COPY_AND_ASSIGN(BackForwardMenuModel); |
| 213 }; | 211 }; |
| 214 | 212 |
| 215 #endif // CHROME_BROWSER_UI_TOOLBAR_BACK_FORWARD_MENU_MODEL_H_ | 213 #endif // CHROME_BROWSER_UI_TOOLBAR_BACK_FORWARD_MENU_MODEL_H_ |
| OLD | NEW |