Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6806)

Unified Diff: chrome/browser/ui/views/extensions/extension_popup.cc

Issue 8879045: Don't close ExtensionPopups on child window focus (Win, non-Aura). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix bad typo. Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/extensions/extension_popup.h ('k') | ui/views/focus/widget_focus_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 5ad10fdccbf3b808a64b0ebb51d0da6c01b589ee..23c64a261d5985d43724526d8d05c166a0a33978 100644
--- a/chrome/browser/ui/views/extensions/extension_popup.cc
+++ b/chrome/browser/ui/views/extensions/extension_popup.cc
@@ -39,7 +39,12 @@ ExtensionPopup::ExtensionPopup(
SetLayoutManager(new views::FillLayout());
AddChildView(host->view());
host->view()->SetContainer(this);
+#if defined(OS_WIN) && !defined(USE_AURA)
+ // Use OnNativeFocusChange to check for child window activation on deactivate.
+ set_close_on_deactivate(false);
+#else
set_close_on_deactivate(!inspect_with_devtools);
+#endif
// We wait to show the popup until the contained host finishes loading.
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING,
@@ -48,9 +53,12 @@ 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() {
+ views::WidgetFocusManager::GetInstance()->RemoveFocusChangeListener(this);
}
void ExtensionPopup::Observe(int type,
@@ -103,6 +111,27 @@ gfx::Size ExtensionPopup::GetPreferredSize() {
return sz;
}
+void ExtensionPopup::OnNativeFocusChange(gfx::NativeView focused_before,
+ gfx::NativeView focused_now) {
+ // TODO(msw): Implement something equivalent for Aura. See crbug.com/106958
+#if defined(OS_WIN) && !defined(USE_AURA)
+ // 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)
+ return;
+ gfx::NativeView focused_parent = focused_now;
+ while (focused_parent = ::GetParent(focused_parent)) {
+ if (this_window == focused_parent)
+ return;
+ }
+ GetWidget()->Close();
+ }
+#endif
+}
+
// static
ExtensionPopup* ExtensionPopup::ShowPopup(
const GURL& url,
« no previous file with comments | « chrome/browser/ui/views/extensions/extension_popup.h ('k') | ui/views/focus/widget_focus_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698