summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rwxr-xr-xchrome/browser/extensions/extension_view.cc34
-rwxr-xr-xchrome/browser/extensions/extension_view.h3
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc6
-rw-r--r--chrome/browser/renderer_host/render_view_host.h1
-rw-r--r--chrome/browser/renderer_host/render_view_host_delegate.h3
-rw-r--r--chrome/common/render_messages_internal.h3
-rw-r--r--chrome/common/temp_scaffolding_stubs.h5
-rw-r--r--chrome/renderer/render_view.cc13
-rw-r--r--chrome/renderer/render_view.h3
9 files changed, 69 insertions, 2 deletions
diff --git a/chrome/browser/extensions/extension_view.cc b/chrome/browser/extensions/extension_view.cc
index a9b3ed0..11c33cf 100755
--- a/chrome/browser/extensions/extension_view.cc
+++ b/chrome/browser/extensions/extension_view.cc
@@ -19,8 +19,38 @@ ExtensionView::ExtensionView(Extension* extension,
: HWNDHtmlView(url, this, false),
extension_(extension),
profile_(profile) {
- // TODO(mpcomplete): query this from the renderer somehow?
- set_preferred_size(gfx::Size(100, 100));
+ // Set the width initially to 0, so that the WebCore::Document can
+ // correctly compute the minPrefWidth which is returned in
+ // DidContentsChangeSize()
+ set_preferred_size(gfx::Size(0, 100));
+ SetVisible(false);
+}
+
+void ExtensionView::DidStopLoading(RenderViewHost* render_view_host,
+ int32 page_id) {
+ SetVisible(true);
+ render_view_host->WasResized();
+}
+
+void ExtensionView::DidContentsPreferredWidthChange(const int pref_width) {
+ if (pref_width > 0) {
+ // SchedulePaint first because new_width may be smaller and we want
+ // the Parent to paint the vacated space.
+ SchedulePaint();
+ set_preferred_size(gfx::Size(pref_width, 100));
+ SizeToPreferredSize();
+
+ // TODO(rafaelw): This assumes that the extension view is a child of an
+ // ExtensionToolstrip, which is a child of the BookmarkBarView. There should
+ // be a way to do this where the ExtensionView doesn't have to know it's
+ // containment hierarchy.
+ if (GetParent() != NULL && GetParent()->GetParent() != NULL) {
+ GetParent()->GetParent()->Layout();
+ }
+
+ SchedulePaint();
+ render_view_host()->WasResized();
+ }
}
void ExtensionView::CreatingRenderer() {
diff --git a/chrome/browser/extensions/extension_view.h b/chrome/browser/extensions/extension_view.h
index e82c918..960a294 100755
--- a/chrome/browser/extensions/extension_view.h
+++ b/chrome/browser/extensions/extension_view.h
@@ -33,6 +33,9 @@ class ExtensionView : public HWNDHtmlView,
// RenderViewHostDelegate
virtual Profile* GetProfile() const { return profile_; }
virtual void RenderViewCreated(RenderViewHost* render_view_host);
+ virtual void DidContentsPreferredWidthChange(const int pref_width);
+ virtual void DidStopLoading(RenderViewHost* render_view_host,
+ int32 page_id);
virtual WebPreferences GetWebkitPrefs();
virtual void RunJavaScriptMessage(
const std::wstring& message,
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index 76bc612..271df03 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -712,6 +712,8 @@ void RenderViewHost::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(ViewHostMsg_DidDownloadImage, OnMsgDidDownloadImage)
IPC_MESSAGE_HANDLER(ViewHostMsg_ContextMenu, OnMsgContextMenu)
IPC_MESSAGE_HANDLER(ViewHostMsg_OpenURL, OnMsgOpenURL)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_DidContentsPreferredWidthChange,
+ OnMsgDidContentsPreferredWidthChange)
IPC_MESSAGE_HANDLER(ViewHostMsg_DomOperationResponse,
OnMsgDomOperationResponse)
IPC_MESSAGE_HANDLER(ViewHostMsg_DOMUISend,
@@ -1053,6 +1055,10 @@ 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::OnMsgDomOperationResponse(
const std::string& json_string, int automation_id) {
delegate_->DomOperationResponse(json_string, automation_id);
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index f7a63a5..68fe3c2 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -493,6 +493,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 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 fc7c8c4..63c01e6 100644
--- a/chrome/browser/renderer_host/render_view_host_delegate.h
+++ b/chrome/browser/renderer_host/render_view_host_delegate.h
@@ -245,6 +245,9 @@ 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/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index ece0cd1..576b659 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -832,6 +832,9 @@ IPC_BEGIN_MESSAGES(ViewHost)
GURL /* referrer */,
WindowOpenDisposition /* disposition */)
+ IPC_MESSAGE_ROUTED1(ViewHostMsg_DidContentsPreferredWidthChange,
+ int /* pref_width */)
+
// Following message is used to communicate the values received by the
// callback binding the JS to Cpp.
// An instance of browser that has an automation host listening to it can
diff --git a/chrome/common/temp_scaffolding_stubs.h b/chrome/common/temp_scaffolding_stubs.h
index 8085896..ede9a18 100644
--- a/chrome/common/temp_scaffolding_stubs.h
+++ b/chrome/common/temp_scaffolding_stubs.h
@@ -639,6 +639,11 @@ class HWNDHtmlView {
RenderViewHost* render_view_host() { NOTIMPLEMENTED(); return NULL; }
void InitHidden() { NOTIMPLEMENTED(); }
void set_preferred_size(const gfx::Size& size) { NOTIMPLEMENTED(); }
+ virtual void SetVisible(bool flag) { NOTIMPLEMENTED(); }
+ void SizeToPreferredSize() { NOTIMPLEMENTED(); }
+ HWNDHtmlView* GetParent() const { NOTIMPLEMENTED(); return NULL; }
+ void Layout() { NOTIMPLEMENTED(); }
+ void SchedulePaint() { NOTIMPLEMENTED(); }
};
#endif // CHROME_COMMON_TEMP_SCAFFOLDING_STUBS_H_
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 91d93119..ee218a3 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -1944,6 +1944,19 @@ void RenderView::OpenURL(WebView* webview, const GURL& url,
Send(new ViewHostMsg_OpenURL(routing_id_, url, referrer, disposition));
}
+void RenderView::DidContentsSizeChange(WebWidget* webwidget,
+ int new_width,
+ int new_height) {
+ // TODO(rafaelw): This is a temporary solution. Only the ExtensionView wants
+ // this notification at the moment. It isn't clean to test for ExtensionView
+ // by examining the enabled_bindings. This needs to be generalized as it
+ // becomes clear what extension toolbars need.
+ if (BindingsPolicy::is_extension_enabled(enabled_bindings_)) {
+ int width = webview()->GetMainFrame()->GetContentsPreferredWidth();
+ Send(new ViewHostMsg_DidContentsPreferredWidthChange(routing_id_, width));
+ }
+}
+
// We are supposed to get a single call to Show for a newly created RenderView
// that was created via RenderView::CreateWebView. So, we wait until this
// point to dispatch the ShowView message.
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index a272a3f..b0568b1 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -207,6 +207,9 @@ class RenderView : public RenderWidget,
WebFrame* frame,
bool is_new_navigation);
virtual void DidReceiveIconForFrame(WebView* webview, WebFrame* frame);
+ virtual void DidContentsSizeChange(WebWidget* webwidget,
+ int new_width,
+ int new_height);
virtual void WillPerformClientRedirect(WebView* webview,
WebFrame* frame,