summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/render_widget_browsertest.h
diff options
context:
space:
mode:
authornoelutz@google.com <noelutz@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-27 00:11:20 +0000
committernoelutz@google.com <noelutz@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-27 00:11:20 +0000
commit7339cd25809e6fd5ec8a18a373daee7182034ba3 (patch)
treed5b061aba8710c862713101b0e119d2e5c8e36b5 /chrome/renderer/render_widget_browsertest.h
parenta8e4b5a8779bed7cb5afcfb7d28cf75486a0b110 (diff)
downloadchromium_src-7339cd25809e6fd5ec8a18a373daee7182034ba3.zip
chromium_src-7339cd25809e6fd5ec8a18a373daee7182034ba3.tar.gz
chromium_src-7339cd25809e6fd5ec8a18a373daee7182034ba3.tar.bz2
Client-side phishing detection: grab snapshot of custom sized view.
Client-side phishing detection needs to be able to take a snapshot of a particular page that has a constant size and aspect ratio (e.g., 1024x768). This CL adds a helper function (safe_browsing::GrabPhishingThumbnail) which re-sizes the view a given size, grabs the snapshot, and then re-sizes the view back to its previous size. Note: this function can be slow since it might re-layout the page twice. This function will only be called if we are very confident that the current page is a phishing site in which case we are OK with taking a slow snapshot. Also, this CL adds a test for the OnMsgPaintAtSize method in the RenderWidget since it does something very similar than the new Thumbnailer. BUG=None TEST=GrabPhishingThumbnail Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=60368 Review URL: http://codereview.chromium.org/3380001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63987 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/render_widget_browsertest.h')
-rw-r--r--chrome/renderer/render_widget_browsertest.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/chrome/renderer/render_widget_browsertest.h b/chrome/renderer/render_widget_browsertest.h
new file mode 100644
index 0000000..42ae02d
--- /dev/null
+++ b/chrome/renderer/render_widget_browsertest.h
@@ -0,0 +1,58 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_RENDERER_RENDER_WIDGET_BROWSERTEST_H_
+#define CHROME_RENDERER_RENDER_WIDGET_BROWSERTEST_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "base/file_path.h"
+#include "chrome/test/render_view_test.h"
+
+namespace gfx {
+class Size;
+}
+
+class SkBitmap;
+class TransportDIB;
+
+class RenderWidgetTest : public RenderViewTest {
+ public:
+ RenderWidgetTest();
+
+ protected:
+ static const int kNumBytesPerPixel;
+ static const int kLargeWidth;
+ static const int kLargeHeight;
+ static const int kSmallWidth;
+ static const int kSmallHeight;
+ static const int kTextPositionX;
+ static const int kTextPositionY;
+ static const uint32 kRedARGB;
+
+ // Helper function which calls OnMsgPaintAtSize and also paints the result
+ // in the given bitmap. The widget is resized to |page_size| before we paint
+ // and the final image is resized to |desired_size|. This method is virtual so
+ // that TestResizeAndPaint() can be reused by subclasses of this test class.
+ virtual void ResizeAndPaint(const gfx::Size& page_size,
+ const gfx::Size& desired_size,
+ SkBitmap* snapshot);
+
+ // Test for ResizeAndPaint.
+ void TestResizeAndPaint();
+
+ // Helper function which returns true if the given bitmap contains the given
+ // ARGB color and false otherwise.
+ bool ImageContainsColor(const SkBitmap& bitmap, uint32 argb_color);
+
+ // This can be used for debugging if you want to output a bitmap
+ // image to a file.
+ // FilePath tmp_path;
+ // file_util::CreateTemporaryFile(&tmp_path);
+ // OutputBitmapToFile(bitmap, tmp_path);
+ // LOG(INFO) << "Bitmap image stored at: " << tmp_path.value();
+ void OutputBitmapToFile(const SkBitmap& bitmap, const FilePath& file_path);
+};
+
+#endif // CHROME_RENDERER_RENDER_WIDGET_BROWSERTEST_H_