Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "ui/views/controls/menu/menu_controller.h" | 5 #include "ui/views/controls/menu/menu_controller.h" |
| 6 | 6 |
| 7 #include "base/i18n/case_conversion.h" | 7 #include "base/i18n/case_conversion.h" |
| 8 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "ui/base/dragdrop/os_exchange_data.h" | 11 #include "ui/base/dragdrop/os_exchange_data.h" |
| 12 #include "ui/base/events.h" | 12 #include "ui/base/events.h" |
| 13 #include "ui/base/keycodes/keyboard_codes.h" | 13 #include "ui/base/keycodes/keyboard_codes.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
| 15 #include "ui/gfx/canvas_skia.h" | 15 #include "ui/gfx/canvas_skia.h" |
| 16 #include "ui/gfx/screen.h" | 16 #include "ui/gfx/screen.h" |
| 17 #include "ui/views/controls/button/menu_button.h" | 17 #include "ui/views/controls/button/menu_button.h" |
| 18 #include "ui/views/controls/menu/menu_controller_delegate.h" | 18 #include "ui/views/controls/menu/menu_controller_delegate.h" |
| 19 #include "ui/views/controls/menu/menu_scroll_view_container.h" | 19 #include "ui/views/controls/menu/menu_scroll_view_container.h" |
| 20 #include "ui/views/controls/menu/submenu_view.h" | 20 #include "ui/views/controls/menu/submenu_view.h" |
| 21 #include "ui/views/drag_utils.h" | 21 #include "ui/views/drag_utils.h" |
| 22 #include "ui/views/view_constants.h" | 22 #include "ui/views/view_constants.h" |
| 23 #include "ui/views/views_delegate.h" | 23 #include "ui/views/views_delegate.h" |
| 24 #include "ui/views/widget/root_view.h" | 24 #include "ui/views/widget/root_view.h" |
| 25 #include "ui/views/widget/widget.h" | 25 #include "ui/views/widget/widget.h" |
| 26 | 26 |
| 27 #if defined(USE_AURA) | 27 #if defined(USE_AURA) |
| 28 #include "ui/aura/client/dispatcher_client.h" | |
| 28 #include "ui/aura/root_window.h" | 29 #include "ui/aura/root_window.h" |
| 29 #elif defined(TOOLKIT_USES_GTK) | 30 #elif defined(TOOLKIT_USES_GTK) |
| 30 #include "ui/base/keycodes/keyboard_code_conversion_gtk.h" | 31 #include "ui/base/keycodes/keyboard_code_conversion_gtk.h" |
| 31 #endif | 32 #endif |
| 32 | 33 |
| 33 using base::Time; | 34 using base::Time; |
| 34 using base::TimeDelta; | 35 using base::TimeDelta; |
| 35 using ui::OSExchangeData; | 36 using ui::OSExchangeData; |
| 36 | 37 |
| 37 // Period of the scroll timer (in milliseconds). | 38 // Period of the scroll timer (in milliseconds). |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 311 } | 312 } |
| 312 | 313 |
| 313 // Make sure Chrome doesn't attempt to shut down while the menu is showing. | 314 // Make sure Chrome doesn't attempt to shut down while the menu is showing. |
| 314 if (ViewsDelegate::views_delegate) | 315 if (ViewsDelegate::views_delegate) |
| 315 ViewsDelegate::views_delegate->AddRef(); | 316 ViewsDelegate::views_delegate->AddRef(); |
| 316 | 317 |
| 317 // We need to turn on nestable tasks as in some situations (pressing alt-f for | 318 // We need to turn on nestable tasks as in some situations (pressing alt-f for |
| 318 // one) the menus are run from a task. If we don't do this and are invoked | 319 // one) the menus are run from a task. If we don't do this and are invoked |
| 319 // from a task none of the tasks we schedule are processed and the menu | 320 // from a task none of the tasks we schedule are processed and the menu |
| 320 // appears totally broken. | 321 // appears totally broken. |
| 322 #if defined(USE_AURA) | |
| 323 aura::client::DispatcherClient* dispatcher_client = | |
| 324 aura::client::GetDispatcherClient(); | |
| 325 DCHECK(dispatcher_client); | |
|
oshima
2012/01/31 18:19:52
no need for DCHECK as next line fill fail immediat
pkotwicz
2012/01/31 20:01:07
Done.
| |
| 326 dispatcher_client->RunWithDispatcher(this, true); | |
| 327 #else | |
| 321 MessageLoopForUI* loop = MessageLoopForUI::current(); | 328 MessageLoopForUI* loop = MessageLoopForUI::current(); |
| 322 bool did_allow_task_nesting = loop->NestableTasksAllowed(); | 329 bool did_allow_task_nesting = loop->NestableTasksAllowed(); |
| 323 loop->SetNestableTasksAllowed(true); | 330 loop->SetNestableTasksAllowed(true); |
| 324 loop->RunWithDispatcher(this); | 331 loop->RunWithDispatcher(this); |
| 325 loop->SetNestableTasksAllowed(did_allow_task_nesting); | 332 loop->SetNestableTasksAllowed(did_allow_task_nesting); |
| 333 #endif | |
| 326 | 334 |
| 327 if (ViewsDelegate::views_delegate) | 335 if (ViewsDelegate::views_delegate) |
| 328 ViewsDelegate::views_delegate->ReleaseRef(); | 336 ViewsDelegate::views_delegate->ReleaseRef(); |
| 329 | 337 |
| 330 // Close any open menus. | 338 // Close any open menus. |
| 331 SetSelection(NULL, SELECTION_UPDATE_IMMEDIATELY | SELECTION_EXIT); | 339 SetSelection(NULL, SELECTION_UPDATE_IMMEDIATELY | SELECTION_EXIT); |
| 332 | 340 |
| 333 if (nested_menu) { | 341 if (nested_menu) { |
| 334 DCHECK(!menu_stack_.empty()); | 342 DCHECK(!menu_stack_.empty()); |
| 335 // We're running from within a menu, restore the previous state. | 343 // We're running from within a menu, restore the previous state. |
| (...skipping 1685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2021 (!pending_state_.item->HasSubmenu() || | 2029 (!pending_state_.item->HasSubmenu() || |
| 2022 !pending_state_.item->GetSubmenu()->IsShowing())) { | 2030 !pending_state_.item->GetSubmenu()->IsShowing())) { |
| 2023 // On exit if the user hasn't selected an item with a submenu, move the | 2031 // On exit if the user hasn't selected an item with a submenu, move the |
| 2024 // selection back to the parent menu item. | 2032 // selection back to the parent menu item. |
| 2025 SetSelection(pending_state_.item->GetParentMenuItem(), | 2033 SetSelection(pending_state_.item->GetParentMenuItem(), |
| 2026 SELECTION_OPEN_SUBMENU); | 2034 SELECTION_OPEN_SUBMENU); |
| 2027 } | 2035 } |
| 2028 } | 2036 } |
| 2029 | 2037 |
| 2030 } // namespace views | 2038 } // namespace views |
| OLD | NEW |