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_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_UI_SEARCH_OTHER_DEVICE_MENU_CONTROLLER_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 // The view. |
| 19 class OtherDeviceMenu { |
| 20 public: |
| 21 virtual ~OtherDeviceMenu(); |
| 22 |
| 23 // Displays the menu in the specified location and window. |
| 24 virtual void ShowMenu( |
| 25 gfx::NativeWindow window, const gfx::Point& location) = 0; |
| 26 |
| 27 static OtherDeviceMenu* Create(ui::SimpleMenuModel* menu_model); |
| 28 }; |
| 29 |
| 30 // A controller that builds the menu model and drives the view. This menu is |
| 31 // displayed when a device on the ntp_search device page is clicked and contains |
| 32 // the session for that device. This is implemented natively rather than in |
| 33 // JavaScript to allow the menu to extend into the natively-rendered section of |
| 34 // the NTP. |
| 35 class OtherDeviceMenuController : public ui::SimpleMenuModel::Delegate { |
| 36 public: |
| 37 OtherDeviceMenuController(content::WebUI* web_ui, |
| 38 const std::string& session_id, |
| 39 const gfx::Point& location); |
| 40 virtual ~OtherDeviceMenuController(); |
| 41 |
| 42 // Displays the menu by invoking the view. |
| 43 void ShowMenu(); |
| 44 |
| 45 private: |
| 46 // ui::SimpleMenuModel::Delegate overrides: |
| 47 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; |
| 48 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; |
| 49 virtual void ExecuteCommand(int command_id) OVERRIDE; |
| 50 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; |
| 51 virtual bool GetAcceleratorForCommandId( |
| 52 int command_id, |
| 53 ui::Accelerator* accelerator) OVERRIDE; |
| 54 |
| 55 typedef std::vector<linked_ptr<DictionaryValue> > TabData; |
| 56 |
| 57 // Adds the tabs of the |session_id_| session to the menu. |
| 58 void AddDeviceTabs(); |
| 59 |
| 60 // Weak - attached to the handler that created this menu. |
| 61 content::WebUI* web_ui_; |
| 62 |
| 63 // The session ID of the tabs displayed in the menu. |
| 64 std::string session_id_; |
| 65 |
| 66 // The anchor point for the top-left corner of the menu. |
| 67 gfx::Point location_; |
| 68 |
| 69 ui::SimpleMenuModel menu_model_; |
| 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 scoped_ptr<OtherDeviceMenu> view_; |
| 76 |
| 77 DISALLOW_COPY_AND_ASSIGN(OtherDeviceMenuController); |
| 78 }; |
| 79 |
| 80 #endif // CHROME_BROWSER_UI_SEARCH_OTHER_DEVICE_MENU_CONTROLLER_H_ |
OLD | NEW |