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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 safe_browsing::SafeBrowsingService::GetBaseFilename().value() + |
| 95 kCookiesFile); |
95 } | 96 } |
96 | 97 |
97 } // namespace | 98 } // namespace |
98 | 99 |
| 100 namespace safe_browsing { |
| 101 |
99 class SafeBrowsingURLRequestContextGetter | 102 class SafeBrowsingURLRequestContextGetter |
100 : public net::URLRequestContextGetter { | 103 : public net::URLRequestContextGetter { |
101 public: | 104 public: |
102 explicit SafeBrowsingURLRequestContextGetter( | 105 explicit SafeBrowsingURLRequestContextGetter( |
103 SafeBrowsingService* sb_service_); | 106 SafeBrowsingService* sb_service_); |
104 | 107 |
105 // Implementation for net::UrlRequestContextGetter. | 108 // Implementation for net::UrlRequestContextGetter. |
106 net::URLRequestContext* GetURLRequestContext() override; | 109 net::URLRequestContext* GetURLRequestContext() override; |
107 scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() | 110 scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() |
108 const override; | 111 const override; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 BrowserThread::PostTask( | 219 BrowserThread::PostTask( |
217 BrowserThread::IO, FROM_HERE, | 220 BrowserThread::IO, FROM_HERE, |
218 base::Bind( | 221 base::Bind( |
219 &SafeBrowsingService::InitURLRequestContextOnIOThread, this, | 222 &SafeBrowsingService::InitURLRequestContextOnIOThread, this, |
220 make_scoped_refptr(g_browser_process->system_request_context()))); | 223 make_scoped_refptr(g_browser_process->system_request_context()))); |
221 | 224 |
222 #if defined(FULL_SAFE_BROWSING) | 225 #if defined(FULL_SAFE_BROWSING) |
223 #if defined(SAFE_BROWSING_CSD) | 226 #if defined(SAFE_BROWSING_CSD) |
224 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 227 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
225 switches::kDisableClientSidePhishingDetection)) { | 228 switches::kDisableClientSidePhishingDetection)) { |
226 csd_service_.reset(safe_browsing::ClientSideDetectionService::Create( | 229 csd_service_.reset(ClientSideDetectionService::Create( |
227 url_request_context_getter_.get())); | 230 url_request_context_getter_.get())); |
228 } | 231 } |
229 #endif // defined(SAFE_BROWSING_CSD) | 232 #endif // defined(SAFE_BROWSING_CSD) |
230 | 233 |
231 download_service_.reset(new safe_browsing::DownloadProtectionService( | 234 download_service_.reset(new DownloadProtectionService( |
232 this, url_request_context_getter_.get())); | 235 this, url_request_context_getter_.get())); |
233 | 236 |
234 incident_service_.reset(CreateIncidentReportingService()); | 237 incident_service_.reset(CreateIncidentReportingService()); |
235 resource_request_detector_.reset(new safe_browsing::ResourceRequestDetector( | 238 resource_request_detector_.reset(new ResourceRequestDetector( |
236 incident_service_->GetIncidentReceiver())); | 239 incident_service_->GetIncidentReceiver())); |
237 | 240 |
238 off_domain_inclusion_detector_.reset( | 241 off_domain_inclusion_detector_.reset( |
239 new safe_browsing::OffDomainInclusionDetector(database_manager_)); | 242 new OffDomainInclusionDetector(database_manager_)); |
240 #endif // !defined(FULL_SAFE_BROWSING) | 243 #endif // !defined(FULL_SAFE_BROWSING) |
241 | 244 |
242 // Track the safe browsing preference of existing profiles. | 245 // Track the safe browsing preference of existing profiles. |
243 // The SafeBrowsingService will be started if any existing profile has the | 246 // The SafeBrowsingService will be started if any existing profile has the |
244 // preference enabled. It will also listen for updates to the preferences. | 247 // preference enabled. It will also listen for updates to the preferences. |
245 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 248 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
246 if (profile_manager) { | 249 if (profile_manager) { |
247 std::vector<Profile*> profiles = profile_manager->GetLoadedProfiles(); | 250 std::vector<Profile*> profiles = profile_manager->GetLoadedProfiles(); |
248 // TODO(felt): I believe this for-loop is dead code. Confirm this and | 251 // 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/ | 252 // 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 { | 350 Profile* profile) const { |
348 #if defined(FULL_SAFE_BROWSING) | 351 #if defined(FULL_SAFE_BROWSING) |
349 return incident_service_->CreatePreferenceValidationDelegate(profile); | 352 return incident_service_->CreatePreferenceValidationDelegate(profile); |
350 #else | 353 #else |
351 return scoped_ptr<TrackedPreferenceValidationDelegate>(); | 354 return scoped_ptr<TrackedPreferenceValidationDelegate>(); |
352 #endif | 355 #endif |
353 } | 356 } |
354 | 357 |
355 #if defined(FULL_SAFE_BROWSING) | 358 #if defined(FULL_SAFE_BROWSING) |
356 void SafeBrowsingService::RegisterDelayedAnalysisCallback( | 359 void SafeBrowsingService::RegisterDelayedAnalysisCallback( |
357 const safe_browsing::DelayedAnalysisCallback& callback) { | 360 const DelayedAnalysisCallback& callback) { |
358 incident_service_->RegisterDelayedAnalysisCallback(callback); | 361 incident_service_->RegisterDelayedAnalysisCallback(callback); |
359 } | 362 } |
360 #endif | 363 #endif |
361 | 364 |
362 void SafeBrowsingService::AddDownloadManager( | 365 void SafeBrowsingService::AddDownloadManager( |
363 content::DownloadManager* download_manager) { | 366 content::DownloadManager* download_manager) { |
364 #if defined(FULL_SAFE_BROWSING) | 367 #if defined(FULL_SAFE_BROWSING) |
365 incident_service_->AddDownloadManager(download_manager); | 368 incident_service_->AddDownloadManager(download_manager); |
366 #endif | 369 #endif |
367 } | 370 } |
(...skipping 15 matching lines...) Expand all Loading... |
383 #if defined(SAFE_BROWSING_DB_LOCAL) | 386 #if defined(SAFE_BROWSING_DB_LOCAL) |
384 return new LocalSafeBrowsingDatabaseManager(this); | 387 return new LocalSafeBrowsingDatabaseManager(this); |
385 #elif defined(SAFE_BROWSING_DB_REMOTE) | 388 #elif defined(SAFE_BROWSING_DB_REMOTE) |
386 return new RemoteSafeBrowsingDatabaseManager(); | 389 return new RemoteSafeBrowsingDatabaseManager(); |
387 #else | 390 #else |
388 return NULL; | 391 return NULL; |
389 #endif | 392 #endif |
390 } | 393 } |
391 | 394 |
392 #if defined(FULL_SAFE_BROWSING) | 395 #if defined(FULL_SAFE_BROWSING) |
393 safe_browsing::IncidentReportingService* | 396 IncidentReportingService* |
394 SafeBrowsingService::CreateIncidentReportingService() { | 397 SafeBrowsingService::CreateIncidentReportingService() { |
395 return new safe_browsing::IncidentReportingService( | 398 return new IncidentReportingService( |
396 this, url_request_context_getter_); | 399 this, url_request_context_getter_); |
397 } | 400 } |
398 #endif | 401 #endif |
399 | 402 |
400 void SafeBrowsingService::RegisterAllDelayedAnalysis() { | 403 void SafeBrowsingService::RegisterAllDelayedAnalysis() { |
401 #if defined(FULL_SAFE_BROWSING) | 404 #if defined(FULL_SAFE_BROWSING) |
402 safe_browsing::RegisterBinaryIntegrityAnalysis(); | 405 RegisterBinaryIntegrityAnalysis(); |
403 safe_browsing::RegisterBlacklistLoadAnalysis(); | 406 RegisterBlacklistLoadAnalysis(); |
404 safe_browsing::RegisterVariationsSeedSignatureAnalysis(); | 407 RegisterVariationsSeedSignatureAnalysis(); |
405 #else | 408 #else |
406 NOTREACHED(); | 409 NOTREACHED(); |
407 #endif | 410 #endif |
408 } | 411 } |
409 | 412 |
410 void SafeBrowsingService::InitURLRequestContextOnIOThread( | 413 void SafeBrowsingService::InitURLRequestContextOnIOThread( |
411 net::URLRequestContextGetter* system_url_request_context_getter) { | 414 net::URLRequestContextGetter* system_url_request_context_getter) { |
412 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 415 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
413 DCHECK(!url_request_context_.get()); | 416 DCHECK(!url_request_context_.get()); |
414 | 417 |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 | 641 |
639 state_callback_list_.Notify(); | 642 state_callback_list_.Notify(); |
640 | 643 |
641 #if defined(FULL_SAFE_BROWSING) | 644 #if defined(FULL_SAFE_BROWSING) |
642 if (csd_service_) | 645 if (csd_service_) |
643 csd_service_->SetEnabledAndRefreshState(enable); | 646 csd_service_->SetEnabledAndRefreshState(enable); |
644 if (download_service_) | 647 if (download_service_) |
645 download_service_->SetEnabled(enable); | 648 download_service_->SetEnabled(enable); |
646 #endif | 649 #endif |
647 } | 650 } |
| 651 |
| 652 } // namespace safe_browsing |
OLD | NEW |