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