Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_service.cc

Issue 516663002: Introducing the OffDomainInclusionDetector to analyze resource requests for suspicious activity. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 12 matching lines...) Expand all
23 #include "chrome/browser/chrome_notification_types.h" 23 #include "chrome/browser/chrome_notification_types.h"
24 #include "chrome/browser/prefs/tracked/tracked_preference_validation_delegate.h" 24 #include "chrome/browser/prefs/tracked/tracked_preference_validation_delegate.h"
25 #include "chrome/browser/profiles/profile.h" 25 #include "chrome/browser/profiles/profile.h"
26 #include "chrome/browser/profiles/profile_manager.h" 26 #include "chrome/browser/profiles/profile_manager.h"
27 #include "chrome/browser/safe_browsing/client_side_detection_service.h" 27 #include "chrome/browser/safe_browsing/client_side_detection_service.h"
28 #include "chrome/browser/safe_browsing/database_manager.h" 28 #include "chrome/browser/safe_browsing/database_manager.h"
29 #include "chrome/browser/safe_browsing/download_protection_service.h" 29 #include "chrome/browser/safe_browsing/download_protection_service.h"
30 #include "chrome/browser/safe_browsing/incident_reporting/binary_integrity_analy zer.h" 30 #include "chrome/browser/safe_browsing/incident_reporting/binary_integrity_analy zer.h"
31 #include "chrome/browser/safe_browsing/incident_reporting/blacklist_load_analyze r.h" 31 #include "chrome/browser/safe_browsing/incident_reporting/blacklist_load_analyze r.h"
32 #include "chrome/browser/safe_browsing/incident_reporting/incident_reporting_ser vice.h" 32 #include "chrome/browser/safe_browsing/incident_reporting/incident_reporting_ser vice.h"
33 #include "chrome/browser/safe_browsing/incident_reporting/off_domain_inclusion_d etector.h"
33 #include "chrome/browser/safe_browsing/malware_details.h" 34 #include "chrome/browser/safe_browsing/malware_details.h"
34 #include "chrome/browser/safe_browsing/ping_manager.h" 35 #include "chrome/browser/safe_browsing/ping_manager.h"
35 #include "chrome/browser/safe_browsing/protocol_manager.h" 36 #include "chrome/browser/safe_browsing/protocol_manager.h"
36 #include "chrome/browser/safe_browsing/safe_browsing_database.h" 37 #include "chrome/browser/safe_browsing/safe_browsing_database.h"
37 #include "chrome/browser/safe_browsing/ui_manager.h" 38 #include "chrome/browser/safe_browsing/ui_manager.h"
38 #include "chrome/common/chrome_constants.h" 39 #include "chrome/common/chrome_constants.h"
39 #include "chrome/common/chrome_paths.h" 40 #include "chrome/common/chrome_paths.h"
40 #include "chrome/common/chrome_switches.h" 41 #include "chrome/common/chrome_switches.h"
41 #include "chrome/common/pref_names.h" 42 #include "chrome/common/pref_names.h"
42 #include "chrome/common/url_constants.h" 43 #include "chrome/common/url_constants.h"
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 url_request_context_getter_.get())); 234 url_request_context_getter_.get()));
234 } 235 }
235 download_service_.reset(new safe_browsing::DownloadProtectionService( 236 download_service_.reset(new safe_browsing::DownloadProtectionService(
236 this, url_request_context_getter_.get())); 237 this, url_request_context_getter_.get()));
237 #endif 238 #endif
238 239
239 if (IsIncidentReportingServiceEnabled()) { 240 if (IsIncidentReportingServiceEnabled()) {
240 incident_service_.reset(new safe_browsing::IncidentReportingService( 241 incident_service_.reset(new safe_browsing::IncidentReportingService(
241 this, url_request_context_getter_)); 242 this, url_request_context_getter_));
242 } 243 }
244
245 off_domain_inclusion_detector_.reset(
246 new safe_browsing::OffDomainInclusionDetector);
243 #endif 247 #endif
244 248
245 // Track the safe browsing preference of existing profiles. 249 // Track the safe browsing preference of existing profiles.
246 // The SafeBrowsingService will be started if any existing profile has the 250 // The SafeBrowsingService will be started if any existing profile has the
247 // preference enabled. It will also listen for updates to the preferences. 251 // preference enabled. It will also listen for updates to the preferences.
248 ProfileManager* profile_manager = g_browser_process->profile_manager(); 252 ProfileManager* profile_manager = g_browser_process->profile_manager();
249 if (profile_manager) { 253 if (profile_manager) {
250 std::vector<Profile*> profiles = profile_manager->GetLoadedProfiles(); 254 std::vector<Profile*> profiles = profile_manager->GetLoadedProfiles();
251 for (size_t i = 0; i < profiles.size(); ++i) { 255 for (size_t i = 0; i < profiles.size(); ++i) {
252 if (profiles[i]->IsOffTheRecord()) 256 if (profiles[i]->IsOffTheRecord())
(...skipping 21 matching lines...) Expand all
274 278
275 // Remove Profile creation/destruction observers. 279 // Remove Profile creation/destruction observers.
276 prefs_registrar_.RemoveAll(); 280 prefs_registrar_.RemoveAll();
277 281
278 Stop(true); 282 Stop(true);
279 // The IO thread is going away, so make sure the ClientSideDetectionService 283 // The IO thread is going away, so make sure the ClientSideDetectionService
280 // dtor executes now since it may call the dtor of URLFetcher which relies 284 // dtor executes now since it may call the dtor of URLFetcher which relies
281 // on it. 285 // on it.
282 csd_service_.reset(); 286 csd_service_.reset();
283 incident_service_.reset(); 287 incident_service_.reset();
284 download_service_.reset(); 288 download_service_.reset();
grt (UTC plus 2) 2014/11/19 18:29:00 ? off_domain_inclusion_detector_.reset();
gab 2014/11/19 21:29:09 I had considered this but initially decided agains
285 289
286 url_request_context_getter_ = NULL; 290 url_request_context_getter_ = NULL;
287 BrowserThread::PostNonNestableTask( 291 BrowserThread::PostNonNestableTask(
288 BrowserThread::IO, FROM_HERE, 292 BrowserThread::IO, FROM_HERE,
289 base::Bind(&SafeBrowsingService::DestroyURLRequestContextOnIOThread, 293 base::Bind(&SafeBrowsingService::DestroyURLRequestContextOnIOThread,
290 this)); 294 this));
291 } 295 }
292 296
293 // Binhash verification is only enabled for UMA users for now. 297 // Binhash verification is only enabled for UMA users for now.
294 bool SafeBrowsingService::DownloadBinHashNeeded() const { 298 bool SafeBrowsingService::DownloadBinHashNeeded() const {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 } 352 }
349 353
350 void SafeBrowsingService::AddDownloadManager( 354 void SafeBrowsingService::AddDownloadManager(
351 content::DownloadManager* download_manager) { 355 content::DownloadManager* download_manager) {
352 #if defined(FULL_SAFE_BROWSING) 356 #if defined(FULL_SAFE_BROWSING)
353 if (incident_service_) 357 if (incident_service_)
354 incident_service_->AddDownloadManager(download_manager); 358 incident_service_->AddDownloadManager(download_manager);
355 #endif 359 #endif
356 } 360 }
357 361
362 void SafeBrowsingService::OnResourceRequest(const net::URLRequest* request) {
363 #if defined(FULL_SAFE_BROWSING)
364 if (off_domain_inclusion_detector_)
365 off_domain_inclusion_detector_->OnResourceRequest(request);
366 #endif
367 }
368
358 SafeBrowsingUIManager* SafeBrowsingService::CreateUIManager() { 369 SafeBrowsingUIManager* SafeBrowsingService::CreateUIManager() {
359 return new SafeBrowsingUIManager(this); 370 return new SafeBrowsingUIManager(this);
360 } 371 }
361 372
362 SafeBrowsingDatabaseManager* SafeBrowsingService::CreateDatabaseManager() { 373 SafeBrowsingDatabaseManager* SafeBrowsingService::CreateDatabaseManager() {
363 #if defined(FULL_SAFE_BROWSING) 374 #if defined(FULL_SAFE_BROWSING)
364 return new SafeBrowsingDatabaseManager(this); 375 return new SafeBrowsingDatabaseManager(this);
365 #else 376 #else
366 return NULL; 377 return NULL;
367 #endif 378 #endif
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 else 580 else
570 Stop(false); 581 Stop(false);
571 582
572 #if defined(FULL_SAFE_BROWSING) 583 #if defined(FULL_SAFE_BROWSING)
573 if (csd_service_) 584 if (csd_service_)
574 csd_service_->SetEnabledAndRefreshState(enable); 585 csd_service_->SetEnabledAndRefreshState(enable);
575 if (download_service_) 586 if (download_service_)
576 download_service_->SetEnabled(enable); 587 download_service_->SetEnabled(enable);
577 #endif 588 #endif
578 } 589 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698