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

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

Issue 12746009: Revert 189969 "Add RenderWidgetHost::GetSnapshotFromRenderer met..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1450/src/
Patch Set: Created 7 years, 9 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/render_widget_snapshot_taker.h" 9 #include "chrome/browser/thumbnails/render_widget_snapshot_taker.h"
10 #include "chrome/browser/thumbnails/thumbnail_service.h" 10 #include "chrome/browser/thumbnails/thumbnail_service.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 ThumbnailingAlgorithm* algorithm, 66 ThumbnailingAlgorithm* algorithm,
67 bool succeeded, 67 bool succeeded,
68 const SkBitmap& bitmap) { 68 const SkBitmap& bitmap) {
69 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 69 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
70 if (!succeeded) 70 if (!succeeded)
71 return; 71 return;
72 72
73 algorithm->ProcessBitmap(context, base::Bind(&UpdateThumbnail), bitmap); 73 algorithm->ProcessBitmap(context, base::Bind(&UpdateThumbnail), bitmap);
74 } 74 }
75 75
76 void GotSnapshotFromRenderer(base::Callback<void(const SkBitmap&)> callback,
77 bool success,
78 const SkBitmap& bitmap) {
79 if (success)
80 callback.Run(bitmap);
81 }
82
83 void AsyncProcessThumbnail(content::WebContents* web_contents, 76 void AsyncProcessThumbnail(content::WebContents* web_contents,
84 scoped_refptr<ThumbnailingContext> context, 77 scoped_refptr<ThumbnailingContext> context,
85 scoped_refptr<ThumbnailingAlgorithm> algorithm) { 78 scoped_refptr<ThumbnailingAlgorithm> algorithm) {
86 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 79 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
87 RenderWidgetHost* render_widget_host = web_contents->GetRenderViewHost(); 80 RenderWidgetHost* render_widget_host = web_contents->GetRenderViewHost();
88 content::RenderWidgetHostView* view = render_widget_host->GetView(); 81 content::RenderWidgetHostView* view = render_widget_host->GetView();
89 if (!view) 82 if (!view)
90 return; 83 return;
91 if (!view->IsSurfaceAvailableForCopy()) { 84 if (!view->IsSurfaceAvailableForCopy()) {
92 // On Windows XP and possibly due to driver issues, neither the backing 85 #if defined(OS_WIN)
93 // store nor the compositing surface is available in the browser when 86 // On Windows XP, neither the backing store nor the compositing surface is
94 // accelerated compositing is active, so ask the renderer to send a snapshot 87 // available in the browser when accelerated compositing is active, so ask
95 // for creating the thumbnail. 88 // the renderer to send a snapshot for creating the thumbnail.
96 render_widget_host->GetSnapshotFromRenderer( 89 if (base::win::GetVersion() < base::win::VERSION_VISTA) {
97 gfx::Rect(), 90 gfx::Size view_size =
98 base::Bind(GotSnapshotFromRenderer, base::Bind( 91 render_widget_host->GetView()->GetViewBounds().size();
99 &ThumbnailingAlgorithm::ProcessBitmap, 92 g_browser_process->GetRenderWidgetSnapshotTaker()->AskForSnapshot(
100 algorithm, context, base::Bind(&UpdateThumbnail)))); 93 render_widget_host,
94 base::Bind(&ThumbnailingAlgorithm::ProcessBitmap,
95 algorithm, context, base::Bind(&UpdateThumbnail)),
96 view_size,
97 view_size);
98 }
99 #endif
101 return; 100 return;
102 } 101 }
103 102
104 gfx::Rect copy_rect = gfx::Rect(view->GetViewBounds().size()); 103 gfx::Rect copy_rect = gfx::Rect(view->GetViewBounds().size());
105 // Clip the pixels that will commonly hold a scrollbar, which looks bad in 104 // Clip the pixels that will commonly hold a scrollbar, which looks bad in
106 // thumbnails. 105 // thumbnails.
107 int scrollbar_size = gfx::scrollbar_size(); 106 int scrollbar_size = gfx::scrollbar_size();
108 gfx::Size copy_size; 107 gfx::Size copy_size;
109 copy_rect.Inset(0, 0, scrollbar_size, scrollbar_size); 108 copy_rect.Inset(0, 0, scrollbar_size, scrollbar_size);
110 109
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 content::Source<RenderWidgetHost>(renderer)); 236 content::Source<RenderWidgetHost>(renderer));
238 } 237 }
239 } 238 }
240 239
241 void ThumbnailTabHelper::WidgetHidden(RenderWidgetHost* widget) { 240 void ThumbnailTabHelper::WidgetHidden(RenderWidgetHost* widget) {
242 if (!enabled_) 241 if (!enabled_)
243 return; 242 return;
244 UpdateThumbnailIfNecessary(web_contents()); 243 UpdateThumbnailIfNecessary(web_contents());
245 } 244 }
246 245
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/tabs/tabs_api.cc ('k') | chrome/browser/ui/browser_tab_contents.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698