| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 | 261 |
| 262 #if defined(FULL_SAFE_BROWSING) | 262 #if defined(FULL_SAFE_BROWSING) |
| 263 #if defined(SAFE_BROWSING_CSD) | 263 #if defined(SAFE_BROWSING_CSD) |
| 264 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 264 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 265 switches::kDisableClientSidePhishingDetection)) { | 265 switches::kDisableClientSidePhishingDetection)) { |
| 266 csd_service_.reset(ClientSideDetectionService::Create( | 266 csd_service_.reset(ClientSideDetectionService::Create( |
| 267 url_request_context_getter_.get())); | 267 url_request_context_getter_.get())); |
| 268 } | 268 } |
| 269 #endif // defined(SAFE_BROWSING_CSD) | 269 #endif // defined(SAFE_BROWSING_CSD) |
| 270 | 270 |
| 271 download_service_.reset(new DownloadProtectionService( | 271 download_service_.reset(CreateDownloadProtectionService( |
| 272 this, url_request_context_getter_.get())); | 272 url_request_context_getter_.get())); |
| 273 | 273 |
| 274 incident_service_.reset(CreateIncidentReportingService()); | 274 incident_service_.reset(CreateIncidentReportingService()); |
| 275 resource_request_detector_.reset(new ResourceRequestDetector( | 275 resource_request_detector_.reset(new ResourceRequestDetector( |
| 276 database_manager_, incident_service_->GetIncidentReceiver())); | 276 database_manager_, incident_service_->GetIncidentReceiver())); |
| 277 #endif // !defined(FULL_SAFE_BROWSING) | 277 #endif // !defined(FULL_SAFE_BROWSING) |
| 278 | 278 |
| 279 // Track the safe browsing preference of existing profiles. | 279 // Track the safe browsing preference of existing profiles. |
| 280 // The SafeBrowsingService will be started if any existing profile has the | 280 // The SafeBrowsingService will be started if any existing profile has the |
| 281 // preference enabled. It will also listen for updates to the preferences. | 281 // preference enabled. It will also listen for updates to the preferences. |
| 282 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 282 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 #if defined(SAFE_BROWSING_DB_LOCAL) | 427 #if defined(SAFE_BROWSING_DB_LOCAL) |
| 428 return new LocalSafeBrowsingDatabaseManager(this); | 428 return new LocalSafeBrowsingDatabaseManager(this); |
| 429 #elif defined(SAFE_BROWSING_DB_REMOTE) | 429 #elif defined(SAFE_BROWSING_DB_REMOTE) |
| 430 return new RemoteSafeBrowsingDatabaseManager(); | 430 return new RemoteSafeBrowsingDatabaseManager(); |
| 431 #else | 431 #else |
| 432 return NULL; | 432 return NULL; |
| 433 #endif | 433 #endif |
| 434 } | 434 } |
| 435 | 435 |
| 436 #if defined(FULL_SAFE_BROWSING) | 436 #if defined(FULL_SAFE_BROWSING) |
| 437 DownloadProtectionService* SafeBrowsingService::CreateDownloadProtectionService( |
| 438 net::URLRequestContextGetter* request_context_getter) { |
| 439 return new DownloadProtectionService(this, request_context_getter); |
| 440 } |
| 441 |
| 437 IncidentReportingService* | 442 IncidentReportingService* |
| 438 SafeBrowsingService::CreateIncidentReportingService() { | 443 SafeBrowsingService::CreateIncidentReportingService() { |
| 439 return new IncidentReportingService( | 444 return new IncidentReportingService( |
| 440 this, url_request_context_getter_); | 445 this, url_request_context_getter_); |
| 441 } | 446 } |
| 442 #endif | 447 #endif |
| 443 | 448 |
| 444 void SafeBrowsingService::RegisterAllDelayedAnalysis() { | 449 void SafeBrowsingService::RegisterAllDelayedAnalysis() { |
| 445 #if defined(FULL_SAFE_BROWSING) | 450 #if defined(FULL_SAFE_BROWSING) |
| 446 RegisterBinaryIntegrityAnalysis(); | 451 RegisterBinaryIntegrityAnalysis(); |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 state_callback_list_.Notify(); | 676 state_callback_list_.Notify(); |
| 672 | 677 |
| 673 #if defined(FULL_SAFE_BROWSING) | 678 #if defined(FULL_SAFE_BROWSING) |
| 674 if (csd_service_) | 679 if (csd_service_) |
| 675 csd_service_->SetEnabledAndRefreshState(enable); | 680 csd_service_->SetEnabledAndRefreshState(enable); |
| 676 if (download_service_) | 681 if (download_service_) |
| 677 download_service_->SetEnabled(enable); | 682 download_service_->SetEnabled(enable); |
| 678 #endif | 683 #endif |
| 679 } | 684 } |
| 680 | 685 |
| 681 void SafeBrowsingService::SendDownloadRecoveryReport( | 686 void SafeBrowsingService::SendSerializedDownloadReport( |
| 682 const std::string& report) { | 687 const std::string& report) { |
| 683 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 688 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 684 BrowserThread::PostTask( | 689 BrowserThread::PostTask( |
| 685 BrowserThread::IO, FROM_HERE, | 690 BrowserThread::IO, FROM_HERE, |
| 686 base::Bind(&SafeBrowsingService::OnSendDownloadRecoveryReport, this, | 691 base::Bind(&SafeBrowsingService::OnSendSerializedDownloadReport, this, |
| 687 report)); | 692 report)); |
| 688 } | 693 } |
| 689 | 694 |
| 690 void SafeBrowsingService::OnSendDownloadRecoveryReport( | 695 void SafeBrowsingService::OnSendSerializedDownloadReport( |
| 691 const std::string& report) { | 696 const std::string& report) { |
| 692 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 697 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 693 if (ping_manager()) | 698 if (ping_manager()) |
| 694 ping_manager()->ReportThreatDetails(report); | 699 ping_manager()->ReportThreatDetails(report); |
| 695 } | 700 } |
| 696 | 701 |
| 697 } // namespace safe_browsing | 702 } // namespace safe_browsing |
| OLD | NEW |