Chromium Code Reviews| Index: chrome/browser/chromeos/arc/arc_session_manager.cc |
| diff --git a/chrome/browser/chromeos/arc/arc_session_manager.cc b/chrome/browser/chromeos/arc/arc_session_manager.cc |
| index 6ae5cb9b46f27a2d3d58ec52a74577213bcac569..904dcbacd6e031a52cff3ecad4d56f5f8fcbba82 100644 |
| --- a/chrome/browser/chromeos/arc/arc_session_manager.cc |
| +++ b/chrome/browser/chromeos/arc/arc_session_manager.cc |
| @@ -418,7 +418,7 @@ void ArcSessionManager::OnPrimaryUserProfilePrepared(Profile* profile) { |
| !IsArcKioskMode()) { |
| DCHECK(!support_host_); |
| support_host_ = base::MakeUnique<ArcSupportHost>(profile_); |
| - support_host_->SetArcManaged(IsArcManaged()); |
| + support_host_->SetArcManaged(IsArcPlayStoreEnabledForProfile(profile_)); |
|
Yusuke Sato
2017/02/17 22:27:08
This contradicts with the description of the CL yo
hidehiko
2017/02/20 18:18:44
Good catch! Fixed.
|
| support_host_->AddObserver(this); |
| } |
| @@ -445,7 +445,7 @@ void ArcSessionManager::OnPrimaryUserProfilePrepared(Profile* profile) { |
| RemoveArcData(); |
| } |
| - if (IsArcPlayStoreEnabled()) { |
| + if (IsArcPlayStoreEnabledForProfile(profile_)) { |
| VLOG(1) << "ARC is already enabled."; |
| DCHECK(!enable_requested_); |
| RequestEnable(); |
| @@ -509,13 +509,15 @@ void ArcSessionManager::OnOptInPreferenceChanged() { |
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| DCHECK(profile_); |
| - const bool arc_enabled = IsArcPlayStoreEnabled(); |
| - if (!IsArcManaged()) { |
| + const bool is_play_store_enabled = IsArcPlayStoreEnabledForProfile(profile_); |
| + const bool is_play_store_managed = |
| + IsArcPlayStoreEnabledPreferenceManagedForProfile(profile_); |
| + if (!is_play_store_managed) { |
| // Update UMA only for non-Managed cases. |
| - UpdateOptInActionUMA(arc_enabled ? OptInActionType::OPTED_IN |
| - : OptInActionType::OPTED_OUT); |
| + UpdateOptInActionUMA(is_play_store_enabled ? OptInActionType::OPTED_IN |
| + : OptInActionType::OPTED_OUT); |
| - if (!arc_enabled) { |
| + if (!is_play_store_enabled) { |
| // Remove the pinned Play Store icon launcher in Shelf. |
| // This is only for non-Managed cases. In managed cases, it is expected |
| // to be "disabled" rather than "removed", so keep it here. |
| @@ -526,7 +528,7 @@ void ArcSessionManager::OnOptInPreferenceChanged() { |
| } |
| if (support_host_) |
| - support_host_->SetArcManaged(IsArcManaged()); |
| + support_host_->SetArcManaged(is_play_store_managed); |
| // Hide auth notification if it was opened before and arc.enabled pref was |
| // explicitly set to true or false. |
| @@ -535,13 +537,13 @@ void ArcSessionManager::OnOptInPreferenceChanged() { |
| ArcAuthNotification::Hide(); |
| } |
| - if (arc_enabled) |
| + if (is_play_store_enabled) |
| RequestEnable(); |
| else |
| RequestDisable(); |
| for (auto& observer : observer_list_) |
| - observer.OnArcPlayStoreEnabledChanged(arc_enabled); |
| + observer.OnArcPlayStoreEnabledChanged(is_play_store_enabled); |
| } |
| void ArcSessionManager::ShutdownSession() { |
| @@ -643,34 +645,7 @@ void ArcSessionManager::CancelAuthCode() { |
| } |
| StopArc(); |
| - SetArcPlayStoreEnabled(false); |
| -} |
| - |
| -bool ArcSessionManager::IsArcManaged() const { |
| - DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| - DCHECK(profile_); |
| - return profile_->GetPrefs()->IsManagedPreference(prefs::kArcEnabled); |
| -} |
| - |
| -bool ArcSessionManager::IsArcPlayStoreEnabled() const { |
| - DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| - if (!IsAllowed()) |
| - return false; |
| - |
| - DCHECK(profile_); |
| - return profile_->GetPrefs()->GetBoolean(prefs::kArcEnabled); |
| -} |
| - |
| -void ArcSessionManager::SetArcPlayStoreEnabled(bool enabled) { |
| - DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| - DCHECK(profile_); |
| - |
| - if (IsArcManaged()) { |
| - VLOG(1) << "Whether Google Play Store is enabled is managed. Do nothing."; |
| - return; |
| - } |
| - |
| - profile_->GetPrefs()->SetBoolean(prefs::kArcEnabled, enabled); |
| + SetArcPlayStoreEnabledForProfile(profile_, false); |
| } |
| void ArcSessionManager::RecordArcState() { |
| @@ -733,7 +708,7 @@ void ArcSessionManager::RequestEnableImpl() { |
| // Check Android management in parallel. |
| // Note: Because the callback may be called in synchronous way (i.e. called |
| // on the same stack), StartCheck() needs to be called *after* StartArc(). |
| - // Otherwise, SetArcPlayStoreEnabled() which may be called in |
| + // Otherwise, SetArcPlayStoreEnabledForProfile() which may be called in |
| // OnBackgroundAndroidManagementChecked() could be ignored. |
| android_management_checker_ = base::MakeUnique<ArcAndroidManagementChecker>( |
| profile_, context_->token_service(), context_->account_id(), |
| @@ -893,7 +868,7 @@ void ArcSessionManager::OnBackgroundAndroidManagementChecked( |
| // Do nothing. ARC should be started already. |
| break; |
| case policy::AndroidManagementClient::Result::MANAGED: |
| - SetArcPlayStoreEnabled(false); |
| + SetArcPlayStoreEnabledForProfile(profile_, false); |
| break; |
| case policy::AndroidManagementClient::Result::ERROR: |
| // This code should not be reached. For background check, |