diff options
author | bryner@chromium.org <bryner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-14 22:38:02 +0000 |
---|---|---|
committer | bryner@chromium.org <bryner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-14 22:38:02 +0000 |
commit | 9818134c9394a0e50da66b91873deb8491a0e40e (patch) | |
tree | ae7b4477dff47062f98a1e67ab048f94dcf4d87d | |
parent | 463194fe1a2940ab8c2d9a117d3bcccb5af0436d (diff) | |
download | chromium_src-9818134c9394a0e50da66b91873deb8491a0e40e.zip chromium_src-9818134c9394a0e50da66b91873deb8491a0e40e.tar.gz chromium_src-9818134c9394a0e50da66b91873deb8491a0e40e.tar.bz2 |
Remove thumbnails from the ClientSideDetectionService.
BUG=none
TEST=ClientSideDetectionServiceTest
Review URL: http://codereview.chromium.org/6277002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71503 0039d316-1c4b-4281-b951-d872f2087c98
4 files changed, 11 insertions, 49 deletions
diff --git a/chrome/browser/safe_browsing/client_side_detection_service.cc b/chrome/browser/safe_browsing/client_side_detection_service.cc index 5b2da22..0c29e3e 100644 --- a/chrome/browser/safe_browsing/client_side_detection_service.cc +++ b/chrome/browser/safe_browsing/client_side_detection_service.cc @@ -10,7 +10,6 @@ #include "base/logging.h" #include "base/message_loop.h" #include "base/platform_file.h" -#include "base/ref_counted_memory.h" #include "base/scoped_ptr.h" #include "base/stl_util-inl.h" #include "base/task.h" @@ -19,11 +18,9 @@ #include "chrome/common/net/http_return.h" #include "chrome/common/net/url_fetcher.h" #include "chrome/common/net/url_request_context_getter.h" -#include "gfx/codec/png_codec.h" #include "googleurl/src/gurl.h" #include "net/base/load_flags.h" #include "net/url_request/url_request_status.h" -#include "third_party/skia/include/core/SkBitmap.h" namespace safe_browsing { @@ -92,14 +89,13 @@ void ClientSideDetectionService::GetModelFile(OpenModelDoneCallback* callback) { void ClientSideDetectionService::SendClientReportPhishingRequest( const GURL& phishing_url, double score, - SkBitmap thumbnail, ClientReportPhishingRequestCallback* callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); MessageLoop::current()->PostTask( FROM_HERE, method_factory_.NewRunnableMethod( &ClientSideDetectionService::StartClientReportPhishingRequest, - phishing_url, score, thumbnail, callback)); + phishing_url, score, callback)); } void ClientSideDetectionService::OnURLFetchComplete( @@ -226,26 +222,13 @@ void ClientSideDetectionService::StartGetModelFile( void ClientSideDetectionService::StartClientReportPhishingRequest( const GURL& phishing_url, double score, - SkBitmap thumbnail, ClientReportPhishingRequestCallback* callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); scoped_ptr<ClientReportPhishingRequestCallback> cb(callback); - // The server expects an encoded PNG image. - scoped_refptr<RefCountedBytes> thumbnail_data(new RefCountedBytes); - SkAutoLockPixels lock(thumbnail); - if (!thumbnail.readyToDraw() || - !gfx::PNGCodec::EncodeBGRASkBitmap(thumbnail, - true /* discard_transparency */, - &thumbnail_data->data)) { - cb->Run(phishing_url, false); - return; - } ClientPhishingRequest request; request.set_url(phishing_url.spec()); request.set_client_score(static_cast<float>(score)); - request.set_snapshot(reinterpret_cast<const char*>(thumbnail_data->front()), - thumbnail_data->size()); std::string request_data; if (!request.SerializeToString(&request_data)) { // For consistency, we always call the callback asynchronously, rather than diff --git a/chrome/browser/safe_browsing/client_side_detection_service.h b/chrome/browser/safe_browsing/client_side_detection_service.h index 7e048e5..af0a2d9 100644 --- a/chrome/browser/safe_browsing/client_side_detection_service.h +++ b/chrome/browser/safe_browsing/client_side_detection_service.h @@ -33,7 +33,6 @@ #include "chrome/common/net/url_fetcher.h" #include "googleurl/src/gurl.h" -class SkBitmap; class URLRequestContextGetter; namespace net { @@ -75,17 +74,15 @@ class ClientSideDetectionService : public URLFetcher::Delegate { void GetModelFile(OpenModelDoneCallback* callback); // Sends a request to the SafeBrowsing servers with the potentially phishing - // URL, the client-side phishing score, and a low resolution thumbnail. The - // |phishing_url| scheme should be HTTP. This method takes ownership of the - // |callback| and calls it once the result has come back from the server or - // if an error occurs during the fetch. If an error occurs the phishing - // verdict will always be false. The callback is always called after - // SendClientReportPhishingRequest() returns and on the same thread as - // SendClientReportPhishingRequest() was called. + // URL and the client-side phishing score. The |phishing_url| scheme should + // be HTTP. This method takes ownership of the |callback| and calls it once + // the result has come back from the server or if an error occurs during the + // fetch. If an error occurs the phishing verdict will always be false. The + // callback is always called after SendClientReportPhishingRequest() returns + // and on the same thread as SendClientReportPhishingRequest() was called. void SendClientReportPhishingRequest( const GURL& phishing_url, double score, - SkBitmap thumbnail, ClientReportPhishingRequestCallback* callback); private: @@ -142,7 +139,6 @@ class ClientSideDetectionService : public URLFetcher::Delegate { void StartClientReportPhishingRequest( const GURL& phishing_url, double score, - SkBitmap thumbnail, ClientReportPhishingRequestCallback* callback); // Starts getting the model file. diff --git a/chrome/browser/safe_browsing/client_side_detection_service_unittest.cc b/chrome/browser/safe_browsing/client_side_detection_service_unittest.cc index ca3cdc5..d39c99f 100644 --- a/chrome/browser/safe_browsing/client_side_detection_service_unittest.cc +++ b/chrome/browser/safe_browsing/client_side_detection_service_unittest.cc @@ -23,7 +23,6 @@ #include "chrome/common/net/url_fetcher.h" #include "googleurl/src/gurl.h" #include "net/url_request/url_request_status.h" -#include "third_party/skia/include/core/SkBitmap.h" namespace safe_browsing { @@ -63,12 +62,10 @@ class ClientSideDetectionServiceTest : public testing::Test { } bool SendClientReportPhishingRequest(const GURL& phishing_url, - double score, - SkBitmap thumbnail) { + double score) { csd_service_->SendClientReportPhishingRequest( phishing_url, score, - thumbnail, NewCallback(this, &ClientSideDetectionServiceTest::SendRequestDone)); phishing_url_ = phishing_url; msg_loop_.Run(); // Waits until callback is called. @@ -166,33 +163,23 @@ TEST_F(ClientSideDetectionServiceTest, SendClientReportPhishingRequest) { csd_service_.reset(ClientSideDetectionService::Create( tmp_dir.path().AppendASCII("model"), NULL)); - // Invalid thumbnail. - SkBitmap thumbnail; GURL url("http://a.com/"); double score = 0.4; // Some random client score. - EXPECT_FALSE(SendClientReportPhishingRequest(url, score, thumbnail)); - - // Valid thumbnail but the server returns an error. - thumbnail.setConfig(SkBitmap::kARGB_8888_Config, 100, 100); - ASSERT_TRUE(thumbnail.allocPixels()); - thumbnail.eraseRGB(255, 0, 0); - SetClientReportPhishingResponse("", false /* fail */); - EXPECT_FALSE(SendClientReportPhishingRequest(url, score, thumbnail)); // Invalid response body from the server. SetClientReportPhishingResponse("invalid proto response", true /* success */); - EXPECT_FALSE(SendClientReportPhishingRequest(url, score, thumbnail)); + EXPECT_FALSE(SendClientReportPhishingRequest(url, score)); // Normal behavior. ClientPhishingResponse response; response.set_phishy(true); SetClientReportPhishingResponse(response.SerializeAsString(), true /* success */); - EXPECT_TRUE(SendClientReportPhishingRequest(url, score, thumbnail)); + EXPECT_TRUE(SendClientReportPhishingRequest(url, score)); response.set_phishy(false); SetClientReportPhishingResponse(response.SerializeAsString(), true /* success */); - EXPECT_FALSE(SendClientReportPhishingRequest(url, score, thumbnail)); + EXPECT_FALSE(SendClientReportPhishingRequest(url, score)); } } // namespace safe_browsing diff --git a/chrome/browser/safe_browsing/csd.proto b/chrome/browser/safe_browsing/csd.proto index 6fcc544..fc01f96 100644 --- a/chrome/browser/safe_browsing/csd.proto +++ b/chrome/browser/safe_browsing/csd.proto @@ -23,10 +23,6 @@ message ClientPhishingRequest { // Score that was computed on the client. Value is between 0.0 and 1.0. // The larger the value the more likely the url is phishing. required float client_score = 2; - - // Thumbnail from the client. Supports all typical image formats (png, jpg - // etc.). - required bytes snapshot = 3; } message ClientPhishingResponse { |