OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "chrome/browser/chromeos/views/native_menu_domui.h" | 5 #include "chrome/browser/chromeos/views/native_menu_domui.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "app/menus/menu_model.h" | 9 #include "app/menus/menu_model.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "chrome/browser/chromeos/dom_ui/menu_ui.h" | 12 #include "chrome/browser/chromeos/dom_ui/menu_ui.h" |
13 #include "chrome/browser/chromeos/views/domui_menu_widget.h" | 13 #include "chrome/browser/chromeos/views/domui_menu_widget.h" |
14 #include "chrome/browser/chromeos/views/menu_locator.h" | 14 #include "chrome/browser/chromeos/views/menu_locator.h" |
15 #include "chrome/browser/profiles/profile_manager.h" | 15 #include "chrome/browser/profiles/profile_manager.h" |
16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
17 #include "chrome/browser/ui/browser_list.h" | 17 #include "chrome/browser/ui/browser_list.h" |
18 #include "chrome/browser/ui/browser_window.h" | 18 #include "chrome/browser/ui/browser_window.h" |
19 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
20 #include "gfx/rect.h" | 20 #include "gfx/rect.h" |
21 #include "views/controls/menu/menu_2.h" | 21 #include "views/controls/menu/menu_2.h" |
22 #include "views/controls/menu/native_menu_gtk.h" | |
23 #include "views/controls/menu/nested_dispatcher_gtk.h" | 22 #include "views/controls/menu/nested_dispatcher_gtk.h" |
24 | 23 |
25 #if defined(TOUCH_UI) | 24 #if defined(TOUCH_UI) |
26 #include "views/focus/accelerator_handler.h" | 25 #include "views/focus/accelerator_handler.h" |
| 26 #include "views/controls/menu/native_menu_x.h" |
| 27 #else |
| 28 #include "views/controls/menu/native_menu_gtk.h" |
27 #endif | 29 #endif |
28 | 30 |
29 namespace { | 31 namespace { |
30 | 32 |
31 using chromeos::NativeMenuDOMUI; | 33 using chromeos::NativeMenuDOMUI; |
32 using chromeos::DOMUIMenuWidget; | 34 using chromeos::DOMUIMenuWidget; |
33 | 35 |
34 // Returns true if the menu item type specified can be executed as a command. | 36 // Returns true if the menu item type specified can be executed as a command. |
35 bool MenuTypeCanExecute(menus::MenuModel::ItemType type) { | 37 bool MenuTypeCanExecute(menus::MenuModel::ItemType type) { |
36 return type == menus::MenuModel::TYPE_COMMAND || | 38 return type == menus::MenuModel::TYPE_COMMAND || |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 break; | 244 break; |
243 } | 245 } |
244 default: | 246 default: |
245 break; | 247 break; |
246 } | 248 } |
247 gtk_main_do_event(event); | 249 gtk_main_do_event(event); |
248 return true; | 250 return true; |
249 } | 251 } |
250 | 252 |
251 #if defined(TOUCH_UI) | 253 #if defined(TOUCH_UI) |
252 bool NativeMenuDOMUI::Dispatch(XEvent* xevent) { | 254 base::MessagePumpGlibXDispatcher::DispatchStatus NativeMenuDOMUI::Dispatch( |
253 return views::DispatchXEvent(xevent); | 255 XEvent* xevent) { |
| 256 return views::DispatchXEvent(xevent) ? |
| 257 base::MessagePumpGlibXDispatcher::EVENT_PROCESSED : |
| 258 base::MessagePumpGlibXDispatcher::EVENT_IGNORED; |
| 259 |
254 } | 260 } |
255 #endif | 261 #endif |
256 | 262 |
257 //////////////////////////////////////////////////////////////////////////////// | 263 //////////////////////////////////////////////////////////////////////////////// |
258 // NativeMenuDOMUI, MenuControl implementation: | 264 // NativeMenuDOMUI, MenuControl implementation: |
259 | 265 |
260 void NativeMenuDOMUI::Activate(menus::MenuModel* model, | 266 void NativeMenuDOMUI::Activate(menus::MenuModel* model, |
261 int index, | 267 int index, |
262 ActivationMode activation) { | 268 ActivationMode activation) { |
263 NativeMenuDOMUI* root = GetRoot(); | 269 NativeMenuDOMUI* root = GetRoot(); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 // MenuWrapper, public: | 405 // MenuWrapper, public: |
400 | 406 |
401 namespace views { | 407 namespace views { |
402 | 408 |
403 // static | 409 // static |
404 MenuWrapper* MenuWrapper::CreateWrapper(Menu2* menu) { | 410 MenuWrapper* MenuWrapper::CreateWrapper(Menu2* menu) { |
405 menus::MenuModel* model = menu->model(); | 411 menus::MenuModel* model = menu->model(); |
406 if (chromeos::MenuUI::IsEnabled()) { | 412 if (chromeos::MenuUI::IsEnabled()) { |
407 return new chromeos::NativeMenuDOMUI(model, true); | 413 return new chromeos::NativeMenuDOMUI(model, true); |
408 } else { | 414 } else { |
| 415 #if defined(TOUCH_UI) |
| 416 return new NativeMenuX(menu); |
| 417 #else |
409 return new NativeMenuGtk(menu); | 418 return new NativeMenuGtk(menu); |
| 419 #endif |
410 } | 420 } |
411 } | 421 } |
412 | 422 |
413 } // namespace views | 423 } // namespace views |
OLD | NEW |