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

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

Issue 845663004: Initial script request detector. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: grt feedback, switch to gmock Created 5 years, 10 months 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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()));
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
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();
281 incident_service_.reset(); 286 incident_service_.reset();
282 #endif 287 #endif
283 288
284 download_service_.reset(); 289 download_service_.reset();
285 290
286 url_request_context_getter_ = NULL; 291 url_request_context_getter_ = NULL;
287 BrowserThread::PostNonNestableTask( 292 BrowserThread::PostNonNestableTask(
288 BrowserThread::IO, FROM_HERE, 293 BrowserThread::IO, FROM_HERE,
289 base::Bind(&SafeBrowsingService::DestroyURLRequestContextOnIOThread, 294 base::Bind(&SafeBrowsingService::DestroyURLRequestContextOnIOThread,
290 this)); 295 this));
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 #if defined(FULL_SAFE_BROWSING) 357 #if defined(FULL_SAFE_BROWSING)
353 if (incident_service_) 358 if (incident_service_)
354 incident_service_->AddDownloadManager(download_manager); 359 incident_service_->AddDownloadManager(download_manager);
355 #endif 360 #endif
356 } 361 }
357 362
358 void SafeBrowsingService::OnResourceRequest(const net::URLRequest* request) { 363 void SafeBrowsingService::OnResourceRequest(const net::URLRequest* request) {
359 #if defined(FULL_SAFE_BROWSING) 364 #if defined(FULL_SAFE_BROWSING)
360 if (off_domain_inclusion_detector_) 365 if (off_domain_inclusion_detector_)
361 off_domain_inclusion_detector_->OnResourceRequest(request); 366 off_domain_inclusion_detector_->OnResourceRequest(request);
367 if (script_request_detector_)
368 script_request_detector_->OnResourceRequest(request);
362 #endif 369 #endif
363 } 370 }
364 371
365 SafeBrowsingUIManager* SafeBrowsingService::CreateUIManager() { 372 SafeBrowsingUIManager* SafeBrowsingService::CreateUIManager() {
366 return new SafeBrowsingUIManager(this); 373 return new SafeBrowsingUIManager(this);
367 } 374 }
368 375
369 SafeBrowsingDatabaseManager* SafeBrowsingService::CreateDatabaseManager() { 376 SafeBrowsingDatabaseManager* SafeBrowsingService::CreateDatabaseManager() {
370 #if defined(FULL_SAFE_BROWSING) 377 #if defined(FULL_SAFE_BROWSING)
371 return new SafeBrowsingDatabaseManager(this); 378 return new SafeBrowsingDatabaseManager(this);
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 else 584 else
578 Stop(false); 585 Stop(false);
579 586
580 #if defined(FULL_SAFE_BROWSING) 587 #if defined(FULL_SAFE_BROWSING)
581 if (csd_service_) 588 if (csd_service_)
582 csd_service_->SetEnabledAndRefreshState(enable); 589 csd_service_->SetEnabledAndRefreshState(enable);
583 if (download_service_) 590 if (download_service_)
584 download_service_->SetEnabled(enable); 591 download_service_->SetEnabled(enable);
585 #endif 592 #endif
586 } 593 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698