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 { | 68 namespace safe_browsing { |
69 | 69 |
70 // Filename suffix for the cookie database. | 70 // Filename suffix for the cookie database. |
Nathan Parker
2015/11/05 22:00:53
anon-namespace
vakh (old account. dont use)
2015/11/07 01:22:56
Done.
| |
71 const base::FilePath::CharType kCookiesFile[] = FILE_PATH_LITERAL(" Cookies"); | 71 const base::FilePath::CharType kCookiesFile[] = FILE_PATH_LITERAL(" Cookies"); |
72 | 72 |
73 // The default URL prefix where browser fetches chunk updates, hashes, | 73 // The default URL prefix where browser fetches chunk updates, hashes, |
74 // and reports safe browsing hits and malware details. | 74 // and reports safe browsing hits and malware details. |
75 const char kSbDefaultURLPrefix[] = | 75 const char kSbDefaultURLPrefix[] = |
76 "https://safebrowsing.google.com/safebrowsing"; | 76 "https://safebrowsing.google.com/safebrowsing"; |
77 | 77 |
78 // The backup URL prefix used when there are issues establishing a connection | 78 // The backup URL prefix used when there are issues establishing a connection |
79 // with the server at the primary URL. | 79 // with the server at the primary URL. |
80 const char kSbBackupConnectErrorURLPrefix[] = | 80 const char kSbBackupConnectErrorURLPrefix[] = |
81 "https://alt1-safebrowsing.google.com/safebrowsing"; | 81 "https://alt1-safebrowsing.google.com/safebrowsing"; |
82 | 82 |
83 // The backup URL prefix used when there are HTTP-specific issues with the | 83 // The backup URL prefix used when there are HTTP-specific issues with the |
84 // server at the primary URL. | 84 // server at the primary URL. |
85 const char kSbBackupHttpErrorURLPrefix[] = | 85 const char kSbBackupHttpErrorURLPrefix[] = |
86 "https://alt2-safebrowsing.google.com/safebrowsing"; | 86 "https://alt2-safebrowsing.google.com/safebrowsing"; |
87 | 87 |
88 // The backup URL prefix used when there are local network specific issues. | 88 // The backup URL prefix used when there are local network specific issues. |
89 const char kSbBackupNetworkErrorURLPrefix[] = | 89 const char kSbBackupNetworkErrorURLPrefix[] = |
90 "https://alt3-safebrowsing.google.com/safebrowsing"; | 90 "https://alt3-safebrowsing.google.com/safebrowsing"; |
91 | 91 |
92 base::FilePath CookieFilePath() { | 92 base::FilePath CookieFilePath() { |
93 return base::FilePath( | 93 return base::FilePath( |
94 SafeBrowsingService::GetBaseFilename().value() + kCookiesFile); | 94 SafeBrowsingService::GetBaseFilename().value() + kCookiesFile); |
95 } | 95 } |
96 | 96 |
97 } // namespace | |
98 | |
99 class SafeBrowsingURLRequestContextGetter | 97 class SafeBrowsingURLRequestContextGetter |
100 : public net::URLRequestContextGetter { | 98 : public net::URLRequestContextGetter { |
101 public: | 99 public: |
102 explicit SafeBrowsingURLRequestContextGetter( | 100 explicit SafeBrowsingURLRequestContextGetter( |
103 SafeBrowsingService* sb_service_); | 101 SafeBrowsingService* sb_service_); |
104 | 102 |
105 // Implementation for net::UrlRequestContextGetter. | 103 // Implementation for net::UrlRequestContextGetter. |
106 net::URLRequestContext* GetURLRequestContext() override; | 104 net::URLRequestContext* GetURLRequestContext() override; |
107 scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() | 105 scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() |
108 const override; | 106 const override; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 BrowserThread::PostTask( | 214 BrowserThread::PostTask( |
217 BrowserThread::IO, FROM_HERE, | 215 BrowserThread::IO, FROM_HERE, |
218 base::Bind( | 216 base::Bind( |
219 &SafeBrowsingService::InitURLRequestContextOnIOThread, this, | 217 &SafeBrowsingService::InitURLRequestContextOnIOThread, this, |
220 make_scoped_refptr(g_browser_process->system_request_context()))); | 218 make_scoped_refptr(g_browser_process->system_request_context()))); |
221 | 219 |
222 #if defined(FULL_SAFE_BROWSING) | 220 #if defined(FULL_SAFE_BROWSING) |
223 #if defined(SAFE_BROWSING_CSD) | 221 #if defined(SAFE_BROWSING_CSD) |
224 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 222 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
225 switches::kDisableClientSidePhishingDetection)) { | 223 switches::kDisableClientSidePhishingDetection)) { |
226 csd_service_.reset(safe_browsing::ClientSideDetectionService::Create( | 224 csd_service_.reset(ClientSideDetectionService::Create( |
227 url_request_context_getter_.get())); | 225 url_request_context_getter_.get())); |
228 } | 226 } |
229 #endif // defined(SAFE_BROWSING_CSD) | 227 #endif // defined(SAFE_BROWSING_CSD) |
230 | 228 |
231 download_service_.reset(new safe_browsing::DownloadProtectionService( | 229 download_service_.reset(new DownloadProtectionService( |
232 this, url_request_context_getter_.get())); | 230 this, url_request_context_getter_.get())); |
233 | 231 |
234 incident_service_.reset(CreateIncidentReportingService()); | 232 incident_service_.reset(CreateIncidentReportingService()); |
235 resource_request_detector_.reset(new safe_browsing::ResourceRequestDetector( | 233 resource_request_detector_.reset(new ResourceRequestDetector( |
236 incident_service_->GetIncidentReceiver())); | 234 incident_service_->GetIncidentReceiver())); |
237 | 235 |
238 off_domain_inclusion_detector_.reset( | 236 off_domain_inclusion_detector_.reset( |
239 new safe_browsing::OffDomainInclusionDetector(database_manager_)); | 237 new OffDomainInclusionDetector(database_manager_)); |
240 #endif // !defined(FULL_SAFE_BROWSING) | 238 #endif // !defined(FULL_SAFE_BROWSING) |
241 | 239 |
242 // Track the safe browsing preference of existing profiles. | 240 // Track the safe browsing preference of existing profiles. |
243 // The SafeBrowsingService will be started if any existing profile has the | 241 // The SafeBrowsingService will be started if any existing profile has the |
244 // preference enabled. It will also listen for updates to the preferences. | 242 // preference enabled. It will also listen for updates to the preferences. |
245 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 243 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
246 if (profile_manager) { | 244 if (profile_manager) { |
247 std::vector<Profile*> profiles = profile_manager->GetLoadedProfiles(); | 245 std::vector<Profile*> profiles = profile_manager->GetLoadedProfiles(); |
248 // TODO(felt): I believe this for-loop is dead code. Confirm this and | 246 // 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/ | 247 // 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 { | 345 Profile* profile) const { |
348 #if defined(FULL_SAFE_BROWSING) | 346 #if defined(FULL_SAFE_BROWSING) |
349 return incident_service_->CreatePreferenceValidationDelegate(profile); | 347 return incident_service_->CreatePreferenceValidationDelegate(profile); |
350 #else | 348 #else |
351 return scoped_ptr<TrackedPreferenceValidationDelegate>(); | 349 return scoped_ptr<TrackedPreferenceValidationDelegate>(); |
352 #endif | 350 #endif |
353 } | 351 } |
354 | 352 |
355 #if defined(FULL_SAFE_BROWSING) | 353 #if defined(FULL_SAFE_BROWSING) |
356 void SafeBrowsingService::RegisterDelayedAnalysisCallback( | 354 void SafeBrowsingService::RegisterDelayedAnalysisCallback( |
357 const safe_browsing::DelayedAnalysisCallback& callback) { | 355 const DelayedAnalysisCallback& callback) { |
358 incident_service_->RegisterDelayedAnalysisCallback(callback); | 356 incident_service_->RegisterDelayedAnalysisCallback(callback); |
359 } | 357 } |
360 #endif | 358 #endif |
361 | 359 |
362 void SafeBrowsingService::AddDownloadManager( | 360 void SafeBrowsingService::AddDownloadManager( |
363 content::DownloadManager* download_manager) { | 361 content::DownloadManager* download_manager) { |
364 #if defined(FULL_SAFE_BROWSING) | 362 #if defined(FULL_SAFE_BROWSING) |
365 incident_service_->AddDownloadManager(download_manager); | 363 incident_service_->AddDownloadManager(download_manager); |
366 #endif | 364 #endif |
367 } | 365 } |
(...skipping 15 matching lines...) Expand all Loading... | |
383 #if defined(SAFE_BROWSING_DB_LOCAL) | 381 #if defined(SAFE_BROWSING_DB_LOCAL) |
384 return new LocalSafeBrowsingDatabaseManager(this); | 382 return new LocalSafeBrowsingDatabaseManager(this); |
385 #elif defined(SAFE_BROWSING_DB_REMOTE) | 383 #elif defined(SAFE_BROWSING_DB_REMOTE) |
386 return new RemoteSafeBrowsingDatabaseManager(); | 384 return new RemoteSafeBrowsingDatabaseManager(); |
387 #else | 385 #else |
388 return NULL; | 386 return NULL; |
389 #endif | 387 #endif |
390 } | 388 } |
391 | 389 |
392 #if defined(FULL_SAFE_BROWSING) | 390 #if defined(FULL_SAFE_BROWSING) |
393 safe_browsing::IncidentReportingService* | 391 IncidentReportingService* |
394 SafeBrowsingService::CreateIncidentReportingService() { | 392 SafeBrowsingService::CreateIncidentReportingService() { |
395 return new safe_browsing::IncidentReportingService( | 393 return new IncidentReportingService( |
396 this, url_request_context_getter_); | 394 this, url_request_context_getter_); |
397 } | 395 } |
398 #endif | 396 #endif |
399 | 397 |
400 void SafeBrowsingService::RegisterAllDelayedAnalysis() { | 398 void SafeBrowsingService::RegisterAllDelayedAnalysis() { |
401 #if defined(FULL_SAFE_BROWSING) | 399 #if defined(FULL_SAFE_BROWSING) |
402 safe_browsing::RegisterBinaryIntegrityAnalysis(); | 400 RegisterBinaryIntegrityAnalysis(); |
403 safe_browsing::RegisterBlacklistLoadAnalysis(); | 401 RegisterBlacklistLoadAnalysis(); |
404 safe_browsing::RegisterVariationsSeedSignatureAnalysis(); | 402 RegisterVariationsSeedSignatureAnalysis(); |
405 #else | 403 #else |
406 NOTREACHED(); | 404 NOTREACHED(); |
407 #endif | 405 #endif |
408 } | 406 } |
409 | 407 |
410 void SafeBrowsingService::InitURLRequestContextOnIOThread( | 408 void SafeBrowsingService::InitURLRequestContextOnIOThread( |
411 net::URLRequestContextGetter* system_url_request_context_getter) { | 409 net::URLRequestContextGetter* system_url_request_context_getter) { |
412 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 410 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
413 DCHECK(!url_request_context_.get()); | 411 DCHECK(!url_request_context_.get()); |
414 | 412 |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
638 | 636 |
639 state_callback_list_.Notify(); | 637 state_callback_list_.Notify(); |
640 | 638 |
641 #if defined(FULL_SAFE_BROWSING) | 639 #if defined(FULL_SAFE_BROWSING) |
642 if (csd_service_) | 640 if (csd_service_) |
643 csd_service_->SetEnabledAndRefreshState(enable); | 641 csd_service_->SetEnabledAndRefreshState(enable); |
644 if (download_service_) | 642 if (download_service_) |
645 download_service_->SetEnabled(enable); | 643 download_service_->SetEnabled(enable); |
646 #endif | 644 #endif |
647 } | 645 } |
646 | |
647 } // namespace safe_browsing | |
OLD | NEW |