| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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_RECENT_TABS_SUB_MENU_MODEL_H_ | 5 #ifndef CHROME_BROWSER_UI_TOOLBAR_RECENT_TABS_SUB_MENU_MODEL_H_ |
| 6 #define CHROME_BROWSER_UI_TOOLBAR_RECENT_TABS_SUB_MENU_MODEL_H_ | 6 #define CHROME_BROWSER_UI_TOOLBAR_RECENT_TABS_SUB_MENU_MODEL_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 namespace ui { | 33 namespace ui { |
| 34 class AcceleratorProvider; | 34 class AcceleratorProvider; |
| 35 } | 35 } |
| 36 | 36 |
| 37 // A menu model that builds the contents of "Recent tabs" submenu, which include | 37 // A menu model that builds the contents of "Recent tabs" submenu, which include |
| 38 // the last closed tab and opened tabs of other devices. | 38 // the last closed tab and opened tabs of other devices. |
| 39 class RecentTabsSubMenuModel : public ui::SimpleMenuModel, | 39 class RecentTabsSubMenuModel : public ui::SimpleMenuModel, |
| 40 public ui::SimpleMenuModel::Delegate { | 40 public ui::SimpleMenuModel::Delegate { |
| 41 public: | 41 public: |
| 42 // Command Id for recently closed items header or disabled item to which the | |
| 43 // accelerator string will be appended. | |
| 44 static const int kRecentlyClosedHeaderCommandId; | |
| 45 static const int kDisabledRecentlyClosedHeaderCommandId; | |
| 46 | |
| 47 // If |associator| is NULL, default associator for |browser|'s profile will | 42 // If |associator| is NULL, default associator for |browser|'s profile will |
| 48 // be used. Testing may require a specific |associator|. | 43 // be used. Testing may require a specific |associator|. |
| 49 RecentTabsSubMenuModel(ui::AcceleratorProvider* accelerator_provider, | 44 RecentTabsSubMenuModel(ui::AcceleratorProvider* accelerator_provider, |
| 50 Browser* browser, | 45 Browser* browser, |
| 51 browser_sync::SessionModelAssociator* associator); | 46 browser_sync::SessionModelAssociator* associator); |
| 52 virtual ~RecentTabsSubMenuModel(); | 47 virtual ~RecentTabsSubMenuModel(); |
| 53 | 48 |
| 54 // Overridden from ui::SimpleMenuModel::Delegate: | 49 // Overridden from ui::SimpleMenuModel::Delegate: |
| 55 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; | 50 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; |
| 56 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; | 51 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; |
| 57 virtual bool GetAcceleratorForCommandId( | 52 virtual bool GetAcceleratorForCommandId( |
| 58 int command_id, | 53 int command_id, |
| 59 ui::Accelerator* accelerator) OVERRIDE; | 54 ui::Accelerator* accelerator) OVERRIDE; |
| 60 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; | 55 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; |
| 61 virtual const gfx::Font* GetLabelFontAt(int index) const OVERRIDE; | 56 virtual const gfx::Font* GetLabelFontAt(int index) const OVERRIDE; |
| 62 | 57 |
| 63 int GetMaxWidthForItemAtIndex(int item_index) const; | 58 int GetMaxWidthForItemAtIndex(int item_index) const; |
| 64 bool GetURLAndTitleForItemAtIndex(int index, | 59 bool GetURLAndTitleForItemAtIndex(int index, |
| 65 std::string* url, | 60 std::string* url, |
| 66 string16* title) const; | 61 string16* title) const; |
| 67 | 62 |
| 63 // Command Id for recently closed items header or disabled item to which the |
| 64 // accelerator string will be appended. |
| 65 static const int kRecentlyClosedHeaderCommandId; |
| 66 static const int kDisabledRecentlyClosedHeaderCommandId; |
| 67 |
| 68 // Command Id for other devices section headers, using the device name. |
| 69 static const int kDeviceNameCommandId; |
| 70 |
| 68 private: | 71 private: |
| 69 struct TabNavigationItem; | 72 struct TabNavigationItem; |
| 70 typedef std::vector<TabNavigationItem> TabNavigationItems; | 73 typedef std::vector<TabNavigationItem> TabNavigationItems; |
| 71 | 74 |
| 72 typedef std::vector<SessionID::id_type> WindowItems; | 75 typedef std::vector<SessionID::id_type> WindowItems; |
| 73 | 76 |
| 74 // Build the menu items by populating the model. | 77 // Build the menu items by populating the model. |
| 75 void Build(); | 78 void Build(); |
| 76 void BuildRecentTabs(); | 79 void BuildRecentTabs(); |
| 77 void BuildDevices(); | 80 void BuildDevices(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 gfx::Image default_favicon_; | 113 gfx::Image default_favicon_; |
| 111 | 114 |
| 112 CancelableTaskTracker cancelable_task_tracker_; | 115 CancelableTaskTracker cancelable_task_tracker_; |
| 113 | 116 |
| 114 base::WeakPtrFactory<RecentTabsSubMenuModel> weak_ptr_factory_; | 117 base::WeakPtrFactory<RecentTabsSubMenuModel> weak_ptr_factory_; |
| 115 | 118 |
| 116 DISALLOW_COPY_AND_ASSIGN(RecentTabsSubMenuModel); | 119 DISALLOW_COPY_AND_ASSIGN(RecentTabsSubMenuModel); |
| 117 }; | 120 }; |
| 118 | 121 |
| 119 #endif // CHROME_BROWSER_UI_TOOLBAR_RECENT_TABS_SUB_MENU_MODEL_H_ | 122 #endif // CHROME_BROWSER_UI_TOOLBAR_RECENT_TABS_SUB_MENU_MODEL_H_ |
| OLD | NEW |