A collection of fixes allowing the chrome.experimental.popup.* set of APIs to function in circumstances where there is no Browser instance present. This is a symptom of a tab-contents view hosted in an ExternalTabContainer.The major change here is the removal of the explicit dependency on a Browser instance across all of the delegates involved when showing a pop-up API. I modified the following delegates:- ExtensionPopupHost::Delegate- TabContentsDelegate- ExtensionFunctionDispatcher::DelegateBecause the pop-up requires a Profile, and a gfx::NativeWindow, I added methods to the above interfaces to provide them.BUG=noneTEST=ExtensionApiTest.FLAKY_Popup
Review URL: http://codereview.chromium.org/434046
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34219 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc
index 071c6f1..c1cb333 100644
--- a/chrome/browser/extensions/extension_function_dispatcher.cc
+++ b/chrome/browser/extensions/extension_function_dispatcher.cc
@@ -7,6 +7,8 @@
#include "base/process_util.h"
#include "base/singleton.h"
#include "base/values.h"
+#include "chrome/browser/browser.h"
+#include "chrome/browser/browser_window.h"
#include "chrome/browser/extensions/execute_code_in_tab_function.h"
#include "chrome/browser/extensions/extension_bookmarks_module.h"
#include "chrome/browser/extensions/extension_bookmarks_module_constants.h"
@@ -181,6 +183,20 @@
}; // namespace
+// ExtensionFunctionDispatcher::Delegate ---------------------------------------
+
+gfx::NativeWindow ExtensionFunctionDispatcher::Delegate::
+ GetFrameNativeWindow() {
+ Browser* browser = GetBrowser();
+ // If a browser is bound to this dispatcher, then return the widget hosting
+ // the window. Extensions hosted in ExternalTabContainer objects may not
+ // have a running browser instance.
+ if (browser)
+ return browser->window()->GetNativeHandle();
+
+ return NULL;
+}
+
// ExtensionFunctionDispatcher -------------------------------------------------
void ExtensionFunctionDispatcher::GetAllFunctionNames(
@@ -318,3 +334,7 @@
Profile* ExtensionFunctionDispatcher::profile() {
return render_view_host_->process()->profile();
}
+
+gfx::NativeWindow ExtensionFunctionDispatcher::GetFrameNativeWindow() {
+ return delegate_ ? delegate_->GetFrameNativeWindow() : NULL;
+}