summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/chromeos/options/wifi_config_view.cc4
-rw-r--r--chrome/browser/extensions/api/networking_private/networking_private_api_nonchromeos.cc6
-rw-r--r--chrome/browser/extensions/api/networking_private/networking_private_apitest.cc2
-rw-r--r--chrome/test/data/chromeos/net/shill_for_managed_toplevel2.json4
-rw-r--r--chrome/test/data/chromeos/net/shill_for_managed_toplevel_wifi_peap.json6
-rw-r--r--chrome/test/data/chromeos/net/shill_for_toplevel_wifi_eap_clientcert.json4
-rw-r--r--chrome/test/data/chromeos/net/shill_for_toplevel_wifi_leap.json6
-rw-r--r--chrome/test/data/chromeos/net/shill_for_toplevel_wifi_open.json6
-rw-r--r--chrome/test/data/chromeos/net/shill_for_toplevel_wifi_wep_proxy.json4
-rw-r--r--chrome/test/data/chromeos/net/shill_for_toplevel_wifi_wpa_psk.json4
-rw-r--r--chrome/test/data/extensions/api_test/networking/test.js6
-rw-r--r--chromeos/dbus/shill_client_unittest_base.cc5
-rw-r--r--chromeos/dbus/shill_service_client_stub.cc5
-rw-r--r--chromeos/network/network_configuration_handler_unittest.cc16
-rw-r--r--chromeos/network/network_state_unittest.cc63
-rw-r--r--chromeos/network/onc/onc_translation_tables.cc3
-rw-r--r--chromeos/network/onc/onc_translator_onc_to_shill.cc5
-rw-r--r--chromeos/network/onc/onc_translator_shill_to_onc.cc5
-rw-r--r--chromeos/network/shill_property_util.cc135
-rw-r--r--chromeos/network/shill_property_util.h14
-rw-r--r--chromeos/test/data/network/policy/shill_managed_wifi1.json4
-rw-r--r--chromeos/test/data/network/policy/shill_policy_on_unconfigured_wifi1.json4
-rw-r--r--chromeos/test/data/network/policy/shill_policy_on_unmanaged_user_wifi1.json2
-rw-r--r--chromeos/test/data/network/policy/shill_policy_on_unmanaged_user_wifi1_wo_uidata.json4
-rw-r--r--chromeos/test/data/network/policy/shill_unmanaged_user_wifi1.json2
-rw-r--r--chromeos/test/data/network/policy/shill_unmanaged_user_wifi1_wo_uidata.json2
-rw-r--r--chromeos/test/data/network/policy/shill_unmanaged_user_wifi2.json2
-rw-r--r--chromeos/test/data/network/shill_wifi_clientcert.json4
-rw-r--r--chromeos/test/data/network/shill_wifi_clientref.json4
-rw-r--r--chromeos/test/data/network/shill_wifi_psk.json2
-rw-r--r--chromeos/test/data/network/shill_wifi_with_state.json2
-rw-r--r--chromeos/test/data/network/shill_wifi_wpa1.json4
32 files changed, 195 insertions, 144 deletions
diff --git a/chrome/browser/chromeos/options/wifi_config_view.cc b/chrome/browser/chromeos/options/wifi_config_view.cc
index 9e93cf7..f5190ae 100644
--- a/chrome/browser/chromeos/options/wifi_config_view.cc
+++ b/chrome/browser/chromeos/options/wifi_config_view.cc
@@ -19,6 +19,7 @@
#include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h"
#include "chromeos/network/network_ui_data.h"
+#include "chromeos/network/shill_property_util.h"
#include "components/onc/onc_constants.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
@@ -652,8 +653,7 @@ bool WifiConfigView::Login() {
base::DictionaryValue properties;
properties.SetStringWithoutPathExpansion(
shill::kTypeProperty, shill::kTypeWifi);
- properties.SetStringWithoutPathExpansion(
- shill::kSSIDProperty, GetSsid());
+ shill_property_util::SetSSID(GetSsid(), &properties);
properties.SetStringWithoutPathExpansion(
shill::kModeProperty, shill::kModeManaged);
properties.SetBooleanWithoutPathExpansion(
diff --git a/chrome/browser/extensions/api/networking_private/networking_private_api_nonchromeos.cc b/chrome/browser/extensions/api/networking_private/networking_private_api_nonchromeos.cc
index bc206ad..167d853 100644
--- a/chrome/browser/extensions/api/networking_private/networking_private_api_nonchromeos.cc
+++ b/chrome/browser/extensions/api/networking_private/networking_private_api_nonchromeos.cc
@@ -60,7 +60,7 @@ bool NetworkingPrivateGetPropertiesFunction::RunImpl() {
"\"WiFi\":{"
"\"Frequency\":5000,"
"\"FrequencyList\":[2400,5000],"
- "\"SSID\":\"stub_wifi2\","
+ "\"SSID\":\"wifi2_PSK\","
"\"Security\":\"WPA-PSK\","
"\"SignalStrength\":80}}";
@@ -121,9 +121,9 @@ bool NetworkingPrivateGetManagedPropertiesFunction::RunImpl() {
" \"UserSetting\": \"FAKE_CREDENTIAL_VPaJDV9x\""
" },"
" \"SSID\": {"
- " \"Active\": \"stub_wifi2\","
+ " \"Active\": \"wifi2_PSK\","
" \"Effective\": \"UserPolicy\","
- " \"UserPolicy\": \"stub_wifi2\""
+ " \"UserPolicy\": \"wifi2_PSK\""
" },"
" \"Security\": {"
" \"Active\": \"WPA-PSK\","
diff --git a/chrome/browser/extensions/api/networking_private/networking_private_apitest.cc b/chrome/browser/extensions/api/networking_private/networking_private_apitest.cc
index 42acc0e..7886eed 100644
--- a/chrome/browser/extensions/api/networking_private/networking_private_apitest.cc
+++ b/chrome/browser/extensions/api/networking_private/networking_private_apitest.cc
@@ -324,7 +324,7 @@ IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest,
" \"WiFi\": {"
" \"Passphrase\": \"passphrase\","
" \"Recommended\": [ \"AutoConnect\", \"Passphrase\" ],"
- " \"SSID\": \"stub_wifi2\","
+ " \"SSID\": \"wifi2_PSK\","
" \"Security\": \"WPA-PSK\" }"
" }"
" ],"
diff --git a/chrome/test/data/chromeos/net/shill_for_managed_toplevel2.json b/chrome/test/data/chromeos/net/shill_for_managed_toplevel2.json
index a7fe0e7..ed7daec 100644
--- a/chrome/test/data/chromeos/net/shill_for_managed_toplevel2.json
+++ b/chrome/test/data/chromeos/net/shill_for_managed_toplevel2.json
@@ -6,11 +6,11 @@
"GUID": "{77db0089-0bc8-4358-929c-123xcv}",
"Mode": "managed",
"Profile": "user",
- "SSID": "SomeWifi-XY",
"SaveCredentials": true,
"Security": "802_1x",
"Type": "wifi",
- "UIData": "{\"certificate_pattern\":{\"EnrollmentURI\":[\"chrome-extension://delkjfjibodjclmdijflfnimdmgdagfk/generate-cert.html\"],\"IssuerCAPEMs\":[\"pem1\",\"pem2\"]},\"certificate_type\":\"pattern\",\"onc_source\":\"user_policy\"}"
+ "UIData": "{\"certificate_pattern\":{\"EnrollmentURI\":[\"chrome-extension://delkjfjibodjclmdijflfnimdmgdagfk/generate-cert.html\"],\"IssuerCAPEMs\":[\"pem1\",\"pem2\"]},\"certificate_type\":\"pattern\",\"onc_source\":\"user_policy\"}",
+ "WiFi.HexSSID": "536F6D65576966692D5859" // "SomeWifi-XY"
},
"{a3860e83-f03d-4cb1-bafa-789oij}": {
"GUID": "{a3860e83-f03d-4cb1-bafa-789oij}",
diff --git a/chrome/test/data/chromeos/net/shill_for_managed_toplevel_wifi_peap.json b/chrome/test/data/chromeos/net/shill_for_managed_toplevel_wifi_peap.json
index 5fcdab7..cbd6b9e 100644
--- a/chrome/test/data/chromeos/net/shill_for_managed_toplevel_wifi_peap.json
+++ b/chrome/test/data/chromeos/net/shill_for_managed_toplevel_wifi_peap.json
@@ -6,9 +6,9 @@
"GUID": "{485d6076-dd44-6b6d-69787465725f5045}",
"Mode": "managed",
"Profile": "default",
- "SSID": "ssid",
"Security": "802_1x",
"Type": "wifi",
- "UIData": "{\"onc_source\":\"device_policy\"}"
+ "UIData": "{\"onc_source\":\"device_policy\"}",
+ "WiFi.HexSSID": "73736964" // "ssid"
}
-} \ No newline at end of file
+}
diff --git a/chrome/test/data/chromeos/net/shill_for_toplevel_wifi_eap_clientcert.json b/chrome/test/data/chromeos/net/shill_for_toplevel_wifi_eap_clientcert.json
index 4b651c3..cfbc531 100644
--- a/chrome/test/data/chromeos/net/shill_for_toplevel_wifi_eap_clientcert.json
+++ b/chrome/test/data/chromeos/net/shill_for_toplevel_wifi_eap_clientcert.json
@@ -7,10 +7,10 @@
"GUID": "{88dc6576-a740-ded0-3c0f16c4c7f5fb51}",
"Mode": "managed",
"Profile": "user",
- "SSID": "WirelessNetwork",
"Security": "802_1x",
"Type": "wifi",
"UIData": "{\"certificate_pattern\":{\"EnrollmentURI\":[\"http://youtu.be/dQw4w9WgXcQ\",\"chrome-extension://abc/keygen-cert.html\"],\"Issuer\":{\"Organization\":\"Google, Inc.\"}},\"certificate_type\":\"pattern\",\"onc_source\":\"user_policy\"}",
- "WiFi.HiddenSSID": false
+ "WiFi.HiddenSSID": false,
+ "WiFi.HexSSID": "576972656C6573734E6574776F726B" // "WirelessNetwork"
}
}
diff --git a/chrome/test/data/chromeos/net/shill_for_toplevel_wifi_leap.json b/chrome/test/data/chromeos/net/shill_for_toplevel_wifi_leap.json
index 349f2f4..039921f 100644
--- a/chrome/test/data/chromeos/net/shill_for_toplevel_wifi_leap.json
+++ b/chrome/test/data/chromeos/net/shill_for_toplevel_wifi_leap.json
@@ -7,9 +7,9 @@
"GUID": "{485d6076-dd44-6b6d-69787465725f5045}",
"Mode": "managed",
"Profile": "user",
- "SSID": "ssid",
"Security": "802_1x",
"Type": "wifi",
- "UIData": "{\"onc_source\":\"user_policy\"}"
+ "UIData": "{\"onc_source\":\"user_policy\"}",
+ "WiFi.HexSSID": "73736964" // "ssid"
}
-} \ No newline at end of file
+}
diff --git a/chrome/test/data/chromeos/net/shill_for_toplevel_wifi_open.json b/chrome/test/data/chromeos/net/shill_for_toplevel_wifi_open.json
index e9b3279..b130e12 100644
--- a/chrome/test/data/chromeos/net/shill_for_toplevel_wifi_open.json
+++ b/chrome/test/data/chromeos/net/shill_for_toplevel_wifi_open.json
@@ -3,9 +3,9 @@
"GUID": "{485d6076-dd44-6b6d-69787465725f5040}",
"Mode": "managed",
"Profile": "default",
- "SSID": "ssid-none",
"Security": "none",
"Type": "wifi",
- "UIData": "{\"onc_source\":\"device_policy\"}"
+ "UIData": "{\"onc_source\":\"device_policy\"}",
+ "WiFi.HexSSID": "737369642D6E6F6E65" // "ssid-none"
}
-} \ No newline at end of file
+}
diff --git a/chrome/test/data/chromeos/net/shill_for_toplevel_wifi_wep_proxy.json b/chrome/test/data/chromeos/net/shill_for_toplevel_wifi_wep_proxy.json
index 370e1d8..5fd5905 100644
--- a/chrome/test/data/chromeos/net/shill_for_toplevel_wifi_wep_proxy.json
+++ b/chrome/test/data/chromeos/net/shill_for_toplevel_wifi_wep_proxy.json
@@ -4,9 +4,9 @@
"Mode": "managed",
"Passphrase": "z123456789012",
"Profile": "user",
- "SSID": "ssid",
"Security": "wep",
"Type": "wifi",
- "UIData": "{\"onc_source\":\"user_policy\"}"
+ "UIData": "{\"onc_source\":\"user_policy\"}",
+ "WiFi.HexSSID": "73736964" // "ssid"
}
}
diff --git a/chrome/test/data/chromeos/net/shill_for_toplevel_wifi_wpa_psk.json b/chrome/test/data/chromeos/net/shill_for_toplevel_wifi_wpa_psk.json
index 0e6374a..046e9ec 100644
--- a/chrome/test/data/chromeos/net/shill_for_toplevel_wifi_wpa_psk.json
+++ b/chrome/test/data/chromeos/net/shill_for_toplevel_wifi_wpa_psk.json
@@ -5,10 +5,10 @@
"Mode": "managed",
"Passphrase": "some passphrase",
"Profile": "user",
- "SSID": "OpenWrt",
"Security": "psk",
"Type": "wifi",
"UIData": "{\"onc_source\":\"user_policy\"}",
- "WiFi.HiddenSSID": false
+ "WiFi.HiddenSSID": false,
+ "WiFi.HexSSID": "4F70656E577274" // "OpenWrt"
}
}
diff --git a/chrome/test/data/extensions/api_test/networking/test.js b/chrome/test/data/extensions/api_test/networking/test.js
index 13cc108..ed491cf 100644
--- a/chrome/test/data/extensions/api_test/networking/test.js
+++ b/chrome/test/data/extensions/api_test/networking/test.js
@@ -212,7 +212,7 @@ var availableTests = [
"WiFi": {
"Frequency": 5000,
"FrequencyList": [2400, 5000],
- "SSID": "stub_wifi2",
+ "SSID": "wifi2_PSK",
"Security": "WPA-PSK",
"SignalStrength": 80
}
@@ -258,9 +258,9 @@ var availableTests = [
"UserSetting": "FAKE_CREDENTIAL_VPaJDV9x"
},
"SSID": {
- "Active": "stub_wifi2",
+ "Active": "wifi2_PSK",
"Effective": "UserPolicy",
- "UserPolicy": "stub_wifi2"
+ "UserPolicy": "wifi2_PSK"
},
"Security": {
"Active": "WPA-PSK",
diff --git a/chromeos/dbus/shill_client_unittest_base.cc b/chromeos/dbus/shill_client_unittest_base.cc
index ccc481c..f53586f 100644
--- a/chromeos/dbus/shill_client_unittest_base.cc
+++ b/chromeos/dbus/shill_client_unittest_base.cc
@@ -7,6 +7,7 @@
#include "base/bind.h"
#include "base/json/json_writer.h"
#include "base/values.h"
+#include "chromeos/network/shill_property_util.h"
#include "dbus/message.h"
#include "dbus/object_path.h"
#include "dbus/values_util.h"
@@ -288,9 +289,7 @@ ShillClientUnittestBase::CreateExampleServiceProperties() {
properties->SetWithoutPathExpansion(
shill::kTypeProperty,
base::Value::CreateStringValue(shill::kTypeWifi));
- properties->SetWithoutPathExpansion(
- shill::kSSIDProperty,
- base::Value::CreateStringValue("testssid"));
+ shill_property_util::SetSSID("testssid", properties);
properties->SetWithoutPathExpansion(
shill::kSecurityProperty,
base::Value::CreateStringValue(shill::kSecurityPsk));
diff --git a/chromeos/dbus/shill_service_client_stub.cc b/chromeos/dbus/shill_service_client_stub.cc
index 8e2be67..c03fc48 100644
--- a/chromeos/dbus/shill_service_client_stub.cc
+++ b/chromeos/dbus/shill_service_client_stub.cc
@@ -16,6 +16,7 @@
#include "chromeos/dbus/shill_manager_client.h"
#include "chromeos/dbus/shill_property_changed_observer.h"
#include "chromeos/dbus/shill_stub_helper.h"
+#include "chromeos/network/shill_property_util.h"
#include "dbus/bus.h"
#include "dbus/message.h"
#include "dbus/object_path.h"
@@ -345,9 +346,7 @@ void ShillServiceClientStub::AddServiceWithIPConfig(
base::DictionaryValue* properties =
GetModifiableServiceProperties(service_path, true);
connect_behavior_.erase(service_path);
- properties->SetWithoutPathExpansion(
- shill::kSSIDProperty,
- base::Value::CreateStringValue(service_path));
+ shill_property_util::SetSSID(name, properties);
properties->SetWithoutPathExpansion(
shill::kNameProperty,
base::Value::CreateStringValue(name));
diff --git a/chromeos/network/network_configuration_handler_unittest.cc b/chromeos/network/network_configuration_handler_unittest.cc
index e353543..af8d593 100644
--- a/chromeos/network/network_configuration_handler_unittest.cc
+++ b/chromeos/network/network_configuration_handler_unittest.cc
@@ -17,6 +17,7 @@
#include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h"
#include "chromeos/network/network_state_handler_observer.h"
+#include "chromeos/network/shill_property_util.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
@@ -333,11 +334,8 @@ TEST_F(NetworkConfigurationHandlerTest, CreateConfiguration) {
std::string networkName = "MyNetwork";
std::string key = "SSID";
std::string profile = "profile path";
- scoped_ptr<base::StringValue> networkNameValue(
- base::Value::CreateStringValue(networkName));
base::DictionaryValue value;
- value.SetWithoutPathExpansion(shill::kSSIDProperty,
- base::Value::CreateStringValue(networkName));
+ shill_property_util::SetSSID(networkName, &value);
value.SetWithoutPathExpansion(shill::kProfileProperty,
base::Value::CreateStringValue(profile));
@@ -581,7 +579,7 @@ TEST_F(NetworkConfigurationHandlerStubTest, StubGetNameFromWifiHex) {
TEST_F(NetworkConfigurationHandlerStubTest, StubCreateConfiguration) {
const std::string service_path("test_wifi");
base::DictionaryValue properties;
- properties.SetStringWithoutPathExpansion(shill::kSSIDProperty, service_path);
+ shill_property_util::SetSSID(service_path, &properties);
properties.SetStringWithoutPathExpansion(shill::kNameProperty, service_path);
properties.SetStringWithoutPathExpansion(shill::kGuidProperty, service_path);
properties.SetStringWithoutPathExpansion(
@@ -601,12 +599,12 @@ TEST_F(NetworkConfigurationHandlerStubTest, StubCreateConfiguration) {
EXPECT_FALSE(create_service_path_.empty());
- std::string ssid;
+ std::string guid;
EXPECT_TRUE(GetServiceStringProperty(
- create_service_path_, shill::kSSIDProperty, &ssid));
- std::string actual_profile;
- EXPECT_EQ(service_path, ssid);
+ create_service_path_, shill::kGuidProperty, &guid));
+ EXPECT_EQ(service_path, guid);
+ std::string actual_profile;
EXPECT_TRUE(GetServiceStringProperty(
create_service_path_, shill::kProfileProperty, &actual_profile));
EXPECT_EQ(shill_stub_helper::kSharedProfilePath, actual_profile);
diff --git a/chromeos/network/network_state_unittest.cc b/chromeos/network/network_state_unittest.cc
index f652493..642d77f 100644
--- a/chromeos/network/network_state_unittest.cc
+++ b/chromeos/network/network_state_unittest.cc
@@ -75,41 +75,53 @@ class NetworkStateTest : public testing::Test {
} // namespace
-// Seting kNameProperty should set network name after call to
-// InitialPropertiesReceived() in SetStringProperty().
-TEST_F(NetworkStateTest, SsidAscii) {
- std::string wifi_setname = "SSID TEST";
- std::string wifi_setname_result = "SSID TEST";
- EXPECT_TRUE(SetStringProperty(shill::kNameProperty, wifi_setname));
- EXPECT_EQ(network_state_.name(), wifi_setname_result);
+// Setting kNameProperty should set network name after call to
+// InitialPropertiesReceived().
+TEST_F(NetworkStateTest, NameAscii) {
+ EXPECT_TRUE(SetStringProperty(shill::kTypeProperty, shill::kTypeVPN));
+
+ std::string network_setname = "Name TEST";
+ EXPECT_TRUE(SetStringProperty(shill::kNameProperty, network_setname));
+ EXPECT_FALSE(SignalInitialPropertiesReceived());
+ EXPECT_EQ(network_state_.name(), network_setname);
}
-TEST_F(NetworkStateTest, SsidAsciiWithNull) {
- std::string wifi_setname = "SSID TEST\x00xxx";
- std::string wifi_setname_result = "SSID TEST";
- EXPECT_TRUE(SetStringProperty(shill::kNameProperty, wifi_setname));
- EXPECT_EQ(network_state_.name(), wifi_setname_result);
+TEST_F(NetworkStateTest, NameAsciiWithNull) {
+ EXPECT_TRUE(SetStringProperty(shill::kTypeProperty, shill::kTypeVPN));
+
+ std::string network_setname = "Name TEST\x00xxx";
+ std::string network_setname_result = "Name TEST";
+ EXPECT_TRUE(SetStringProperty(shill::kNameProperty, network_setname));
+ EXPECT_FALSE(SignalInitialPropertiesReceived());
+ EXPECT_EQ(network_state_.name(), network_setname_result);
}
-// UTF8 SSID
-TEST_F(NetworkStateTest, SsidUtf8) {
+// Truncates invalid UTF-8
+TEST_F(NetworkStateTest, NameTruncateInvalid) {
+ EXPECT_TRUE(SetStringProperty(shill::kTypeProperty, shill::kTypeVPN));
+
+ std::string network_setname = "SSID TEST \x01\xff!";
+ std::string network_setname_result = "SSID TEST \xEF\xBF\xBD\xEF\xBF\xBD!";
+ EXPECT_TRUE(SetStringProperty(shill::kNameProperty, network_setname));
+ EXPECT_TRUE(SignalInitialPropertiesReceived());
+ EXPECT_EQ(network_state_.name(), network_setname_result);
+}
+
+// If HexSSID doesn't exist, fallback to NameProperty.
+TEST_F(NetworkStateTest, SsidFromName) {
+ EXPECT_TRUE(SetStringProperty(shill::kTypeProperty, shill::kTypeWifi));
+
std::string wifi_utf8 = "UTF-8 \u3042\u3044\u3046";
std::string wifi_utf8_result = "UTF-8 \xE3\x81\x82\xE3\x81\x84\xE3\x81\x86";
EXPECT_TRUE(SetStringProperty(shill::kNameProperty, wifi_utf8));
+ EXPECT_FALSE(SignalInitialPropertiesReceived());
EXPECT_EQ(network_state_.name(), wifi_utf8_result);
}
-// Truncates invalid UTF-8
-TEST_F(NetworkStateTest, SsidTruncateInvalid) {
- std::string wifi_setname2 = "SSID TEST \x01\xff!";
- std::string wifi_setname2_result = "SSID TEST \xEF\xBF\xBD\xEF\xBF\xBD!";
- EXPECT_TRUE(SetStringProperty(shill::kNameProperty, wifi_setname2));
- EXPECT_TRUE(SignalInitialPropertiesReceived());
- EXPECT_EQ(network_state_.name(), wifi_setname2_result);
-}
-
// latin1 SSID -> UTF8 SSID (Hex)
TEST_F(NetworkStateTest, SsidLatin) {
+ EXPECT_TRUE(SetStringProperty(shill::kTypeProperty, shill::kTypeWifi));
+
std::string wifi_latin1 = "latin-1 \xc0\xcb\xcc\xd6\xfb";
std::string wifi_latin1_hex =
base::HexEncode(wifi_latin1.c_str(), wifi_latin1.length());
@@ -121,8 +133,11 @@ TEST_F(NetworkStateTest, SsidLatin) {
// Hex SSID
TEST_F(NetworkStateTest, SsidHex) {
- std::string wifi_hex = "5468697320697320484558205353494421";
+ EXPECT_TRUE(SetStringProperty(shill::kTypeProperty, shill::kTypeWifi));
+
std::string wifi_hex_result = "This is HEX SSID!";
+ std::string wifi_hex =
+ base::HexEncode(wifi_hex_result.c_str(), wifi_hex_result.length());
EXPECT_FALSE(SetStringProperty(shill::kWifiHexSsid, wifi_hex));
EXPECT_TRUE(SignalInitialPropertiesReceived());
EXPECT_EQ(network_state_.name(), wifi_hex_result);
diff --git a/chromeos/network/onc/onc_translation_tables.cc b/chromeos/network/onc/onc_translation_tables.cc
index ce6dd3e..a0bebbe 100644
--- a/chromeos/network/onc/onc_translation_tables.cc
+++ b/chromeos/network/onc/onc_translation_tables.cc
@@ -99,7 +99,8 @@ const FieldTranslationEntry wifi_fields[] = {
{ ::onc::wifi::kFrequencyList, shill::kWifiFrequencyListProperty},
{ ::onc::wifi::kHiddenSSID, shill::kWifiHiddenSsid},
{ ::onc::wifi::kPassphrase, shill::kPassphraseProperty},
- { ::onc::wifi::kSSID, shill::kSSIDProperty},
+ // This field is converted during translation, see onc_translator_*.
+ // { ::onc::wifi::kSSID, shill::kWifiHexSsid},
// This field is converted during translation, see onc_translator_*.
// { ::onc::wifi::kSecurity, shill::kSecurityProperty },
{ ::onc::wifi::kSignalStrength, shill::kSignalStrengthProperty},
diff --git a/chromeos/network/onc/onc_translator_onc_to_shill.cc b/chromeos/network/onc/onc_translator_onc_to_shill.cc
index c2ba0e8..f6b0117 100644
--- a/chromeos/network/onc/onc_translator_onc_to_shill.cc
+++ b/chromeos/network/onc/onc_translator_onc_to_shill.cc
@@ -18,6 +18,7 @@
#include "base/values.h"
#include "chromeos/network/onc/onc_signature.h"
#include "chromeos/network/onc/onc_translation_tables.h"
+#include "chromeos/network/shill_property_util.h"
#include "components/onc/onc_constants.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
@@ -156,6 +157,10 @@ void LocalTranslator::TranslateWiFi() {
TranslateWithTableAndSet(security, kWiFiSecurityTable,
shill::kSecurityProperty);
+ std::string ssid;
+ onc_object_->GetStringWithoutPathExpansion(::onc::wifi::kSSID, &ssid);
+ shill_property_util::SetSSID(ssid, shill_dictionary_);
+
// We currently only support managed and no adhoc networks.
shill_dictionary_->SetStringWithoutPathExpansion(shill::kModeProperty,
shill::kModeManaged);
diff --git a/chromeos/network/onc/onc_translator_shill_to_onc.cc b/chromeos/network/onc/onc_translator_shill_to_onc.cc
index ed1e643..bc14913 100644
--- a/chromeos/network/onc/onc_translator_shill_to_onc.cc
+++ b/chromeos/network/onc/onc_translator_shill_to_onc.cc
@@ -14,6 +14,7 @@
#include "chromeos/network/network_state.h"
#include "chromeos/network/onc/onc_signature.h"
#include "chromeos/network/onc/onc_translation_tables.h"
+#include "chromeos/network/shill_property_util.h"
#include "components/onc/onc_constants.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
@@ -216,6 +217,10 @@ void ShillToONCTranslator::TranslateVPN() {
void ShillToONCTranslator::TranslateWiFiWithState() {
TranslateWithTableAndSet(
shill::kSecurityProperty, kWiFiSecurityTable, ::onc::wifi::kSecurity);
+ std::string ssid = shill_property_util::GetSSIDFromProperties(
+ *shill_dictionary_, NULL /* ignore unknown encoding */);
+ if (!ssid.empty())
+ onc_object_->SetStringWithoutPathExpansion(::onc::wifi::kSSID, ssid);
CopyPropertiesAccordingToSignature();
}
diff --git a/chromeos/network/shill_property_util.cc b/chromeos/network/shill_property_util.cc
index 0f736d8..3077218 100644
--- a/chromeos/network/shill_property_util.cc
+++ b/chromeos/network/shill_property_util.cc
@@ -58,86 +58,105 @@ bool CopyStringFromDictionary(const base::DictionaryValue& source,
} // namespace
-std::string GetNameFromProperties(const std::string& service_path,
- const base::DictionaryValue& properties) {
- std::string name, hex_ssid;
- properties.GetStringWithoutPathExpansion(shill::kNameProperty, &name);
+void SetSSID(const std::string ssid, base::DictionaryValue* properties) {
+ std::string hex_ssid = base::HexEncode(ssid.c_str(), ssid.size());
+ properties->SetStringWithoutPathExpansion(shill::kWifiHexSsid, hex_ssid);
+}
+
+std::string GetSSIDFromProperties(const base::DictionaryValue& properties,
+ bool* unknown_encoding) {
+ if (unknown_encoding)
+ *unknown_encoding = false;
+ std::string hex_ssid;
properties.GetStringWithoutPathExpansion(shill::kWifiHexSsid, &hex_ssid);
if (hex_ssid.empty()) {
- if (name.empty())
- return name;
- // Validate name for UTF8.
- std::string valid_ssid = ValidateUTF8(name);
- if (valid_ssid != name) {
- NET_LOG_DEBUG(
- "GetNameFromProperties",
- base::StringPrintf(
- "%s: UTF8: %s", service_path.c_str(), valid_ssid.c_str()));
- }
- return valid_ssid;
+ NET_LOG_ERROR("GetSSIDFromProperties", "No HexSSID set.");
+ return std::string();
}
std::string ssid;
std::vector<uint8> raw_ssid_bytes;
if (base::HexStringToBytes(hex_ssid, &raw_ssid_bytes)) {
ssid = std::string(raw_ssid_bytes.begin(), raw_ssid_bytes.end());
- NET_LOG_DEBUG("GetNameFromProperties",
- base::StringPrintf("%s: %s, SSID: %s",
- service_path.c_str(),
- hex_ssid.c_str(),
- ssid.c_str()));
+ NET_LOG_DEBUG(
+ "GetSSIDFromProperties",
+ base::StringPrintf("%s, SSID: %s", hex_ssid.c_str(), ssid.c_str()));
} else {
- NET_LOG_ERROR("GetNameFromProperties",
- base::StringPrintf("%s: Error processing: %s",
- service_path.c_str(),
- hex_ssid.c_str()));
- return name;
+ NET_LOG_ERROR("GetSSIDFromProperties",
+ base::StringPrintf("Error processing: %s", hex_ssid.c_str()));
+ return std::string();
}
- if (IsStringUTF8(ssid)) {
- if (ssid != name) {
- NET_LOG_DEBUG("GetNameFromProperties",
- base::StringPrintf(
- "%s: UTF8: %s", service_path.c_str(), ssid.c_str()));
- }
+ if (IsStringUTF8(ssid))
return ssid;
- }
// Detect encoding and convert to UTF-8.
- std::string country_code;
- properties.GetStringWithoutPathExpansion(shill::kCountryProperty,
- &country_code);
std::string encoding;
if (!base::DetectEncoding(ssid, &encoding)) {
// TODO(stevenjb): This is currently experimental. If we find a case where
// base::DetectEncoding() fails, we need to figure out whether we can use
// country_code with ConvertToUtf8(). crbug.com/233267.
- encoding = country_code;
+ properties.GetStringWithoutPathExpansion(shill::kCountryProperty,
+ &encoding);
}
- if (!encoding.empty()) {
- std::string utf8_ssid;
- if (base::ConvertToUtf8AndNormalize(ssid, encoding, &utf8_ssid)) {
- if (utf8_ssid != name) {
- NET_LOG_DEBUG("GetNameFromProperties",
- base::StringPrintf("%s: Encoding=%s: %s",
- service_path.c_str(),
- encoding.c_str(),
- utf8_ssid.c_str()));
- }
- return utf8_ssid;
+ std::string utf8_ssid;
+ if (!encoding.empty() &&
+ base::ConvertToUtf8AndNormalize(ssid, encoding, &utf8_ssid)) {
+ if (utf8_ssid != ssid) {
+ NET_LOG_DEBUG(
+ "GetSSIDFromProperties",
+ base::StringPrintf(
+ "Encoding=%s: %s", encoding.c_str(), utf8_ssid.c_str()));
}
+ return utf8_ssid;
}
- // Unrecognized encoding. Only use raw bytes if name_ is empty.
- NET_LOG_DEBUG("GetNameFromProperties",
- base::StringPrintf("%s: Unrecognized Encoding=%s: %s",
- service_path.c_str(),
- encoding.c_str(),
- ssid.c_str()));
- if (name.empty() && !ssid.empty())
- return ssid;
- return name;
+ if (unknown_encoding)
+ *unknown_encoding = true;
+ NET_LOG_DEBUG(
+ "GetSSIDFromProperties",
+ base::StringPrintf("Unrecognized Encoding=%s", encoding.c_str()));
+ return ssid;
+}
+
+std::string GetNameFromProperties(const std::string& service_path,
+ const base::DictionaryValue& properties) {
+ std::string name;
+ properties.GetStringWithoutPathExpansion(shill::kNameProperty, &name);
+
+ std::string validated_name = ValidateUTF8(name);
+ if (validated_name != name) {
+ NET_LOG_DEBUG("GetNameFromProperties",
+ base::StringPrintf("Validated name %s: UTF8: %s",
+ service_path.c_str(),
+ validated_name.c_str()));
+ }
+
+ std::string type;
+ properties.GetStringWithoutPathExpansion(shill::kTypeProperty, &type);
+ if (!NetworkTypePattern::WiFi().MatchesType(type))
+ return validated_name;
+
+ bool unknown_ssid_encoding = false;
+ std::string ssid = GetSSIDFromProperties(properties, &unknown_ssid_encoding);
+ if (ssid.empty())
+ NET_LOG_ERROR("GetNameFromProperties", "No SSID set: " + service_path);
+
+ // Use |validated_name| if |ssid| is empty.
+ // And if the encoding of the SSID is unknown, use |ssid|, which contains raw
+ // bytes in that case, only if |validated_name| is empty.
+ if (ssid.empty() || (unknown_ssid_encoding && !validated_name.empty()))
+ return validated_name;
+
+ if (ssid != validated_name) {
+ NET_LOG_DEBUG("GetNameFromProperties",
+ base::StringPrintf("%s: SSID: %s, Name: %s",
+ service_path.c_str(),
+ ssid.c_str(),
+ validated_name.c_str()));
+ }
+ return ssid;
}
scoped_ptr<NetworkUIData> GetUIDataFromValue(const base::Value& ui_data_value) {
@@ -192,8 +211,8 @@ bool CopyIdentifyingProperties(const base::DictionaryValue& service_properties,
if (type == shill::kTypeWifi) {
success &= CopyStringFromDictionary(
service_properties, shill::kSecurityProperty, dest);
- success &= CopyStringFromDictionary(
- service_properties, shill::kSSIDProperty, dest);
+ success &=
+ CopyStringFromDictionary(service_properties, shill::kWifiHexSsid, dest);
success &= CopyStringFromDictionary(
service_properties, shill::kModeProperty, dest);
} else if (type == shill::kTypeVPN) {
diff --git a/chromeos/network/shill_property_util.h b/chromeos/network/shill_property_util.h
index 9072a28..dc1f45f 100644
--- a/chromeos/network/shill_property_util.h
+++ b/chromeos/network/shill_property_util.h
@@ -21,8 +21,18 @@ class NetworkUIData;
namespace shill_property_util {
-// Generates a name from properties."Wifi.HexSSID" if present, otherwise
-// validates properties.Name and returns a valid utf8 version.
+// Sets the |ssid| in |properties|.
+CHROMEOS_EXPORT void SetSSID(const std::string ssid,
+ base::DictionaryValue* properties);
+
+// Returns the SSID from |properties| in UTF-8 encoding. If |unknown_encoding|
+// is not NULL, it is set to whether the SSID is of unknown encoding.
+CHROMEOS_EXPORT std::string GetSSIDFromProperties(
+ const base::DictionaryValue& properties,
+ bool* unknown_encoding);
+
+// Returns the name for the network represented by the Shill |properties|. For
+// WiFi it refers to the HexSSID.
CHROMEOS_EXPORT std::string GetNameFromProperties(
const std::string& service_path,
const base::DictionaryValue& properties);
diff --git a/chromeos/test/data/network/policy/shill_managed_wifi1.json b/chromeos/test/data/network/policy/shill_managed_wifi1.json
index 031e5cb..c138013 100644
--- a/chromeos/test/data/network/policy/shill_managed_wifi1.json
+++ b/chromeos/test/data/network/policy/shill_managed_wifi1.json
@@ -6,8 +6,8 @@
"Mode": "managed",
"Passphrase": "user's passphrase",
"Profile": "/profile/chronos/shill",
- "SSID": "wifi1",
"Security": "802_1x",
"Type": "wifi",
- "UIData": "{\"onc_source\":\"user_policy\",\"user_settings\":{\"WiFi\":{\"Passphrase\":\"FAKE_CREDENTIAL_VPaJDV9x\"}}}"
+ "UIData": "{\"onc_source\":\"user_policy\",\"user_settings\":{\"WiFi\":{\"Passphrase\":\"FAKE_CREDENTIAL_VPaJDV9x\"}}}",
+ "WiFi.HexSSID": "7769666931" // "wifi1"
}
diff --git a/chromeos/test/data/network/policy/shill_policy_on_unconfigured_wifi1.json b/chromeos/test/data/network/policy/shill_policy_on_unconfigured_wifi1.json
index c8b5929..d998ba9 100644
--- a/chromeos/test/data/network/policy/shill_policy_on_unconfigured_wifi1.json
+++ b/chromeos/test/data/network/policy/shill_policy_on_unconfigured_wifi1.json
@@ -3,8 +3,8 @@
"Mode": "managed",
"Passphrase": "policy's passphrase",
"Profile": "/profile/user1/shill",
- "SSID": "wifi1",
"Security": "psk",
"Type": "wifi",
- "UIData": "{\"onc_source\":\"user_policy\"}"
+ "UIData": "{\"onc_source\":\"user_policy\"}",
+ "WiFi.HexSSID": "7769666931" // "wifi1"
}
diff --git a/chromeos/test/data/network/policy/shill_policy_on_unmanaged_user_wifi1.json b/chromeos/test/data/network/policy/shill_policy_on_unmanaged_user_wifi1.json
index 1790bd7..7c9c4bc 100644
--- a/chromeos/test/data/network/policy/shill_policy_on_unmanaged_user_wifi1.json
+++ b/chromeos/test/data/network/policy/shill_policy_on_unmanaged_user_wifi1.json
@@ -3,7 +3,7 @@
"Mode": "managed",
"Passphrase": "user's passphrase",
"Profile": "/profile/user1/shill",
- "SSID": "wifi1",
+ "WiFi.HexSSID": "7769666931", // "wifi1"
"Security": "psk",
"Type": "wifi",
"UIData": "{\"onc_source\":\"user_policy\",\"user_settings\":{\"WiFi\":{\"Passphrase\":\"FAKE_CREDENTIAL_VPaJDV9x\"}}}"
diff --git a/chromeos/test/data/network/policy/shill_policy_on_unmanaged_user_wifi1_wo_uidata.json b/chromeos/test/data/network/policy/shill_policy_on_unmanaged_user_wifi1_wo_uidata.json
index d2c959e..9df16c0 100644
--- a/chromeos/test/data/network/policy/shill_policy_on_unmanaged_user_wifi1_wo_uidata.json
+++ b/chromeos/test/data/network/policy/shill_policy_on_unmanaged_user_wifi1_wo_uidata.json
@@ -3,8 +3,8 @@
"Mode": "managed",
"Passphrase": "user's passphrase",
"Profile": "/profile/user1/shill",
- "SSID": "wifi1",
"Security": "psk",
"Type": "wifi",
- "UIData": "{\"onc_source\":\"user_policy\"}}"
+ "UIData": "{\"onc_source\":\"user_policy\"}}",
+ "WiFi.HexSSID": "7769666931" // "wifi1"
}
diff --git a/chromeos/test/data/network/policy/shill_unmanaged_user_wifi1.json b/chromeos/test/data/network/policy/shill_unmanaged_user_wifi1.json
index 45cbe90..ebf81ef 100644
--- a/chromeos/test/data/network/policy/shill_unmanaged_user_wifi1.json
+++ b/chromeos/test/data/network/policy/shill_unmanaged_user_wifi1.json
@@ -3,7 +3,7 @@
"Mode": "managed",
"Passphrase": "user's passphrase",
"Profile": "/profile/chronos/shill",
- "SSID": "wifi1",
+ "WiFi.HexSSID": "7769666931", // "wifi1"
"Security": "psk",
"Type": "wifi",
"UIData": "{\"user_settings\":{\"WiFi\":{\"Passphrase\":\"user's passphrase\"}}}"
diff --git a/chromeos/test/data/network/policy/shill_unmanaged_user_wifi1_wo_uidata.json b/chromeos/test/data/network/policy/shill_unmanaged_user_wifi1_wo_uidata.json
index ac7fb73..f7a1e1f 100644
--- a/chromeos/test/data/network/policy/shill_unmanaged_user_wifi1_wo_uidata.json
+++ b/chromeos/test/data/network/policy/shill_unmanaged_user_wifi1_wo_uidata.json
@@ -3,7 +3,7 @@
"Mode": "managed",
"Passphrase": "user's passphrase",
"Profile": "/profile/chronos/shill",
- "SSID": "wifi1",
"Security": "psk",
"Type": "wifi",
+ "WiFi.HexSSID": "7769666931" // "wifi1"
}
diff --git a/chromeos/test/data/network/policy/shill_unmanaged_user_wifi2.json b/chromeos/test/data/network/policy/shill_unmanaged_user_wifi2.json
index 13e81fb..af7b56f 100644
--- a/chromeos/test/data/network/policy/shill_unmanaged_user_wifi2.json
+++ b/chromeos/test/data/network/policy/shill_unmanaged_user_wifi2.json
@@ -3,7 +3,7 @@
"Mode": "managed",
"Passphrase": "user's passphrase",
"Profile": "/profile/chronos/shill",
- "SSID": "wifi2",
"Security": "psk",
"Type": "wifi",
+ "WiFi.HexSSID": "7769666932" // "wifi2"
}
diff --git a/chromeos/test/data/network/shill_wifi_clientcert.json b/chromeos/test/data/network/shill_wifi_clientcert.json
index f6664d2..0015800 100644
--- a/chromeos/test/data/network/shill_wifi_clientcert.json
+++ b/chromeos/test/data/network/shill_wifi_clientcert.json
@@ -4,8 +4,8 @@
"EAP.UseSystemCAs": true,
"GUID": "{77db0089-0bc8-4358-929c-123xcv}",
"Mode": "managed",
- "SSID": "SomeWifi-XY",
"SaveCredentials": true,
"Security": "802_1x",
- "Type": "wifi"
+ "Type": "wifi",
+ "WiFi.HexSSID": "536F6D65576966692D5859" // "SomeWifi-XY"
}
diff --git a/chromeos/test/data/network/shill_wifi_clientref.json b/chromeos/test/data/network/shill_wifi_clientref.json
index 541032b8..551cda8 100644
--- a/chromeos/test/data/network/shill_wifi_clientref.json
+++ b/chromeos/test/data/network/shill_wifi_clientref.json
@@ -4,8 +4,8 @@
"EAP.UseSystemCAs": true,
"GUID": "{77db0089-0bc8-4358-929c-123xcv}",
"Mode": "managed",
- "SSID": "SomeWifi-XY",
"SaveCredentials": true,
"Security": "802_1x",
- "Type": "wifi"
+ "Type": "wifi",
+ "WiFi.HexSSID": "536F6D65576966692D5859" // "SomeWifi-XY"
}
diff --git a/chromeos/test/data/network/shill_wifi_psk.json b/chromeos/test/data/network/shill_wifi_psk.json
index e476052..9969879 100644
--- a/chromeos/test/data/network/shill_wifi_psk.json
+++ b/chromeos/test/data/network/shill_wifi_psk.json
@@ -3,9 +3,9 @@
"GUID": "{64c4f86b-cf6a-4e4a-8eff-456def}",
"Mode": "managed",
"Passphrase": "some passphrase",
- "SSID": "OpenWrt",
"Security": "psk",
"Type": "wifi",
+ "WiFi.HexSSID": "4F70656E577274", // "OpenWrt"
"WiFi.HiddenSSID": false,
"WiFi.Frequency": 2412,
"WiFi.FrequencyList": [2412, 5180]
diff --git a/chromeos/test/data/network/shill_wifi_with_state.json b/chromeos/test/data/network/shill_wifi_with_state.json
index 5697c38..865162b 100644
--- a/chromeos/test/data/network/shill_wifi_with_state.json
+++ b/chromeos/test/data/network/shill_wifi_with_state.json
@@ -4,11 +4,11 @@
"Mode": "managed",
"Name": "OpenWrt",
"Passphrase": "some passphrase",
- "SSID": "OpenWrt",
"Security": "psk",
"State": "idle",
"Strength": 10,
"Type": "wifi",
"WiFi.BSSID": "00:12:34:ca:56:8b",
+ "WiFi.HexSSID": "4F70656E577274", // "OpenWrt"
"WiFi.HiddenSSID": false
}
diff --git a/chromeos/test/data/network/shill_wifi_wpa1.json b/chromeos/test/data/network/shill_wifi_wpa1.json
index 2d92618..db1e353 100644
--- a/chromeos/test/data/network/shill_wifi_wpa1.json
+++ b/chromeos/test/data/network/shill_wifi_wpa1.json
@@ -3,7 +3,7 @@
"Mode":"managed",
"Name":"OpenWrt",
"Passphrase":"some passphrase",
- "SSID":"OpenWrt",
"Security":"wpa",
- "Type":"wifi"
+ "Type":"wifi",
+ "WiFi.HexSSID": "4F70656E577274" // "OpenWrt"
}