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

Side by Side Diff: chrome/browser/policy/profile_policy_connector.cc

Issue 2694933003: Return management state without retrieving the management domain if the (Closed)
Patch Set: Extract redundant logic into GetActualPolicyStore 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
« no previous file with comments | « chrome/browser/policy/profile_policy_connector.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/policy/profile_policy_connector.h" 5 #include "chrome/browser/policy/profile_policy_connector.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 if (special_user_policy_provider_) 147 if (special_user_policy_provider_)
148 special_user_policy_provider_->Shutdown(); 148 special_user_policy_provider_->Shutdown();
149 #endif 149 #endif
150 if (wrapped_platform_policy_provider_) 150 if (wrapped_platform_policy_provider_)
151 wrapped_platform_policy_provider_->Shutdown(); 151 wrapped_platform_policy_provider_->Shutdown();
152 } 152 }
153 153
154 bool ProfilePolicyConnector::IsManaged() const { 154 bool ProfilePolicyConnector::IsManaged() const {
155 if (is_managed_override_) 155 if (is_managed_override_)
156 return *is_managed_override_; 156 return *is_managed_override_;
157 return !GetManagementDomain().empty(); 157 const CloudPolicyStore* actual_policy_store = GetActualPolicyStore();
158 if (actual_policy_store)
159 return actual_policy_store->is_managed();
160 return false;
158 } 161 }
159 162
160 std::string ProfilePolicyConnector::GetManagementDomain() const { 163 std::string ProfilePolicyConnector::GetManagementDomain() const {
161 if (policy_store_) 164 const CloudPolicyStore* actual_policy_store = GetActualPolicyStore();
162 return GetStoreManagementDomain(policy_store_); 165 if (actual_policy_store)
163 #if defined(OS_CHROMEOS) 166 return GetStoreManagementDomain(actual_policy_store);
164 if (special_user_policy_provider_) {
165 // |special_user_policy_provider_| is non-null for device-local accounts and
166 // for the login profile.
167 // They receive policy iff the device itself is managed.
168 const DeviceCloudPolicyManagerChromeOS* const device_cloud_policy_manager =
169 g_browser_process->platform_part()
170 ->browser_policy_connector_chromeos()
171 ->GetDeviceCloudPolicyManager();
172 // The device_cloud_policy_manager can be a nullptr in unit tests.
173 if (device_cloud_policy_manager)
174 return GetStoreManagementDomain(
175 device_cloud_policy_manager->core()->store());
176 }
177 #endif
178 return std::string(); 167 return std::string();
179 } 168 }
180 169
181 bool ProfilePolicyConnector::IsProfilePolicy(const char* policy_key) const { 170 bool ProfilePolicyConnector::IsProfilePolicy(const char* policy_key) const {
182 const ConfigurationPolicyProvider* const provider = 171 const ConfigurationPolicyProvider* const provider =
183 DeterminePolicyProviderForPolicy(policy_key); 172 DeterminePolicyProviderForPolicy(policy_key);
184 return provider == configuration_policy_provider_; 173 return provider == configuration_policy_provider_;
185 } 174 }
186 175
176 const CloudPolicyStore* ProfilePolicyConnector::GetActualPolicyStore() const {
177 if (policy_store_)
178 return policy_store_;
179 #if defined(OS_CHROMEOS)
180 if (special_user_policy_provider_) {
181 // |special_user_policy_provider_| is non-null for device-local accounts and
182 // for the login profile.
183 const DeviceCloudPolicyManagerChromeOS* const device_cloud_policy_manager =
184 g_browser_process->platform_part()
185 ->browser_policy_connector_chromeos()
186 ->GetDeviceCloudPolicyManager();
187 // The device_cloud_policy_manager can be a nullptr in unit tests.
188 if (device_cloud_policy_manager)
189 return device_cloud_policy_manager->core()->store();
190 }
191 #endif
192 return nullptr;
193 }
194
187 const ConfigurationPolicyProvider* 195 const ConfigurationPolicyProvider*
188 ProfilePolicyConnector::DeterminePolicyProviderForPolicy( 196 ProfilePolicyConnector::DeterminePolicyProviderForPolicy(
189 const char* policy_key) const { 197 const char* policy_key) const {
190 const PolicyNamespace chrome_ns(POLICY_DOMAIN_CHROME, ""); 198 const PolicyNamespace chrome_ns(POLICY_DOMAIN_CHROME, "");
191 for (const ConfigurationPolicyProvider* provider : policy_providers_) { 199 for (const ConfigurationPolicyProvider* provider : policy_providers_) {
192 if (provider->policies().Get(chrome_ns).Get(policy_key)) 200 if (provider->policies().Get(chrome_ns).Get(policy_key))
193 return provider; 201 return provider;
194 } 202 }
195 return nullptr; 203 return nullptr;
196 } 204 }
197 205
198 } // namespace policy 206 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/profile_policy_connector.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698