| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/user_policy_cache.h" | 5 #include "chrome/browser/policy/user_policy_cache.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 14 #include "chrome/browser/policy/configuration_policy_pref_store.h" | 14 #include "chrome/browser/policy/configuration_policy_pref_store.h" |
| 15 #include "chrome/browser/policy/enterprise_metrics.h" | 15 #include "chrome/browser/policy/enterprise_metrics.h" |
| 16 #include "chrome/browser/policy/policy_map.h" | 16 #include "chrome/browser/policy/policy_map.h" |
| 17 #include "chrome/browser/policy/proto/cloud_policy.pb.h" | 17 #include "chrome/browser/policy/proto/cloud_policy.pb.h" |
| 18 #include "chrome/browser/policy/proto/device_management_local.pb.h" | 18 #include "chrome/browser/policy/proto/device_management_local.pb.h" |
| 19 #include "chrome/browser/policy/proto/old_generic_format.pb.h" | 19 #include "chrome/browser/policy/proto/old_generic_format.pb.h" |
| 20 #include "policy/configuration_policy_type.h" | 20 #include "policy/configuration_policy_type.h" |
| 21 #include "policy/policy_constants.h" |
| 21 | 22 |
| 22 namespace policy { | 23 namespace policy { |
| 23 | 24 |
| 24 // Decodes a CloudPolicySettings object into two maps with mandatory and | 25 // Decodes a CloudPolicySettings object into two maps with mandatory and |
| 25 // recommended settings, respectively. The implementation is generated code | 26 // recommended settings, respectively. The implementation is generated code |
| 26 // in policy/cloud_policy_generated.cc. | 27 // in policy/cloud_policy_generated.cc. |
| 27 void DecodePolicy(const em::CloudPolicySettings& policy, | 28 void DecodePolicy(const em::CloudPolicySettings& policy, |
| 28 PolicyMap* mandatory, PolicyMap* recommended); | 29 PolicyMap* mandatory, PolicyMap* recommended); |
| 29 | 30 |
| 30 UserPolicyCache::UserPolicyCache(const FilePath& backing_file_path) | 31 UserPolicyCache::UserPolicyCache(const FilePath& backing_file_path) |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 RepeatedPtrField<em::GenericNamedValue>::const_iterator named_value; | 133 RepeatedPtrField<em::GenericNamedValue>::const_iterator named_value; |
| 133 for (named_value = policy.named_value().begin(); | 134 for (named_value = policy.named_value().begin(); |
| 134 named_value != policy.named_value().end(); | 135 named_value != policy.named_value().end(); |
| 135 ++named_value) { | 136 ++named_value) { |
| 136 if (named_value->has_value()) { | 137 if (named_value->has_value()) { |
| 137 Value* decoded_value = DecodeValue(named_value->value()); | 138 Value* decoded_value = DecodeValue(named_value->value()); |
| 138 if (decoded_value) | 139 if (decoded_value) |
| 139 result.Set(named_value->name(), decoded_value); | 140 result.Set(named_value->name(), decoded_value); |
| 140 } | 141 } |
| 141 } | 142 } |
| 142 mandatory->LoadFrom( | 143 mandatory->LoadFrom(&result, GetChromePolicyDefinitionList()); |
| 143 &result, | |
| 144 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList()); | |
| 145 } | 144 } |
| 146 | 145 |
| 147 Value* UserPolicyCache::DecodeIntegerValue( | 146 Value* UserPolicyCache::DecodeIntegerValue( |
| 148 google::protobuf::int64 value) const { | 147 google::protobuf::int64 value) const { |
| 149 if (value < std::numeric_limits<int>::min() || | 148 if (value < std::numeric_limits<int>::min() || |
| 150 value > std::numeric_limits<int>::max()) { | 149 value > std::numeric_limits<int>::max()) { |
| 151 LOG(WARNING) << "Integer value " << value | 150 LOG(WARNING) << "Integer value " << value |
| 152 << " out of numeric limits, ignoring."; | 151 << " out of numeric limits, ignoring."; |
| 153 return NULL; | 152 return NULL; |
| 154 } | 153 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 return list; | 218 return list; |
| 220 } | 219 } |
| 221 default: | 220 default: |
| 222 NOTREACHED() << "Unhandled value type"; | 221 NOTREACHED() << "Unhandled value type"; |
| 223 } | 222 } |
| 224 | 223 |
| 225 return NULL; | 224 return NULL; |
| 226 } | 225 } |
| 227 | 226 |
| 228 } // namespace policy | 227 } // namespace policy |
| OLD | NEW |