| 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" |
| 11 #include "chrome/browser/favicon/favicon_service.h" | 11 #include "chrome/browser/favicon/favicon_service.h" |
| 12 #include "chrome/browser/sessions/tab_restore_service.h" | 12 #include "chrome/browser/sessions/tab_restore_service.h" |
| 13 #include "chrome/browser/sessions/tab_restore_service_observer.h" | 13 #include "chrome/browser/sessions/tab_restore_service_observer.h" |
| 14 #include "chrome/browser/sync/glue/synced_session.h" | 14 #include "chrome/browser/sync/glue/synced_session.h" |
| 15 #include "chrome/common/cancelable_task_tracker.h" | 15 #include "chrome/common/cancelable_task_tracker.h" |
| 16 #include "ui/base/accelerators/accelerator.h" | 16 #include "ui/base/accelerators/accelerator.h" |
| 17 #include "ui/base/models/simple_menu_model.h" | 17 #include "ui/base/models/simple_menu_model.h" |
| 18 | 18 |
| 19 class Browser; | 19 class Browser; |
| 20 struct SessionTab; | 20 struct SessionTab; |
| 21 | 21 |
| 22 namespace browser_sync { | 22 namespace browser_sync { |
| 23 class SessionModelAssociator; | 23 class OpenTabsUIDelegate; |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace chrome { | 26 namespace chrome { |
| 27 struct FaviconImageResult; | 27 struct FaviconImageResult; |
| 28 } | 28 } |
| 29 | 29 |
| 30 namespace gfx { | 30 namespace gfx { |
| 31 class Image; | 31 class Image; |
| 32 } | 32 } |
| 33 | 33 |
| 34 namespace ui { | 34 namespace ui { |
| 35 class AcceleratorProvider; | 35 class AcceleratorProvider; |
| 36 } | 36 } |
| 37 | 37 |
| 38 // A menu model that builds the contents of "Recent tabs" submenu, which include | 38 // A menu model that builds the contents of "Recent tabs" submenu, which include |
| 39 // the recently closed tabs/windows of current device i.e. local entries, and | 39 // the recently closed tabs/windows of current device i.e. local entries, and |
| 40 // opened tabs of other devices. | 40 // opened tabs of other devices. |
| 41 class RecentTabsSubMenuModel : public ui::SimpleMenuModel, | 41 class RecentTabsSubMenuModel : public ui::SimpleMenuModel, |
| 42 public ui::SimpleMenuModel::Delegate, | 42 public ui::SimpleMenuModel::Delegate, |
| 43 public TabRestoreServiceObserver { | 43 public TabRestoreServiceObserver { |
| 44 public: | 44 public: |
| 45 // Command Id for recently closed items header or disabled item to which the | 45 // Command Id for recently closed items header or disabled item to which the |
| 46 // accelerator string will be appended. | 46 // accelerator string will be appended. |
| 47 static const int kRecentlyClosedHeaderCommandId; | 47 static const int kRecentlyClosedHeaderCommandId; |
| 48 static const int kDisabledRecentlyClosedHeaderCommandId; | 48 static const int kDisabledRecentlyClosedHeaderCommandId; |
| 49 | 49 |
| 50 // If |associator| is NULL, default associator for |browser|'s profile will | 50 // If |delegate| is NULL, default delegate for |browser|'s profile will |
| 51 // be used. Testing may require a specific |associator|. | 51 // be used. Testing may require a specific |delegate|. |
| 52 RecentTabsSubMenuModel(ui::AcceleratorProvider* accelerator_provider, | 52 RecentTabsSubMenuModel(ui::AcceleratorProvider* accelerator_provider, |
| 53 Browser* browser, | 53 Browser* browser, |
| 54 browser_sync::SessionModelAssociator* associator); | 54 browser_sync::OpenTabsUIDelegate* delegate); |
| 55 virtual ~RecentTabsSubMenuModel(); | 55 virtual ~RecentTabsSubMenuModel(); |
| 56 | 56 |
| 57 // Overridden from ui::SimpleMenuModel::Delegate: | 57 // Overridden from ui::SimpleMenuModel::Delegate: |
| 58 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; | 58 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; |
| 59 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; | 59 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; |
| 60 virtual bool GetAcceleratorForCommandId( | 60 virtual bool GetAcceleratorForCommandId( |
| 61 int command_id, | 61 int command_id, |
| 62 ui::Accelerator* accelerator) OVERRIDE; | 62 ui::Accelerator* accelerator) OVERRIDE; |
| 63 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; | 63 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; |
| 64 virtual const gfx::Font* GetLabelFontAt(int index) const OVERRIDE; | 64 virtual const gfx::Font* GetLabelFontAt(int index) const OVERRIDE; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 void OnFaviconDataAvailable(int command_id, | 110 void OnFaviconDataAvailable(int command_id, |
| 111 const chrome::FaviconImageResult& image_result); | 111 const chrome::FaviconImageResult& image_result); |
| 112 | 112 |
| 113 // Clear all recently closed tabs and windows. | 113 // Clear all recently closed tabs and windows. |
| 114 void ClearLocalEntries(); | 114 void ClearLocalEntries(); |
| 115 | 115 |
| 116 // Converts |command_id| of menu item to index in local or other devices' | 116 // Converts |command_id| of menu item to index in local or other devices' |
| 117 // TabNavigationItems, and returns the corresponding local or other devices' | 117 // TabNavigationItems, and returns the corresponding local or other devices' |
| 118 // TabNavigationItems in |tab_items|. | 118 // TabNavigationItems in |tab_items|. |
| 119 int CommandIdToTabVectorIndex(int command_id, TabNavigationItems** tab_items); | 119 int CommandIdToTabVectorIndex(int command_id, TabNavigationItems** tab_items); |
| 120 browser_sync::SessionModelAssociator* GetModelAssociator(); | 120 browser_sync::OpenTabsUIDelegate* GetOpenTabsUIDelegate(); |
| 121 | 121 |
| 122 // Overridden from TabRestoreServiceObserver: | 122 // Overridden from TabRestoreServiceObserver: |
| 123 virtual void TabRestoreServiceChanged(TabRestoreService* service) OVERRIDE; | 123 virtual void TabRestoreServiceChanged(TabRestoreService* service) OVERRIDE; |
| 124 virtual void TabRestoreServiceDestroyed(TabRestoreService* service) OVERRIDE; | 124 virtual void TabRestoreServiceDestroyed(TabRestoreService* service) OVERRIDE; |
| 125 | 125 |
| 126 Browser* browser_; // Weak. | 126 Browser* browser_; // Weak. |
| 127 | 127 |
| 128 browser_sync::SessionModelAssociator* associator_; // Weak. | 128 browser_sync::OpenTabsUIDelegate* open_tabs_; // Weak. |
| 129 | 129 |
| 130 // Accelerator for reopening last closed tab. | 130 // Accelerator for reopening last closed tab. |
| 131 ui::Accelerator reopen_closed_tab_accelerator_; | 131 ui::Accelerator reopen_closed_tab_accelerator_; |
| 132 | 132 |
| 133 // Navigation items for local recently closed tabs. The |command_id| for | 133 // Navigation items for local recently closed tabs. The |command_id| for |
| 134 // these is set to |kFirstLocalTabCommandId| plus the index into the vector. | 134 // these is set to |kFirstLocalTabCommandId| plus the index into the vector. |
| 135 // Upon invocation of the menu, the navigation information is retrieved from | 135 // Upon invocation of the menu, the navigation information is retrieved from |
| 136 // |local_tab_navigation_items_| and used to navigate to the item specified. | 136 // |local_tab_navigation_items_| and used to navigate to the item specified. |
| 137 TabNavigationItems local_tab_navigation_items_; | 137 TabNavigationItems local_tab_navigation_items_; |
| 138 | 138 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 155 | 155 |
| 156 CancelableTaskTracker local_tab_cancelable_task_tracker_; | 156 CancelableTaskTracker local_tab_cancelable_task_tracker_; |
| 157 CancelableTaskTracker other_devices_tab_cancelable_task_tracker_; | 157 CancelableTaskTracker other_devices_tab_cancelable_task_tracker_; |
| 158 | 158 |
| 159 base::WeakPtrFactory<RecentTabsSubMenuModel> weak_ptr_factory_; | 159 base::WeakPtrFactory<RecentTabsSubMenuModel> weak_ptr_factory_; |
| 160 | 160 |
| 161 DISALLOW_COPY_AND_ASSIGN(RecentTabsSubMenuModel); | 161 DISALLOW_COPY_AND_ASSIGN(RecentTabsSubMenuModel); |
| 162 }; | 162 }; |
| 163 | 163 |
| 164 #endif // CHROME_BROWSER_UI_TOOLBAR_RECENT_TABS_SUB_MENU_MODEL_H_ | 164 #endif // CHROME_BROWSER_UI_TOOLBAR_RECENT_TABS_SUB_MENU_MODEL_H_ |
| OLD | NEW |