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( | |
237 incident_service_->GetIncidentReceiver().Pass())); | |
grt (UTC plus 2)
2015/02/06 15:24:55
do you need the .Pass() here? does it compile if y
robertshield
2015/02/06 22:36:48
Done.
| |
234 } | 238 } |
235 | 239 |
236 off_domain_inclusion_detector_.reset( | 240 off_domain_inclusion_detector_.reset( |
237 new safe_browsing::OffDomainInclusionDetector(database_manager_)); | 241 new safe_browsing::OffDomainInclusionDetector(database_manager_)); |
238 #endif | 242 #endif |
239 | 243 |
240 // Track the safe browsing preference of existing profiles. | 244 // Track the safe browsing preference of existing profiles. |
241 // The SafeBrowsingService will be started if any existing profile has the | 245 // The SafeBrowsingService will be started if any existing profile has the |
242 // preference enabled. It will also listen for updates to the preferences. | 246 // preference enabled. It will also listen for updates to the preferences. |
243 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 247 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
(...skipping 27 matching lines...) Expand all Loading... | |
271 prefs_registrar_.RemoveAll(); | 275 prefs_registrar_.RemoveAll(); |
272 | 276 |
273 Stop(true); | 277 Stop(true); |
274 // The IO thread is going away, so make sure the ClientSideDetectionService | 278 // 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 | 279 // dtor executes now since it may call the dtor of URLFetcher which relies |
276 // on it. | 280 // on it. |
277 csd_service_.reset(); | 281 csd_service_.reset(); |
278 | 282 |
279 #if defined(FULL_SAFE_BROWSING) | 283 #if defined(FULL_SAFE_BROWSING) |
280 off_domain_inclusion_detector_.reset(); | 284 off_domain_inclusion_detector_.reset(); |
285 script_request_detector_.reset(); | |
286 // Note that it is important that incident_service_ be destroyed AFTER the | |
grt (UTC plus 2)
2015/02/06 15:24:55
why do you say that? i don't think it's true.
robertshield
2015/02/06 22:36:48
If you recall the earlier revision of the CL, it u
grt (UTC plus 2)
2015/02/06 23:37:46
Oh, right. Apologies if that comment sounded snott
| |
287 // detectors. | |
281 incident_service_.reset(); | 288 incident_service_.reset(); |
282 #endif | 289 #endif |
283 | 290 |
284 download_service_.reset(); | 291 download_service_.reset(); |
285 | 292 |
286 url_request_context_getter_ = NULL; | 293 url_request_context_getter_ = NULL; |
287 BrowserThread::PostNonNestableTask( | 294 BrowserThread::PostNonNestableTask( |
288 BrowserThread::IO, FROM_HERE, | 295 BrowserThread::IO, FROM_HERE, |
289 base::Bind(&SafeBrowsingService::DestroyURLRequestContextOnIOThread, | 296 base::Bind(&SafeBrowsingService::DestroyURLRequestContextOnIOThread, |
290 this)); | 297 this)); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
352 #if defined(FULL_SAFE_BROWSING) | 359 #if defined(FULL_SAFE_BROWSING) |
353 if (incident_service_) | 360 if (incident_service_) |
354 incident_service_->AddDownloadManager(download_manager); | 361 incident_service_->AddDownloadManager(download_manager); |
355 #endif | 362 #endif |
356 } | 363 } |
357 | 364 |
358 void SafeBrowsingService::OnResourceRequest(const net::URLRequest* request) { | 365 void SafeBrowsingService::OnResourceRequest(const net::URLRequest* request) { |
359 #if defined(FULL_SAFE_BROWSING) | 366 #if defined(FULL_SAFE_BROWSING) |
360 if (off_domain_inclusion_detector_) | 367 if (off_domain_inclusion_detector_) |
361 off_domain_inclusion_detector_->OnResourceRequest(request); | 368 off_domain_inclusion_detector_->OnResourceRequest(request); |
369 if (script_request_detector_) | |
370 script_request_detector_->OnResourceRequest(request); | |
362 #endif | 371 #endif |
363 } | 372 } |
364 | 373 |
365 SafeBrowsingUIManager* SafeBrowsingService::CreateUIManager() { | 374 SafeBrowsingUIManager* SafeBrowsingService::CreateUIManager() { |
366 return new SafeBrowsingUIManager(this); | 375 return new SafeBrowsingUIManager(this); |
367 } | 376 } |
368 | 377 |
369 SafeBrowsingDatabaseManager* SafeBrowsingService::CreateDatabaseManager() { | 378 SafeBrowsingDatabaseManager* SafeBrowsingService::CreateDatabaseManager() { |
370 #if defined(FULL_SAFE_BROWSING) | 379 #if defined(FULL_SAFE_BROWSING) |
371 return new SafeBrowsingDatabaseManager(this); | 380 return new SafeBrowsingDatabaseManager(this); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
577 else | 586 else |
578 Stop(false); | 587 Stop(false); |
579 | 588 |
580 #if defined(FULL_SAFE_BROWSING) | 589 #if defined(FULL_SAFE_BROWSING) |
581 if (csd_service_) | 590 if (csd_service_) |
582 csd_service_->SetEnabledAndRefreshState(enable); | 591 csd_service_->SetEnabledAndRefreshState(enable); |
583 if (download_service_) | 592 if (download_service_) |
584 download_service_->SetEnabled(enable); | 593 download_service_->SetEnabled(enable); |
585 #endif | 594 #endif |
586 } | 595 } |
OLD | NEW |