| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 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_CHROMEOS_VIEWS_WEBUI_MENU_WIDGET_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_VIEWS_WEBUI_MENU_WIDGET_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <string> | |
| 10 | |
| 11 #include "views/widget/widget_gtk.h" | |
| 12 | |
| 13 class DOMView; | |
| 14 class ExtensionApiTest; | |
| 15 | |
| 16 namespace chromeos { | |
| 17 | |
| 18 class MenuLocator; | |
| 19 class NativeMenuWebUI; | |
| 20 | |
| 21 // WebUIMenuWidget is a window widget for a Web UI based menu. | |
| 22 class WebUIMenuWidget : public views::WidgetGtk { | |
| 23 public: | |
| 24 // Create a Window for the NativeMenuDMOUI. |root| specifies if | |
| 25 // the menu is root menu. | |
| 26 WebUIMenuWidget(NativeMenuWebUI* webui_menu, bool root); | |
| 27 virtual ~WebUIMenuWidget(); | |
| 28 | |
| 29 // WidgetGtk overrides: | |
| 30 virtual void Init(gfx::NativeView parent, const gfx::Rect& bounds) OVERRIDE; | |
| 31 virtual void Hide() OVERRIDE; | |
| 32 virtual void Close() OVERRIDE; | |
| 33 virtual void ReleaseNativeCapture() OVERRIDE; | |
| 34 virtual gboolean OnGrabBrokeEvent(GtkWidget* widget, GdkEvent* event) | |
| 35 OVERRIDE; | |
| 36 virtual void OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation) | |
| 37 OVERRIDE; | |
| 38 | |
| 39 // Returns NativeMenuWebUI that owns this widget. | |
| 40 NativeMenuWebUI* webui_menu() const { | |
| 41 return webui_menu_; | |
| 42 } | |
| 43 | |
| 44 // Returns true if the menu widget is a root. | |
| 45 bool is_root() const { | |
| 46 return is_root_; | |
| 47 } | |
| 48 | |
| 49 // Returns true if the menu widget has input grab. | |
| 50 bool did_input_grab() const { | |
| 51 return did_input_grab_; | |
| 52 } | |
| 53 | |
| 54 // Enables/Disables menu scroll. | |
| 55 void EnableScroll(bool enabled); | |
| 56 | |
| 57 // Tell the gtk to send all input events (mouse, keyboard) to this | |
| 58 // Widget. If |selectItem| is true, it highlights the selected item | |
| 59 // (or select 1st selectable item if none is selected). | |
| 60 void EnableInput(bool select_item); | |
| 61 | |
| 62 // Executes given |javascript|. | |
| 63 void ExecuteJavascript(const std::wstring& javascript); | |
| 64 | |
| 65 // Show the menu using |locator|. Ownership of locator is transferred | |
| 66 // to this widget. | |
| 67 void ShowAt(MenuLocator* locator); | |
| 68 | |
| 69 // Updates the size | |
| 70 void SetSize(const gfx::Size& new_size); | |
| 71 | |
| 72 // Returns the menu locator owned by this widget. | |
| 73 const MenuLocator* menu_locator() const { | |
| 74 return menu_locator_.get(); | |
| 75 } | |
| 76 | |
| 77 // Returns WebUIMenuWidget that contains given native. This returns | |
| 78 // NULL if not found. | |
| 79 static WebUIMenuWidget* FindWebUIMenuWidget(gfx::NativeView native); | |
| 80 | |
| 81 private: | |
| 82 // Capture the X pointer grab. This also enables input on the widget by | |
| 83 // calling EnableInput(false). | |
| 84 void CaptureGrab(); | |
| 85 | |
| 86 // Clears GTK grab. | |
| 87 void ClearGrabWidget(); | |
| 88 | |
| 89 // NativeMenu object that owns this widget. | |
| 90 NativeMenuWebUI* webui_menu_; | |
| 91 | |
| 92 // DOMView to render the menu contents. | |
| 93 DOMView* dom_view_; | |
| 94 | |
| 95 // MenuLocator that controls the position of this menu widget. | |
| 96 scoped_ptr<chromeos::MenuLocator> menu_locator_; | |
| 97 | |
| 98 // True if the widget has input grab. | |
| 99 bool did_input_grab_; | |
| 100 | |
| 101 // True if the widget is for root menu (very first menu in | |
| 102 // submenu chain). | |
| 103 bool is_root_; | |
| 104 | |
| 105 DISALLOW_COPY_AND_ASSIGN(WebUIMenuWidget); | |
| 106 }; | |
| 107 | |
| 108 } // namespace chromeos | |
| 109 | |
| 110 #endif // CHROME_BROWSER_CHROMEOS_VIEWS_WEBUI_MENU_WIDGET_H_ | |
| OLD | NEW |