summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Bennetts <stevenjb@chromium.org>2014-09-11 13:50:25 -0700
committerSteven Bennetts <stevenjb@chromium.org>2014-09-11 20:56:15 +0000
commitb4dd54b73384e5ca0af94aefcef95e4521c338ea (patch)
treefbe22869ad30317d49cbe26965c185467d1af69e
parent93c37f1b01ef982bce30d4404562f05c7b1d439e (diff)
downloadchromium_src-b4dd54b73384e5ca0af94aefcef95e4521c338ea.zip
chromium_src-b4dd54b73384e5ca0af94aefcef95e4521c338ea.tar.gz
chromium_src-b4dd54b73384e5ca0af94aefcef95e4521c338ea.tar.bz2
Add ONC 'Source' configuration property
This also includes a bit of JS cleanup to use ONC properties directly where possible. BUG=279351 R=pneubeck@chromium.org Review URL: https://codereview.chromium.org/552113002 Cr-Commit-Position: refs/heads/master@{#294462}
-rw-r--r--chrome/browser/resources/options/chromeos/internet_detail.js47
-rw-r--r--chrome/browser/resources/options/chromeos/onc_data.js23
-rw-r--r--chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc6
-rw-r--r--chrome/test/data/extensions/api_test/networking/test.js1
-rw-r--r--chromeos/network/managed_network_configuration_handler_impl.cc19
-rw-r--r--chromeos/network/managed_network_configuration_handler_impl.h1
-rw-r--r--chromeos/network/network_util.cc5
-rw-r--r--chromeos/network/onc/onc_signature.cc1
-rw-r--r--chromeos/network/onc/onc_translation_tables.cc1
-rw-r--r--chromeos/network/onc/onc_translator.h6
-rw-r--r--chromeos/network/onc/onc_translator_shill_to_onc.cc34
-rw-r--r--chromeos/network/onc/onc_translator_unittest.cc2
-rw-r--r--chromeos/network/onc/onc_utils.cc6
-rw-r--r--chromeos/network/policy_applicator.cc1
-rw-r--r--chromeos/test/data/network/policy/managed_onc_disallow_autoconnect_on_unmanaged_wifi2.onc1
-rw-r--r--chromeos/test/data/network/shill_cellular_with_state.json3
-rw-r--r--chromeos/test/data/network/shill_wifi_with_state.json1
-rw-r--r--chromeos/test/data/network/translation_of_shill_cellular_with_state.onc3
-rw-r--r--chromeos/test/data/network/translation_of_shill_wifi_with_state.onc1
-rw-r--r--components/onc/docs/onc_spec.html30
-rw-r--r--components/onc/onc_constants.cc20
-rw-r--r--components/onc/onc_constants.h7
22 files changed, 161 insertions, 58 deletions
diff --git a/chrome/browser/resources/options/chromeos/internet_detail.js b/chrome/browser/resources/options/chromeos/internet_detail.js
index 979777d..387d57e 100644
--- a/chrome/browser/resources/options/chromeos/internet_detail.js
+++ b/chrome/browser/resources/options/chromeos/internet_detail.js
@@ -379,14 +379,18 @@ cr.define('options.internet', function() {
* Update details page controls.
*/
updateControls: function() {
+ var onc = this.onc_;
+ if (onc == undefined)
+ return; // May get called from a pref update before initialized.
+
// Only show ipconfig section if network is connected OR if nothing on
// this device is connected. This is so that you can fix the ip configs
// if you can't connect to any network.
// TODO(chocobo): Once ipconfig is moved to flimflam service objects,
// we need to redo this logic to allow configuration of all networks.
- $('ipconfig-section').hidden = !this.connected && this.deviceConnected;
- $('ipconfig-dns-section').hidden =
- !this.connected && this.deviceConnected;
+ var connected = onc.getActiveValue('ConnectionState') == 'Connected';
+ $('ipconfig-section').hidden = !connected && this.deviceConnected;
+ $('ipconfig-dns-section').hidden = !connected && this.deviceConnected;
// Network type related.
updateHidden('#details-internet-page .cellular-details',
@@ -414,16 +418,15 @@ cr.define('options.internet', function() {
this.type_ == 'VPN');
// Password and shared.
+ var source = onc.getSource();
+ var shared = (source == 'Device' || source == 'DevicePolicy');
updateHidden('#details-internet-page #password-details',
- this.type_ != 'WiFi' || !this.hasSecurity);
- updateHidden('#details-internet-page #wifi-shared-network',
- !this.shared);
- updateHidden('#details-internet-page #prefer-network',
- !this.showPreferred);
+ this.type_ != 'WiFi' || onc.getWiFiSecurity() == 'None');
+ updateHidden('#details-internet-page #wifi-shared-network', !shared);
+ updateHidden('#details-internet-page #prefer-network', source == 'None');
// WiMAX.
- updateHidden('#details-internet-page #wimax-shared-network',
- !this.shared);
+ updateHidden('#details-internet-page #wimax-shared-network', !shared);
// Proxy
this.updateProxyBannerVisibility_();
@@ -578,7 +581,7 @@ cr.define('options.internet', function() {
var connectable = onc.getActiveValue('Connectable');
if (connectState != 'Connected' &&
- (!connectable || this.hasSecurity ||
+ (!connectable || onc.getWiFiSecurity() != 'None' ||
(this.type_ == 'Wimax' || this.type_ == 'VPN'))) {
$('details-internet-configure').hidden = false;
} else {
@@ -592,7 +595,6 @@ cr.define('options.internet', function() {
$('network-details-title').textContent = onc.getTranslatedValue('Name');
var connectionState = onc.getActiveValue('ConnectionState');
var connectionStateString = onc.getTranslatedValue('ConnectionState');
- this.connected = connectionState == 'Connected';
$('network-details-subtitle-status').textContent = connectionStateString;
var typeKey;
var type = this.type_;
@@ -1024,7 +1026,6 @@ cr.define('options.internet', function() {
var connectionStateString = onc.getTranslatedValue('ConnectionState');
if ('deviceConnected' in update)
detailsPage.deviceConnected = update.deviceConnected;
- detailsPage.connected = connectionState == 'Connected';
$('connection-state').textContent = connectionStateString;
detailsPage.updateConnectionButtonVisibilty_();
@@ -1071,11 +1072,10 @@ cr.define('options.internet', function() {
$('web-proxy-auto-discovery').hidden = true;
detailsPage.deviceConnected = data.deviceConnected;
- detailsPage.connected =
- onc.getActiveValue('ConnectionState') == 'Connected';
// Only show proxy for remembered networks.
- if (data.remembered) {
+ var remembered = onc.getSource() != 'None';
+ if (remembered) {
detailsPage.showProxy = true;
chrome.send('selectNetwork', [detailsPage.servicePath_]);
} else {
@@ -1231,7 +1231,7 @@ cr.define('options.internet', function() {
}
var setOrHideParent = function(field, property) {
- if (property) {
+ if (property != undefined) {
$(field).textContent = property;
$(field).parentElement.hidden = false;
} else {
@@ -1253,13 +1253,12 @@ cr.define('options.internet', function() {
if (type == 'WiFi') {
OptionsPage.showTab($('wifi-network-nav-tab'));
detailsPage.gsm = false;
- detailsPage.shared = data.shared;
$('wifi-connection-state').textContent = connectionStateString;
$('wifi-restricted-connectivity').textContent = restrictedString;
var ssid = onc.getActiveValue('WiFi.SSID');
$('wifi-ssid').textContent = ssid ? ssid : networkName;
setOrHideParent('wifi-bssid', onc.getActiveValue('WiFi.BSSID'));
- var security = onc.getActiveValue('WiFi.Security');
+ var security = onc.getWiFiSecurity();
if (security == 'None')
security = undefined;
setOrHideParent('wifi-security', security);
@@ -1273,24 +1272,20 @@ cr.define('options.internet', function() {
$('wifi-signal-strength').textContent = strengthString;
setOrHideParent('wifi-hardware-address',
onc.getActiveValue('MacAddress'));
- detailsPage.showPreferred = data.remembered;
var priority = onc.getActiveValue('Priority');
$('prefer-network-wifi').checked = priority > 0;
- $('prefer-network-wifi').disabled = !data.remembered;
+ $('prefer-network-wifi').disabled = !remembered;
$('auto-connect-network-wifi').checked =
onc.getActiveValue('AutoConnect');
- $('auto-connect-network-wifi').disabled = !data.remembered;
- detailsPage.hasSecurity = security != undefined;
+ $('auto-connect-network-wifi').disabled = !remembered;
} else if (type == 'Wimax') {
OptionsPage.showTab($('wimax-network-nav-tab'));
detailsPage.gsm = false;
- detailsPage.shared = data.shared;
- detailsPage.showPreferred = data.remembered;
$('wimax-connection-state').textContent = connectionStateString;
$('wimax-restricted-connectivity').textContent = restrictedString;
$('auto-connect-network-wimax').checked =
onc.getActiveValue('AutoConnect');
- $('auto-connect-network-wimax').disabled = !data.remembered;
+ $('auto-connect-network-wimax').disabled = !remembered;
var identity = onc.getActiveValue('Wimax.EAP.Identity');
setOrHideParent('wimax-eap-identity', identity);
$('wimax-signal-strength').textContent = strengthString;
diff --git a/chrome/browser/resources/options/chromeos/onc_data.js b/chrome/browser/resources/options/chromeos/onc_data.js
index dd1f062..61e1622 100644
--- a/chrome/browser/resources/options/chromeos/onc_data.js
+++ b/chrome/browser/resources/options/chromeos/onc_data.js
@@ -133,6 +133,29 @@ cr.define('cr.onc', function() {
},
/**
+ * Returns the Source of this configuration. If undefined returns 'None'.
+ * @return {string} The configuration source: 'None', 'User', 'Device',
+ * 'UserPolicy', or 'DevicePolicy'.
+ */
+ getSource: function() {
+ var source = this.getActiveValue('Source');
+ if (source == undefined)
+ return 'None';
+ return source;
+ },
+
+ /**
+ * Returns the WiFi security type (defaults to 'None').
+ * @return {string} The security type.
+ */
+ getWiFiSecurity: function() {
+ var security = this.getActiveValue('WiFi.Security');
+ if (security == undefined)
+ return 'None';
+ return security;
+ },
+
+ /**
* Updates the properties of |data_| from the properties in |update|.
* Note: this only looks at top level entries, so if a dictionary is
* updated the entire dictionary is written over. TODO(stevenjb):
diff --git a/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc
index b1c3b56..abfb487 100644
--- a/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc
+++ b/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc
@@ -123,11 +123,9 @@ const char kTagDisconnect[] = "disconnect";
const char kTagErrorMessage[] = "errorMessage";
const char kTagForget[] = "forget";
const char kTagOptions[] = "options";
-const char kTagRemembered[] = "remembered";
const char kTagRememberedList[] = "rememberedList";
const char kTagCarriers[] = "carriers";
const char kTagCurrentCarrierIndex[] = "currentCarrierIndex";
-const char kTagShared[] = "shared";
const char kTagShowActivateButton[] = "showActivateButton";
const char kTagShowViewAccountButton[] = "showViewAccountButton";
const char kTagTrue[] = "true";
@@ -313,10 +311,6 @@ scoped_ptr<base::DictionaryValue> PopulateConnectionDetails(
kTagErrorMessage,
ash::network_connect::ErrorString(network->error(), network->path()));
- dictionary->SetBoolean(kTagRemembered, !network->profile_path().empty());
- bool shared = !network->IsPrivate();
- dictionary->SetBoolean(kTagShared, shared);
-
const std::string& type = network->type();
const NetworkState* connected_network =
diff --git a/chrome/test/data/extensions/api_test/networking/test.js b/chrome/test/data/extensions/api_test/networking/test.js
index 2c3e904..0c40497 100644
--- a/chrome/test/data/extensions/api_test/networking/test.js
+++ b/chrome/test/data/extensions/api_test/networking/test.js
@@ -324,6 +324,7 @@ var availableTests = [
"Effective": "UserPolicy",
"UserPolicy": "My WiFi Network"
},
+ "Source": "UserPolicy",
"Type": {
"Active": "WiFi",
"Effective": "UserPolicy",
diff --git a/chromeos/network/managed_network_configuration_handler_impl.cc b/chromeos/network/managed_network_configuration_handler_impl.cc
index a2a58ca..44f3da7 100644
--- a/chromeos/network/managed_network_configuration_handler_impl.cc
+++ b/chromeos/network/managed_network_configuration_handler_impl.cc
@@ -127,12 +127,14 @@ void ManagedNetworkConfigurationHandlerImpl::GetManagedProperties(
base::Bind(
&ManagedNetworkConfigurationHandlerImpl::SendManagedProperties,
weak_ptr_factory_.GetWeakPtr(),
+ userhash,
callback,
error_callback)),
error_callback);
}
void ManagedNetworkConfigurationHandlerImpl::SendManagedProperties(
+ const std::string& userhash,
const network_handler::DictionaryResultCallback& callback,
const network_handler::ErrorCallback& error_callback,
const std::string& service_path,
@@ -159,14 +161,14 @@ void ManagedNetworkConfigurationHandlerImpl::SendManagedProperties(
// properties _might_ be user configured.
}
+ std::string guid;
+ shill_properties->GetStringWithoutPathExpansion(shill::kGuidProperty, &guid);
+
+ ::onc::ONCSource onc_source;
+ FindPolicyByGUID(userhash, guid, &onc_source);
scoped_ptr<base::DictionaryValue> active_settings(
onc::TranslateShillServiceToONCPart(
- *shill_properties,
- &onc::kNetworkWithStateSignature));
-
- std::string guid;
- active_settings->GetStringWithoutPathExpansion(::onc::network_config::kGUID,
- &guid);
+ *shill_properties, onc_source, &onc::kNetworkWithStateSignature));
const base::DictionaryValue* network_policy = NULL;
const base::DictionaryValue* global_policy = NULL;
@@ -215,8 +217,9 @@ void ManagedNetworkConfigurationHandlerImpl::SendProperties(
const std::string& service_path,
scoped_ptr<base::DictionaryValue> shill_properties) {
scoped_ptr<base::DictionaryValue> onc_network(
- onc::TranslateShillServiceToONCPart(*shill_properties,
- &onc::kNetworkWithStateSignature));
+ onc::TranslateShillServiceToONCPart(
+ *shill_properties, ::onc::ONC_SOURCE_UNKNOWN,
+ &onc::kNetworkWithStateSignature));
callback.Run(service_path, *onc_network);
}
diff --git a/chromeos/network/managed_network_configuration_handler_impl.h b/chromeos/network/managed_network_configuration_handler_impl.h
index e22dcc8..9cccc4d 100644
--- a/chromeos/network/managed_network_configuration_handler_impl.h
+++ b/chromeos/network/managed_network_configuration_handler_impl.h
@@ -123,6 +123,7 @@ class CHROMEOS_EXPORT ManagedNetworkConfigurationHandlerImpl
// Sends the response to the caller of GetManagedProperties.
void SendManagedProperties(
+ const std::string& userhash,
const network_handler::DictionaryResultCallback& callback,
const network_handler::ErrorCallback& error_callback,
const std::string& service_path,
diff --git a/chromeos/network/network_util.cc b/chromeos/network/network_util.cc
index c090444..7f0aaf8 100644
--- a/chromeos/network/network_util.cc
+++ b/chromeos/network/network_util.cc
@@ -147,8 +147,9 @@ scoped_ptr<base::DictionaryValue> TranslateNetworkStateToONC(
network->GetStateProperties(&shill_dictionary);
scoped_ptr<base::DictionaryValue> onc_dictionary =
- TranslateShillServiceToONCPart(
- shill_dictionary, &onc::kNetworkWithStateSignature);
+ TranslateShillServiceToONCPart(shill_dictionary,
+ ::onc::ONC_SOURCE_UNKNOWN,
+ &onc::kNetworkWithStateSignature);
return onc_dictionary.Pass();
}
diff --git a/chromeos/network/onc/onc_signature.cc b/chromeos/network/onc/onc_signature.cc
index 0d82a7b..306fc93 100644
--- a/chromeos/network/onc/onc_signature.cc
+++ b/chromeos/network/onc/onc_signature.cc
@@ -316,6 +316,7 @@ const OncFieldSignature network_with_state_fields[] = {
{ ::onc::network_config::kMacAddress, &kStringSignature},
{ ::onc::network_config::kRestrictedConnectivity, &kBoolSignature},
{ ::onc::network_config::kSavedIPConfig, &kSavedIPConfigSignature},
+ { ::onc::network_config::kSource, &kStringSignature},
{ ::onc::network_config::kWiFi, &kWiFiWithStateSignature},
{NULL}};
diff --git a/chromeos/network/onc/onc_translation_tables.cc b/chromeos/network/onc/onc_translation_tables.cc
index c3cb594..d38f187 100644
--- a/chromeos/network/onc/onc_translation_tables.cc
+++ b/chromeos/network/onc/onc_translation_tables.cc
@@ -178,6 +178,7 @@ const FieldTranslationEntry network_fields[] = {
// { ::onc::network_config::kConnectionState, shill::kStateProperty },
// { ::onc::network_config::kRestrictedConnectivity,
// shill::kStateProperty },
+ // { ::onc::network_config::kSource, shill::kProfileProperty },
// { ::onc::network_config::kMacAddress, shill::kAddressProperty },
{NULL}};
diff --git a/chromeos/network/onc/onc_translator.h b/chromeos/network/onc/onc_translator.h
index 270247c..dc5afa3 100644
--- a/chromeos/network/onc/onc_translator.h
+++ b/chromeos/network/onc/onc_translator.h
@@ -7,6 +7,7 @@
#include "base/memory/scoped_ptr.h"
#include "chromeos/chromeos_export.h"
+#include "components/onc/onc_constants.h"
namespace base {
class DictionaryValue;
@@ -36,10 +37,13 @@ scoped_ptr<base::DictionaryValue> TranslateONCObjectToShill(
// This function is used to translate network settings coming from Shill to ONC
// before sending them to the UI. The result doesn't have to be valid ONC, but
// only a subset of it and includes only the values that are actually required
-// by the UI.
+// by the UI. If |onc_source| != ONC_SOURCE_UNKNOWN then the 'Source' property
+// of the ONC dictionary will be set accordingly. Note: ONC_SOURCE_USER_IMPORT
+// is treated the same as ONC_SOURCE_NONE.
CHROMEOS_EXPORT
scoped_ptr<base::DictionaryValue> TranslateShillServiceToONCPart(
const base::DictionaryValue& shill_dictionary,
+ ::onc::ONCSource onc_source,
const OncValueSignature* onc_signature);
} // namespace onc
diff --git a/chromeos/network/onc/onc_translator_shill_to_onc.cc b/chromeos/network/onc/onc_translator_shill_to_onc.cc
index 900ec21..d7bc265 100644
--- a/chromeos/network/onc/onc_translator_shill_to_onc.cc
+++ b/chromeos/network/onc/onc_translator_shill_to_onc.cc
@@ -12,6 +12,7 @@
#include "base/logging.h"
#include "base/strings/string_util.h"
#include "base/values.h"
+#include "chromeos/network/network_profile_handler.h"
#include "chromeos/network/network_state.h"
#include "chromeos/network/network_util.h"
#include "chromeos/network/onc/onc_signature.h"
@@ -50,16 +51,20 @@ scoped_ptr<base::Value> ConvertStringToValue(const std::string& str,
class ShillToONCTranslator {
public:
ShillToONCTranslator(const base::DictionaryValue& shill_dictionary,
+ ::onc::ONCSource onc_source,
const OncValueSignature& onc_signature)
: shill_dictionary_(&shill_dictionary),
+ onc_source_(onc_source),
onc_signature_(&onc_signature) {
field_translation_table_ = GetFieldTranslationTable(onc_signature);
}
ShillToONCTranslator(const base::DictionaryValue& shill_dictionary,
+ ::onc::ONCSource onc_source,
const OncValueSignature& onc_signature,
const FieldTranslationEntry* field_translation_table)
: shill_dictionary_(&shill_dictionary),
+ onc_source_(onc_source),
onc_signature_(&onc_signature),
field_translation_table_(field_translation_table) {
}
@@ -132,6 +137,7 @@ class ShillToONCTranslator {
std::string GetName();
const base::DictionaryValue* shill_dictionary_;
+ ::onc::ONCSource onc_source_;
const OncValueSignature* onc_signature_;
const FieldTranslationEntry* field_translation_table_;
scoped_ptr<base::DictionaryValue> onc_object_;
@@ -342,6 +348,7 @@ void ShillToONCTranslator::TranslateCellularWithState() {
return;
}
ShillToONCTranslator nested_translator(*device_dictionary,
+ onc_source_,
kCellularWithStateSignature,
kCellularDeviceTable);
scoped_ptr<base::DictionaryValue> nested_object =
@@ -415,6 +422,25 @@ void ShillToONCTranslator::TranslateNetworkWithState() {
}
}
+ std::string profile_path;
+ if (onc_source_ != ::onc::ONC_SOURCE_UNKNOWN &&
+ shill_dictionary_->GetStringWithoutPathExpansion(shill::kProfileProperty,
+ &profile_path)) {
+ std::string source;
+ if (onc_source_ == ::onc::ONC_SOURCE_DEVICE_POLICY)
+ source = ::onc::network_config::kSourceDevicePolicy;
+ else if (onc_source_ == ::onc::ONC_SOURCE_USER_POLICY)
+ source = ::onc::network_config::kSourceUserPolicy;
+ else if (profile_path == NetworkProfileHandler::GetSharedProfilePath())
+ source = ::onc::network_config::kSourceDevice;
+ else if (!profile_path.empty())
+ source = ::onc::network_config::kSourceUser;
+ else
+ source = ::onc::network_config::kSourceNone;
+ onc_object_->SetStringWithoutPathExpansion(
+ ::onc::network_config::kSource, source);
+ }
+
// Use a human-readable aa:bb format for any hardware MAC address. Note:
// this property is provided by the caller but is not part of the Shill
// Service properties (it is copied from the Device properties).
@@ -507,8 +533,8 @@ void ShillToONCTranslator::TranslateAndAddNestedObject(
NOTREACHED() << "Unable to find signature for field: " << onc_field_name;
return;
}
- ShillToONCTranslator nested_translator(dictionary,
- *field_signature->value_signature);
+ ShillToONCTranslator nested_translator(
+ dictionary, onc_source_, *field_signature->value_signature);
scoped_ptr<base::DictionaryValue> nested_object =
nested_translator.CreateTranslatedONCObject();
if (nested_object->empty())
@@ -549,6 +575,7 @@ void ShillToONCTranslator::TranslateAndAddListOfObjects(
continue;
ShillToONCTranslator nested_translator(
*shill_value,
+ onc_source_,
*field_signature->value_signature->onc_array_entry_signature);
scoped_ptr<base::DictionaryValue> nested_object =
nested_translator.CreateTranslatedONCObject();
@@ -636,10 +663,11 @@ std::string ShillToONCTranslator::GetName() {
scoped_ptr<base::DictionaryValue> TranslateShillServiceToONCPart(
const base::DictionaryValue& shill_dictionary,
+ ::onc::ONCSource onc_source,
const OncValueSignature* onc_signature) {
CHECK(onc_signature != NULL);
- ShillToONCTranslator translator(shill_dictionary, *onc_signature);
+ ShillToONCTranslator translator(shill_dictionary, onc_source, *onc_signature);
return translator.CreateTranslatedONCObject();
}
diff --git a/chromeos/network/onc/onc_translator_unittest.cc b/chromeos/network/onc/onc_translator_unittest.cc
index bce14cb..aa287eb 100644
--- a/chromeos/network/onc/onc_translator_unittest.cc
+++ b/chromeos/network/onc/onc_translator_unittest.cc
@@ -78,7 +78,7 @@ TEST_P(ONCTranslatorShillToOncTest, Translate) {
test_utils::ReadTestDictionary(result_onc_filename));
scoped_ptr<base::DictionaryValue> translation(TranslateShillServiceToONCPart(
- *shill_network, &kNetworkWithStateSignature));
+ *shill_network, ::onc::ONC_SOURCE_NONE, &kNetworkWithStateSignature));
EXPECT_TRUE(test_utils::Equals(expected_onc_network.get(),
translation.get()));
diff --git a/chromeos/network/onc/onc_utils.cc b/chromeos/network/onc/onc_utils.cc
index 73b5deb..9eb4e50 100644
--- a/chromeos/network/onc/onc_utils.cc
+++ b/chromeos/network/onc/onc_utils.cc
@@ -160,12 +160,14 @@ scoped_ptr<base::DictionaryValue> Decrypt(const std::string& passphrase,
std::string GetSourceAsString(ONCSource source) {
switch (source) {
+ case ONC_SOURCE_UNKNOWN:
+ return "unknown";
+ case ONC_SOURCE_NONE:
+ return "none";
case ONC_SOURCE_DEVICE_POLICY:
return "device policy";
case ONC_SOURCE_USER_POLICY:
return "user policy";
- case ONC_SOURCE_NONE:
- return "none";
case ONC_SOURCE_USER_IMPORT:
return "user import";
}
diff --git a/chromeos/network/policy_applicator.cc b/chromeos/network/policy_applicator.cc
index bd81d7d..2c1e720 100644
--- a/chromeos/network/policy_applicator.cc
+++ b/chromeos/network/policy_applicator.cc
@@ -112,6 +112,7 @@ void PolicyApplicator::GetEntryCallback(
scoped_ptr<base::DictionaryValue> onc_part(
onc::TranslateShillServiceToONCPart(entry_properties,
+ ::onc::ONC_SOURCE_UNKNOWN,
&onc::kNetworkWithStateSignature));
std::string old_guid;
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 d8c252a9..3de8b23 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
@@ -2,6 +2,7 @@
"Name": {
"Active": "wifi2"
},
+ "Source": "User",
"Type": {
"Active": "WiFi"
},
diff --git a/chromeos/test/data/network/shill_cellular_with_state.json b/chromeos/test/data/network/shill_cellular_with_state.json
index 3edece1..081f173 100644
--- a/chromeos/test/data/network/shill_cellular_with_state.json
+++ b/chromeos/test/data/network/shill_cellular_with_state.json
@@ -49,5 +49,6 @@
"LockType": "sim-pin",
"LockEnabled": true
}
- }
+ },
+ "Profile": "/profile/default",
}
diff --git a/chromeos/test/data/network/shill_wifi_with_state.json b/chromeos/test/data/network/shill_wifi_with_state.json
index 8ae1dc5..9a2fe93 100644
--- a/chromeos/test/data/network/shill_wifi_with_state.json
+++ b/chromeos/test/data/network/shill_wifi_with_state.json
@@ -6,6 +6,7 @@
"Name": "OpenWrt",
"Passphrase": "some passphrase",
"Priority": 1,
+ "Profile": "/profile/someuser",
"Security": "psk",
"State": "idle",
"Strength": 10,
diff --git a/chromeos/test/data/network/translation_of_shill_cellular_with_state.onc b/chromeos/test/data/network/translation_of_shill_cellular_with_state.onc
index 8179464..7180366 100644
--- a/chromeos/test/data/network/translation_of_shill_cellular_with_state.onc
+++ b/chromeos/test/data/network/translation_of_shill_cellular_with_state.onc
@@ -43,5 +43,6 @@
"LockType": "sim-pin",
"LockEnabled": true
}
- }
+ },
+ "Source":"Device"
}
diff --git a/chromeos/test/data/network/translation_of_shill_wifi_with_state.onc b/chromeos/test/data/network/translation_of_shill_wifi_with_state.onc
index 6ba3974..25c833e 100644
--- a/chromeos/test/data/network/translation_of_shill_wifi_with_state.onc
+++ b/chromeos/test/data/network/translation_of_shill_wifi_with_state.onc
@@ -14,4 +14,5 @@
"SignalStrength": 10
},
"ConnectionState": "NotConnected",
+ "Source":"User"
}
diff --git a/components/onc/docs/onc_spec.html b/components/onc/docs/onc_spec.html
index ac2e500..9d3b43c 100644
--- a/components/onc/docs/onc_spec.html
+++ b/components/onc/docs/onc_spec.html
@@ -431,6 +431,36 @@
networks. The format is 00:11:22:AA:BB:CC.
</dd>
+ <dt class="field">Source</dt>
+ <dd>
+ <span class="field_meta">
+ (optional, read-only)
+ <span class="type">string</span>
+ </span>
+ Indicates whether the network is configured and how it is configured:
+ <ul>
+ <li><span class="value">User</span>: Configured for the active
+ user only, i.e. an unshared configuration.</li>
+ <li><span class="value">Device</span>: Configured for all users of the
+ device (e.g laptop), i.e. a shared configuration.</li>
+ <li><span class="value">UserPolicy</span>: Configured by the user
+ policy for the active user.</li>
+ <li><span class="value">DevicePolicy</span>: Configured by the device
+ policy for the device.</li>
+ <li><span class="value">None</span>: Not configured, e.g. a visible
+ but unconfigured WiFi network.</li>
+ </ul>
+ <span class="rule">
+ <span class="rule_id"></span>
+ Allowed values are:
+ <span class="value">User</span>,
+ <span class="value">Device</span>,
+ <span class="value">UserPolicy</span>,
+ <span class="value">DevicePolicy</span>,
+ <span class="value">None</span>
+ </span>
+ </dd>
+
<dt class="field">Priority</dt>
<dd>
<span class="field_meta">
diff --git a/components/onc/onc_constants.cc b/components/onc/onc_constants.cc
index 5aa0903..11e3e4e 100644
--- a/components/onc/onc_constants.cc
+++ b/components/onc/onc_constants.cc
@@ -33,22 +33,28 @@ const char kUnencryptedConfiguration[] = "UnencryptedConfiguration";
// Network Configuration
namespace network_config {
const char kCellular[] = "Cellular";
+const char kConnectable[] = "Connectable";
+const char kConnectionState[] = "ConnectionState";
const char kDevice[] = "Device";
+const char kErrorState[] = "ErrorState";
const char kEthernet[] = "Ethernet";
const char kGUID[] = "GUID";
const char kIPConfigs[] = "IPConfigs";
-const char kSavedIPConfig[] = "SavedIPConfig";
-const char kStaticIPConfig[] = "StaticIPConfig";
const char kMacAddress[] = "MacAddress";
-const char kName[] = "Name";
const char kNameServers[] = "NameServers";
+const char kName[] = "Name";
const char kPriority[] = "Priority";
const char kProxySettings[] = "ProxySettings";
-const char kSearchDomains[] = "SearchDomains";
-const char kConnectionState[] = "ConnectionState";
const char kRestrictedConnectivity[] = "RestrictedConnectivity";
-const char kConnectable[] = "Connectable";
-const char kErrorState[] = "ErrorState";
+const char kSavedIPConfig[] = "SavedIPConfig";
+const char kSearchDomains[] = "SearchDomains";
+const char kSourceDevice[] = "Device";
+const char kSourceDevicePolicy[] = "DevicePolicy";
+const char kSourceNone[] = "None";
+const char kSourceUser[] = "User";
+const char kSourceUserPolicy[] = "UserPolicy";
+const char kSource[] = "Source";
+const char kStaticIPConfig[] = "StaticIPConfig";
const char kType[] = "Type";
const char kVPN[] = "VPN";
const char kWiFi[] = "WiFi";
diff --git a/components/onc/onc_constants.h b/components/onc/onc_constants.h
index 0029ca7..14ddb98 100644
--- a/components/onc/onc_constants.h
+++ b/components/onc/onc_constants.h
@@ -13,6 +13,7 @@ namespace onc {
// Indicates from which source an ONC blob comes from.
enum ONCSource {
+ ONC_SOURCE_UNKNOWN,
ONC_SOURCE_NONE,
ONC_SOURCE_USER_IMPORT,
ONC_SOURCE_DEVICE_POLICY,
@@ -69,6 +70,12 @@ ONC_EXPORT extern const char kNameServers[];
ONC_EXPORT extern const char kPriority[];
ONC_EXPORT extern const char kProxySettings[];
ONC_EXPORT extern const char kSearchDomains[];
+ONC_EXPORT extern const char kSource[];
+ONC_EXPORT extern const char kSourceDevice[];
+ONC_EXPORT extern const char kSourceDevicePolicy[];
+ONC_EXPORT extern const char kSourceNone[];
+ONC_EXPORT extern const char kSourceUser[];
+ONC_EXPORT extern const char kSourceUserPolicy[];
ONC_EXPORT extern const char kConnectionState[];
ONC_EXPORT extern const char kRestrictedConnectivity[];
ONC_EXPORT extern const char kConnectable[];