| Index: chrome/browser/ui/views/extensions/extension_popup.cc
|
| diff --git a/chrome/browser/ui/views/extensions/extension_popup.cc b/chrome/browser/ui/views/extensions/extension_popup.cc
|
| index d0704a41fe1516c3c54c1b1f69721b4e1ddf540a..a3e984d34855bda92f716596f096f52f084bb1d3 100644
|
| --- a/chrome/browser/ui/views/extensions/extension_popup.cc
|
| +++ b/chrome/browser/ui/views/extensions/extension_popup.cc
|
| @@ -1,4 +1,4 @@
|
| -// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| @@ -57,8 +57,6 @@ ExtensionPopup::ExtensionPopup(
|
| // Listen for the containing view calling window.close();
|
| registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE,
|
| content::Source<Profile>(host->profile()));
|
| -
|
| - views::WidgetFocusManager::GetInstance()->AddFocusChangeListener(this);
|
| }
|
|
|
| ExtensionPopup::~ExtensionPopup() {
|
| @@ -72,16 +70,7 @@ void ExtensionPopup::Observe(int type,
|
| case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME:
|
| DCHECK(content::Source<WebContents>(host()->host_contents()) == source);
|
| // Show when the content finishes loading and its width is computed.
|
| - Show();
|
| - // Focus on the host contents when the bubble is first shown.
|
| - host()->host_contents()->Focus();
|
| - if (inspect_with_devtools_) {
|
| - // Listen for the the devtools window closing.
|
| - registrar_.Add(this, content::NOTIFICATION_DEVTOOLS_WINDOW_CLOSING,
|
| - content::Source<content::BrowserContext>(host()->profile()));
|
| - DevToolsWindow::ToggleDevToolsWindow(host()->render_view_host(),
|
| - DEVTOOLS_TOGGLE_ACTION_SHOW_CONSOLE);
|
| - }
|
| + ShowBubble();
|
| break;
|
| case chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE:
|
| // If we aren't the host of the popup, then disregard the notification.
|
| @@ -120,17 +109,15 @@ void ExtensionPopup::OnNativeFocusChange(gfx::NativeView focused_before,
|
| // Don't close if a child of this window is activated (only needed on Win).
|
| // ExtensionPopups can create Javascipt dialogs; see crbug.com/106723.
|
| gfx::NativeView this_window = GetWidget()->GetNativeView();
|
| - if (!inspect_with_devtools_ && focused_before == this_window) {
|
| - DCHECK_NE(focused_now, this_window);
|
| - if (::GetWindow(focused_now, GW_OWNER) == this_window)
|
| + if (inspect_with_devtools_ || focused_now == this_window ||
|
| + ::GetWindow(focused_now, GW_OWNER) == this_window)
|
| + return;
|
| + gfx::NativeView focused_parent = focused_now;
|
| + while (focused_parent = ::GetParent(focused_parent)) {
|
| + if (this_window == focused_parent)
|
| return;
|
| - gfx::NativeView focused_parent = focused_now;
|
| - while (focused_parent = ::GetParent(focused_parent)) {
|
| - if (this_window == focused_parent)
|
| - return;
|
| - }
|
| - GetWidget()->Close();
|
| }
|
| + GetWidget()->Close();
|
| #endif
|
| }
|
|
|
| @@ -150,11 +137,26 @@ ExtensionPopup* ExtensionPopup::ShowPopup(
|
|
|
| // If the host had somehow finished loading, then we'd miss the notification
|
| // and not show. This seems to happen in single-process mode.
|
| - if (host->did_stop_loading()) {
|
| - popup->Show();
|
| - // Focus on the host contents when the bubble is first shown.
|
| - host->host_contents()->Focus();
|
| - }
|
| + if (host->did_stop_loading())
|
| + popup->ShowBubble();
|
|
|
| return popup;
|
| }
|
| +
|
| +void ExtensionPopup::ShowBubble() {
|
| + Show();
|
| +
|
| + // Focus on the host contents when the bubble is first shown.
|
| + host()->host_contents()->Focus();
|
| +
|
| + // Listen for widget focus changes after showing (used for non-aura win).
|
| + views::WidgetFocusManager::GetInstance()->AddFocusChangeListener(this);
|
| +
|
| + if (inspect_with_devtools_) {
|
| + // Listen for the the devtools window closing.
|
| + registrar_.Add(this, content::NOTIFICATION_DEVTOOLS_WINDOW_CLOSING,
|
| + content::Source<content::BrowserContext>(host()->profile()));
|
| + DevToolsWindow::ToggleDevToolsWindow(host()->render_view_host(),
|
| + DEVTOOLS_TOGGLE_ACTION_SHOW_CONSOLE);
|
| + }
|
| +}
|
|
|