Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/device_policy_cache.h" | 5 #include "chrome/browser/policy/device_policy_decoder_chromeos.h" |
| 6 | 6 |
| 7 #include <limits> | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/basictypes.h" | |
| 12 #include "base/bind.h" | |
| 13 #include "base/callback.h" | |
| 14 #include "base/compiler_specific.h" | |
| 15 #include "base/logging.h" | |
|
Joao da Silva
2012/08/28 19:56:57
There's a LOG(WARNING)
Mattias Nissler (ping if slow)
2012/08/31 14:13:18
Done.
| |
| 16 #include "base/metrics/histogram.h" | |
| 17 #include "base/values.h" | |
|
Joao da Silva
2012/08/28 19:56:57
This is used
Mattias Nissler (ping if slow)
2012/08/31 14:13:18
Done.
| |
| 18 #include "chrome/browser/policy/app_pack_updater.h" | 7 #include "chrome/browser/policy/app_pack_updater.h" |
| 19 #include "chrome/browser/policy/cloud_policy_data_store.h" | |
| 20 #include "chrome/browser/policy/enterprise_install_attributes.h" | 8 #include "chrome/browser/policy/enterprise_install_attributes.h" |
| 21 #include "chrome/browser/policy/enterprise_metrics.h" | |
| 22 #include "chrome/browser/policy/policy_map.h" | 9 #include "chrome/browser/policy/policy_map.h" |
| 23 #include "chrome/browser/policy/proto/chrome_device_policy.pb.h" | 10 #include "chrome/browser/policy/proto/chrome_device_policy.pb.h" |
| 24 #include "chrome/browser/policy/proto/device_management_backend.pb.h" | |
| 25 #include "chrome/browser/policy/proto/device_management_local.pb.h" | |
| 26 #include "chrome/common/net/gaia/gaia_auth_util.h" | |
| 27 #include "chromeos/dbus/dbus_thread_manager.h" | 11 #include "chromeos/dbus/dbus_thread_manager.h" |
| 28 #include "chromeos/dbus/update_engine_client.h" | 12 #include "chromeos/dbus/update_engine_client.h" |
| 29 #include "policy/policy_constants.h" | 13 #include "policy/policy_constants.h" |
| 30 #include "third_party/cros_system_api/dbus/service_constants.h" | 14 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 31 | 15 |
| 32 using google::protobuf::RepeatedField; | 16 using google::protobuf::RepeatedField; |
| 33 using google::protobuf::RepeatedPtrField; | 17 using google::protobuf::RepeatedPtrField; |
| 34 | 18 |
| 35 namespace em = enterprise_management; | 19 namespace em = enterprise_management; |
| 36 | 20 |
| 21 namespace policy { | |
| 22 | |
| 37 namespace { | 23 namespace { |
| 38 | 24 |
| 39 // Decodes a protobuf integer to an IntegerValue. The caller assumes ownership | 25 // Decodes a protobuf integer to an IntegerValue. The caller assumes ownership |
| 40 // of the return Value*. Returns NULL in case the input value is out of bounds. | 26 // of the return Value*. Returns NULL in case the input value is out of bounds. |
| 41 Value* DecodeIntegerValue(google::protobuf::int64 value) { | 27 Value* DecodeIntegerValue(google::protobuf::int64 value) { |
| 42 if (value < std::numeric_limits<int>::min() || | 28 if (value < std::numeric_limits<int>::min() || |
| 43 value > std::numeric_limits<int>::max()) { | 29 value > std::numeric_limits<int>::max()) { |
| 44 LOG(WARNING) << "Integer value " << value | 30 LOG(WARNING) << "Integer value " << value |
| 45 << " out of numeric limits, ignoring."; | 31 << " out of numeric limits, ignoring."; |
| 46 return NULL; | 32 return NULL; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 57 flimflam::kTypeBluetooth, | 43 flimflam::kTypeBluetooth, |
| 58 flimflam::kTypeCellular, | 44 flimflam::kTypeCellular, |
| 59 }; | 45 }; |
| 60 | 46 |
| 61 if (value < 0 || value >= static_cast<int>(arraysize(kConnectionTypes))) | 47 if (value < 0 || value >= static_cast<int>(arraysize(kConnectionTypes))) |
| 62 return NULL; | 48 return NULL; |
| 63 | 49 |
| 64 return Value::CreateStringValue(kConnectionTypes[value]); | 50 return Value::CreateStringValue(kConnectionTypes[value]); |
| 65 } | 51 } |
| 66 | 52 |
| 67 } // namespace | 53 void DecodeLoginPolicies(const em::ChromeDeviceSettingsProto& policy, |
| 68 | 54 PolicyMap* policies) { |
| 69 namespace policy { | |
| 70 | |
| 71 DevicePolicyCache::DevicePolicyCache( | |
| 72 CloudPolicyDataStore* data_store, | |
| 73 EnterpriseInstallAttributes* install_attributes) | |
| 74 : data_store_(data_store), | |
| 75 install_attributes_(install_attributes), | |
| 76 device_settings_service_(chromeos::DeviceSettingsService::Get()), | |
| 77 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)), | |
| 78 policy_fetch_pending_(false) { | |
| 79 device_settings_service_->AddObserver(this); | |
| 80 } | |
| 81 | |
| 82 DevicePolicyCache::DevicePolicyCache( | |
| 83 CloudPolicyDataStore* data_store, | |
| 84 EnterpriseInstallAttributes* install_attributes, | |
| 85 chromeos::DeviceSettingsService* device_settings_service) | |
| 86 : data_store_(data_store), | |
| 87 install_attributes_(install_attributes), | |
| 88 device_settings_service_(device_settings_service), | |
| 89 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)), | |
| 90 policy_fetch_pending_(false) { | |
| 91 device_settings_service_->AddObserver(this); | |
| 92 } | |
| 93 | |
| 94 DevicePolicyCache::~DevicePolicyCache() { | |
| 95 device_settings_service_->RemoveObserver(this); | |
| 96 } | |
| 97 | |
| 98 void DevicePolicyCache::Load() { | |
| 99 DeviceSettingsUpdated(); | |
| 100 } | |
| 101 | |
| 102 bool DevicePolicyCache::SetPolicy(const em::PolicyFetchResponse& policy) { | |
| 103 DCHECK(IsReady()); | |
| 104 | |
| 105 // Make sure we have an enterprise device. | |
| 106 std::string registration_domain(install_attributes_->GetDomain()); | |
| 107 if (registration_domain.empty()) { | |
| 108 LOG(WARNING) << "Refusing to accept policy on non-enterprise device."; | |
| 109 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, | |
| 110 kMetricPolicyFetchNonEnterpriseDevice, | |
| 111 kMetricPolicySize); | |
| 112 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR, | |
| 113 CloudPolicySubsystem::POLICY_LOCAL_ERROR); | |
| 114 return false; | |
| 115 } | |
| 116 | |
| 117 // Check the user this policy is for against the device-locked name. | |
| 118 em::PolicyData policy_data; | |
| 119 if (!policy_data.ParseFromString(policy.policy_data())) { | |
| 120 LOG(WARNING) << "Invalid policy protobuf"; | |
| 121 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchInvalidPolicy, | |
| 122 kMetricPolicySize); | |
| 123 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR, | |
| 124 CloudPolicySubsystem::POLICY_LOCAL_ERROR); | |
| 125 return false; | |
| 126 } | |
| 127 | |
| 128 // Existing installations may not have a canonicalized version of the | |
| 129 // registration domain in install attributes, so lower-case the data here. | |
| 130 if (registration_domain != gaia::ExtractDomainName(policy_data.username())) { | |
| 131 LOG(WARNING) << "Refusing policy blob for " << policy_data.username() | |
| 132 << " which doesn't match domain " << registration_domain; | |
| 133 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchUserMismatch, | |
| 134 kMetricPolicySize); | |
| 135 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR, | |
| 136 CloudPolicySubsystem::POLICY_LOCAL_ERROR); | |
| 137 return false; | |
| 138 } | |
| 139 | |
| 140 set_last_policy_refresh_time(base::Time::NowFromSystemTime()); | |
| 141 | |
| 142 // Start a store operation. | |
| 143 policy_fetch_pending_ = true; | |
| 144 device_settings_service_->Store( | |
| 145 policy.SerializeAsString(), | |
| 146 base::Bind(&DevicePolicyCache::PolicyStoreOpCompleted, | |
| 147 weak_ptr_factory_.GetWeakPtr())); | |
| 148 return true; | |
| 149 } | |
| 150 | |
| 151 void DevicePolicyCache::SetUnmanaged() { | |
| 152 LOG(WARNING) << "Tried to set DevicePolicyCache to 'unmanaged'!"; | |
| 153 // This is not supported for DevicePolicyCache. | |
| 154 } | |
| 155 | |
| 156 void DevicePolicyCache::SetFetchingDone() { | |
| 157 // Don't send the notification just yet if there is a pending policy | |
| 158 // store/reload cycle. | |
| 159 if (!policy_fetch_pending_) | |
| 160 CloudPolicyCacheBase::SetFetchingDone(); | |
| 161 } | |
| 162 | |
| 163 void DevicePolicyCache::OwnershipStatusChanged() {} | |
| 164 | |
| 165 void DevicePolicyCache::DeviceSettingsUpdated() { | |
| 166 DCHECK(CalledOnValidThread()); | |
| 167 chromeos::DeviceSettingsService::Status status = | |
| 168 device_settings_service_->status(); | |
| 169 const em::PolicyData* policy_data = device_settings_service_->policy_data(); | |
| 170 if (status == chromeos::DeviceSettingsService::STORE_SUCCESS && | |
| 171 !policy_data) { | |
| 172 // Initial policy load is still pending. | |
| 173 return; | |
| 174 } | |
| 175 | |
| 176 if (!IsReady()) { | |
| 177 std::string device_token; | |
| 178 InstallInitialPolicy(status, policy_data, &device_token); | |
| 179 SetTokenAndFlagReady(device_token); | |
| 180 } else { // In other words, IsReady() == true | |
| 181 if (status != chromeos::DeviceSettingsService::STORE_SUCCESS || | |
| 182 !policy_data) { | |
| 183 if (status == chromeos::DeviceSettingsService::STORE_VALIDATION_ERROR) { | |
| 184 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchBadSignature, | |
| 185 kMetricPolicySize); | |
| 186 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR, | |
| 187 CloudPolicySubsystem::SIGNATURE_MISMATCH); | |
| 188 } else { | |
| 189 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchOtherFailed, | |
| 190 kMetricPolicySize); | |
| 191 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR, | |
| 192 CloudPolicySubsystem::POLICY_LOCAL_ERROR); | |
| 193 } | |
| 194 } else { | |
| 195 em::PolicyFetchResponse policy_response; | |
| 196 CHECK(policy_data->SerializeToString( | |
| 197 policy_response.mutable_policy_data())); | |
| 198 bool ok = SetPolicyInternal(policy_response, NULL, false); | |
| 199 if (ok) { | |
| 200 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchOK, | |
| 201 kMetricPolicySize); | |
| 202 } | |
| 203 } | |
| 204 } | |
| 205 } | |
| 206 | |
| 207 bool DevicePolicyCache::DecodePolicyData(const em::PolicyData& policy_data, | |
| 208 PolicyMap* policies) { | |
| 209 em::ChromeDeviceSettingsProto policy; | |
| 210 if (!policy.ParseFromString(policy_data.policy_value())) { | |
| 211 LOG(WARNING) << "Failed to parse ChromeDeviceSettingsProto."; | |
| 212 return false; | |
| 213 } | |
| 214 DecodeDevicePolicy(policy, policies); | |
| 215 return true; | |
| 216 } | |
| 217 | |
| 218 void DevicePolicyCache::PolicyStoreOpCompleted() { | |
| 219 DCHECK(CalledOnValidThread()); | |
| 220 chromeos::DeviceSettingsService::Status status = | |
| 221 device_settings_service_->status(); | |
| 222 if (status != chromeos::DeviceSettingsService::STORE_SUCCESS) { | |
| 223 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyStoreFailed, | |
| 224 kMetricPolicySize); | |
| 225 if (status == chromeos::DeviceSettingsService::STORE_VALIDATION_ERROR) { | |
| 226 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchBadSignature, | |
| 227 kMetricPolicySize); | |
| 228 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR, | |
| 229 CloudPolicySubsystem::SIGNATURE_MISMATCH); | |
| 230 } else { | |
| 231 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchOtherFailed, | |
| 232 kMetricPolicySize); | |
| 233 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR, | |
| 234 CloudPolicySubsystem::POLICY_LOCAL_ERROR); | |
| 235 } | |
| 236 CheckFetchingDone(); | |
| 237 return; | |
| 238 } | |
| 239 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyStoreSucceeded, | |
| 240 kMetricPolicySize); | |
| 241 | |
| 242 CheckFetchingDone(); | |
| 243 } | |
| 244 | |
| 245 void DevicePolicyCache::InstallInitialPolicy( | |
| 246 chromeos::DeviceSettingsService::Status status, | |
| 247 const em::PolicyData* policy_data, | |
| 248 std::string* device_token) { | |
| 249 if (status == chromeos::DeviceSettingsService::STORE_NO_POLICY || | |
| 250 status == chromeos::DeviceSettingsService::STORE_KEY_UNAVAILABLE) { | |
| 251 InformNotifier(CloudPolicySubsystem::UNENROLLED, | |
| 252 CloudPolicySubsystem::NO_DETAILS); | |
| 253 return; | |
| 254 } | |
| 255 if (!policy_data) { | |
| 256 LOG(WARNING) << "Failed to parse PolicyData protobuf."; | |
| 257 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyLoadFailed, | |
| 258 kMetricPolicySize); | |
| 259 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR, | |
| 260 CloudPolicySubsystem::POLICY_LOCAL_ERROR); | |
| 261 return; | |
| 262 } | |
| 263 if (!policy_data->has_request_token() || | |
| 264 policy_data->request_token().empty()) { | |
| 265 SetUnmanagedInternal(base::Time::NowFromSystemTime()); | |
| 266 InformNotifier(CloudPolicySubsystem::UNMANAGED, | |
| 267 CloudPolicySubsystem::NO_DETAILS); | |
| 268 // TODO(jkummerow): Reminder: When we want to feed device-wide settings | |
| 269 // made by a local owner into this cache, we need to call | |
| 270 // SetPolicyInternal() here. | |
| 271 return; | |
| 272 } | |
| 273 if (!policy_data->has_username() || !policy_data->has_device_id()) { | |
| 274 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyLoadFailed, | |
| 275 kMetricPolicySize); | |
| 276 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR, | |
| 277 CloudPolicySubsystem::POLICY_LOCAL_ERROR); | |
| 278 return; | |
| 279 } | |
| 280 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyLoadSucceeded, | |
| 281 kMetricPolicySize); | |
| 282 data_store_->set_user_name(policy_data->username()); | |
| 283 data_store_->set_device_id(policy_data->device_id()); | |
| 284 *device_token = policy_data->request_token(); | |
| 285 base::Time timestamp; | |
| 286 em::PolicyFetchResponse policy_response; | |
| 287 CHECK(policy_data->SerializeToString(policy_response.mutable_policy_data())); | |
| 288 if (SetPolicyInternal(policy_response, ×tamp, true)) | |
| 289 set_last_policy_refresh_time(timestamp); | |
| 290 } | |
| 291 | |
| 292 void DevicePolicyCache::SetTokenAndFlagReady(const std::string& device_token) { | |
| 293 // We need to call SetDeviceToken unconditionally to indicate the cache has | |
| 294 // finished loading. | |
| 295 data_store_->SetDeviceToken(device_token, true); | |
| 296 SetReady(); | |
| 297 } | |
| 298 | |
| 299 void DevicePolicyCache::CheckFetchingDone() { | |
| 300 if (policy_fetch_pending_) { | |
| 301 CloudPolicyCacheBase::SetFetchingDone(); | |
| 302 policy_fetch_pending_ = false; | |
| 303 } | |
| 304 } | |
| 305 | |
| 306 void DevicePolicyCache::DecodeDevicePolicy( | |
| 307 const em::ChromeDeviceSettingsProto& policy, | |
| 308 PolicyMap* policies) { | |
| 309 // Decode the various groups of policies. | |
| 310 DecodeLoginPolicies(policy, policies); | |
| 311 DecodeKioskPolicies(policy, policies, install_attributes_); | |
| 312 DecodeNetworkPolicies(policy, policies, install_attributes_); | |
| 313 DecodeReportingPolicies(policy, policies); | |
| 314 DecodeAutoUpdatePolicies(policy, policies); | |
| 315 DecodeGenericPolicies(policy, policies); | |
| 316 } | |
| 317 | |
| 318 // static | |
| 319 void DevicePolicyCache::DecodeLoginPolicies( | |
| 320 const em::ChromeDeviceSettingsProto& policy, | |
| 321 PolicyMap* policies) { | |
| 322 if (policy.has_guest_mode_enabled()) { | 55 if (policy.has_guest_mode_enabled()) { |
| 323 const em::GuestModeEnabledProto& container(policy.guest_mode_enabled()); | 56 const em::GuestModeEnabledProto& container(policy.guest_mode_enabled()); |
| 324 if (container.has_guest_mode_enabled()) { | 57 if (container.has_guest_mode_enabled()) { |
| 325 policies->Set(key::kDeviceGuestModeEnabled, | 58 policies->Set(key::kDeviceGuestModeEnabled, |
| 326 POLICY_LEVEL_MANDATORY, | 59 POLICY_LEVEL_MANDATORY, |
| 327 POLICY_SCOPE_MACHINE, | 60 POLICY_SCOPE_MACHINE, |
| 328 Value::CreateBooleanValue(container.guest_mode_enabled())); | 61 Value::CreateBooleanValue(container.guest_mode_enabled())); |
| 329 } | 62 } |
| 330 } | 63 } |
| 331 | 64 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 372 if (container.has_ephemeral_users_enabled()) { | 105 if (container.has_ephemeral_users_enabled()) { |
| 373 policies->Set(key::kDeviceEphemeralUsersEnabled, | 106 policies->Set(key::kDeviceEphemeralUsersEnabled, |
| 374 POLICY_LEVEL_MANDATORY, | 107 POLICY_LEVEL_MANDATORY, |
| 375 POLICY_SCOPE_MACHINE, | 108 POLICY_SCOPE_MACHINE, |
| 376 Value::CreateBooleanValue( | 109 Value::CreateBooleanValue( |
| 377 container.ephemeral_users_enabled())); | 110 container.ephemeral_users_enabled())); |
| 378 } | 111 } |
| 379 } | 112 } |
| 380 } | 113 } |
| 381 | 114 |
| 382 // static | 115 void DecodeKioskPolicies(const em::ChromeDeviceSettingsProto& policy, |
| 383 void DevicePolicyCache::DecodeKioskPolicies( | 116 PolicyMap* policies, |
| 384 const em::ChromeDeviceSettingsProto& policy, | 117 EnterpriseInstallAttributes* install_attributes) { |
| 385 PolicyMap* policies, | |
| 386 EnterpriseInstallAttributes* install_attributes) { | |
| 387 // No policies if this is not KIOSK. | 118 // No policies if this is not KIOSK. |
| 388 if (install_attributes->GetMode() != DEVICE_MODE_KIOSK) | 119 if (install_attributes->GetMode() != DEVICE_MODE_KIOSK) |
| 389 return; | 120 return; |
| 390 | 121 |
| 391 if (policy.has_forced_logout_timeouts()) { | 122 if (policy.has_forced_logout_timeouts()) { |
| 392 const em::ForcedLogoutTimeoutsProto& container( | 123 const em::ForcedLogoutTimeoutsProto& container( |
| 393 policy.forced_logout_timeouts()); | 124 policy.forced_logout_timeouts()); |
| 394 if (container.has_idle_logout_timeout()) { | 125 if (container.has_idle_logout_timeout()) { |
| 395 policies->Set(key::kDeviceIdleLogoutTimeout, | 126 policies->Set(key::kDeviceIdleLogoutTimeout, |
| 396 POLICY_LEVEL_MANDATORY, | 127 POLICY_LEVEL_MANDATORY, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 448 for (int i = 0; i < container.app_id_size(); ++i) | 179 for (int i = 0; i < container.app_id_size(); ++i) |
| 449 pinned_apps_list->Append(Value::CreateStringValue(container.app_id(i))); | 180 pinned_apps_list->Append(Value::CreateStringValue(container.app_id(i))); |
| 450 | 181 |
| 451 policies->Set(key::kPinnedLauncherApps, | 182 policies->Set(key::kPinnedLauncherApps, |
| 452 POLICY_LEVEL_RECOMMENDED, | 183 POLICY_LEVEL_RECOMMENDED, |
| 453 POLICY_SCOPE_MACHINE, | 184 POLICY_SCOPE_MACHINE, |
| 454 pinned_apps_list); | 185 pinned_apps_list); |
| 455 } | 186 } |
| 456 } | 187 } |
| 457 | 188 |
| 458 // static | 189 void DecodeNetworkPolicies(const em::ChromeDeviceSettingsProto& policy, |
| 459 void DevicePolicyCache::DecodeNetworkPolicies( | 190 PolicyMap* policies, |
| 460 const em::ChromeDeviceSettingsProto& policy, | 191 EnterpriseInstallAttributes* install_attributes) { |
| 461 PolicyMap* policies, | |
| 462 EnterpriseInstallAttributes* install_attributes) { | |
| 463 if (policy.has_device_proxy_settings()) { | 192 if (policy.has_device_proxy_settings()) { |
| 464 const em::DeviceProxySettingsProto& container( | 193 const em::DeviceProxySettingsProto& container( |
| 465 policy.device_proxy_settings()); | 194 policy.device_proxy_settings()); |
| 466 scoped_ptr<DictionaryValue> proxy_settings(new DictionaryValue); | 195 scoped_ptr<DictionaryValue> proxy_settings(new DictionaryValue); |
| 467 if (container.has_proxy_mode()) | 196 if (container.has_proxy_mode()) |
| 468 proxy_settings->SetString(key::kProxyMode, container.proxy_mode()); | 197 proxy_settings->SetString(key::kProxyMode, container.proxy_mode()); |
| 469 if (container.has_proxy_server()) | 198 if (container.has_proxy_server()) |
| 470 proxy_settings->SetString(key::kProxyServer, container.proxy_server()); | 199 proxy_settings->SetString(key::kProxyServer, container.proxy_server()); |
| 471 if (container.has_proxy_pac_url()) | 200 if (container.has_proxy_pac_url()) |
| 472 proxy_settings->SetString(key::kProxyPacUrl, container.proxy_pac_url()); | 201 proxy_settings->SetString(key::kProxyPacUrl, container.proxy_pac_url()); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 503 policy.open_network_configuration().has_open_network_configuration()) { | 232 policy.open_network_configuration().has_open_network_configuration()) { |
| 504 std::string config( | 233 std::string config( |
| 505 policy.open_network_configuration().open_network_configuration()); | 234 policy.open_network_configuration().open_network_configuration()); |
| 506 policies->Set(key::kDeviceOpenNetworkConfiguration, | 235 policies->Set(key::kDeviceOpenNetworkConfiguration, |
| 507 POLICY_LEVEL_MANDATORY, | 236 POLICY_LEVEL_MANDATORY, |
| 508 POLICY_SCOPE_MACHINE, | 237 POLICY_SCOPE_MACHINE, |
| 509 Value::CreateStringValue(config)); | 238 Value::CreateStringValue(config)); |
| 510 } | 239 } |
| 511 } | 240 } |
| 512 | 241 |
| 513 // static | 242 void DecodeReportingPolicies(const em::ChromeDeviceSettingsProto& policy, |
| 514 void DevicePolicyCache::DecodeReportingPolicies( | 243 PolicyMap* policies) { |
| 515 const em::ChromeDeviceSettingsProto& policy, | |
| 516 PolicyMap* policies) { | |
| 517 if (policy.has_device_reporting()) { | 244 if (policy.has_device_reporting()) { |
| 518 const em::DeviceReportingProto& container(policy.device_reporting()); | 245 const em::DeviceReportingProto& container(policy.device_reporting()); |
| 519 if (container.has_report_version_info()) { | 246 if (container.has_report_version_info()) { |
| 520 policies->Set(key::kReportDeviceVersionInfo, | 247 policies->Set(key::kReportDeviceVersionInfo, |
| 521 POLICY_LEVEL_MANDATORY, | 248 POLICY_LEVEL_MANDATORY, |
| 522 POLICY_SCOPE_MACHINE, | 249 POLICY_SCOPE_MACHINE, |
| 523 Value::CreateBooleanValue(container.report_version_info())); | 250 Value::CreateBooleanValue(container.report_version_info())); |
| 524 } | 251 } |
| 525 if (container.has_report_activity_times()) { | 252 if (container.has_report_activity_times()) { |
| 526 policies->Set(key::kReportDeviceActivityTimes, | 253 policies->Set(key::kReportDeviceActivityTimes, |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 537 } | 264 } |
| 538 if (container.has_report_location()) { | 265 if (container.has_report_location()) { |
| 539 policies->Set(key::kReportDeviceLocation, | 266 policies->Set(key::kReportDeviceLocation, |
| 540 POLICY_LEVEL_MANDATORY, | 267 POLICY_LEVEL_MANDATORY, |
| 541 POLICY_SCOPE_MACHINE, | 268 POLICY_SCOPE_MACHINE, |
| 542 Value::CreateBooleanValue(container.report_location())); | 269 Value::CreateBooleanValue(container.report_location())); |
| 543 } | 270 } |
| 544 } | 271 } |
| 545 } | 272 } |
| 546 | 273 |
| 547 // static | 274 void DecodeAutoUpdatePolicies(const em::ChromeDeviceSettingsProto& policy, |
| 548 void DevicePolicyCache::DecodeAutoUpdatePolicies( | 275 PolicyMap* policies) { |
| 549 const em::ChromeDeviceSettingsProto& policy, | |
| 550 PolicyMap* policies) { | |
| 551 if (policy.has_release_channel()) { | 276 if (policy.has_release_channel()) { |
| 552 const em::ReleaseChannelProto& container(policy.release_channel()); | 277 const em::ReleaseChannelProto& container(policy.release_channel()); |
| 553 if (container.has_release_channel()) { | 278 if (container.has_release_channel()) { |
| 554 std::string channel(container.release_channel()); | 279 std::string channel(container.release_channel()); |
| 555 policies->Set(key::kChromeOsReleaseChannel, | 280 policies->Set(key::kChromeOsReleaseChannel, |
| 556 POLICY_LEVEL_MANDATORY, | 281 POLICY_LEVEL_MANDATORY, |
| 557 POLICY_SCOPE_MACHINE, | 282 POLICY_SCOPE_MACHINE, |
| 558 Value::CreateStringValue(channel)); | 283 Value::CreateStringValue(channel)); |
| 559 // TODO(dubroy): Once http://crosbug.com/17015 is implemented, we won't | 284 // TODO(dubroy): Once http://crosbug.com/17015 is implemented, we won't |
| 560 // have to pass the channel in here, only ping the update engine to tell | 285 // have to pass the channel in here, only ping the update engine to tell |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 610 allowed_connection_types->Append(value); | 335 allowed_connection_types->Append(value); |
| 611 } | 336 } |
| 612 policies->Set(key::kDeviceUpdateAllowedConnectionTypes, | 337 policies->Set(key::kDeviceUpdateAllowedConnectionTypes, |
| 613 POLICY_LEVEL_MANDATORY, | 338 POLICY_LEVEL_MANDATORY, |
| 614 POLICY_SCOPE_MACHINE, | 339 POLICY_SCOPE_MACHINE, |
| 615 allowed_connection_types); | 340 allowed_connection_types); |
| 616 } | 341 } |
| 617 } | 342 } |
| 618 } | 343 } |
| 619 | 344 |
| 620 // static | 345 void DecodeGenericPolicies(const em::ChromeDeviceSettingsProto& policy, |
| 621 void DevicePolicyCache::DecodeGenericPolicies( | 346 PolicyMap* policies) { |
| 622 const em::ChromeDeviceSettingsProto& policy, | |
| 623 PolicyMap* policies) { | |
| 624 if (policy.has_device_policy_refresh_rate()) { | 347 if (policy.has_device_policy_refresh_rate()) { |
| 625 const em::DevicePolicyRefreshRateProto& container( | 348 const em::DevicePolicyRefreshRateProto& container( |
| 626 policy.device_policy_refresh_rate()); | 349 policy.device_policy_refresh_rate()); |
| 627 if (container.has_device_policy_refresh_rate()) { | 350 if (container.has_device_policy_refresh_rate()) { |
| 628 policies->Set(key::kDevicePolicyRefreshRate, | 351 policies->Set(key::kDevicePolicyRefreshRate, |
| 629 POLICY_LEVEL_MANDATORY, | 352 POLICY_LEVEL_MANDATORY, |
| 630 POLICY_SCOPE_MACHINE, | 353 POLICY_SCOPE_MACHINE, |
| 631 DecodeIntegerValue(container.device_policy_refresh_rate())); | 354 DecodeIntegerValue(container.device_policy_refresh_rate())); |
| 632 } | 355 } |
| 633 } | 356 } |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 663 if (policy.system_timezone().has_timezone()) { | 386 if (policy.system_timezone().has_timezone()) { |
| 664 policies->Set(key::kSystemTimezone, | 387 policies->Set(key::kSystemTimezone, |
| 665 POLICY_LEVEL_MANDATORY, | 388 POLICY_LEVEL_MANDATORY, |
| 666 POLICY_SCOPE_MACHINE, | 389 POLICY_SCOPE_MACHINE, |
| 667 Value::CreateStringValue( | 390 Value::CreateStringValue( |
| 668 policy.system_timezone().timezone())); | 391 policy.system_timezone().timezone())); |
| 669 } | 392 } |
| 670 } | 393 } |
| 671 } | 394 } |
| 672 | 395 |
| 396 } // namespace | |
| 397 | |
| 398 void DecodeDevicePolicy(const em::ChromeDeviceSettingsProto& policy, | |
| 399 PolicyMap* policies, | |
| 400 EnterpriseInstallAttributes* install_attributes) { | |
| 401 // Decode the various groups of policies. | |
| 402 DecodeLoginPolicies(policy, policies); | |
| 403 DecodeKioskPolicies(policy, policies, install_attributes); | |
| 404 DecodeNetworkPolicies(policy, policies, install_attributes); | |
| 405 DecodeReportingPolicies(policy, policies); | |
| 406 DecodeAutoUpdatePolicies(policy, policies); | |
| 407 DecodeGenericPolicies(policy, policies); | |
| 408 } | |
| 409 | |
| 673 } // namespace policy | 410 } // namespace policy |
| OLD | NEW |