diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-23 21:38:06 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-23 21:38:06 +0000 |
commit | 7d99a86a9ea01a007152ae240dc58df062e19662 (patch) | |
tree | 0427fad6c7e3f55d82fdec5ee1300d5025fa7214 /chrome | |
parent | e48739a659dbe066dc4352355d4332eec63ad703 (diff) | |
download | chromium_src-7d99a86a9ea01a007152ae240dc58df062e19662.zip chromium_src-7d99a86a9ea01a007152ae240dc58df062e19662.tar.gz chromium_src-7d99a86a9ea01a007152ae240dc58df062e19662.tar.bz2 |
Displaying a JavaScript message box (such as an alert) from
an extension popup was causing the popup to lose focus and
be dismissed, causing other problems.
This CL fixes it on Windows with the following:
- the message box is now parented to the popup, not the tab
- the popup is not disimissed when losing focus to a window for
which it is the owner.
BUG=29147
TEST=Create an extension with a popup that contains a combo-box
and a button to show an alert and confirm box. Click on the
combobox and select an item. Click the button to show the
alert and confirm message box. The popup should not be closed
when you do that.
Review URL: http://codereview.chromium.org/650045
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39770 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/extensions/extension_host.cc | 6 | ||||
-rw-r--r-- | chrome/browser/views/browser_actions_container.cc | 7 | ||||
-rw-r--r-- | chrome/browser/views/browser_bubble.h | 2 |
3 files changed, 9 insertions, 6 deletions
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index 4d930cf..e9fb5c4 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -12,6 +12,7 @@ #include "base/message_loop.h" #include "base/singleton.h" #include "base/string_util.h" +#include "chrome/common/platform_util.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/browser_shutdown.h" @@ -437,10 +438,7 @@ std::wstring ExtensionHost::GetMessageBoxTitle(const GURL& frame_url, } gfx::NativeWindow ExtensionHost::GetMessageBoxRootWindow() { - TabContents* active_tab = GetBrowser()->GetSelectedTabContents(); - if (active_tab) - return active_tab->view()->GetTopLevelNativeWindow(); - return NULL; + return platform_util::GetTopLevel(GetNativeViewOfHost()); } void ExtensionHost::OnMessageBoxClosed(IPC::Message* reply_msg, diff --git a/chrome/browser/views/browser_actions_container.cc b/chrome/browser/views/browser_actions_container.cc index 9f26598..98608e0 100644 --- a/chrome/browser/views/browser_actions_container.cc +++ b/chrome/browser/views/browser_actions_container.cc @@ -848,7 +848,7 @@ void BrowserActionsContainer::BubbleLostFocus(BrowserBubble* bubble, return; #if defined(OS_WIN) - // Don't hide when we are loosing focus to a child window. This is the case + // Don't hide when we are losing focus to a child window. This is the case // with select popups. // TODO(jcampan): http://crbugs.com/29131 make that work on toolkit views // so this #if defined can be removed. @@ -858,6 +858,11 @@ void BrowserActionsContainer::BubbleLostFocus(BrowserBubble* bubble, if (parent == popup_native_view) return; } + + // Don't close when we are losing focus to a window we own. + // This is the case with JavaScript message boxes (such as alerts). + if (::GetWindow(focused_view, GW_OWNER) == popup_native_view) + return; #endif // This is a bit annoying. If you click on the button that generated the diff --git a/chrome/browser/views/browser_bubble.h b/chrome/browser/views/browser_bubble.h index feb55f8..a75211c 100644 --- a/chrome/browser/views/browser_bubble.h +++ b/chrome/browser/views/browser_bubble.h @@ -88,7 +88,7 @@ class BrowserBubble { void ResizeToView(); // Returns the NativeView containing that popup. - gfx::NativeView native_view() const { return frame_->GetNativeView(); } + gfx::NativeView native_view() const { return popup_->GetNativeView(); } protected: // Create the popup widget. |