| Index: ui/views/controls/menu/menu_message_loop_aura.cc
|
| diff --git a/ui/views/controls/menu/menu_message_loop_aura.cc b/ui/views/controls/menu/menu_message_loop_aura.cc
|
| index dab58be36c9401e6e5ba610083a5f57f5f986765..3bfdef98a46e7ef4ff0bc9110ab88d8586e5a785 100644
|
| --- a/ui/views/controls/menu/menu_message_loop_aura.cc
|
| +++ b/ui/views/controls/menu/menu_message_loop_aura.cc
|
| @@ -15,7 +15,6 @@
|
| #include "ui/events/platform/platform_event_source.h"
|
| #include "ui/events/platform/scoped_event_dispatcher.h"
|
| #include "ui/views/controls/menu/menu_controller.h"
|
| -#include "ui/views/controls/menu/menu_key_event_handler.h"
|
| #include "ui/views/widget/widget.h"
|
| #include "ui/wm/public/activation_change_observer.h"
|
| #include "ui/wm/public/activation_client.h"
|
| @@ -26,68 +25,6 @@ using aura::client::ScreenPositionClient;
|
|
|
| namespace views {
|
|
|
| -namespace {
|
| -
|
| -aura::Window* GetOwnerRootWindow(views::Widget* owner) {
|
| - return owner ? owner->GetNativeWindow()->GetRootWindow() : NULL;
|
| -}
|
| -
|
| -// ActivationChangeObserverImpl is used to observe activation changes and close
|
| -// the menu. Additionally it listens for the root window to be destroyed and
|
| -// cancel the menu as well.
|
| -class ActivationChangeObserverImpl
|
| - : public aura::client::ActivationChangeObserver,
|
| - public aura::WindowObserver,
|
| - public ui::EventHandler {
|
| - public:
|
| - ActivationChangeObserverImpl(MenuController* controller, aura::Window* root)
|
| - : controller_(controller), root_(root) {
|
| - aura::client::GetActivationClient(root_)->AddObserver(this);
|
| - root_->AddObserver(this);
|
| - root_->AddPreTargetHandler(this);
|
| - }
|
| -
|
| - ~ActivationChangeObserverImpl() override { Cleanup(); }
|
| -
|
| - // aura::client::ActivationChangeObserver:
|
| - void OnWindowActivated(
|
| - aura::client::ActivationChangeObserver::ActivationReason reason,
|
| - aura::Window* gained_active,
|
| - aura::Window* lost_active) override {
|
| - if (!controller_->drag_in_progress())
|
| - controller_->CancelAll();
|
| - }
|
| -
|
| - // aura::WindowObserver:
|
| - void OnWindowDestroying(aura::Window* window) override { Cleanup(); }
|
| -
|
| - // ui::EventHandler:
|
| - void OnCancelMode(ui::CancelModeEvent* event) override {
|
| - controller_->CancelAll();
|
| - }
|
| -
|
| - private:
|
| - void Cleanup() {
|
| - if (!root_)
|
| - return;
|
| - // The ActivationClient may have been destroyed by the time we get here.
|
| - aura::client::ActivationClient* client =
|
| - aura::client::GetActivationClient(root_);
|
| - if (client)
|
| - client->RemoveObserver(this);
|
| - root_->RemovePreTargetHandler(this);
|
| - root_->RemoveObserver(this);
|
| - root_ = NULL;
|
| - }
|
| -
|
| - MenuController* controller_;
|
| - aura::Window* root_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(ActivationChangeObserverImpl);
|
| -};
|
| -
|
| -} // namespace
|
| -
|
| // static
|
| MenuMessageLoop* MenuMessageLoop::Create() {
|
| return new MenuMessageLoopAura;
|
| @@ -115,16 +52,11 @@ void MenuMessageLoop::RepostEventToWindow(const ui::LocatedEvent* event,
|
| root->GetHost()->dispatcher()->RepostEvent(located_event.get());
|
| }
|
|
|
| -MenuMessageLoopAura::MenuMessageLoopAura() : owner_(nullptr) {}
|
| +MenuMessageLoopAura::MenuMessageLoopAura() {}
|
|
|
| MenuMessageLoopAura::~MenuMessageLoopAura() {}
|
|
|
| -void MenuMessageLoopAura::Run(MenuController* controller,
|
| - Widget* owner,
|
| - bool nested_menu) {
|
| - // |owner_| may be NULL.
|
| - owner_ = owner;
|
| - aura::Window* root = GetOwnerRootWindow(owner_);
|
| +void MenuMessageLoopAura::Run() {
|
| // It is possible for the same MenuMessageLoopAura to start a nested
|
| // message-loop while it is already running a nested loop. So make sure the
|
| // quit-closure gets reset to the outer loop's quit-closure once the innermost
|
| @@ -132,12 +64,6 @@ void MenuMessageLoopAura::Run(MenuController* controller,
|
| base::AutoReset<base::Closure> reset_quit_closure(&message_loop_quit_,
|
| base::Closure());
|
|
|
| - std::unique_ptr<ActivationChangeObserverImpl> observer;
|
| - if (root) {
|
| - if (!nested_menu)
|
| - observer.reset(new ActivationChangeObserverImpl(controller, root));
|
| - }
|
| -
|
| base::MessageLoop* loop = base::MessageLoop::current();
|
| base::MessageLoop::ScopedNestableTaskAllower allow(loop);
|
| base::RunLoop run_loop;
|
| @@ -158,8 +84,4 @@ void MenuMessageLoopAura::QuitNow() {
|
| #endif
|
| }
|
|
|
| -void MenuMessageLoopAura::ClearOwner() {
|
| - owner_ = NULL;
|
| -}
|
| -
|
| } // namespace views
|
|
|