Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_TOOLBAR_RECENT_TABS_SUB_MENU_MODEL_H_ | |
| 6 #define CHROME_BROWSER_UI_TOOLBAR_RECENT_TABS_SUB_MENU_MODEL_H_ | |
| 7 | |
| 8 #include <set> | |
| 9 | |
| 10 #include "base/memory/weak_ptr.h" | |
| 11 #include "chrome/browser/favicon/favicon_service.h" | |
| 12 #include "chrome/browser/sessions/tab_restore_service.h" | |
| 13 #include "ui/base/accelerators/accelerator.h" | |
| 14 #include "ui/base/models/simple_menu_model.h" | |
| 15 | |
| 16 class Browser; | |
| 17 struct SessionTab; | |
| 18 | |
| 19 namespace browser_sync { | |
| 20 class SessionModelAssociator; | |
| 21 } | |
| 22 | |
| 23 namespace gfx { | |
| 24 class Image; | |
| 25 } | |
| 26 | |
| 27 namespace ui { | |
| 28 class AcceleratorProvider; | |
| 29 } | |
| 30 | |
| 31 // A menu model that builds the contents of "Recent tabs" submenu, which include | |
| 32 // the last closed tab and opened tabs of other devices. | |
| 33 class RecentTabsSubMenuModel : public ui::SimpleMenuModel, | |
| 34 public ui::SimpleMenuModel::Delegate { | |
| 35 public: | |
| 36 RecentTabsSubMenuModel(ui::AcceleratorProvider* accelerator_provider, | |
| 37 Browser* browser); | |
| 38 virtual ~RecentTabsSubMenuModel(); | |
| 39 | |
| 40 // Overridden from ui::SimpleMenuModel::Delegate: | |
| 41 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; | |
| 42 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; | |
| 43 virtual bool GetAcceleratorForCommandId( | |
| 44 int command_id, | |
| 45 ui::Accelerator* accelerator) OVERRIDE; | |
| 46 virtual bool IsItemForCommandIdDynamic(int command_id) const OVERRIDE; | |
| 47 virtual string16 GetLabelForCommandId(int command_id) const OVERRIDE; | |
| 48 virtual void ExecuteCommand(int command_id) OVERRIDE; | |
| 49 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; | |
| 50 | |
| 51 private: | |
| 52 struct NavigationItem; | |
| 53 typedef std::vector<NavigationItem> NavigationItems; | |
| 54 | |
| 55 // Build the menu items by populating the model. | |
| 56 void Build(); | |
| 57 void BuildLastClosed(); | |
| 58 void BuildDevices(); | |
| 59 bool BuildForeignTabItem(const std::string& session_tag, | |
| 60 const SessionTab& tab, | |
| 61 const std::string& session_name, | |
| 62 bool need_separator); | |
| 63 void AddFavicon(int index_in_menu, const GURL& url); | |
| 64 void OnFaviconDataAvailable(FaviconService::Handle handle, | |
| 65 const history::FaviconImageResult& image_result); | |
| 66 browser_sync::SessionModelAssociator* GetModelAssociator() const; | |
|
sky
2012/11/07 22:33:40
Remove the const since you're returning a non-cons
kuan
2012/11/08 22:57:54
Done.
| |
| 67 | |
| 68 Browser* browser_; // Weak. | |
| 69 | |
| 70 // Accelerator for reopening last closed tab. | |
| 71 ui::Accelerator reopen_closed_tab_accelerator_; | |
| 72 | |
| 73 // Navigation items. The |command_id| is set to the index into this vector. | |
| 74 // Upon invocation of the menu, the navigation information is retrieved from | |
| 75 // |model_| and used to navigate to the item specified. | |
| 76 NavigationItems model_; | |
| 77 | |
| 78 // Weak. | |
| 79 gfx::Image* default_favicon_; | |
| 80 | |
| 81 CancelableRequestConsumerTSimple<int> favicon_consumer_; | |
|
sky
2012/11/07 22:33:40
nit: two spaces here.
kuan
2012/11/08 22:57:54
Done.
| |
| 82 | |
| 83 base::WeakPtrFactory<RecentTabsSubMenuModel> weak_ptr_factory_; | |
| 84 | |
| 85 DISALLOW_COPY_AND_ASSIGN(RecentTabsSubMenuModel); | |
| 86 }; | |
| 87 | |
| 88 #endif // CHROME_BROWSER_UI_TOOLBAR_RECENT_TABS_SUB_MENU_MODEL_H_ | |
| OLD | NEW |