| 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" |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 if (ViewsDelegate::views_delegate) | 315 if (ViewsDelegate::views_delegate) |
| 316 ViewsDelegate::views_delegate->AddRef(); | 316 ViewsDelegate::views_delegate->AddRef(); |
| 317 | 317 |
| 318 // 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 |
| 319 // 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 |
| 320 // 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 |
| 321 // appears totally broken. | 321 // appears totally broken. |
| 322 #if defined(USE_AURA) | 322 #if defined(USE_AURA) |
| 323 aura::client::GetDispatcherClient()->RunWithDispatcher(this, true); | 323 aura::client::GetDispatcherClient()->RunWithDispatcher(this, true); |
| 324 #else | 324 #else |
| 325 MessageLoopForUI* loop = MessageLoopForUI::current(); | 325 { |
| 326 bool did_allow_task_nesting = loop->NestableTasksAllowed(); | 326 MessageLoopForUI* loop = MessageLoopForUI::current(); |
| 327 loop->SetNestableTasksAllowed(true); | 327 MessageLoop::ScopedNestableTaskAllower allow(loop); |
| 328 loop->RunWithDispatcher(this); | 328 loop->RunWithDispatcher(this); |
| 329 loop->SetNestableTasksAllowed(did_allow_task_nesting); | 329 } |
| 330 #endif | 330 #endif |
| 331 | 331 |
| 332 if (ViewsDelegate::views_delegate) | 332 if (ViewsDelegate::views_delegate) |
| 333 ViewsDelegate::views_delegate->ReleaseRef(); | 333 ViewsDelegate::views_delegate->ReleaseRef(); |
| 334 | 334 |
| 335 // Close any open menus. | 335 // Close any open menus. |
| 336 SetSelection(NULL, SELECTION_UPDATE_IMMEDIATELY | SELECTION_EXIT); | 336 SetSelection(NULL, SELECTION_UPDATE_IMMEDIATELY | SELECTION_EXIT); |
| 337 | 337 |
| 338 if (nested_menu) { | 338 if (nested_menu) { |
| 339 DCHECK(!menu_stack_.empty()); | 339 DCHECK(!menu_stack_.empty()); |
| (...skipping 1682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2022 (!pending_state_.item->HasSubmenu() || | 2022 (!pending_state_.item->HasSubmenu() || |
| 2023 !pending_state_.item->GetSubmenu()->IsShowing())) { | 2023 !pending_state_.item->GetSubmenu()->IsShowing())) { |
| 2024 // On exit if the user hasn't selected an item with a submenu, move the | 2024 // On exit if the user hasn't selected an item with a submenu, move the |
| 2025 // selection back to the parent menu item. | 2025 // selection back to the parent menu item. |
| 2026 SetSelection(pending_state_.item->GetParentMenuItem(), | 2026 SetSelection(pending_state_.item->GetParentMenuItem(), |
| 2027 SELECTION_OPEN_SUBMENU); | 2027 SELECTION_OPEN_SUBMENU); |
| 2028 } | 2028 } |
| 2029 } | 2029 } |
| 2030 | 2030 |
| 2031 } // namespace views | 2031 } // namespace views |
| OLD | NEW |