summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/cros
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/chromeos/cros')
-rw-r--r--chrome/browser/chromeos/cros/native_network_parser.cc157
-rw-r--r--chrome/browser/chromeos/cros/native_network_parser.h38
-rw-r--r--chrome/browser/chromeos/cros/network_library.cc27
-rw-r--r--chrome/browser/chromeos/cros/network_library.h4
-rw-r--r--chrome/browser/chromeos/cros/network_parser.cc38
-rw-r--r--chrome/browser/chromeos/cros/network_parser.h9
6 files changed, 130 insertions, 143 deletions
diff --git a/chrome/browser/chromeos/cros/native_network_parser.cc b/chrome/browser/chromeos/cros/native_network_parser.cc
index 24340b2..3172025 100644
--- a/chrome/browser/chromeos/cros/native_network_parser.cc
+++ b/chrome/browser/chromeos/cros/native_network_parser.cc
@@ -147,13 +147,12 @@ NativeNetworkDeviceParser::NativeNetworkDeviceParser()
NativeNetworkDeviceParser::~NativeNetworkDeviceParser() {
}
-bool NativeNetworkDeviceParser::ParseValue(PropertyIndex index,
- Value* value,
- NetworkDevice* device) {
+bool NativeNetworkDeviceParser::ParseValue(
+ PropertyIndex index, const Value& value, NetworkDevice* device) {
switch (index) {
case PROPERTY_INDEX_TYPE: {
std::string type_string;
- if (value->GetAsString(&type_string)) {
+ if (value.GetAsString(&type_string)) {
device->set_type(ParseType(type_string));
return true;
}
@@ -161,75 +160,79 @@ bool NativeNetworkDeviceParser::ParseValue(PropertyIndex index,
}
case PROPERTY_INDEX_NAME: {
std::string name;
- if (!value->GetAsString(&name))
+ if (!value.GetAsString(&name))
return false;
device->set_name(name);
return true;
}
case PROPERTY_INDEX_GUID: {
std::string unique_id;
- if (!value->GetAsString(&unique_id))
+ if (!value.GetAsString(&unique_id))
return false;
device->set_unique_id(unique_id);
return true;
}
case PROPERTY_INDEX_CARRIER: {
std::string carrier;
- if (!value->GetAsString(&carrier))
+ if (!value.GetAsString(&carrier))
return false;
device->set_carrier(carrier);
return true;
}
case PROPERTY_INDEX_SCANNING: {
bool scanning;
- if (!value->GetAsBoolean(&scanning))
+ if (!value.GetAsBoolean(&scanning))
return false;
device->set_scanning(scanning);
return true;
}
case PROPERTY_INDEX_CELLULAR_ALLOW_ROAMING: {
bool data_roaming_allowed;
- if (!value->GetAsBoolean(&data_roaming_allowed))
+ if (!value.GetAsBoolean(&data_roaming_allowed))
return false;
device->set_data_roaming_allowed(data_roaming_allowed);
return true;
}
case PROPERTY_INDEX_CELLULAR_APN_LIST:
- if (ListValue* list = value->AsList()) {
+ if (value.IsType(Value::TYPE_LIST)) {
CellularApnList provider_apn_list;
- if (!ParseApnList(*list, &provider_apn_list))
+ if (!ParseApnList(static_cast<const ListValue&>(value),
+ &provider_apn_list))
return false;
device->set_provider_apn_list(provider_apn_list);
return true;
}
break;
case PROPERTY_INDEX_NETWORKS:
- if (value->AsList()) {
+ if (value.IsType(Value::TYPE_LIST)) {
// Ignored.
return true;
}
break;
case PROPERTY_INDEX_FOUND_NETWORKS:
- if (ListValue* list = value->AsList()) {
+ if (value.IsType(Value::TYPE_LIST)) {
CellularNetworkList found_cellular_networks;
- if (!ParseFoundNetworksFromList(*list, &found_cellular_networks))
+ if (!ParseFoundNetworksFromList(
+ static_cast<const ListValue&>(value),
+ &found_cellular_networks))
return false;
device->set_found_cellular_networks(found_cellular_networks);
return true;
}
break;
case PROPERTY_INDEX_HOME_PROVIDER: {
- if (value->IsType(Value::TYPE_DICTIONARY)) {
- DictionaryValue* dict = static_cast<DictionaryValue*>(value);
+ if (value.IsType(Value::TYPE_DICTIONARY)) {
+ const DictionaryValue& dict =
+ static_cast<const DictionaryValue&>(value);
std::string home_provider_code;
std::string home_provider_country;
std::string home_provider_name;
- dict->GetStringWithoutPathExpansion(kOperatorCodeKey,
- &home_provider_code);
- dict->GetStringWithoutPathExpansion(kOperatorCountryKey,
- &home_provider_country);
- dict->GetStringWithoutPathExpansion(kOperatorNameKey,
- &home_provider_name);
+ dict.GetStringWithoutPathExpansion(kOperatorCodeKey,
+ &home_provider_code);
+ dict.GetStringWithoutPathExpansion(kOperatorCountryKey,
+ &home_provider_country);
+ dict.GetStringWithoutPathExpansion(kOperatorNameKey,
+ &home_provider_name);
device->set_home_provider_code(home_provider_code);
device->set_home_provider_country(home_provider_country);
device->set_home_provider_name(home_provider_name);
@@ -260,7 +263,7 @@ bool NativeNetworkDeviceParser::ParseValue(PropertyIndex index,
case PROPERTY_INDEX_HARDWARE_REVISION:
case PROPERTY_INDEX_SELECTED_NETWORK: {
std::string item;
- if (!value->GetAsString(&item))
+ if (!value.GetAsString(&item))
return false;
switch (index) {
case PROPERTY_INDEX_MEID:
@@ -302,11 +305,11 @@ bool NativeNetworkDeviceParser::ParseValue(PropertyIndex index,
return true;
}
case PROPERTY_INDEX_SIM_LOCK:
- if (value->IsType(Value::TYPE_DICTIONARY)) {
+ if (value.IsType(Value::TYPE_DICTIONARY)) {
SimLockState sim_lock_state;
int sim_retries_left;
if (!ParseSimLockStateFromDictionary(
- static_cast<const DictionaryValue&>(*value),
+ static_cast<const DictionaryValue&>(value),
&sim_lock_state,
&sim_retries_left))
return false;
@@ -330,21 +333,21 @@ bool NativeNetworkDeviceParser::ParseValue(PropertyIndex index,
return true;
case PROPERTY_INDEX_PRL_VERSION: {
int prl_version;
- if (!value->GetAsInteger(&prl_version))
+ if (!value.GetAsInteger(&prl_version))
return false;
device->set_prl_version(prl_version);
return true;
}
case PROPERTY_INDEX_SUPPORT_NETWORK_SCAN: {
bool support_network_scan;
- if (!value->GetAsBoolean(&support_network_scan))
+ if (!value.GetAsBoolean(&support_network_scan))
return false;
device->set_support_network_scan(support_network_scan);
return true;
}
case PROPERTY_INDEX_TECHNOLOGY_FAMILY: {
std::string technology_family_string;
- if (value->GetAsString(&technology_family_string)) {
+ if (value.GetAsString(&technology_family_string)) {
device->set_technology_family(
ParseTechnologyFamily(technology_family_string));
return true;
@@ -474,12 +477,12 @@ const ConnectionType NativeNetworkParser::ParseConnectionType(
}
bool NativeNetworkParser::ParseValue(PropertyIndex index,
- Value* value,
+ const Value& value,
Network* network) {
switch (index) {
case PROPERTY_INDEX_TYPE: {
std::string type_string;
- if (value->GetAsString(&type_string)) {
+ if (value.GetAsString(&type_string)) {
ConnectionType type = ParseType(type_string);
LOG_IF(ERROR, type != network->type())
<< "Network with mismatched type: " << network->service_path()
@@ -490,21 +493,21 @@ bool NativeNetworkParser::ParseValue(PropertyIndex index,
}
case PROPERTY_INDEX_DEVICE: {
std::string device_path;
- if (!value->GetAsString(&device_path))
+ if (!value.GetAsString(&device_path))
return false;
network->set_device_path(device_path);
return true;
}
case PROPERTY_INDEX_NAME: {
std::string name;
- if (!value->GetAsString(&name))
+ if (!value.GetAsString(&name))
return false;
network->SetName(name);
return true;
}
case PROPERTY_INDEX_GUID: {
std::string unique_id;
- if (!value->GetAsString(&unique_id))
+ if (!value.GetAsString(&unique_id))
return false;
network->set_unique_id(unique_id);
return true;
@@ -512,14 +515,14 @@ bool NativeNetworkParser::ParseValue(PropertyIndex index,
case PROPERTY_INDEX_PROFILE: {
// Note: currently this is only provided for non remembered networks.
std::string profile_path;
- if (!value->GetAsString(&profile_path))
+ if (!value.GetAsString(&profile_path))
return false;
network->set_profile_path(profile_path);
return true;
}
case PROPERTY_INDEX_STATE: {
std::string state_string;
- if (value->GetAsString(&state_string)) {
+ if (value.GetAsString(&state_string)) {
network->SetState(ParseState(state_string));
return true;
}
@@ -527,7 +530,7 @@ bool NativeNetworkParser::ParseValue(PropertyIndex index,
}
case PROPERTY_INDEX_MODE: {
std::string mode_string;
- if (value->GetAsString(&mode_string)) {
+ if (value.GetAsString(&mode_string)) {
network->set_mode(ParseMode(mode_string));
return true;
}
@@ -535,7 +538,7 @@ bool NativeNetworkParser::ParseValue(PropertyIndex index,
}
case PROPERTY_INDEX_ERROR: {
std::string error_string;
- if (value->GetAsString(&error_string)) {
+ if (value.GetAsString(&error_string)) {
network->set_error(ParseError(error_string));
return true;
}
@@ -543,14 +546,14 @@ bool NativeNetworkParser::ParseValue(PropertyIndex index,
}
case PROPERTY_INDEX_CONNECTABLE: {
bool connectable;
- if (!value->GetAsBoolean(&connectable))
+ if (!value.GetAsBoolean(&connectable))
return false;
network->set_connectable(connectable);
return true;
}
case PROPERTY_INDEX_IS_ACTIVE: {
bool is_active;
- if (!value->GetAsBoolean(&is_active))
+ if (!value.GetAsBoolean(&is_active))
return false;
network->set_is_active(is_active);
return true;
@@ -560,21 +563,21 @@ bool NativeNetworkParser::ParseValue(PropertyIndex index,
return true;
case PROPERTY_INDEX_AUTO_CONNECT: {
bool auto_connect;
- if (!value->GetAsBoolean(&auto_connect))
+ if (!value.GetAsBoolean(&auto_connect))
return false;
network->set_auto_connect(auto_connect);
return true;
}
case PROPERTY_INDEX_SAVE_CREDENTIALS: {
bool save_credentials;
- if (!value->GetAsBoolean(&save_credentials))
+ if (!value.GetAsBoolean(&save_credentials))
return false;
network->set_save_credentials(save_credentials);
return true;
}
case PROPERTY_INDEX_PROXY_CONFIG: {
std::string proxy_config;
- if (!value->GetAsString(&proxy_config))
+ if (!value.GetAsString(&proxy_config))
return false;
network->set_proxy_config(proxy_config);
return true;
@@ -657,7 +660,7 @@ NativeWirelessNetworkParser::NativeWirelessNetworkParser() {}
NativeWirelessNetworkParser::~NativeWirelessNetworkParser() {}
bool NativeWirelessNetworkParser::ParseValue(PropertyIndex index,
- Value* value,
+ const Value& value,
Network* network) {
DCHECK_NE(TYPE_ETHERNET, network->type());
DCHECK_NE(TYPE_VPN, network->type());
@@ -665,7 +668,7 @@ bool NativeWirelessNetworkParser::ParseValue(PropertyIndex index,
switch (index) {
case PROPERTY_INDEX_SIGNAL_STRENGTH: {
int strength;
- if (!value->GetAsInteger(&strength))
+ if (!value.GetAsInteger(&strength))
return false;
wireless_network->set_strength(strength);
return true;
@@ -683,14 +686,14 @@ NativeCellularNetworkParser::NativeCellularNetworkParser() {}
NativeCellularNetworkParser::~NativeCellularNetworkParser() {}
bool NativeCellularNetworkParser::ParseValue(PropertyIndex index,
- Value* value,
+ const Value& value,
Network* network) {
DCHECK_EQ(TYPE_CELLULAR, network->type());
CellularNetwork* cellular_network = static_cast<CellularNetwork*>(network);
switch (index) {
case PROPERTY_INDEX_ACTIVATION_STATE: {
std::string activation_state_string;
- if (value->GetAsString(&activation_state_string)) {
+ if (value.GetAsString(&activation_state_string)) {
ActivationState prev_state = cellular_network->activation_state();
cellular_network->set_activation_state(
ParseActivationState(activation_state_string));
@@ -701,23 +704,23 @@ bool NativeCellularNetworkParser::ParseValue(PropertyIndex index,
break;
}
case PROPERTY_INDEX_CELLULAR_APN: {
- if (value->IsType(Value::TYPE_DICTIONARY)) {
- cellular_network->set_apn(static_cast<const DictionaryValue&>(*value));
+ if (value.IsType(Value::TYPE_DICTIONARY)) {
+ cellular_network->set_apn(static_cast<const DictionaryValue&>(value));
return true;
}
break;
}
case PROPERTY_INDEX_CELLULAR_LAST_GOOD_APN: {
- if (value->IsType(Value::TYPE_DICTIONARY)) {
+ if (value.IsType(Value::TYPE_DICTIONARY)) {
cellular_network->set_last_good_apn(
- static_cast<const DictionaryValue&>(*value));
+ static_cast<const DictionaryValue&>(value));
return true;
}
break;
}
case PROPERTY_INDEX_NETWORK_TECHNOLOGY: {
std::string network_technology_string;
- if (value->GetAsString(&network_technology_string)) {
+ if (value.GetAsString(&network_technology_string)) {
cellular_network->set_network_technology(
ParseNetworkTechnology(network_technology_string));
return true;
@@ -726,7 +729,7 @@ bool NativeCellularNetworkParser::ParseValue(PropertyIndex index,
}
case PROPERTY_INDEX_ROAMING_STATE: {
std::string roaming_state_string;
- if (value->GetAsString(&roaming_state_string)) {
+ if (value.GetAsString(&roaming_state_string)) {
cellular_network->set_roaming_state(
ParseRoamingState(roaming_state_string));
return true;
@@ -735,22 +738,22 @@ bool NativeCellularNetworkParser::ParseValue(PropertyIndex index,
}
case PROPERTY_INDEX_OPERATOR_NAME: {
std::string value_str;
- if (!value->GetAsString(&value_str))
+ if (!value.GetAsString(&value_str))
break;
cellular_network->set_operator_name(value_str);
return true;
}
case PROPERTY_INDEX_OPERATOR_CODE: {
std::string value_str;
- if (!value->GetAsString(&value_str))
+ if (!value.GetAsString(&value_str))
break;
cellular_network->set_operator_code(value_str);
return true;
}
case PROPERTY_INDEX_SERVING_OPERATOR: {
- if (value->IsType(Value::TYPE_DICTIONARY)) {
+ if (value.IsType(Value::TYPE_DICTIONARY)) {
const DictionaryValue& dict =
- static_cast<const DictionaryValue&>(*value);
+ static_cast<const DictionaryValue&>(value);
std::string value_str;
dict.GetStringWithoutPathExpansion(kOperatorNameKey, &value_str);
cellular_network->set_operator_name(value_str);
@@ -766,14 +769,14 @@ bool NativeCellularNetworkParser::ParseValue(PropertyIndex index,
}
case PROPERTY_INDEX_PAYMENT_URL: {
std::string value_str;
- if (!value->GetAsString(&value_str))
+ if (!value.GetAsString(&value_str))
break;
cellular_network->set_payment_url(value_str);
return true;
}
case PROPERTY_INDEX_USAGE_URL: {
std::string value_str;
- if (!value->GetAsString(&value_str))
+ if (!value.GetAsString(&value_str))
break;
cellular_network->set_usage_url(value_str);
return true;
@@ -845,14 +848,14 @@ NativeWifiNetworkParser::NativeWifiNetworkParser() {}
NativeWifiNetworkParser::~NativeWifiNetworkParser() {}
bool NativeWifiNetworkParser::ParseValue(PropertyIndex index,
- Value* value,
+ const Value& value,
Network* network) {
DCHECK_EQ(TYPE_WIFI, network->type());
WifiNetwork* wifi_network = static_cast<WifiNetwork*>(network);
switch (index) {
case PROPERTY_INDEX_WIFI_HEX_SSID: {
std::string ssid_hex;
- if (!value->GetAsString(&ssid_hex))
+ if (!value.GetAsString(&ssid_hex))
return false;
wifi_network->SetHexSsid(ssid_hex);
@@ -873,21 +876,21 @@ bool NativeWifiNetworkParser::ParseValue(PropertyIndex index,
}
case PROPERTY_INDEX_GUID: {
std::string unique_id;
- if (!value->GetAsString(&unique_id))
+ if (!value.GetAsString(&unique_id))
break;
wifi_network->set_unique_id(unique_id);
return true;
}
case PROPERTY_INDEX_SECURITY: {
std::string security_string;
- if (!value->GetAsString(&security_string))
+ if (!value.GetAsString(&security_string))
break;
wifi_network->set_encryption(ParseSecurity(security_string));
return true;
}
case PROPERTY_INDEX_PASSPHRASE: {
std::string passphrase;
- if (!value->GetAsString(&passphrase))
+ if (!value.GetAsString(&passphrase))
break;
// Only store the passphrase if we are the owner.
// TODO(stevenjb): Remove this when chromium-os:12948 is resolved.
@@ -897,57 +900,57 @@ bool NativeWifiNetworkParser::ParseValue(PropertyIndex index,
}
case PROPERTY_INDEX_PASSPHRASE_REQUIRED: {
bool passphrase_required;
- value->GetAsBoolean(&passphrase_required);
- if (!value->GetAsBoolean(&passphrase_required))
+ value.GetAsBoolean(&passphrase_required);
+ if (!value.GetAsBoolean(&passphrase_required))
break;
wifi_network->set_passphrase_required(passphrase_required);
return true;
}
case PROPERTY_INDEX_IDENTITY: {
std::string identity;
- if (!value->GetAsString(&identity))
+ if (!value.GetAsString(&identity))
break;
wifi_network->set_identity(identity);
return true;
}
case PROPERTY_INDEX_EAP_IDENTITY: {
std::string eap_identity;
- if (!value->GetAsString(&eap_identity))
+ if (!value.GetAsString(&eap_identity))
break;
wifi_network->set_eap_identity(eap_identity);
return true;
}
case PROPERTY_INDEX_EAP_METHOD: {
std::string eap_method;
- if (!value->GetAsString(&eap_method))
+ if (!value.GetAsString(&eap_method))
break;
wifi_network->set_eap_method(ParseEAPMethod(eap_method));
return true;
}
case PROPERTY_INDEX_EAP_PHASE_2_AUTH: {
std::string eap_phase_2_auth;
- if (!value->GetAsString(&eap_phase_2_auth))
+ if (!value.GetAsString(&eap_phase_2_auth))
break;
wifi_network->set_eap_phase_2_auth(ParseEAPPhase2Auth(eap_phase_2_auth));
return true;
}
case PROPERTY_INDEX_EAP_ANONYMOUS_IDENTITY: {
std::string eap_anonymous_identity;
- if (!value->GetAsString(&eap_anonymous_identity))
+ if (!value.GetAsString(&eap_anonymous_identity))
break;
wifi_network->set_eap_anonymous_identity(eap_anonymous_identity);
return true;
}
case PROPERTY_INDEX_EAP_CERT_ID: {
std::string eap_client_cert_pkcs11_id;
- if (!value->GetAsString(&eap_client_cert_pkcs11_id))
+ if (!value.GetAsString(&eap_client_cert_pkcs11_id))
break;
wifi_network->set_eap_client_cert_pkcs11_id(eap_client_cert_pkcs11_id);
return true;
}
case PROPERTY_INDEX_EAP_CA_CERT_NSS: {
std::string eap_server_ca_cert_nss_nickname;
- if (!value->GetAsString(&eap_server_ca_cert_nss_nickname))
+ if (!value.GetAsString(&eap_server_ca_cert_nss_nickname))
break;
wifi_network->set_eap_server_ca_cert_nss_nickname(
eap_server_ca_cert_nss_nickname);
@@ -955,14 +958,14 @@ bool NativeWifiNetworkParser::ParseValue(PropertyIndex index,
}
case PROPERTY_INDEX_EAP_USE_SYSTEM_CAS: {
bool eap_use_system_cas;
- if (!value->GetAsBoolean(&eap_use_system_cas))
+ if (!value.GetAsBoolean(&eap_use_system_cas))
break;
wifi_network->set_eap_use_system_cas(eap_use_system_cas);
return true;
}
case PROPERTY_INDEX_EAP_PASSWORD: {
std::string eap_passphrase;
- if (!value->GetAsString(&eap_passphrase))
+ if (!value.GetAsString(&eap_passphrase))
break;
wifi_network->set_eap_passphrase(eap_passphrase);
return true;
@@ -1052,14 +1055,14 @@ bool NativeVirtualNetworkParser::UpdateNetworkFromInfo(
}
bool NativeVirtualNetworkParser::ParseValue(PropertyIndex index,
- Value* value,
+ const Value& value,
Network* network) {
DCHECK_EQ(TYPE_VPN, network->type());
VirtualNetwork* virtual_network = static_cast<VirtualNetwork*>(network);
switch (index) {
case PROPERTY_INDEX_PROVIDER: {
- DCHECK_EQ(value->GetType(), Value::TYPE_DICTIONARY);
- const DictionaryValue& dict = static_cast<const DictionaryValue&>(*value);
+ DCHECK_EQ(value.GetType(), Value::TYPE_DICTIONARY);
+ const DictionaryValue& dict = static_cast<const DictionaryValue&>(value);
for (DictionaryValue::key_iterator iter = dict.begin_keys();
iter != dict.end_keys(); ++iter) {
const std::string& key = *iter;
diff --git a/chrome/browser/chromeos/cros/native_network_parser.h b/chrome/browser/chromeos/cros/native_network_parser.h
index 29af4fe..eee1384 100644
--- a/chrome/browser/chromeos/cros/native_network_parser.h
+++ b/chrome/browser/chromeos/cros/native_network_parser.h
@@ -6,8 +6,8 @@
#define CHROME_BROWSER_CHROMEOS_CROS_NATIVE_NETWORK_PARSER_H_
#pragma once
-#include "base/compiler_specific.h" // for OVERRIDE
#include "chrome/browser/chromeos/cros/network_parser.h"
+#include "base/compiler_specific.h" // for OVERRIDE
namespace chromeos {
@@ -18,11 +18,9 @@ class NativeNetworkDeviceParser : public NetworkDeviceParser {
public:
NativeNetworkDeviceParser();
virtual ~NativeNetworkDeviceParser();
-
virtual bool ParseValue(PropertyIndex index,
- Value* value,
+ const Value& value,
NetworkDevice* device) OVERRIDE;
-
protected:
virtual ConnectionType ParseType(const std::string& type) OVERRIDE;
@@ -48,13 +46,11 @@ class NativeNetworkParser : public NetworkParser {
public:
NativeNetworkParser();
virtual ~NativeNetworkParser();
-
static const EnumMapper<PropertyIndex>* property_mapper();
static const ConnectionType ParseConnectionType(const std::string& type);
-
protected:
virtual bool ParseValue(PropertyIndex index,
- Value* value,
+ const Value& value,
Network* network) OVERRIDE;
virtual ConnectionType ParseType(const std::string& type) OVERRIDE;
virtual ConnectionType ParseTypeFromDictionary(
@@ -62,7 +58,6 @@ class NativeNetworkParser : public NetworkParser {
virtual ConnectionMode ParseMode(const std::string& mode) OVERRIDE;
virtual ConnectionState ParseState(const std::string& state) OVERRIDE;
virtual ConnectionError ParseError(const std::string& error) OVERRIDE;
-
private:
DISALLOW_COPY_AND_ASSIGN(NativeNetworkParser);
};
@@ -72,7 +67,6 @@ class NativeEthernetNetworkParser : public NativeNetworkParser {
public:
NativeEthernetNetworkParser();
virtual ~NativeEthernetNetworkParser();
-
private:
// NOTE: Uses base class ParseValue, etc.
@@ -85,9 +79,8 @@ class NativeWirelessNetworkParser : public NativeNetworkParser {
NativeWirelessNetworkParser();
virtual ~NativeWirelessNetworkParser();
virtual bool ParseValue(PropertyIndex index,
- Value* value,
+ const Value& value,
Network* network) OVERRIDE;
-
private:
DISALLOW_COPY_AND_ASSIGN(NativeWirelessNetworkParser);
};
@@ -97,14 +90,12 @@ class NativeWifiNetworkParser : public NativeWirelessNetworkParser {
NativeWifiNetworkParser();
virtual ~NativeWifiNetworkParser();
virtual bool ParseValue(PropertyIndex index,
- Value* value,
+ const Value& value,
Network* network) OVERRIDE;
-
protected:
ConnectionSecurity ParseSecurity(const std::string& security);
EAPMethod ParseEAPMethod(const std::string& method);
EAPPhase2Auth ParseEAPPhase2Auth(const std::string& auth);
-
private:
DISALLOW_COPY_AND_ASSIGN(NativeWifiNetworkParser);
};
@@ -114,14 +105,14 @@ class NativeCellularNetworkParser : public NativeWirelessNetworkParser {
NativeCellularNetworkParser();
virtual ~NativeCellularNetworkParser();
virtual bool ParseValue(PropertyIndex index,
- Value* value,
+ const Value& value,
Network* network) OVERRIDE;
-
protected:
ActivationState ParseActivationState(const std::string& state);
- NetworkTechnology ParseNetworkTechnology(const std::string& technology);
- NetworkRoamingState ParseRoamingState(const std::string& roaming_state);
-
+ NetworkTechnology ParseNetworkTechnology(
+ const std::string& technology);
+ NetworkRoamingState ParseRoamingState(
+ const std::string& roaming_state);
private:
DISALLOW_COPY_AND_ASSIGN(NativeCellularNetworkParser);
};
@@ -131,21 +122,20 @@ class NativeVirtualNetworkParser : public NativeNetworkParser {
NativeVirtualNetworkParser();
virtual ~NativeVirtualNetworkParser();
virtual bool ParseValue(PropertyIndex index,
- Value* value,
+ const Value& value,
Network* network) OVERRIDE;
virtual bool UpdateNetworkFromInfo(const DictionaryValue& info,
Network* network) OVERRIDE;
-
protected:
bool ParseProviderValue(PropertyIndex index,
- const Value& value,
- VirtualNetwork* network);
+ const Value& value,
+ VirtualNetwork* network);
ProviderType ParseProviderType(const std::string& type);
-
private:
DISALLOW_COPY_AND_ASSIGN(NativeVirtualNetworkParser);
};
+
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_CROS_NATIVE_NETWORK_PARSER_H_
diff --git a/chrome/browser/chromeos/cros/network_library.cc b/chrome/browser/chromeos/cros/network_library.cc
index fb01a4b..847cd1e 100644
--- a/chrome/browser/chromeos/cros/network_library.cc
+++ b/chrome/browser/chromeos/cros/network_library.cc
@@ -183,7 +183,7 @@ void NetworkDevice::ParseInfo(const DictionaryValue& info) {
}
bool NetworkDevice::UpdateStatus(const std::string& key,
- Value* value,
+ const Value& value,
PropertyIndex* index) {
if (device_parser_.get())
return device_parser_->UpdateStatus(key, value, this, index);
@@ -430,7 +430,7 @@ void Network::InitIPAddress() {
}
bool Network::UpdateStatus(const std::string& key,
- Value* value,
+ const Value& value,
PropertyIndex* index) {
if (network_parser_.get())
return network_parser_->UpdateStatus(key, value, this, index);
@@ -2981,14 +2981,13 @@ class NetworkLibraryImplCros : public NetworkLibraryImplBase {
// Calbacks.
static void NetworkStatusChangedHandler(
void* object, const char* path, const char* key, const Value* value);
- void UpdateNetworkStatus(const std::string& path,
- const std::string& key,
- Value* value);
+ void UpdateNetworkStatus(
+ const std::string& path, const std::string& key, const Value& value);
static void NetworkDevicePropertyChangedHandler(
void* object, const char* path, const char* key, const Value* value);
void UpdateNetworkDeviceStatus(
- const std::string& path, const std::string& key, Value* value);
+ const std::string& path, const std::string& key, const Value& value);
static void PinOperationCallback(void* object,
const char* path,
@@ -3175,14 +3174,11 @@ void NetworkLibraryImplCros::NetworkStatusChangedHandler(
DCHECK(networklib);
if (key == NULL || value == NULL || path == NULL || object == NULL)
return;
- networklib->UpdateNetworkStatus(std::string(path),
- std::string(key),
- const_cast<Value*>(value));
+ networklib->UpdateNetworkStatus(std::string(path), std::string(key), *value);
}
-void NetworkLibraryImplCros::UpdateNetworkStatus(const std::string& path,
- const std::string& key,
- Value* value) {
+void NetworkLibraryImplCros::UpdateNetworkStatus(
+ const std::string& path, const std::string& key, const Value& value) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
Network* network = FindNetworkByPath(path);
if (network) {
@@ -3211,12 +3207,11 @@ void NetworkLibraryImplCros::NetworkDevicePropertyChangedHandler(
return;
networklib->UpdateNetworkDeviceStatus(std::string(path),
std::string(key),
- const_cast<Value*>(value));
+ *value);
}
-void NetworkLibraryImplCros::UpdateNetworkDeviceStatus(const std::string& path,
- const std::string& key,
- Value* value) {
+void NetworkLibraryImplCros::UpdateNetworkDeviceStatus(
+ const std::string& path, const std::string& key, const Value& value) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
NetworkDevice* device = FindNetworkDeviceByPath(path);
if (device) {
diff --git a/chrome/browser/chromeos/cros/network_library.h b/chrome/browser/chromeos/cros/network_library.h
index b416214..63f4f55a 100644
--- a/chrome/browser/chromeos/cros/network_library.h
+++ b/chrome/browser/chromeos/cros/network_library.h
@@ -413,7 +413,7 @@ class NetworkDevice {
// PropertyIndex that was updated in |index|. |index| may be NULL
// if not needed.
bool UpdateStatus(const std::string& key,
- Value* value,
+ const Value& value,
PropertyIndex *index);
NativeNetworkDeviceParser* device_parser() { return device_parser_.get(); }
@@ -635,7 +635,7 @@ class Network {
}
virtual bool UpdateStatus(const std::string& key,
- Value* value,
+ const Value& value,
PropertyIndex* index);
protected:
diff --git a/chrome/browser/chromeos/cros/network_parser.cc b/chrome/browser/chromeos/cros/network_parser.cc
index ecdfbdd..5d3dfd4 100644
--- a/chrome/browser/chromeos/cros/network_parser.cc
+++ b/chrome/browser/chromeos/cros/network_parser.cc
@@ -70,7 +70,7 @@ bool NetworkDeviceParser::UpdateDeviceFromInfo(const DictionaryValue& info,
bool result = info.GetWithoutPathExpansion(key, &value);
DCHECK(result);
if (result)
- UpdateStatus(key, value, device, NULL);
+ UpdateStatus(key, *value, device, NULL);
}
if (VLOG_IS_ON(2)) {
std::string json;
@@ -82,7 +82,7 @@ bool NetworkDeviceParser::UpdateDeviceFromInfo(const DictionaryValue& info,
}
bool NetworkDeviceParser::UpdateStatus(const std::string& key,
- Value* value,
+ const Value& value,
NetworkDevice* device,
PropertyIndex* index) {
PropertyIndex found_index = mapper().Get(key);
@@ -94,7 +94,7 @@ bool NetworkDeviceParser::UpdateStatus(const std::string& key,
}
if (VLOG_IS_ON(2)) {
std::string value_json;
- base::JSONWriter::Write(value, true, &value_json);
+ base::JSONWriter::Write(&value, true, &value_json);
VLOG(2) << "Updated value on device: "
<< device->device_path() << "[" << key << "] = " << value_json;
}
@@ -134,7 +134,7 @@ bool NetworkParser::UpdateNetworkFromInfo(const DictionaryValue& info,
bool res = info.GetWithoutPathExpansion(key, &value);
DCHECK(res);
if (res)
- network->UpdateStatus(key, value, NULL);
+ network->UpdateStatus(key, *value, NULL);
}
if (network->unique_id().empty())
network->CalculateUniqueId();
@@ -145,7 +145,7 @@ bool NetworkParser::UpdateNetworkFromInfo(const DictionaryValue& info,
}
bool NetworkParser::UpdateStatus(const std::string& key,
- Value* value,
+ const Value& value,
Network* network,
PropertyIndex* index) {
PropertyIndex found_index = mapper().Get(key);
@@ -159,7 +159,7 @@ bool NetworkParser::UpdateStatus(const std::string& key,
}
if (VLOG_IS_ON(2)) {
std::string value_json;
- base::JSONWriter::Write(value, true, &value_json);
+ base::JSONWriter::Write(&value, true, &value_json);
VLOG(2) << "Updated value on network: "
<< network->unique_id() << "[" << key << "] = " << value_json;
}
@@ -167,12 +167,12 @@ bool NetworkParser::UpdateStatus(const std::string& key,
}
bool NetworkParser::ParseValue(PropertyIndex index,
- Value* value,
+ const Value& value,
Network* network) {
switch (index) {
case PROPERTY_INDEX_TYPE: {
std::string type_string;
- if (value->GetAsString(&type_string)) {
+ if (value.GetAsString(&type_string)) {
ConnectionType type = ParseType(type_string);
LOG_IF(ERROR, type != network->type())
<< "Network with mismatched type: " << network->service_path()
@@ -183,14 +183,14 @@ bool NetworkParser::ParseValue(PropertyIndex index,
}
case PROPERTY_INDEX_DEVICE: {
std::string device_path;
- if (!value->GetAsString(&device_path))
+ if (!value.GetAsString(&device_path))
break;
network->set_device_path(device_path);
return true;
}
case PROPERTY_INDEX_NAME: {
std::string name;
- if (value->GetAsString(&name)) {
+ if (value.GetAsString(&name)) {
network->SetName(name);
return true;
}
@@ -198,7 +198,7 @@ bool NetworkParser::ParseValue(PropertyIndex index,
}
case PROPERTY_INDEX_GUID: {
std::string unique_id;
- if (!value->GetAsString(&unique_id))
+ if (!value.GetAsString(&unique_id))
break;
network->set_unique_id(unique_id);
return true;
@@ -206,14 +206,14 @@ bool NetworkParser::ParseValue(PropertyIndex index,
case PROPERTY_INDEX_PROFILE: {
// Note: currently this is only provided for non remembered networks.
std::string profile_path;
- if (!value->GetAsString(&profile_path))
+ if (!value.GetAsString(&profile_path))
break;
network->set_profile_path(profile_path);
return true;
}
case PROPERTY_INDEX_STATE: {
std::string state_string;
- if (value->GetAsString(&state_string)) {
+ if (value.GetAsString(&state_string)) {
network->SetState(ParseState(state_string));
return true;
}
@@ -221,7 +221,7 @@ bool NetworkParser::ParseValue(PropertyIndex index,
}
case PROPERTY_INDEX_MODE: {
std::string mode_string;
- if (value->GetAsString(&mode_string)) {
+ if (value.GetAsString(&mode_string)) {
network->mode_ = ParseMode(mode_string);
return true;
}
@@ -229,7 +229,7 @@ bool NetworkParser::ParseValue(PropertyIndex index,
}
case PROPERTY_INDEX_ERROR: {
std::string error_string;
- if (value->GetAsString(&error_string)) {
+ if (value.GetAsString(&error_string)) {
network->error_ = ParseError(error_string);
return true;
}
@@ -237,28 +237,28 @@ bool NetworkParser::ParseValue(PropertyIndex index,
}
case PROPERTY_INDEX_CONNECTABLE: {
bool connectable;
- if (!value->GetAsBoolean(&connectable))
+ if (!value.GetAsBoolean(&connectable))
break;
network->set_connectable(connectable);
return true;
}
case PROPERTY_INDEX_IS_ACTIVE: {
bool is_active;
- if (!value->GetAsBoolean(&is_active))
+ if (!value.GetAsBoolean(&is_active))
break;
network->set_is_active(is_active);
return true;
}
case PROPERTY_INDEX_AUTO_CONNECT: {
bool auto_connect;
- if (!value->GetAsBoolean(&auto_connect))
+ if (!value.GetAsBoolean(&auto_connect))
break;
network->set_auto_connect(auto_connect);
return true;
}
case PROPERTY_INDEX_SAVE_CREDENTIALS: {
bool save_credentials;
- if (!value->GetAsBoolean(&save_credentials))
+ if (!value.GetAsBoolean(&save_credentials))
break;
network->set_save_credentials(save_credentials);
return true;
diff --git a/chrome/browser/chromeos/cros/network_parser.h b/chrome/browser/chromeos/cros/network_parser.h
index a06a792..9181551 100644
--- a/chrome/browser/chromeos/cros/network_parser.h
+++ b/chrome/browser/chromeos/cros/network_parser.h
@@ -83,17 +83,16 @@ class NetworkDeviceParser {
virtual bool UpdateDeviceFromInfo(const DictionaryValue& info,
NetworkDevice* device);
virtual bool UpdateStatus(const std::string& key,
- Value* value,
+ const Value& value,
NetworkDevice* device,
PropertyIndex* index);
-
protected:
// The NetworkDeviceParser does not take ownership of the |mapper|.
explicit NetworkDeviceParser(const EnumMapper<PropertyIndex>* mapper);
virtual ~NetworkDeviceParser();
virtual bool ParseValue(PropertyIndex index,
- Value* value,
+ const Value& value,
NetworkDevice* device) = 0;
virtual ConnectionType ParseType(const std::string& type) = 0;
@@ -126,7 +125,7 @@ class NetworkParser {
// property index for the given key. |index| is filled in even if
// the update fails. Returns false upon failure.
virtual bool UpdateStatus(const std::string& key,
- Value* value,
+ const Value& value,
Network* network,
PropertyIndex* index);
protected:
@@ -135,7 +134,7 @@ class NetworkParser {
virtual ~NetworkParser();
virtual bool ParseValue(PropertyIndex index,
- Value* value,
+ const Value& value,
Network* network) = 0;
virtual ConnectionType ParseType(const std::string& type) = 0;
virtual ConnectionType ParseTypeFromDictionary(