Commit 902d73ba authored by Robert Liao's avatar Robert Liao Committed by Commit Bot

Adjust ExtensionPopup Dismissal Behavior

Before, dismissing the ExtensionPopup when the anchor window received
focus was an arbitrary decision (http://crbug.com/179786) that allowed
the ExtensionPopup to dismiss at most of the right times. However, if
the some other top-level window received activation, the ExtensionPopup
would not dismiss, unlike a typical menu.

This change adjusts the ExtensionPopup to always dismiss when it loses
activation as long as devtools is not attached.

When devtools is detached, activation is placed back on the
ExtensionPopup so that the normal dismissal behavior can continue to
work. Failure to receive activation means the ExtensionPopup will not
dismiss until it receives activation at least once.

BUG=825867

Change-Id: I802af281616c66013c370e892953ad2805533728
Reviewed-on: https://chromium-review.googlesource.com/984404Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Commit-Queue: Robert Liao <robliao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547391}
parent cce7668a
......@@ -34,8 +34,8 @@ ExtensionPopupViewsMac* ExtensionPopupViewsMac::ShowPopup(
NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
// ObjC id collides with views::View::id().
::id token = [center addObserverForName:NSWindowDidBecomeKeyNotification
object:parent_window
::id token = [center addObserverForName:NSWindowDidResignKeyNotification
object:popup->GetWidget()->GetNativeWindow()
queue:nil
usingBlock:^(NSNotification* notification) {
popup->CloseUnlessUnderInspection();
......
......@@ -129,6 +129,14 @@ void ExtensionPopup::DevToolsAgentHostDetached(
if (host()->host_contents() != agent_host->GetWebContents())
return;
inspect_with_devtools_ = false;
// Reset the dismissing logic back to a known state.
// The Chrome top-level window often receives activation when devtools is
// closed. However, because devtools was shown, ExtensionPopup doesn't have
// activation. This means there is no chance for it to dismiss until it
// receives activation again. Checking the anchor window for activation and
// then dismissing would result in the ExtensionPopup dismissing with
// devtools, which is also unexpected.
GetWidget()->Activate();
}
void ExtensionPopup::OnExtensionSizeChanged(ExtensionViewViews* view) {
......@@ -154,7 +162,7 @@ void ExtensionPopup::AddedToWidget() {
void ExtensionPopup::OnWidgetActivationChanged(views::Widget* widget,
bool active) {
if (active && widget == anchor_widget())
if (!active && widget == GetWidget())
CloseUnlessUnderInspection();
}
......
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