OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/safe_browsing/safe_browsing_service.h" | 5 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 #include "chrome/browser/safe_browsing/incident_reporting/binary_integrity_analy
zer.h" | 58 #include "chrome/browser/safe_browsing/incident_reporting/binary_integrity_analy
zer.h" |
59 #include "chrome/browser/safe_browsing/incident_reporting/blacklist_load_analyze
r.h" | 59 #include "chrome/browser/safe_browsing/incident_reporting/blacklist_load_analyze
r.h" |
60 #include "chrome/browser/safe_browsing/incident_reporting/incident_reporting_ser
vice.h" | 60 #include "chrome/browser/safe_browsing/incident_reporting/incident_reporting_ser
vice.h" |
61 #include "chrome/browser/safe_browsing/incident_reporting/off_domain_inclusion_d
etector.h" | 61 #include "chrome/browser/safe_browsing/incident_reporting/off_domain_inclusion_d
etector.h" |
62 #include "chrome/browser/safe_browsing/incident_reporting/resource_request_detec
tor.h" | 62 #include "chrome/browser/safe_browsing/incident_reporting/resource_request_detec
tor.h" |
63 #include "chrome/browser/safe_browsing/incident_reporting/variations_seed_signat
ure_analyzer.h" | 63 #include "chrome/browser/safe_browsing/incident_reporting/variations_seed_signat
ure_analyzer.h" |
64 #endif | 64 #endif |
65 | 65 |
66 using content::BrowserThread; | 66 using content::BrowserThread; |
67 | 67 |
| 68 namespace safe_browsing { |
| 69 |
68 namespace { | 70 namespace { |
69 | 71 |
70 // Filename suffix for the cookie database. | 72 // Filename suffix for the cookie database. |
71 const base::FilePath::CharType kCookiesFile[] = FILE_PATH_LITERAL(" Cookies"); | 73 const base::FilePath::CharType kCookiesFile[] = FILE_PATH_LITERAL(" Cookies"); |
72 | 74 |
73 // The default URL prefix where browser fetches chunk updates, hashes, | 75 // The default URL prefix where browser fetches chunk updates, hashes, |
74 // and reports safe browsing hits and malware details. | 76 // and reports safe browsing hits and malware details. |
75 const char kSbDefaultURLPrefix[] = | 77 const char kSbDefaultURLPrefix[] = |
76 "https://safebrowsing.google.com/safebrowsing"; | 78 "https://safebrowsing.google.com/safebrowsing"; |
77 | 79 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 BrowserThread::PostTask( | 218 BrowserThread::PostTask( |
217 BrowserThread::IO, FROM_HERE, | 219 BrowserThread::IO, FROM_HERE, |
218 base::Bind( | 220 base::Bind( |
219 &SafeBrowsingService::InitURLRequestContextOnIOThread, this, | 221 &SafeBrowsingService::InitURLRequestContextOnIOThread, this, |
220 make_scoped_refptr(g_browser_process->system_request_context()))); | 222 make_scoped_refptr(g_browser_process->system_request_context()))); |
221 | 223 |
222 #if defined(FULL_SAFE_BROWSING) | 224 #if defined(FULL_SAFE_BROWSING) |
223 #if defined(SAFE_BROWSING_CSD) | 225 #if defined(SAFE_BROWSING_CSD) |
224 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 226 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
225 switches::kDisableClientSidePhishingDetection)) { | 227 switches::kDisableClientSidePhishingDetection)) { |
226 csd_service_.reset(safe_browsing::ClientSideDetectionService::Create( | 228 csd_service_.reset(ClientSideDetectionService::Create( |
227 url_request_context_getter_.get())); | 229 url_request_context_getter_.get())); |
228 } | 230 } |
229 #endif // defined(SAFE_BROWSING_CSD) | 231 #endif // defined(SAFE_BROWSING_CSD) |
230 | 232 |
231 download_service_.reset(new safe_browsing::DownloadProtectionService( | 233 download_service_.reset(new DownloadProtectionService( |
232 this, url_request_context_getter_.get())); | 234 this, url_request_context_getter_.get())); |
233 | 235 |
234 incident_service_.reset(CreateIncidentReportingService()); | 236 incident_service_.reset(CreateIncidentReportingService()); |
235 resource_request_detector_.reset(new safe_browsing::ResourceRequestDetector( | 237 resource_request_detector_.reset(new ResourceRequestDetector( |
236 incident_service_->GetIncidentReceiver())); | 238 incident_service_->GetIncidentReceiver())); |
237 | 239 |
238 off_domain_inclusion_detector_.reset( | 240 off_domain_inclusion_detector_.reset( |
239 new safe_browsing::OffDomainInclusionDetector(database_manager_)); | 241 new OffDomainInclusionDetector(database_manager_)); |
240 #endif // !defined(FULL_SAFE_BROWSING) | 242 #endif // !defined(FULL_SAFE_BROWSING) |
241 | 243 |
242 // Track the safe browsing preference of existing profiles. | 244 // Track the safe browsing preference of existing profiles. |
243 // The SafeBrowsingService will be started if any existing profile has the | 245 // The SafeBrowsingService will be started if any existing profile has the |
244 // preference enabled. It will also listen for updates to the preferences. | 246 // preference enabled. It will also listen for updates to the preferences. |
245 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 247 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
246 if (profile_manager) { | 248 if (profile_manager) { |
247 std::vector<Profile*> profiles = profile_manager->GetLoadedProfiles(); | 249 std::vector<Profile*> profiles = profile_manager->GetLoadedProfiles(); |
248 // TODO(felt): I believe this for-loop is dead code. Confirm this and | 250 // TODO(felt): I believe this for-loop is dead code. Confirm this and |
249 // remove in a future CL. See https://codereview.chromium.org/1341533002/ | 251 // remove in a future CL. See https://codereview.chromium.org/1341533002/ |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 Profile* profile) const { | 349 Profile* profile) const { |
348 #if defined(FULL_SAFE_BROWSING) | 350 #if defined(FULL_SAFE_BROWSING) |
349 return incident_service_->CreatePreferenceValidationDelegate(profile); | 351 return incident_service_->CreatePreferenceValidationDelegate(profile); |
350 #else | 352 #else |
351 return scoped_ptr<TrackedPreferenceValidationDelegate>(); | 353 return scoped_ptr<TrackedPreferenceValidationDelegate>(); |
352 #endif | 354 #endif |
353 } | 355 } |
354 | 356 |
355 #if defined(FULL_SAFE_BROWSING) | 357 #if defined(FULL_SAFE_BROWSING) |
356 void SafeBrowsingService::RegisterDelayedAnalysisCallback( | 358 void SafeBrowsingService::RegisterDelayedAnalysisCallback( |
357 const safe_browsing::DelayedAnalysisCallback& callback) { | 359 const DelayedAnalysisCallback& callback) { |
358 incident_service_->RegisterDelayedAnalysisCallback(callback); | 360 incident_service_->RegisterDelayedAnalysisCallback(callback); |
359 } | 361 } |
360 #endif | 362 #endif |
361 | 363 |
362 void SafeBrowsingService::AddDownloadManager( | 364 void SafeBrowsingService::AddDownloadManager( |
363 content::DownloadManager* download_manager) { | 365 content::DownloadManager* download_manager) { |
364 #if defined(FULL_SAFE_BROWSING) | 366 #if defined(FULL_SAFE_BROWSING) |
365 incident_service_->AddDownloadManager(download_manager); | 367 incident_service_->AddDownloadManager(download_manager); |
366 #endif | 368 #endif |
367 } | 369 } |
(...skipping 15 matching lines...) Expand all Loading... |
383 #if defined(SAFE_BROWSING_DB_LOCAL) | 385 #if defined(SAFE_BROWSING_DB_LOCAL) |
384 return new LocalSafeBrowsingDatabaseManager(this); | 386 return new LocalSafeBrowsingDatabaseManager(this); |
385 #elif defined(SAFE_BROWSING_DB_REMOTE) | 387 #elif defined(SAFE_BROWSING_DB_REMOTE) |
386 return new RemoteSafeBrowsingDatabaseManager(); | 388 return new RemoteSafeBrowsingDatabaseManager(); |
387 #else | 389 #else |
388 return NULL; | 390 return NULL; |
389 #endif | 391 #endif |
390 } | 392 } |
391 | 393 |
392 #if defined(FULL_SAFE_BROWSING) | 394 #if defined(FULL_SAFE_BROWSING) |
393 safe_browsing::IncidentReportingService* | 395 IncidentReportingService* |
394 SafeBrowsingService::CreateIncidentReportingService() { | 396 SafeBrowsingService::CreateIncidentReportingService() { |
395 return new safe_browsing::IncidentReportingService( | 397 return new IncidentReportingService( |
396 this, url_request_context_getter_); | 398 this, url_request_context_getter_); |
397 } | 399 } |
398 #endif | 400 #endif |
399 | 401 |
400 void SafeBrowsingService::RegisterAllDelayedAnalysis() { | 402 void SafeBrowsingService::RegisterAllDelayedAnalysis() { |
401 #if defined(FULL_SAFE_BROWSING) | 403 #if defined(FULL_SAFE_BROWSING) |
402 safe_browsing::RegisterBinaryIntegrityAnalysis(); | 404 RegisterBinaryIntegrityAnalysis(); |
403 safe_browsing::RegisterBlacklistLoadAnalysis(); | 405 RegisterBlacklistLoadAnalysis(); |
404 safe_browsing::RegisterVariationsSeedSignatureAnalysis(); | 406 RegisterVariationsSeedSignatureAnalysis(); |
405 #else | 407 #else |
406 NOTREACHED(); | 408 NOTREACHED(); |
407 #endif | 409 #endif |
408 } | 410 } |
409 | 411 |
410 void SafeBrowsingService::InitURLRequestContextOnIOThread( | 412 void SafeBrowsingService::InitURLRequestContextOnIOThread( |
411 net::URLRequestContextGetter* system_url_request_context_getter) { | 413 net::URLRequestContextGetter* system_url_request_context_getter) { |
412 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 414 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
413 DCHECK(!url_request_context_.get()); | 415 DCHECK(!url_request_context_.get()); |
414 | 416 |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 | 640 |
639 state_callback_list_.Notify(); | 641 state_callback_list_.Notify(); |
640 | 642 |
641 #if defined(FULL_SAFE_BROWSING) | 643 #if defined(FULL_SAFE_BROWSING) |
642 if (csd_service_) | 644 if (csd_service_) |
643 csd_service_->SetEnabledAndRefreshState(enable); | 645 csd_service_->SetEnabledAndRefreshState(enable); |
644 if (download_service_) | 646 if (download_service_) |
645 download_service_->SetEnabled(enable); | 647 download_service_->SetEnabled(enable); |
646 #endif | 648 #endif |
647 } | 649 } |
| 650 |
| 651 } // namespace safe_browsing |
OLD | NEW |