Chromium Code Reviews| 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/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 Loading... | |
| 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 ArcSessionManager* arc_session_manager = ArcSessionManager::Get(); | |
|
hidehiko
2017/03/13 21:46:47
QQ: If this is only for launcher icon click case,
khmel
2017/03/13 21:58:49
This is not only for launcher item case. My first
hidehiko
2017/03/15 00:45:00
If this is short term fix that's ok, but please ad
khmel
2017/03/15 01:33:28
TODO added, IsArcPlayStoreEnabledForProfile is alw
| |
| 124 // |arc_session_manager| can be nullptr in unit_tests. | |
| 125 if (!arc_session_manager) | |
| 126 return; | |
| 127 if (enabled) | |
| 128 arc_session_manager->RequestEnable(); | |
| 129 else | |
| 130 arc_session_manager->RequestDisable(); | |
| 119 return; | 131 return; |
| 120 } | 132 } |
| 121 profile->GetPrefs()->SetBoolean(prefs::kArcEnabled, enabled); | 133 profile->GetPrefs()->SetBoolean(prefs::kArcEnabled, enabled); |
| 122 } | 134 } |
| 123 | 135 |
| 124 bool AreArcAllOptInPreferencesManagedForProfile(const Profile* profile) { | 136 bool AreArcAllOptInPreferencesManagedForProfile(const Profile* profile) { |
| 125 return profile->GetPrefs()->IsManagedPreference( | 137 return profile->GetPrefs()->IsManagedPreference( |
| 126 prefs::kArcBackupRestoreEnabled) && | 138 prefs::kArcBackupRestoreEnabled) && |
| 127 profile->GetPrefs()->IsManagedPreference( | 139 profile->GetPrefs()->IsManagedPreference( |
| 128 prefs::kArcLocationServiceEnabled); | 140 prefs::kArcLocationServiceEnabled); |
| 129 } | 141 } |
| 130 | 142 |
| 131 } // namespace arc | 143 } // namespace arc |
| OLD | NEW |