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

Unified Diff: chrome/browser/safe_browsing/safe_browsing_service.cc

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/safe_browsing_service.cc
diff --git a/chrome/browser/safe_browsing/safe_browsing_service.cc b/chrome/browser/safe_browsing/safe_browsing_service.cc
index cac584c5a29534107b6cd36011a7a0750ba3c38f..c8f1851d26bb6332e1d102ab06438361475e0122 100644
--- a/chrome/browser/safe_browsing/safe_browsing_service.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_service.cc
@@ -17,6 +17,7 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/safe_browsing/client_side_detection_service.h"
#include "chrome/browser/safe_browsing/malware_details.h"
#include "chrome/browser/safe_browsing/protocol_manager.h"
#include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h"
@@ -165,6 +166,25 @@ SafeBrowsingService::SafeBrowsingService()
closing_database_(false),
download_urlcheck_timeout_ms_(kDownloadUrlCheckTimeoutMs),
download_hashcheck_timeout_ms_(kDownloadHashCheckTimeoutMs) {
+#if !defined(OS_CHROMEOS)
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kDisableClientSidePhishingDetection) &&
+ CanReportStats()) {
+ csd_service_.reset(
+ safe_browsing::ClientSideDetectionService::Create(
+ g_browser_process->system_request_context()));
+ }
+#endif
+}
+
+SafeBrowsingService::~SafeBrowsingService() {
+ // Deletes the PrefChangeRegistrars, whose dtors also unregister |this| as an
+ // observer of the preferences.
+ STLDeleteValues(&prefs_map_);
+
+ // We should have already been shut down. If we're still enabled, then the
+ // database isn't going to be closed properly, which could lead to corruption.
+ DCHECK(!enabled_);
}
void SafeBrowsingService::Initialize() {
@@ -189,9 +209,11 @@ void SafeBrowsingService::Initialize() {
}
void SafeBrowsingService::ShutDown() {
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- NewRunnableMethod(this, &SafeBrowsingService::OnIOShutdown));
+ Stop();
+ // The IO thread is going away, so make sure the ClientSideDetectionService
+ // dtor executes now since it may call the dtor of URLFetcher which relies
+ // on it.
+ csd_service_.reset();
}
bool SafeBrowsingService::CanCheckUrl(const GURL& url) const {
@@ -481,16 +503,6 @@ void SafeBrowsingService::LogPauseDelay(base::TimeDelta time) {
UMA_HISTOGRAM_LONG_TIMES("SB2.Delay", time);
}
-SafeBrowsingService::~SafeBrowsingService() {
- // Deletes the PrefChangeRegistrars, whose dtors also unregister |this| as an
- // observer of the preferences.
- STLDeleteValues(&prefs_map_);
-
- // We should have already been shut down. If we're still enabled, then the
- // database isn't going to be closed properly, which could lead to corruption.
- DCHECK(!enabled_);
-}
-
void SafeBrowsingService::OnIOInitialize(
const std::string& client_key,
const std::string& wrapped_key,
@@ -897,6 +909,12 @@ void SafeBrowsingService::Start() {
request_context_getter));
}
+void SafeBrowsingService::Stop() {
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ NewRunnableMethod(this, &SafeBrowsingService::OnIOShutdown));
+}
+
void SafeBrowsingService::OnCloseDatabase() {
DCHECK_EQ(MessageLoop::current(), safe_browsing_thread_->message_loop());
DCHECK(closing_database_);
@@ -1321,5 +1339,8 @@ void SafeBrowsingService::RefreshState() {
if (enable)
Start();
else
- ShutDown();
+ Stop();
+
+ if (csd_service_.get())
+ csd_service_->SetEnabled(enable);
}

Powered by Google App Engine
This is Rietveld 408576698