Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "ash/common/shelf/shelf_delegate.h" | 9 #include "ash/common/shelf/shelf_delegate.h" |
| 10 #include "ash/common/wm_shell.h" | 10 #include "ash/common/wm_shell.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 #include "content/public/browser/browser_thread.h" | 45 #include "content/public/browser/browser_thread.h" |
| 46 #include "extensions/browser/app_window/app_window_registry.h" | 46 #include "extensions/browser/app_window/app_window_registry.h" |
| 47 #include "extensions/browser/extension_prefs.h" | 47 #include "extensions/browser/extension_prefs.h" |
| 48 #include "extensions/browser/extension_registry.h" | 48 #include "extensions/browser/extension_registry.h" |
| 49 #include "ui/base/l10n/l10n_util.h" | 49 #include "ui/base/l10n/l10n_util.h" |
| 50 | 50 |
| 51 namespace arc { | 51 namespace arc { |
| 52 | 52 |
| 53 namespace { | 53 namespace { |
| 54 | 54 |
| 55 constexpr size_t kMinVersionForOnAccountInfoReady = 5; | |
| 56 | |
| 55 // Weak pointer. This class is owned by ArcServiceManager. | 57 // Weak pointer. This class is owned by ArcServiceManager. |
| 56 ArcAuthService* g_arc_auth_service = nullptr; | 58 ArcAuthService* g_arc_auth_service = nullptr; |
| 57 | 59 |
| 58 // Skip creating UI in unit tests | 60 // Skip creating UI in unit tests |
| 59 bool g_disable_ui_for_testing = false; | 61 bool g_disable_ui_for_testing = false; |
| 60 | 62 |
| 61 // Use specified ash::ShelfDelegate for unit tests. | 63 // Use specified ash::ShelfDelegate for unit tests. |
| 62 ash::ShelfDelegate* g_shelf_delegate_for_testing = nullptr; | 64 ash::ShelfDelegate* g_shelf_delegate_for_testing = nullptr; |
| 63 | 65 |
| 64 // The Android management check is disabled by default, it's used only for | 66 // The Android management check is disabled by default, it's used only for |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 MAP_PROVISIONING_RESULT(CLOUD_PROVISION_FLOW_INTERNAL_ERROR); | 108 MAP_PROVISIONING_RESULT(CLOUD_PROVISION_FLOW_INTERNAL_ERROR); |
| 107 } | 109 } |
| 108 #undef MAP_PROVISIONING_RESULT | 110 #undef MAP_PROVISIONING_RESULT |
| 109 | 111 |
| 110 NOTREACHED() << "unknown reason: " << static_cast<int>(reason); | 112 NOTREACHED() << "unknown reason: " << static_cast<int>(reason); |
| 111 return ProvisioningResult::UNKNOWN_ERROR; | 113 return ProvisioningResult::UNKNOWN_ERROR; |
| 112 } | 114 } |
| 113 | 115 |
| 114 } // namespace | 116 } // namespace |
| 115 | 117 |
| 118 class ArcAuthService::AccountInfoNotifier { | |
|
khmel
2016/11/03 20:16:45
nit: May be move to separate class to improve read
Luis Héctor Chávez
2016/11/04 15:43:13
Actually my goal is to eventually deprecate the ol
| |
| 119 public: | |
| 120 explicit AccountInfoNotifier( | |
| 121 const GetAuthCodeDeprecatedCallback& auth_callback) | |
| 122 : callback_type_(CallbackType::AUTH_CODE), | |
| 123 auth_callback_(auth_callback) {} | |
| 124 | |
| 125 explicit AccountInfoNotifier( | |
| 126 const GetAuthCodeAndAccountTypeDeprecatedCallback& auth_account_callback) | |
| 127 : callback_type_(CallbackType::AUTH_CODE_AND_ACCOUNT), | |
| 128 auth_account_callback_(auth_account_callback) {} | |
| 129 | |
| 130 explicit AccountInfoNotifier(const AccountInfoCallback& account_info_callback) | |
| 131 : callback_type_(CallbackType::ACCOUNT_INFO), | |
| 132 account_info_callback_(account_info_callback) {} | |
| 133 | |
| 134 void Notify(bool is_enforced, | |
| 135 const std::string& auth_code, | |
| 136 mojom::ChromeAccountType account_type, | |
| 137 bool is_managed) { | |
| 138 switch (callback_type_) { | |
| 139 case CallbackType::AUTH_CODE: | |
| 140 DCHECK(!auth_callback_.is_null()); | |
| 141 auth_callback_.Run(auth_code, is_enforced); | |
| 142 break; | |
| 143 case CallbackType::AUTH_CODE_AND_ACCOUNT: | |
| 144 DCHECK(!auth_account_callback_.is_null()); | |
| 145 auth_account_callback_.Run(auth_code, is_enforced, account_type); | |
| 146 break; | |
| 147 case CallbackType::ACCOUNT_INFO: | |
| 148 DCHECK(!account_info_callback_.is_null()); | |
| 149 mojom::AccountInfoPtr account_info = mojom::AccountInfo::New(); | |
| 150 if (!is_enforced) { | |
| 151 account_info->auth_code = nullptr; | |
| 152 } else { | |
| 153 account_info->auth_code = auth_code; | |
| 154 } | |
| 155 account_info->account_type = account_type; | |
| 156 account_info->is_managed = is_managed; | |
| 157 account_info_callback_.Run(std::move(account_info)); | |
| 158 break; | |
| 159 } | |
| 160 } | |
| 161 | |
| 162 private: | |
| 163 enum class CallbackType { AUTH_CODE, AUTH_CODE_AND_ACCOUNT, ACCOUNT_INFO }; | |
| 164 | |
| 165 const CallbackType callback_type_; | |
| 166 const GetAuthCodeDeprecatedCallback auth_callback_; | |
| 167 const GetAuthCodeAndAccountTypeDeprecatedCallback auth_account_callback_; | |
| 168 const AccountInfoCallback account_info_callback_; | |
| 169 }; | |
| 170 | |
| 116 ArcAuthService::ArcAuthService(ArcBridgeService* bridge_service) | 171 ArcAuthService::ArcAuthService(ArcBridgeService* bridge_service) |
| 117 : ArcService(bridge_service), binding_(this), weak_ptr_factory_(this) { | 172 : ArcService(bridge_service), binding_(this), weak_ptr_factory_(this) { |
| 118 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 173 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 119 DCHECK(!g_arc_auth_service); | 174 DCHECK(!g_arc_auth_service); |
| 120 | 175 |
| 121 g_arc_auth_service = this; | 176 g_arc_auth_service = this; |
| 122 | 177 |
| 123 arc_bridge_service()->AddObserver(this); | 178 arc_bridge_service()->AddObserver(this); |
| 124 arc_bridge_service()->auth()->AddObserver(this); | 179 arc_bridge_service()->auth()->AddObserver(this); |
| 125 } | 180 } |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 271 EnableArc(); | 326 EnableArc(); |
| 272 } | 327 } |
| 273 | 328 |
| 274 std::string ArcAuthService::GetAndResetAuthCode() { | 329 std::string ArcAuthService::GetAndResetAuthCode() { |
| 275 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 330 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 276 std::string auth_code; | 331 std::string auth_code; |
| 277 auth_code_.swap(auth_code); | 332 auth_code_.swap(auth_code); |
| 278 return auth_code; | 333 return auth_code; |
| 279 } | 334 } |
| 280 | 335 |
| 281 void ArcAuthService::GetAuthCodeDeprecated( | 336 void ArcAuthService::GetAuthCodeDeprecated0( |
| 282 const GetAuthCodeDeprecatedCallback& callback) { | 337 const GetAuthCodeDeprecated0Callback& callback) { |
| 283 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 338 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 284 DCHECK(!IsOptInVerificationDisabled()); | 339 DCHECK(!IsOptInVerificationDisabled()); |
| 285 callback.Run(GetAndResetAuthCode()); | 340 callback.Run(GetAndResetAuthCode()); |
| 286 } | 341 } |
| 287 | 342 |
| 288 void ArcAuthService::GetAuthCode(const GetAuthCodeCallback& callback) { | 343 void ArcAuthService::GetAuthCodeDeprecated( |
| 344 const GetAuthCodeDeprecatedCallback& callback) { | |
| 345 RequestAccountInfoInternal( | |
| 346 base::MakeUnique<ArcAuthService::AccountInfoNotifier>(callback)); | |
| 347 } | |
| 348 | |
| 349 void ArcAuthService::GetAuthCodeAndAccountTypeDeprecated( | |
| 350 const GetAuthCodeAndAccountTypeDeprecatedCallback& callback) { | |
| 351 RequestAccountInfoInternal( | |
| 352 base::MakeUnique<ArcAuthService::AccountInfoNotifier>(callback)); | |
| 353 } | |
| 354 | |
| 355 void ArcAuthService::RequestAccountInfo() { | |
| 356 RequestAccountInfoInternal( | |
| 357 base::MakeUnique<ArcAuthService::AccountInfoNotifier>( | |
| 358 base::Bind(&ArcAuthService::OnAccountInfoReady, | |
| 359 weak_ptr_factory_.GetWeakPtr()))); | |
| 360 } | |
| 361 | |
| 362 void ArcAuthService::OnAccountInfoReady(mojom::AccountInfoPtr account_info) { | |
| 289 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 363 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 290 // GetAuthCodeAndAccountType operation must not be in progress. | 364 auto* instance = arc_bridge_service()->auth()->GetInstanceForMethod( |
| 291 DCHECK(auth_account_callback_.is_null()); | 365 "OnAccountInfoReady", kMinVersionForOnAccountInfoReady); |
| 366 DCHECK(instance); | |
| 367 instance->OnAccountInfoReady(std::move(account_info)); | |
| 368 } | |
| 369 | |
| 370 void ArcAuthService::RequestAccountInfoInternal( | |
| 371 std::unique_ptr<ArcAuthService::AccountInfoNotifier> | |
| 372 account_info_notifier) { | |
| 373 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
| 374 // No other auth code-related operation may be in progress. | |
| 375 DCHECK(!account_info_notifier_); | |
| 292 | 376 |
| 293 const std::string auth_code = GetAndResetAuthCode(); | 377 const std::string auth_code = GetAndResetAuthCode(); |
| 294 const bool verification_disabled = IsOptInVerificationDisabled(); | 378 const bool is_enforced = !IsOptInVerificationDisabled(); |
| 295 if (!auth_code.empty() || verification_disabled) { | 379 if (!auth_code.empty() || !is_enforced) { |
| 296 callback.Run(auth_code, !verification_disabled); | 380 account_info_notifier->Notify(is_enforced, auth_code, |
| 381 mojom::ChromeAccountType::USER_ACCOUNT, | |
| 382 policy_util::IsAccountManaged(profile_)); | |
| 297 return; | 383 return; |
| 298 } | 384 } |
| 299 | 385 |
| 300 auth_callback_ = callback; | 386 account_info_notifier_ = std::move(account_info_notifier); |
| 301 PrepareContextForAuthCodeRequest(); | |
| 302 } | |
| 303 | |
| 304 void ArcAuthService::GetAuthCodeAndAccountType( | |
| 305 const GetAuthCodeAndAccountTypeCallback& callback) { | |
| 306 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
| 307 // GetAuthCode operation must not be in progress. | |
| 308 DCHECK(auth_callback_.is_null()); | |
| 309 | |
| 310 const std::string auth_code = GetAndResetAuthCode(); | |
| 311 const bool verification_disabled = IsOptInVerificationDisabled(); | |
| 312 if (!auth_code.empty() || verification_disabled) { | |
| 313 callback.Run(auth_code, !verification_disabled, | |
| 314 mojom::ChromeAccountType::USER_ACCOUNT); | |
| 315 return; | |
| 316 } | |
| 317 | |
| 318 auth_account_callback_ = callback; | |
| 319 PrepareContextForAuthCodeRequest(); | 387 PrepareContextForAuthCodeRequest(); |
| 320 } | 388 } |
| 321 | 389 |
| 322 bool ArcAuthService::IsAuthCodeRequest() const { | 390 bool ArcAuthService::IsAuthCodeRequest() const { |
| 323 return !auth_callback_.is_null() || !auth_account_callback_.is_null(); | 391 return account_info_notifier_ != nullptr; |
| 324 } | 392 } |
| 325 | 393 |
| 326 void ArcAuthService::PrepareContextForAuthCodeRequest() { | 394 void ArcAuthService::PrepareContextForAuthCodeRequest() { |
| 327 // Requesting auth code on demand happens in following cases: | 395 // Requesting auth code on demand happens in following cases: |
| 328 // 1. To handle account password revoke. | 396 // 1. To handle account password revoke. |
| 329 // 2. In case Arc is activated in OOBE flow. | 397 // 2. In case Arc is activated in OOBE flow. |
| 330 // 3. For any other state on Android side that leads device appears in | 398 // 3. For any other state on Android side that leads device appears in |
| 331 // non-signed state. | 399 // non-signed state. |
| 332 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 400 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 333 DCHECK(IsAuthCodeRequest()); | 401 DCHECK(IsAuthCodeRequest()); |
| 334 DCHECK_EQ(state_, State::ACTIVE); | 402 DCHECK_EQ(state_, State::ACTIVE); |
| 335 initial_opt_in_ = false; | 403 initial_opt_in_ = false; |
| 336 context_->PrepareContext(); | 404 context_->PrepareContext(); |
| 337 } | 405 } |
| 338 | 406 |
| 339 void ArcAuthService::OnSignInComplete() { | 407 void ArcAuthService::OnSignInComplete() { |
| 340 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 408 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 341 DCHECK_EQ(state_, State::ACTIVE); | 409 DCHECK_EQ(state_, State::ACTIVE); |
| 342 DCHECK(!sign_in_time_.is_null()); | |
| 343 | 410 |
| 344 arc_sign_in_timer_.Stop(); | 411 CloseUI(); |
| 345 | 412 |
| 346 if (!IsOptInVerificationDisabled() && | 413 if (profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn)) |
|
khmel
2016/11/03 20:16:45
Is it guaranty that timers are not set?
nit: mayb
Luis Héctor Chávez
2016/11/04 15:43:13
It should be guaranteed, but after more careful co
| |
| 347 !profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn)) { | 414 return; |
| 415 | |
| 416 profile_->GetPrefs()->SetBoolean(prefs::kArcSignedIn, true); | |
| 417 if (!IsOptInVerificationDisabled()) { | |
| 348 playstore_launcher_.reset( | 418 playstore_launcher_.reset( |
| 349 new ArcAppLauncher(profile_, kPlayStoreAppId, true)); | 419 new ArcAppLauncher(profile_, kPlayStoreAppId, true)); |
| 350 } | 420 } |
| 351 | 421 |
| 352 profile_->GetPrefs()->SetBoolean(prefs::kArcSignedIn, true); | 422 DCHECK(!sign_in_time_.is_null()); |
| 353 CloseUI(); | 423 arc_sign_in_timer_.Stop(); |
| 354 UpdateProvisioningTiming(base::Time::Now() - sign_in_time_, true, | 424 UpdateProvisioningTiming(base::Time::Now() - sign_in_time_, true, |
| 355 policy_util::IsAccountManaged(profile_)); | 425 policy_util::IsAccountManaged(profile_)); |
| 356 UpdateProvisioningResultUMA(ProvisioningResult::SUCCESS, | 426 UpdateProvisioningResultUMA(ProvisioningResult::SUCCESS, |
| 357 policy_util::IsAccountManaged(profile_)); | 427 policy_util::IsAccountManaged(profile_)); |
| 358 | 428 |
| 359 for (auto& observer : observer_list_) | 429 for (auto& observer : observer_list_) |
| 360 observer.OnInitialStart(); | 430 observer.OnInitialStart(); |
| 361 } | 431 } |
| 362 | 432 |
| 363 void ArcAuthService::OnSignInFailed(mojom::ArcSignInFailureReason reason) { | 433 void ArcAuthService::OnSignInFailed(mojom::ArcSignInFailureReason reason) { |
| 364 OnSignInFailedInternal( | 434 OnSignInFailedInternal( |
| 365 ConvertArcSignInFailureReasonToProvisioningResult(reason)); | 435 ConvertArcSignInFailureReasonToProvisioningResult(reason)); |
| 366 } | 436 } |
| 367 | 437 |
| 368 void ArcAuthService::OnSignInFailedInternal(ProvisioningResult result) { | 438 void ArcAuthService::OnSignInFailedInternal(ProvisioningResult result) { |
| 369 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 439 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 370 DCHECK_EQ(state_, State::ACTIVE); | 440 DCHECK_EQ(state_, State::ACTIVE); |
| 371 DCHECK(!sign_in_time_.is_null()); | |
| 372 | 441 |
| 373 arc_sign_in_timer_.Stop(); | 442 if (!sign_in_time_.is_null()) { |
| 443 arc_sign_in_timer_.Stop(); | |
| 374 | 444 |
| 375 UpdateProvisioningTiming(base::Time::Now() - sign_in_time_, false, | 445 UpdateProvisioningTiming(base::Time::Now() - sign_in_time_, false, |
| 376 policy_util::IsAccountManaged(profile_)); | 446 policy_util::IsAccountManaged(profile_)); |
| 377 UpdateOptInCancelUMA(OptInCancelReason::CLOUD_PROVISION_FLOW_FAIL); | 447 UpdateOptInCancelUMA(OptInCancelReason::CLOUD_PROVISION_FLOW_FAIL); |
| 378 UpdateProvisioningResultUMA(result, policy_util::IsAccountManaged(profile_)); | 448 UpdateProvisioningResultUMA(result, |
| 449 policy_util::IsAccountManaged(profile_)); | |
| 450 } | |
| 379 | 451 |
| 380 int error_message_id; | 452 int error_message_id; |
| 381 switch (result) { | 453 switch (result) { |
| 382 case ProvisioningResult::GMS_NETWORK_ERROR: | 454 case ProvisioningResult::GMS_NETWORK_ERROR: |
| 383 error_message_id = IDS_ARC_SIGN_IN_NETWORK_ERROR; | 455 error_message_id = IDS_ARC_SIGN_IN_NETWORK_ERROR; |
| 384 break; | 456 break; |
| 385 case ProvisioningResult::GMS_SERVICE_UNAVAILABLE: | 457 case ProvisioningResult::GMS_SERVICE_UNAVAILABLE: |
| 386 case ProvisioningResult::GMS_SIGN_IN_FAILED: | 458 case ProvisioningResult::GMS_SIGN_IN_FAILED: |
| 387 case ProvisioningResult::GMS_SIGN_IN_TIMEOUT: | 459 case ProvisioningResult::GMS_SIGN_IN_TIMEOUT: |
| 388 case ProvisioningResult::GMS_SIGN_IN_INTERNAL_ERROR: | 460 case ProvisioningResult::GMS_SIGN_IN_INTERNAL_ERROR: |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 424 result == ProvisioningResult::UNKNOWN_ERROR) { | 496 result == ProvisioningResult::UNKNOWN_ERROR) { |
| 425 RemoveArcData(); | 497 RemoveArcData(); |
| 426 } | 498 } |
| 427 | 499 |
| 428 // We'll delay shutting down the bridge in this case to allow people to send | 500 // We'll delay shutting down the bridge in this case to allow people to send |
| 429 // feedback. | 501 // feedback. |
| 430 ShowUI(UIPage::ERROR_WITH_FEEDBACK, | 502 ShowUI(UIPage::ERROR_WITH_FEEDBACK, |
| 431 l10n_util::GetStringUTF16(error_message_id)); | 503 l10n_util::GetStringUTF16(error_message_id)); |
| 432 } | 504 } |
| 433 | 505 |
| 434 void ArcAuthService::GetIsAccountManaged( | 506 void ArcAuthService::GetIsAccountManagedDeprecated( |
| 435 const GetIsAccountManagedCallback& callback) { | 507 const GetIsAccountManagedDeprecatedCallback& callback) { |
| 436 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 508 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 437 | 509 |
| 438 callback.Run(policy_util::IsAccountManaged(profile_)); | 510 callback.Run(policy_util::IsAccountManaged(profile_)); |
| 439 } | 511 } |
| 440 | 512 |
| 441 void ArcAuthService::SetState(State state) { | 513 void ArcAuthService::SetState(State state) { |
| 442 if (state_ == state) | 514 if (state_ == state) |
| 443 return; | 515 return; |
| 444 | 516 |
| 445 state_ = state; | 517 state_ = state; |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 645 weak_ptr_factory_.GetWeakPtr())); | 717 weak_ptr_factory_.GetWeakPtr())); |
| 646 } | 718 } |
| 647 } | 719 } |
| 648 | 720 |
| 649 UpdateEnabledStateUMA(true); | 721 UpdateEnabledStateUMA(true); |
| 650 } | 722 } |
| 651 | 723 |
| 652 void ArcAuthService::ShutdownBridge() { | 724 void ArcAuthService::ShutdownBridge() { |
| 653 arc_sign_in_timer_.Stop(); | 725 arc_sign_in_timer_.Stop(); |
| 654 playstore_launcher_.reset(); | 726 playstore_launcher_.reset(); |
| 655 auth_callback_.Reset(); | 727 account_info_notifier_.reset(); |
| 656 auth_account_callback_.Reset(); | |
| 657 android_management_checker_.reset(); | 728 android_management_checker_.reset(); |
| 658 auth_code_fetcher_.reset(); | 729 auth_code_fetcher_.reset(); |
| 659 arc_bridge_service()->RequestStop(); | 730 arc_bridge_service()->RequestStop(); |
| 660 if (state_ != State::NOT_INITIALIZED) | 731 if (state_ != State::NOT_INITIALIZED) |
| 661 SetState(State::STOPPED); | 732 SetState(State::STOPPED); |
| 662 for (auto& observer : observer_list_) | 733 for (auto& observer : observer_list_) |
| 663 observer.OnShutdownBridge(); | 734 observer.OnShutdownBridge(); |
| 664 } | 735 } |
| 665 | 736 |
| 666 void ArcAuthService::ShutdownBridgeAndCloseUI() { | 737 void ArcAuthService::ShutdownBridgeAndCloseUI() { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 715 SetState(State::ACTIVE); | 786 SetState(State::ACTIVE); |
| 716 } | 787 } |
| 717 | 788 |
| 718 void ArcAuthService::SetAuthCodeAndStartArc(const std::string& auth_code) { | 789 void ArcAuthService::SetAuthCodeAndStartArc(const std::string& auth_code) { |
| 719 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 790 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 720 DCHECK(!auth_code.empty()); | 791 DCHECK(!auth_code.empty()); |
| 721 | 792 |
| 722 if (IsAuthCodeRequest()) { | 793 if (IsAuthCodeRequest()) { |
| 723 DCHECK_EQ(state_, State::FETCHING_CODE); | 794 DCHECK_EQ(state_, State::FETCHING_CODE); |
| 724 SetState(State::ACTIVE); | 795 SetState(State::ACTIVE); |
| 725 if (!auth_callback_.is_null()) { | 796 account_info_notifier_->Notify(!IsOptInVerificationDisabled(), auth_code, |
| 726 auth_callback_.Run(auth_code, !IsOptInVerificationDisabled()); | 797 mojom::ChromeAccountType::USER_ACCOUNT, |
| 727 auth_callback_.Reset(); | 798 policy_util::IsAccountManaged(profile_)); |
| 728 return; | 799 account_info_notifier_.reset(); |
| 729 } else { | 800 return; |
| 730 auth_account_callback_.Run(auth_code, !IsOptInVerificationDisabled(), | |
| 731 mojom::ChromeAccountType::USER_ACCOUNT); | |
| 732 auth_account_callback_.Reset(); | |
| 733 return; | |
| 734 } | |
| 735 } | 801 } |
| 736 | 802 |
| 737 if (state_ != State::FETCHING_CODE) { | 803 if (state_ != State::FETCHING_CODE) { |
| 738 ShutdownBridgeAndCloseUI(); | 804 ShutdownBridgeAndCloseUI(); |
| 739 return; | 805 return; |
| 740 } | 806 } |
| 741 | 807 |
| 742 sign_in_time_ = base::Time::Now(); | 808 sign_in_time_ = base::Time::Now(); |
| 743 VLOG(1) << "Starting ARC for first sign in."; | 809 VLOG(1) << "Starting ARC for first sign in."; |
| 744 | 810 |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 964 return os << "FETCHING_CODE"; | 1030 return os << "FETCHING_CODE"; |
| 965 case ArcAuthService::State::ACTIVE: | 1031 case ArcAuthService::State::ACTIVE: |
| 966 return os << "ACTIVE"; | 1032 return os << "ACTIVE"; |
| 967 default: | 1033 default: |
| 968 NOTREACHED(); | 1034 NOTREACHED(); |
| 969 return os; | 1035 return os; |
| 970 } | 1036 } |
| 971 } | 1037 } |
| 972 | 1038 |
| 973 } // namespace arc | 1039 } // namespace arc |
| OLD | NEW |