diff options
author | zork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-06 22:51:04 +0000 |
---|---|---|
committer | zork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-06 22:51:04 +0000 |
commit | 11e7e3bd16e35256d1d0a6fd80968aab1b4025f2 (patch) | |
tree | 603b6ac2c47bf1a078785590e44fe10660dfa61a /chrome/browser/extensions | |
parent | ef17eadd053b655afd2453ad08b3a817a69de3a4 (diff) | |
download | chromium_src-11e7e3bd16e35256d1d0a6fd80968aab1b4025f2.zip chromium_src-11e7e3bd16e35256d1d0a6fd80968aab1b4025f2.tar.gz chromium_src-11e7e3bd16e35256d1d0a6fd80968aab1b4025f2.tar.bz2 |
Revert 46592 - Disallow display of multiple experimental.extension.popup(...) windows.
Patch 1 contains twiz@'s code reviewed implementation from http://codereview.chromium.org/1512007.
This CL is to address the failure of release tests.
BUG=None
TEST=ExtensionApiTest.Popup
Review URL: http://codereview.chromium.org/1921003
TBR=ericdingle@google.com
Review URL: http://codereview.chromium.org/2036002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46638 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r-- | chrome/browser/extensions/extension_host.cc | 2 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_host.h | 2 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_popup_api.cc | 86 |
3 files changed, 20 insertions, 70 deletions
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index 3a6ccc3..3921aa6 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -439,9 +439,7 @@ void ExtensionHost::DocumentAvailableInMainFrame(RenderViewHost* rvh) { break; // No style sheet for other types, at the moment. } } -} -void ExtensionHost::DocumentOnLoadCompletedInMainFrame(RenderViewHost* rvh) { if (ViewType::EXTENSION_POPUP == GetRenderViewType()) { NotificationService::current()->Notify( NotificationType::EXTENSION_POPUP_VIEW_READY, diff --git a/chrome/browser/extensions/extension_host.h b/chrome/browser/extensions/extension_host.h index 013cb99..39d2f8b 100644 --- a/chrome/browser/extensions/extension_host.h +++ b/chrome/browser/extensions/extension_host.h @@ -125,8 +125,6 @@ class ExtensionHost : public RenderViewHostDelegate, const ViewHostMsg_FrameNavigate_Params& params); virtual void DidStopLoading(); virtual void DocumentAvailableInMainFrame(RenderViewHost* render_view_host); - virtual void DocumentOnLoadCompletedInMainFrame( - RenderViewHost* render_view_host); virtual WebPreferences GetWebkitPrefs(); virtual void ProcessDOMUIMessage(const std::string& message, diff --git a/chrome/browser/extensions/extension_popup_api.cc b/chrome/browser/extensions/extension_popup_api.cc index 836b5b2..a6f85f2 100644 --- a/chrome/browser/extensions/extension_popup_api.cc +++ b/chrome/browser/extensions/extension_popup_api.cc @@ -12,9 +12,6 @@ #include "chrome/browser/browser.h" #include "chrome/browser/browser_window.h" #include "chrome/browser/profile.h" -#include "chrome/browser/renderer_host/render_view_host.h" -#include "chrome/browser/renderer_host/render_view_host_delegate.h" -#include "chrome/browser/renderer_host/render_widget_host_view.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/notification_details.h" @@ -25,6 +22,9 @@ #include "gfx/point.h" #if defined(TOOLKIT_VIEWS) +#include "chrome/browser/renderer_host/render_view_host.h" +#include "chrome/browser/renderer_host/render_view_host_delegate.h" +#include "chrome/browser/renderer_host/render_widget_host_view.h" #include "chrome/browser/views/extensions/extension_popup.h" #include "views/view.h" #include "views/focus/focus_manager.h" @@ -42,8 +42,6 @@ namespace { const char kBadAnchorArgument[] = "Invalid anchor argument."; const char kInvalidURLError[] = "Invalid URL."; const char kNotAnExtension[] = "Not an extension view."; -const char kPopupsDisallowed[] = - "Popups are only supported from toolstrip or tab-contents views."; // Keys. const wchar_t kUrlKey[] = L"url"; @@ -72,8 +70,7 @@ const char kRectangleChrome[] = "rectangle"; // containing view or any of *its* children. class ExtensionPopupHost : public ExtensionPopup::Observer, public views::WidgetFocusChangeListener, - public base::RefCounted<ExtensionPopupHost>, - public NotificationObserver { + public base::RefCounted<ExtensionPopupHost> { public: explicit ExtensionPopupHost(ExtensionFunctionDispatcher* dispatcher) : dispatcher_(dispatcher), popup_(NULL) { @@ -88,18 +85,9 @@ class ExtensionPopupHost : public ExtensionPopup::Observer, void set_popup(ExtensionPopup* popup) { popup_ = popup; - - // Now that a popup has been assigned, listen for subsequent popups being - // created in the same extension - we want to disallow more than one - // concurrently displayed popup windows. - registrar_.Add( - this, - NotificationType::EXTENSION_HOST_CREATED, - Source<ExtensionProcessManager>( - dispatcher_->profile()->GetExtensionProcessManager())); } - // Overridden from ExtensionPopup::Observer + // Overriden from ExtensionPopup::Observer virtual void ExtensionPopupClosed(ExtensionPopup* popup) { // Unregister the automation resource routing registered upon host // creation. @@ -131,7 +119,7 @@ class ExtensionPopupHost : public ExtensionPopup::Observer, Release(); // Balanced in ctor. } - // Overridden from views::WidgetFocusChangeListener + // Overriden from views::WidgetFocusChangeListener virtual void NativeFocusWillChange(gfx::NativeView focused_before, gfx::NativeView focused_now) { // If no view is to be focused, then Chrome was deactivated, so hide the @@ -141,16 +129,11 @@ class ExtensionPopupHost : public ExtensionPopup::Observer, dispatcher_->delegate()->GetNativeViewOfHost(); // If the widget hosting the popup contains the newly focused view, then - // don't dismiss the pop-up. Note that an ExtensionPopup must have an - // ExtensionHost, but an ExtensionHost may or may not have an - // ExtensionView view. We check to make sure. - ExtensionView* view = popup_->host()->view(); - if (view) { - views::Widget* popup_root_widget = view->GetWidget(); - if (popup_root_widget && - popup_root_widget->ContainsNativeView(focused_now)) - return; - } + // don't dismiss the pop-up. + views::Widget* popup_root_widget = popup_->host()->view()->GetWidget(); + if (popup_root_widget && + popup_root_widget->ContainsNativeView(focused_now)) + return; // If the widget or RenderWidgetHostView hosting the extension that // launched the pop-up is receiving focus, then don't dismiss the popup. @@ -173,23 +156,6 @@ class ExtensionPopupHost : public ExtensionPopup::Observer, &ExtensionPopup::Close)); } - // Overridden from NotificationObserver - virtual void Observe(NotificationType type, - const NotificationSource& source, - const NotificationDetails& details) { - DCHECK(NotificationType::EXTENSION_HOST_CREATED == type); - if (NotificationType::EXTENSION_HOST_CREATED == type) { - Details<ExtensionHost> details_host(details); - // Disallow multiple pop-ups from the same extension, by closing - // the presently opened popup during construction of any new popups. - if (ViewType::EXTENSION_POPUP == details_host->GetRenderViewType() && - popup_->host()->extension() == details_host->extension() && - Details<ExtensionHost>(popup_->host()) != details) { - popup_->Close(); - } - } - } - private: // Returns the AutomationResourceRoutingDelegate interface for |dispatcher|. static AutomationResourceRoutingDelegate* @@ -211,8 +177,6 @@ class ExtensionPopupHost : public ExtensionPopup::Observer, // A pointer to the popup. ExtensionPopup* popup_; - NotificationRegistrar registrar_; - DISALLOW_COPY_AND_ASSIGN(ExtensionPopupHost); }; #endif // TOOLKIT_VIEWS @@ -247,16 +211,6 @@ void PopupShowFunction::Run() { } bool PopupShowFunction::RunImpl() { - // Popups may only be displayed from TAB_CONTENTS and EXTENSION_TOOLSTRIP - // views. - ViewType::Type view_type = - dispatcher()->render_view_host()->delegate()->GetRenderViewType(); - if (ViewType::EXTENSION_TOOLSTRIP != view_type && - ViewType::TAB_CONTENTS != view_type) { - error_ = kPopupsDisallowed; - return false; - } - EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_LIST)); const ListValue* args = args_as_list(); @@ -318,6 +272,7 @@ bool PopupShowFunction::RunImpl() { return false; } +#if defined(TOOLKIT_VIEWS) gfx::Point origin(dom_left, dom_top); if (!dispatcher()->render_view_host()->view()) { error_ = kNotAnExtension; @@ -329,6 +284,14 @@ bool PopupShowFunction::RunImpl() { origin.Offset(content_bounds.x(), content_bounds.y()); gfx::Rect rect(origin.x(), origin.y(), dom_width, dom_height); + // Pop-up from extension views (ExtensionShelf, etc.), and drop-down when + // in a TabContents view. + ViewType::Type view_type = + dispatcher()->render_view_host()->delegate()->GetRenderViewType(); + BubbleBorder::ArrowLocation arrow_location = + view_type == ViewType::TAB_CONTENTS ? + BubbleBorder::TOP_LEFT : BubbleBorder::BOTTOM_LEFT; + // Get the correct native window to pass to ExtensionPopup. // ExtensionFunctionDispatcher::Delegate may provide a custom implementation // of this. @@ -337,13 +300,6 @@ bool PopupShowFunction::RunImpl() { if (!window) window = GetCurrentBrowser()->window()->GetNativeHandle(); -#if defined(TOOLKIT_VIEWS) - // Pop-up from extension views (ExtensionShelf, etc.), and drop-down when - // in a TabContents view. - BubbleBorder::ArrowLocation arrow_location = - view_type == ViewType::TAB_CONTENTS ? - BubbleBorder::TOP_LEFT : BubbleBorder::BOTTOM_LEFT; - // ExtensionPopupHost manages it's own lifetime. ExtensionPopupHost* popup_host = new ExtensionPopupHost(dispatcher()); popup_ = ExtensionPopup::Show(url, @@ -373,8 +329,6 @@ void PopupShowFunction::Observe(NotificationType type, type == NotificationType::EXTENSION_HOST_DESTROYED); DCHECK(popup_ != NULL); - // Wait for notification that the popup view is ready (and onload has been - // called), before completing the API call. if (popup_ && type == NotificationType::EXTENSION_POPUP_VIEW_READY && Details<ExtensionHost>(popup_->host()) == details) { SendResponse(true); |