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

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

Issue 7019013: Removal of dependencies on PlatformDevice classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Syncing merge conflicts. Created 9 years, 7 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/renderer/render_view.h" 10 #include "content/renderer/render_view.h"
11 #include "skia/ext/bitmap_platform_device.h"
12 #include "skia/ext/image_operations.h" 11 #include "skia/ext/image_operations.h"
13 #include "skia/ext/platform_canvas.h" 12 #include "skia/ext/platform_canvas.h"
14 #include "third_party/skia/include/core/SkBitmap.h" 13 #include "third_party/skia/include/core/SkBitmap.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h" 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h"
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
19 #include "ui/gfx/size.h" 18 #include "ui/gfx/size.h"
20 #include "webkit/glue/webkit_glue.h" 19 #include "webkit/glue/webkit_glue.h"
21 20
(...skipping 24 matching lines...) Expand all
46 } 45 }
47 WebSize old_size = view->size(); 46 WebSize old_size = view->size();
48 // TODO(noelutz): not only should we hide all scroll bars but we should also 47 // TODO(noelutz): not only should we hide all scroll bars but we should also
49 // make sure that all scroll-bars are at the top. 48 // make sure that all scroll-bars are at the top.
50 view->mainFrame()->setCanHaveScrollbars(false); // always hide scrollbars. 49 view->mainFrame()->setCanHaveScrollbars(false); // always hide scrollbars.
51 view->resize(view_size); 50 view->resize(view_size);
52 view->layout(); 51 view->layout();
53 view->paint(webkit_glue::ToWebCanvas(&canvas), 52 view->paint(webkit_glue::ToWebCanvas(&canvas),
54 WebRect(0, 0, view_size.width(), view_size.height())); 53 WebRect(0, 0, view_size.width(), view_size.height()));
55 54
56 skia::BitmapPlatformDevice& device = 55 SkDevice* device = skia::GetTopDevice(canvas);
57 static_cast<skia::BitmapPlatformDevice&>(canvas.getTopPlatformDevice());
58 56
59 // Now resize the thumbnail to the right size. Note: it is important that we 57 // Now resize the thumbnail to the right size. Note: it is important that we
60 // use this resize algorithm here. 58 // use this resize algorithm here.
61 const SkBitmap& bitmap = device.accessBitmap(false); 59 const SkBitmap& bitmap = device->accessBitmap(false);
62 SkBitmap thumbnail = skia::ImageOperations::Resize( 60 SkBitmap thumbnail = skia::ImageOperations::Resize(
63 bitmap, 61 bitmap,
64 skia::ImageOperations::RESIZE_LANCZOS3, 62 skia::ImageOperations::RESIZE_LANCZOS3,
65 thumbnail_size.width(), 63 thumbnail_size.width(),
66 thumbnail_size.height()); 64 thumbnail_size.height());
67 65
68 // Put things back as they were before. 66 // Put things back as they were before.
69 if (view->zoomLevel() != old_zoom_level) { 67 if (view->zoomLevel() != old_zoom_level) {
70 view->setZoomLevel(false, old_zoom_level); 68 view->setZoomLevel(false, old_zoom_level);
71 } 69 }
72 // Maybe re-display the scrollbars and resize the view to its old size. 70 // Maybe re-display the scrollbars and resize the view to its old size.
73 view->mainFrame()->setCanHaveScrollbars( 71 view->mainFrame()->setCanHaveScrollbars(
74 render_view->should_display_scrollbars(old_size.width, old_size.height)); 72 render_view->should_display_scrollbars(old_size.width, old_size.height));
75 view->resize(old_size); 73 view->resize(old_size);
76 74
77 UMA_HISTOGRAM_TIMES("SBClientPhishing.GrabPhishingThumbnail", 75 UMA_HISTOGRAM_TIMES("SBClientPhishing.GrabPhishingThumbnail",
78 base::TimeTicks::Now() - beginning_time); 76 base::TimeTicks::Now() - beginning_time);
79 return thumbnail; 77 return thumbnail;
80 } 78 }
81 79
82 } // namespace safe_browsing 80 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/renderer/print_web_view_helper_win.cc ('k') | content/browser/renderer_host/backing_store_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698