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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/arc/arc_util.cc
diff --git a/chrome/browser/chromeos/arc/arc_util.cc b/chrome/browser/chromeos/arc/arc_util.cc
index de722a70e63ff37ee2cf24ba237e3a0f4fc0cf71..49b6f04bdf062d1d444ff68f48c80ec53804ce3b 100644
--- a/chrome/browser/chromeos/arc/arc_util.cc
+++ b/chrome/browser/chromeos/arc/arc_util.cc
@@ -9,7 +9,9 @@
#include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/pref_names.h"
#include "components/arc/arc_util.h"
+#include "components/prefs/pref_service.h"
#include "components/user_manager/user.h"
#include "components/user_manager/user_manager.h"
@@ -96,4 +98,27 @@ void DisallowArcForTesting() {
g_disallow_for_testing = true;
}
+bool IsArcPlayStoreEnabledForProfile(const Profile* profile) {
+ return IsArcAllowedForProfile(profile) &&
+ profile->GetPrefs()->GetBoolean(prefs::kArcEnabled);
+}
+
+bool IsArcPlayStoreEnabledPreferenceManagedForProfile(const Profile* profile) {
+ if (!IsArcAllowedForProfile(profile)) {
+ LOG(DFATAL) << "ARC is not allowed for profile";
+ return false;
+ }
+ return profile->GetPrefs()->IsManagedPreference(prefs::kArcEnabled);
+}
+
+void SetArcPlayStoreEnabledForProfile(Profile* profile, bool enabled) {
+ DCHECK(IsArcAllowedForProfile(profile));
+ if (IsArcPlayStoreEnabledPreferenceManagedForProfile(profile)) {
+ VLOG(1) << "Do nothing, since the Google-Play-Store-enabled pref is "
+ << "managed.";
+ return;
+ }
+ profile->GetPrefs()->SetBoolean(prefs::kArcEnabled, enabled);
+}
+
} // namespace arc
« 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