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 |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 } | 210 } |
211 | 211 |
212 // Whether a device policy was provided. | 212 // Whether a device policy was provided. |
213 bool HasDevicePolicy() { | 213 bool HasDevicePolicy() { |
214 return hasDevicePolicy_; | 214 return hasDevicePolicy_; |
215 } | 215 } |
216 | 216 |
217 // MergeListOfDictionaries override. | 217 // MergeListOfDictionaries override. |
218 virtual scoped_ptr<base::Value> MergeListOfValues( | 218 virtual scoped_ptr<base::Value> MergeListOfValues( |
219 const std::string& key, | 219 const std::string& key, |
220 const std::vector<const base::Value*>& values) OVERRIDE { | 220 const std::vector<const base::Value*>& values) override { |
221 bool user_editable = !HasUserPolicy(); | 221 bool user_editable = !HasUserPolicy(); |
222 if (values[kUserEditableIndex]) | 222 if (values[kUserEditableIndex]) |
223 values[kUserEditableIndex]->GetAsBoolean(&user_editable); | 223 values[kUserEditableIndex]->GetAsBoolean(&user_editable); |
224 | 224 |
225 bool device_editable = !HasDevicePolicy(); | 225 bool device_editable = !HasDevicePolicy(); |
226 if (values[kDeviceEditableIndex]) | 226 if (values[kDeviceEditableIndex]) |
227 values[kDeviceEditableIndex]->GetAsBoolean(&device_editable); | 227 values[kDeviceEditableIndex]->GetAsBoolean(&device_editable); |
228 | 228 |
229 ValueParams params; | 229 ValueParams params; |
230 params.user_policy = values[kUserPolicyIndex]; | 230 params.user_policy = values[kUserPolicyIndex]; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 // dictionaries contained a value for it. | 298 // dictionaries contained a value for it. |
299 } | 299 } |
300 if (result) | 300 if (result) |
301 return make_scoped_ptr(result->DeepCopy()); | 301 return make_scoped_ptr(result->DeepCopy()); |
302 return scoped_ptr<base::Value>(); | 302 return scoped_ptr<base::Value>(); |
303 } | 303 } |
304 | 304 |
305 // MergeSettingsAndPolicies override. | 305 // MergeSettingsAndPolicies override. |
306 virtual scoped_ptr<base::Value> MergeValues( | 306 virtual scoped_ptr<base::Value> MergeValues( |
307 const std::string& key, | 307 const std::string& key, |
308 const ValueParams& values) OVERRIDE { | 308 const ValueParams& values) override { |
309 std::string which; | 309 std::string which; |
310 return MergeValues(key, values, &which); | 310 return MergeValues(key, values, &which); |
311 } | 311 } |
312 | 312 |
313 private: | 313 private: |
314 DISALLOW_COPY_AND_ASSIGN(MergeToEffective); | 314 DISALLOW_COPY_AND_ASSIGN(MergeToEffective); |
315 }; | 315 }; |
316 | 316 |
317 namespace { | 317 namespace { |
318 | 318 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 device_policy, | 353 device_policy, |
354 user_settings, | 354 user_settings, |
355 shared_settings, | 355 shared_settings, |
356 active_settings); | 356 active_settings); |
357 } | 357 } |
358 | 358 |
359 protected: | 359 protected: |
360 // MergeSettingsAndPolicies override. | 360 // MergeSettingsAndPolicies override. |
361 virtual scoped_ptr<base::Value> MergeValues( | 361 virtual scoped_ptr<base::Value> MergeValues( |
362 const std::string& key, | 362 const std::string& key, |
363 const ValueParams& values) OVERRIDE { | 363 const ValueParams& values) override { |
364 const OncFieldSignature* field = NULL; | 364 const OncFieldSignature* field = NULL; |
365 if (signature_) | 365 if (signature_) |
366 field = GetFieldSignature(*signature_, key); | 366 field = GetFieldSignature(*signature_, key); |
367 | 367 |
368 if (!field) { | 368 if (!field) { |
369 // This field is not part of the provided ONCSignature, thus it cannot be | 369 // This field is not part of the provided ONCSignature, thus it cannot be |
370 // controlled by policy. Return the plain active value instead of an | 370 // controlled by policy. Return the plain active value instead of an |
371 // augmented dictionary. | 371 // augmented dictionary. |
372 return make_scoped_ptr(values.active_setting->DeepCopy()); | 372 return make_scoped_ptr(values.active_setting->DeepCopy()); |
373 } | 373 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 ::onc::kAugmentationDeviceEditable, true); | 438 ::onc::kAugmentationDeviceEditable, true); |
439 } | 439 } |
440 if (augmented_value->empty()) | 440 if (augmented_value->empty()) |
441 augmented_value.reset(); | 441 augmented_value.reset(); |
442 return augmented_value.PassAs<base::Value>(); | 442 return augmented_value.PassAs<base::Value>(); |
443 } | 443 } |
444 | 444 |
445 // MergeListOfDictionaries override. | 445 // MergeListOfDictionaries override. |
446 virtual DictionaryPtr MergeNestedDictionaries( | 446 virtual DictionaryPtr MergeNestedDictionaries( |
447 const std::string& key, | 447 const std::string& key, |
448 const DictPtrs &dicts) OVERRIDE { | 448 const DictPtrs &dicts) override { |
449 DictionaryPtr result; | 449 DictionaryPtr result; |
450 if (signature_) { | 450 if (signature_) { |
451 const OncValueSignature* enclosing_signature = signature_; | 451 const OncValueSignature* enclosing_signature = signature_; |
452 signature_ = NULL; | 452 signature_ = NULL; |
453 | 453 |
454 const OncFieldSignature* field = | 454 const OncFieldSignature* field = |
455 GetFieldSignature(*enclosing_signature, key); | 455 GetFieldSignature(*enclosing_signature, key); |
456 if (field) | 456 if (field) |
457 signature_ = field->value_signature; | 457 signature_ = field->value_signature; |
458 result = MergeToEffective::MergeNestedDictionaries(key, dicts); | 458 result = MergeToEffective::MergeNestedDictionaries(key, dicts); |
(...skipping 30 matching lines...) Expand all Loading... |
489 const base::DictionaryValue* shared_settings, | 489 const base::DictionaryValue* shared_settings, |
490 const base::DictionaryValue* active_settings) { | 490 const base::DictionaryValue* active_settings) { |
491 MergeToAugmented merger; | 491 MergeToAugmented merger; |
492 return merger.MergeDictionaries( | 492 return merger.MergeDictionaries( |
493 signature, user_policy, device_policy, user_settings, shared_settings, | 493 signature, user_policy, device_policy, user_settings, shared_settings, |
494 active_settings); | 494 active_settings); |
495 } | 495 } |
496 | 496 |
497 } // namespace onc | 497 } // namespace onc |
498 } // namespace chromeos | 498 } // namespace chromeos |
OLD | NEW |