diff options
Diffstat (limited to 'chrome/browser/policy')
-rw-r--r-- | chrome/browser/policy/device_policy_cache.cc | 94 | ||||
-rw-r--r-- | chrome/browser/policy/device_policy_cache.h | 3 | ||||
-rw-r--r-- | chrome/browser/policy/proto/chrome_device_policy.proto | 18 |
3 files changed, 92 insertions, 23 deletions
diff --git a/chrome/browser/policy/device_policy_cache.cc b/chrome/browser/policy/device_policy_cache.cc index 3c4bb24..d1b666b 100644 --- a/chrome/browser/policy/device_policy_cache.cc +++ b/chrome/browser/policy/device_policy_cache.cc @@ -29,7 +29,9 @@ #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/update_engine_client.h" #include "policy/policy_constants.h" +#include "third_party/cros_system_api/dbus/service_constants.h" +using google::protobuf::RepeatedField; using google::protobuf::RepeatedPtrField; namespace em = enterprise_management; @@ -112,6 +114,21 @@ Value* DecodeIntegerValue(google::protobuf::int64 value) { return Value::CreateIntegerValue(static_cast<int>(value)); } +Value* DecodeConnectionType(int value) { + static const char* const kConnectionTypes[] = { + flimflam::kTypeEthernet, + flimflam::kTypeWifi, + flimflam::kTypeWimax, + flimflam::kTypeBluetooth, + flimflam::kTypeCellular, + }; + + if (value < 0 || value >= static_cast<int>(arraysize(kConnectionTypes))) + return NULL; + + return Value::CreateStringValue(kConnectionTypes[value]); +} + } // namespace namespace policy { @@ -356,6 +373,7 @@ void DevicePolicyCache::DecodeDevicePolicy( DecodeKioskPolicies(policy, policies, install_attributes_); DecodeNetworkPolicies(policy, policies, install_attributes_); DecodeReportingPolicies(policy, policies); + DecodeAutoUpdatePolicies(policy, policies); DecodeGenericPolicies(policy, policies); } @@ -589,30 +607,9 @@ void DevicePolicyCache::DecodeReportingPolicies( } // static -void DevicePolicyCache::DecodeGenericPolicies( +void DevicePolicyCache::DecodeAutoUpdatePolicies( const em::ChromeDeviceSettingsProto& policy, PolicyMap* policies) { - if (policy.has_device_policy_refresh_rate()) { - const em::DevicePolicyRefreshRateProto& container( - policy.device_policy_refresh_rate()); - if (container.has_device_policy_refresh_rate()) { - policies->Set(key::kDevicePolicyRefreshRate, - POLICY_LEVEL_MANDATORY, - POLICY_SCOPE_MACHINE, - DecodeIntegerValue(container.device_policy_refresh_rate())); - } - } - - if (policy.has_metrics_enabled()) { - const em::MetricsEnabledProto& container(policy.metrics_enabled()); - if (container.has_metrics_enabled()) { - policies->Set(key::kDeviceMetricsReportingEnabled, - POLICY_LEVEL_MANDATORY, - POLICY_SCOPE_MACHINE, - Value::CreateBooleanValue(container.metrics_enabled())); - } - } - if (policy.has_release_channel()) { const em::ReleaseChannelProto& container(policy.release_channel()); if (container.has_release_channel()) { @@ -652,6 +649,59 @@ void DevicePolicyCache::DecodeGenericPolicies( Value::CreateStringValue( container.target_version_prefix())); } + + // target_version_display_name is not actually a policy, but a display + // string for target_version_prefix, so we ignore it. + + if (container.has_scatter_factor_in_seconds()) { + policies->Set(key::kDeviceUpdateScatterFactor, + POLICY_LEVEL_MANDATORY, + POLICY_SCOPE_MACHINE, + Value::CreateIntegerValue( + container.scatter_factor_in_seconds())); + } + + if (container.allowed_connection_types_size()) { + ListValue* allowed_connection_types = new ListValue(); + RepeatedField<int>::const_iterator entry; + for (entry = container.allowed_connection_types().begin(); + entry != container.allowed_connection_types().end(); + ++entry) { + base::Value* value = DecodeConnectionType(*entry); + if (value) + allowed_connection_types->Append(value); + } + policies->Set(key::kDeviceUpdateAllowedConnectionTypes, + POLICY_LEVEL_MANDATORY, + POLICY_SCOPE_MACHINE, + allowed_connection_types); + } + } +} + +// static +void DevicePolicyCache::DecodeGenericPolicies( + const em::ChromeDeviceSettingsProto& policy, + PolicyMap* policies) { + if (policy.has_device_policy_refresh_rate()) { + const em::DevicePolicyRefreshRateProto& container( + policy.device_policy_refresh_rate()); + if (container.has_device_policy_refresh_rate()) { + policies->Set(key::kDevicePolicyRefreshRate, + POLICY_LEVEL_MANDATORY, + POLICY_SCOPE_MACHINE, + DecodeIntegerValue(container.device_policy_refresh_rate())); + } + } + + if (policy.has_metrics_enabled()) { + const em::MetricsEnabledProto& container(policy.metrics_enabled()); + if (container.has_metrics_enabled()) { + policies->Set(key::kDeviceMetricsReportingEnabled, + POLICY_LEVEL_MANDATORY, + POLICY_SCOPE_MACHINE, + Value::CreateBooleanValue(container.metrics_enabled())); + } } if (policy.has_start_up_urls()) { diff --git a/chrome/browser/policy/device_policy_cache.h b/chrome/browser/policy/device_policy_cache.h index c396a9f..0987296 100644 --- a/chrome/browser/policy/device_policy_cache.h +++ b/chrome/browser/policy/device_policy_cache.h @@ -98,6 +98,9 @@ class DevicePolicyCache : public CloudPolicyCacheBase { static void DecodeReportingPolicies( const enterprise_management::ChromeDeviceSettingsProto& policy, PolicyMap* policies); + static void DecodeAutoUpdatePolicies( + const enterprise_management::ChromeDeviceSettingsProto& policy, + PolicyMap* policies); static void DecodeGenericPolicies( const enterprise_management::ChromeDeviceSettingsProto& policy, PolicyMap* policies); diff --git a/chrome/browser/policy/proto/chrome_device_policy.proto b/chrome/browser/policy/proto/chrome_device_policy.proto index 17a1743c..5313c88 100644 --- a/chrome/browser/policy/proto/chrome_device_policy.proto +++ b/chrome/browser/policy/proto/chrome_device_policy.proto @@ -178,10 +178,26 @@ message AutoUpdateSettingsProto { // delay its download of an update from the time the update was first pushed // out to the server. The device may wait a portion of this time in terms // of wall-clock-time and the remaining portion in terms of the number of - // update checks. In any case, the scatter is upper bounded to a constant + // update checks. In any case, the scatter is upper bounded by a constant // amount of time so that a device does not ever get stuck waiting to download // an update forever. optional int64 scatter_factor_in_seconds = 4; + + // Enumerates network connection types. + enum ConnectionType { + CONNECTION_TYPE_ETHERNET = 0; + CONNECTION_TYPE_WIFI = 1; + CONNECTION_TYPE_WIMAX = 2; + CONNECTION_TYPE_BLUETOOTH = 3; + CONNECTION_TYPE_CELLULAR = 4; + } + + // The types of connections that are OK to use for OS updates. OS updates + // potentially put heavy strain on the connection due to their size and may + // incur additional cost. Therefore, they are by default not enabled for + // connection types that are considered expensive, which include WiMax, + // Bluetooth and Cellular at the moment. + repeated ConnectionType allowed_connection_types = 5; } message StartUpUrlsProto { |