| 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 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 bool MenuRunnerImpl::IsRunning() const { | 41 bool MenuRunnerImpl::IsRunning() const { |
| 42 return running_; | 42 return running_; |
| 43 } | 43 } |
| 44 | 44 |
| 45 void MenuRunnerImpl::Release() { | 45 void MenuRunnerImpl::Release() { |
| 46 if (running_) { | 46 if (running_) { |
| 47 if (delete_after_run_) | 47 if (delete_after_run_) |
| 48 return; // We already canceled. | 48 return; // We already canceled. |
| 49 | 49 |
| 50 // The menu is running a nested message loop, we can't delete it now | 50 // The menu is running a nested run loop, we can't delete it now |
| 51 // otherwise the stack would be in a really bad state (many frames would | 51 // otherwise the stack would be in a really bad state (many frames would |
| 52 // have deleted objects on them). Instead cancel the menu, when it returns | 52 // have deleted objects on them). Instead cancel the menu, when it returns |
| 53 // Holder will delete itself. | 53 // Holder will delete itself. |
| 54 delete_after_run_ = true; | 54 delete_after_run_ = true; |
| 55 | 55 |
| 56 // Swap in a different delegate. That way we know the original MenuDelegate | 56 // Swap in a different delegate. That way we know the original MenuDelegate |
| 57 // won't be notified later on (when it's likely already been deleted). | 57 // won't be notified later on (when it's likely already been deleted). |
| 58 if (!empty_delegate_.get()) | 58 if (!empty_delegate_.get()) |
| 59 empty_delegate_.reset(new MenuDelegate()); | 59 empty_delegate_.reset(new MenuDelegate()); |
| 60 menu_->set_delegate(empty_delegate_.get()); | 60 menu_->set_delegate(empty_delegate_.get()); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 #if defined(OS_WIN) | 196 #if defined(OS_WIN) |
| 197 // This is only needed on Windows. | 197 // This is only needed on Windows. |
| 198 if (!show_mnemonics) | 198 if (!show_mnemonics) |
| 199 show_mnemonics = ui::win::IsAltPressed(); | 199 show_mnemonics = ui::win::IsAltPressed(); |
| 200 #endif | 200 #endif |
| 201 return show_mnemonics; | 201 return show_mnemonics; |
| 202 } | 202 } |
| 203 | 203 |
| 204 } // namespace internal | 204 } // namespace internal |
| 205 } // namespace views | 205 } // namespace views |
| OLD | NEW |