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 kMinVersionForOnAccountInformationReady = 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::AccountInformationNotifier { | |
| 119 public: | |
| 120 explicit AccountInformationNotifier( | |
| 121 const GetAuthCodeDeprecatedCallback& auth_callback) | |
| 122 : callback_type_(CallbackType::AUTH_CODE), | |
| 123 auth_callback_(auth_callback) {} | |
| 124 | |
| 125 explicit AccountInformationNotifier( | |
| 126 const GetAuthCodeAndAccountTypeDeprecatedCallback& auth_account_callback) | |
| 127 : callback_type_(CallbackType::AUTH_CODE_AND_ACCOUNT), | |
| 128 auth_account_callback_(auth_account_callback) {} | |
| 129 | |
| 130 explicit AccountInformationNotifier( | |
| 131 const AccountInformationCallback& account_information_callback) | |
| 132 : callback_type_(CallbackType::ACCOUNT_INFORMATION), | |
| 133 account_information_callback_(account_information_callback) {} | |
| 134 | |
| 135 void Notify(bool is_enforced, | |
| 136 const std::string& auth_code, | |
| 137 mojom::ChromeAccountType account_type, | |
| 138 bool is_managed) { | |
| 139 switch (callback_type_) { | |
| 140 case CallbackType::AUTH_CODE: | |
| 141 DCHECK(!auth_callback_.is_null()); | |
| 142 auth_callback_.Run(auth_code, is_enforced); | |
| 143 break; | |
| 144 case CallbackType::AUTH_CODE_AND_ACCOUNT: | |
| 145 DCHECK(!auth_account_callback_.is_null()); | |
| 146 auth_account_callback_.Run(auth_code, is_enforced, account_type); | |
| 147 break; | |
| 148 case CallbackType::ACCOUNT_INFORMATION: | |
| 149 DCHECK(!account_information_callback_.is_null()); | |
| 150 mojom::AccountInformationPtr account_information = | |
| 151 mojom::AccountInformation::New(); | |
| 152 if (!is_enforced) { | |
| 153 account_information->auth_code = nullptr; | |
| 154 } else { | |
| 155 account_information->auth_code = auth_code; | |
| 156 } | |
| 157 account_information->account_type = account_type; | |
| 158 account_information->is_managed = is_managed; | |
| 159 account_information_callback_.Run(std::move(account_information)); | |
| 160 break; | |
| 161 } | |
| 162 } | |
| 163 | |
| 164 private: | |
| 165 enum class CallbackType { | |
| 166 AUTH_CODE, | |
| 167 AUTH_CODE_AND_ACCOUNT, | |
| 168 ACCOUNT_INFORMATION | |
| 169 }; | |
| 170 | |
| 171 const CallbackType callback_type_; | |
| 172 const GetAuthCodeDeprecatedCallback auth_callback_; | |
| 173 const GetAuthCodeAndAccountTypeDeprecatedCallback auth_account_callback_; | |
| 174 const AccountInformationCallback account_information_callback_; | |
| 175 }; | |
| 176 | |
| 116 ArcAuthService::ArcAuthService(ArcBridgeService* bridge_service) | 177 ArcAuthService::ArcAuthService(ArcBridgeService* bridge_service) |
| 117 : ArcService(bridge_service), binding_(this), weak_ptr_factory_(this) { | 178 : ArcService(bridge_service), binding_(this), weak_ptr_factory_(this) { |
| 118 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 179 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 119 DCHECK(!g_arc_auth_service); | 180 DCHECK(!g_arc_auth_service); |
| 120 | 181 |
| 121 g_arc_auth_service = this; | 182 g_arc_auth_service = this; |
| 122 | 183 |
| 123 arc_bridge_service()->AddObserver(this); | 184 arc_bridge_service()->AddObserver(this); |
| 124 arc_bridge_service()->auth()->AddObserver(this); | 185 arc_bridge_service()->auth()->AddObserver(this); |
| 125 } | 186 } |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 271 EnableArc(); | 332 EnableArc(); |
| 272 } | 333 } |
| 273 | 334 |
| 274 std::string ArcAuthService::GetAndResetAuthCode() { | 335 std::string ArcAuthService::GetAndResetAuthCode() { |
| 275 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 336 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 276 std::string auth_code; | 337 std::string auth_code; |
| 277 auth_code_.swap(auth_code); | 338 auth_code_.swap(auth_code); |
| 278 return auth_code; | 339 return auth_code; |
| 279 } | 340 } |
| 280 | 341 |
| 281 void ArcAuthService::GetAuthCodeDeprecated( | 342 void ArcAuthService::GetAuthCodeDeprecated0( |
| 282 const GetAuthCodeDeprecatedCallback& callback) { | 343 const GetAuthCodeDeprecated0Callback& callback) { |
| 283 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 344 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 284 DCHECK(!IsOptInVerificationDisabled()); | 345 DCHECK(!IsOptInVerificationDisabled()); |
| 285 callback.Run(GetAndResetAuthCode()); | 346 callback.Run(GetAndResetAuthCode()); |
| 286 } | 347 } |
| 287 | 348 |
| 288 void ArcAuthService::GetAuthCode(const GetAuthCodeCallback& callback) { | 349 void ArcAuthService::GetAuthCodeDeprecated( |
| 289 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 350 const GetAuthCodeDeprecatedCallback& callback) { |
| 290 // GetAuthCodeAndAccountType operation must not be in progress. | 351 RequestAccountInformationInternal( |
| 291 DCHECK(auth_account_callback_.is_null()); | 352 base::MakeUnique<ArcAuthService::AccountInformationNotifier>(callback)); |
| 292 | |
| 293 const std::string auth_code = GetAndResetAuthCode(); | |
| 294 const bool verification_disabled = IsOptInVerificationDisabled(); | |
| 295 if (!auth_code.empty() || verification_disabled) { | |
| 296 callback.Run(auth_code, !verification_disabled); | |
| 297 return; | |
| 298 } | |
| 299 | |
| 300 auth_callback_ = callback; | |
| 301 PrepareContextForAuthCodeRequest(); | |
| 302 } | 353 } |
| 303 | 354 |
| 304 void ArcAuthService::GetAuthCodeAndAccountType( | 355 void ArcAuthService::GetAuthCodeAndAccountTypeDeprecated( |
| 305 const GetAuthCodeAndAccountTypeCallback& callback) { | 356 const GetAuthCodeAndAccountTypeDeprecatedCallback& callback) { |
| 306 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 357 RequestAccountInformationInternal( |
| 307 // GetAuthCode operation must not be in progress. | 358 base::MakeUnique<ArcAuthService::AccountInformationNotifier>(callback)); |
| 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(); | |
| 320 } | 359 } |
| 321 | 360 |
| 322 bool ArcAuthService::IsAuthCodeRequest() const { | 361 bool ArcAuthService::IsAuthCodeRequest() const { |
| 323 return !auth_callback_.is_null() || !auth_account_callback_.is_null(); | 362 return account_information_notifier_ != nullptr; |
| 324 } | 363 } |
| 325 | 364 |
| 326 void ArcAuthService::PrepareContextForAuthCodeRequest() { | 365 void ArcAuthService::PrepareContextForAuthCodeRequest() { |
| 327 // Requesting auth code on demand happens in following cases: | 366 // Requesting auth code on demand happens in following cases: |
| 328 // 1. To handle account password revoke. | 367 // 1. To handle account password revoke. |
| 329 // 2. In case Arc is activated in OOBE flow. | 368 // 2. In case Arc is activated in OOBE flow. |
| 330 // 3. For any other state on Android side that leads device appears in | 369 // 3. For any other state on Android side that leads device appears in |
| 331 // non-signed state. | 370 // non-signed state. |
| 332 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 371 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 333 DCHECK(IsAuthCodeRequest()); | 372 DCHECK(IsAuthCodeRequest()); |
| 334 DCHECK_EQ(state_, State::ACTIVE); | 373 DCHECK_EQ(state_, State::ACTIVE); |
| 335 initial_opt_in_ = false; | 374 initial_opt_in_ = false; |
| 336 context_->PrepareContext(); | 375 context_->PrepareContext(); |
| 337 } | 376 } |
| 338 | 377 |
| 339 void ArcAuthService::OnSignInComplete() { | 378 void ArcAuthService::OnSignInComplete() { |
| 340 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 379 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 341 DCHECK_EQ(state_, State::ACTIVE); | 380 DCHECK_EQ(state_, State::ACTIVE); |
| 342 DCHECK(!sign_in_time_.is_null()); | |
| 343 | 381 |
| 344 arc_sign_in_timer_.Stop(); | 382 CloseUI(); |
| 345 | 383 |
| 346 if (!IsOptInVerificationDisabled() && | 384 if (profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn)) |
| 347 !profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn)) { | 385 return; |
| 386 | |
| 387 if (!IsOptInVerificationDisabled()) { | |
| 348 playstore_launcher_.reset( | 388 playstore_launcher_.reset( |
| 349 new ArcAppLauncher(profile_, kPlayStoreAppId, true)); | 389 new ArcAppLauncher(profile_, kPlayStoreAppId, true)); |
| 350 } | 390 } |
| 351 | 391 |
| 352 profile_->GetPrefs()->SetBoolean(prefs::kArcSignedIn, true); | 392 profile_->GetPrefs()->SetBoolean(prefs::kArcSignedIn, true); |
|
hidehiko
2016/11/03 00:27:21
Let's move this to L386.
Luis Héctor Chávez
2016/11/03 20:08:09
Done.
| |
| 353 CloseUI(); | 393 DCHECK(!sign_in_time_.is_null()); |
| 394 arc_sign_in_timer_.Stop(); | |
| 354 UpdateProvisioningTiming(base::Time::Now() - sign_in_time_, true, | 395 UpdateProvisioningTiming(base::Time::Now() - sign_in_time_, true, |
| 355 policy_util::IsAccountManaged(profile_)); | 396 policy_util::IsAccountManaged(profile_)); |
| 356 UpdateProvisioningResultUMA(ProvisioningResult::SUCCESS, | 397 UpdateProvisioningResultUMA(ProvisioningResult::SUCCESS, |
| 357 policy_util::IsAccountManaged(profile_)); | 398 policy_util::IsAccountManaged(profile_)); |
| 358 | 399 |
| 359 for (auto& observer : observer_list_) | 400 for (auto& observer : observer_list_) |
| 360 observer.OnInitialStart(); | 401 observer.OnInitialStart(); |
| 361 } | 402 } |
| 362 | 403 |
| 363 void ArcAuthService::OnSignInFailed(mojom::ArcSignInFailureReason reason) { | 404 void ArcAuthService::OnSignInFailed(mojom::ArcSignInFailureReason reason) { |
| 364 OnSignInFailedInternal( | 405 OnSignInFailedInternal( |
| 365 ConvertArcSignInFailureReasonToProvisioningResult(reason)); | 406 ConvertArcSignInFailureReasonToProvisioningResult(reason)); |
| 366 } | 407 } |
| 367 | 408 |
| 409 void ArcAuthService::RequestAccountInformation() { | |
| 410 RequestAccountInformationInternal( | |
| 411 base::MakeUnique<ArcAuthService::AccountInformationNotifier>( | |
| 412 base::Bind(&ArcAuthService::OnAccountInformationReady, | |
| 413 weak_ptr_factory_.GetWeakPtr()))); | |
| 414 } | |
| 415 | |
| 416 void ArcAuthService::OnAccountInformationReady( | |
| 417 mojom::AccountInformationPtr account_information) { | |
| 418 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
| 419 auto* instance = arc_bridge_service()->auth()->GetInstanceForMethod( | |
| 420 "OnAccountInformationReady", kMinVersionForOnAccountInformationReady); | |
| 421 DCHECK(instance); | |
| 422 instance->OnAccountInformationReady(std::move(account_information)); | |
| 423 } | |
| 424 | |
| 425 void ArcAuthService::RequestAccountInformationInternal( | |
| 426 std::unique_ptr<ArcAuthService::AccountInformationNotifier> | |
| 427 account_information_notifier) { | |
| 428 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
| 429 // No other auth code-related operation may be in progress. | |
| 430 DCHECK(!account_information_notifier_); | |
| 431 | |
| 432 const std::string auth_code = GetAndResetAuthCode(); | |
| 433 const bool is_enforced = !IsOptInVerificationDisabled(); | |
| 434 if (!auth_code.empty() || !is_enforced) { | |
| 435 account_information_notifier->Notify( | |
| 436 is_enforced, auth_code, mojom::ChromeAccountType::USER_ACCOUNT, | |
| 437 policy_util::IsAccountManaged(profile_)); | |
| 438 return; | |
| 439 } | |
| 440 | |
| 441 account_information_notifier_ = std::move(account_information_notifier); | |
| 442 PrepareContextForAuthCodeRequest(); | |
| 443 } | |
| 444 | |
| 368 void ArcAuthService::OnSignInFailedInternal(ProvisioningResult result) { | 445 void ArcAuthService::OnSignInFailedInternal(ProvisioningResult result) { |
| 369 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 446 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 370 DCHECK_EQ(state_, State::ACTIVE); | 447 DCHECK_EQ(state_, State::ACTIVE); |
| 371 DCHECK(!sign_in_time_.is_null()); | |
| 372 | 448 |
| 373 arc_sign_in_timer_.Stop(); | 449 if (!sign_in_time_.is_null()) { |
| 450 arc_sign_in_timer_.Stop(); | |
| 374 | 451 |
| 375 UpdateProvisioningTiming(base::Time::Now() - sign_in_time_, false, | 452 UpdateProvisioningTiming(base::Time::Now() - sign_in_time_, false, |
| 376 policy_util::IsAccountManaged(profile_)); | 453 policy_util::IsAccountManaged(profile_)); |
| 377 UpdateOptInCancelUMA(OptInCancelReason::CLOUD_PROVISION_FLOW_FAIL); | 454 UpdateOptInCancelUMA(OptInCancelReason::CLOUD_PROVISION_FLOW_FAIL); |
| 378 UpdateProvisioningResultUMA(result, policy_util::IsAccountManaged(profile_)); | 455 UpdateProvisioningResultUMA(result, |
| 456 policy_util::IsAccountManaged(profile_)); | |
| 457 } | |
| 379 | 458 |
| 380 int error_message_id; | 459 int error_message_id; |
| 381 switch (result) { | 460 switch (result) { |
| 382 case ProvisioningResult::GMS_NETWORK_ERROR: | 461 case ProvisioningResult::GMS_NETWORK_ERROR: |
| 383 error_message_id = IDS_ARC_SIGN_IN_NETWORK_ERROR; | 462 error_message_id = IDS_ARC_SIGN_IN_NETWORK_ERROR; |
| 384 break; | 463 break; |
| 385 case ProvisioningResult::GMS_SERVICE_UNAVAILABLE: | 464 case ProvisioningResult::GMS_SERVICE_UNAVAILABLE: |
| 386 case ProvisioningResult::GMS_SIGN_IN_FAILED: | 465 case ProvisioningResult::GMS_SIGN_IN_FAILED: |
| 387 case ProvisioningResult::GMS_SIGN_IN_TIMEOUT: | 466 case ProvisioningResult::GMS_SIGN_IN_TIMEOUT: |
| 388 case ProvisioningResult::GMS_SIGN_IN_INTERNAL_ERROR: | 467 case ProvisioningResult::GMS_SIGN_IN_INTERNAL_ERROR: |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 415 } | 494 } |
| 416 | 495 |
| 417 if (result == ProvisioningResult::CLOUD_PROVISION_FLOW_FAILED || | 496 if (result == ProvisioningResult::CLOUD_PROVISION_FLOW_FAILED || |
| 418 result == ProvisioningResult::CLOUD_PROVISION_FLOW_TIMEOUT || | 497 result == ProvisioningResult::CLOUD_PROVISION_FLOW_TIMEOUT || |
| 419 result == ProvisioningResult::CLOUD_PROVISION_FLOW_INTERNAL_ERROR || | 498 result == ProvisioningResult::CLOUD_PROVISION_FLOW_INTERNAL_ERROR || |
| 420 // OVERALL_SIGN_IN_TIMEOUT might be an indication that ARC believes it is | 499 // OVERALL_SIGN_IN_TIMEOUT might be an indication that ARC believes it is |
| 421 // fully setup, but Chrome does not. | 500 // fully setup, but Chrome does not. |
| 422 result == ProvisioningResult::OVERALL_SIGN_IN_TIMEOUT || | 501 result == ProvisioningResult::OVERALL_SIGN_IN_TIMEOUT || |
| 423 // Just to be safe, remove data if we don't know the cause. | 502 // Just to be safe, remove data if we don't know the cause. |
| 424 result == ProvisioningResult::UNKNOWN_ERROR) { | 503 result == ProvisioningResult::UNKNOWN_ERROR) { |
| 425 RemoveArcData(); | 504 RemoveArcData(); |
|
hidehiko
2016/11/03 00:27:21
Slightly off-topic. Is it ok to remove the data fo
Luis Héctor Chávez
2016/11/03 20:08:09
If re-auth needs provisioning, definitely. Otherwi
| |
| 426 } | 505 } |
| 427 | 506 |
| 428 // We'll delay shutting down the bridge in this case to allow people to send | 507 // We'll delay shutting down the bridge in this case to allow people to send |
| 429 // feedback. | 508 // feedback. |
| 430 ShowUI(UIPage::ERROR_WITH_FEEDBACK, | 509 ShowUI(UIPage::ERROR_WITH_FEEDBACK, |
| 431 l10n_util::GetStringUTF16(error_message_id)); | 510 l10n_util::GetStringUTF16(error_message_id)); |
| 432 } | 511 } |
| 433 | 512 |
| 434 void ArcAuthService::GetIsAccountManaged( | 513 void ArcAuthService::GetIsAccountManagedDeprecated( |
| 435 const GetIsAccountManagedCallback& callback) { | 514 const GetIsAccountManagedDeprecatedCallback& callback) { |
| 436 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 515 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 437 | 516 |
| 438 callback.Run(policy_util::IsAccountManaged(profile_)); | 517 callback.Run(policy_util::IsAccountManaged(profile_)); |
| 439 } | 518 } |
| 440 | 519 |
| 441 void ArcAuthService::SetState(State state) { | 520 void ArcAuthService::SetState(State state) { |
| 442 if (state_ == state) | 521 if (state_ == state) |
| 443 return; | 522 return; |
| 444 | 523 |
| 445 state_ = state; | 524 state_ = state; |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 645 weak_ptr_factory_.GetWeakPtr())); | 724 weak_ptr_factory_.GetWeakPtr())); |
| 646 } | 725 } |
| 647 } | 726 } |
| 648 | 727 |
| 649 UpdateEnabledStateUMA(true); | 728 UpdateEnabledStateUMA(true); |
| 650 } | 729 } |
| 651 | 730 |
| 652 void ArcAuthService::ShutdownBridge() { | 731 void ArcAuthService::ShutdownBridge() { |
| 653 arc_sign_in_timer_.Stop(); | 732 arc_sign_in_timer_.Stop(); |
| 654 playstore_launcher_.reset(); | 733 playstore_launcher_.reset(); |
| 655 auth_callback_.Reset(); | 734 account_information_notifier_.reset(); |
| 656 auth_account_callback_.Reset(); | |
| 657 android_management_checker_.reset(); | 735 android_management_checker_.reset(); |
| 658 auth_code_fetcher_.reset(); | 736 auth_code_fetcher_.reset(); |
| 659 arc_bridge_service()->RequestStop(); | 737 arc_bridge_service()->RequestStop(); |
| 660 if (state_ != State::NOT_INITIALIZED) | 738 if (state_ != State::NOT_INITIALIZED) |
| 661 SetState(State::STOPPED); | 739 SetState(State::STOPPED); |
| 662 for (auto& observer : observer_list_) | 740 for (auto& observer : observer_list_) |
| 663 observer.OnShutdownBridge(); | 741 observer.OnShutdownBridge(); |
| 664 } | 742 } |
| 665 | 743 |
| 666 void ArcAuthService::ShutdownBridgeAndCloseUI() { | 744 void ArcAuthService::ShutdownBridgeAndCloseUI() { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 715 SetState(State::ACTIVE); | 793 SetState(State::ACTIVE); |
| 716 } | 794 } |
| 717 | 795 |
| 718 void ArcAuthService::SetAuthCodeAndStartArc(const std::string& auth_code) { | 796 void ArcAuthService::SetAuthCodeAndStartArc(const std::string& auth_code) { |
| 719 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 797 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 720 DCHECK(!auth_code.empty()); | 798 DCHECK(!auth_code.empty()); |
| 721 | 799 |
| 722 if (IsAuthCodeRequest()) { | 800 if (IsAuthCodeRequest()) { |
| 723 DCHECK_EQ(state_, State::FETCHING_CODE); | 801 DCHECK_EQ(state_, State::FETCHING_CODE); |
| 724 SetState(State::ACTIVE); | 802 SetState(State::ACTIVE); |
| 725 if (!auth_callback_.is_null()) { | 803 account_information_notifier_->Notify( |
| 726 auth_callback_.Run(auth_code, !IsOptInVerificationDisabled()); | 804 !IsOptInVerificationDisabled(), auth_code, |
| 727 auth_callback_.Reset(); | 805 mojom::ChromeAccountType::USER_ACCOUNT, |
| 728 return; | 806 policy_util::IsAccountManaged(profile_)); |
| 729 } else { | 807 account_information_notifier_.reset(); |
| 730 auth_account_callback_.Run(auth_code, !IsOptInVerificationDisabled(), | 808 return; |
| 731 mojom::ChromeAccountType::USER_ACCOUNT); | |
| 732 auth_account_callback_.Reset(); | |
| 733 return; | |
| 734 } | |
| 735 } | 809 } |
| 736 | 810 |
| 737 if (state_ != State::FETCHING_CODE) { | 811 if (state_ != State::FETCHING_CODE) { |
| 738 ShutdownBridgeAndCloseUI(); | 812 ShutdownBridgeAndCloseUI(); |
| 739 return; | 813 return; |
| 740 } | 814 } |
| 741 | 815 |
| 742 sign_in_time_ = base::Time::Now(); | 816 sign_in_time_ = base::Time::Now(); |
| 743 VLOG(1) << "Starting ARC for first sign in."; | 817 VLOG(1) << "Starting ARC for first sign in."; |
| 744 | 818 |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 964 return os << "FETCHING_CODE"; | 1038 return os << "FETCHING_CODE"; |
| 965 case ArcAuthService::State::ACTIVE: | 1039 case ArcAuthService::State::ACTIVE: |
| 966 return os << "ACTIVE"; | 1040 return os << "ACTIVE"; |
| 967 default: | 1041 default: |
| 968 NOTREACHED(); | 1042 NOTREACHED(); |
| 969 return os; | 1043 return os; |
| 970 } | 1044 } |
| 971 } | 1045 } |
| 972 | 1046 |
| 973 } // namespace arc | 1047 } // namespace arc |
| OLD | NEW |