diff options
Diffstat (limited to 'chrome/browser/tab_contents')
-rw-r--r-- | chrome/browser/tab_contents/interstitial_page.cc | 5 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.cc | 2 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents_view.cc | 11 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents_view.h | 14 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents_view_mac.h | 4 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents_view_mac.mm | 8 |
6 files changed, 43 insertions, 1 deletions
diff --git a/chrome/browser/tab_contents/interstitial_page.cc b/chrome/browser/tab_contents/interstitial_page.cc index 0dbe26a..04afbbc 100644 --- a/chrome/browser/tab_contents/interstitial_page.cc +++ b/chrome/browser/tab_contents/interstitial_page.cc @@ -90,6 +90,7 @@ class InterstitialPage::InterstitialPageRVHViewDelegate const gfx::Rect& selection_rect, int active_match_ordinal, bool final_update); + virtual void UpdatePreferredWidth(int pref_width); private: InterstitialPage* interstitial_page_; @@ -516,6 +517,10 @@ void InterstitialPage::InterstitialPageRVHViewDelegate::UpdateDragCursor( NOTREACHED() << "InterstitialPage does not support dragging yet."; } +void InterstitialPage::InterstitialPageRVHViewDelegate::UpdatePreferredWidth( + int pref_width) { +} + void InterstitialPage::InterstitialPageRVHViewDelegate::TakeFocus( bool reverse) { if (interstitial_page_->tab() && interstitial_page_->tab()->GetViewDelegate()) diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index 5bc2cacd..d253dc9 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -1626,6 +1626,8 @@ void TabContents::RenderViewCreated(RenderViewHost* render_view_host) { render_view_host->Send( new ViewMsg_EnableViewSourceMode(render_view_host->routing_id())); } + + view()->RenderViewCreated(render_view_host); } void TabContents::RenderViewReady(RenderViewHost* rvh) { diff --git a/chrome/browser/tab_contents/tab_contents_view.cc b/chrome/browser/tab_contents/tab_contents_view.cc index 402876d..78d084a 100644 --- a/chrome/browser/tab_contents/tab_contents_view.cc +++ b/chrome/browser/tab_contents/tab_contents_view.cc @@ -11,7 +11,8 @@ #include "chrome/browser/tab_contents/tab_contents_delegate.h" TabContentsView::TabContentsView(TabContents* tab_contents) - : tab_contents_(tab_contents) { + : tab_contents_(tab_contents), + preferred_width_(0) { } void TabContentsView::CreateView() { @@ -21,6 +22,14 @@ void TabContentsView::RenderWidgetHostDestroyed(RenderWidgetHost* host) { delegate_view_helper_.RenderWidgetHostDestroyed(host); } +void TabContentsView::RenderViewCreated(RenderViewHost* host) { + // Default implementation does nothing. Platforms may override. +} + +void TabContentsView::UpdatePreferredWidth(int pref_width) { + preferred_width_ = pref_width; +} + void TabContentsView::CreateNewWindow(int route_id, base::WaitableEvent* modal_dialog_event) { delegate_view_helper_.CreateNewWindow(route_id, modal_dialog_event, diff --git a/chrome/browser/tab_contents/tab_contents_view.h b/chrome/browser/tab_contents/tab_contents_view.h index 2af4902..c5868b0 100644 --- a/chrome/browser/tab_contents/tab_contents_view.h +++ b/chrome/browser/tab_contents/tab_contents_view.h @@ -110,6 +110,11 @@ class TabContentsView : public RenderViewHostDelegate::View { // RenderWidgetHost is deleted. Removes |host| from internal maps. void RenderWidgetHostDestroyed(RenderWidgetHost* host); + // Invoked when the TabContents is notified that the RenderView has been + // fully created. The default implementation does nothing; override + // for platform-specific behavior is needed. + virtual void RenderViewCreated(RenderViewHost* host); + // Sets focus to the native widget for this tab. virtual void Focus() = 0; @@ -124,6 +129,12 @@ class TabContentsView : public RenderViewHostDelegate::View { // invoked, SetInitialFocus is invoked. virtual void RestoreFocus() = 0; + // Set and return the content's intrinsic width. + virtual void UpdatePreferredWidth(int pref_width); + int preferred_width() const { + return preferred_width_; + } + protected: TabContentsView() {} // Abstract interface. @@ -171,6 +182,9 @@ 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 0fd3c89..8259316 100644 --- a/chrome/browser/tab_contents/tab_contents_view_mac.h +++ b/chrome/browser/tab_contents/tab_contents_view_mac.h @@ -46,6 +46,7 @@ class TabContentsViewMac : public TabContentsView, virtual gfx::NativeWindow GetTopLevelNativeWindow() const; virtual void GetContainerBounds(gfx::Rect* out) const; virtual void OnContentsDestroy(); + virtual void RenderViewCreated(RenderViewHost* host); virtual void SetPageTitle(const std::wstring& title); virtual void Invalidate(); virtual void SizeContents(const gfx::Size& size); @@ -84,6 +85,9 @@ class TabContentsViewMac : public TabContentsView, // visible. scoped_nsobject<SadTabView> sad_tab_; + // The page content's intrinsic width. + int preferred_width_; + DISALLOW_COPY_AND_ASSIGN(TabContentsViewMac); }; diff --git a/chrome/browser/tab_contents/tab_contents_view_mac.mm b/chrome/browser/tab_contents/tab_contents_view_mac.mm index 662dd42..d0d814d4 100644 --- a/chrome/browser/tab_contents/tab_contents_view_mac.mm +++ b/chrome/browser/tab_contents/tab_contents_view_mac.mm @@ -12,6 +12,7 @@ #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/common/notification_type.h" #include "chrome/common/notification_service.h" +#include "chrome/common/render_messages.h" #include "chrome/common/temp_scaffolding_stubs.h" @@ -90,6 +91,13 @@ void TabContentsViewMac::StartDragging(const WebDropData& drop_data) { void TabContentsViewMac::OnContentsDestroy() { } +void TabContentsViewMac::RenderViewCreated(RenderViewHost* host) { + // We want updates whenever the intrinsic width of the webpage + // changes. Put the RenderView into that mode. + int routing_id = host->routing_id(); + host->Send(new ViewMsg_EnableIntrinsicWidthChangedMode(routing_id)); +} + void TabContentsViewMac::SetPageTitle(const std::wstring& title) { // Meaningless on the Mac; widgets don't have a "title" attribute } |