diff options
author | stevenjb <stevenjb@chromium.org> | 2015-08-12 18:39:04 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-13 01:39:36 +0000 |
commit | e4695f45330a7f79ef5ea3309c3ea784f6c5f83a (patch) | |
tree | caaa5d5bc180fe2073494be77bb00031eab92dce | |
parent | 4f336a6bca18d7a71660d79e7a56d018d74dabaf (diff) | |
download | chromium_src-e4695f45330a7f79ef5ea3309c3ea784f6c5f83a.zip chromium_src-e4695f45330a7f79ef5ea3309c3ea784f6c5f83a.tar.gz chromium_src-e4695f45330a7f79ef5ea3309c3ea784f6c5f83a.tar.bz2 |
Make Type an unmanaged ONC property
This will simplify some of the new Settings UI, allowing us
to read onc.Type directly without parsing a managed dictionary.
BUG=none
Review URL: https://codereview.chromium.org/1284963002
Cr-Commit-Position: refs/heads/master@{#343146}
7 files changed, 30 insertions, 37 deletions
diff --git a/chrome/test/data/extensions/api_test/networking_private/chromeos/test.js b/chrome/test/data/extensions/api_test/networking_private/chromeos/test.js index 5127715..5e1205e 100644 --- a/chrome/test/data/extensions/api_test/networking_private/chromeos/test.js +++ b/chrome/test/data/extensions/api_test/networking_private/chromeos/test.js @@ -498,11 +498,7 @@ var availableTests = [ UserPolicy: 'My WiFi Network' }, Source: 'UserPolicy', - Type: { - Active: NetworkType.WI_FI, - Effective: 'UserPolicy', - UserPolicy: NetworkType.WI_FI - }, + Type: NetworkType.WI_FI, WiFi: { AutoConnect: { Active: false, diff --git a/chrome/test/data/extensions/api_test/networking_private/service_client/test.js b/chrome/test/data/extensions/api_test/networking_private/service_client/test.js index a434607..1ac0b8c 100644 --- a/chrome/test/data/extensions/api_test/networking_private/service_client/test.js +++ b/chrome/test/data/extensions/api_test/networking_private/service_client/test.js @@ -271,11 +271,7 @@ var availableTests = [ "UserPolicy": "My WiFi Network" }, "Source": "UserPolicy", - "Type": { - "Active": "WiFi", - "Effective": "UserPolicy", - "UserPolicy": "WiFi" - }, + "Type": "WiFi", "WiFi": { "AutoConnect": { "Active": false, diff --git a/chromeos/network/onc/onc_merger.cc b/chromeos/network/onc/onc_merger.cc index 931c3f0..2237b3a 100644 --- a/chromeos/network/onc/onc_merger.cc +++ b/chromeos/network/onc/onc_merger.cc @@ -21,8 +21,7 @@ namespace { typedef scoped_ptr<base::DictionaryValue> DictionaryPtr; // Returns true if the field is the identifier of a configuration, i.e. the GUID -// of a network or a certificate. These can be special handled during merging -// because they are always identical for the various setting sources. +// of a network or a certificate. bool IsIdentifierField(const OncValueSignature& value_signature, const std::string& field_name) { if (&value_signature == &kNetworkConfigurationSignature) @@ -32,6 +31,18 @@ bool IsIdentifierField(const OncValueSignature& value_signature, return false; } +// Identifier fields and other read-only fields (specifically Type) are +// handled specially during merging because they are always identical for the +// various setting sources. +bool IsReadOnlyField(const OncValueSignature& value_signature, + const std::string& field_name) { + if (IsIdentifierField(value_signature, field_name)) + return true; + if (&value_signature == &kNetworkConfigurationSignature) + return field_name == ::onc::network_config::kType; + return false; +} + // Inserts |true| at every field name in |result| that is recommended in // |policy|. void MarkRecommendedFieldnames(const base::DictionaryValue& policy, @@ -378,19 +389,21 @@ class MergeToAugmented : public MergeToEffective { scoped_ptr<base::Value> effective_value = MergeToEffective::MergeValues(key, values, &which_effective); - if (IsIdentifierField(*signature_, key)) { - // Don't augment the GUID but write the plain value. + if (IsReadOnlyField(*signature_, key)) { + // Don't augment read-only fields (GUID and Type). if (effective_value) { - // DCHECK that all provided GUIDs are identical. - DCHECK(AllPresentValuesEqual(values, *effective_value)); - // Return the un-augmented GUID. + // DCHECK that all provided fields are identical. + DCHECK(AllPresentValuesEqual(values, *effective_value)) + << "Values do not match: " << key + << " Effective: " << *effective_value; + // Return the un-augmented field. return effective_value.Pass(); } if (values.active_setting) { - // Unmanaged networks have assigned (active) GUID values. + // Unmanaged networks have assigned (active) values. return make_scoped_ptr(values.active_setting->DeepCopy()); } - LOG(ERROR) << "GUID field has no effective value"; + LOG(ERROR) << "Field has no effective value: " << key; return nullptr; } diff --git a/chromeos/network/policy_util.cc b/chromeos/network/policy_util.cc index 8ac4856..7c2d0de 100644 --- a/chromeos/network/policy_util.cc +++ b/chromeos/network/policy_util.cc @@ -178,14 +178,10 @@ base::DictionaryValue* GetOrCreateNestedDictionary( void ApplyGlobalAutoconnectPolicy( NetworkProfile::Type profile_type, base::DictionaryValue* augmented_onc_network) { - base::DictionaryValue* type_dictionary = NULL; - augmented_onc_network->GetDictionaryWithoutPathExpansion( - ::onc::network_config::kType, &type_dictionary); std::string type; - if (!type_dictionary || - !type_dictionary->GetStringWithoutPathExpansion( - ::onc::kAugmentationActiveSetting, &type) || - type.empty()) { + augmented_onc_network->GetStringWithoutPathExpansion( + ::onc::network_config::kType, &type); + if (type.empty()) { LOG(ERROR) << "ONC dictionary with no Type."; return; } diff --git a/chromeos/test/data/network/augmented_merge.json b/chromeos/test/data/network/augmented_merge.json index f06cc2f..500813d 100644 --- a/chromeos/test/data/network/augmented_merge.json +++ b/chromeos/test/data/network/augmented_merge.json @@ -55,13 +55,7 @@ "UserSetting": "Direct" } }, - "Type": { - "Active": "VPN", - "DevicePolicy": "VPN", - "Effective": "UserPolicy", - "UserPolicy": "VPN", - "UserSetting": "Ethernet" - }, + "Type": "VPN", "VPN": { "Host": { "DeviceEditable": true, diff --git a/chromeos/test/data/network/policy/managed_onc_disallow_autoconnect_on_unmanaged_wifi2.onc b/chromeos/test/data/network/policy/managed_onc_disallow_autoconnect_on_unmanaged_wifi2.onc index a3c79ce..8205bd5 100644 --- a/chromeos/test/data/network/policy/managed_onc_disallow_autoconnect_on_unmanaged_wifi2.onc +++ b/chromeos/test/data/network/policy/managed_onc_disallow_autoconnect_on_unmanaged_wifi2.onc @@ -3,9 +3,7 @@ "Active": "wifi2" }, "Source": "User", - "Type": { - "Active": "WiFi" - }, + "Type": "WiFi", "WiFi": { "AutoConnect": { "Active": false, diff --git a/chromeos/test/data/network/user.onc b/chromeos/test/data/network/user.onc index b277e11..4e6835e 100644 --- a/chromeos/test/data/network/user.onc +++ b/chromeos/test/data/network/user.onc @@ -1,4 +1,4 @@ -{ "Type": "Ethernet", +{ "Type": "VPN", "Name": "testopenvpn", "VPN": { "Host": "users host", |