summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-12 20:49:35 +0000
committerstevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-12 20:49:35 +0000
commit7f08375a52884609b72510d5c662ffdda6330afe (patch)
tree394a1eadcd6e93e772fd0ae46b2aeb1ea84e0b3c
parentb13862c40f4b5964f4328d91cdd175bb3d3f2d53 (diff)
downloadchromium_src-7f08375a52884609b72510d5c662ffdda6330afe.zip
chromium_src-7f08375a52884609b72510d5c662ffdda6330afe.tar.gz
chromium_src-7f08375a52884609b72510d5c662ffdda6330afe.tar.bz2
Format network hardware address in settings page
BUG=324005 R=pneubeck@chromium.org Review URL: https://codereview.chromium.org/101633003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240401 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc2
-rw-r--r--chromeos/network/device_state.cc12
-rw-r--r--chromeos/network/device_state.h3
-rw-r--r--chromeos/network/network_state_handler.cc20
-rw-r--r--chromeos/network/network_state_handler.h6
5 files changed, 20 insertions, 23 deletions
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 0cabdc9..25a449a 100644
--- a/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc
+++ b/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc
@@ -1534,7 +1534,7 @@ void InternetOptionsHandler::PopulateDictionaryDetailsCallback(
const DeviceState* device = NetworkHandler::Get()->network_state_handler()->
GetDeviceState(network->device_path());
if (device)
- dictionary.SetString(kTagHardwareAddress, device->mac_address());
+ dictionary.SetString(kTagHardwareAddress, device->GetFormattedMacAddress());
// IP config
scoped_ptr<base::DictionaryValue> ipconfig_dhcp(new base::DictionaryValue);
diff --git a/chromeos/network/device_state.cc b/chromeos/network/device_state.cc
index 1545d84..9019d33 100644
--- a/chromeos/network/device_state.cc
+++ b/chromeos/network/device_state.cc
@@ -132,6 +132,18 @@ bool DeviceState::InitialPropertiesReceived(
return false;
}
+std::string DeviceState::GetFormattedMacAddress() const {
+ if (mac_address_.size() % 2 != 0)
+ return mac_address_;
+ std::string result;
+ for (size_t i = 0; i < mac_address_.size(); ++i) {
+ if ((i != 0) && (i % 2 == 0))
+ result.push_back(':');
+ result.push_back(mac_address_[i]);
+ }
+ return result;
+}
+
bool DeviceState::IsSimAbsent() const {
return technology_family_ == shill::kTechnologyFamilyGsm && !sim_present_;
}
diff --git a/chromeos/network/device_state.h b/chromeos/network/device_state.h
index c6df864..33bc847 100644
--- a/chromeos/network/device_state.h
+++ b/chromeos/network/device_state.h
@@ -29,6 +29,9 @@ class CHROMEOS_EXPORT DeviceState : public ManagedState {
// Accessors
const std::string& mac_address() const { return mac_address_; }
+ // Returns |mac_address_| in aa:bb format.
+ std::string GetFormattedMacAddress() const;
+
// Cellular specific accessors
const std::string& home_provider_id() const { return home_provider_id_; }
bool provider_requires_roaming() const { return provider_requires_roaming_; }
diff --git a/chromeos/network/network_state_handler.cc b/chromeos/network/network_state_handler.cc
index 7743662..78346dc 100644
--- a/chromeos/network/network_state_handler.cc
+++ b/chromeos/network/network_state_handler.cc
@@ -245,7 +245,7 @@ const NetworkState* NetworkStateHandler::FirstNetworkByType(
return NULL;
}
-std::string NetworkStateHandler::HardwareAddressForType(
+std::string NetworkStateHandler::FormattedHardwareAddressForType(
const NetworkTypePattern& type) const {
const DeviceState* device = NULL;
const NetworkState* network = ConnectedNetworkByType(type);
@@ -255,23 +255,7 @@ std::string NetworkStateHandler::HardwareAddressForType(
device = GetDeviceStateByType(type);
if (!device)
return std::string();
- std::string result = device->mac_address();
- StringToUpperASCII(&result);
- return result;
-}
-
-std::string NetworkStateHandler::FormattedHardwareAddressForType(
- const NetworkTypePattern& type) const {
- std::string address = HardwareAddressForType(type);
- if (address.size() % 2 != 0)
- return address;
- std::string result;
- for (size_t i = 0; i < address.size(); ++i) {
- if ((i != 0) && (i % 2 == 0))
- result.push_back(':');
- result.push_back(address[i]);
- }
- return result;
+ return device->GetFormattedMacAddress();
}
void NetworkStateHandler::GetNetworkList(NetworkStateList* list) const {
diff --git a/chromeos/network/network_state_handler.h b/chromeos/network/network_state_handler.h
index 84bd9cb..c45a0d9 100644
--- a/chromeos/network/network_state_handler.h
+++ b/chromeos/network/network_state_handler.h
@@ -142,10 +142,8 @@ class CHROMEOS_EXPORT NetworkStateHandler
// network. Note: O(N).
const NetworkState* FirstNetworkByType(const NetworkTypePattern& type) const;
- // Returns the hardware (MAC) address for the first connected network
- // matching |type|, or an empty string if none is connected.
- std::string HardwareAddressForType(const NetworkTypePattern& type) const;
- // Same as above but in aa:bb format.
+ // Returns the aa:bb formatted hardware (MAC) address for the first connected
+ // network matching |type|, or an empty string if none is connected.
std::string FormattedHardwareAddressForType(
const NetworkTypePattern& type) const;