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

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: 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/models/simple_menu_model.h"
14
15 class Browser;
16 class SessionTab;
17
18 namespace browser_sync {
19 class SessionModelAssociator;
20 }
21
22 namespace gfx {
23 class Image;
24 }
25
26 namespace ui {
27 class AcceleratorProvider;
28 }
29
30 class RecentTabsSubMenuModel : public ui::SimpleMenuModel,
sky 2012/11/07 00:10:47 Add description, and I think this should be Recent
kuan 2012/11/07 02:29:46 added description. but didn't rename, 'cos it con
31 public ui::SimpleMenuModel::Delegate {
32 public:
33 RecentTabsSubMenuModel(ui::AcceleratorProvider* accelerator_provider,
34 Browser* browser);
35 virtual ~RecentTabsSubMenuModel();
36
37 // Overridden from ui::SimpleMenuModel::Delegate:
38 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE;
39 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE;
40 virtual bool GetAcceleratorForCommandId(
41 int command_id,
42 ui::Accelerator* accelerator) OVERRIDE;
43 virtual void ExecuteCommand(int command_id) OVERRIDE;
44 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE;
45
46 private:
47 struct NavigationItem;
48 typedef std::vector<NavigationItem> NavigationItems;
49
50 // Build the menu items by populating the model.
51 void Build();
52 void BuildRecentlyClosed();
53 bool BuildRecentlyClosedTabItem(const TabRestoreService::Tab& entry,
54 std::set<NavigationItem>* seen_tabs);
55 void BuildDevices();
56 bool BuildForeignTabItem(const std::string& session_tag,
57 const SessionTab& tab,
58 const std::string& session_name,
59 bool need_separator);
60 void BuildTabToRestore(const NavigationItem& item,
61 const string16& tab_title);
62 void AddFavicon(int index_in_menu, const GURL& url);
63 void OnFaviconDataAvailable(FaviconService::Handle handle,
64 const history::FaviconImageResult& image_result);
65 int GetIndexInMenu(int model_index) const;
66 browser_sync::SessionModelAssociator* GetModelAssociator() const;
67
68 ui::AcceleratorProvider* accelerator_provider_; // Weak.
69
70 Browser* browser_; // Weak.
71
72 // Navigation items. The |command_id| is set to the index into this vector.
73 // Upon invocation of the menu, the navigation information is retrieved from
74 // |model_| and used to navigate to the item specified.
75 NavigationItems model_;
76
77 // Weak.
78 gfx::Image* default_favicon_;
79
80 CancelableRequestConsumerTSimple<int> favicon_consumer_;
81
82 base::WeakPtrFactory<RecentTabsSubMenuModel> weak_ptr_factory_;
83
84 DISALLOW_COPY_AND_ASSIGN(RecentTabsSubMenuModel);
85 };
86
87 #endif // CHROME_BROWSER_UI_TOOLBAR_RECENT_TABS_SUB_MENU_MODEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698