| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_VIEWS_NATIVE_MENU_DOMUI_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_VIEWS_NATIVE_MENU_DOMUI_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_VIEWS_NATIVE_MENU_DOMUI_H_ | 6 #define CHROME_BROWSER_CHROMEOS_VIEWS_NATIVE_MENU_DOMUI_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
| 13 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
| 14 #include "chrome/browser/chromeos/dom_ui/domui_menu_control.h" | 14 #include "chrome/browser/chromeos/webui_menu_control.h" |
| 15 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
| 16 #include "views/controls/menu/menu_wrapper.h" | 16 #include "views/controls/menu/menu_wrapper.h" |
| 17 | 17 |
| 18 class DictionaryValue; | 18 class DictionaryValue; |
| 19 class Profile; | 19 class Profile; |
| 20 class SkBitmap; | 20 class SkBitmap; |
| 21 | 21 |
| 22 namespace ui { | 22 namespace ui { |
| 23 class MenuModel; | 23 class MenuModel; |
| 24 } // namespace ui | 24 } // namespace ui |
| 25 | 25 |
| 26 namespace views { | 26 namespace views { |
| 27 class NestedDispatcherGtk; | 27 class NestedDispatcherGtk; |
| 28 } // namespace views; | 28 } // namespace views; |
| 29 | 29 |
| 30 #if defined(TOUCH_UI) | 30 #if defined(TOUCH_UI) |
| 31 typedef union _XEvent XEvent; | 31 typedef union _XEvent XEvent; |
| 32 #endif | 32 #endif |
| 33 | 33 |
| 34 namespace chromeos { | 34 namespace chromeos { |
| 35 | 35 |
| 36 class MenuLocator; | 36 class MenuLocator; |
| 37 class DOMUIMenuWidget; | 37 class WebUIMenuWidget; |
| 38 | 38 |
| 39 // A DOMUI implementation of MenuWrapper. | 39 // A DOMUI implementation of MenuWrapper. |
| 40 class NativeMenuDOMUI : public views::MenuWrapper, | 40 class NativeMenuDOMUI : public views::MenuWrapper, |
| 41 public DOMUIMenuControl, | 41 public WebUIMenuControl, |
| 42 public MessageLoop::Dispatcher { | 42 public MessageLoop::Dispatcher { |
| 43 public: | 43 public: |
| 44 NativeMenuDOMUI(ui::MenuModel* menu_model, bool root); | 44 NativeMenuDOMUI(ui::MenuModel* menu_model, bool root); |
| 45 virtual ~NativeMenuDOMUI(); | 45 virtual ~NativeMenuDOMUI(); |
| 46 | 46 |
| 47 // Returns true if menu is currently shown. | 47 // Returns true if menu is currently shown. |
| 48 bool is_menu_shown() { return menu_shown_; } | 48 bool is_menu_shown() { return menu_shown_; } |
| 49 | 49 |
| 50 // Set parent menu. | 50 // Set parent menu. |
| 51 void set_parent(NativeMenuDOMUI* parent) { parent_ = parent; } | 51 void set_parent(NativeMenuDOMUI* parent) { parent_ = parent; } |
| 52 | 52 |
| 53 // Overridden from MenuWrapper: | 53 // Overridden from views::MenuWrapper: |
| 54 virtual void RunMenuAt(const gfx::Point& point, int alignment); | 54 virtual void RunMenuAt(const gfx::Point& point, int alignment); |
| 55 virtual void CancelMenu(); | 55 virtual void CancelMenu(); |
| 56 virtual void Rebuild(); | 56 virtual void Rebuild(); |
| 57 virtual void UpdateStates(); | 57 virtual void UpdateStates(); |
| 58 virtual gfx::NativeMenu GetNativeMenu() const; | 58 virtual gfx::NativeMenu GetNativeMenu() const; |
| 59 virtual MenuAction GetMenuAction() const; | 59 virtual MenuAction GetMenuAction() const; |
| 60 virtual void AddMenuListener(views::MenuListener* listener); | 60 virtual void AddMenuListener(views::MenuListener* listener); |
| 61 virtual void RemoveMenuListener(views::MenuListener* listener); | 61 virtual void RemoveMenuListener(views::MenuListener* listener); |
| 62 virtual void SetMinimumWidth(int width); | 62 virtual void SetMinimumWidth(int width); |
| 63 | 63 |
| 64 // Overriden from MessageLoopForUI::Dispatcher: | 64 // Overridden from MessageLoopForUI::Dispatcher: |
| 65 virtual bool Dispatch(GdkEvent* event); | 65 virtual bool Dispatch(GdkEvent* event); |
| 66 #if defined(TOUCH_UI) | 66 #if defined(TOUCH_UI) |
| 67 virtual base::MessagePumpGlibXDispatcher::DispatchStatus Dispatch( | 67 virtual base::MessagePumpGlibXDispatcher::DispatchStatus Dispatch( |
| 68 XEvent* xevent); | 68 XEvent* xevent); |
| 69 #endif | 69 #endif |
| 70 | 70 |
| 71 // Overriden from DOMUIMenuControl; | 71 // Overridden from WebUIMenuControl: |
| 72 virtual ui::MenuModel* GetMenuModel() { return model_; } | 72 virtual ui::MenuModel* GetMenuModel() { return model_; } |
| 73 virtual void Activate(ui::MenuModel* model, | 73 virtual void Activate(ui::MenuModel* model, |
| 74 int index, | 74 int index, |
| 75 ActivationMode activation_mode); | 75 ActivationMode activation_mode); |
| 76 virtual void CloseAll(); | 76 virtual void CloseAll(); |
| 77 virtual void CloseSubmenu(); | 77 virtual void CloseSubmenu(); |
| 78 virtual void MoveInputToParent(); | 78 virtual void MoveInputToParent(); |
| 79 virtual void MoveInputToSubmenu(); | 79 virtual void MoveInputToSubmenu(); |
| 80 virtual void OnLoad(); | 80 virtual void OnLoad(); |
| 81 virtual void OpenSubmenu(int index, int y); | 81 virtual void OpenSubmenu(int index, int y); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 116 |
| 117 // If we're a submenu, this is the parent. | 117 // If we're a submenu, this is the parent. |
| 118 NativeMenuDOMUI* parent_; | 118 NativeMenuDOMUI* parent_; |
| 119 | 119 |
| 120 // Holds the current submenu. | 120 // Holds the current submenu. |
| 121 scoped_ptr<NativeMenuDOMUI> submenu_; | 121 scoped_ptr<NativeMenuDOMUI> submenu_; |
| 122 | 122 |
| 123 ui::MenuModel* model_; | 123 ui::MenuModel* model_; |
| 124 | 124 |
| 125 // A window widget that draws the content of the menu. | 125 // A window widget that draws the content of the menu. |
| 126 DOMUIMenuWidget* menu_widget_; | 126 WebUIMenuWidget* menu_widget_; |
| 127 | 127 |
| 128 // True if the menu is currently shown. | 128 // True if the menu is currently shown. |
| 129 // Used only in root. | 129 // Used only in root. |
| 130 bool menu_shown_; | 130 bool menu_shown_; |
| 131 | 131 |
| 132 // If the user selects something from the menu this is the menu they selected | 132 // If the user selects something from the menu this is the menu they selected |
| 133 // it from. When an item is selected menu_activated_ on the root ancestor is | 133 // it from. When an item is selected menu_activated_ on the root ancestor is |
| 134 // set to the menu the user selected and after the nested message loop exits | 134 // set to the menu the user selected and after the nested message loop exits |
| 135 // Activate is invoked on this menu. | 135 // Activate is invoked on this menu. |
| 136 ui::MenuModel* activated_menu_; | 136 ui::MenuModel* activated_menu_; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 157 // This is to deal with the menu being deleted while the nested | 157 // This is to deal with the menu being deleted while the nested |
| 158 // message loop is handled. see http://crosbug.com/7929 . | 158 // message loop is handled. see http://crosbug.com/7929 . |
| 159 views::NestedDispatcherGtk* nested_dispatcher_; | 159 views::NestedDispatcherGtk* nested_dispatcher_; |
| 160 | 160 |
| 161 DISALLOW_COPY_AND_ASSIGN(NativeMenuDOMUI); | 161 DISALLOW_COPY_AND_ASSIGN(NativeMenuDOMUI); |
| 162 }; | 162 }; |
| 163 | 163 |
| 164 } // namespace chromeos | 164 } // namespace chromeos |
| 165 | 165 |
| 166 #endif // CHROME_BROWSER_CHROMEOS_VIEWS_NATIVE_MENU_DOMUI_H_ | 166 #endif // CHROME_BROWSER_CHROMEOS_VIEWS_NATIVE_MENU_DOMUI_H_ |
| OLD | NEW |