Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(676)

Side by Side Diff: chrome/browser/thumbnails/thumbnail_tab_helper.cc

Issue 259523008: Remove RenderWidgetHost::GetSnapshotFromRenderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: getsnapshotfromrenderer: rm Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/thumbnails/thumbnail_tab_helper.h" 5 #include "chrome/browser/thumbnails/thumbnail_tab_helper.h"
6 6
7 #include "chrome/browser/browser_process.h" 7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/thumbnails/thumbnail_service.h" 9 #include "chrome/browser/thumbnails/thumbnail_service.h"
10 #include "chrome/browser/thumbnails/thumbnail_service_factory.h" 10 #include "chrome/browser/thumbnails/thumbnail_service_factory.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 if (!succeeded) 68 if (!succeeded)
69 return; 69 return;
70 70
71 // On success, we must be on the UI thread (on failure because of shutdown we 71 // On success, we must be on the UI thread (on failure because of shutdown we
72 // are not on the UI thread). 72 // are not on the UI thread).
73 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 73 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
74 74
75 algorithm->ProcessBitmap(context, base::Bind(&UpdateThumbnail), bitmap); 75 algorithm->ProcessBitmap(context, base::Bind(&UpdateThumbnail), bitmap);
76 } 76 }
77 77
78 void GotSnapshotFromRenderer(base::Callback<void(const SkBitmap&)> callback,
79 bool success,
80 const SkBitmap& bitmap) {
81 if (success)
82 callback.Run(bitmap);
83 }
84
85 void AsyncProcessThumbnail(content::WebContents* web_contents, 78 void AsyncProcessThumbnail(content::WebContents* web_contents,
86 scoped_refptr<ThumbnailingContext> context, 79 scoped_refptr<ThumbnailingContext> context,
87 scoped_refptr<ThumbnailingAlgorithm> algorithm) { 80 scoped_refptr<ThumbnailingAlgorithm> algorithm) {
88 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 81 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
89 RenderWidgetHost* render_widget_host = web_contents->GetRenderViewHost(); 82 RenderWidgetHost* render_widget_host = web_contents->GetRenderViewHost();
90 content::RenderWidgetHostView* view = render_widget_host->GetView(); 83 content::RenderWidgetHostView* view = render_widget_host->GetView();
91 if (!view) 84 if (!view)
92 return; 85 return;
93 if (!view->IsSurfaceAvailableForCopy()) { 86 if (!view->IsSurfaceAvailableForCopy())
94 // On Windows XP and possibly due to driver issues, neither the backing
95 // store nor the compositing surface is available in the browser when
96 // accelerated compositing is active, so ask the renderer to send a snapshot
97 // for creating the thumbnail.
98 render_widget_host->GetSnapshotFromRenderer(
99 gfx::Rect(),
100 base::Bind(GotSnapshotFromRenderer, base::Bind(
101 &ThumbnailingAlgorithm::ProcessBitmap,
102 algorithm, context, base::Bind(&UpdateThumbnail))));
103 return; 87 return;
104 }
105 88
106 gfx::Rect copy_rect = gfx::Rect(view->GetViewBounds().size()); 89 gfx::Rect copy_rect = gfx::Rect(view->GetViewBounds().size());
107 // Clip the pixels that will commonly hold a scrollbar, which looks bad in 90 // Clip the pixels that will commonly hold a scrollbar, which looks bad in
108 // thumbnails. 91 // thumbnails.
109 int scrollbar_size = gfx::scrollbar_size(); 92 int scrollbar_size = gfx::scrollbar_size();
110 gfx::Size copy_size; 93 gfx::Size copy_size;
111 copy_rect.Inset(0, 0, scrollbar_size, scrollbar_size); 94 copy_rect.Inset(0, 0, scrollbar_size, scrollbar_size);
112 95
113 if (copy_rect.IsEmpty()) 96 if (copy_rect.IsEmpty())
114 return; 97 return;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED, 216 content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED,
234 content::Source<RenderWidgetHost>(renderer)); 217 content::Source<RenderWidgetHost>(renderer));
235 } 218 }
236 } 219 }
237 220
238 void ThumbnailTabHelper::WidgetHidden(RenderWidgetHost* widget) { 221 void ThumbnailTabHelper::WidgetHidden(RenderWidgetHost* widget) {
239 if (!enabled_) 222 if (!enabled_)
240 return; 223 return;
241 UpdateThumbnailIfNecessary(web_contents()); 224 UpdateThumbnailIfNecessary(web_contents());
242 } 225 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/capture_web_contents_function.cc ('k') | chrome/browser/ui/pdf/pdf_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698