Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: chrome/browser/chromeos/arc/arc_util.cc

Issue 2702723002: Extract kArcEnabled preference from ArcSessionManager part 1. (Closed)
Patch Set: Address comments. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/login/user_flow.h" 8 #include "chrome/browser/chromeos/login/user_flow.h"
9 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" 9 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
10 #include "chrome/browser/chromeos/profiles/profile_helper.h" 10 #include "chrome/browser/chromeos/profiles/profile_helper.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/common/pref_names.h"
12 #include "components/arc/arc_util.h" 13 #include "components/arc/arc_util.h"
14 #include "components/prefs/pref_service.h"
13 #include "components/user_manager/user.h" 15 #include "components/user_manager/user.h"
14 #include "components/user_manager/user_manager.h" 16 #include "components/user_manager/user_manager.h"
15 17
16 namespace arc { 18 namespace arc {
17 19
18 namespace { 20 namespace {
19 21
20 // Let IsAllowedForProfile() return "false" for any profile. 22 // Let IsAllowedForProfile() return "false" for any profile.
21 bool g_disallow_for_testing = false; 23 bool g_disallow_for_testing = false;
22 24
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 return false; 91 return false;
90 } 92 }
91 93
92 return true; 94 return true;
93 } 95 }
94 96
95 void DisallowArcForTesting() { 97 void DisallowArcForTesting() {
96 g_disallow_for_testing = true; 98 g_disallow_for_testing = true;
97 } 99 }
98 100
101 bool IsArcPlayStoreEnabledForProfile(const Profile* profile) {
102 return IsArcAllowedForProfile(profile) &&
103 profile->GetPrefs()->GetBoolean(prefs::kArcEnabled);
104 }
105
106 bool IsArcPlayStoreEnabledPreferenceManagedForProfile(const Profile* profile) {
107 if (!IsArcAllowedForProfile(profile)) {
108 LOG(DFATAL) << "ARC is not allowed for profile";
109 return false;
110 }
111 return profile->GetPrefs()->IsManagedPreference(prefs::kArcEnabled);
112 }
113
114 void SetArcPlayStoreEnabledForProfile(Profile* profile, bool enabled) {
115 DCHECK(IsArcAllowedForProfile(profile));
116 if (IsArcPlayStoreEnabledPreferenceManagedForProfile(profile)) {
117 VLOG(1) << "Do nothing, since the Google-Play-Store-enabled pref is "
118 << "managed.";
119 return;
120 }
121 profile->GetPrefs()->SetBoolean(prefs::kArcEnabled, enabled);
122 }
123
99 } // namespace arc 124 } // namespace arc
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/arc/arc_util.h ('k') | chrome/browser/chromeos/arc/arc_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698