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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 388 } | 388 } |
| 389 | 389 |
| 390 account_info_notifier_ = std::move(account_info_notifier); | 390 account_info_notifier_ = std::move(account_info_notifier); |
| 391 PrepareContextForAuthCodeRequest(); | 391 PrepareContextForAuthCodeRequest(); |
| 392 } | 392 } |
| 393 | 393 |
| 394 bool ArcAuthService::IsAuthCodeRequest() const { | 394 bool ArcAuthService::IsAuthCodeRequest() const { |
| 395 return account_info_notifier_ != nullptr; | 395 return account_info_notifier_ != nullptr; |
| 396 } | 396 } |
| 397 | 397 |
| 398 void ArcAuthService::PrepareContextForAuthCodeRequest() { | 398 void ArcAuthService::PrepareContextForAuthCodeRequest() { |
|
Luis Héctor Chávez
2016/11/10 23:30:58
Is it possible to split this method so we have tig
hidehiko
2016/11/14 10:55:09
Hmm... Maybe I do not understand what you mean.
D
Luis Héctor Chávez
2016/11/14 17:06:50
If this will be addressed in a following CL, then
hidehiko
2016/11/14 19:07:57
I will. However, TBH, I do not think it is reasona
| |
| 399 // Requesting auth code on demand happens in following cases: | 399 // Requesting auth code on demand happens in following cases: |
| 400 // 1. To handle account password revoke. | 400 // 1. To handle account password revoke. |
| 401 // 2. In case Arc is activated in OOBE flow. | 401 // 2. In case Arc is activated in OOBE flow. |
| 402 // 3. For any other state on Android side that leads device appears in | 402 // 3. For any other state on Android side that leads device appears in |
| 403 // non-signed state. | 403 // non-signed state. |
| 404 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 404 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 405 DCHECK(state_ != State::ACTIVE || IsAuthCodeRequest()); | 405 DCHECK(state_ != State::ACTIVE || IsAuthCodeRequest()); |
| 406 context_->PrepareContext(); | 406 context_->PrepareContext(); |
| 407 } | 407 } |
| 408 | 408 |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 628 ArcSupportHost::kHostAppId); | 628 ArcSupportHost::kHostAppId); |
| 629 CHECK(extension && extensions::util::IsAppLaunchable( | 629 CHECK(extension && extensions::util::IsAppLaunchable( |
| 630 ArcSupportHost::kHostAppId, profile_)); | 630 ArcSupportHost::kHostAppId, profile_)); |
| 631 OpenApplication(CreateAppLaunchParamsUserContainer( | 631 OpenApplication(CreateAppLaunchParamsUserContainer( |
| 632 profile_, extension, WindowOpenDisposition::NEW_WINDOW, | 632 profile_, extension, WindowOpenDisposition::NEW_WINDOW, |
| 633 extensions::SOURCE_CHROME_INTERNAL)); | 633 extensions::SOURCE_CHROME_INTERNAL)); |
| 634 } | 634 } |
| 635 | 635 |
| 636 void ArcAuthService::OnContextReady() { | 636 void ArcAuthService::OnContextReady() { |
| 637 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 637 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 638 | 638 FetchAuthCode(); |
| 639 // TODO(hidehiko): The check is not necessary if this is a part of re-auth | |
| 640 // flow and OOBE OptIn where Android Management check must be a part of | |
| 641 // checking if Arc OptIn should be skip. Remove this. | |
| 642 android_management_checker_.reset(new ArcAndroidManagementChecker( | |
| 643 profile_, context_->token_service(), context_->account_id(), | |
| 644 false /* retry_on_error */)); | |
| 645 android_management_checker_->StartCheck( | |
| 646 base::Bind(&ArcAuthService::OnAndroidManagementChecked, | |
| 647 weak_ptr_factory_.GetWeakPtr())); | |
| 648 } | 639 } |
| 649 | 640 |
| 650 void ArcAuthService::OnSyncedPrefChanged(const std::string& path, | 641 void ArcAuthService::OnSyncedPrefChanged(const std::string& path, |
| 651 bool from_sync) { | 642 bool from_sync) { |
| 652 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 643 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 653 | 644 |
| 654 // Update UMA only for local changes | 645 // Update UMA only for local changes |
| 655 if (!from_sync) { | 646 if (!from_sync) { |
| 656 const bool arc_enabled = | 647 const bool arc_enabled = |
| 657 profile_->GetPrefs()->GetBoolean(prefs::kArcEnabled); | 648 profile_->GetPrefs()->GetBoolean(prefs::kArcEnabled); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 787 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 778 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 788 arc_bridge_service()->RequestStart(); | 779 arc_bridge_service()->RequestStart(); |
| 789 SetState(State::ACTIVE); | 780 SetState(State::ACTIVE); |
| 790 } | 781 } |
| 791 | 782 |
| 792 void ArcAuthService::SetAuthCodeAndStartArc(const std::string& auth_code) { | 783 void ArcAuthService::SetAuthCodeAndStartArc(const std::string& auth_code) { |
| 793 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 784 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 794 DCHECK(!auth_code.empty()); | 785 DCHECK(!auth_code.empty()); |
| 795 | 786 |
| 796 if (IsAuthCodeRequest()) { | 787 if (IsAuthCodeRequest()) { |
| 797 DCHECK_EQ(state_, State::FETCHING_CODE); | |
|
hidehiko
2016/11/10 01:46:23
here, state_ should be State::ACTIVE in most cases
| |
| 798 SetState(State::ACTIVE); | |
| 799 account_info_notifier_->Notify(!IsOptInVerificationDisabled(), auth_code, | 788 account_info_notifier_->Notify(!IsOptInVerificationDisabled(), auth_code, |
| 800 mojom::ChromeAccountType::USER_ACCOUNT, | 789 mojom::ChromeAccountType::USER_ACCOUNT, |
| 801 policy_util::IsAccountManaged(profile_)); | 790 policy_util::IsAccountManaged(profile_)); |
| 802 account_info_notifier_.reset(); | 791 account_info_notifier_.reset(); |
| 803 return; | 792 return; |
| 804 } | 793 } |
| 805 | 794 |
| 806 if (state_ != State::FETCHING_CODE) { | 795 if (state_ != State::TERMS && state_ != State::ANDROID_MANAGEMENT_CHECK && |
| 796 state_ != State::FETCHING_CODE) { | |
| 807 ShutdownBridgeAndCloseUI(); | 797 ShutdownBridgeAndCloseUI(); |
| 808 return; | 798 return; |
| 809 } | 799 } |
| 810 | 800 |
| 811 sign_in_time_ = base::Time::Now(); | 801 sign_in_time_ = base::Time::Now(); |
| 812 VLOG(1) << "Starting ARC for first sign in."; | 802 VLOG(1) << "Starting ARC for first sign in."; |
| 813 | 803 |
| 814 SetUIPage(ArcSupportHost::UIPage::START_PROGRESS, base::string16()); | 804 SetUIPage(ArcSupportHost::UIPage::START_PROGRESS, base::string16()); |
| 815 ShutdownBridge(); | 805 ShutdownBridge(); |
| 816 auth_code_ = auth_code; | 806 auth_code_ = auth_code; |
| 817 arc_sign_in_timer_.Start(FROM_HERE, kArcSignInTimeout, | 807 arc_sign_in_timer_.Start(FROM_HERE, kArcSignInTimeout, |
| 818 base::Bind(&ArcAuthService::OnArcSignInTimeout, | 808 base::Bind(&ArcAuthService::OnArcSignInTimeout, |
| 819 weak_ptr_factory_.GetWeakPtr())); | 809 weak_ptr_factory_.GetWeakPtr())); |
| 820 StartArc(); | 810 StartArc(); |
| 821 } | 811 } |
| 822 | 812 |
| 823 void ArcAuthService::OnArcSignInTimeout() { | 813 void ArcAuthService::OnArcSignInTimeout() { |
| 824 LOG(ERROR) << "Timed out waiting for first sign in."; | 814 LOG(ERROR) << "Timed out waiting for first sign in."; |
| 825 OnSignInFailedInternal(ProvisioningResult::OVERALL_SIGN_IN_TIMEOUT); | 815 OnSignInFailedInternal(ProvisioningResult::OVERALL_SIGN_IN_TIMEOUT); |
| 826 } | 816 } |
| 827 | 817 |
| 828 void ArcAuthService::StartLso() { | 818 void ArcAuthService::StartLso() { |
| 829 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 819 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 830 | 820 |
| 831 // Terms were accepted | |
| 832 profile_->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, true); | |
|
hidehiko
2016/11/10 01:46:23
Note: Moved to OnTermsAccepted(). Actually, this i
| |
| 833 | |
| 834 // Update UMA only if error (with or without feedback) is currently shown. | |
| 835 if (ui_page_ == ArcSupportHost::UIPage::ERROR) { | |
| 836 UpdateOptInActionUMA(OptInActionType::RETRY); | |
| 837 } else if (ui_page_ == ArcSupportHost::UIPage::ERROR_WITH_FEEDBACK) { | |
| 838 UpdateOptInActionUMA(OptInActionType::RETRY); | |
| 839 ShutdownBridge(); | |
| 840 } | |
| 841 | |
| 842 DCHECK(arc_bridge_service()->stopped()); | 821 DCHECK(arc_bridge_service()->stopped()); |
| 843 SetState(State::FETCHING_CODE); | 822 SetState(State::ANDROID_MANAGEMENT_CHECK); |
|
xiyuan
2016/11/10 17:55:21
Why ANDROID_MANAGEMENT_CHECK instead of FETCHING_C
hidehiko
2016/11/14 10:55:09
Sorry this was my mistake. We no longer need Start
| |
| 844 PrepareContextForAuthCodeRequest(); | 823 PrepareContextForAuthCodeRequest(); |
| 845 } | 824 } |
| 846 | 825 |
| 847 void ArcAuthService::CancelAuthCode() { | 826 void ArcAuthService::CancelAuthCode() { |
| 848 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 827 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 849 | 828 |
| 850 if (state_ == State::NOT_INITIALIZED) { | 829 if (state_ == State::NOT_INITIALIZED) { |
| 851 NOTREACHED(); | 830 NOTREACHED(); |
| 852 return; | 831 return; |
| 853 } | 832 } |
| 854 | 833 |
| 855 // In case |state_| is ACTIVE, |ui_page_| can be START_PROGRESS (which means | 834 // In case |state_| is ACTIVE, |ui_page_| can be START_PROGRESS (which means |
| 856 // normal Arc booting) or ERROR or ERROR_WITH_FEEDBACK (in case Arc can not | 835 // normal Arc booting) or ERROR or ERROR_WITH_FEEDBACK (in case Arc can not |
| 857 // be started). If Arc is booting normally dont't stop it on progress close. | 836 // be started). If Arc is booting normally dont't stop it on progress close. |
| 858 if (state_ != State::FETCHING_CODE && | 837 if ((state_ != State::FETCHING_CODE && state_ != State::TERMS && |
| 838 state_ != State::ANDROID_MANAGEMENT_CHECK) && | |
| 859 ui_page_ != ArcSupportHost::UIPage::ERROR && | 839 ui_page_ != ArcSupportHost::UIPage::ERROR && |
| 860 ui_page_ != ArcSupportHost::UIPage::ERROR_WITH_FEEDBACK) { | 840 ui_page_ != ArcSupportHost::UIPage::ERROR_WITH_FEEDBACK) { |
| 861 return; | 841 return; |
| 862 } | 842 } |
| 863 | 843 |
| 864 // Update UMA with user cancel only if error is not currently shown. | 844 // Update UMA with user cancel only if error is not currently shown. |
| 865 if (ui_page_ == ArcSupportHost::UIPage::ERROR_WITH_FEEDBACK) | 845 if (ui_page_ == ArcSupportHost::UIPage::ERROR_WITH_FEEDBACK) |
| 866 UpdateOptInCancelUMA(OptInCancelReason::USER_CANCEL); | 846 UpdateOptInCancelUMA(OptInCancelReason::USER_CANCEL); |
| 867 | 847 |
| 868 StopArc(); | 848 StopArc(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 919 | 899 |
| 920 if (!arc_bridge_service()->stopped()) { | 900 if (!arc_bridge_service()->stopped()) { |
| 921 // If the user attempts to re-enable ARC while the bridge is still running | 901 // If the user attempts to re-enable ARC while the bridge is still running |
| 922 // the user should not be able to continue until the bridge has stopped. | 902 // the user should not be able to continue until the bridge has stopped. |
| 923 ShowUI( | 903 ShowUI( |
| 924 ArcSupportHost::UIPage::ERROR, | 904 ArcSupportHost::UIPage::ERROR, |
| 925 l10n_util::GetStringUTF16(IDS_ARC_SIGN_IN_SERVICE_UNAVAILABLE_ERROR)); | 905 l10n_util::GetStringUTF16(IDS_ARC_SIGN_IN_SERVICE_UNAVAILABLE_ERROR)); |
| 926 return; | 906 return; |
| 927 } | 907 } |
| 928 | 908 |
| 929 SetState(State::FETCHING_CODE); | 909 SetState(State::TERMS); |
| 930 ShowUI(ArcSupportHost::UIPage::TERMS, base::string16()); | 910 ShowUI(ArcSupportHost::UIPage::TERMS, base::string16()); |
| 931 } | 911 } |
| 932 | 912 |
| 933 void ArcAuthService::OnPrepareContextFailed() { | 913 void ArcAuthService::OnPrepareContextFailed() { |
| 934 DCHECK_EQ(state_, State::FETCHING_CODE); | 914 DCHECK_EQ(state_, State::FETCHING_CODE); |
| 935 | 915 |
| 936 ShutdownBridgeAndShowUI( | 916 ShutdownBridgeAndShowUI( |
| 937 ArcSupportHost::UIPage::ERROR, | 917 ArcSupportHost::UIPage::ERROR, |
| 938 l10n_util::GetStringUTF16(IDS_ARC_SERVER_COMMUNICATION_ERROR)); | 918 l10n_util::GetStringUTF16(IDS_ARC_SERVER_COMMUNICATION_ERROR)); |
| 939 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR); | 919 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR); |
| 940 } | 920 } |
| 941 | 921 |
| 942 void ArcAuthService::OnAuthCodeSuccess(const std::string& auth_code) { | 922 void ArcAuthService::OnAuthCodeSuccess(const std::string& auth_code) { |
| 943 SetAuthCodeAndStartArc(auth_code); | 923 SetAuthCodeAndStartArc(auth_code); |
| 944 } | 924 } |
| 945 | 925 |
| 946 void ArcAuthService::OnAuthCodeFailed() { | 926 void ArcAuthService::OnAuthCodeFailed() { |
| 947 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 927 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 948 DCHECK_EQ(state_, State::FETCHING_CODE); | 928 DCHECK_EQ(state_, State::FETCHING_CODE); |
| 949 ShutdownBridgeAndShowUI( | 929 ShutdownBridgeAndShowUI( |
| 950 ArcSupportHost::UIPage::ERROR, | 930 ArcSupportHost::UIPage::ERROR, |
| 951 l10n_util::GetStringUTF16(IDS_ARC_SERVER_COMMUNICATION_ERROR)); | 931 l10n_util::GetStringUTF16(IDS_ARC_SERVER_COMMUNICATION_ERROR)); |
| 952 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR); | 932 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR); |
| 953 } | 933 } |
| 954 | 934 |
| 935 void ArcAuthService::StartArcAndroidManagementCheck() { | |
| 936 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
| 937 DCHECK(arc_bridge_service()->stopped()); | |
| 938 SetState(State::ANDROID_MANAGEMENT_CHECK); | |
|
Luis Héctor Chávez
2016/11/10 23:30:58
Is it possible to have a DCHECK_EQ(state_, ...) ev
hidehiko
2016/11/14 10:55:09
WDY mean?
SetState(...) is just "state_ = ...". So
Luis Héctor Chávez
2016/11/14 17:06:50
Sorry, I meant before assigning. In other words, m
hidehiko
2016/11/14 19:07:57
I got your point.
However, currently, the state tr
| |
| 939 | |
| 940 android_management_checker_.reset(new ArcAndroidManagementChecker( | |
| 941 profile_, context_->token_service(), context_->account_id(), | |
| 942 false /* retry_on_error */)); | |
| 943 android_management_checker_->StartCheck( | |
| 944 base::Bind(&ArcAuthService::OnAndroidManagementChecked, | |
| 945 weak_ptr_factory_.GetWeakPtr())); | |
| 946 } | |
| 947 | |
| 955 void ArcAuthService::OnAndroidManagementChecked( | 948 void ArcAuthService::OnAndroidManagementChecked( |
| 956 policy::AndroidManagementClient::Result result) { | 949 policy::AndroidManagementClient::Result result) { |
| 957 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 950 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 951 DCHECK_EQ(state_, State::ANDROID_MANAGEMENT_CHECK); | |
| 952 | |
| 958 switch (result) { | 953 switch (result) { |
| 959 case policy::AndroidManagementClient::Result::UNMANAGED: | 954 case policy::AndroidManagementClient::Result::UNMANAGED: |
| 960 OnAndroidManagementPassed(); | 955 if (IsOptInVerificationDisabled()) { |
| 956 StartArc(); | |
| 957 } else { | |
| 958 // TODO(hidehiko): Merge this prefetching into re-auth case. | |
| 959 SetState(State::FETCHING_CODE); | |
| 960 PrepareContextForAuthCodeRequest(); | |
| 961 } | |
| 961 break; | 962 break; |
| 962 case policy::AndroidManagementClient::Result::MANAGED: | 963 case policy::AndroidManagementClient::Result::MANAGED: |
| 963 ShutdownBridgeAndShowUI( | 964 ShutdownBridgeAndShowUI( |
| 964 ArcSupportHost::UIPage::ERROR, | 965 ArcSupportHost::UIPage::ERROR, |
| 965 l10n_util::GetStringUTF16(IDS_ARC_ANDROID_MANAGEMENT_REQUIRED_ERROR)); | 966 l10n_util::GetStringUTF16(IDS_ARC_ANDROID_MANAGEMENT_REQUIRED_ERROR)); |
| 966 UpdateOptInCancelUMA(OptInCancelReason::ANDROID_MANAGEMENT_REQUIRED); | 967 UpdateOptInCancelUMA(OptInCancelReason::ANDROID_MANAGEMENT_REQUIRED); |
| 967 break; | 968 break; |
| 968 case policy::AndroidManagementClient::Result::ERROR: | 969 case policy::AndroidManagementClient::Result::ERROR: |
| 969 ShutdownBridgeAndShowUI( | 970 ShutdownBridgeAndShowUI( |
| 970 ArcSupportHost::UIPage::ERROR, | 971 ArcSupportHost::UIPage::ERROR, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1003 } | 1004 } |
| 1004 | 1005 |
| 1005 if (!auth_endpoint.empty()) { | 1006 if (!auth_endpoint.empty()) { |
| 1006 auth_code_fetcher_.reset(new ArcAuthCodeFetcher( | 1007 auth_code_fetcher_.reset(new ArcAuthCodeFetcher( |
| 1007 this, context_->GetURLRequestContext(), profile_, auth_endpoint)); | 1008 this, context_->GetURLRequestContext(), profile_, auth_endpoint)); |
| 1008 } else { | 1009 } else { |
| 1009 ShowUI(ArcSupportHost::UIPage::LSO_PROGRESS, base::string16()); | 1010 ShowUI(ArcSupportHost::UIPage::LSO_PROGRESS, base::string16()); |
| 1010 } | 1011 } |
| 1011 } | 1012 } |
| 1012 | 1013 |
| 1013 void ArcAuthService::OnAndroidManagementPassed() { | |
| 1014 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
| 1015 | |
| 1016 if (state_ == State::ACTIVE) { | |
|
hidehiko
2016/11/10 01:46:23
Because AndroidManagement check is no longer runni
| |
| 1017 if (IsAuthCodeRequest()) | |
| 1018 FetchAuthCode(); | |
| 1019 return; | |
| 1020 } | |
| 1021 | |
| 1022 if (profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn) || | |
|
hidehiko
2016/11/10 01:46:23
This is migrated into OnAndroidManagementChecked()
| |
| 1023 IsOptInVerificationDisabled()) { | |
| 1024 StartArc(); | |
| 1025 } else { | |
| 1026 FetchAuthCode(); | |
| 1027 } | |
| 1028 } | |
| 1029 | |
| 1030 void ArcAuthService::OnWindowClosed() { | 1014 void ArcAuthService::OnWindowClosed() { |
| 1031 CancelAuthCode(); | 1015 CancelAuthCode(); |
| 1032 } | 1016 } |
| 1033 | 1017 |
| 1034 void ArcAuthService::OnTermsAgreed(bool is_metrics_enabled, | 1018 void ArcAuthService::OnTermsAgreed(bool is_metrics_enabled, |
| 1035 bool is_backup_and_restore_enabled, | 1019 bool is_backup_and_restore_enabled, |
| 1036 bool is_location_service_enabled) { | 1020 bool is_location_service_enabled) { |
| 1021 // Terms were accepted | |
| 1022 profile_->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, true); | |
| 1023 | |
| 1037 // This is ARC support's UI event callback, so this is called only when | 1024 // This is ARC support's UI event callback, so this is called only when |
| 1038 // the UI is visible. The condition to open the UI is | 1025 // the UI is visible. The condition to open the UI is |
| 1039 // !g_disable_ui_for_testing && !IsOptInVerificationDisabled() (see ShowUI()) | 1026 // !g_disable_ui_for_testing && !IsOptInVerificationDisabled() (see ShowUI()) |
| 1040 // and in the case, preference_handler_ should be always created (see | 1027 // and in the case, preference_handler_ should be always created (see |
| 1041 // OnPrimaryUserProfilePrepared()), | 1028 // OnPrimaryUserProfilePrepared()), |
| 1042 // TODO(hidehiko): Simplify the logic with the code restructuring. | 1029 // TODO(hidehiko): Simplify the logic with the code restructuring. |
| 1043 DCHECK(preference_handler_); | 1030 DCHECK(preference_handler_); |
| 1044 preference_handler_->EnableMetrics(is_metrics_enabled); | 1031 preference_handler_->EnableMetrics(is_metrics_enabled); |
| 1045 preference_handler_->EnableBackupRestore(is_backup_and_restore_enabled); | 1032 preference_handler_->EnableBackupRestore(is_backup_and_restore_enabled); |
| 1046 preference_handler_->EnableLocationService(is_location_service_enabled); | 1033 preference_handler_->EnableLocationService(is_location_service_enabled); |
| 1047 StartLso(); | 1034 StartArcAndroidManagementCheck(); |
| 1048 } | 1035 } |
| 1049 | 1036 |
| 1050 void ArcAuthService::OnAuthSucceeded(const std::string& auth_code) { | 1037 void ArcAuthService::OnAuthSucceeded(const std::string& auth_code) { |
| 1051 SetAuthCodeAndStartArc(auth_code); | 1038 SetAuthCodeAndStartArc(auth_code); |
| 1052 } | 1039 } |
| 1053 | 1040 |
| 1041 void ArcAuthService::OnRetryClicked() { | |
| 1042 UpdateOptInActionUMA(OptInActionType::RETRY); | |
| 1043 // ERROR_WITH_FEEDBACK is set in OnSignInFailed(). In the case, we postpone | |
| 1044 // to stop the ARC to obtain the internal state. | |
| 1045 // Here, on retry, stop it. | |
| 1046 if (ui_page_ == ArcSupportHost::UIPage::ERROR_WITH_FEEDBACK) | |
| 1047 ShutdownBridge(); | |
| 1048 | |
| 1049 switch (state_) { | |
| 1050 case State::NOT_INITIALIZED: | |
| 1051 NOTREACHED(); | |
| 1052 break; | |
| 1053 case State::STOPPED: | |
| 1054 case State::TERMS: | |
| 1055 ShowUI(ArcSupportHost::UIPage::TERMS, base::string16()); | |
| 1056 break; | |
| 1057 case State::ANDROID_MANAGEMENT_CHECK: | |
| 1058 StartArcAndroidManagementCheck(); | |
| 1059 break; | |
| 1060 case State::FETCHING_CODE: | |
| 1061 case State::ACTIVE: | |
| 1062 PrepareContextForAuthCodeRequest(); | |
| 1063 break; | |
| 1064 } | |
| 1065 } | |
| 1066 | |
| 1054 void ArcAuthService::OnSendFeedbackClicked() { | 1067 void ArcAuthService::OnSendFeedbackClicked() { |
| 1055 chrome::OpenFeedbackDialog(nullptr); | 1068 chrome::OpenFeedbackDialog(nullptr); |
| 1056 } | 1069 } |
| 1057 | 1070 |
| 1058 void ArcAuthService::OnMetricsModeChanged(bool enabled, bool managed) { | 1071 void ArcAuthService::OnMetricsModeChanged(bool enabled, bool managed) { |
| 1059 if (!support_host_) | 1072 if (!support_host_) |
| 1060 return; | 1073 return; |
| 1061 support_host_->SetMetricsPreferenceCheckbox(enabled, managed); | 1074 support_host_->SetMetricsPreferenceCheckbox(enabled, managed); |
| 1062 } | 1075 } |
| 1063 | 1076 |
| 1064 void ArcAuthService::OnBackupAndRestoreModeChanged(bool enabled, bool managed) { | 1077 void ArcAuthService::OnBackupAndRestoreModeChanged(bool enabled, bool managed) { |
| 1065 if (!support_host_) | 1078 if (!support_host_) |
| 1066 return; | 1079 return; |
| 1067 support_host_->SetBackupAndRestorePreferenceCheckbox(enabled, managed); | 1080 support_host_->SetBackupAndRestorePreferenceCheckbox(enabled, managed); |
| 1068 } | 1081 } |
| 1069 | 1082 |
| 1070 void ArcAuthService::OnLocationServicesModeChanged(bool enabled, bool managed) { | 1083 void ArcAuthService::OnLocationServicesModeChanged(bool enabled, bool managed) { |
| 1071 if (!support_host_) | 1084 if (!support_host_) |
| 1072 return; | 1085 return; |
| 1073 support_host_->SetLocationServicesPreferenceCheckbox(enabled, managed); | 1086 support_host_->SetLocationServicesPreferenceCheckbox(enabled, managed); |
| 1074 } | 1087 } |
| 1075 | 1088 |
| 1076 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state) { | 1089 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state) { |
| 1077 switch (state) { | 1090 switch (state) { |
| 1078 case ArcAuthService::State::NOT_INITIALIZED: | 1091 case ArcAuthService::State::NOT_INITIALIZED: |
| 1079 return os << "NOT_INITIALIZED"; | 1092 return os << "NOT_INITIALIZED"; |
| 1080 case ArcAuthService::State::STOPPED: | 1093 case ArcAuthService::State::STOPPED: |
| 1081 return os << "STOPPED"; | 1094 return os << "STOPPED"; |
| 1095 case ArcAuthService::State::TERMS: | |
| 1096 return os << "TERMS"; | |
| 1097 case ArcAuthService::State::ANDROID_MANAGEMENT_CHECK: | |
| 1098 return os << "ANDROID_MANAGEMENT_CHECK"; | |
| 1082 case ArcAuthService::State::FETCHING_CODE: | 1099 case ArcAuthService::State::FETCHING_CODE: |
| 1083 return os << "FETCHING_CODE"; | 1100 return os << "FETCHING_CODE"; |
| 1084 case ArcAuthService::State::ACTIVE: | 1101 case ArcAuthService::State::ACTIVE: |
| 1085 return os << "ACTIVE"; | 1102 return os << "ACTIVE"; |
| 1086 default: | 1103 default: |
|
Luis Héctor Chávez
2016/11/10 23:30:58
nit: remove the default: case and move the NOTREAC
hidehiko
2016/11/14 10:55:09
Addressed in a separate CL.
https://codereview.chr
| |
| 1087 NOTREACHED(); | 1104 NOTREACHED(); |
| 1088 return os; | 1105 return os; |
| 1089 } | 1106 } |
| 1090 } | 1107 } |
| 1091 | 1108 |
| 1092 } // namespace arc | 1109 } // namespace arc |
| OLD | NEW |