Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 if (policy_store_) |
| 158 return policy_store_->is_managed(); | |
| 159 #if defined(OS_CHROMEOS) | |
|
Thiemo Nagel
2017/02/15 16:23:03
Nit: Instead of duplicating that code, I'd suggest
Marton Hunyady
2017/02/15 20:13:54
Done.
| |
| 160 if (special_user_policy_provider_) { | |
| 161 // If |special_user_policy_provider_| is non-null the profile is managed iff | |
| 162 // the device itself is managed. | |
| 163 const DeviceCloudPolicyManagerChromeOS* const device_cloud_policy_manager = | |
| 164 g_browser_process->platform_part() | |
| 165 ->browser_policy_connector_chromeos() | |
| 166 ->GetDeviceCloudPolicyManager(); | |
| 167 // The device_cloud_policy_manager can be a nullptr in unit tests. | |
| 168 if (device_cloud_policy_manager) | |
| 169 return device_cloud_policy_manager->core()->store()->is_managed(); | |
| 170 } | |
| 171 #endif | |
| 172 return false; | |
| 158 } | 173 } |
| 159 | 174 |
| 160 std::string ProfilePolicyConnector::GetManagementDomain() const { | 175 std::string ProfilePolicyConnector::GetManagementDomain() const { |
| 161 if (policy_store_) | 176 if (policy_store_) |
| 162 return GetStoreManagementDomain(policy_store_); | 177 return GetStoreManagementDomain(policy_store_); |
| 163 #if defined(OS_CHROMEOS) | 178 #if defined(OS_CHROMEOS) |
| 164 if (special_user_policy_provider_) { | 179 if (special_user_policy_provider_) { |
| 165 // |special_user_policy_provider_| is non-null for device-local accounts and | 180 // |special_user_policy_provider_| is non-null for device-local accounts and |
| 166 // for the login profile. | 181 // for the login profile. |
| 167 // They receive policy iff the device itself is managed. | 182 // They receive policy iff the device itself is managed. |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 189 const char* policy_key) const { | 204 const char* policy_key) const { |
| 190 const PolicyNamespace chrome_ns(POLICY_DOMAIN_CHROME, ""); | 205 const PolicyNamespace chrome_ns(POLICY_DOMAIN_CHROME, ""); |
| 191 for (const ConfigurationPolicyProvider* provider : policy_providers_) { | 206 for (const ConfigurationPolicyProvider* provider : policy_providers_) { |
| 192 if (provider->policies().Get(chrome_ns).Get(policy_key)) | 207 if (provider->policies().Get(chrome_ns).Get(policy_key)) |
| 193 return provider; | 208 return provider; |
| 194 } | 209 } |
| 195 return nullptr; | 210 return nullptr; |
| 196 } | 211 } |
| 197 | 212 |
| 198 } // namespace policy | 213 } // namespace policy |
| OLD | NEW |