Chromium Code Reviews| Index: chrome/browser/ui/search/other_device_menu.h |
| diff --git a/chrome/browser/ui/search/other_device_menu.h b/chrome/browser/ui/search/other_device_menu.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e728131166fae4e64e51658c228656bd5f25b91a |
| --- /dev/null |
| +++ b/chrome/browser/ui/search/other_device_menu.h |
| @@ -0,0 +1,78 @@ |
| +// Copyright (c) 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_SEARCH_OTHER_DEVICE_MENU_H_ |
| +#define CHROME_BROWSER_UI_SEARCH_OTHER_DEVICE_MENU_H_ |
| + |
| +#include "base/memory/linked_ptr.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/values.h" |
| +#include "ui/base/models/simple_menu_model.h" |
| +#include "ui/gfx/point.h" |
| + |
| +namespace content { |
| +class WebUI; |
| +} |
| + |
| +namespace views { |
| +class MenuRunner; |
| +} |
| + |
| +// A menu model that builds the contents of the other device menu. This menu |
| +// is displayed when a device on the ntp_search device page is clicked and |
| +// contains the session for that device. This is implemented natively rather |
| +// than in JavaScript to allow the menu to extend into the natively-rendered |
| +// section of the NTP. |
| +class OtherDeviceMenu : public ui::SimpleMenuModel::Delegate { |
| + public: |
| + // Enumerates the different menu item types. |
|
dhollowa
2012/10/09 15:13:42
This enum should be private, or better yet declare
jeremycho
2012/10/09 19:45:38
Done.
|
| + enum ItemType { |
| + // An item for restoring a single tab. |
| + TAB, |
| + |
| + // An item for restoring all tabs in this session. |
| + OPEN_ALL, |
| + |
| + // Number of enum entries, used for UMA histogram reporting macros. |
| + ITEM_TYPE_ENUM_COUNT, |
| + }; |
| + |
| + OtherDeviceMenu(content::WebUI* web_ui, |
| + std::string session_id, |
|
dhollowa
2012/10/09 15:13:42
These should remain const references. Just the me
jeremycho
2012/10/09 19:45:38
Ah sorry. Done.
On 2012/10/09 15:13:42, dhollowa
|
| + gfx::Point location); |
| + virtual ~OtherDeviceMenu(); |
| + |
| + // Displays the menu. |
| + void ShowMenu(); |
| + |
| + // ui::SimpleMenuModel::Delegate overrides: |
| + virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; |
| + virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; |
| + virtual void ExecuteCommand(int command_id) OVERRIDE; |
| + virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; |
| + virtual bool GetAcceleratorForCommandId( |
| + int command_id, |
| + ui::Accelerator* accelerator) OVERRIDE; |
| + |
| + private: |
| + typedef std::vector<linked_ptr<DictionaryValue> > TabData; |
| + |
| + // Adds the tabs of the |session_id_| session to the menu. |
| + void AddDeviceTabs(); |
| + |
| + content::WebUI* web_ui_; // weak |
| + std::string session_id_; |
| + // The anchor point for the top-left corner of the menu. |
| + gfx::Point location_; |
| + ui::SimpleMenuModel menu_model_; |
| + scoped_ptr<views::MenuRunner> menu_runner_; |
| + |
| + // The tab data for each menu item, in the order in which they're displayed. |
| + // |command_id| i corresponds to index i. |
| + TabData tab_data_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(OtherDeviceMenu); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_UI_SEARCH_OTHER_DEVICE_MENU_H_ |