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

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

Issue 2485233002: Do not run Android management check for re-auth case. (Closed)
Patch Set: rebase Created 4 years, 1 month 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 "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 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 return account_info_notifier_ != nullptr; 439 return account_info_notifier_ != nullptr;
440 } 440 }
441 441
442 void ArcAuthService::PrepareContextForAuthCodeRequest() { 442 void ArcAuthService::PrepareContextForAuthCodeRequest() {
443 // Requesting auth code on demand happens in following cases: 443 // Requesting auth code on demand happens in following cases:
444 // 1. To handle account password revoke. 444 // 1. To handle account password revoke.
445 // 2. In case Arc is activated in OOBE flow. 445 // 2. In case Arc is activated in OOBE flow.
446 // 3. For any other state on Android side that leads device appears in 446 // 3. For any other state on Android side that leads device appears in
447 // non-signed state. 447 // non-signed state.
448 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 448 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
449 DCHECK(state_ != State::ACTIVE || IsAuthCodeRequest()); 449 DCHECK(state_ == State::FETCHING_CODE || state_ == State::ACTIVE);
450 if (state_ == State::ACTIVE)
451 DCHECK(IsAuthCodeRequest());
450 DCHECK(!IsArcKioskMode()); 452 DCHECK(!IsArcKioskMode());
451 context_->PrepareContext(); 453 context_->PrepareContext();
452 } 454 }
453 455
454 void ArcAuthService::OnSignInComplete() { 456 void ArcAuthService::OnSignInComplete() {
455 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 457 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
456 DCHECK_EQ(state_, State::ACTIVE); 458 DCHECK_EQ(state_, State::ACTIVE);
457 459
458 if (!sign_in_time_.is_null()) { 460 if (!sign_in_time_.is_null()) {
459 arc_sign_in_timer_.Stop(); 461 arc_sign_in_timer_.Stop();
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 // TODO(hidehiko): Revisit to think about lazy initialization. 592 // TODO(hidehiko): Revisit to think about lazy initialization.
591 support_host_.reset(new ArcSupportHost()); 593 support_host_.reset(new ArcSupportHost());
592 support_host_->AddObserver(this); 594 support_host_->AddObserver(this);
593 if (!g_disable_ui_for_testing && !IsOptInVerificationDisabled()) { 595 if (!g_disable_ui_for_testing && !IsOptInVerificationDisabled()) {
594 preference_handler_ = base::MakeUnique<arc::ArcOptInPreferenceHandler>( 596 preference_handler_ = base::MakeUnique<arc::ArcOptInPreferenceHandler>(
595 this, profile_->GetPrefs()); 597 this, profile_->GetPrefs());
596 // This automatically updates all preferences. 598 // This automatically updates all preferences.
597 preference_handler_->Start(); 599 preference_handler_->Start();
598 } 600 }
599 601
602 DCHECK_EQ(State::NOT_INITIALIZED, state_);
600 SetState(State::STOPPED); 603 SetState(State::STOPPED);
601 604
602 PrefServiceSyncableFromProfile(profile_)->AddSyncedPrefObserver( 605 PrefServiceSyncableFromProfile(profile_)->AddSyncedPrefObserver(
603 prefs::kArcEnabled, this); 606 prefs::kArcEnabled, this);
604 607
605 context_.reset(new ArcAuthContext(this, profile_)); 608 context_.reset(new ArcAuthContext(this, profile_));
606 609
607 // In case UI is disabled we assume that ARC is opted-in. For ARC Kiosk we 610 // In case UI is disabled we assume that ARC is opted-in. For ARC Kiosk we
608 // skip ToS because it is very likely that near the device there will be 611 // skip ToS because it is very likely that near the device there will be
609 // no one who is eligible to accept them. We skip if Android management check 612 // no one who is eligible to accept them. We skip if Android management check
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 ArcSupportHost::kHostAppId); 687 ArcSupportHost::kHostAppId);
685 CHECK(extension && extensions::util::IsAppLaunchable( 688 CHECK(extension && extensions::util::IsAppLaunchable(
686 ArcSupportHost::kHostAppId, profile_)); 689 ArcSupportHost::kHostAppId, profile_));
687 OpenApplication(CreateAppLaunchParamsUserContainer( 690 OpenApplication(CreateAppLaunchParamsUserContainer(
688 profile_, extension, WindowOpenDisposition::NEW_WINDOW, 691 profile_, extension, WindowOpenDisposition::NEW_WINDOW,
689 extensions::SOURCE_CHROME_INTERNAL)); 692 extensions::SOURCE_CHROME_INTERNAL));
690 } 693 }
691 694
692 void ArcAuthService::OnContextReady() { 695 void ArcAuthService::OnContextReady() {
693 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 696 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
694 697 FetchAuthCode();
695 // TODO(hidehiko): The check is not necessary if this is a part of re-auth
696 // flow and OOBE OptIn where Android Management check must be a part of
697 // checking if Arc OptIn should be skip. Remove this.
698 android_management_checker_.reset(new ArcAndroidManagementChecker(
699 profile_, context_->token_service(), context_->account_id(),
700 false /* retry_on_error */));
701 android_management_checker_->StartCheck(
702 base::Bind(&ArcAuthService::OnAndroidManagementChecked,
703 weak_ptr_factory_.GetWeakPtr()));
704 } 698 }
705 699
706 void ArcAuthService::OnSyncedPrefChanged(const std::string& path, 700 void ArcAuthService::OnSyncedPrefChanged(const std::string& path,
707 bool from_sync) { 701 bool from_sync) {
708 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 702 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
709 703
710 // Update UMA only for local changes 704 // Update UMA only for local changes
711 if (!from_sync) { 705 if (!from_sync) {
712 const bool arc_enabled = 706 const bool arc_enabled =
713 profile_->GetPrefs()->GetBoolean(prefs::kArcEnabled); 707 profile_->GetPrefs()->GetBoolean(prefs::kArcEnabled);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 837 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
844 arc_bridge_service()->RequestStart(); 838 arc_bridge_service()->RequestStart();
845 SetState(State::ACTIVE); 839 SetState(State::ACTIVE);
846 } 840 }
847 841
848 void ArcAuthService::SetAuthCodeAndStartArc(const std::string& auth_code) { 842 void ArcAuthService::SetAuthCodeAndStartArc(const std::string& auth_code) {
849 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 843 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
850 DCHECK(!auth_code.empty()); 844 DCHECK(!auth_code.empty());
851 845
852 if (IsAuthCodeRequest()) { 846 if (IsAuthCodeRequest()) {
853 DCHECK_EQ(state_, State::FETCHING_CODE);
854 SetState(State::ACTIVE);
855 account_info_notifier_->Notify(!IsOptInVerificationDisabled(), auth_code, 847 account_info_notifier_->Notify(!IsOptInVerificationDisabled(), auth_code,
856 GetAccountType(), 848 GetAccountType(),
857 policy_util::IsAccountManaged(profile_)); 849 policy_util::IsAccountManaged(profile_));
858 account_info_notifier_.reset(); 850 account_info_notifier_.reset();
859 return; 851 return;
860 } 852 }
861 853
862 if (state_ != State::FETCHING_CODE) { 854 if (state_ != State::SHOWING_TERMS_OF_SERVICE &&
855 state_ != State::CHECKING_ANDROID_MANAGEMENT &&
856 state_ != State::FETCHING_CODE) {
863 ShutdownBridgeAndCloseUI(); 857 ShutdownBridgeAndCloseUI();
864 return; 858 return;
865 } 859 }
866 860
867 sign_in_time_ = base::Time::Now(); 861 sign_in_time_ = base::Time::Now();
868 VLOG(1) << "Starting ARC for first sign in."; 862 VLOG(1) << "Starting ARC for first sign in.";
869 863
870 SetUIPage(ArcSupportHost::UIPage::START_PROGRESS, base::string16()); 864 SetUIPage(ArcSupportHost::UIPage::START_PROGRESS, base::string16());
871 ShutdownBridge(); 865 ShutdownBridge();
872 auth_code_ = auth_code; 866 auth_code_ = auth_code;
873 arc_sign_in_timer_.Start(FROM_HERE, kArcSignInTimeout, 867 arc_sign_in_timer_.Start(FROM_HERE, kArcSignInTimeout,
874 base::Bind(&ArcAuthService::OnArcSignInTimeout, 868 base::Bind(&ArcAuthService::OnArcSignInTimeout,
875 weak_ptr_factory_.GetWeakPtr())); 869 weak_ptr_factory_.GetWeakPtr()));
876 StartArc(); 870 StartArc();
877 } 871 }
878 872
879 void ArcAuthService::OnArcSignInTimeout() { 873 void ArcAuthService::OnArcSignInTimeout() {
880 LOG(ERROR) << "Timed out waiting for first sign in."; 874 LOG(ERROR) << "Timed out waiting for first sign in.";
881 OnSignInFailedInternal(ProvisioningResult::OVERALL_SIGN_IN_TIMEOUT); 875 OnSignInFailedInternal(ProvisioningResult::OVERALL_SIGN_IN_TIMEOUT);
882 } 876 }
883 877
884 void ArcAuthService::StartLso() {
885 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
886
887 // Terms were accepted
888 profile_->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, true);
889
890 // Update UMA only if error (with or without feedback) is currently shown.
891 if (ui_page_ == ArcSupportHost::UIPage::ERROR) {
892 UpdateOptInActionUMA(OptInActionType::RETRY);
893 } else if (ui_page_ == ArcSupportHost::UIPage::ERROR_WITH_FEEDBACK) {
894 UpdateOptInActionUMA(OptInActionType::RETRY);
895 ShutdownBridge();
896 }
897
898 DCHECK(arc_bridge_service()->stopped());
899 SetState(State::FETCHING_CODE);
900 PrepareContextForAuthCodeRequest();
901 }
902
903 void ArcAuthService::CancelAuthCode() { 878 void ArcAuthService::CancelAuthCode() {
904 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 879 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
905 880
906 if (state_ == State::NOT_INITIALIZED) { 881 if (state_ == State::NOT_INITIALIZED) {
907 NOTREACHED(); 882 NOTREACHED();
908 return; 883 return;
909 } 884 }
910 885
911 // In case |state_| is ACTIVE, |ui_page_| can be START_PROGRESS (which means 886 // In case |state_| is ACTIVE, |ui_page_| can be START_PROGRESS (which means
912 // normal Arc booting) or ERROR or ERROR_WITH_FEEDBACK (in case Arc can not 887 // normal Arc booting) or ERROR or ERROR_WITH_FEEDBACK (in case Arc can not
913 // be started). If Arc is booting normally dont't stop it on progress close. 888 // be started). If Arc is booting normally dont't stop it on progress close.
914 if (state_ != State::FETCHING_CODE && 889 if ((state_ != State::FETCHING_CODE &&
890 state_ != State::SHOWING_TERMS_OF_SERVICE &&
891 state_ != State::CHECKING_ANDROID_MANAGEMENT) &&
915 ui_page_ != ArcSupportHost::UIPage::ERROR && 892 ui_page_ != ArcSupportHost::UIPage::ERROR &&
916 ui_page_ != ArcSupportHost::UIPage::ERROR_WITH_FEEDBACK) { 893 ui_page_ != ArcSupportHost::UIPage::ERROR_WITH_FEEDBACK) {
917 return; 894 return;
918 } 895 }
919 896
920 // Update UMA with user cancel only if error is not currently shown. 897 // Update UMA with user cancel only if error is not currently shown.
921 if (ui_page_ != ArcSupportHost::UIPage::NO_PAGE && 898 if (ui_page_ != ArcSupportHost::UIPage::NO_PAGE &&
922 ui_page_ != ArcSupportHost::UIPage::ERROR && 899 ui_page_ != ArcSupportHost::UIPage::ERROR &&
923 ui_page_ != ArcSupportHost::UIPage::ERROR_WITH_FEEDBACK) { 900 ui_page_ != ArcSupportHost::UIPage::ERROR_WITH_FEEDBACK) {
924 UpdateOptInCancelUMA(OptInCancelReason::USER_CANCEL); 901 UpdateOptInCancelUMA(OptInCancelReason::USER_CANCEL);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 955
979 if (!arc_bridge_service()->stopped()) { 956 if (!arc_bridge_service()->stopped()) {
980 // If the user attempts to re-enable ARC while the bridge is still running 957 // If the user attempts to re-enable ARC while the bridge is still running
981 // the user should not be able to continue until the bridge has stopped. 958 // the user should not be able to continue until the bridge has stopped.
982 ShowUI( 959 ShowUI(
983 ArcSupportHost::UIPage::ERROR, 960 ArcSupportHost::UIPage::ERROR,
984 l10n_util::GetStringUTF16(IDS_ARC_SIGN_IN_SERVICE_UNAVAILABLE_ERROR)); 961 l10n_util::GetStringUTF16(IDS_ARC_SIGN_IN_SERVICE_UNAVAILABLE_ERROR));
985 return; 962 return;
986 } 963 }
987 964
988 SetState(State::FETCHING_CODE); 965 SetState(State::SHOWING_TERMS_OF_SERVICE);
989 ShowUI(ArcSupportHost::UIPage::TERMS, base::string16()); 966 ShowUI(ArcSupportHost::UIPage::TERMS, base::string16());
990 } 967 }
991 968
992 void ArcAuthService::OnPrepareContextFailed() { 969 void ArcAuthService::OnPrepareContextFailed() {
993 DCHECK_EQ(state_, State::FETCHING_CODE); 970 DCHECK_EQ(state_, State::FETCHING_CODE);
994 971
995 ShutdownBridgeAndShowUI( 972 ShutdownBridgeAndShowUI(
996 ArcSupportHost::UIPage::ERROR, 973 ArcSupportHost::UIPage::ERROR,
997 l10n_util::GetStringUTF16(IDS_ARC_SERVER_COMMUNICATION_ERROR)); 974 l10n_util::GetStringUTF16(IDS_ARC_SERVER_COMMUNICATION_ERROR));
998 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR); 975 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR);
999 } 976 }
1000 977
1001 void ArcAuthService::OnAuthCodeSuccess(const std::string& auth_code) { 978 void ArcAuthService::OnAuthCodeSuccess(const std::string& auth_code) {
1002 SetAuthCodeAndStartArc(auth_code); 979 SetAuthCodeAndStartArc(auth_code);
1003 } 980 }
1004 981
1005 void ArcAuthService::OnAuthCodeFailed() { 982 void ArcAuthService::OnAuthCodeFailed() {
1006 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 983 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
1007 DCHECK_EQ(state_, State::FETCHING_CODE); 984 DCHECK_EQ(state_, State::FETCHING_CODE);
1008 ShutdownBridgeAndShowUI( 985 ShutdownBridgeAndShowUI(
1009 ArcSupportHost::UIPage::ERROR, 986 ArcSupportHost::UIPage::ERROR,
1010 l10n_util::GetStringUTF16(IDS_ARC_SERVER_COMMUNICATION_ERROR)); 987 l10n_util::GetStringUTF16(IDS_ARC_SERVER_COMMUNICATION_ERROR));
1011 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR); 988 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR);
1012 } 989 }
1013 990
991 void ArcAuthService::StartArcAndroidManagementCheck() {
992 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
993 DCHECK(arc_bridge_service()->stopped());
994 DCHECK(state_ == State::SHOWING_TERMS_OF_SERVICE ||
995 state_ == State::CHECKING_ANDROID_MANAGEMENT);
996 SetState(State::CHECKING_ANDROID_MANAGEMENT);
997
998 android_management_checker_.reset(new ArcAndroidManagementChecker(
999 profile_, context_->token_service(), context_->account_id(),
1000 false /* retry_on_error */));
1001 android_management_checker_->StartCheck(
1002 base::Bind(&ArcAuthService::OnAndroidManagementChecked,
1003 weak_ptr_factory_.GetWeakPtr()));
1004 }
1005
1014 void ArcAuthService::OnAndroidManagementChecked( 1006 void ArcAuthService::OnAndroidManagementChecked(
1015 policy::AndroidManagementClient::Result result) { 1007 policy::AndroidManagementClient::Result result) {
1016 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 1008 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
1009 DCHECK_EQ(state_, State::CHECKING_ANDROID_MANAGEMENT);
1010
1017 switch (result) { 1011 switch (result) {
1018 case policy::AndroidManagementClient::Result::UNMANAGED: 1012 case policy::AndroidManagementClient::Result::UNMANAGED:
1019 OnAndroidManagementPassed(); 1013 if (IsOptInVerificationDisabled()) {
1014 StartArc();
1015 } else {
1016 // TODO(hidehiko): Merge this prefetching into re-auth case.
1017 SetState(State::FETCHING_CODE);
1018 PrepareContextForAuthCodeRequest();
1019 }
1020 break; 1020 break;
1021 case policy::AndroidManagementClient::Result::MANAGED: 1021 case policy::AndroidManagementClient::Result::MANAGED:
1022 ShutdownBridgeAndShowUI( 1022 ShutdownBridgeAndShowUI(
1023 ArcSupportHost::UIPage::ERROR, 1023 ArcSupportHost::UIPage::ERROR,
1024 l10n_util::GetStringUTF16(IDS_ARC_ANDROID_MANAGEMENT_REQUIRED_ERROR)); 1024 l10n_util::GetStringUTF16(IDS_ARC_ANDROID_MANAGEMENT_REQUIRED_ERROR));
1025 UpdateOptInCancelUMA(OptInCancelReason::ANDROID_MANAGEMENT_REQUIRED); 1025 UpdateOptInCancelUMA(OptInCancelReason::ANDROID_MANAGEMENT_REQUIRED);
1026 break; 1026 break;
1027 case policy::AndroidManagementClient::Result::ERROR: 1027 case policy::AndroidManagementClient::Result::ERROR:
1028 ShutdownBridgeAndShowUI( 1028 ShutdownBridgeAndShowUI(
1029 ArcSupportHost::UIPage::ERROR, 1029 ArcSupportHost::UIPage::ERROR,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 } 1062 }
1063 1063
1064 if (!auth_endpoint.empty()) { 1064 if (!auth_endpoint.empty()) {
1065 auth_code_fetcher_.reset(new ArcAuthCodeFetcher( 1065 auth_code_fetcher_.reset(new ArcAuthCodeFetcher(
1066 this, context_->GetURLRequestContext(), profile_, auth_endpoint)); 1066 this, context_->GetURLRequestContext(), profile_, auth_endpoint));
1067 } else { 1067 } else {
1068 ShowUI(ArcSupportHost::UIPage::LSO_PROGRESS, base::string16()); 1068 ShowUI(ArcSupportHost::UIPage::LSO_PROGRESS, base::string16());
1069 } 1069 }
1070 } 1070 }
1071 1071
1072 void ArcAuthService::OnAndroidManagementPassed() {
1073 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
1074
1075 if (state_ == State::ACTIVE) {
1076 if (IsAuthCodeRequest())
1077 FetchAuthCode();
1078 return;
1079 }
1080
1081 if (profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn) ||
1082 IsOptInVerificationDisabled()) {
1083 StartArc();
1084 } else {
1085 FetchAuthCode();
1086 }
1087 }
1088
1089 void ArcAuthService::OnWindowClosed() { 1072 void ArcAuthService::OnWindowClosed() {
1090 CancelAuthCode(); 1073 CancelAuthCode();
1091 } 1074 }
1092 1075
1093 void ArcAuthService::OnTermsAgreed(bool is_metrics_enabled, 1076 void ArcAuthService::OnTermsAgreed(bool is_metrics_enabled,
1094 bool is_backup_and_restore_enabled, 1077 bool is_backup_and_restore_enabled,
1095 bool is_location_service_enabled) { 1078 bool is_location_service_enabled) {
1079 // Terms were accepted
1080 profile_->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, true);
1081
1096 // This is ARC support's UI event callback, so this is called only when 1082 // This is ARC support's UI event callback, so this is called only when
1097 // the UI is visible. The condition to open the UI is 1083 // the UI is visible. The condition to open the UI is
1098 // !g_disable_ui_for_testing && !IsOptInVerificationDisabled() (see ShowUI()) 1084 // !g_disable_ui_for_testing && !IsOptInVerificationDisabled() (see ShowUI())
1099 // and in the case, preference_handler_ should be always created (see 1085 // and in the case, preference_handler_ should be always created (see
1100 // OnPrimaryUserProfilePrepared()), 1086 // OnPrimaryUserProfilePrepared()),
1101 // TODO(hidehiko): Simplify the logic with the code restructuring. 1087 // TODO(hidehiko): Simplify the logic with the code restructuring.
1102 DCHECK(preference_handler_); 1088 DCHECK(preference_handler_);
1103 preference_handler_->EnableMetrics(is_metrics_enabled); 1089 preference_handler_->EnableMetrics(is_metrics_enabled);
1104 preference_handler_->EnableBackupRestore(is_backup_and_restore_enabled); 1090 preference_handler_->EnableBackupRestore(is_backup_and_restore_enabled);
1105 preference_handler_->EnableLocationService(is_location_service_enabled); 1091 preference_handler_->EnableLocationService(is_location_service_enabled);
1106 StartLso(); 1092 StartArcAndroidManagementCheck();
1107 } 1093 }
1108 1094
1109 void ArcAuthService::OnAuthSucceeded(const std::string& auth_code) { 1095 void ArcAuthService::OnAuthSucceeded(const std::string& auth_code) {
1110 SetAuthCodeAndStartArc(auth_code); 1096 SetAuthCodeAndStartArc(auth_code);
1111 } 1097 }
1112 1098
1099 void ArcAuthService::OnRetryClicked() {
1100 UpdateOptInActionUMA(OptInActionType::RETRY);
1101 // ERROR_WITH_FEEDBACK is set in OnSignInFailed(). In the case, we postpone
1102 // to stop the ARC to obtain the internal state.
1103 // Here, on retry, stop it.
1104 if (ui_page_ == ArcSupportHost::UIPage::ERROR_WITH_FEEDBACK)
1105 ShutdownBridge();
1106
1107 switch (state_) {
1108 case State::NOT_INITIALIZED:
1109 NOTREACHED();
1110 break;
1111 case State::STOPPED:
1112 case State::SHOWING_TERMS_OF_SERVICE:
1113 ShowUI(ArcSupportHost::UIPage::TERMS, base::string16());
1114 break;
1115 case State::CHECKING_ANDROID_MANAGEMENT:
1116 StartArcAndroidManagementCheck();
1117 break;
1118 case State::FETCHING_CODE:
1119 case State::ACTIVE:
1120 PrepareContextForAuthCodeRequest();
1121 break;
1122 }
1123 }
1124
1113 void ArcAuthService::OnSendFeedbackClicked() { 1125 void ArcAuthService::OnSendFeedbackClicked() {
1114 chrome::OpenFeedbackDialog(nullptr); 1126 chrome::OpenFeedbackDialog(nullptr);
1115 } 1127 }
1116 1128
1117 void ArcAuthService::OnMetricsModeChanged(bool enabled, bool managed) { 1129 void ArcAuthService::OnMetricsModeChanged(bool enabled, bool managed) {
1118 if (!support_host_) 1130 if (!support_host_)
1119 return; 1131 return;
1120 support_host_->SetMetricsPreferenceCheckbox(enabled, managed); 1132 support_host_->SetMetricsPreferenceCheckbox(enabled, managed);
1121 } 1133 }
1122 1134
1123 void ArcAuthService::OnBackupAndRestoreModeChanged(bool enabled, bool managed) { 1135 void ArcAuthService::OnBackupAndRestoreModeChanged(bool enabled, bool managed) {
1124 if (!support_host_) 1136 if (!support_host_)
1125 return; 1137 return;
1126 support_host_->SetBackupAndRestorePreferenceCheckbox(enabled, managed); 1138 support_host_->SetBackupAndRestorePreferenceCheckbox(enabled, managed);
1127 } 1139 }
1128 1140
1129 void ArcAuthService::OnLocationServicesModeChanged(bool enabled, bool managed) { 1141 void ArcAuthService::OnLocationServicesModeChanged(bool enabled, bool managed) {
1130 if (!support_host_) 1142 if (!support_host_)
1131 return; 1143 return;
1132 support_host_->SetLocationServicesPreferenceCheckbox(enabled, managed); 1144 support_host_->SetLocationServicesPreferenceCheckbox(enabled, managed);
1133 } 1145 }
1134 1146
1135 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state) { 1147 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state) {
1136 switch (state) { 1148 switch (state) {
1137 case ArcAuthService::State::NOT_INITIALIZED: 1149 case ArcAuthService::State::NOT_INITIALIZED:
1138 return os << "NOT_INITIALIZED"; 1150 return os << "NOT_INITIALIZED";
1139 case ArcAuthService::State::STOPPED: 1151 case ArcAuthService::State::STOPPED:
1140 return os << "STOPPED"; 1152 return os << "STOPPED";
1153 case ArcAuthService::State::SHOWING_TERMS_OF_SERVICE:
1154 return os << "SHOWING_TERMS_OF_SERVICE";
1155 case ArcAuthService::State::CHECKING_ANDROID_MANAGEMENT:
1156 return os << "CHECKING_ANDROID_MANAGEMENT";
1141 case ArcAuthService::State::FETCHING_CODE: 1157 case ArcAuthService::State::FETCHING_CODE:
1142 return os << "FETCHING_CODE"; 1158 return os << "FETCHING_CODE";
1143 case ArcAuthService::State::ACTIVE: 1159 case ArcAuthService::State::ACTIVE:
1144 return os << "ACTIVE"; 1160 return os << "ACTIVE";
1145 } 1161 }
1146 1162
1147 // Some compiler reports an error even if all values of an enum-class are 1163 // Some compiler reports an error even if all values of an enum-class are
1148 // covered indivisually in a switch statement. 1164 // covered indivisually in a switch statement.
1149 NOTREACHED(); 1165 NOTREACHED();
1150 return os; 1166 return os;
1151 } 1167 }
1152 1168
1153 } // namespace arc 1169 } // namespace arc
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/arc/arc_auth_service.h ('k') | chrome/browser/chromeos/arc/arc_auth_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698