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

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

Issue 2912383004: Fill is_chrome_signin_password field in the password entry pings. (Closed)
Patch Set: address nparker's comments Created 3 years, 6 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/lazy_instance.h" 15 #include "base/lazy_instance.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/ptr_util.h" 17 #include "base/memory/ptr_util.h"
18 #include "base/metrics/histogram_macros.h" 18 #include "base/metrics/histogram_macros.h"
19 #include "base/path_service.h" 19 #include "base/path_service.h"
20 #include "base/strings/string_util.h" 20 #include "base/strings/string_util.h"
21 #include "base/threading/thread.h" 21 #include "base/threading/thread.h"
22 #include "base/threading/thread_restrictions.h" 22 #include "base/threading/thread_restrictions.h"
23 #include "base/trace_event/trace_event.h" 23 #include "base/trace_event/trace_event.h"
24 #include "build/build_config.h" 24 #include "build/build_config.h"
25 #include "chrome/browser/browser_process.h" 25 #include "chrome/browser/browser_process.h"
26 #include "chrome/browser/chrome_notification_types.h" 26 #include "chrome/browser/chrome_notification_types.h"
27 #include "chrome/browser/profiles/profile.h" 27 #include "chrome/browser/profiles/profile.h"
28 #include "chrome/browser/profiles/profile_manager.h" 28 #include "chrome/browser/profiles/profile_manager.h"
29 #include "chrome/browser/safe_browsing/chrome_password_protection_service.h"
30 #include "chrome/browser/safe_browsing/ping_manager.h" 29 #include "chrome/browser/safe_browsing/ping_manager.h"
31 #include "chrome/browser/safe_browsing/safe_browsing_navigation_observer_manager .h" 30 #include "chrome/browser/safe_browsing/safe_browsing_navigation_observer_manager .h"
32 #include "chrome/browser/safe_browsing/ui_manager.h" 31 #include "chrome/browser/safe_browsing/ui_manager.h"
33 #include "chrome/common/chrome_paths.h" 32 #include "chrome/common/chrome_paths.h"
34 #include "chrome/common/chrome_switches.h" 33 #include "chrome/common/chrome_switches.h"
35 #include "chrome/common/pref_names.h" 34 #include "chrome/common/pref_names.h"
36 #include "chrome/common/safe_browsing/file_type_policies.h" 35 #include "chrome/common/safe_browsing/file_type_policies.h"
37 #include "components/prefs/pref_change_registrar.h" 36 #include "components/prefs/pref_change_registrar.h"
38 #include "components/prefs/pref_service.h" 37 #include "components/prefs/pref_service.h"
39 #include "components/safe_browsing/browser/safe_browsing_url_request_context_get ter.h" 38 #include "components/safe_browsing/browser/safe_browsing_url_request_context_get ter.h"
(...skipping 24 matching lines...) Expand all
64 #if defined(FULL_SAFE_BROWSING) 63 #if defined(FULL_SAFE_BROWSING)
65 #include "chrome/browser/safe_browsing/client_side_detection_service.h" 64 #include "chrome/browser/safe_browsing/client_side_detection_service.h"
66 #include "chrome/browser/safe_browsing/download_protection_service.h" 65 #include "chrome/browser/safe_browsing/download_protection_service.h"
67 #include "chrome/browser/safe_browsing/incident_reporting/binary_integrity_analy zer.h" 66 #include "chrome/browser/safe_browsing/incident_reporting/binary_integrity_analy zer.h"
68 #include "chrome/browser/safe_browsing/incident_reporting/blacklist_load_analyze r.h" 67 #include "chrome/browser/safe_browsing/incident_reporting/blacklist_load_analyze r.h"
69 #include "chrome/browser/safe_browsing/incident_reporting/incident_reporting_ser vice.h" 68 #include "chrome/browser/safe_browsing/incident_reporting/incident_reporting_ser vice.h"
70 #include "chrome/browser/safe_browsing/incident_reporting/module_load_analyzer.h " 69 #include "chrome/browser/safe_browsing/incident_reporting/module_load_analyzer.h "
71 #include "chrome/browser/safe_browsing/incident_reporting/resource_request_detec tor.h" 70 #include "chrome/browser/safe_browsing/incident_reporting/resource_request_detec tor.h"
72 #include "chrome/browser/safe_browsing/incident_reporting/variations_seed_signat ure_analyzer.h" 71 #include "chrome/browser/safe_browsing/incident_reporting/variations_seed_signat ure_analyzer.h"
73 #include "chrome/browser/safe_browsing/protocol_manager.h" 72 #include "chrome/browser/safe_browsing/protocol_manager.h"
73 #include "components/safe_browsing/password_protection/password_protection_servi ce.h"
74 #endif 74 #endif
75 75
76 using content::BrowserThread; 76 using content::BrowserThread;
77 77
78 namespace safe_browsing { 78 namespace safe_browsing {
79 79
80 namespace { 80 namespace {
81 81
82 // The default URL prefix where browser fetches chunk updates, hashes, 82 // The default URL prefix where browser fetches chunk updates, hashes,
83 // and reports safe browsing hits and malware details. 83 // and reports safe browsing hits and malware details.
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 DCHECK_CURRENTLY_ON(BrowserThread::UI); 201 DCHECK_CURRENTLY_ON(BrowserThread::UI);
202 shutdown_callback_list_.Notify(); 202 shutdown_callback_list_.Notify();
203 203
204 // Remove Profile creation/destruction observers. 204 // Remove Profile creation/destruction observers.
205 profiles_registrar_.RemoveAll(); 205 profiles_registrar_.RemoveAll();
206 206
207 // Delete the PrefChangeRegistrars, whose dtors also unregister |this| as an 207 // Delete the PrefChangeRegistrars, whose dtors also unregister |this| as an
208 // observer of the preferences. 208 // observer of the preferences.
209 prefs_map_.clear(); 209 prefs_map_.clear();
210 210
211 // Delete the ChromePasswordProtectionService instances.
212 password_protection_service_map_.clear();
213
214 Stop(true); 211 Stop(true);
215 212
216 services_delegate_->ShutdownServices(); 213 services_delegate_->ShutdownServices();
217 214
218 // Since URLRequestContextGetters are refcounted, can't count on clearing 215 // Since URLRequestContextGetters are refcounted, can't count on clearing
219 // |url_request_context_getter_| to delete it, so need to shut it down first, 216 // |url_request_context_getter_| to delete it, so need to shut it down first,
220 // which will cancel any requests that are currently using it, and prevent 217 // which will cancel any requests that are currently using it, and prevent
221 // new requests from using it as well. 218 // new requests from using it as well.
222 BrowserThread::PostNonNestableTask( 219 BrowserThread::PostNonNestableTask(
223 BrowserThread::IO, FROM_HERE, 220 BrowserThread::IO, FROM_HERE,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 return services_delegate_->v4_local_database_manager(); 287 return services_delegate_->v4_local_database_manager();
291 } 288 }
292 289
293 TriggerManager* SafeBrowsingService::trigger_manager() const { 290 TriggerManager* SafeBrowsingService::trigger_manager() const {
294 DCHECK_CURRENTLY_ON(BrowserThread::UI); 291 DCHECK_CURRENTLY_ON(BrowserThread::UI);
295 return trigger_manager_.get(); 292 return trigger_manager_.get();
296 } 293 }
297 294
298 PasswordProtectionService* SafeBrowsingService::GetPasswordProtectionService( 295 PasswordProtectionService* SafeBrowsingService::GetPasswordProtectionService(
299 Profile* profile) const { 296 Profile* profile) const {
300 DCHECK(profile); 297 return services_delegate_->GetPasswordProtectionService(profile);
301 auto it = password_protection_service_map_.find(profile);
302 DCHECK(it != password_protection_service_map_.end());
303 return it->second.get();
304 } 298 }
305 299
306 std::unique_ptr<prefs::mojom::TrackedPreferenceValidationDelegate> 300 std::unique_ptr<prefs::mojom::TrackedPreferenceValidationDelegate>
307 SafeBrowsingService::CreatePreferenceValidationDelegate( 301 SafeBrowsingService::CreatePreferenceValidationDelegate(
308 Profile* profile) const { 302 Profile* profile) const {
309 return services_delegate_->CreatePreferenceValidationDelegate(profile); 303 return services_delegate_->CreatePreferenceValidationDelegate(profile);
310 } 304 }
311 305
312 void SafeBrowsingService::RegisterDelayedAnalysisCallback( 306 void SafeBrowsingService::RegisterDelayedAnalysisCallback(
313 const DelayedAnalysisCallback& callback) { 307 const DelayedAnalysisCallback& callback) {
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 base::BindOnce(&SafeBrowsingService::StopOnIOThread, this, shutdown)); 489 base::BindOnce(&SafeBrowsingService::StopOnIOThread, this, shutdown));
496 } 490 }
497 491
498 void SafeBrowsingService::Observe(int type, 492 void SafeBrowsingService::Observe(int type,
499 const content::NotificationSource& source, 493 const content::NotificationSource& source,
500 const content::NotificationDetails& details) { 494 const content::NotificationDetails& details) {
501 switch (type) { 495 switch (type) {
502 case chrome::NOTIFICATION_PROFILE_CREATED: { 496 case chrome::NOTIFICATION_PROFILE_CREATED: {
503 DCHECK_CURRENTLY_ON(BrowserThread::UI); 497 DCHECK_CURRENTLY_ON(BrowserThread::UI);
504 Profile* profile = content::Source<Profile>(source).ptr(); 498 Profile* profile = content::Source<Profile>(source).ptr();
505 CreatePasswordProtectionService(profile); 499 services_delegate_->CreatePasswordProtectionService(profile);
506 if (!profile->IsOffTheRecord()) 500 if (!profile->IsOffTheRecord())
507 AddPrefService(profile->GetPrefs()); 501 AddPrefService(profile->GetPrefs());
508 break; 502 break;
509 } 503 }
510 case chrome::NOTIFICATION_PROFILE_DESTROYED: { 504 case chrome::NOTIFICATION_PROFILE_DESTROYED: {
511 DCHECK_CURRENTLY_ON(BrowserThread::UI); 505 DCHECK_CURRENTLY_ON(BrowserThread::UI);
512 Profile* profile = content::Source<Profile>(source).ptr(); 506 Profile* profile = content::Source<Profile>(source).ptr();
513 RemovePasswordProtectionService(profile); 507 services_delegate_->RemovePasswordProtectionService(profile);
514 if (!profile->IsOffTheRecord()) 508 if (!profile->IsOffTheRecord())
515 RemovePrefService(profile->GetPrefs()); 509 RemovePrefService(profile->GetPrefs());
516 break; 510 break;
517 } 511 }
518 default: 512 default:
519 NOTREACHED(); 513 NOTREACHED();
520 } 514 }
521 } 515 }
522 516
523 void SafeBrowsingService::AddPrefService(PrefService* pref_service) { 517 void SafeBrowsingService::AddPrefService(PrefService* pref_service) {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 if (ping_manager()) 608 if (ping_manager())
615 ping_manager()->ReportThreatDetails(report); 609 ping_manager()->ReportThreatDetails(report);
616 } 610 }
617 611
618 void SafeBrowsingService::ProcessResourceRequest( 612 void SafeBrowsingService::ProcessResourceRequest(
619 const ResourceRequestInfo& request) { 613 const ResourceRequestInfo& request) {
620 DCHECK_CURRENTLY_ON(BrowserThread::UI); 614 DCHECK_CURRENTLY_ON(BrowserThread::UI);
621 services_delegate_->ProcessResourceRequest(&request); 615 services_delegate_->ProcessResourceRequest(&request);
622 } 616 }
623 617
624 void SafeBrowsingService::CreatePasswordProtectionService(Profile* profile) {
625 DCHECK_CURRENTLY_ON(BrowserThread::UI);
626 DCHECK(profile);
627 auto it = password_protection_service_map_.find(profile);
628 DCHECK(it == password_protection_service_map_.end());
629 std::unique_ptr<ChromePasswordProtectionService> service =
630 base::MakeUnique<ChromePasswordProtectionService>(this, profile);
631 password_protection_service_map_[profile] = std::move(service);
632 }
633
634 void SafeBrowsingService::RemovePasswordProtectionService(Profile* profile) {
635 DCHECK_CURRENTLY_ON(BrowserThread::UI);
636 DCHECK(profile);
637 auto it = password_protection_service_map_.find(profile);
638 if (it != password_protection_service_map_.end())
639 password_protection_service_map_.erase(it);
640 }
641
642 void SafeBrowsingService::CreateTriggerManager() { 618 void SafeBrowsingService::CreateTriggerManager() {
643 DCHECK_CURRENTLY_ON(BrowserThread::UI); 619 DCHECK_CURRENTLY_ON(BrowserThread::UI);
644 trigger_manager_ = base::MakeUnique<TriggerManager>(ui_manager_.get()); 620 trigger_manager_ = base::MakeUnique<TriggerManager>(ui_manager_.get());
645 } 621 }
646 } // namespace safe_browsing 622 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_service.h ('k') | chrome/browser/safe_browsing/services_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698