| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 111 |
| 112 // static | 112 // static |
| 113 void ArcSessionManager::RegisterProfilePrefs( | 113 void ArcSessionManager::RegisterProfilePrefs( |
| 114 user_prefs::PrefRegistrySyncable* registry) { | 114 user_prefs::PrefRegistrySyncable* registry) { |
| 115 // TODO(dspaid): Implement a mechanism to allow this to sync on first boot | 115 // TODO(dspaid): Implement a mechanism to allow this to sync on first boot |
| 116 // only. | 116 // only. |
| 117 registry->RegisterBooleanPref(prefs::kArcDataRemoveRequested, false); | 117 registry->RegisterBooleanPref(prefs::kArcDataRemoveRequested, false); |
| 118 registry->RegisterBooleanPref(prefs::kArcEnabled, false); | 118 registry->RegisterBooleanPref(prefs::kArcEnabled, false); |
| 119 registry->RegisterBooleanPref(prefs::kArcSignedIn, false); | 119 registry->RegisterBooleanPref(prefs::kArcSignedIn, false); |
| 120 registry->RegisterBooleanPref(prefs::kArcTermsAccepted, false); | 120 registry->RegisterBooleanPref(prefs::kArcTermsAccepted, false); |
| 121 registry->RegisterBooleanPref(prefs::kArcBackupRestoreEnabled, true); | 121 // Note that ArcBackupRestoreEnabled and ArcLocationServiceEnabled prefs have |
| 122 registry->RegisterBooleanPref(prefs::kArcLocationServiceEnabled, true); | 122 // to be off by default, until an explicit gesture from the user to enable |
| 123 // them is received. This is crucial in the cases when these prefs transition |
| 124 // from a previous managed state to the unmanaged. |
| 125 registry->RegisterBooleanPref(prefs::kArcBackupRestoreEnabled, false); |
| 126 registry->RegisterBooleanPref(prefs::kArcLocationServiceEnabled, false); |
| 123 } | 127 } |
| 124 | 128 |
| 125 // static | 129 // static |
| 126 bool ArcSessionManager::IsOobeOptInActive() { | 130 bool ArcSessionManager::IsOobeOptInActive() { |
| 127 // ARC OOBE OptIn is optional for now. Test if it exists and login host is | 131 // ARC OOBE OptIn is optional for now. Test if it exists and login host is |
| 128 // active. | 132 // active. |
| 129 if (!user_manager::UserManager::Get()->IsCurrentUserNew()) | 133 if (!user_manager::UserManager::Get()->IsCurrentUserNew()) |
| 130 return false; | 134 return false; |
| 131 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 135 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 132 chromeos::switches::kEnableArcOOBEOptIn)) | 136 chromeos::switches::kEnableArcOOBEOptIn)) |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 DCHECK(profile_); | 703 DCHECK(profile_); |
| 700 DCHECK_NE(state_, State::ACTIVE); | 704 DCHECK_NE(state_, State::ACTIVE); |
| 701 | 705 |
| 702 if (state_ == State::REMOVING_DATA_DIR) { | 706 if (state_ == State::REMOVING_DATA_DIR) { |
| 703 // Data removal request is in progress. Set flag to re-enable ARC once it | 707 // Data removal request is in progress. Set flag to re-enable ARC once it |
| 704 // is finished. | 708 // is finished. |
| 705 reenable_arc_ = true; | 709 reenable_arc_ = true; |
| 706 return; | 710 return; |
| 707 } | 711 } |
| 708 | 712 |
| 713 PrefService* const prefs = profile_->GetPrefs(); |
| 714 |
| 709 // For ARC Kiosk we skip ToS because it is very likely that near the device | 715 // For ARC Kiosk we skip ToS because it is very likely that near the device |
| 710 // there will be no one who is eligible to accept them. | 716 // there will be no one who is eligible to accept them. |
| 711 // TODO(poromov): Move to more Kiosk dedicated set-up phase. | 717 // TODO(poromov): Move to more Kiosk dedicated set-up phase. |
| 712 if (IsArcKioskMode()) | 718 if (IsArcKioskMode()) |
| 713 profile_->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, true); | 719 prefs->SetBoolean(prefs::kArcTermsAccepted, true); |
| 720 |
| 721 // Skip to show UI asking users to enable/disable their preference for |
| 722 // backup-restore and location-service, if both are managed by the admin |
| 723 // policy. Note that the ToS agreement is anyway not shown in the case of the |
| 724 // managed ARC. |
| 725 if (IsArcManaged() && |
| 726 prefs->IsManagedPreference(prefs::kArcBackupRestoreEnabled) && |
| 727 prefs->IsManagedPreference(prefs::kArcLocationServiceEnabled)) { |
| 728 prefs->SetBoolean(prefs::kArcTermsAccepted, true); |
| 729 } |
| 714 | 730 |
| 715 // If it is marked that sign in has been successfully done, then directly | 731 // If it is marked that sign in has been successfully done, then directly |
| 716 // start ARC. | 732 // start ARC. |
| 717 // For testing, and for Kisok mode, we also skip ToS negotiation procedure. | 733 // For testing, and for Kiosk mode, we also skip ToS negotiation procedure. |
| 718 // For backward compatibility, this check needs to be prior to the | 734 // For backward compatibility, this check needs to be prior to the |
| 719 // kArcTermsAccepted check below. | 735 // kArcTermsAccepted check below. |
| 720 if (profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn) || | 736 if (prefs->GetBoolean(prefs::kArcSignedIn) || |
| 721 IsArcOptInVerificationDisabled() || IsArcKioskMode()) { | 737 IsArcOptInVerificationDisabled() || IsArcKioskMode()) { |
| 722 StartArc(); | 738 StartArc(); |
| 723 | 739 |
| 724 // Skip Android management check for testing. | 740 // Skip Android management check for testing. |
| 725 // We also skip if Android management check for Kiosk mode, | 741 // We also skip if Android management check for Kiosk mode, |
| 726 // because there are no managed human users for Kiosk exist. | 742 // because there are no managed human users for Kiosk exist. |
| 727 if (IsArcOptInVerificationDisabled() || IsArcKioskMode() || | 743 if (IsArcOptInVerificationDisabled() || IsArcKioskMode() || |
| 728 (g_disable_ui_for_testing && | 744 (g_disable_ui_for_testing && |
| 729 !g_enable_check_android_management_for_testing)) { | 745 !g_enable_check_android_management_for_testing)) { |
| 730 return; | 746 return; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 744 return; | 760 return; |
| 745 } | 761 } |
| 746 | 762 |
| 747 // If it is marked that the Terms of service is accepted already, | 763 // If it is marked that the Terms of service is accepted already, |
| 748 // just skip the negotiation with user, and start Android management | 764 // just skip the negotiation with user, and start Android management |
| 749 // check directly. | 765 // check directly. |
| 750 // This happens, e.g., when; | 766 // This happens, e.g., when; |
| 751 // 1) User accepted the Terms of service on OOBE flow. | 767 // 1) User accepted the Terms of service on OOBE flow. |
| 752 // 2) User accepted the Terms of service on Opt-in flow, but logged out | 768 // 2) User accepted the Terms of service on Opt-in flow, but logged out |
| 753 // before ARC sign in procedure was done. Then, logs in again. | 769 // before ARC sign in procedure was done. Then, logs in again. |
| 754 if (profile_->GetPrefs()->GetBoolean(prefs::kArcTermsAccepted)) { | 770 if (prefs->GetBoolean(prefs::kArcTermsAccepted)) { |
| 755 // Don't show UI for this progress if it was not shown. | 771 // Don't show UI for this progress if it was not shown. |
| 756 if (support_host_->ui_page() != ArcSupportHost::UIPage::NO_PAGE) | 772 if (support_host_ && |
| 773 support_host_->ui_page() != ArcSupportHost::UIPage::NO_PAGE) { |
| 757 support_host_->ShowArcLoading(); | 774 support_host_->ShowArcLoading(); |
| 775 } |
| 758 StartArcAndroidManagementCheck(); | 776 StartArcAndroidManagementCheck(); |
| 759 return; | 777 return; |
| 760 } | 778 } |
| 761 | 779 |
| 762 StartTermsOfServiceNegotiation(); | 780 StartTermsOfServiceNegotiation(); |
| 763 } | 781 } |
| 764 | 782 |
| 765 void ArcSessionManager::RequestDisable() { | 783 void ArcSessionManager::RequestDisable() { |
| 766 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 784 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 767 DCHECK(profile_); | 785 DCHECK(profile_); |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 990 | 1008 |
| 991 #undef MAP_STATE | 1009 #undef MAP_STATE |
| 992 | 1010 |
| 993 // Some compilers report an error even if all values of an enum-class are | 1011 // Some compilers report an error even if all values of an enum-class are |
| 994 // covered exhaustively in a switch statement. | 1012 // covered exhaustively in a switch statement. |
| 995 NOTREACHED() << "Invalid value " << static_cast<int>(state); | 1013 NOTREACHED() << "Invalid value " << static_cast<int>(state); |
| 996 return os; | 1014 return os; |
| 997 } | 1015 } |
| 998 | 1016 |
| 999 } // namespace arc | 1017 } // namespace arc |
| OLD | NEW |