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

Unified Diff: chrome/browser/safe_browsing/client_side_detection_service.h

Issue 7583007: Add "enabled" state to the ClientSideDetectionService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/safe_browsing/client_side_detection_service.h
diff --git a/chrome/browser/safe_browsing/client_side_detection_service.h b/chrome/browser/safe_browsing/client_side_detection_service.h
index 864ab7677b06913e1c11b79cfebd5b5f8c2f46f4..98a1fe2229fc21f6feedfaf327b83b5360318de3 100644
--- a/chrome/browser/safe_browsing/client_side_detection_service.h
+++ b/chrome/browser/safe_browsing/client_side_detection_service.h
@@ -58,12 +58,23 @@ class ClientSideDetectionService : public URLFetcher::Delegate,
virtual ~ClientSideDetectionService();
- // Creates a client-side detection service and starts fetching the client-side
- // detection model if necessary. The caller takes ownership of the object.
- // This function may return NULL.
+ // Creates a client-side detection service. The service is initially
+ // disabled, use SetEnabled() to start it. The caller takes ownership of the
+ // object. This function may return NULL.
static ClientSideDetectionService* Create(
net::URLRequestContextGetter* request_context_getter);
+ // Enables or disables the service. This is usually called by the
+ // SafeBrowsingService, which tracks whether any profile uses these services
+ // at all. Disabling cancels any pending requests; existing
+ // ClientSideDetectionHosts will have their callbacks called with "false"
+ // verdicts. Enabling starts downloading the model after a delay.
+ void SetEnabled(bool enabled);
+
+ bool enabled() const {
+ return enabled_;
+ }
+
// From the URLFetcher::Delegate interface.
virtual void OnURLFetchComplete(const URLFetcher* source,
const GURL& url,
@@ -81,9 +92,9 @@ class ClientSideDetectionService : public URLFetcher::Delegate,
// The URL scheme of the |url()| in the request should be HTTP. This method
// takes ownership of the |verdict| as well as the |callback| and calls the
// the callback 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
+ // occurs during the fetch. If the service is disabled or 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. You may set |callback| to
// NULL if you don't care about the server verdict.
virtual void SendClientReportPhishingRequest(
@@ -139,6 +150,9 @@ class ClientSideDetectionService : public URLFetcher::Delegate,
// for download.
void StartFetchModel();
+ // Schedules the next fetch of the model.
+ virtual void ScheduleFetchModel(int64 delay_ms); // Virtual for testing.
+
// This method is called when we're done fetching the model either because
// we hit an error somewhere or because we're actually done fetch and
// validating the model.
@@ -148,6 +162,7 @@ class ClientSideDetectionService : public URLFetcher::Delegate,
friend class ClientSideDetectionServiceTest;
FRIEND_TEST_ALL_PREFIXES(ClientSideDetectionServiceTest, FetchModelTest);
FRIEND_TEST_ALL_PREFIXES(ClientSideDetectionServiceTest, SetBadSubnets);
+ FRIEND_TEST_ALL_PREFIXES(ClientSideDetectionServiceTest, SetEnabled);
FRIEND_TEST_ALL_PREFIXES(ClientSideDetectionServiceTest, IsBadIpAddress);
FRIEND_TEST_ALL_PREFIXES(ClientSideDetectionServiceTest,
ModelHasValidHashIds);
@@ -232,6 +247,10 @@ class ClientSideDetectionService : public URLFetcher::Delegate,
// valid hashes in the model.
static bool ModelHasValidHashIds(const ClientSideModel& model);
+ // Whether the service is running or not. When the service is not running,
+ // it won't download the model nor report detected phishing URLs.
+ bool enabled_;
+
std::string model_str_;
scoped_ptr<ClientSideModel> model_;
scoped_ptr<base::TimeDelta> model_max_age_;
« no previous file with comments | « chrome/browser/browser_process_impl.cc ('k') | chrome/browser/safe_browsing/client_side_detection_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698