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

Side by Side Diff: chrome/renderer/safe_browsing/phishing_thumbnailer.cc

Issue 9416017: Optionally clear PlatformCanvas instances. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Address style issues. Created 8 years, 10 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/renderer/safe_browsing/phishing_thumbnailer.h" 5 #include "chrome/renderer/safe_browsing/phishing_thumbnailer.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "content/public/renderer/render_view.h" 10 #include "content/public/renderer/render_view.h"
(...skipping 15 matching lines...) Expand all
26 26
27 SkBitmap GrabPhishingThumbnail(content::RenderView* render_view, 27 SkBitmap GrabPhishingThumbnail(content::RenderView* render_view,
28 const gfx::Size& view_size, 28 const gfx::Size& view_size,
29 const gfx::Size& thumbnail_size) { 29 const gfx::Size& thumbnail_size) {
30 if (!render_view || !render_view->GetWebView()) { 30 if (!render_view || !render_view->GetWebView()) {
31 return SkBitmap(); // The WebView is going away. 31 return SkBitmap(); // The WebView is going away.
32 } 32 }
33 WebView* view = render_view->GetWebView(); 33 WebView* view = render_view->GetWebView();
34 base::TimeTicks beginning_time = base::TimeTicks::Now(); 34 base::TimeTicks beginning_time = base::TimeTicks::Now();
35 skia::PlatformCanvas canvas; 35 skia::PlatformCanvas canvas;
36 if (!canvas.initialize(view_size.width(), view_size.height(), true)) { 36 if (!canvas.initialize(view_size.width(), view_size.height(),
37 skia::PlatformDevice::FLAGS_OPAQUE)) {
37 return SkBitmap(); 38 return SkBitmap();
38 } 39 }
39 40
40 // Make sure we are not using any zoom when we take the snapshot. We will 41 // Make sure we are not using any zoom when we take the snapshot. We will
41 // restore the previous zoom level after the snapshot is taken. 42 // restore the previous zoom level after the snapshot is taken.
42 double old_zoom_level = view->zoomLevel(); 43 double old_zoom_level = view->zoomLevel();
43 if (view->zoomLevel() != 0.0) { 44 if (view->zoomLevel() != 0.0) {
44 view->setZoomLevel(false, 0.0); 45 view->setZoomLevel(false, 0.0);
45 } 46 }
46 WebSize old_size = view->size(); 47 WebSize old_size = view->size();
(...skipping 24 matching lines...) Expand all
71 view->mainFrame()->setCanHaveScrollbars( 72 view->mainFrame()->setCanHaveScrollbars(
72 render_view->ShouldDisplayScrollbars(old_size.width, old_size.height)); 73 render_view->ShouldDisplayScrollbars(old_size.width, old_size.height));
73 view->resize(old_size); 74 view->resize(old_size);
74 75
75 UMA_HISTOGRAM_TIMES("SBClientPhishing.GrabPhishingThumbnail", 76 UMA_HISTOGRAM_TIMES("SBClientPhishing.GrabPhishingThumbnail",
76 base::TimeTicks::Now() - beginning_time); 77 base::TimeTicks::Now() - beginning_time);
77 return thumbnail; 78 return thumbnail;
78 } 79 }
79 80
80 } // namespace safe_browsing 81 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698