diff options
-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(). |