OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_session_manager.h" | 5 #include "chrome/browser/chromeos/arc/arc_session_manager.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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 | 57 |
58 // The Android management check is disabled by default, it's used only for | 58 // The Android management check is disabled by default, it's used only for |
59 // testing. | 59 // testing. |
60 bool g_enable_check_android_management_for_testing = false; | 60 bool g_enable_check_android_management_for_testing = false; |
61 | 61 |
62 // Maximum amount of time we'll wait for ARC to finish booting up. Once this | 62 // Maximum amount of time we'll wait for ARC to finish booting up. Once this |
63 // timeout expires, keep ARC running in case the user wants to file feedback, | 63 // timeout expires, keep ARC running in case the user wants to file feedback, |
64 // but present the UI to try again. | 64 // but present the UI to try again. |
65 constexpr base::TimeDelta kArcSignInTimeout = base::TimeDelta::FromMinutes(5); | 65 constexpr base::TimeDelta kArcSignInTimeout = base::TimeDelta::FromMinutes(5); |
66 | 66 |
67 // Updates UMA with user cancel only if error is not currently shown. | |
68 void MaybeUpdateOptInCancelUMA(const ArcSupportHost* support_host) { | |
69 if (!support_host || | |
70 support_host->ui_page() == ArcSupportHost::UIPage::NO_PAGE || | |
71 support_host->ui_page() == ArcSupportHost::UIPage::ERROR) { | |
72 return; | |
73 } | |
74 | |
75 UpdateOptInCancelUMA(OptInCancelReason::USER_CANCEL); | |
76 } | |
77 | |
67 } // namespace | 78 } // namespace |
68 | 79 |
69 ArcSessionManager::ArcSessionManager( | 80 ArcSessionManager::ArcSessionManager( |
70 std::unique_ptr<ArcSessionRunner> arc_session_runner) | 81 std::unique_ptr<ArcSessionRunner> arc_session_runner) |
71 : arc_session_runner_(std::move(arc_session_runner)), | 82 : arc_session_runner_(std::move(arc_session_runner)), |
72 attempt_user_exit_callback_(base::Bind(chrome::AttemptUserExit)), | 83 attempt_user_exit_callback_(base::Bind(chrome::AttemptUserExit)), |
73 weak_ptr_factory_(this) { | 84 weak_ptr_factory_(this) { |
74 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 85 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
75 DCHECK(!g_arc_session_manager); | 86 DCHECK(!g_arc_session_manager); |
76 g_arc_session_manager = this; | 87 g_arc_session_manager = this; |
(...skipping 24 matching lines...) Expand all Loading... | |
101 registry->RegisterBooleanPref(prefs::kArcDataRemoveRequested, false); | 112 registry->RegisterBooleanPref(prefs::kArcDataRemoveRequested, false); |
102 registry->RegisterBooleanPref(prefs::kArcEnabled, false); | 113 registry->RegisterBooleanPref(prefs::kArcEnabled, false); |
103 registry->RegisterBooleanPref(prefs::kArcSignedIn, false); | 114 registry->RegisterBooleanPref(prefs::kArcSignedIn, false); |
104 registry->RegisterBooleanPref(prefs::kArcTermsAccepted, false); | 115 registry->RegisterBooleanPref(prefs::kArcTermsAccepted, false); |
105 // Note that ArcBackupRestoreEnabled and ArcLocationServiceEnabled prefs have | 116 // Note that ArcBackupRestoreEnabled and ArcLocationServiceEnabled prefs have |
106 // to be off by default, until an explicit gesture from the user to enable | 117 // to be off by default, until an explicit gesture from the user to enable |
107 // them is received. This is crucial in the cases when these prefs transition | 118 // them is received. This is crucial in the cases when these prefs transition |
108 // from a previous managed state to the unmanaged. | 119 // from a previous managed state to the unmanaged. |
109 registry->RegisterBooleanPref(prefs::kArcBackupRestoreEnabled, false); | 120 registry->RegisterBooleanPref(prefs::kArcBackupRestoreEnabled, false); |
110 registry->RegisterBooleanPref(prefs::kArcLocationServiceEnabled, false); | 121 registry->RegisterBooleanPref(prefs::kArcLocationServiceEnabled, false); |
111 // This is used to delete the Play user ID if ARC is disabled for an | 122 // This is used to delete the Play user ID if ARC is disabled for an |
hidehiko
2017/03/07 14:52:20
Note: Sorry, mistakenly mixed rebase.
| |
112 // AD-managed device. | 123 // AD-managed device. |
113 registry->RegisterStringPref(prefs::kArcActiveDirectoryPlayUserId, | 124 registry->RegisterStringPref(prefs::kArcActiveDirectoryPlayUserId, |
114 std::string()); | 125 std::string()); |
115 } | 126 } |
116 | 127 |
117 // static | 128 // static |
118 bool ArcSessionManager::IsOobeOptInActive() { | 129 bool ArcSessionManager::IsOobeOptInActive() { |
119 // ARC OOBE OptIn is optional for now. Test if it exists and login host is | 130 // ARC OOBE OptIn is optional for now. Test if it exists and login host is |
120 // active. | 131 // active. |
121 if (!user_manager::UserManager::Get()->IsCurrentUserNew()) | 132 if (!user_manager::UserManager::Get()->IsCurrentUserNew()) |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
179 profile_->GetPrefs()->SetBoolean(prefs::kArcDataRemoveRequested, true); | 190 profile_->GetPrefs()->SetBoolean(prefs::kArcDataRemoveRequested, true); |
180 | 191 |
181 if (!arc_session_runner_->IsStopped()) { | 192 if (!arc_session_runner_->IsStopped()) { |
182 // Just set a flag. On session stopped, this will be re-called, | 193 // Just set a flag. On session stopped, this will be re-called, |
183 // then session manager should remove the data. | 194 // then session manager should remove the data. |
184 return; | 195 return; |
185 } | 196 } |
186 | 197 |
187 VLOG(1) << "Starting ARC data removal"; | 198 VLOG(1) << "Starting ARC data removal"; |
188 | 199 |
189 // Remove Play user ID for Active Directory managed devices. | 200 // Remove Play user ID for Active Directory managed devices. |
hidehiko
2017/03/07 14:52:20
Note: Sorry, mistakenly mixed rebase.
| |
190 profile_->GetPrefs()->SetString(prefs::kArcActiveDirectoryPlayUserId, | 201 profile_->GetPrefs()->SetString(prefs::kArcActiveDirectoryPlayUserId, |
191 std::string()); | 202 std::string()); |
192 | 203 |
193 SetState(State::REMOVING_DATA_DIR); | 204 SetState(State::REMOVING_DATA_DIR); |
194 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()->RemoveArcData( | 205 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()->RemoveArcData( |
195 cryptohome::Identification( | 206 cryptohome::Identification( |
196 multi_user_util::GetAccountIdFromProfile(profile_)), | 207 multi_user_util::GetAccountIdFromProfile(profile_)), |
197 base::Bind(&ArcSessionManager::OnArcDataRemoved, | 208 base::Bind(&ArcSessionManager::OnArcDataRemoved, |
198 weak_ptr_factory_.GetWeakPtr())); | 209 weak_ptr_factory_.GetWeakPtr())); |
199 } | 210 } |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
513 | 524 |
514 if (state_ == State::NOT_INITIALIZED) { | 525 if (state_ == State::NOT_INITIALIZED) { |
515 NOTREACHED(); | 526 NOTREACHED(); |
516 return; | 527 return; |
517 } | 528 } |
518 | 529 |
519 // If ARC failed to boot normally, stop ARC. Similarly, if the current page is | 530 // If ARC failed to boot normally, stop ARC. Similarly, if the current page is |
520 // LSO, closing the window should stop ARC since the user activity chooses to | 531 // LSO, closing the window should stop ARC since the user activity chooses to |
521 // not sign in. In any other case, ARC is booting normally and the instance | 532 // not sign in. In any other case, ARC is booting normally and the instance |
522 // should not be stopped. | 533 // should not be stopped. |
523 if ((state_ != State::SHOWING_TERMS_OF_SERVICE && | 534 if ((state_ != State::NEGOTIATING_TERMS_OF_SERVICE && |
524 state_ != State::CHECKING_ANDROID_MANAGEMENT) && | 535 state_ != State::CHECKING_ANDROID_MANAGEMENT) && |
525 (!support_host_ || | 536 (!support_host_ || |
526 (support_host_->ui_page() != ArcSupportHost::UIPage::ERROR && | 537 (support_host_->ui_page() != ArcSupportHost::UIPage::ERROR && |
527 support_host_->ui_page() != ArcSupportHost::UIPage::LSO))) { | 538 support_host_->ui_page() != ArcSupportHost::UIPage::LSO))) { |
528 return; | 539 return; |
529 } | 540 } |
530 | 541 |
531 // Update UMA with user cancel only if error is not currently shown. | 542 MaybeUpdateOptInCancelUMA(support_host_.get()); |
532 if (support_host_ && | |
533 support_host_->ui_page() != ArcSupportHost::UIPage::NO_PAGE && | |
534 support_host_->ui_page() != ArcSupportHost::UIPage::ERROR) { | |
535 UpdateOptInCancelUMA(OptInCancelReason::USER_CANCEL); | |
536 } | |
537 | |
538 StopArc(); | 543 StopArc(); |
539 SetArcPlayStoreEnabledForProfile(profile_, false); | 544 SetArcPlayStoreEnabledForProfile(profile_, false); |
540 } | 545 } |
541 | 546 |
542 void ArcSessionManager::RecordArcState() { | 547 void ArcSessionManager::RecordArcState() { |
543 // Only record Enabled state if ARC is allowed in the first place, so we do | 548 // Only record Enabled state if ARC is allowed in the first place, so we do |
544 // not split the ARC population by devices that cannot run ARC. | 549 // not split the ARC population by devices that cannot run ARC. |
545 if (IsAllowed()) | 550 if (IsAllowed()) |
546 UpdateEnabledStateUMA(enable_requested_); | 551 UpdateEnabledStateUMA(enable_requested_); |
547 } | 552 } |
(...skipping 23 matching lines...) Expand all Loading... | |
571 | 576 |
572 if (state_ == State::REMOVING_DATA_DIR) { | 577 if (state_ == State::REMOVING_DATA_DIR) { |
573 // Data removal request is in progress. Set flag to re-enable ARC once it | 578 // Data removal request is in progress. Set flag to re-enable ARC once it |
574 // is finished. | 579 // is finished. |
575 reenable_arc_ = true; | 580 reenable_arc_ = true; |
576 return; | 581 return; |
577 } | 582 } |
578 | 583 |
579 PrefService* const prefs = profile_->GetPrefs(); | 584 PrefService* const prefs = profile_->GetPrefs(); |
580 | 585 |
581 // For ARC Kiosk we skip ToS because it is very likely that near the device | |
582 // there will be no one who is eligible to accept them. | |
583 // TODO(poromov): Move to more Kiosk dedicated set-up phase. | |
584 if (IsArcKioskMode()) | |
585 prefs->SetBoolean(prefs::kArcTermsAccepted, true); | |
586 | |
587 // Skip to show UI asking users to set up ARC OptIn preferences, if all of | |
588 // them are managed by the admin policy. Note that the ToS agreement is anyway | |
589 // not shown in the case of the managed ARC. | |
590 if (IsArcPlayStoreEnabledPreferenceManagedForProfile(profile_) && | |
591 AreArcAllOptInPreferencesManagedForProfile(profile_)) { | |
592 prefs->SetBoolean(prefs::kArcTermsAccepted, true); | |
593 } | |
594 | |
595 // If it is marked that sign in has been successfully done, then directly | 586 // If it is marked that sign in has been successfully done, then directly |
596 // start ARC. | 587 // start ARC. |
597 // For testing, and for Kiosk mode, we also skip ToS negotiation procedure. | 588 // For Kiosk mode, skip ToS because it is very likely that near the device |
598 // For backward compatibility, this check needs to be prior to the | 589 // there will be no one who is eligible to accept them. |
599 // kArcTermsAccepted check below. | 590 // If opt-in verification is disabled, skip negotiation, too. This is for |
600 if (prefs->GetBoolean(prefs::kArcSignedIn) || | 591 // testing purpose. |
601 IsArcOptInVerificationDisabled() || IsArcKioskMode()) { | 592 if (prefs->GetBoolean(prefs::kArcSignedIn) || IsArcKioskMode() || |
593 IsArcOptInVerificationDisabled()) { | |
602 StartArc(); | 594 StartArc(); |
603 // Check Android management in parallel. | 595 // Check Android management in parallel. |
604 // Note: StartBackgroundAndroidManagementCheck() may call | 596 // Note: StartBackgroundAndroidManagementCheck() may call |
605 // OnBackgroundAndroidManagementChecked() synchronously (or | 597 // OnBackgroundAndroidManagementChecked() synchronously (or |
606 // asynchornously). In the callback, Google Play Store enabled preference | 598 // asynchornously). In the callback, Google Play Store enabled preference |
607 // can be set to false if managed, and it triggers RequestDisable() via | 599 // can be set to false if managed, and it triggers RequestDisable() via |
608 // ArcPlayStoreEnabledPreferenceHandler. | 600 // ArcPlayStoreEnabledPreferenceHandler. |
609 // Thus, StartArc() should be called so that disabling should work even | 601 // Thus, StartArc() should be called so that disabling should work even |
610 // if synchronous call case. | 602 // if synchronous call case. |
611 StartBackgroundAndroidManagementCheck(); | 603 StartBackgroundAndroidManagementCheck(); |
612 return; | 604 return; |
613 } | 605 } |
614 | 606 |
615 // If it is marked that the Terms of service is accepted already, | |
616 // just skip the negotiation with user, and start Android management | |
617 // check directly. | |
618 // This happens, e.g., when; | |
619 // 1) User accepted the Terms of service on OOBE flow. | |
620 // 2) User accepted the Terms of service on Opt-in flow, but logged out | |
621 // before ARC sign in procedure was done. Then, logs in again. | |
622 if (prefs->GetBoolean(prefs::kArcTermsAccepted)) { | |
623 // Don't show UI for this progress if it was not shown. | |
624 if (support_host_ && | |
625 support_host_->ui_page() != ArcSupportHost::UIPage::NO_PAGE) { | |
626 support_host_->ShowArcLoading(); | |
627 } | |
628 StartAndroidManagementCheck(); | |
629 return; | |
630 } | |
631 | |
632 StartTermsOfServiceNegotiation(); | 607 StartTermsOfServiceNegotiation(); |
633 } | 608 } |
634 | 609 |
635 void ArcSessionManager::RequestDisable() { | 610 void ArcSessionManager::RequestDisable() { |
636 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 611 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
637 DCHECK(profile_); | 612 DCHECK(profile_); |
638 | 613 |
639 if (!enable_requested_) { | 614 if (!enable_requested_) { |
640 VLOG(1) << "ARC is already disabled. Do nothing."; | 615 VLOG(1) << "ARC is already disabled. Do nothing."; |
641 return; | 616 return; |
642 } | 617 } |
643 enable_requested_ = false; | 618 enable_requested_ = false; |
644 | 619 |
645 // Reset any pending request to re-enable ARC. | 620 // Reset any pending request to re-enable ARC. |
646 VLOG(1) << "ARC opt-out. Removing user data."; | 621 VLOG(1) << "ARC opt-out. Removing user data."; |
647 reenable_arc_ = false; | 622 reenable_arc_ = false; |
648 StopArc(); | 623 StopArc(); |
649 RemoveArcData(); | 624 RemoveArcData(); |
650 } | 625 } |
651 | 626 |
652 void ArcSessionManager::StartTermsOfServiceNegotiation() { | 627 void ArcSessionManager::StartTermsOfServiceNegotiation() { |
653 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 628 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
629 DCHECK(profile_); | |
654 DCHECK(!terms_of_service_negotiator_); | 630 DCHECK(!terms_of_service_negotiator_); |
631 // In Kiosk-mode, Terms of Service negotiation should be skipped. | |
632 // See also RequestEnableImpl(). | |
633 DCHECK(!IsArcKioskMode()); | |
634 // If opt-in verification is disabled, Terms of Service negotiation should | |
635 // be skipped, too. See also RequestEnableImpl(). | |
636 DCHECK(!IsArcOptInVerificationDisabled()); | |
655 | 637 |
638 // TODO(hidehiko): Remove this condition, when the state machine is fixed. | |
656 if (!arc_session_runner_->IsStopped()) { | 639 if (!arc_session_runner_->IsStopped()) { |
657 // If the user attempts to re-enable ARC while the ARC instance is still | 640 // If the user attempts to re-enable ARC while the ARC instance is still |
658 // running the user should not be able to continue until the ARC instance | 641 // running the user should not be able to continue until the ARC instance |
659 // has stopped. | 642 // has stopped. |
660 if (support_host_) { | 643 if (support_host_) { |
661 support_host_->ShowError( | 644 support_host_->ShowError( |
662 ArcSupportHost::Error::SIGN_IN_SERVICE_UNAVAILABLE_ERROR, false); | 645 ArcSupportHost::Error::SIGN_IN_SERVICE_UNAVAILABLE_ERROR, false); |
663 } | 646 } |
664 return; | 647 return; |
665 } | 648 } |
666 | 649 |
667 SetState(State::SHOWING_TERMS_OF_SERVICE); | 650 // TODO(hidehiko): DCHECK if |state_| is STOPPED, when the state machine |
651 // is fixed. | |
652 SetState(State::NEGOTIATING_TERMS_OF_SERVICE); | |
653 | |
654 if (!IsArcTermsOfServiceNegotiationNeeded()) { | |
655 // Moves to next state, Android management check, immediately, as if | |
656 // Terms of Service negotiation is done successfully. | |
657 StartAndroidManagementCheck(); | |
658 return; | |
659 } | |
660 | |
668 if (IsOobeOptInActive()) { | 661 if (IsOobeOptInActive()) { |
669 VLOG(1) << "Use OOBE negotiator."; | 662 VLOG(1) << "Use OOBE negotiator."; |
670 terms_of_service_negotiator_ = | 663 terms_of_service_negotiator_ = |
671 base::MakeUnique<ArcTermsOfServiceOobeNegotiator>(); | 664 base::MakeUnique<ArcTermsOfServiceOobeNegotiator>(); |
672 } else if (support_host_) { | 665 } else if (support_host_) { |
673 VLOG(1) << "Use default negotiator."; | 666 VLOG(1) << "Use default negotiator."; |
674 terms_of_service_negotiator_ = | 667 terms_of_service_negotiator_ = |
675 base::MakeUnique<ArcTermsOfServiceDefaultNegotiator>( | 668 base::MakeUnique<ArcTermsOfServiceDefaultNegotiator>( |
676 profile_->GetPrefs(), support_host_.get()); | 669 profile_->GetPrefs(), support_host_.get()); |
670 } else { | |
671 // The only case reached here is when g_disable_ui_for_testing is set | |
672 // so ARC support host is not created in SetProfile(), for testing purpose. | |
673 DCHECK(g_disable_ui_for_testing) | |
674 << "Negotiator is not created on production."; | |
675 return; | |
677 } | 676 } |
678 | 677 |
679 if (terms_of_service_negotiator_) { | 678 terms_of_service_negotiator_->StartNegotiation( |
680 terms_of_service_negotiator_->StartNegotiation( | 679 base::Bind(&ArcSessionManager::OnTermsOfServiceNegotiated, |
681 base::Bind(&ArcSessionManager::OnTermsOfServiceNegotiated, | 680 weak_ptr_factory_.GetWeakPtr())); |
682 weak_ptr_factory_.GetWeakPtr())); | |
683 } | |
684 } | 681 } |
685 | 682 |
686 void ArcSessionManager::OnTermsOfServiceNegotiated(bool accepted) { | 683 void ArcSessionManager::OnTermsOfServiceNegotiated(bool accepted) { |
684 DCHECK_EQ(state_, State::NEGOTIATING_TERMS_OF_SERVICE); | |
685 DCHECK(profile_); | |
687 DCHECK(terms_of_service_negotiator_); | 686 DCHECK(terms_of_service_negotiator_); |
688 terms_of_service_negotiator_.reset(); | 687 terms_of_service_negotiator_.reset(); |
689 | 688 |
690 if (!accepted) { | 689 if (!accepted) { |
691 // To cancel, user needs to close the window. Note that clicking "Cancel" | 690 // User does not accept the Terms of Service. Disable Google Play Store. |
692 // button effectively just closes the window. | 691 MaybeUpdateOptInCancelUMA(support_host_.get()); |
693 CancelAuthCode(); | 692 SetArcPlayStoreEnabledForProfile(profile_, false); |
694 return; | 693 return; |
695 } | 694 } |
696 | 695 |
697 // Terms were accepted. | 696 // Terms were accepted. |
698 profile_->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, true); | 697 profile_->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, true); |
698 StartAndroidManagementCheck(); | |
699 } | |
699 | 700 |
700 // Don't show UI for this progress if it was not shown. | 701 bool ArcSessionManager::IsArcTermsOfServiceNegotiationNeeded() const { |
701 if (support_host_ && | 702 DCHECK(profile_); |
702 support_host_->ui_page() != ArcSupportHost::UIPage::NO_PAGE) | 703 |
703 support_host_->ShowArcLoading(); | 704 // Skip to show UI asking users to set up ARC OptIn preferences, if all of |
704 StartAndroidManagementCheck(); | 705 // them are managed by the admin policy. Note that the ToS agreement is anyway |
706 // not shown in the case of the managed ARC. | |
707 if (AreArcAllOptInPreferencesManagedForProfile(profile_)) { | |
708 VLOG(1) << "All opt-in preferences are under managed. " | |
709 << "Skip ARC Terms of Service negotiation."; | |
710 return false; | |
711 } | |
712 | |
713 // If it is marked that the Terms of service is accepted already, | |
714 // just skip the negotiation with user, and start Android management | |
715 // check directly. | |
716 // This happens, e.g., when a user accepted the Terms of service on Opt-in | |
717 // flow, but logged out before ARC sign in procedure was done. Then, logs | |
718 // in again. | |
719 if (profile_->GetPrefs()->GetBoolean(prefs::kArcTermsAccepted)) { | |
720 VLOG(1) << "The user already accepts ARC Terms of Service."; | |
721 return false; | |
722 } | |
723 | |
724 return true; | |
705 } | 725 } |
706 | 726 |
707 void ArcSessionManager::StartAndroidManagementCheck() { | 727 void ArcSessionManager::StartAndroidManagementCheck() { |
708 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 728 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
709 DCHECK(arc_session_runner_->IsStopped()); | 729 DCHECK(arc_session_runner_->IsStopped()); |
710 DCHECK(state_ == State::SHOWING_TERMS_OF_SERVICE || | 730 DCHECK(state_ == State::NEGOTIATING_TERMS_OF_SERVICE || |
711 state_ == State::CHECKING_ANDROID_MANAGEMENT || | 731 state_ == State::CHECKING_ANDROID_MANAGEMENT); |
712 (state_ == State::STOPPED && | |
713 profile_->GetPrefs()->GetBoolean(prefs::kArcTermsAccepted))); | |
714 DCHECK(!android_management_checker_); | |
715 SetState(State::CHECKING_ANDROID_MANAGEMENT); | 732 SetState(State::CHECKING_ANDROID_MANAGEMENT); |
716 | 733 |
734 // Show loading UI only if ARC support app's window is already shown. | |
735 // User may not see any ARC support UI if everything needed is done in | |
736 // background. In such a case, showing loading UI here (then closed sometime | |
737 // soon later) would look just noisy. | |
738 if (support_host_ && | |
739 support_host_->ui_page() != ArcSupportHost::UIPage::NO_PAGE) { | |
740 support_host_->ShowArcLoading(); | |
741 } | |
742 | |
717 android_management_checker_ = base::MakeUnique<ArcAndroidManagementChecker>( | 743 android_management_checker_ = base::MakeUnique<ArcAndroidManagementChecker>( |
718 profile_, context_->token_service(), context_->account_id(), | 744 profile_, context_->token_service(), context_->account_id(), |
719 false /* retry_on_error */); | 745 false /* retry_on_error */); |
720 android_management_checker_->StartCheck( | 746 android_management_checker_->StartCheck( |
721 base::Bind(&ArcSessionManager::OnAndroidManagementChecked, | 747 base::Bind(&ArcSessionManager::OnAndroidManagementChecked, |
722 weak_ptr_factory_.GetWeakPtr())); | 748 weak_ptr_factory_.GetWeakPtr())); |
723 } | 749 } |
724 | 750 |
725 void ArcSessionManager::OnAndroidManagementChecked( | 751 void ArcSessionManager::OnAndroidManagementChecked( |
726 policy::AndroidManagementClient::Result result) { | 752 policy::AndroidManagementClient::Result result) { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
860 support_host_->ShowArcLoading(); | 886 support_host_->ShowArcLoading(); |
861 ShutdownSession(); | 887 ShutdownSession(); |
862 reenable_arc_ = true; | 888 reenable_arc_ = true; |
863 } else if (state_ == State::ACTIVE) { | 889 } else if (state_ == State::ACTIVE) { |
864 // This case is handled in ArcAuthService. | 890 // This case is handled in ArcAuthService. |
865 // Do nothing. | 891 // Do nothing. |
866 } else { | 892 } else { |
867 // Otherwise, we restart ARC. Note: this is the first boot case. | 893 // Otherwise, we restart ARC. Note: this is the first boot case. |
868 // For second or later boot, either ERROR_WITH_FEEDBACK case or ACTIVE | 894 // For second or later boot, either ERROR_WITH_FEEDBACK case or ACTIVE |
869 // case must hit. | 895 // case must hit. |
870 support_host_->ShowArcLoading(); | |
871 StartAndroidManagementCheck(); | 896 StartAndroidManagementCheck(); |
872 } | 897 } |
873 } | 898 } |
874 | 899 |
875 void ArcSessionManager::OnSendFeedbackClicked() { | 900 void ArcSessionManager::OnSendFeedbackClicked() { |
876 DCHECK(support_host_); | 901 DCHECK(support_host_); |
877 chrome::OpenFeedbackDialog(nullptr); | 902 chrome::OpenFeedbackDialog(nullptr); |
878 } | 903 } |
879 | 904 |
880 void ArcSessionManager::SetArcSessionRunnerForTesting( | 905 void ArcSessionManager::SetArcSessionRunnerForTesting( |
(...skipping 14 matching lines...) Expand all Loading... | |
895 | 920 |
896 std::ostream& operator<<(std::ostream& os, | 921 std::ostream& operator<<(std::ostream& os, |
897 const ArcSessionManager::State& state) { | 922 const ArcSessionManager::State& state) { |
898 #define MAP_STATE(name) \ | 923 #define MAP_STATE(name) \ |
899 case ArcSessionManager::State::name: \ | 924 case ArcSessionManager::State::name: \ |
900 return os << #name | 925 return os << #name |
901 | 926 |
902 switch (state) { | 927 switch (state) { |
903 MAP_STATE(NOT_INITIALIZED); | 928 MAP_STATE(NOT_INITIALIZED); |
904 MAP_STATE(STOPPED); | 929 MAP_STATE(STOPPED); |
905 MAP_STATE(SHOWING_TERMS_OF_SERVICE); | 930 MAP_STATE(NEGOTIATING_TERMS_OF_SERVICE); |
906 MAP_STATE(CHECKING_ANDROID_MANAGEMENT); | 931 MAP_STATE(CHECKING_ANDROID_MANAGEMENT); |
907 MAP_STATE(REMOVING_DATA_DIR); | 932 MAP_STATE(REMOVING_DATA_DIR); |
908 MAP_STATE(ACTIVE); | 933 MAP_STATE(ACTIVE); |
909 } | 934 } |
910 | 935 |
911 #undef MAP_STATE | 936 #undef MAP_STATE |
912 | 937 |
913 // Some compilers report an error even if all values of an enum-class are | 938 // Some compilers report an error even if all values of an enum-class are |
914 // covered exhaustively in a switch statement. | 939 // covered exhaustively in a switch statement. |
915 NOTREACHED() << "Invalid value " << static_cast<int>(state); | 940 NOTREACHED() << "Invalid value " << static_cast<int>(state); |
916 return os; | 941 return os; |
917 } | 942 } |
918 | 943 |
919 } // namespace arc | 944 } // namespace arc |
OLD | NEW |