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

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: rebase, drop vpn. 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 };
125
126 if (value < 0 || value >= static_cast<int>(arraysize(kConnectionTypes)))
127 return NULL;
128
129 return Value::CreateStringValue(kConnectionTypes[value]);
130 }
131
115 } // namespace 132 } // namespace
116 133
117 namespace policy { 134 namespace policy {
118 135
119 DevicePolicyCache::DevicePolicyCache( 136 DevicePolicyCache::DevicePolicyCache(
120 CloudPolicyDataStore* data_store, 137 CloudPolicyDataStore* data_store,
121 EnterpriseInstallAttributes* install_attributes) 138 EnterpriseInstallAttributes* install_attributes)
122 : data_store_(data_store), 139 : data_store_(data_store),
123 install_attributes_(install_attributes), 140 install_attributes_(install_attributes),
124 signed_settings_helper_(chromeos::SignedSettingsHelper::Get()), 141 signed_settings_helper_(chromeos::SignedSettingsHelper::Get()),
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 if (container.has_report_location()) { 598 if (container.has_report_location()) {
582 policies->Set(key::kReportDeviceLocation, 599 policies->Set(key::kReportDeviceLocation,
583 POLICY_LEVEL_MANDATORY, 600 POLICY_LEVEL_MANDATORY,
584 POLICY_SCOPE_MACHINE, 601 POLICY_SCOPE_MACHINE,
585 Value::CreateBooleanValue(container.report_location())); 602 Value::CreateBooleanValue(container.report_location()));
586 } 603 }
587 } 604 }
588 } 605 }
589 606
590 // static 607 // static
591 void DevicePolicyCache::DecodeGenericPolicies( 608 void DevicePolicyCache::DecodeAutoUpdatePolicies(
592 const em::ChromeDeviceSettingsProto& policy, 609 const em::ChromeDeviceSettingsProto& policy,
593 PolicyMap* policies) { 610 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()) { 611 if (policy.has_release_channel()) {
616 const em::ReleaseChannelProto& container(policy.release_channel()); 612 const em::ReleaseChannelProto& container(policy.release_channel());
617 if (container.has_release_channel()) { 613 if (container.has_release_channel()) {
618 std::string channel(container.release_channel()); 614 std::string channel(container.release_channel());
619 policies->Set(key::kChromeOsReleaseChannel, 615 policies->Set(key::kChromeOsReleaseChannel,
620 POLICY_LEVEL_MANDATORY, 616 POLICY_LEVEL_MANDATORY,
621 POLICY_SCOPE_MACHINE, 617 POLICY_SCOPE_MACHINE,
622 Value::CreateStringValue(channel)); 618 Value::CreateStringValue(channel));
623 // TODO(dubroy): Once http://crosbug.com/17015 is implemented, we won't 619 // 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 620 // 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())); 640 Value::CreateBooleanValue(container.update_disabled()));
645 } 641 }
646 642
647 if (container.has_target_version_prefix()) { 643 if (container.has_target_version_prefix()) {
648 policies->Set(key::kDeviceTargetVersionPrefix, 644 policies->Set(key::kDeviceTargetVersionPrefix,
649 POLICY_LEVEL_MANDATORY, 645 POLICY_LEVEL_MANDATORY,
650 POLICY_SCOPE_MACHINE, 646 POLICY_SCOPE_MACHINE,
651 Value::CreateStringValue( 647 Value::CreateStringValue(
652 container.target_version_prefix())); 648 container.target_version_prefix()));
653 } 649 }
650
651 // target_version_display_name is not actually a policy, but a display
652 // string for target_version_prefix, so we ignore it.
653
654 if (container.has_scatter_factor_in_seconds()) {
655 policies->Set(key::kDeviceUpdateScatterFactor,
656 POLICY_LEVEL_MANDATORY,
657 POLICY_SCOPE_MACHINE,
658 Value::CreateIntegerValue(
659 container.scatter_factor_in_seconds()));
660 }
661
662 if (container.allowed_connection_types_size()) {
663 ListValue* allowed_connection_types = new ListValue();
664 RepeatedField<int>::const_iterator entry;
665 for (entry = container.allowed_connection_types().begin();
666 entry != container.allowed_connection_types().end();
667 ++entry) {
668 base::Value* value = DecodeConnectionType(*entry);
669 if (!value)
670 allowed_connection_types->Append(value);
671 }
672 policies->Set(key::kDeviceUpdateAllowedConnectionTypes,
673 POLICY_LEVEL_MANDATORY,
674 POLICY_SCOPE_MACHINE,
675 allowed_connection_types);
676 }
677 }
678 }
679
680 // static
681 void DevicePolicyCache::DecodeGenericPolicies(
682 const em::ChromeDeviceSettingsProto& policy,
683 PolicyMap* policies) {
684 if (policy.has_device_policy_refresh_rate()) {
685 const em::DevicePolicyRefreshRateProto& container(
686 policy.device_policy_refresh_rate());
687 if (container.has_device_policy_refresh_rate()) {
688 policies->Set(key::kDevicePolicyRefreshRate,
689 POLICY_LEVEL_MANDATORY,
690 POLICY_SCOPE_MACHINE,
691 DecodeIntegerValue(container.device_policy_refresh_rate()));
692 }
693 }
694
695 if (policy.has_metrics_enabled()) {
696 const em::MetricsEnabledProto& container(policy.metrics_enabled());
697 if (container.has_metrics_enabled()) {
698 policies->Set(key::kDeviceMetricsReportingEnabled,
699 POLICY_LEVEL_MANDATORY,
700 POLICY_SCOPE_MACHINE,
701 Value::CreateBooleanValue(container.metrics_enabled()));
702 }
654 } 703 }
655 704
656 if (policy.has_start_up_urls()) { 705 if (policy.has_start_up_urls()) {
657 const em::StartUpUrlsProto& container(policy.start_up_urls()); 706 const em::StartUpUrlsProto& container(policy.start_up_urls());
658 if (container.start_up_urls_size()) { 707 if (container.start_up_urls_size()) {
659 ListValue* urls = new ListValue(); 708 ListValue* urls = new ListValue();
660 RepeatedPtrField<std::string>::const_iterator entry; 709 RepeatedPtrField<std::string>::const_iterator entry;
661 for (entry = container.start_up_urls().begin(); 710 for (entry = container.start_up_urls().begin();
662 entry != container.start_up_urls().end(); 711 entry != container.start_up_urls().end();
663 ++entry) { 712 ++entry) {
664 urls->Append(Value::CreateStringValue(*entry)); 713 urls->Append(Value::CreateStringValue(*entry));
665 } 714 }
666 policies->Set(key::kDeviceStartUpUrls, 715 policies->Set(key::kDeviceStartUpUrls,
667 POLICY_LEVEL_MANDATORY, 716 POLICY_LEVEL_MANDATORY,
668 POLICY_SCOPE_MACHINE, 717 POLICY_SCOPE_MACHINE,
669 urls); 718 urls);
670 } 719 }
671 } 720 }
672 } 721 }
673 722
674 } // namespace policy 723 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698