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

Unified Diff: chrome/browser/policy/device_policy_cache.cc

Issue 10388254: Introduce a device setting controlling allowed connection types for AU. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and fix some bugs. Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/policy/device_policy_cache.h ('k') | chrome/browser/policy/proto/chrome_device_policy.proto » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/policy/device_policy_cache.cc
diff --git a/chrome/browser/policy/device_policy_cache.cc b/chrome/browser/policy/device_policy_cache.cc
index 3c4bb24c158da271f038f88754fab69a12631fc3..d1b666bda7521a08129239d879550c4b942f43e2 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()) {
« no previous file with comments | « chrome/browser/policy/device_policy_cache.h ('k') | chrome/browser/policy/proto/chrome_device_policy.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698