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 | |
13 namespace content { | |
14 class WebUI; | |
15 } | |
16 | |
17 namespace gfx { | |
18 class Point; | |
19 } | |
20 | |
21 namespace views { | |
22 class MenuRunner; | |
23 } | |
24 | |
25 // A menu model that builds the contents of the other device menu. This menu | |
26 // is displayed when a device on the ntp_search device page is clicked and | |
27 // contains the session for that device. This is implemented natively rather | |
28 // than in JavaScript to allow the menu to extend into the natively-rendered | |
29 // section of the NTP. | |
30 class OtherDeviceMenu : public ui::SimpleMenuModel::Delegate { | |
31 | |
32 public: | |
33 OtherDeviceMenu(content::WebUI* web_ui, | |
34 const std::string& session_id, | |
35 const gfx::Point& location); | |
36 virtual ~OtherDeviceMenu(); | |
37 | |
38 // Displays the menu. | |
39 void ShowMenu(); | |
40 | |
41 // ui::SimpleMenuModel::Delegate overrides: | |
42 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; | |
43 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; | |
44 virtual void ExecuteCommand(int command_id) OVERRIDE; | |
45 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; | |
46 virtual bool GetAcceleratorForCommandId( | |
47 int command_id, | |
48 ui::Accelerator* accelerator) OVERRIDE; | |
49 | |
50 private: | |
51 // Adds the tabs of the |session_id_| session to the menu. | |
52 void AddDeviceTabs(); | |
53 | |
54 content::WebUI* web_ui_; // weak | |
55 const std::string& session_id_; | |
56 // The anchor point for the top-left corner of the menu. | |
57 const gfx::Point& location_; | |
58 ui::SimpleMenuModel menu_model_; | |
59 scoped_ptr<views::MenuRunner> menu_runner_; | |
60 | |
61 // The tab data for each menu item, in the order in which they're displayed. | |
62 // |command_id| i corresponds to index i. | |
63 typedef std::vector<linked_ptr<DictionaryValue> > TabData; | |
dhollowa
2012/10/02 00:02:08
nit: typedefs usually live just under their enclos
jeremycho
2012/10/02 04:49:00
Done.
| |
64 TabData tab_data_; | |
65 | |
66 DISALLOW_COPY_AND_ASSIGN(OtherDeviceMenu); | |
67 }; | |
68 | |
69 #endif // CHROME_BROWSER_UI_SEARCH_OTHER_DEVICE_MENU_H_ | |
OLD | NEW |