summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authorsatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-21 09:19:52 +0000
committersatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-21 09:19:52 +0000
commitd54169e95756693bf243ba0d74e63b94b29f1bfc (patch)
tree0c32a98b7d8af8e274eb202c2cba2f1eda41bb0f /chrome/renderer
parent15ba3e1a737fb2c8260779424fcd94f79e9a42e3 (diff)
downloadchromium_src-d54169e95756693bf243ba0d74e63b94b29f1bfc.zip
chromium_src-d54169e95756693bf243ba0d74e63b94b29f1bfc.tar.gz
chromium_src-d54169e95756693bf243ba0d74e63b94b29f1bfc.tar.bz2
Generate thumbnails in the browser process.
The feature is now behind --enable-in-browser-thumbnailing flag. The in-browser thumbnailing works as follows: - The scroll offset is sent from the renderer to the browser. - The thumbnail is taken when the page info is sent from the renderer process. - Since thumbnails are generated in the browser, we can avoid the generation when unnecessary (ex. off-the-record mode, or New Tab Page). - The quality of thumbnails is as good as before, as the patch doesn't change timing heuristics. - The drawback is that we cannot take thumbnails from background tabs. New functions are added to ThumbnailGenerator for clipping thumbnails, with tests. BUG=65936 TEST=add unit tests for thumbnail_generator. confirmed that the thumbnails are updated with and without --enable-in-browser-thumbnailing Review URL: http://codereview.chromium.org/6246007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72115 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/render_view.cc13
-rw-r--r--chrome/renderer/render_view.h1
-rw-r--r--chrome/renderer/render_widget.cc6
-rw-r--r--chrome/renderer/render_widget.h4
4 files changed, 23 insertions, 1 deletions
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 151d927..c7df8bf 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -1227,7 +1227,13 @@ void RenderView::CapturePageInfo(int load_id, bool preliminary_capture) {
TranslateHelper::IsPageTranslatable(&document)));
}
- OnCaptureThumbnail();
+ // Generate the thumbnail here if the in-browser thumbnailing isn't
+ // enabled. TODO(satorux): Remove this and related code once
+ // crbug.com/65936 is complete.
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableInBrowserThumbnailing)) {
+ OnCaptureThumbnail();
+ }
if (phishing_delegate_.get())
phishing_delegate_->FinishedLoad(&contents);
@@ -5175,6 +5181,11 @@ webkit::ppapi::PluginInstance* RenderView::GetBitmapForOptimizedPluginPaint(
paint_bounds, dib, location, clip);
}
+gfx::Size RenderView::GetScrollOffset() {
+ WebKit::WebSize scroll_offset = webview()->mainFrame()->scrollOffset();
+ return gfx::Size(scroll_offset.width, scroll_offset.height);
+}
+
void RenderView::OnClearFocusedNode() {
if (webview())
webview()->clearFocusedNode();
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 2f4729a..fa357c4 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -665,6 +665,7 @@ class RenderView : public RenderWidget,
TransportDIB** dib,
gfx::Rect* location,
gfx::Rect* clip);
+ virtual gfx::Size GetScrollOffset();
virtual void DidHandleKeyEvent();
virtual void DidHandleMouseEvent(const WebKit::WebMouseEvent& event);
virtual void OnSetFocus(bool enable);
diff --git a/chrome/renderer/render_widget.cc b/chrome/renderer/render_widget.cc
index 7fb9e4a..ba01020 100644
--- a/chrome/renderer/render_widget.cc
+++ b/chrome/renderer/render_widget.cc
@@ -585,6 +585,7 @@ void RenderWidget::DoDeferredUpdate() {
params.resizer_rect = resizer_rect_;
params.plugin_window_moves.swap(plugin_window_moves_);
params.flags = next_paint_flags_;
+ params.scroll_offset = GetScrollOffset();
update_reply_pending_ = true;
Send(new ViewHostMsg_UpdateRect(routing_id_, params));
@@ -920,6 +921,11 @@ webkit::ppapi::PluginInstance* RenderWidget::GetBitmapForOptimizedPluginPaint(
return NULL;
}
+gfx::Size RenderWidget::GetScrollOffset() {
+ // Bare RenderWidgets don't support scroll offset.
+ return gfx::Size(0, 0);
+}
+
void RenderWidget::SetHidden(bool hidden) {
if (is_hidden_ == hidden)
return;
diff --git a/chrome/renderer/render_widget.h b/chrome/renderer/render_widget.h
index 33d0205..71a065e 100644
--- a/chrome/renderer/render_widget.h
+++ b/chrome/renderer/render_widget.h
@@ -219,6 +219,10 @@ class RenderWidget : public IPC::Channel::Listener,
gfx::Rect* location,
gfx::Rect* clip);
+ // Gets the scroll offset of this widget, if this widget has a notion of
+ // scroll offset.
+ virtual gfx::Size GetScrollOffset();
+
// Sets the "hidden" state of this widget. All accesses to is_hidden_ should
// use this method so that we can properly inform the RenderThread of our
// state.