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 OtherDeviceMenu(content::WebUI* web_ui, |
| 30 const std::string& session_id, |
| 31 const gfx::Point& location); |
| 32 virtual ~OtherDeviceMenu(); |
| 33 |
| 34 // Displays the menu. |
| 35 void ShowMenu(); |
| 36 |
| 37 private: |
| 38 // ui::SimpleMenuModel::Delegate overrides: |
| 39 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; |
| 40 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; |
| 41 virtual void ExecuteCommand(int command_id) OVERRIDE; |
| 42 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; |
| 43 virtual bool GetAcceleratorForCommandId( |
| 44 int command_id, |
| 45 ui::Accelerator* accelerator) OVERRIDE; |
| 46 |
| 47 typedef std::vector<linked_ptr<DictionaryValue> > TabData; |
| 48 |
| 49 // Adds the tabs of the |session_id_| session to the menu. |
| 50 void AddDeviceTabs(); |
| 51 |
| 52 // Weak - attached to the handler that created this menu. |
| 53 content::WebUI* web_ui_; |
| 54 |
| 55 // The session ID of the tabs displayed in the menu. |
| 56 std::string session_id_; |
| 57 |
| 58 // The anchor point for the top-left corner of the menu. |
| 59 gfx::Point location_; |
| 60 |
| 61 ui::SimpleMenuModel menu_model_; |
| 62 scoped_ptr<views::MenuRunner> menu_runner_; |
| 63 |
| 64 // The tab data for each menu item, in the order in which they're displayed. |
| 65 // |command_id| i corresponds to index i. |
| 66 TabData tab_data_; |
| 67 |
| 68 DISALLOW_COPY_AND_ASSIGN(OtherDeviceMenu); |
| 69 }; |
| 70 |
| 71 #endif // CHROME_BROWSER_UI_SEARCH_OTHER_DEVICE_MENU_H_ |
OLD | NEW |