summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/cocoa/browser_window_controller.mm5
-rw-r--r--chrome/browser/extensions/extension_host.cc2
-rw-r--r--chrome/browser/extensions/extension_host.h2
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc7
-rw-r--r--chrome/browser/renderer_host/render_view_host.h2
-rw-r--r--chrome/browser/renderer_host/render_view_host_delegate.h6
-rw-r--r--chrome/browser/tab_contents/interstitial_page.cc5
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc2
-rw-r--r--chrome/browser/tab_contents/tab_contents_view.cc11
-rw-r--r--chrome/browser/tab_contents/tab_contents_view.h14
-rw-r--r--chrome/browser/tab_contents/tab_contents_view_mac.h4
-rw-r--r--chrome/browser/tab_contents/tab_contents_view_mac.mm8
12 files changed, 55 insertions, 13 deletions
diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm
index 0f6ef71..3dba768 100644
--- a/chrome/browser/cocoa/browser_window_controller.mm
+++ b/chrome/browser/cocoa/browser_window_controller.mm
@@ -213,8 +213,6 @@ willPositionSheet:(NSWindow *)sheet
// regardless.
- (NSRect)windowWillUseStandardFrame:(NSWindow*)window
defaultFrame:(NSRect)frame {
-#if 0
-// TODO(pinkerton): this is part of another CL which is out for review.
const int kMinimumIntrinsicWidth = 700;
const int kScrollbarWidth = 16;
const int kSpaceForIcons = 50;
@@ -224,12 +222,11 @@ willPositionSheet:(NSWindow *)sheet
TabContents* contents = browser_->tabstrip_model()->GetSelectedTabContents();
if (contents) {
- int intrinsicWidth = contents->preferred_width() + kScrollbarWidth;
+ int intrinsicWidth = contents->view()->preferred_width() + kScrollbarWidth;
int tempWidth = std::max(intrinsicWidth, kMinimumIntrinsicWidth);
frame.size.width = std::min(tempWidth, kMaxWidth);
frame.size.height = screenSize.height;
}
-#endif
return frame;
}
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc
index 5f91ba1..e2f202a 100644
--- a/chrome/browser/extensions/extension_host.cc
+++ b/chrome/browser/extensions/extension_host.cc
@@ -49,7 +49,7 @@ void ExtensionHost::CreateRenderView(const GURL& url,
render_view_host_->NavigateToURL(url);
}
-void ExtensionHost::DidContentsPreferredWidthChange(const int pref_width) {
+void ExtensionHost::UpdatePreferredWidth(int pref_width) {
if (view_)
view_->DidContentsPreferredWidthChange(pref_width);
}
diff --git a/chrome/browser/extensions/extension_host.h b/chrome/browser/extensions/extension_host.h
index 8c5a8cd..d8e9a50 100644
--- a/chrome/browser/extensions/extension_host.h
+++ b/chrome/browser/extensions/extension_host.h
@@ -43,7 +43,6 @@ class ExtensionHost : public RenderViewHostDelegate,
// TODO(mpcomplete): GetProfile is unused.
virtual Profile* GetProfile() const { return NULL; }
virtual const GURL& GetURL() const { return url_; }
- virtual void DidContentsPreferredWidthChange(const int pref_width);
virtual WebPreferences GetWebkitPrefs();
virtual void RunJavaScriptMessage(
const std::wstring& message,
@@ -73,6 +72,7 @@ class ExtensionHost : public RenderViewHostDelegate,
virtual void UpdateDragCursor(bool is_drop_target);
virtual void TakeFocus(bool reverse);
virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event);
+ virtual void UpdatePreferredWidth(int pref_width);
private:
// ExtensionFunctionDispatcher::Delegate
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index 0f3141f..09737bb 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -1081,8 +1081,11 @@ void RenderViewHost::OnMsgOpenURL(const GURL& url,
delegate_->RequestOpenURL(validated_url, referrer, disposition);
}
-void RenderViewHost::OnMsgDidContentsPreferredWidthChange(const int pref_width) {
- delegate_->DidContentsPreferredWidthChange(pref_width);
+void RenderViewHost::OnMsgDidContentsPreferredWidthChange(int pref_width) {
+ RenderViewHostDelegate::View* view = delegate_->GetViewDelegate();
+ if (!view)
+ return;
+ view->UpdatePreferredWidth(pref_width);
}
void RenderViewHost::OnMsgDomOperationResponse(
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index 25ff89b..4421aab 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -482,7 +482,7 @@ class RenderViewHost : public RenderWidgetHost {
void OnMsgContextMenu(const ContextMenuParams& params);
void OnMsgOpenURL(const GURL& url, const GURL& referrer,
WindowOpenDisposition disposition);
- void OnMsgDidContentsPreferredWidthChange(const int pref_width);
+ void OnMsgDidContentsPreferredWidthChange(int pref_width);
void OnMsgDomOperationResponse(const std::string& json_string,
int automation_id);
void OnMsgDOMUISend(const std::string& message,
diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h
index 88ba027..14c1337 100644
--- a/chrome/browser/renderer_host/render_view_host_delegate.h
+++ b/chrome/browser/renderer_host/render_view_host_delegate.h
@@ -117,6 +117,9 @@ class RenderViewHostDelegate {
// specified events. This gives an opportunity to the browser to process the
// event (used for keyboard shortcuts).
virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) = 0;
+
+ // The content's intrinsic width (prefWidth) changed.
+ virtual void UpdatePreferredWidth(int pref_width) = 0;
};
// Interface for saving web pages.
@@ -253,9 +256,6 @@ class RenderViewHostDelegate {
bool errored,
const SkBitmap& image) { }
- // The content's intrinsic width (prefWidth) changed.
- virtual void DidContentsPreferredWidthChange(const int pref_width) { }
-
// The page wants to open a URL with the specified disposition.
virtual void RequestOpenURL(const GURL& url,
const GURL& referrer,
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
}