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