| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_play_store_enabled_preference_handler.
h" | 5 #include "chrome/browser/chromeos/arc/arc_play_store_enabled_preference_handler.
h" |
| 6 | 6 |
| 7 #include "ash/common/shelf/shelf_delegate.h" | 7 #include "ash/common/shelf/shelf_delegate.h" |
| 8 #include "ash/common/wm_shell.h" | 8 #include "ash/common/wm_shell.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "chrome/browser/chromeos/arc/arc_auth_notification.h" | 12 #include "chrome/browser/chromeos/arc/arc_auth_notification.h" |
| 13 #include "chrome/browser/chromeos/arc/arc_optin_uma.h" | 13 #include "chrome/browser/chromeos/arc/arc_optin_uma.h" |
| 14 #include "chrome/browser/chromeos/arc/arc_session_manager.h" | 14 #include "chrome/browser/chromeos/arc/arc_session_manager.h" |
| 15 #include "chrome/browser/chromeos/arc/arc_support_host.h" | 15 #include "chrome/browser/chromeos/arc/arc_support_host.h" |
| 16 #include "chrome/browser/chromeos/arc/arc_util.h" | 16 #include "chrome/browser/chromeos/arc/arc_util.h" |
| 17 #include "chrome/browser/prefs/pref_service_syncable_util.h" | 17 #include "chrome/browser/prefs/pref_service_syncable_util.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
| 20 #include "chromeos/chromeos_switches.h" | 20 #include "chromeos/chromeos_switches.h" |
| 21 #include "components/arc/arc_util.h" |
| 21 #include "components/sync_preferences/pref_service_syncable.h" | 22 #include "components/sync_preferences/pref_service_syncable.h" |
| 22 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| 23 | 24 |
| 24 namespace arc { | 25 namespace arc { |
| 25 | 26 |
| 26 ArcPlayStoreEnabledPreferenceHandler::ArcPlayStoreEnabledPreferenceHandler( | 27 ArcPlayStoreEnabledPreferenceHandler::ArcPlayStoreEnabledPreferenceHandler( |
| 27 Profile* profile, | 28 Profile* profile, |
| 28 ArcSessionManager* arc_session_manager) | 29 ArcSessionManager* arc_session_manager) |
| 29 : profile_(profile), | 30 : profile_(profile), |
| 30 arc_session_manager_(arc_session_manager), | 31 arc_session_manager_(arc_session_manager), |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 arc_session_manager_->NotifyArcPlayStoreEnabledChanged(is_play_store_enabled); | 114 arc_session_manager_->NotifyArcPlayStoreEnabledChanged(is_play_store_enabled); |
| 114 } | 115 } |
| 115 | 116 |
| 116 void ArcPlayStoreEnabledPreferenceHandler::UpdateArcSessionManager() { | 117 void ArcPlayStoreEnabledPreferenceHandler::UpdateArcSessionManager() { |
| 117 auto* support_host = arc_session_manager_->support_host(); | 118 auto* support_host = arc_session_manager_->support_host(); |
| 118 if (support_host) { | 119 if (support_host) { |
| 119 support_host->SetArcManaged( | 120 support_host->SetArcManaged( |
| 120 IsArcPlayStoreEnabledPreferenceManagedForProfile(profile_)); | 121 IsArcPlayStoreEnabledPreferenceManagedForProfile(profile_)); |
| 121 } | 122 } |
| 122 | 123 |
| 123 if (IsArcPlayStoreEnabledForProfile(profile_)) | 124 if (ShouldArcAlwaysStart() || IsArcPlayStoreEnabledForProfile(profile_)) |
| 124 arc_session_manager_->RequestEnable(); | 125 arc_session_manager_->RequestEnable(); |
| 125 else | 126 else |
| 126 arc_session_manager_->RequestDisable(); | 127 arc_session_manager_->RequestDisable(); |
| 127 } | 128 } |
| 128 | 129 |
| 129 void ArcPlayStoreEnabledPreferenceHandler::OnIsSyncingChanged() { | 130 void ArcPlayStoreEnabledPreferenceHandler::OnIsSyncingChanged() { |
| 130 sync_preferences::PrefServiceSyncable* const pref_service_syncable = | 131 sync_preferences::PrefServiceSyncable* const pref_service_syncable = |
| 131 PrefServiceSyncableFromProfile(profile_); | 132 PrefServiceSyncableFromProfile(profile_); |
| 132 if (!pref_service_syncable->IsSyncing()) | 133 if (!pref_service_syncable->IsSyncing()) |
| 133 return; | 134 return; |
| 134 pref_service_syncable->RemoveObserver(this); | 135 pref_service_syncable->RemoveObserver(this); |
| 135 | 136 |
| 136 // TODO(hidehiko): Extract kEnableArcOOBEOptIn check as a utility method. | 137 // TODO(hidehiko): Extract kEnableArcOOBEOptIn check as a utility method. |
| 137 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 138 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 138 chromeos::switches::kEnableArcOOBEOptIn) && | 139 chromeos::switches::kEnableArcOOBEOptIn) && |
| 139 profile_->IsNewProfile() && | 140 profile_->IsNewProfile() && |
| 140 !profile_->GetPrefs()->HasPrefPath(prefs::kArcEnabled)) { | 141 !profile_->GetPrefs()->HasPrefPath(prefs::kArcEnabled)) { |
| 141 ArcAuthNotification::Show(profile_); | 142 ArcAuthNotification::Show(profile_); |
| 142 } | 143 } |
| 143 } | 144 } |
| 144 | 145 |
| 145 } // namespace arc | 146 } // namespace arc |
| OLD | NEW |