Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 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_SEARCH_OTHER_DEVICE_MENU_H_ | |
| 6 #define CHROME_BROWSER_UI_SEARCH_OTHER_DEVICE_MENU_H_ | |
| 7 | |
| 8 #include "base/memory/linked_ptr.h" | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/values.h" | |
| 11 #include "ui/base/models/simple_menu_model.h" | |
| 12 #include "ui/gfx/point.h" | |
| 13 | |
| 14 namespace content { | |
| 15 class WebUI; | |
| 16 } | |
| 17 | |
| 18 namespace views { | |
| 19 class MenuRunner; | |
| 20 } | |
| 21 | |
| 22 // A menu model that builds the contents of the other device menu. This menu | |
| 23 // is displayed when a device on the ntp_search device page is clicked and | |
| 24 // contains the session for that device. This is implemented natively rather | |
| 25 // than in JavaScript to allow the menu to extend into the natively-rendered | |
| 26 // section of the NTP. | |
| 27 class OtherDeviceMenu : public ui::SimpleMenuModel::Delegate { | |
| 28 public: | |
| 29 // 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.
| |
| 30 enum ItemType { | |
| 31 // An item for restoring a single tab. | |
| 32 TAB, | |
| 33 | |
| 34 // An item for restoring all tabs in this session. | |
| 35 OPEN_ALL, | |
| 36 | |
| 37 // Number of enum entries, used for UMA histogram reporting macros. | |
| 38 ITEM_TYPE_ENUM_COUNT, | |
| 39 }; | |
| 40 | |
| 41 OtherDeviceMenu(content::WebUI* web_ui, | |
| 42 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
| |
| 43 gfx::Point location); | |
| 44 virtual ~OtherDeviceMenu(); | |
| 45 | |
| 46 // Displays the menu. | |
| 47 void ShowMenu(); | |
| 48 | |
| 49 // ui::SimpleMenuModel::Delegate overrides: | |
| 50 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; | |
| 51 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; | |
| 52 virtual void ExecuteCommand(int command_id) OVERRIDE; | |
| 53 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; | |
| 54 virtual bool GetAcceleratorForCommandId( | |
| 55 int command_id, | |
| 56 ui::Accelerator* accelerator) OVERRIDE; | |
| 57 | |
| 58 private: | |
| 59 typedef std::vector<linked_ptr<DictionaryValue> > TabData; | |
| 60 | |
| 61 // Adds the tabs of the |session_id_| session to the menu. | |
| 62 void AddDeviceTabs(); | |
| 63 | |
| 64 content::WebUI* web_ui_; // weak | |
| 65 std::string session_id_; | |
| 66 // The anchor point for the top-left corner of the menu. | |
| 67 gfx::Point location_; | |
| 68 ui::SimpleMenuModel menu_model_; | |
| 69 scoped_ptr<views::MenuRunner> menu_runner_; | |
| 70 | |
| 71 // The tab data for each menu item, in the order in which they're displayed. | |
| 72 // |command_id| i corresponds to index i. | |
| 73 TabData tab_data_; | |
| 74 | |
| 75 DISALLOW_COPY_AND_ASSIGN(OtherDeviceMenu); | |
| 76 }; | |
| 77 | |
| 78 #endif // CHROME_BROWSER_UI_SEARCH_OTHER_DEVICE_MENU_H_ | |
| OLD | NEW |