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

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: Rebase 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() {
Jialiu Lin 2017/06/23 15:08:16 +rogerta@, Does this function make sense? Thanks
Jialiu Lin 2017/06/26 17:42:17 Done.
154 DCHECK(profile_);
155 SigninManagerBase* signin_manager =
156 SigninManagerFactory::GetForProfileIfExists(profile_);
157
158 AccountTrackerService* account_tracker =
159 AccountTrackerServiceFactory::GetForProfile(profile_);
160 if (!signin_manager || !account_tracker)
161 return LoginReputationClientRequest_PasswordReuseEvent::NOT_SIGNED_IN;
162
163 AccountInfo account_info = account_tracker->GetAccountInfo(
164 signin_manager->GetAuthenticatedAccountId());
Roger Tawa OOO till Jul 10th 2017/06/23 15:25:38 No need to get the account tracker in this case.
Jialiu Lin 2017/06/23 15:34:34 Ah, that simplifies things. Good to know! Thanks!
165
166 if (account_info.account_id.empty())
167 return LoginReputationClientRequest::PasswordReuseEvent::NOT_SIGNED_IN;
168
169 if (account_info.hosted_domain.empty() ||
170 account_info.hosted_domain ==
171 std::string(AccountTrackerService::kNoHostedDomainFound)) {
Roger Tawa OOO till Jul 10th 2017/06/23 15:25:38 In theory "kNoHostedDomainFound" means we don't kn
Jialiu Lin 2017/06/23 15:34:34 Oh, I misunderstood. In that case, I'd better trea
Jialiu Lin 2017/06/26 17:42:17 Resolved with mlerman offline. For gmail/googlemai
172 return LoginReputationClientRequest_PasswordReuseEvent::GMAIL;
173 }
174
175 return account_info.hosted_domain == "google.com"
176 ? LoginReputationClientRequest_PasswordReuseEvent::GOOGLE
177 : LoginReputationClientRequest_PasswordReuseEvent::DASHER;
178 }
179
147 void ChromePasswordProtectionService::ShowPhishingInterstitial( 180 void ChromePasswordProtectionService::ShowPhishingInterstitial(
148 const GURL& phishing_url, 181 const GURL& phishing_url,
149 const std::string& token, 182 const std::string& token,
150 content::WebContents* web_contents) { 183 content::WebContents* web_contents) {
151 DCHECK_CURRENTLY_ON(BrowserThread::UI); 184 DCHECK_CURRENTLY_ON(BrowserThread::UI);
152 if (!ui_manager_) 185 if (!ui_manager_)
153 return; 186 return;
154 security_interstitials::UnsafeResource resource; 187 security_interstitials::UnsafeResource resource;
155 resource.url = phishing_url; 188 resource.url = phishing_url;
156 resource.original_url = phishing_url; 189 resource.original_url = phishing_url;
(...skipping 10 matching lines...) Expand all
167 web_contents->GetController().DiscardNonCommittedEntries(); 200 web_contents->GetController().DiscardNonCommittedEntries();
168 } 201 }
169 ui_manager_->DisplayBlockingPage(resource); 202 ui_manager_->DisplayBlockingPage(resource);
170 } 203 }
171 204
172 ChromePasswordProtectionService::ChromePasswordProtectionService( 205 ChromePasswordProtectionService::ChromePasswordProtectionService(
173 Profile* profile) 206 Profile* profile)
174 : PasswordProtectionService(nullptr, nullptr, nullptr, nullptr), 207 : PasswordProtectionService(nullptr, nullptr, nullptr, nullptr),
175 profile_(profile) {} 208 profile_(profile) {}
176 } // namespace safe_browsing 209 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698