| 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 |
| 42 // If |associator| is NULL, default associator for |browser|'s profile will | 47 // If |associator| is NULL, default associator for |browser|'s profile will |
| 43 // be used. Testing may require a specific |associator|. | 48 // be used. Testing may require a specific |associator|. |
| 44 RecentTabsSubMenuModel(ui::AcceleratorProvider* accelerator_provider, | 49 RecentTabsSubMenuModel(ui::AcceleratorProvider* accelerator_provider, |
| 45 Browser* browser, | 50 Browser* browser, |
| 46 browser_sync::SessionModelAssociator* associator); | 51 browser_sync::SessionModelAssociator* associator); |
| 47 virtual ~RecentTabsSubMenuModel(); | 52 virtual ~RecentTabsSubMenuModel(); |
| 48 | 53 |
| 49 // Overridden from ui::SimpleMenuModel::Delegate: | 54 // Overridden from ui::SimpleMenuModel::Delegate: |
| 50 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; | 55 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; |
| 51 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; | 56 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; |
| 52 virtual bool GetAcceleratorForCommandId( | 57 virtual bool GetAcceleratorForCommandId( |
| 53 int command_id, | 58 int command_id, |
| 54 ui::Accelerator* accelerator) OVERRIDE; | 59 ui::Accelerator* accelerator) OVERRIDE; |
| 55 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; | 60 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; |
| 56 virtual const gfx::Font* GetLabelFontAt(int index) const OVERRIDE; | 61 virtual const gfx::Font* GetLabelFontAt(int index) const OVERRIDE; |
| 57 | 62 |
| 58 int GetMaxWidthForItemAtIndex(int item_index) const; | 63 int GetMaxWidthForItemAtIndex(int item_index) const; |
| 59 bool GetURLAndTitleForItemAtIndex(int index, | 64 bool GetURLAndTitleForItemAtIndex(int index, |
| 60 std::string* url, | 65 std::string* url, |
| 61 string16* title) const; | 66 string16* title) const; |
| 62 | 67 |
| 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 | |
| 71 private: | 68 private: |
| 72 struct TabNavigationItem; | 69 struct TabNavigationItem; |
| 73 typedef std::vector<TabNavigationItem> TabNavigationItems; | 70 typedef std::vector<TabNavigationItem> TabNavigationItems; |
| 74 | 71 |
| 75 typedef std::vector<SessionID::id_type> WindowItems; | 72 typedef std::vector<SessionID::id_type> WindowItems; |
| 76 | 73 |
| 77 // Build the menu items by populating the model. | 74 // Build the menu items by populating the model. |
| 78 void Build(); | 75 void Build(); |
| 79 void BuildRecentTabs(); | 76 void BuildRecentTabs(); |
| 80 void BuildDevices(); | 77 void BuildDevices(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 gfx::Image default_favicon_; | 110 gfx::Image default_favicon_; |
| 114 | 111 |
| 115 CancelableTaskTracker cancelable_task_tracker_; | 112 CancelableTaskTracker cancelable_task_tracker_; |
| 116 | 113 |
| 117 base::WeakPtrFactory<RecentTabsSubMenuModel> weak_ptr_factory_; | 114 base::WeakPtrFactory<RecentTabsSubMenuModel> weak_ptr_factory_; |
| 118 | 115 |
| 119 DISALLOW_COPY_AND_ASSIGN(RecentTabsSubMenuModel); | 116 DISALLOW_COPY_AND_ASSIGN(RecentTabsSubMenuModel); |
| 120 }; | 117 }; |
| 121 | 118 |
| 122 #endif // CHROME_BROWSER_UI_TOOLBAR_RECENT_TABS_SUB_MENU_MODEL_H_ | 119 #endif // CHROME_BROWSER_UI_TOOLBAR_RECENT_TABS_SUB_MENU_MODEL_H_ |
| OLD | NEW |