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

Side by Side Diff: chrome/browser/chromeos/arc/arc_auth_service.cc

Issue 2771943003: arc: Skip GMS Sign-In in case Android is already signed-in. (Closed)
Patch Set: use sparse UMA Created 3 years, 8 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/chromeos/arc/arc_auth_service.h" 5 #include "chrome/browser/chromeos/arc/arc_auth_service.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 const GetAuthCodeAndAccountTypeDeprecatedCallback& auth_account_callback) 83 const GetAuthCodeAndAccountTypeDeprecatedCallback& auth_account_callback)
84 : callback_type_(CallbackType::AUTH_CODE_AND_ACCOUNT), 84 : callback_type_(CallbackType::AUTH_CODE_AND_ACCOUNT),
85 auth_account_callback_(auth_account_callback) {} 85 auth_account_callback_(auth_account_callback) {}
86 86
87 explicit AccountInfoNotifier(const AccountInfoCallback& account_info_callback) 87 explicit AccountInfoNotifier(const AccountInfoCallback& account_info_callback)
88 : callback_type_(CallbackType::ACCOUNT_INFO), 88 : callback_type_(CallbackType::ACCOUNT_INFO),
89 account_info_callback_(account_info_callback) {} 89 account_info_callback_(account_info_callback) {}
90 90
91 void Notify(bool is_enforced, 91 void Notify(bool is_enforced,
92 const std::string& auth_info, 92 const std::string& auth_info,
93 const std::string& account_name,
93 mojom::ChromeAccountType account_type, 94 mojom::ChromeAccountType account_type,
94 bool is_managed) { 95 bool is_managed) {
95 switch (callback_type_) { 96 switch (callback_type_) {
96 case CallbackType::AUTH_CODE: 97 case CallbackType::AUTH_CODE:
97 DCHECK(!auth_callback_.is_null()); 98 DCHECK(!auth_callback_.is_null());
98 auth_callback_.Run(auth_info, is_enforced); 99 auth_callback_.Run(auth_info, is_enforced);
99 break; 100 break;
100 case CallbackType::AUTH_CODE_AND_ACCOUNT: 101 case CallbackType::AUTH_CODE_AND_ACCOUNT:
101 DCHECK(!auth_account_callback_.is_null()); 102 DCHECK(!auth_account_callback_.is_null());
102 auth_account_callback_.Run(auth_info, is_enforced, account_type); 103 auth_account_callback_.Run(auth_info, is_enforced, account_type);
103 break; 104 break;
104 case CallbackType::ACCOUNT_INFO: 105 case CallbackType::ACCOUNT_INFO:
105 DCHECK(!account_info_callback_.is_null()); 106 DCHECK(!account_info_callback_.is_null());
106 mojom::AccountInfoPtr account_info = mojom::AccountInfo::New(); 107 mojom::AccountInfoPtr account_info = mojom::AccountInfo::New();
108 account_info->account_name = account_name;
107 if (account_type == 109 if (account_type ==
108 mojom::ChromeAccountType::ACTIVE_DIRECTORY_ACCOUNT) { 110 mojom::ChromeAccountType::ACTIVE_DIRECTORY_ACCOUNT) {
109 account_info->enrollment_token = auth_info; 111 account_info->enrollment_token = auth_info;
110 } else { 112 } else {
111 if (!is_enforced) 113 if (!is_enforced)
112 account_info->auth_code = base::nullopt; 114 account_info->auth_code = base::nullopt;
113 else 115 else
114 account_info->auth_code = auth_info; 116 account_info->auth_code = auth_info;
115 } 117 }
116 account_info->account_type = account_type; 118 account_info->account_type = account_type;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 UpdateAuthCheckinAttempts(value); 190 UpdateAuthCheckinAttempts(value);
189 break; 191 break;
190 case mojom::MetricsType::CHECKIN_TIME_MILLISECONDS: 192 case mojom::MetricsType::CHECKIN_TIME_MILLISECONDS:
191 UpdateAuthTiming("ArcAuth.CheckinTime", 193 UpdateAuthTiming("ArcAuth.CheckinTime",
192 base::TimeDelta::FromMilliseconds(value)); 194 base::TimeDelta::FromMilliseconds(value));
193 break; 195 break;
194 case mojom::MetricsType::SIGNIN_TIME_MILLISECONDS: 196 case mojom::MetricsType::SIGNIN_TIME_MILLISECONDS:
195 UpdateAuthTiming("ArcAuth.SignInTime", 197 UpdateAuthTiming("ArcAuth.SignInTime",
196 base::TimeDelta::FromMilliseconds(value)); 198 base::TimeDelta::FromMilliseconds(value));
197 break; 199 break;
200 case mojom::MetricsType::ACCOUNT_CHECK_MILLISECONDS:
201 UpdateAuthTiming("ArcAuth.AccountCheckTime",
202 base::TimeDelta::FromMilliseconds(value));
203 break;
198 } 204 }
199 } 205 }
200 206
207 void ArcAuthService::ReportAccountCheckStatus(
208 mojom::AccountCheckStatus status) {
209 UpdateAuthAccountCheckStatus(status);
210 }
211
201 void ArcAuthService::OnAccountInfoReady(mojom::AccountInfoPtr account_info) { 212 void ArcAuthService::OnAccountInfoReady(mojom::AccountInfoPtr account_info) {
202 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 213 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
203 auto* instance = ARC_GET_INSTANCE_FOR_METHOD(arc_bridge_service()->auth(), 214 auto* instance = ARC_GET_INSTANCE_FOR_METHOD(arc_bridge_service()->auth(),
204 OnAccountInfoReady); 215 OnAccountInfoReady);
205 DCHECK(instance); 216 DCHECK(instance);
206 instance->OnAccountInfoReady(std::move(account_info)); 217 instance->OnAccountInfoReady(std::move(account_info));
207 } 218 }
208 219
209 void ArcAuthService::GetAuthCodeDeprecated0( 220 void ArcAuthService::GetAuthCodeDeprecated0(
210 const GetAuthCodeDeprecated0Callback& callback) { 221 const GetAuthCodeDeprecated0Callback& callback) {
(...skipping 25 matching lines...) Expand all
236 247
237 void ArcAuthService::RequestAccountInfoInternal( 248 void ArcAuthService::RequestAccountInfoInternal(
238 std::unique_ptr<AccountInfoNotifier> notifier) { 249 std::unique_ptr<AccountInfoNotifier> notifier) {
239 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 250 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
240 // No other auth code-related operation may be in progress. 251 // No other auth code-related operation may be in progress.
241 DCHECK(!notifier_); 252 DCHECK(!notifier_);
242 DCHECK(!fetcher_); 253 DCHECK(!fetcher_);
243 254
244 if (IsArcOptInVerificationDisabled()) { 255 if (IsArcOptInVerificationDisabled()) {
245 notifier->Notify( 256 notifier->Notify(
246 false /* = is_enforced */, std::string(), GetAccountType(), 257 false /* = is_enforced */, std::string() /* auth_info */,
258 std::string() /* auth_name */, GetAccountType(),
247 policy_util::IsAccountManaged(ArcSessionManager::Get()->profile())); 259 policy_util::IsAccountManaged(ArcSessionManager::Get()->profile()));
248 return; 260 return;
249 } 261 }
250 262
251 // Hereafter asynchronous operation. Remember the notifier. 263 // Hereafter asynchronous operation. Remember the notifier.
252 notifier_ = std::move(notifier); 264 notifier_ = std::move(notifier);
253 265
254 Profile* profile = ArcSessionManager::Get()->profile(); 266 Profile* profile = ArcSessionManager::Get()->profile();
255 const user_manager::User* user = nullptr; 267 const user_manager::User* user = nullptr;
256 if (profile) 268 if (profile)
257 user = chromeos::ProfileHelper::Get()->GetUserByProfile(profile); 269 user = chromeos::ProfileHelper::Get()->GetUserByProfile(profile);
270
258 if (user && user->IsActiveDirectoryUser()) { 271 if (user && user->IsActiveDirectoryUser()) {
259 // For Active Directory enrolled devices, we get an enrollment token for a 272 // For Active Directory enrolled devices, we get an enrollment token for a
260 // managed Google Play account from DMServer. 273 // managed Google Play account from DMServer.
261 fetcher_ = base::MakeUnique<ArcActiveDirectoryEnrollmentTokenFetcher>(); 274 fetcher_ = base::MakeUnique<ArcActiveDirectoryEnrollmentTokenFetcher>();
262 fetcher_->Fetch(base::Bind(&ArcAuthService::OnEnrollmentTokenFetched, 275 fetcher_->Fetch(base::Bind(&ArcAuthService::OnEnrollmentTokenFetched,
263 weak_ptr_factory_.GetWeakPtr())); 276 weak_ptr_factory_.GetWeakPtr()));
264 return; 277 return;
265 } 278 }
266 // For non-AD enrolled devices an auth code is fetched. 279 // For non-AD enrolled devices an auth code is fetched.
267 if (IsArcKioskMode()) { 280 if (IsArcKioskMode()) {
(...skipping 22 matching lines...) Expand all
290 303
291 void ArcAuthService::OnEnrollmentTokenFetched( 304 void ArcAuthService::OnEnrollmentTokenFetched(
292 ArcAuthInfoFetcher::Status status, 305 ArcAuthInfoFetcher::Status status,
293 const std::string& enrollment_token) { 306 const std::string& enrollment_token) {
294 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 307 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
295 fetcher_.reset(); 308 fetcher_.reset();
296 309
297 switch (status) { 310 switch (status) {
298 case ArcAuthInfoFetcher::Status::SUCCESS: 311 case ArcAuthInfoFetcher::Status::SUCCESS:
299 notifier_->Notify(true /*is_enforced*/, enrollment_token, 312 notifier_->Notify(true /*is_enforced*/, enrollment_token,
313 std::string() /* account_name */,
300 mojom::ChromeAccountType::ACTIVE_DIRECTORY_ACCOUNT, 314 mojom::ChromeAccountType::ACTIVE_DIRECTORY_ACCOUNT,
301 true); 315 true);
302 notifier_.reset(); 316 notifier_.reset();
303 return; 317 return;
304 case ArcAuthInfoFetcher::Status::FAILURE: 318 case ArcAuthInfoFetcher::Status::FAILURE:
305 ArcSessionManager::Get()->OnProvisioningFinished( 319 ArcSessionManager::Get()->OnProvisioningFinished(
306 ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR); 320 ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR);
307 return; 321 return;
308 case ArcAuthInfoFetcher::Status::ARC_DISABLED: 322 case ArcAuthInfoFetcher::Status::ARC_DISABLED:
309 ArcSessionManager::Get()->OnProvisioningFinished( 323 ArcSessionManager::Get()->OnProvisioningFinished(
310 ProvisioningResult::ARC_DISABLED); 324 ProvisioningResult::ARC_DISABLED);
311 return; 325 return;
312 } 326 }
313 } 327 }
314 328
315 void ArcAuthService::OnAuthCodeFetched(ArcAuthInfoFetcher::Status status, 329 void ArcAuthService::OnAuthCodeFetched(ArcAuthInfoFetcher::Status status,
316 const std::string& auth_code) { 330 const std::string& auth_code) {
317 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 331 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
318 fetcher_.reset(); 332 fetcher_.reset();
319 333
320 if (status != ArcAuthInfoFetcher::Status::SUCCESS) { 334 if (status != ArcAuthInfoFetcher::Status::SUCCESS) {
321 ArcSessionManager::Get()->OnProvisioningFinished( 335 ArcSessionManager::Get()->OnProvisioningFinished(
322 ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR); 336 ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR);
323 return; 337 return;
324 } 338 }
325 339
326 notifier_->Notify( 340 notifier_->Notify(
327 !IsArcOptInVerificationDisabled(), auth_code, GetAccountType(), 341 !IsArcOptInVerificationDisabled(), auth_code,
342 ArcSessionManager::Get()->auth_context()->full_account_id(),
343 GetAccountType(),
328 policy_util::IsAccountManaged(ArcSessionManager::Get()->profile())); 344 policy_util::IsAccountManaged(ArcSessionManager::Get()->profile()));
329 notifier_.reset(); 345 notifier_.reset();
330 } 346 }
331 347
332 } // namespace arc 348 } // namespace arc
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/arc/arc_auth_service.h ('k') | chrome/browser/chromeos/arc/arc_optin_uma.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698