Commit c79cc2cb authored by Jun Mukai's avatar Jun Mukai Committed by Commit Bot

Install MenuPreTargetHandlerAura to the right Env

aura::Env::GetInstance() means the Env in the client in
SingleProcessMash, which means this PreTargetHandler might not
be invoked in SingleProcessMash.

This is primarily for fixing test failures of BookmarkBarViewTest
and MenuItemViewTestRemoveWithSubmenu in interactive_ui_tests,
but I guess this will fix some keyboard operations on menu
items in normal chrome.

Bug: 883523
Test: interactive_ui_tests --enable-features=SingleProcessMash
Change-Id: I4f081b290bf6468318df3a77844efaf8410d05b7
Reviewed-on: https://chromium-review.googlesource.com/1237540
Commit-Queue: Jun Mukai <mukai@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593633}
parent ef28cfe6
......@@ -6,6 +6,7 @@
#include "ui/aura/env.h"
#include "ui/aura/window.h"
#include "ui/base/ui_base_features.h"
#include "ui/views/controls/menu/menu_controller.h"
#include "ui/views/widget/widget.h"
#include "ui/wm/public/activation_client.h"
......@@ -23,16 +24,27 @@ aura::Window* GetOwnerRootWindow(views::Widget* owner) {
MenuPreTargetHandlerAura::MenuPreTargetHandlerAura(MenuController* controller,
Widget* owner)
: controller_(controller), root_(GetOwnerRootWindow(owner)) {
aura::Env::GetInstance()->AddPreTargetHandler(
this, ui::EventTarget::Priority::kSystem);
if (root_) {
root_->env()->AddPreTargetHandler(this, ui::EventTarget::Priority::kSystem);
wm::GetActivationClient(root_)->AddObserver(this);
root_->AddObserver(this);
} else {
// TODO(mukai): check if this code path can run in ChromeOS and find the
// solution for SingleProcessMash.
if (features::IsUsingWindowService()) {
LOG(WARNING) << "MenuPreTargetHandlerAura is created without owner "
<< "widget. This may not work well in SingleProcessMash.";
}
aura::Env::GetInstance()->AddPreTargetHandler(
this, ui::EventTarget::Priority::kSystem);
}
}
MenuPreTargetHandlerAura::~MenuPreTargetHandlerAura() {
aura::Env::GetInstance()->RemovePreTargetHandler(this);
if (root_)
root_->env()->RemovePreTargetHandler(this);
else
aura::Env::GetInstance()->RemovePreTargetHandler(this);
Cleanup();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment