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

Side by Side 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: Add VPN to connection types. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_cache.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 11 matching lines...) Expand all
22 #include "chrome/browser/policy/app_pack_updater.h" 22 #include "chrome/browser/policy/app_pack_updater.h"
23 #include "chrome/browser/policy/cloud_policy_data_store.h" 23 #include "chrome/browser/policy/cloud_policy_data_store.h"
24 #include "chrome/browser/policy/enterprise_install_attributes.h" 24 #include "chrome/browser/policy/enterprise_install_attributes.h"
25 #include "chrome/browser/policy/enterprise_metrics.h" 25 #include "chrome/browser/policy/enterprise_metrics.h"
26 #include "chrome/browser/policy/policy_map.h" 26 #include "chrome/browser/policy/policy_map.h"
27 #include "chrome/browser/policy/proto/device_management_backend.pb.h" 27 #include "chrome/browser/policy/proto/device_management_backend.pb.h"
28 #include "chrome/browser/policy/proto/device_management_local.pb.h" 28 #include "chrome/browser/policy/proto/device_management_local.pb.h"
29 #include "chromeos/dbus/dbus_thread_manager.h" 29 #include "chromeos/dbus/dbus_thread_manager.h"
30 #include "chromeos/dbus/update_engine_client.h" 30 #include "chromeos/dbus/update_engine_client.h"
31 #include "policy/policy_constants.h" 31 #include "policy/policy_constants.h"
32 #include "third_party/cros_system_api/dbus/service_constants.h"
32 33
34 using google::protobuf::RepeatedField;
33 using google::protobuf::RepeatedPtrField; 35 using google::protobuf::RepeatedPtrField;
34 36
35 namespace em = enterprise_management; 37 namespace em = enterprise_management;
36 38
37 namespace { 39 namespace {
38 40
39 // Stores policy, updates the owner key if required and reports the status 41 // Stores policy, updates the owner key if required and reports the status
40 // through a callback. 42 // through a callback.
41 class StorePolicyOperation : public chromeos::OwnerManager::KeyUpdateDelegate { 43 class StorePolicyOperation : public chromeos::OwnerManager::KeyUpdateDelegate {
42 public: 44 public:
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 if (value < std::numeric_limits<int>::min() || 107 if (value < std::numeric_limits<int>::min() ||
106 value > std::numeric_limits<int>::max()) { 108 value > std::numeric_limits<int>::max()) {
107 LOG(WARNING) << "Integer value " << value 109 LOG(WARNING) << "Integer value " << value
108 << " out of numeric limits, ignoring."; 110 << " out of numeric limits, ignoring.";
109 return NULL; 111 return NULL;
110 } 112 }
111 113
112 return Value::CreateIntegerValue(static_cast<int>(value)); 114 return Value::CreateIntegerValue(static_cast<int>(value));
113 } 115 }
114 116
117 Value* DecodeConnectionType(int value) {
118 static const char* const kConnectionTypes[] = {
119 flimflam::kTypeEthernet,
120 flimflam::kTypeWifi,
121 flimflam::kTypeWimax,
122 flimflam::kTypeBluetooth,
123 flimflam::kTypeCellular,
124 flimflam::kTypeVPN,
125 };
126
127 if (value < 0 || value >= static_cast<int>(arraysize(kConnectionTypes)))
128 return NULL;
129
130 return Value::CreateStringValue(kConnectionTypes[value]);
131 }
132
115 } // namespace 133 } // namespace
116 134
117 namespace policy { 135 namespace policy {
118 136
119 DevicePolicyCache::DevicePolicyCache( 137 DevicePolicyCache::DevicePolicyCache(
120 CloudPolicyDataStore* data_store, 138 CloudPolicyDataStore* data_store,
121 EnterpriseInstallAttributes* install_attributes) 139 EnterpriseInstallAttributes* install_attributes)
122 : data_store_(data_store), 140 : data_store_(data_store),
123 install_attributes_(install_attributes), 141 install_attributes_(install_attributes),
124 signed_settings_helper_(chromeos::SignedSettingsHelper::Get()), 142 signed_settings_helper_(chromeos::SignedSettingsHelper::Get()),
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 if (container.has_report_location()) { 599 if (container.has_report_location()) {
582 policies->Set(key::kReportDeviceLocation, 600 policies->Set(key::kReportDeviceLocation,
583 POLICY_LEVEL_MANDATORY, 601 POLICY_LEVEL_MANDATORY,
584 POLICY_SCOPE_MACHINE, 602 POLICY_SCOPE_MACHINE,
585 Value::CreateBooleanValue(container.report_location())); 603 Value::CreateBooleanValue(container.report_location()));
586 } 604 }
587 } 605 }
588 } 606 }
589 607
590 // static 608 // static
591 void DevicePolicyCache::DecodeGenericPolicies( 609 void DevicePolicyCache::DecodeAutoUpdatePolicies(
592 const em::ChromeDeviceSettingsProto& policy, 610 const em::ChromeDeviceSettingsProto& policy,
593 PolicyMap* policies) { 611 PolicyMap* policies) {
594 if (policy.has_device_policy_refresh_rate()) {
595 const em::DevicePolicyRefreshRateProto& container(
596 policy.device_policy_refresh_rate());
597 if (container.has_device_policy_refresh_rate()) {
598 policies->Set(key::kDevicePolicyRefreshRate,
599 POLICY_LEVEL_MANDATORY,
600 POLICY_SCOPE_MACHINE,
601 DecodeIntegerValue(container.device_policy_refresh_rate()));
602 }
603 }
604
605 if (policy.has_metrics_enabled()) {
606 const em::MetricsEnabledProto& container(policy.metrics_enabled());
607 if (container.has_metrics_enabled()) {
608 policies->Set(key::kDeviceMetricsReportingEnabled,
609 POLICY_LEVEL_MANDATORY,
610 POLICY_SCOPE_MACHINE,
611 Value::CreateBooleanValue(container.metrics_enabled()));
612 }
613 }
614
615 if (policy.has_release_channel()) { 612 if (policy.has_release_channel()) {
616 const em::ReleaseChannelProto& container(policy.release_channel()); 613 const em::ReleaseChannelProto& container(policy.release_channel());
617 if (container.has_release_channel()) { 614 if (container.has_release_channel()) {
618 std::string channel(container.release_channel()); 615 std::string channel(container.release_channel());
619 policies->Set(key::kChromeOsReleaseChannel, 616 policies->Set(key::kChromeOsReleaseChannel,
620 POLICY_LEVEL_MANDATORY, 617 POLICY_LEVEL_MANDATORY,
621 POLICY_SCOPE_MACHINE, 618 POLICY_SCOPE_MACHINE,
622 Value::CreateStringValue(channel)); 619 Value::CreateStringValue(channel));
623 // TODO(dubroy): Once http://crosbug.com/17015 is implemented, we won't 620 // TODO(dubroy): Once http://crosbug.com/17015 is implemented, we won't
624 // have to pass the channel in here, only ping the update engine to tell 621 // have to pass the channel in here, only ping the update engine to tell
(...skipping 19 matching lines...) Expand all
644 Value::CreateBooleanValue(container.update_disabled())); 641 Value::CreateBooleanValue(container.update_disabled()));
645 } 642 }
646 643
647 if (container.has_target_version_prefix()) { 644 if (container.has_target_version_prefix()) {
648 policies->Set(key::kDeviceTargetVersionPrefix, 645 policies->Set(key::kDeviceTargetVersionPrefix,
649 POLICY_LEVEL_MANDATORY, 646 POLICY_LEVEL_MANDATORY,
650 POLICY_SCOPE_MACHINE, 647 POLICY_SCOPE_MACHINE,
651 Value::CreateStringValue( 648 Value::CreateStringValue(
652 container.target_version_prefix())); 649 container.target_version_prefix()));
653 } 650 }
651
652 // target_version_display_name is not actually a policy, but a display
653 // string for target_version_prefix, so we ignore it.
654
655 if (container.has_scatter_factor_in_seconds()) {
656 policies->Set(key::kDeviceUpdateScatterFactor,
657 POLICY_LEVEL_MANDATORY,
658 POLICY_SCOPE_MACHINE,
659 Value::CreateIntegerValue(
660 container.scatter_factor_in_seconds()));
661 }
662
663 if (container.allowed_connection_types_size()) {
664 ListValue* allowed_connection_types = new ListValue();
665 RepeatedField<int>::const_iterator entry;
666 for (entry = container.allowed_connection_types().begin();
667 entry != container.allowed_connection_types().end();
668 ++entry) {
669 base::Value* value = DecodeConnectionType(*entry);
670 if (!value)
671 allowed_connection_types->Append(value);
672 }
673 policies->Set(key::kDeviceUpdateAllowedConnectionTypes,
674 POLICY_LEVEL_MANDATORY,
675 POLICY_SCOPE_MACHINE,
676 allowed_connection_types);
677 }
678 }
679 }
680
681 // static
682 void DevicePolicyCache::DecodeGenericPolicies(
683 const em::ChromeDeviceSettingsProto& policy,
684 PolicyMap* policies) {
685 if (policy.has_device_policy_refresh_rate()) {
686 const em::DevicePolicyRefreshRateProto& container(
687 policy.device_policy_refresh_rate());
688 if (container.has_device_policy_refresh_rate()) {
689 policies->Set(key::kDevicePolicyRefreshRate,
690 POLICY_LEVEL_MANDATORY,
691 POLICY_SCOPE_MACHINE,
692 DecodeIntegerValue(container.device_policy_refresh_rate()));
693 }
694 }
695
696 if (policy.has_metrics_enabled()) {
697 const em::MetricsEnabledProto& container(policy.metrics_enabled());
698 if (container.has_metrics_enabled()) {
699 policies->Set(key::kDeviceMetricsReportingEnabled,
700 POLICY_LEVEL_MANDATORY,
701 POLICY_SCOPE_MACHINE,
702 Value::CreateBooleanValue(container.metrics_enabled()));
703 }
654 } 704 }
655 705
656 if (policy.has_start_up_urls()) { 706 if (policy.has_start_up_urls()) {
657 const em::StartUpUrlsProto& container(policy.start_up_urls()); 707 const em::StartUpUrlsProto& container(policy.start_up_urls());
658 if (container.start_up_urls_size()) { 708 if (container.start_up_urls_size()) {
659 ListValue* urls = new ListValue(); 709 ListValue* urls = new ListValue();
660 RepeatedPtrField<std::string>::const_iterator entry; 710 RepeatedPtrField<std::string>::const_iterator entry;
661 for (entry = container.start_up_urls().begin(); 711 for (entry = container.start_up_urls().begin();
662 entry != container.start_up_urls().end(); 712 entry != container.start_up_urls().end();
663 ++entry) { 713 ++entry) {
664 urls->Append(Value::CreateStringValue(*entry)); 714 urls->Append(Value::CreateStringValue(*entry));
665 } 715 }
666 policies->Set(key::kDeviceStartUpUrls, 716 policies->Set(key::kDeviceStartUpUrls,
667 POLICY_LEVEL_MANDATORY, 717 POLICY_LEVEL_MANDATORY,
668 POLICY_SCOPE_MACHINE, 718 POLICY_SCOPE_MACHINE,
669 urls); 719 urls);
670 } 720 }
671 } 721 }
672 } 722 }
673 723
674 } // namespace policy 724 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698