diff options
author | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-09 18:55:48 +0000 |
---|---|---|
committer | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-09 18:55:48 +0000 |
commit | 89f72b3241a342e39e678e4ff632c4b2a1d54b7a (patch) | |
tree | 5a4c2ba6975eb2ff903313029d7512a9feb59927 /chrome/browser/extensions | |
parent | 24c3b9f5d424170ef0f32460d1385ebbe94f5022 (diff) | |
download | chromium_src-89f72b3241a342e39e678e4ff632c4b2a1d54b7a.zip chromium_src-89f72b3241a342e39e678e4ff632c4b2a1d54b7a.tar.gz chromium_src-89f72b3241a342e39e678e4ff632c4b2a1d54b7a.tar.bz2 |
Fix crash when a background page calls alert().
BUG=37567
Review URL: http://codereview.chromium.org/691001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41054 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r-- | chrome/browser/extensions/extension_host.cc | 12 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_host.h | 2 |
2 files changed, 12 insertions, 2 deletions
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index f4ee926..1519581 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -444,7 +444,17 @@ std::wstring ExtensionHost::GetMessageBoxTitle(const GURL& frame_url, } gfx::NativeWindow ExtensionHost::GetMessageBoxRootWindow() { - return platform_util::GetTopLevel(GetNativeViewOfHost()); + // If we have a view, use that. + gfx::NativeView native_view = GetNativeViewOfHost(); + if (native_view) + return platform_util::GetTopLevel(native_view); + + // Otherwise, try the active tab's view. + TabContents* active_tab = GetBrowser()->GetSelectedTabContents();
+ if (active_tab)
+ return active_tab->view()->GetTopLevelNativeWindow();
+
+ return NULL;
} void ExtensionHost::OnMessageBoxClosed(IPC::Message* reply_msg, diff --git a/chrome/browser/extensions/extension_host.h b/chrome/browser/extensions/extension_host.h index 83f2cb2..38f6dbe 100644 --- a/chrome/browser/extensions/extension_host.h +++ b/chrome/browser/extensions/extension_host.h @@ -203,7 +203,7 @@ class ExtensionHost : public ExtensionPopupHost::PopupDelegate, virtual Browser* GetBrowser() const { return GetBrowser(true); } virtual RenderViewHost* GetRenderViewHost() { return render_view_host(); } virtual gfx::NativeView GetNativeViewOfHost() { - return view()->native_view(); + return view() ? view()->native_view() : NULL; } // Handles keyboard events that were not handled by HandleKeyboardEvent(). |