Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h

Issue 11298004: alternate ntp: add "Recent Tabs" submenu to wrench menu (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased to resolve conflicts Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 // If |associator| is NULL, default associator for |browser|'s profile will
37 // be used. Testing may require a specific |associator|.
38 RecentTabsSubMenuModel(ui::AcceleratorProvider* accelerator_provider,
39 Browser* browser,
40 browser_sync::SessionModelAssociator* associator);
41 virtual ~RecentTabsSubMenuModel();
42
43 // Overridden from ui::SimpleMenuModel::Delegate:
44 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE;
45 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE;
46 virtual bool GetAcceleratorForCommandId(
47 int command_id,
48 ui::Accelerator* accelerator) OVERRIDE;
49 virtual bool IsItemForCommandIdDynamic(int command_id) const OVERRIDE;
50 virtual string16 GetLabelForCommandId(int command_id) const OVERRIDE;
51 virtual void ExecuteCommand(int command_id) OVERRIDE;
52 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE;
53
54 private:
55 struct NavigationItem;
56 typedef std::vector<NavigationItem> NavigationItems;
57
58 // Build the menu items by populating the model.
59 void Build();
60 void BuildLastClosed();
61 void BuildDevices();
62 void BuildForeignTabItem(const std::string& session_tag,
63 const SessionTab& tab,
64 const std::string& session_name,
65 bool need_separator);
66 void AddFavicon(int model_index, int command_id, const GURL& url);
67 void OnFaviconDataAvailable(FaviconService::Handle handle,
68 const history::FaviconImageResult& image_result);
69 browser_sync::SessionModelAssociator* GetModelAssociator();
70
71 Browser* browser_; // Weak.
72
73 browser_sync::SessionModelAssociator* associator_; // Weak.
74
75 // Accelerator for reopening last closed tab.
76 ui::Accelerator reopen_closed_tab_accelerator_;
77
78 // Navigation items. The |command_id| is set to kFirstTabCommandId plus the
79 // index into this vector. Upon invocation of the menu, the navigation
80 // information is retrieved from |model_| and used to navigate to the item
81 // specified.
82 NavigationItems model_;
83
84 gfx::Image default_favicon_;
85
86 CancelableRequestConsumerTSimple<int> favicon_consumer_;
87
88 base::WeakPtrFactory<RecentTabsSubMenuModel> weak_ptr_factory_;
89
90 DISALLOW_COPY_AND_ASSIGN(RecentTabsSubMenuModel);
91 };
92
93 #endif // CHROME_BROWSER_UI_TOOLBAR_RECENT_TABS_SUB_MENU_MODEL_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_command_controller.cc ('k') | chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698