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

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

Issue 2949243004: Distinguish G Suite accounts from regular gmail/googlemail accounts (Closed)
Patch Set: nits Created 3 years, 5 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/chrome_password_protection_service.h" 5 #include "chrome/browser/safe_browsing/chrome_password_protection_service.h"
6 6
7 #include "base/feature_list.h" 7 #include "base/feature_list.h"
8 #include "base/metrics/field_trial_params.h" 8 #include "base/metrics/field_trial_params.h"
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
11 #include "chrome/browser/history/history_service_factory.h" 11 #include "chrome/browser/history/history_service_factory.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/safe_browsing/safe_browsing_navigation_observer_manager .h" 13 #include "chrome/browser/safe_browsing/safe_browsing_navigation_observer_manager .h"
14 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 14 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
15 #include "chrome/browser/safe_browsing/ui_manager.h" 15 #include "chrome/browser/safe_browsing/ui_manager.h"
16 #include "chrome/browser/signin/account_tracker_service_factory.h"
17 #include "chrome/browser/signin/signin_manager_factory.h"
16 #include "chrome/browser/sync/profile_sync_service_factory.h" 18 #include "chrome/browser/sync/profile_sync_service_factory.h"
17 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
18 #include "components/browser_sync/profile_sync_service.h" 20 #include "components/browser_sync/profile_sync_service.h"
19 #include "components/prefs/pref_service.h" 21 #include "components/prefs/pref_service.h"
20 #include "components/safe_browsing/common/safe_browsing_prefs.h" 22 #include "components/safe_browsing/common/safe_browsing_prefs.h"
21 #include "components/safe_browsing/password_protection/password_protection_reque st.h" 23 #include "components/safe_browsing/password_protection/password_protection_reque st.h"
22 #include "components/safe_browsing_db/database_manager.h" 24 #include "components/safe_browsing_db/database_manager.h"
25 #include "components/signin/core/browser/account_info.h"
26 #include "components/signin/core/browser/account_tracker_service.h"
27 #include "components/signin/core/browser/signin_manager.h"
23 #include "content/public/browser/render_frame_host.h" 28 #include "content/public/browser/render_frame_host.h"
24 #include "content/public/browser/render_process_host.h" 29 #include "content/public/browser/render_process_host.h"
25 #include "content/public/browser/web_contents.h" 30 #include "content/public/browser/web_contents.h"
26 31
27 using content::BrowserThread; 32 using content::BrowserThread;
28 33
29 namespace safe_browsing { 34 namespace safe_browsing {
30 35
31 namespace { 36 namespace {
32 37
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 return allowed_all_population; 142 return allowed_all_population;
138 } 143 }
139 144
140 bool ChromePasswordProtectionService::IsHistorySyncEnabled() { 145 bool ChromePasswordProtectionService::IsHistorySyncEnabled() {
141 browser_sync::ProfileSyncService* sync = 146 browser_sync::ProfileSyncService* sync =
142 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_); 147 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_);
143 return sync && sync->IsSyncActive() && !sync->IsLocalSyncEnabled() && 148 return sync && sync->IsSyncActive() && !sync->IsLocalSyncEnabled() &&
144 sync->GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES); 149 sync->GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES);
145 } 150 }
146 151
152 PasswordProtectionService::SyncAccountType
153 ChromePasswordProtectionService::GetSyncAccountType() {
154 DCHECK(profile_);
155 SigninManagerBase* signin_manager =
156 SigninManagerFactory::GetForProfileIfExists(profile_);
157
158 if (!signin_manager)
159 return LoginReputationClientRequest::PasswordReuseEvent::NOT_SIGNED_IN;
160
161 AccountInfo account_info = signin_manager->GetAuthenticatedAccountInfo();
162
163 if (account_info.account_id.empty() || account_info.hosted_domain.empty()) {
164 return LoginReputationClientRequest::PasswordReuseEvent::NOT_SIGNED_IN;
165 }
166
167 // For gmail or googlemail account, the hosted_domain will always be
168 // kNoHostedDomainFound.
169 return account_info.hosted_domain ==
170 std::string(AccountTrackerService::kNoHostedDomainFound)
171 ? LoginReputationClientRequest::PasswordReuseEvent::GMAIL
172 : LoginReputationClientRequest::PasswordReuseEvent::GSUITE;
173 }
174
147 void ChromePasswordProtectionService::ShowPhishingInterstitial( 175 void ChromePasswordProtectionService::ShowPhishingInterstitial(
148 const GURL& phishing_url, 176 const GURL& phishing_url,
149 const std::string& token, 177 const std::string& token,
150 content::WebContents* web_contents) { 178 content::WebContents* web_contents) {
151 DCHECK_CURRENTLY_ON(BrowserThread::UI); 179 DCHECK_CURRENTLY_ON(BrowserThread::UI);
152 if (!ui_manager_) 180 if (!ui_manager_)
153 return; 181 return;
154 security_interstitials::UnsafeResource resource; 182 security_interstitials::UnsafeResource resource;
155 resource.url = phishing_url; 183 resource.url = phishing_url;
156 resource.original_url = phishing_url; 184 resource.original_url = phishing_url;
(...skipping 10 matching lines...) Expand all
167 web_contents->GetController().DiscardNonCommittedEntries(); 195 web_contents->GetController().DiscardNonCommittedEntries();
168 } 196 }
169 ui_manager_->DisplayBlockingPage(resource); 197 ui_manager_->DisplayBlockingPage(resource);
170 } 198 }
171 199
172 ChromePasswordProtectionService::ChromePasswordProtectionService( 200 ChromePasswordProtectionService::ChromePasswordProtectionService(
173 Profile* profile) 201 Profile* profile)
174 : PasswordProtectionService(nullptr, nullptr, nullptr, nullptr), 202 : PasswordProtectionService(nullptr, nullptr, nullptr, nullptr),
175 profile_(profile) {} 203 profile_(profile) {}
176 } // namespace safe_browsing 204 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698