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

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

Issue 2739323004: arc: Reactivate OptIn flow on clicking Play Store. (Closed)
Patch Set: Created 3 years, 9 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/arc/arc_session_manager.h"
8 #include "chrome/browser/chromeos/login/user_flow.h" 9 #include "chrome/browser/chromeos/login/user_flow.h"
9 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" 10 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
10 #include "chrome/browser/chromeos/profiles/profile_helper.h" 11 #include "chrome/browser/chromeos/profiles/profile_helper.h"
11 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/common/pref_names.h" 13 #include "chrome/common/pref_names.h"
13 #include "components/arc/arc_util.h" 14 #include "components/arc/arc_util.h"
14 #include "components/prefs/pref_service.h" 15 #include "components/prefs/pref_service.h"
15 #include "components/user_manager/user.h" 16 #include "components/user_manager/user.h"
16 #include "components/user_manager/user_manager.h" 17 #include "components/user_manager/user_manager.h"
17 18
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 if (!IsArcAllowedForProfile(profile)) { 108 if (!IsArcAllowedForProfile(profile)) {
108 LOG(DFATAL) << "ARC is not allowed for profile"; 109 LOG(DFATAL) << "ARC is not allowed for profile";
109 return false; 110 return false;
110 } 111 }
111 return profile->GetPrefs()->IsManagedPreference(prefs::kArcEnabled); 112 return profile->GetPrefs()->IsManagedPreference(prefs::kArcEnabled);
112 } 113 }
113 114
114 void SetArcPlayStoreEnabledForProfile(Profile* profile, bool enabled) { 115 void SetArcPlayStoreEnabledForProfile(Profile* profile, bool enabled) {
115 DCHECK(IsArcAllowedForProfile(profile)); 116 DCHECK(IsArcAllowedForProfile(profile));
116 if (IsArcPlayStoreEnabledPreferenceManagedForProfile(profile)) { 117 if (IsArcPlayStoreEnabledPreferenceManagedForProfile(profile)) {
117 VLOG(1) << "Do nothing, since the Google-Play-Store-enabled pref is " 118 VLOG(1) << "Google-Play-Store-enabled pref is managed. Request to "
118 << "managed."; 119 << (enabled ? "enable" : "disable") << " Play Store is not stored";
120 // 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
122 // request.
123 if (enabled)
124 ArcSessionManager::Get()->RequestEnable();
125 else
126 ArcSessionManager::Get()->RequestDisable();
119 return; 127 return;
120 } 128 }
121 profile->GetPrefs()->SetBoolean(prefs::kArcEnabled, enabled); 129 profile->GetPrefs()->SetBoolean(prefs::kArcEnabled, enabled);
122 } 130 }
123 131
124 bool AreArcAllOptInPreferencesManagedForProfile(const Profile* profile) { 132 bool AreArcAllOptInPreferencesManagedForProfile(const Profile* profile) {
125 return profile->GetPrefs()->IsManagedPreference( 133 return profile->GetPrefs()->IsManagedPreference(
126 prefs::kArcBackupRestoreEnabled) && 134 prefs::kArcBackupRestoreEnabled) &&
127 profile->GetPrefs()->IsManagedPreference( 135 profile->GetPrefs()->IsManagedPreference(
128 prefs::kArcLocationServiceEnabled); 136 prefs::kArcLocationServiceEnabled);
129 } 137 }
130 138
131 } // namespace arc 139 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698