| 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..0714661b95d73239849c5564cbf3f1cd544eea4e
|
| --- /dev/null
|
| +++ b/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h
|
| @@ -0,0 +1,93 @@
|
| +// 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/accelerators/accelerator.h"
|
| +#include "ui/base/models/simple_menu_model.h"
|
| +
|
| +class Browser;
|
| +struct SessionTab;
|
| +
|
| +namespace browser_sync {
|
| +class SessionModelAssociator;
|
| +}
|
| +
|
| +namespace gfx {
|
| +class Image;
|
| +}
|
| +
|
| +namespace ui {
|
| +class AcceleratorProvider;
|
| +}
|
| +
|
| +// A menu model that builds the contents of "Recent tabs" submenu, which include
|
| +// the last closed tab and opened tabs of other devices.
|
| +class RecentTabsSubMenuModel : public ui::SimpleMenuModel,
|
| + public ui::SimpleMenuModel::Delegate {
|
| + public:
|
| + // If |associator| is NULL, default associator for |browser|'s profile will
|
| + // be used. Testing may require a specific |associator|.
|
| + RecentTabsSubMenuModel(ui::AcceleratorProvider* accelerator_provider,
|
| + Browser* browser,
|
| + browser_sync::SessionModelAssociator* associator);
|
| + 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 bool IsItemForCommandIdDynamic(int command_id) const OVERRIDE;
|
| + virtual string16 GetLabelForCommandId(int command_id) const 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 BuildLastClosed();
|
| + void BuildDevices();
|
| + void BuildForeignTabItem(const std::string& session_tag,
|
| + const SessionTab& tab,
|
| + const std::string& session_name,
|
| + bool need_separator);
|
| + void AddFavicon(int model_index, int command_id, const GURL& url);
|
| + void OnFaviconDataAvailable(FaviconService::Handle handle,
|
| + const history::FaviconImageResult& image_result);
|
| + browser_sync::SessionModelAssociator* GetModelAssociator();
|
| +
|
| + Browser* browser_; // Weak.
|
| +
|
| + browser_sync::SessionModelAssociator* associator_; // Weak.
|
| +
|
| + // Accelerator for reopening last closed tab.
|
| + ui::Accelerator reopen_closed_tab_accelerator_;
|
| +
|
| + // Navigation items. The |command_id| is set to kFirstTabCommandId plus 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_;
|
| +
|
| + 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_
|
|
|