summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/extensions
diff options
context:
space:
mode:
authortwiz@google.com <twiz@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-10 01:59:11 +0000
committertwiz@google.com <twiz@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-10 01:59:11 +0000
commita95631cb9427e4d20c243dcd0f36da3fd3e7cb55 (patch)
tree09da2c4493a7303671961051b32718830c451ad7 /chrome/browser/views/extensions
parent2007ad49132097b2a2eb10d0025361d1bf7a9340 (diff)
downloadchromium_src-a95631cb9427e4d20c243dcd0f36da3fd3e7cb55.zip
chromium_src-a95631cb9427e4d20c243dcd0f36da3fd3e7cb55.tar.gz
chromium_src-a95631cb9427e4d20c243dcd0f36da3fd3e7cb55.tar.bz2
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
Diffstat (limited to 'chrome/browser/views/extensions')
-rw-r--r--chrome/browser/views/extensions/extension_popup.cc30
-rw-r--r--chrome/browser/views/extensions/extension_popup.h14
2 files changed, 36 insertions, 8 deletions
diff --git a/chrome/browser/views/extensions/extension_popup.cc b/chrome/browser/views/extensions/extension_popup.cc
index c9c7ae6..6d8e4d6 100644
--- a/chrome/browser/views/extensions/extension_popup.cc
+++ b/chrome/browser/views/extensions/extension_popup.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/views/extensions/extension_popup.h"
#include "chrome/browser/browser.h"
+#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_window.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/extensions/extension_process_manager.h"
@@ -27,7 +28,7 @@ const int ExtensionPopup::kMaxWidth = 800;
const int ExtensionPopup::kMaxHeight = 600;
ExtensionPopup::ExtensionPopup(ExtensionHost* host,
- Widget* frame,
+ views::Widget* frame,
const gfx::Rect& relative_to,
BubbleBorder::ArrowLocation arrow_location,
bool activate_on_show)
@@ -79,7 +80,8 @@ void ExtensionPopup::Show(bool activate) {
return;
#if defined(OS_WIN)
- frame_->GetWindow()->DisableInactiveRendering();
+ if (frame_->GetWindow())
+ frame_->GetWindow()->DisableInactiveRendering();
#endif
ResizeToView();
@@ -142,20 +144,32 @@ void ExtensionPopup::OnExtensionPreferredSizeChanged(ExtensionView* view) {
// static
ExtensionPopup* ExtensionPopup::Show(
- const GURL& url, Browser* browser,
+ const GURL& url,
+ Browser* browser,
+ Profile* profile,
+ gfx::NativeWindow frame_window,
const gfx::Rect& relative_to,
BubbleBorder::ArrowLocation arrow_location,
bool activate_on_show) {
- ExtensionProcessManager* manager =
- browser->profile()->GetExtensionProcessManager();
+ DCHECK(profile);
+ DCHECK(frame_window);
+ ExtensionProcessManager* manager = profile->GetExtensionProcessManager();
DCHECK(manager);
if (!manager)
return NULL;
+ // If no Browser instance was given, attempt to look up one matching the given
+ // profile.
+ if (!browser)
+ browser = BrowserList::FindBrowserWithProfile(profile);
+
+ Widget* frame_widget = Widget::GetWidgetFromNativeWindow(frame_window);
+ DCHECK(frame_widget);
+ if (!frame_widget)
+ return NULL;
+
ExtensionHost* host = manager->CreatePopup(url, browser);
- views::Widget* frame = BrowserView::GetBrowserViewForNativeWindow(
- browser->window()->GetNativeHandle())->GetWidget();
- ExtensionPopup* popup = new ExtensionPopup(host, frame, relative_to,
+ ExtensionPopup* popup = new ExtensionPopup(host, frame_widget, relative_to,
arrow_location, activate_on_show);
// If the host had somehow finished loading, then we'd miss the notification
diff --git a/chrome/browser/views/extensions/extension_popup.h b/chrome/browser/views/extensions/extension_popup.h
index 4c3ca11..92eab93 100644
--- a/chrome/browser/views/extensions/extension_popup.h
+++ b/chrome/browser/views/extensions/extension_popup.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_VIEWS_EXTENSIONS_EXTENSION_POPUP_H_
#define CHROME_BROWSER_VIEWS_EXTENSIONS_EXTENSION_POPUP_H_
+#include "app/gfx/native_widget_types.h"
#include "chrome/browser/extensions/extension_host.h"
#include "chrome/browser/views/browser_bubble.h"
#include "chrome/browser/views/extensions/extension_view.h"
@@ -15,6 +16,11 @@
class Browser;
class ExtensionHost;
+class Profile;
+
+namespace views {
+class Widget;
+}
class ExtensionPopup : public BrowserBubble,
public NotificationObserver,
@@ -24,6 +30,12 @@ class ExtensionPopup : public BrowserBubble,
// Create and show a popup with |url| positioned adjacent to |relative_to| in
// screen coordinates.
+ // |browser| is the browser to which the pop-up will be attached. NULL is a
+ // valid parameter for pop-ups not associated with a browser.
+ // |profile| is the user profile instance associated with the popup. A
+ // non NULL value must be given.
+ // |frame_window| is the native window that hosts the view inside which the
+ // popup will be anchored.
// The positioning of the pop-up is determined by |arrow_location| according
// to the following logic: The popup is anchored so that the corner indicated
// by value of |arrow_location| remains fixed during popup resizes.
@@ -34,6 +46,8 @@ class ExtensionPopup : public BrowserBubble,
// The actual display of the popup is delayed until the page contents
// finish loading in order to minimize UI flashing and resizing.
static ExtensionPopup* Show(const GURL& url, Browser* browser,
+ Profile* profile,
+ gfx::NativeWindow frame_window,
const gfx::Rect& relative_to,
BubbleBorder::ArrowLocation arrow_location,
bool activate_on_show);