| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_runner_impl.h" | 5 #include "ui/views/controls/menu/menu_runner_impl.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "ui/native_theme/native_theme.h" | 8 #include "ui/native_theme/native_theme.h" |
| 9 #include "ui/views/controls/button/menu_button.h" | 9 #include "ui/views/controls/button/menu_button.h" |
| 10 #include "ui/views/controls/menu/menu_controller.h" | 10 #include "ui/views/controls/menu/menu_controller.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 // doesn't handle this very well (meaning it crashes). | 81 // doesn't handle this very well (meaning it crashes). |
| 82 return MenuRunner::NORMAL_EXIT; | 82 return MenuRunner::NORMAL_EXIT; |
| 83 } | 83 } |
| 84 | 84 |
| 85 MenuController* controller = MenuController::GetActiveInstance(); | 85 MenuController* controller = MenuController::GetActiveInstance(); |
| 86 if (controller) { | 86 if (controller) { |
| 87 if ((run_types & MenuRunner::IS_NESTED) != 0) { | 87 if ((run_types & MenuRunner::IS_NESTED) != 0) { |
| 88 if (!controller->IsBlockingRun()) { | 88 if (!controller->IsBlockingRun()) { |
| 89 controller->CancelAll(); | 89 controller->CancelAll(); |
| 90 controller = NULL; | 90 controller = NULL; |
| 91 } else { |
| 92 // Only nest the delegate when not cancelling drag-and-drop. When |
| 93 // cancelling this will become the root delegate of the new |
| 94 // MenuController |
| 95 controller->AddNestedDelegate(this); |
| 91 } | 96 } |
| 92 controller->AddNestedDelegate(this); | |
| 93 } else { | 97 } else { |
| 94 // There's some other menu open and we're not nested. Cancel the menu. | 98 // There's some other menu open and we're not nested. Cancel the menu. |
| 95 controller->CancelAll(); | 99 controller->CancelAll(); |
| 96 if ((run_types & MenuRunner::FOR_DROP) == 0) { | 100 if ((run_types & MenuRunner::FOR_DROP) == 0) { |
| 97 // We can't open another menu, otherwise the message loop would become | 101 // We can't open another menu, otherwise the message loop would become |
| 98 // twice nested. This isn't necessarily a problem, but generally isn't | 102 // twice nested. This isn't necessarily a problem, but generally isn't |
| 99 // expected. | 103 // expected. |
| 100 return MenuRunner::NORMAL_EXIT; | 104 return MenuRunner::NORMAL_EXIT; |
| 101 } | 105 } |
| 102 // Drop menus don't block the message loop, so it's ok to create a new | 106 // Drop menus don't block the message loop, so it's ok to create a new |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 #if defined(OS_WIN) | 219 #if defined(OS_WIN) |
| 216 // This is only needed on Windows. | 220 // This is only needed on Windows. |
| 217 if (!show_mnemonics) | 221 if (!show_mnemonics) |
| 218 show_mnemonics = ui::win::IsAltPressed(); | 222 show_mnemonics = ui::win::IsAltPressed(); |
| 219 #endif | 223 #endif |
| 220 return show_mnemonics; | 224 return show_mnemonics; |
| 221 } | 225 } |
| 222 | 226 |
| 223 } // namespace internal | 227 } // namespace internal |
| 224 } // namespace views | 228 } // namespace views |
| OLD | NEW |