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_util.h" | 5 #include "chrome/browser/chromeos/arc/arc_util.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/chromeos/arc/arc_session_manager.h" | 8 #include "chrome/browser/chromeos/arc/arc_session_manager.h" |
9 #include "chrome/browser/chromeos/login/user_flow.h" | 9 #include "chrome/browser/chromeos/login/user_flow.h" |
10 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" | 10 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
108 if (!IsArcAllowedForProfile(profile)) { | 108 if (!IsArcAllowedForProfile(profile)) { |
109 LOG(DFATAL) << "ARC is not allowed for profile"; | 109 LOG(DFATAL) << "ARC is not allowed for profile"; |
110 return false; | 110 return false; |
111 } | 111 } |
112 return profile->GetPrefs()->IsManagedPreference(prefs::kArcEnabled); | 112 return profile->GetPrefs()->IsManagedPreference(prefs::kArcEnabled); |
113 } | 113 } |
114 | 114 |
115 void SetArcPlayStoreEnabledForProfile(Profile* profile, bool enabled) { | 115 void SetArcPlayStoreEnabledForProfile(Profile* profile, bool enabled) { |
116 DCHECK(IsArcAllowedForProfile(profile)); | 116 DCHECK(IsArcAllowedForProfile(profile)); |
117 if (IsArcPlayStoreEnabledPreferenceManagedForProfile(profile)) { | 117 if (IsArcPlayStoreEnabledPreferenceManagedForProfile(profile)) { |
118 if (enabled && !IsArcPlayStoreEnabledForProfile(profile)) { | |
Luis Héctor Chávez
2017/04/07 16:09:05
IIUC (but I'm not entirely sure) this was added fo
khmel
2017/04/07 19:23:19
I remember I added this to enable restart ARC for
| |
119 LOG(WARNING) << "Attempt to enable disabled by policy ARC."; | |
120 return; | |
121 } | |
118 VLOG(1) << "Google-Play-Store-enabled pref is managed. Request to " | 122 VLOG(1) << "Google-Play-Store-enabled pref is managed. Request to " |
119 << (enabled ? "enable" : "disable") << " Play Store is not stored"; | 123 << (enabled ? "enable" : "disable") << " Play Store is not stored"; |
120 // Need update ARC session manager manually for managed case in order to | 124 // Need update ARC session manager manually for managed case in order to |
121 // keep its state up to date, otherwise it may stuck with enabling | 125 // keep its state up to date, otherwise it may stuck with enabling |
122 // request. | 126 // request. |
123 // TODO (khmel): Consider finding the better way handling this. | 127 // TODO (khmel): Consider finding the better way handling this. |
124 ArcSessionManager* arc_session_manager = ArcSessionManager::Get(); | 128 ArcSessionManager* arc_session_manager = ArcSessionManager::Get(); |
125 // |arc_session_manager| can be nullptr in unit_tests. | 129 // |arc_session_manager| can be nullptr in unit_tests. |
126 if (!arc_session_manager) | 130 if (!arc_session_manager) |
127 return; | 131 return; |
128 if (enabled) | 132 if (enabled) |
129 arc_session_manager->RequestEnable(); | 133 arc_session_manager->RequestEnable(); |
130 else | 134 else |
131 arc_session_manager->RequestDisable(); | 135 arc_session_manager->RequestDisable(); |
132 return; | 136 return; |
133 } | 137 } |
134 profile->GetPrefs()->SetBoolean(prefs::kArcEnabled, enabled); | 138 profile->GetPrefs()->SetBoolean(prefs::kArcEnabled, enabled); |
135 } | 139 } |
136 | 140 |
137 bool AreArcAllOptInPreferencesManagedForProfile(const Profile* profile) { | 141 bool AreArcAllOptInPreferencesManagedForProfile(const Profile* profile) { |
138 return profile->GetPrefs()->IsManagedPreference( | 142 return profile->GetPrefs()->IsManagedPreference( |
139 prefs::kArcBackupRestoreEnabled) && | 143 prefs::kArcBackupRestoreEnabled) && |
140 profile->GetPrefs()->IsManagedPreference( | 144 profile->GetPrefs()->IsManagedPreference( |
141 prefs::kArcLocationServiceEnabled); | 145 prefs::kArcLocationServiceEnabled); |
142 } | 146 } |
143 | 147 |
144 } // namespace arc | 148 } // namespace arc |
OLD | NEW |