diff options
author | jcivelli@google.com <jcivelli@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-05 19:58:07 +0000 |
---|---|---|
committer | jcivelli@google.com <jcivelli@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-05 19:58:07 +0000 |
commit | 705243f33047d66a6e0c674041af5dc59073871d (patch) | |
tree | c7d01e2a6b6281455643895369fe3c93032e6cf4 /chrome/browser/tab_contents | |
parent | 377ddd48b5aff4fb231d78fa197f07c933424110 (diff) | |
download | chromium_src-705243f33047d66a6e0c674041af5dc59073871d.zip chromium_src-705243f33047d66a6e0c674041af5dc59073871d.tar.gz chromium_src-705243f33047d66a6e0c674041af5dc59073871d.tar.bz2 |
Make the app launcher bubble fit its contents.
It remains at least as wide as the browser location bar (that way it can always point at the + button).
InfoBubble was modified so it can be resized.
BUG=42260
TEST=Open the app launcher multiple-times. The app launcher
should fit its contents nicely.
Review URL: http://codereview.chromium.org/1739020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46482 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents')
5 files changed, 19 insertions, 13 deletions
diff --git a/chrome/browser/tab_contents/tab_contents_delegate.h b/chrome/browser/tab_contents/tab_contents_delegate.h index eb26827..2c153d2 100644 --- a/chrome/browser/tab_contents/tab_contents_delegate.h +++ b/chrome/browser/tab_contents/tab_contents_delegate.h @@ -286,6 +286,10 @@ class TabContentsDelegate : public AutomationResourceRoutingDelegate { // Returns whether infobars are enabled. Overrideable by child classes. virtual bool infobars_enabled() { return true; } + // Notification that the preferred size of the contents has changed. + // Only called if RenderViewHost::EnablePreferredSizeChangedMode() was called. + virtual void UpdatePreferredSize(const gfx::Size& pref_size) {} + protected: ~TabContentsDelegate() {} }; diff --git a/chrome/browser/tab_contents/tab_contents_view.cc b/chrome/browser/tab_contents/tab_contents_view.cc index b6d45a0..935b96d 100644 --- a/chrome/browser/tab_contents/tab_contents_view.cc +++ b/chrome/browser/tab_contents/tab_contents_view.cc @@ -12,8 +12,7 @@ #include "chrome/browser/tab_contents/tab_contents_delegate.h" TabContentsView::TabContentsView(TabContents* tab_contents) - : tab_contents_(tab_contents), - preferred_width_(0) { + : tab_contents_(tab_contents) { } void TabContentsView::RenderWidgetHostDestroyed(RenderWidgetHost* host) { @@ -26,10 +25,6 @@ void TabContentsView::RenderViewCreated(RenderViewHost* host) { // Default implementation does nothing. Platforms may override. } -void TabContentsView::UpdatePreferredSize(const gfx::Size& pref_size) { - preferred_width_ = pref_size.width(); -} - void TabContentsView::CreateNewWindow( int route_id, WindowContainerType window_container_type) { @@ -72,6 +67,11 @@ bool TabContentsView::PreHandleKeyboardEvent( event, is_keyboard_shortcut); } +void TabContentsView::UpdatePreferredSize(const gfx::Size& pref_size) { + if (tab_contents_->delegate()) + tab_contents_->delegate()->UpdatePreferredSize(pref_size); +} + void TabContentsView::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { if (tab_contents_->delegate()) tab_contents_->delegate()->HandleKeyboardEvent(event); diff --git a/chrome/browser/tab_contents/tab_contents_view.h b/chrome/browser/tab_contents/tab_contents_view.h index e9e26b3..e54e19d 100644 --- a/chrome/browser/tab_contents/tab_contents_view.h +++ b/chrome/browser/tab_contents/tab_contents_view.h @@ -130,11 +130,8 @@ class TabContentsView : public RenderViewHostDelegate::View { virtual void HandleMouseEvent() {} virtual void HandleMouseLeave() {} - // Set and return the content's intrinsic width. + // Notification that the preferred size of the contents has changed. virtual void UpdatePreferredSize(const gfx::Size& pref_size); - int preferred_width() const { - return preferred_width_; - } // If we try to close the tab while a drag is in progress, we crash. These // methods allow the tab contents to determine if a drag is in progress and @@ -202,9 +199,6 @@ class TabContentsView : public RenderViewHostDelegate::View { typedef std::map<int, RenderWidgetHostView*> PendingWidgetViews; PendingWidgetViews pending_widget_views_; - // The page content's intrinsic width. - int preferred_width_; - DISALLOW_COPY_AND_ASSIGN(TabContentsView); }; diff --git a/chrome/browser/tab_contents/tab_contents_view_mac.h b/chrome/browser/tab_contents/tab_contents_view_mac.h index 38853ac..91ef23d 100644 --- a/chrome/browser/tab_contents/tab_contents_view_mac.h +++ b/chrome/browser/tab_contents/tab_contents_view_mac.h @@ -67,6 +67,7 @@ class TabContentsViewMac : public TabContentsView, virtual void SetInitialFocus(); virtual void StoreFocus(); virtual void RestoreFocus(); + virtual void UpdatePreferredSize(const gfx::Size& pref_size); virtual RenderWidgetHostView* CreateNewWidgetInternal( int route_id, WebKit::WebPopupType popup_type); @@ -95,6 +96,8 @@ class TabContentsViewMac : public TabContentsView, // CloseTabAfterEventTracking() implementation. void CloseTab(); + int preferred_width() const { return preferred_width_; } + private: // The Cocoa NSView that lives in the view hierarchy. scoped_nsobject<TabContentsViewCocoa> cocoa_view_; diff --git a/chrome/browser/tab_contents/tab_contents_view_mac.mm b/chrome/browser/tab_contents/tab_contents_view_mac.mm index 495ac24..9e8b70d 100644 --- a/chrome/browser/tab_contents/tab_contents_view_mac.mm +++ b/chrome/browser/tab_contents/tab_contents_view_mac.mm @@ -219,6 +219,11 @@ void TabContentsViewMac::RestoreFocus() { focus_tracker_.reset(nil); } +void TabContentsViewMac::UpdatePreferredSize(const gfx::Size& pref_size) { + preferred_width_ = pref_size.width(); + TabContentsView::UpdatePreferredSize(pref_size); +} + void TabContentsViewMac::UpdateDragCursor(WebDragOperation operation) { [cocoa_view_ setCurrentDragOperation: operation]; } |