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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 #if defined(OS_WIN) | 50 #if defined(OS_WIN) |
51 #include "chrome/installer/util/browser_distribution.h" | 51 #include "chrome/installer/util/browser_distribution.h" |
52 #endif | 52 #endif |
53 | 53 |
54 #if defined(FULL_SAFE_BROWSING) | 54 #if defined(FULL_SAFE_BROWSING) |
55 #include "chrome/browser/safe_browsing/incident_reporting/binary_integrity_analy
zer.h" | 55 #include "chrome/browser/safe_browsing/incident_reporting/binary_integrity_analy
zer.h" |
56 #include "chrome/browser/safe_browsing/incident_reporting/blacklist_load_analyze
r.h" | 56 #include "chrome/browser/safe_browsing/incident_reporting/blacklist_load_analyze
r.h" |
57 #include "chrome/browser/safe_browsing/incident_reporting/incident_reporting_ser
vice.h" | 57 #include "chrome/browser/safe_browsing/incident_reporting/incident_reporting_ser
vice.h" |
58 #include "chrome/browser/safe_browsing/incident_reporting/off_domain_inclusion_d
etector.h" | 58 #include "chrome/browser/safe_browsing/incident_reporting/off_domain_inclusion_d
etector.h" |
| 59 #include "chrome/browser/safe_browsing/incident_reporting/script_request_detecto
r.h" |
59 #include "chrome/browser/safe_browsing/incident_reporting/variations_seed_signat
ure_analyzer.h" | 60 #include "chrome/browser/safe_browsing/incident_reporting/variations_seed_signat
ure_analyzer.h" |
60 #endif | 61 #endif |
61 | 62 |
62 using content::BrowserThread; | 63 using content::BrowserThread; |
63 | 64 |
64 namespace { | 65 namespace { |
65 | 66 |
66 // Filename suffix for the cookie database. | 67 // Filename suffix for the cookie database. |
67 const base::FilePath::CharType kCookiesFile[] = FILE_PATH_LITERAL(" Cookies"); | 68 const base::FilePath::CharType kCookiesFile[] = FILE_PATH_LITERAL(" Cookies"); |
68 | 69 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 csd_service_.reset(safe_browsing::ClientSideDetectionService::Create( | 225 csd_service_.reset(safe_browsing::ClientSideDetectionService::Create( |
225 url_request_context_getter_.get())); | 226 url_request_context_getter_.get())); |
226 } | 227 } |
227 download_service_.reset(new safe_browsing::DownloadProtectionService( | 228 download_service_.reset(new safe_browsing::DownloadProtectionService( |
228 this, url_request_context_getter_.get())); | 229 this, url_request_context_getter_.get())); |
229 #endif | 230 #endif |
230 | 231 |
231 if (IsIncidentReportingServiceEnabled()) { | 232 if (IsIncidentReportingServiceEnabled()) { |
232 incident_service_.reset(new safe_browsing::IncidentReportingService( | 233 incident_service_.reset(new safe_browsing::IncidentReportingService( |
233 this, url_request_context_getter_)); | 234 this, url_request_context_getter_)); |
| 235 script_request_detector_.reset( |
| 236 new safe_browsing::ScriptRequestDetector(incident_service_.get())); |
234 } | 237 } |
235 | 238 |
236 off_domain_inclusion_detector_.reset( | 239 off_domain_inclusion_detector_.reset( |
237 new safe_browsing::OffDomainInclusionDetector(database_manager_)); | 240 new safe_browsing::OffDomainInclusionDetector(database_manager_)); |
238 #endif | 241 #endif |
239 | 242 |
240 // Track the safe browsing preference of existing profiles. | 243 // Track the safe browsing preference of existing profiles. |
241 // The SafeBrowsingService will be started if any existing profile has the | 244 // The SafeBrowsingService will be started if any existing profile has the |
242 // preference enabled. It will also listen for updates to the preferences. | 245 // preference enabled. It will also listen for updates to the preferences. |
243 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 246 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
(...skipping 27 matching lines...) Expand all Loading... |
271 prefs_registrar_.RemoveAll(); | 274 prefs_registrar_.RemoveAll(); |
272 | 275 |
273 Stop(true); | 276 Stop(true); |
274 // The IO thread is going away, so make sure the ClientSideDetectionService | 277 // The IO thread is going away, so make sure the ClientSideDetectionService |
275 // dtor executes now since it may call the dtor of URLFetcher which relies | 278 // dtor executes now since it may call the dtor of URLFetcher which relies |
276 // on it. | 279 // on it. |
277 csd_service_.reset(); | 280 csd_service_.reset(); |
278 | 281 |
279 #if defined(FULL_SAFE_BROWSING) | 282 #if defined(FULL_SAFE_BROWSING) |
280 off_domain_inclusion_detector_.reset(); | 283 off_domain_inclusion_detector_.reset(); |
| 284 script_request_detector_.reset(); |
| 285 // Note that it is important that incident_service_ be destroyed AFTER the |
| 286 // detectors. |
281 incident_service_.reset(); | 287 incident_service_.reset(); |
282 #endif | 288 #endif |
283 | 289 |
284 download_service_.reset(); | 290 download_service_.reset(); |
285 | 291 |
286 url_request_context_getter_ = NULL; | 292 url_request_context_getter_ = NULL; |
287 BrowserThread::PostNonNestableTask( | 293 BrowserThread::PostNonNestableTask( |
288 BrowserThread::IO, FROM_HERE, | 294 BrowserThread::IO, FROM_HERE, |
289 base::Bind(&SafeBrowsingService::DestroyURLRequestContextOnIOThread, | 295 base::Bind(&SafeBrowsingService::DestroyURLRequestContextOnIOThread, |
290 this)); | 296 this)); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 #if defined(FULL_SAFE_BROWSING) | 358 #if defined(FULL_SAFE_BROWSING) |
353 if (incident_service_) | 359 if (incident_service_) |
354 incident_service_->AddDownloadManager(download_manager); | 360 incident_service_->AddDownloadManager(download_manager); |
355 #endif | 361 #endif |
356 } | 362 } |
357 | 363 |
358 void SafeBrowsingService::OnResourceRequest(const net::URLRequest* request) { | 364 void SafeBrowsingService::OnResourceRequest(const net::URLRequest* request) { |
359 #if defined(FULL_SAFE_BROWSING) | 365 #if defined(FULL_SAFE_BROWSING) |
360 if (off_domain_inclusion_detector_) | 366 if (off_domain_inclusion_detector_) |
361 off_domain_inclusion_detector_->OnResourceRequest(request); | 367 off_domain_inclusion_detector_->OnResourceRequest(request); |
| 368 if (script_request_detector_) |
| 369 script_request_detector_->OnResourceRequest(request); |
362 #endif | 370 #endif |
363 } | 371 } |
364 | 372 |
365 SafeBrowsingUIManager* SafeBrowsingService::CreateUIManager() { | 373 SafeBrowsingUIManager* SafeBrowsingService::CreateUIManager() { |
366 return new SafeBrowsingUIManager(this); | 374 return new SafeBrowsingUIManager(this); |
367 } | 375 } |
368 | 376 |
369 SafeBrowsingDatabaseManager* SafeBrowsingService::CreateDatabaseManager() { | 377 SafeBrowsingDatabaseManager* SafeBrowsingService::CreateDatabaseManager() { |
370 #if defined(FULL_SAFE_BROWSING) | 378 #if defined(FULL_SAFE_BROWSING) |
371 return new SafeBrowsingDatabaseManager(this); | 379 return new SafeBrowsingDatabaseManager(this); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 else | 585 else |
578 Stop(false); | 586 Stop(false); |
579 | 587 |
580 #if defined(FULL_SAFE_BROWSING) | 588 #if defined(FULL_SAFE_BROWSING) |
581 if (csd_service_) | 589 if (csd_service_) |
582 csd_service_->SetEnabledAndRefreshState(enable); | 590 csd_service_->SetEnabledAndRefreshState(enable); |
583 if (download_service_) | 591 if (download_service_) |
584 download_service_->SetEnabled(enable); | 592 download_service_->SetEnabled(enable); |
585 #endif | 593 #endif |
586 } | 594 } |
OLD | NEW |