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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h
diff --git a/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h b/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h
new file mode 100644
index 0000000000000000000000000000000000000000..f4df281b14ddb00d97d44321dae20aaab295d1e1
--- /dev/null
+++ b/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h
@@ -0,0 +1,87 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_TOOLBAR_RECENT_TABS_SUB_MENU_MODEL_H_
+#define CHROME_BROWSER_UI_TOOLBAR_RECENT_TABS_SUB_MENU_MODEL_H_
+
+#include <set>
+
+#include "base/memory/weak_ptr.h"
+#include "chrome/browser/favicon/favicon_service.h"
+#include "chrome/browser/sessions/tab_restore_service.h"
+#include "ui/base/models/simple_menu_model.h"
+
+class Browser;
+class SessionTab;
+
+namespace browser_sync {
+class SessionModelAssociator;
+}
+
+namespace gfx {
+class Image;
+}
+
+namespace ui {
+class AcceleratorProvider;
+}
+
+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
+ public ui::SimpleMenuModel::Delegate {
+ public:
+ RecentTabsSubMenuModel(ui::AcceleratorProvider* accelerator_provider,
+ Browser* browser);
+ virtual ~RecentTabsSubMenuModel();
+
+ // Overridden from ui::SimpleMenuModel::Delegate:
+ virtual bool IsCommandIdChecked(int command_id) const OVERRIDE;
+ virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE;
+ virtual bool GetAcceleratorForCommandId(
+ int command_id,
+ ui::Accelerator* accelerator) OVERRIDE;
+ virtual void ExecuteCommand(int command_id) OVERRIDE;
+ virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE;
+
+ private:
+ struct NavigationItem;
+ typedef std::vector<NavigationItem> NavigationItems;
+
+ // Build the menu items by populating the model.
+ void Build();
+ void BuildRecentlyClosed();
+ bool BuildRecentlyClosedTabItem(const TabRestoreService::Tab& entry,
+ std::set<NavigationItem>* seen_tabs);
+ void BuildDevices();
+ bool BuildForeignTabItem(const std::string& session_tag,
+ const SessionTab& tab,
+ const std::string& session_name,
+ bool need_separator);
+ void BuildTabToRestore(const NavigationItem& item,
+ const string16& tab_title);
+ void AddFavicon(int index_in_menu, const GURL& url);
+ void OnFaviconDataAvailable(FaviconService::Handle handle,
+ const history::FaviconImageResult& image_result);
+ int GetIndexInMenu(int model_index) const;
+ browser_sync::SessionModelAssociator* GetModelAssociator() const;
+
+ ui::AcceleratorProvider* accelerator_provider_; // Weak.
+
+ Browser* browser_; // Weak.
+
+ // Navigation items. The |command_id| is set to the index into this vector.
+ // Upon invocation of the menu, the navigation information is retrieved from
+ // |model_| and used to navigate to the item specified.
+ NavigationItems model_;
+
+ // Weak.
+ gfx::Image* default_favicon_;
+
+ CancelableRequestConsumerTSimple<int> favicon_consumer_;
+
+ base::WeakPtrFactory<RecentTabsSubMenuModel> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(RecentTabsSubMenuModel);
+};
+
+#endif // CHROME_BROWSER_UI_TOOLBAR_RECENT_TABS_SUB_MENU_MODEL_H_

Powered by Google App Engine
This is Rietveld 408576698