diff options
author | levin@chromium.org <levin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-20 23:07:03 +0000 |
---|---|---|
committer | levin@chromium.org <levin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-20 23:07:03 +0000 |
commit | 3060ce78db15f4a923d949ab5c1aaa5f75a1a066 (patch) | |
tree | fd5cc29e1927d7191448963099afce23ecc3f35d /chrome | |
parent | d5e28a3e5402329a9f50075ed8d6417feeea7c71 (diff) | |
download | chromium_src-3060ce78db15f4a923d949ab5c1aaa5f75a1a066.zip chromium_src-3060ce78db15f4a923d949ab5c1aaa5f75a1a066.tar.gz chromium_src-3060ce78db15f4a923d949ab5c1aaa5f75a1a066.tar.bz2 |
Move extension pop-ups and notifications to the new auto-resize code.
This should fix the "flicker" issues where autosize ends up flipping
back and forth between two size in rapid succession.
The change in render_widget_host is needed to avoid cases where the OnMsgUpdateRect happens while processing a resize message which may result in recursion back into the resize code which is undesirable.
BUG=58816,56693
TEST=Try out auto resize in notifications and extensions. Best to do with windows that change
size and hit the maximum as well as minimum sizes on the 3 desktop platforms for pop-ups.
Review URL: http://codereview.chromium.org/9702068
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@127824 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
21 files changed, 86 insertions, 90 deletions
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index 71c7442..803c562 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -293,10 +293,10 @@ void ExtensionHost::Observe(int type, } } -void ExtensionHost::UpdatePreferredSize(WebContents* source, - const gfx::Size& pref_size) { +void ExtensionHost::ResizeDueToAutoResize(WebContents* source, + const gfx::Size& new_size) { if (view_.get()) - view_->UpdatePreferredSize(pref_size); + view_->ResizeDueToAutoResize(new_size); } void ExtensionHost::RenderViewGone(base::TerminationStatus status) { @@ -334,11 +334,6 @@ void ExtensionHost::InsertInfobarCSS() { render_view_host()->InsertCSS(string16(), css.as_string()); } -void ExtensionHost::DisableScrollbarsForSmallWindows( - const gfx::Size& size_limit) { - render_view_host()->DisableScrollbarsForThreshold(size_limit); -} - void ExtensionHost::DidStopLoading() { bool notify = !did_stop_loading_; did_stop_loading_ = true; @@ -485,11 +480,6 @@ void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) { if (view_.get()) view_->RenderViewCreated(); - if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP || - extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_INFOBAR) { - render_view_host->EnablePreferredSizeMode(); - } - // If the host is bound to a browser, then extract its window id. // Extensions hosted in ExternalTabContainer objects may not have // an associated browser. diff --git a/chrome/browser/extensions/extension_host.h b/chrome/browser/extensions/extension_host.h index 8c1a36c..e4a177c 100644 --- a/chrome/browser/extensions/extension_host.h +++ b/chrome/browser/extensions/extension_host.h @@ -141,10 +141,6 @@ class ExtensionHost : public content::WebContentsDelegate, // Insert a default style sheet for Extension Infobars. void InsertInfobarCSS(); - // Tell the renderer not to draw scrollbars on windows smaller than - // |size_limit| in both width and height. - void DisableScrollbarsForSmallWindows(const gfx::Size& size_limit); - // content::WebContentsObserver virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; virtual void RenderViewCreated( @@ -165,8 +161,8 @@ class ExtensionHost : public content::WebContentsDelegate, bool* is_keyboard_shortcut) OVERRIDE; virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) OVERRIDE; - virtual void UpdatePreferredSize(content::WebContents* source, - const gfx::Size& pref_size) OVERRIDE; + virtual void ResizeDueToAutoResize(content::WebContents* source, + const gfx::Size& new_size) OVERRIDE; virtual content::JavaScriptDialogCreator* GetJavaScriptDialogCreator() OVERRIDE; virtual void RunFileChooser( diff --git a/chrome/browser/notifications/balloon.cc b/chrome/browser/notifications/balloon.cc index 4a2c0be..c0c2f4b2 100644 --- a/chrome/browser/notifications/balloon.cc +++ b/chrome/browser/notifications/balloon.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -26,7 +26,7 @@ void Balloon::SetPosition(const gfx::Point& upper_left, bool reposition) { balloon_view_->RepositionToBalloon(); } -void Balloon::SetContentPreferredSize(const gfx::Size& size) { +void Balloon::ResizeDueToAutoResize(const gfx::Size& size) { collection_->ResizeBalloon(this, size); } diff --git a/chrome/browser/notifications/balloon.h b/chrome/browser/notifications/balloon.h index b1b89e7..ada6fba 100644 --- a/chrome/browser/notifications/balloon.h +++ b/chrome/browser/notifications/balloon.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -77,7 +77,7 @@ class Balloon { // Request a new content size for this balloon. This will get passed // to the balloon collection for checking against available space and // min/max restrictions. - void SetContentPreferredSize(const gfx::Size& size); + void ResizeDueToAutoResize(const gfx::Size& size); // Provides a view for this balloon. Ownership transfers // to this object. diff --git a/chrome/browser/notifications/balloon_collection_impl.h b/chrome/browser/notifications/balloon_collection_impl.h index f505463..1e4ceb0 100644 --- a/chrome/browser/notifications/balloon_collection_impl.h +++ b/chrome/browser/notifications/balloon_collection_impl.h @@ -76,6 +76,11 @@ class BalloonCollectionImpl : public BalloonCollection, // balloons in the collection. int count() const { return base_.count(); } + static int min_balloon_width() { return Layout::min_balloon_width(); } + static int max_balloon_width() { return Layout::max_balloon_width(); } + static int min_balloon_height() { return Layout::min_balloon_height(); } + static int max_balloon_height() { return Layout::max_balloon_height(); } + protected: // Calculates layout values for the balloons including // the scaling, the max/min sizes, and the upper left corner of each. diff --git a/chrome/browser/notifications/balloon_host.cc b/chrome/browser/notifications/balloon_host.cc index bc79b3c..05d7301 100644 --- a/chrome/browser/notifications/balloon_host.cc +++ b/chrome/browser/notifications/balloon_host.cc @@ -2,8 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/notifications/balloon.h" #include "chrome/browser/notifications/balloon_host.h" + +#include "chrome/browser/notifications/balloon.h" +#include "chrome/browser/notifications/balloon_collection_impl.h" #include "chrome/browser/notifications/notification.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/renderer_preferences_util.h" @@ -68,9 +70,9 @@ void BalloonHost::HandleMouseDown() { balloon_->OnClick(); } -void BalloonHost::UpdatePreferredSize(WebContents* source, - const gfx::Size& pref_size) { - balloon_->SetContentPreferredSize(pref_size); +void BalloonHost::ResizeDueToAutoResize(WebContents* source, + const gfx::Size& pref_size) { + balloon_->ResizeDueToAutoResize(pref_size); } void BalloonHost::AddNewContents(WebContents* source, @@ -86,10 +88,11 @@ void BalloonHost::AddNewContents(WebContents* source, } void BalloonHost::RenderViewCreated(content::RenderViewHost* render_view_host) { - render_view_host->DisableScrollbarsForThreshold( - balloon_->min_scrollbar_size()); - render_view_host->WasResized(); - render_view_host->EnablePreferredSizeMode(); + gfx::Size min_size(BalloonCollectionImpl::min_balloon_width(), + BalloonCollectionImpl::min_balloon_height()); + gfx::Size max_size(BalloonCollectionImpl::max_balloon_width(), + BalloonCollectionImpl::max_balloon_height()); + render_view_host->EnableAutoResize(min_size, max_size); if (enable_web_ui_) render_view_host->AllowBindings(content::BINDINGS_POLICY_WEB_UI); diff --git a/chrome/browser/notifications/balloon_host.h b/chrome/browser/notifications/balloon_host.h index 3913c71..00b1565 100644 --- a/chrome/browser/notifications/balloon_host.h +++ b/chrome/browser/notifications/balloon_host.h @@ -59,8 +59,8 @@ class BalloonHost : public content::WebContentsDelegate, // content::WebContentsDelegate implementation: virtual void CloseContents(content::WebContents* source) OVERRIDE; virtual void HandleMouseDown() OVERRIDE; - virtual void UpdatePreferredSize(content::WebContents* source, - const gfx::Size& pref_size) OVERRIDE; + virtual void ResizeDueToAutoResize(content::WebContents* source, + const gfx::Size& pref_size) OVERRIDE; virtual void AddNewContents(content::WebContents* source, content::WebContents* new_contents, WindowOpenDisposition disposition, diff --git a/chrome/browser/ui/android/extensions/extension_view_android.cc b/chrome/browser/ui/android/extensions/extension_view_android.cc index a66ba91..072c5fe 100644 --- a/chrome/browser/ui/android/extensions/extension_view_android.cc +++ b/chrome/browser/ui/android/extensions/extension_view_android.cc @@ -6,7 +6,7 @@ #include "base/logging.h" -void ExtensionViewAndroid::UpdatePreferredSize(const gfx::Size& new_size) { +void ExtensionViewAndroid::ResizeDueToAutoResize(const gfx::Size& new_size) { NOTIMPLEMENTED(); } diff --git a/chrome/browser/ui/android/extensions/extension_view_android.h b/chrome/browser/ui/android/extensions/extension_view_android.h index 4057b4a..547c796 100644 --- a/chrome/browser/ui/android/extensions/extension_view_android.h +++ b/chrome/browser/ui/android/extensions/extension_view_android.h @@ -15,7 +15,7 @@ class ExtensionViewAndroid { public: Browser* browser() const { return NULL; } - void UpdatePreferredSize(const gfx::Size& new_size); + void ResizeDueToAutoResize(const gfx::Size& new_size); void RenderViewCreated(); private: diff --git a/chrome/browser/ui/cocoa/extensions/extension_popup_controller.h b/chrome/browser/ui/cocoa/extensions/extension_popup_controller.h index 6909df5..7a7ac41 100644 --- a/chrome/browser/ui/cocoa/extensions/extension_popup_controller.h +++ b/chrome/browser/ui/cocoa/extensions/extension_popup_controller.h @@ -51,8 +51,8 @@ class NotificationRegistrar; // Whether the popup has a devtools window attached to it. BOOL beingInspected_; - // The preferred size once the ExtensionView has loaded. - NSSize pendingPreferredSize_; + // The size once the ExtensionView has loaded. + NSSize pendingSize_; } // Returns the ExtensionHost object associated with this popup. diff --git a/chrome/browser/ui/cocoa/extensions/extension_popup_controller.mm b/chrome/browser/ui/cocoa/extensions/extension_popup_controller.mm index 4827299..9a6043a 100644 --- a/chrome/browser/ui/cocoa/extensions/extension_popup_controller.mm +++ b/chrome/browser/ui/cocoa/extensions/extension_popup_controller.mm @@ -48,8 +48,8 @@ CGFloat Clamp(CGFloat value, CGFloat min, CGFloat max) { // Called when the extension's hosted NSView has been resized. - (void)extensionViewFrameChanged; -// Called when the extension's preferred size changes. -- (void)onPreferredSizeChanged:(NSSize)newSize; +// Called when the extension's size changes. +- (void)onSizeChanged:(NSSize)newSize; // Called when the extension view is shown. - (void)onViewDidShow; @@ -61,10 +61,10 @@ class ExtensionPopupContainer : public ExtensionViewMac::Container { : controller_(controller) { } - virtual void OnExtensionPreferredSizeChanged( + virtual void OnExtensionSizeChanged( ExtensionViewMac* view, const gfx::Size& new_size) OVERRIDE { - [controller_ onPreferredSizeChanged: + [controller_ onSizeChanged: NSMakeSize(new_size.width(), new_size.height())]; } @@ -300,10 +300,10 @@ class DevtoolsNotificationBridge : public content::NotificationObserver { } } -- (void)onPreferredSizeChanged:(NSSize)newSize { +- (void)onSizeChanged:(NSSize)newSize { // When we update the size, the window will become visible. Stay hidden until // the host is loaded. - pendingPreferredSize_ = newSize; + pendingSize_ = newSize; if (!host_->did_stop_loading()) return; @@ -315,20 +315,12 @@ class DevtoolsNotificationBridge : public content::NotificationObserver { // |new_size| is in pixels. Convert to view units. frame.size = [extensionView_ convertSize:frame.size fromView:nil]; - // On first display of some extensions, this function is called with zero - // width after the correct size has been set. Bail if zero is seen, assuming - // that an extension's view doesn't want any dimensions to ever be zero. - // http://crbug.com/112810 - Verify this assumption and look into WebCore's - // |contentsPreferredWidth| to see why this is occurring. - if (NSIsEmptyRect(frame)) - return; - [extensionView_ setFrame:frame]; [extensionView_ setNeedsDisplay:YES]; } - (void)onViewDidShow { - [self onPreferredSizeChanged:pendingPreferredSize_]; + [self onSizeChanged:pendingSize_]; } - (void)windowDidResize:(NSNotification*)notification { diff --git a/chrome/browser/ui/cocoa/extensions/extension_view_mac.h b/chrome/browser/ui/cocoa/extensions/extension_view_mac.h index 68ba481d..0871bcf 100644 --- a/chrome/browser/ui/cocoa/extensions/extension_view_mac.h +++ b/chrome/browser/ui/cocoa/extensions/extension_view_mac.h @@ -27,8 +27,8 @@ class ExtensionViewMac { class Container { public: virtual ~Container() {} - virtual void OnExtensionPreferredSizeChanged(ExtensionViewMac* view, - const gfx::Size& new_size) {} + virtual void OnExtensionSizeChanged(ExtensionViewMac* view, + const gfx::Size& new_size) {} virtual void OnExtensionViewDidShow(ExtensionViewMac* view) {}; }; @@ -57,7 +57,7 @@ class ExtensionViewMac { // Method for the ExtensionHost to notify us about the correct size for // extension contents. - void UpdatePreferredSize(const gfx::Size& new_size); + void ResizeDueToAutoResize(const gfx::Size& new_size); // Method for the ExtensionHost to notify us when the RenderViewHost has a // connection. diff --git a/chrome/browser/ui/cocoa/extensions/extension_view_mac.mm b/chrome/browser/ui/cocoa/extensions/extension_view_mac.mm index 21348cf..189a0d7 100644 --- a/chrome/browser/ui/cocoa/extensions/extension_view_mac.mm +++ b/chrome/browser/ui/cocoa/extensions/extension_view_mac.mm @@ -7,6 +7,7 @@ #include "chrome/browser/ui/cocoa/extensions/extension_view_mac.h" #include "chrome/browser/extensions/extension_host.h" +#include "chrome/common/chrome_view_type.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/web_contents.h" @@ -55,24 +56,25 @@ void ExtensionViewMac::SetBackground(const SkBitmap& background) { ShowIfCompletelyLoaded(); } -void ExtensionViewMac::UpdatePreferredSize(const gfx::Size& new_size) { +void ExtensionViewMac::ResizeDueToAutoResize(const gfx::Size& new_size) { if (container_) - container_->OnExtensionPreferredSizeChanged(this, new_size); + container_->OnExtensionSizeChanged(this, new_size); } void ExtensionViewMac::RenderViewCreated() { - // Do not allow webkit to draw scroll bars on views smaller than - // the largest size view allowed. The view will be resized to make - // scroll bars unnecessary. Scroll bars change the height of the - // view, so not drawing them is necessary to avoid infinite resizing. - gfx::Size largest_popup_size( - CGSizeMake(ExtensionViewMac::kMaxWidth, ExtensionViewMac::kMaxHeight)); - extension_host_->DisableScrollbarsForSmallWindows(largest_popup_size); - if (!pending_background_.empty() && render_view_host()->GetView()) { render_view_host()->GetView()->SetBackground(pending_background_); pending_background_.reset(); } + + content::ViewType host_type = extension_host_->extension_host_type(); + if (host_type == chrome::VIEW_TYPE_EXTENSION_POPUP) { + gfx::Size min_size(ExtensionViewMac::kMinWidth, + ExtensionViewMac::kMinHeight); + gfx::Size max_size(ExtensionViewMac::kMaxWidth, + ExtensionViewMac::kMaxHeight); + render_view_host()->EnableAutoResize(min_size, max_size); + } } void ExtensionViewMac::WindowFrameChanged() { diff --git a/chrome/browser/ui/gtk/extensions/extension_popup_gtk.cc b/chrome/browser/ui/gtk/extensions/extension_popup_gtk.cc index 93b2909..59cddd2 100644 --- a/chrome/browser/ui/gtk/extensions/extension_popup_gtk.cc +++ b/chrome/browser/ui/gtk/extensions/extension_popup_gtk.cc @@ -136,7 +136,7 @@ void ExtensionPopupGtk::BubbleClosing(BubbleGtk* bubble, delete this; } -void ExtensionPopupGtk::OnExtensionPreferredSizeChanged( +void ExtensionPopupGtk::OnExtensionSizeChanged( ExtensionViewGtk* view, const gfx::Size& new_size) { int width = std::max(kMinWidth, std::min(kMaxWidth, new_size.width())); diff --git a/chrome/browser/ui/gtk/extensions/extension_popup_gtk.h b/chrome/browser/ui/gtk/extensions/extension_popup_gtk.h index 462fcc6..c3d788b 100644 --- a/chrome/browser/ui/gtk/extensions/extension_popup_gtk.h +++ b/chrome/browser/ui/gtk/extensions/extension_popup_gtk.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -44,7 +44,7 @@ class ExtensionPopupGtk : public content::NotificationObserver, bool closed_by_escape) OVERRIDE; // ExtensionViewGtk::Container implementation. - virtual void OnExtensionPreferredSizeChanged( + virtual void OnExtensionSizeChanged( ExtensionViewGtk* view, const gfx::Size& new_size) OVERRIDE; diff --git a/chrome/browser/ui/gtk/extensions/extension_view_gtk.cc b/chrome/browser/ui/gtk/extensions/extension_view_gtk.cc index 97f52ec..d1675ee 100644 --- a/chrome/browser/ui/gtk/extensions/extension_view_gtk.cc +++ b/chrome/browser/ui/gtk/extensions/extension_view_gtk.cc @@ -6,6 +6,7 @@ #include "chrome/browser/extensions/extension_host.h" #include "chrome/browser/ui/gtk/extensions/extension_popup_gtk.h" +#include "chrome/common/chrome_view_type.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/web_contents.h" @@ -38,9 +39,9 @@ void ExtensionViewGtk::SetBackground(const SkBitmap& background) { } } -void ExtensionViewGtk::UpdatePreferredSize(const gfx::Size& new_size) { +void ExtensionViewGtk::ResizeDueToAutoResize(const gfx::Size& new_size) { if (container_) - container_->OnExtensionPreferredSizeChanged(this, new_size); + container_->OnExtensionSizeChanged(this, new_size); } void ExtensionViewGtk::CreateWidgetHostView() { @@ -53,9 +54,12 @@ void ExtensionViewGtk::RenderViewCreated() { pending_background_.reset(); } - // Tell the renderer not to draw scrollbars in popups unless the - // popups are at the maximum allowed size. - gfx::Size largest_popup_size(ExtensionPopupGtk::kMaxWidth, - ExtensionPopupGtk::kMaxHeight); - extension_host_->DisableScrollbarsForSmallWindows(largest_popup_size); + content::ViewType host_type = extension_host_->extension_host_type(); + if (host_type == chrome::VIEW_TYPE_EXTENSION_POPUP) { + gfx::Size min_size(ExtensionPopupGtk::kMinWidth, + ExtensionPopupGtk::kMinHeight); + gfx::Size max_size(ExtensionPopupGtk::kMaxWidth, + ExtensionPopupGtk::kMaxHeight); + render_view_host()->EnableAutoResize(min_size, max_size); + } } diff --git a/chrome/browser/ui/gtk/extensions/extension_view_gtk.h b/chrome/browser/ui/gtk/extensions/extension_view_gtk.h index 5476148..fb39a48 100644 --- a/chrome/browser/ui/gtk/extensions/extension_view_gtk.h +++ b/chrome/browser/ui/gtk/extensions/extension_view_gtk.h @@ -26,8 +26,8 @@ class ExtensionViewGtk { class Container { public: virtual ~Container() {} - virtual void OnExtensionPreferredSizeChanged(ExtensionViewGtk* view, - const gfx::Size& new_size) {} + virtual void OnExtensionSizeChanged(ExtensionViewGtk* view, + const gfx::Size& new_size) {} }; void Init(); @@ -42,7 +42,7 @@ class ExtensionViewGtk { // Method for the ExtensionHost to notify us about the correct size for // extension contents. - void UpdatePreferredSize(const gfx::Size& new_size); + void ResizeDueToAutoResize(const gfx::Size& new_size); // Method for the ExtensionHost to notify us when the RenderViewHost has a // connection. diff --git a/chrome/browser/ui/views/extensions/extension_popup.cc b/chrome/browser/ui/views/extensions/extension_popup.cc index c7b24cd..df16d45 100644 --- a/chrome/browser/ui/views/extensions/extension_popup.cc +++ b/chrome/browser/ui/views/extensions/extension_popup.cc @@ -137,7 +137,7 @@ void ExtensionPopup::Observe(int type, } } -void ExtensionPopup::OnExtensionPreferredSizeChanged(ExtensionView* view) { +void ExtensionPopup::OnExtensionSizeChanged(ExtensionView* view) { SizeToContents(); } diff --git a/chrome/browser/ui/views/extensions/extension_popup.h b/chrome/browser/ui/views/extensions/extension_popup.h index e17ad36..f6fcb63 100644 --- a/chrome/browser/ui/views/extensions/extension_popup.h +++ b/chrome/browser/ui/views/extensions/extension_popup.h @@ -50,7 +50,7 @@ class ExtensionPopup : public views::BubbleDelegateView, const content::NotificationDetails& details) OVERRIDE; // ExtensionView::Container overrides. - virtual void OnExtensionPreferredSizeChanged(ExtensionView* view) OVERRIDE; + virtual void OnExtensionSizeChanged(ExtensionView* view) OVERRIDE; // views::View overrides. virtual gfx::Size GetPreferredSize() OVERRIDE; diff --git a/chrome/browser/ui/views/extensions/extension_view.cc b/chrome/browser/ui/views/extensions/extension_view.cc index fd5861f..a6cdcc7 100644 --- a/chrome/browser/ui/views/extensions/extension_view.cc +++ b/chrome/browser/ui/views/extensions/extension_view.cc @@ -6,6 +6,7 @@ #include "chrome/browser/extensions/extension_host.h" #include "chrome/browser/ui/views/extensions/extension_popup.h" +#include "chrome/common/chrome_view_type.h" #include "content/public/browser/content_browser_client.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/render_widget_host_view.h" @@ -89,7 +90,7 @@ void ExtensionView::ShowIfCompletelyLoaded() { // actually been created. These can happen in different orders. if (host_->did_stop_loading()) { SetVisible(true); - UpdatePreferredSize(pending_preferred_size_); + ResizeDueToAutoResize(pending_preferred_size_); } } @@ -110,7 +111,7 @@ void ExtensionView::SetBackground(const SkBitmap& background) { ShowIfCompletelyLoaded(); } -void ExtensionView::UpdatePreferredSize(const gfx::Size& new_size) { +void ExtensionView::ResizeDueToAutoResize(const gfx::Size& new_size) { // Don't actually do anything with this information until we have been shown. // Size changes will not be honored by lower layers while we are hidden. if (!visible()) { @@ -134,7 +135,7 @@ void ExtensionView::ViewHierarchyChanged(bool is_add, void ExtensionView::PreferredSizeChanged() { View::PreferredSizeChanged(); if (container_) - container_->OnExtensionPreferredSizeChanged(this); + container_->OnExtensionSizeChanged(this); } bool ExtensionView::SkipDefaultKeyEventProcessing(const views::KeyEvent& e) { @@ -163,11 +164,14 @@ void ExtensionView::RenderViewCreated() { pending_background_.reset(); } - // Tell the renderer not to draw scroll bars in popups unless the - // popups are at the maximum allowed size. - gfx::Size largest_popup_size(ExtensionPopup::kMaxWidth, - ExtensionPopup::kMaxHeight); - host_->DisableScrollbarsForSmallWindows(largest_popup_size); + content::ViewType host_type = host_->extension_host_type(); + if (host_type == chrome::VIEW_TYPE_EXTENSION_POPUP) { + gfx::Size min_size(ExtensionPopup::kMinWidth, + ExtensionPopup::kMinHeight); + gfx::Size max_size(ExtensionPopup::kMaxWidth, + ExtensionPopup::kMaxHeight); + render_view_host()->EnableAutoResize(min_size, max_size); + } if (container_) container_->OnViewWasResized(); diff --git a/chrome/browser/ui/views/extensions/extension_view.h b/chrome/browser/ui/views/extensions/extension_view.h index 660773a1..5254075 100644 --- a/chrome/browser/ui/views/extensions/extension_view.h +++ b/chrome/browser/ui/views/extensions/extension_view.h @@ -31,7 +31,7 @@ class ExtensionView : public views::NativeViewHost { class Container { public: virtual ~Container() {} - virtual void OnExtensionPreferredSizeChanged(ExtensionView* view) {} + virtual void OnExtensionSizeChanged(ExtensionView* view) {} virtual void OnViewWasResized() {} }; @@ -43,7 +43,7 @@ class ExtensionView : public views::NativeViewHost { void SetIsClipped(bool is_clipped); // Notification from ExtensionHost. - void UpdatePreferredSize(const gfx::Size& new_size); + void ResizeDueToAutoResize(const gfx::Size& new_size); // Method for the ExtensionHost to notify us when the RenderViewHost has a // connection. |