Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "chromeos/network/onc/onc_merger.h" | 5 #include "chromeos/network/onc/onc_merger.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "chromeos/network/onc/onc_constants.h" | 14 #include "chromeos/network/onc/onc_constants.h" |
| 15 #include "chromeos/network/onc/onc_signature.h" | |
| 15 | 16 |
| 16 namespace chromeos { | 17 namespace chromeos { |
| 17 namespace onc { | 18 namespace onc { |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| 20 typedef scoped_ptr<base::DictionaryValue> DictionaryPtr; | 21 typedef scoped_ptr<base::DictionaryValue> DictionaryPtr; |
| 21 | 22 |
| 22 // Inserts |true| at every field name in |result| that is recommended in | 23 // Inserts |true| at every field name in |result| that is recommended in |
| 23 // |policy|. | 24 // |policy|. |
| 24 void MarkRecommendedFieldnames(const base::DictionaryValue& policy, | 25 void MarkRecommendedFieldnames(const base::DictionaryValue& policy, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 scoped_ptr<base::Value> merged_value; | 90 scoped_ptr<base::Value> merged_value; |
| 90 if (field.value().IsType(base::Value::TYPE_DICTIONARY)) { | 91 if (field.value().IsType(base::Value::TYPE_DICTIONARY)) { |
| 91 DictPtrs nested_dicts; | 92 DictPtrs nested_dicts; |
| 92 for (DictPtrs::const_iterator it_inner = dicts.begin(); | 93 for (DictPtrs::const_iterator it_inner = dicts.begin(); |
| 93 it_inner != dicts.end(); ++it_inner) { | 94 it_inner != dicts.end(); ++it_inner) { |
| 94 const base::DictionaryValue* nested_dict = NULL; | 95 const base::DictionaryValue* nested_dict = NULL; |
| 95 if (*it_inner) | 96 if (*it_inner) |
| 96 (*it_inner)->GetDictionaryWithoutPathExpansion(key, &nested_dict); | 97 (*it_inner)->GetDictionaryWithoutPathExpansion(key, &nested_dict); |
| 97 nested_dicts.push_back(nested_dict); | 98 nested_dicts.push_back(nested_dict); |
| 98 } | 99 } |
| 99 DictionaryPtr merged_dict(MergeDictionaries(nested_dicts)); | 100 DictionaryPtr merged_dict(MergeNestedDictionaries(key, nested_dicts)); |
| 100 if (!merged_dict->empty()) | 101 if (!merged_dict->empty()) |
| 101 merged_value = merged_dict.Pass(); | 102 merged_value = merged_dict.Pass(); |
| 102 } else { | 103 } else { |
| 103 std::vector<const base::Value*> values; | 104 std::vector<const base::Value*> values; |
| 104 for (DictPtrs::const_iterator it_inner = dicts.begin(); | 105 for (DictPtrs::const_iterator it_inner = dicts.begin(); |
| 105 it_inner != dicts.end(); ++it_inner) { | 106 it_inner != dicts.end(); ++it_inner) { |
| 106 const base::Value* value = NULL; | 107 const base::Value* value = NULL; |
| 107 if (*it_inner) | 108 if (*it_inner) |
| 108 (*it_inner)->GetWithoutPathExpansion(key, &value); | 109 (*it_inner)->GetWithoutPathExpansion(key, &value); |
| 109 values.push_back(value); | 110 values.push_back(value); |
| 110 } | 111 } |
| 111 merged_value = MergeListOfValues(values); | 112 merged_value = MergeListOfValues(key, values); |
| 112 } | 113 } |
| 113 | 114 |
| 114 if (merged_value) | 115 if (merged_value) |
| 115 result->SetWithoutPathExpansion(key, merged_value.release()); | 116 result->SetWithoutPathExpansion(key, merged_value.release()); |
| 116 } | 117 } |
| 117 } | 118 } |
| 118 return result.Pass(); | 119 return result.Pass(); |
| 119 } | 120 } |
| 120 | 121 |
| 121 protected: | 122 protected: |
| 122 // This function is called by MergeDictionaries for each list of values that | 123 // This function is called by MergeDictionaries for each list of values that |
| 123 // are located at the same path in each of the dictionaries. The order of the | 124 // are located at the same path in each of the dictionaries. The order of the |
| 124 // values is the same as of the given dictionaries |dicts|. If a dictionary | 125 // values is the same as of the given dictionaries |dicts|. If a dictionary |
| 125 // doesn't contain a path then it's value is NULL. | 126 // doesn't contain a path then it's value is NULL. |
| 126 virtual scoped_ptr<base::Value> MergeListOfValues( | 127 virtual scoped_ptr<base::Value> MergeListOfValues( |
| 128 const std::string& key, | |
| 127 const std::vector<const base::Value*>& values) = 0; | 129 const std::vector<const base::Value*>& values) = 0; |
| 128 | 130 |
| 131 virtual DictionaryPtr MergeNestedDictionaries(const std::string& key, | |
| 132 const DictPtrs &dicts) { | |
| 133 return MergeDictionaries(dicts); | |
| 134 } | |
| 135 | |
| 129 private: | 136 private: |
| 130 DISALLOW_COPY_AND_ASSIGN(MergeListOfDictionaries); | 137 DISALLOW_COPY_AND_ASSIGN(MergeListOfDictionaries); |
| 131 }; | 138 }; |
| 132 | 139 |
| 133 // This is the base class for merging policies and user settings. | 140 // This is the base class for merging policies and user settings. |
| 134 class MergeSettingsAndPolicies : public MergeListOfDictionaries { | 141 class MergeSettingsAndPolicies : public MergeListOfDictionaries { |
| 135 public: | 142 public: |
| 136 struct ValueParams { | 143 struct ValueParams { |
| 137 const base::Value* user_policy; | 144 const base::Value* user_policy; |
| 138 const base::Value* device_policy; | 145 const base::Value* device_policy; |
| 139 const base::Value* user_settings; | 146 const base::Value* user_setting; |
| 140 const base::Value* shared_settings; | 147 const base::Value* shared_setting; |
| 148 const base::Value* active_setting; | |
| 141 bool user_editable; | 149 bool user_editable; |
| 142 bool device_editable; | 150 bool device_editable; |
| 143 }; | 151 }; |
| 144 | 152 |
| 145 // Merge the provided dictionaries. For each path in any of the dictionaries, | 153 // Merge the provided dictionaries. For each path in any of the dictionaries, |
| 146 // MergeValues is called. Its results are collected in a new dictionary which | 154 // MergeValues is called. Its results are collected in a new dictionary which |
| 147 // is then returned. The resulting dictionary never contains empty | 155 // is then returned. The resulting dictionary never contains empty |
| 148 // dictionaries. | 156 // dictionaries. |
| 149 DictionaryPtr MergeDictionaries( | 157 DictionaryPtr MergeDictionaries( |
| 150 const base::DictionaryValue* user_policy, | 158 const base::DictionaryValue* user_policy, |
| 151 const base::DictionaryValue* device_policy, | 159 const base::DictionaryValue* device_policy, |
| 152 const base::DictionaryValue* user_settings, | 160 const base::DictionaryValue* user_settings, |
| 153 const base::DictionaryValue* shared_settings) { | 161 const base::DictionaryValue* shared_settings, |
| 162 const base::DictionaryValue* active_settings) { | |
| 154 hasUserPolicy_ = (user_policy != NULL); | 163 hasUserPolicy_ = (user_policy != NULL); |
| 155 hasDevicePolicy_ = (device_policy != NULL); | 164 hasDevicePolicy_ = (device_policy != NULL); |
| 156 | 165 |
| 157 DictionaryPtr user_editable; | 166 DictionaryPtr user_editable; |
| 158 if (user_policy != NULL) | 167 if (user_policy != NULL) |
| 159 user_editable = GetEditableFlags(*user_policy); | 168 user_editable = GetEditableFlags(*user_policy); |
| 160 | 169 |
| 161 DictionaryPtr device_editable; | 170 DictionaryPtr device_editable; |
| 162 if (device_policy != NULL) | 171 if (device_policy != NULL) |
| 163 device_editable = GetEditableFlags(*device_policy); | 172 device_editable = GetEditableFlags(*device_policy); |
| 164 | 173 |
| 165 std::vector<const base::DictionaryValue*> dicts(kLastIndex, NULL); | 174 std::vector<const base::DictionaryValue*> dicts(kLastIndex, NULL); |
| 166 dicts[kUserPolicyIndex] = user_policy; | 175 dicts[kUserPolicyIndex] = user_policy; |
| 167 dicts[kDevicePolicyIndex] = device_policy; | 176 dicts[kDevicePolicyIndex] = device_policy; |
| 168 dicts[kUserSettingsIndex] = user_settings; | 177 dicts[kUserSettingsIndex] = user_settings; |
| 169 dicts[kSharedSettingsIndex] = shared_settings; | 178 dicts[kSharedSettingsIndex] = shared_settings; |
| 179 dicts[kActiveSettingsIndex] = active_settings; | |
| 170 dicts[kUserEditableIndex] = user_editable.get(); | 180 dicts[kUserEditableIndex] = user_editable.get(); |
| 171 dicts[kDeviceEditableIndex] = device_editable.get(); | 181 dicts[kDeviceEditableIndex] = device_editable.get(); |
| 172 return MergeListOfDictionaries::MergeDictionaries(dicts); | 182 return MergeListOfDictionaries::MergeDictionaries(dicts); |
| 173 } | 183 } |
| 174 | 184 |
| 175 protected: | 185 protected: |
| 176 // This function is called by MergeDictionaries for each list of values that | 186 // This function is called by MergeDictionaries for each list of values that |
| 177 // are located at the same path in each of the dictionaries. Implementations | 187 // are located at the same path in each of the dictionaries. Implementations |
| 178 // can use the Has*Policy functions. | 188 // can use the Has*Policy functions. |
| 179 virtual scoped_ptr<base::Value> MergeValues(ValueParams values) = 0; | 189 virtual scoped_ptr<base::Value> MergeValues(const std::string& key, |
| 190 const ValueParams& values) = 0; | |
| 180 | 191 |
| 181 // Whether a user policy was provided. | 192 // Whether a user policy was provided. |
| 182 bool HasUserPolicy() { | 193 bool HasUserPolicy() { |
| 183 return hasUserPolicy_; | 194 return hasUserPolicy_; |
| 184 } | 195 } |
| 185 | 196 |
| 186 // Whether a device policy was provided. | 197 // Whether a device policy was provided. |
| 187 bool HasDevicePolicy() { | 198 bool HasDevicePolicy() { |
| 188 return hasDevicePolicy_; | 199 return hasDevicePolicy_; |
| 189 } | 200 } |
| 190 | 201 |
| 191 // MergeListOfDictionaries override. | 202 // MergeListOfDictionaries override. |
| 192 virtual scoped_ptr<base::Value> MergeListOfValues( | 203 virtual scoped_ptr<base::Value> MergeListOfValues( |
| 204 const std::string& key, | |
| 193 const std::vector<const base::Value*>& values) OVERRIDE { | 205 const std::vector<const base::Value*>& values) OVERRIDE { |
| 194 bool user_editable = !HasUserPolicy(); | 206 bool user_editable = !HasUserPolicy(); |
| 195 if (values[kUserEditableIndex]) | 207 if (values[kUserEditableIndex]) |
| 196 values[kUserEditableIndex]->GetAsBoolean(&user_editable); | 208 values[kUserEditableIndex]->GetAsBoolean(&user_editable); |
| 197 | 209 |
| 198 bool device_editable = !HasDevicePolicy(); | 210 bool device_editable = !HasDevicePolicy(); |
| 199 if (values[kDeviceEditableIndex]) | 211 if (values[kDeviceEditableIndex]) |
| 200 values[kDeviceEditableIndex]->GetAsBoolean(&device_editable); | 212 values[kDeviceEditableIndex]->GetAsBoolean(&device_editable); |
| 201 | 213 |
| 202 ValueParams params; | 214 ValueParams params; |
| 203 params.user_policy = values[kUserPolicyIndex]; | 215 params.user_policy = values[kUserPolicyIndex]; |
| 204 params.device_policy = values[kDevicePolicyIndex]; | 216 params.device_policy = values[kDevicePolicyIndex]; |
| 205 params.user_settings = values[kUserSettingsIndex]; | 217 params.user_setting = values[kUserSettingsIndex]; |
| 206 params.shared_settings = values[kSharedSettingsIndex]; | 218 params.shared_setting = values[kSharedSettingsIndex]; |
| 219 params.active_setting = values[kActiveSettingsIndex]; | |
| 207 params.user_editable = user_editable; | 220 params.user_editable = user_editable; |
| 208 params.device_editable = device_editable; | 221 params.device_editable = device_editable; |
| 209 return MergeValues(params); | 222 return MergeValues(key, params); |
| 210 } | 223 } |
| 211 | 224 |
| 212 private: | 225 private: |
| 213 enum { | 226 enum { |
| 214 kUserPolicyIndex, | 227 kUserPolicyIndex, |
| 215 kDevicePolicyIndex, | 228 kDevicePolicyIndex, |
| 216 kUserSettingsIndex, | 229 kUserSettingsIndex, |
| 217 kSharedSettingsIndex, | 230 kSharedSettingsIndex, |
| 231 kActiveSettingsIndex, | |
| 218 kUserEditableIndex, | 232 kUserEditableIndex, |
| 219 kDeviceEditableIndex, | 233 kDeviceEditableIndex, |
| 220 kLastIndex | 234 kLastIndex |
| 221 }; | 235 }; |
| 222 | 236 |
| 223 bool hasUserPolicy_, hasDevicePolicy_; | 237 bool hasUserPolicy_, hasDevicePolicy_; |
| 224 }; | 238 }; |
| 225 | 239 |
| 226 // Call MergeDictionaries to merge policies and settings to the effective | 240 // Call MergeDictionaries to merge policies and settings to the effective |
| 227 // values. See the description of MergeSettingsAndPoliciesToEffective. | 241 // values. This ignores the active settings of Shill. See the description of |
| 242 // MergeSettingsAndPoliciesToEffective. | |
| 228 class MergeToEffective : public MergeSettingsAndPolicies { | 243 class MergeToEffective : public MergeSettingsAndPolicies { |
| 229 protected: | 244 protected: |
| 230 // Merges |values| to the effective value (Mandatory policy overwrites user | 245 // Merges |values| to the effective value (Mandatory policy overwrites user |
| 231 // settings overwrites shared settings overwrites recommended policy). |which| | 246 // settings overwrites shared settings overwrites recommended policy). |which| |
| 232 // is set to the respective onc::kAugmentation* constant that indicates which | 247 // is set to the respective onc::kAugmentation* constant that indicates which |
| 233 // source of settings is effective. Note that this function may return a NULL | 248 // source of settings is effective. Note that this function may return a NULL |
| 234 // pointer and set |which| to kAugmentationUserPolicy, which means that the | 249 // pointer and set |which| to kAugmentationUserPolicy, which means that the |
| 235 // user policy didn't set a value but also didn't recommend it, thus enforcing | 250 // user policy didn't set a value but also didn't recommend it, thus enforcing |
| 236 // the empty value. | 251 // the empty value. |
| 237 scoped_ptr<base::Value> MergeValues(ValueParams values, std::string* which) { | 252 scoped_ptr<base::Value> MergeValues(const std::string& key, |
| 253 const ValueParams& values, | |
| 254 std::string* which) { | |
| 238 const base::Value* result = NULL; | 255 const base::Value* result = NULL; |
| 239 which->clear(); | 256 which->clear(); |
| 240 if (!values.user_editable) { | 257 if (!values.user_editable) { |
| 241 result = values.user_policy; | 258 result = values.user_policy; |
| 242 *which = kAugmentationUserPolicy; | 259 *which = kAugmentationUserPolicy; |
| 243 } else if (!values.device_editable) { | 260 } else if (!values.device_editable) { |
| 244 result = values.device_policy; | 261 result = values.device_policy; |
| 245 *which = kAugmentationDevicePolicy; | 262 *which = kAugmentationDevicePolicy; |
| 246 } else if (values.user_settings) { | 263 } else if (values.user_setting) { |
| 247 result = values.user_settings; | 264 result = values.user_setting; |
| 248 *which = kAugmentationUserSetting; | 265 *which = kAugmentationUserSetting; |
| 249 } else if (values.shared_settings) { | 266 } else if (values.shared_setting) { |
| 250 result = values.shared_settings; | 267 result = values.shared_setting; |
| 251 *which = kAugmentationSharedSetting; | 268 *which = kAugmentationSharedSetting; |
| 252 } else if (values.user_policy) { | 269 } else if (values.user_policy) { |
| 253 result = values.user_policy; | 270 result = values.user_policy; |
| 254 *which = kAugmentationUserPolicy; | 271 *which = kAugmentationUserPolicy; |
| 255 } else if (values.device_policy) { | 272 } else if (values.device_policy) { |
| 256 result = values.device_policy; | 273 result = values.device_policy; |
| 257 *which = kAugmentationDevicePolicy; | 274 *which = kAugmentationDevicePolicy; |
| 258 } else { | 275 } else { |
| 259 // Can be reached if the current field is recommended, but none of the | 276 // Can be reached if the current field is recommended, but none of the |
| 260 // dictionaries contained a value for it. | 277 // dictionaries contained a value for it. |
| 261 } | 278 } |
| 262 if (result) | 279 if (result) |
| 263 return make_scoped_ptr(result->DeepCopy()); | 280 return make_scoped_ptr(result->DeepCopy()); |
| 264 return scoped_ptr<base::Value>(); | 281 return scoped_ptr<base::Value>(); |
| 265 } | 282 } |
| 266 | 283 |
| 267 // MergeSettingsAndPolicies override. | 284 // MergeSettingsAndPolicies override. |
| 268 virtual scoped_ptr<base::Value> MergeValues( | 285 virtual scoped_ptr<base::Value> MergeValues( |
| 269 ValueParams values) OVERRIDE { | 286 const std::string& key, |
| 287 const ValueParams& values) OVERRIDE { | |
| 270 std::string which; | 288 std::string which; |
| 271 return MergeValues(values, &which); | 289 return MergeValues(key, values, &which); |
| 272 } | 290 } |
| 273 }; | 291 }; |
| 274 | 292 |
| 275 // Call MergeDictionaries to merge policies and settings to an augmented | 293 // Call MergeDictionaries to merge policies and settings to an augmented |
| 276 // dictionary which contains a dictionary for each value in the original | 294 // dictionary which contains a dictionary for each value in the original |
| 277 // dictionaries. See the description of MergeSettingsAndPoliciesToAugmented. | 295 // dictionaries. See the description of MergeSettingsAndPoliciesToAugmented. |
| 278 class MergeToAugmented : public MergeToEffective { | 296 class MergeToAugmented : public MergeToEffective { |
| 297 public: | |
| 298 DictionaryPtr MergeDictionaries( | |
| 299 const OncValueSignature& signature, | |
| 300 const base::DictionaryValue* user_policy, | |
| 301 const base::DictionaryValue* device_policy, | |
| 302 const base::DictionaryValue* user_settings, | |
| 303 const base::DictionaryValue* shared_settings, | |
| 304 const base::DictionaryValue* active_settings) { | |
| 305 signature_ = &signature; | |
| 306 return MergeToEffective::MergeDictionaries(user_policy, | |
| 307 device_policy, | |
| 308 user_settings, | |
| 309 shared_settings, | |
| 310 active_settings); | |
| 311 } | |
| 312 | |
| 279 protected: | 313 protected: |
| 280 // MergeSettingsAndPolicies override. | 314 // MergeSettingsAndPolicies override. |
| 281 virtual scoped_ptr<base::Value> MergeValues( | 315 virtual scoped_ptr<base::Value> MergeValues( |
| 282 ValueParams values) OVERRIDE { | 316 const std::string& key, |
| 317 const ValueParams& values) OVERRIDE { | |
| 283 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue); | 318 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue); |
| 284 std::string which_effective; | 319 if (values.active_setting) { |
| 285 MergeToEffective::MergeValues(values, &which_effective).reset(); | 320 result->SetWithoutPathExpansion(kAugmentationActiveSetting, |
| 286 if (!which_effective.empty()) { | 321 values.active_setting->DeepCopy()); |
| 322 } | |
| 323 | |
| 324 const OncFieldSignature* field = NULL; | |
| 325 if (signature_) | |
| 326 field = GetFieldSignature(*signature_, key); | |
| 327 | |
| 328 if (field) { | |
| 329 // This field is part of the provided ONCSignature, thus it can be | |
| 330 // controlled by policy. | |
| 331 std::string which_effective; | |
| 332 MergeToEffective::MergeValues(key, values, &which_effective).reset(); | |
| 333 if (!which_effective.empty()) { | |
| 334 result->SetStringWithoutPathExpansion(kAugmentationEffectiveSetting, | |
| 335 which_effective); | |
| 336 } | |
| 337 bool is_credential = onc::FieldIsCredential(*signature_, key); | |
| 338 | |
| 339 // Prevent that credentials are forwarded in cleartext to UI. User/shared | |
|
Greg Spencer (Chromium)
2013/04/10 01:14:15
Prevent that credentials are --> Prevent credentia
pneubeck (no reviews)
2013/04/15 12:16:23
Done.
| |
| 340 // credentials are not stored separately, so they cannot leak here. | |
| 341 if (!is_credential) { | |
| 342 if (values.user_policy) { | |
| 343 result->SetWithoutPathExpansion(kAugmentationUserPolicy, | |
| 344 values.user_policy->DeepCopy()); | |
| 345 } | |
| 346 if (values.device_policy) { | |
| 347 result->SetWithoutPathExpansion(kAugmentationDevicePolicy, | |
| 348 values.device_policy->DeepCopy()); | |
| 349 } | |
| 350 } | |
| 351 if (values.user_setting) { | |
| 352 result->SetWithoutPathExpansion(kAugmentationUserSetting, | |
| 353 values.user_setting->DeepCopy()); | |
| 354 } | |
| 355 if (values.shared_setting) { | |
| 356 result->SetWithoutPathExpansion(kAugmentationSharedSetting, | |
| 357 values.shared_setting->DeepCopy()); | |
| 358 } | |
| 359 if (HasUserPolicy() && values.user_editable) { | |
| 360 result->SetBooleanWithoutPathExpansion(kAugmentationUserEditable, | |
| 361 true); | |
| 362 } | |
| 363 if (HasDevicePolicy() && values.device_editable) { | |
| 364 result->SetBooleanWithoutPathExpansion(kAugmentationDeviceEditable, | |
| 365 true); | |
| 366 } | |
| 367 } else { | |
| 368 // This field is not part of the provided ONCSignature, thus it cannot be | |
| 369 // controlled by policy. | |
| 287 result->SetStringWithoutPathExpansion(kAugmentationEffectiveSetting, | 370 result->SetStringWithoutPathExpansion(kAugmentationEffectiveSetting, |
| 288 which_effective); | 371 kAugmentationUnmanaged); |
| 289 } | 372 } |
| 290 if (values.user_policy) { | 373 if (result->empty()) |
| 291 result->SetWithoutPathExpansion(kAugmentationUserPolicy, | 374 result.reset(); |
| 292 values.user_policy->DeepCopy()); | |
| 293 } | |
| 294 if (values.device_policy) { | |
| 295 result->SetWithoutPathExpansion(kAugmentationDevicePolicy, | |
| 296 values.device_policy->DeepCopy()); | |
| 297 } | |
| 298 if (values.user_settings) { | |
| 299 result->SetWithoutPathExpansion(kAugmentationUserSetting, | |
| 300 values.user_settings->DeepCopy()); | |
| 301 } | |
| 302 if (values.shared_settings) { | |
| 303 result->SetWithoutPathExpansion(kAugmentationSharedSetting, | |
| 304 values.shared_settings->DeepCopy()); | |
| 305 } | |
| 306 if (HasUserPolicy() && values.user_editable) { | |
| 307 result->SetBooleanWithoutPathExpansion(kAugmentationUserEditable, | |
| 308 values.user_editable); | |
| 309 } | |
| 310 if (HasDevicePolicy() && values.device_editable) { | |
| 311 result->SetBooleanWithoutPathExpansion(kAugmentationDeviceEditable, | |
| 312 values.device_editable); | |
| 313 } | |
| 314 return result.PassAs<base::Value>(); | 375 return result.PassAs<base::Value>(); |
| 315 } | 376 } |
| 377 | |
| 378 // MergeListOfDictionaries override. | |
| 379 virtual DictionaryPtr MergeNestedDictionaries( | |
| 380 const std::string& key, | |
| 381 const DictPtrs &dicts) OVERRIDE { | |
| 382 DictionaryPtr result; | |
| 383 if (signature_) { | |
| 384 const OncValueSignature* enclosing_signature = signature_; | |
| 385 signature_ = NULL; | |
| 386 | |
| 387 const OncFieldSignature* field = | |
| 388 GetFieldSignature(*enclosing_signature, key); | |
| 389 if (field) | |
| 390 signature_ = field->value_signature; | |
| 391 result = MergeToEffective::MergeNestedDictionaries(key, dicts); | |
| 392 | |
| 393 signature_ = enclosing_signature; | |
| 394 } else { | |
| 395 result = MergeToEffective::MergeNestedDictionaries(key, dicts); | |
| 396 } | |
| 397 return result.Pass(); | |
| 398 } | |
| 399 | |
| 400 private: | |
| 401 const OncValueSignature* signature_; | |
|
Greg Spencer (Chromium)
2013/04/10 01:14:15
DISALLOW_COPY_AND_ASSIGN? And for other classes h
pneubeck (no reviews)
2013/04/15 12:16:23
Done.
| |
| 316 }; | 402 }; |
| 317 | 403 |
| 318 } // namespace | 404 } // namespace |
| 319 | 405 |
| 320 DictionaryPtr MergeSettingsAndPoliciesToEffective( | 406 DictionaryPtr MergeSettingsAndPoliciesToEffective( |
| 321 const base::DictionaryValue* user_policy, | 407 const base::DictionaryValue* user_policy, |
| 322 const base::DictionaryValue* device_policy, | 408 const base::DictionaryValue* device_policy, |
| 323 const base::DictionaryValue* user_settings, | 409 const base::DictionaryValue* user_settings, |
| 324 const base::DictionaryValue* shared_settings) { | 410 const base::DictionaryValue* shared_settings) { |
| 325 MergeToEffective merger; | 411 MergeToEffective merger; |
| 326 return merger.MergeDictionaries( | 412 return merger.MergeDictionaries( |
| 327 user_policy, device_policy, user_settings, shared_settings); | 413 user_policy, device_policy, user_settings, shared_settings, NULL); |
| 328 } | 414 } |
| 329 | 415 |
| 330 DictionaryPtr MergeSettingsAndPoliciesToAugmented( | 416 DictionaryPtr MergeSettingsAndPoliciesToAugmented( |
| 417 const OncValueSignature& signature, | |
| 331 const base::DictionaryValue* user_policy, | 418 const base::DictionaryValue* user_policy, |
| 332 const base::DictionaryValue* device_policy, | 419 const base::DictionaryValue* device_policy, |
| 333 const base::DictionaryValue* user_settings, | 420 const base::DictionaryValue* user_settings, |
| 334 const base::DictionaryValue* shared_settings) { | 421 const base::DictionaryValue* shared_settings, |
| 422 const base::DictionaryValue* active_settings) { | |
| 335 MergeToAugmented merger; | 423 MergeToAugmented merger; |
| 336 return merger.MergeDictionaries( | 424 return merger.MergeDictionaries( |
| 337 user_policy, device_policy, user_settings, shared_settings); | 425 signature, user_policy, device_policy, user_settings, shared_settings, |
| 426 active_settings); | |
| 338 } | 427 } |
| 339 | 428 |
| 340 } // namespace onc | 429 } // namespace onc |
| 341 } // namespace chromeos | 430 } // namespace chromeos |
| OLD | NEW |