summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-26 01:54:00 +0000
committerstevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-26 01:54:00 +0000
commit0de764e26db70294974f67061ab2d991c739e27f (patch)
treec3d7cfa40628e20496f65ce7abd56daebc521077
parent79d0b6726455b644b1a2532cea21a421ce2f9990 (diff)
downloadchromium_src-0de764e26db70294974f67061ab2d991c739e27f.zip
chromium_src-0de764e26db70294974f67061ab2d991c739e27f.tar.gz
chromium_src-0de764e26db70294974f67061ab2d991c739e27f.tar.bz2
Revert recent changes to base::Value
Reverts: 98223: base: Add AsList() function to Value API. 98266: base: Add AsBinary() function to Value API. There are two issues with these commits: 1. libcros uses base::Value to pass data to Chrome. It includes values.h from libchrome which contains its own copy. This is a terrible design flaw in libcros and is being addressed (http://crosbug.com/19576), however we need some time to address this before we can make these changes without breaking Chrome on ChromeOS. 2. AsList() and AsBinary() should be const. The fact that they were not const caused re-factoring that changed const Value& input arguments to Value*, which is against the spec. When we re-introduce this, these members should be made const. BUG=chromium-os:19604 TEST=Check bots + ChromeOS autotests Review URL: http://codereview.chromium.org/7753020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98378 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/json/json_reader_unittest.cc20
-rw-r--r--base/values.cc34
-rw-r--r--base/values.h5
-rw-r--r--base/values_unittest.cc17
-rw-r--r--chrome/browser/autocomplete/search_provider.cc11
-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
-rw-r--r--chrome/browser/extensions/extension_bookmarks_module.cc3
-rw-r--r--chrome/browser/extensions/extension_tabs_module.cc3
-rw-r--r--chrome/browser/extensions/extension_webrequest_api_unittest.cc9
-rw-r--r--chrome/common/json_value_serializer_unittest.cc10
-rw-r--r--chrome/renderer/extensions/extension_process_bindings.cc4
-rw-r--r--chrome/test/automation/automation_json_requests.cc8
-rw-r--r--chrome/test/automation/javascript_execution_controller.cc6
-rw-r--r--chrome/test/automation/javascript_message_utils.h6
-rw-r--r--chrome/test/automation/tab_proxy.cc12
-rw-r--r--chrome/test/automation/value_conversion_traits.cc7
-rw-r--r--chrome/test/base/ui_test_utils.cc8
-rw-r--r--chrome/test/perf/dom_checker_uitest.cc7
-rw-r--r--chrome/test/webdriver/commands/response.cc2
-rw-r--r--chrome/test/webdriver/commands/response.h2
-rw-r--r--chrome/test/webdriver/webdriver_dispatch.cc9
-rw-r--r--chrome/test/webdriver/webdriver_session.cc4
-rw-r--r--content/browser/speech/speech_recognition_request.cc4
-rw-r--r--content/renderer/web_ui_bindings.cc2
29 files changed, 218 insertions, 248 deletions
diff --git a/base/json/json_reader_unittest.cc b/base/json/json_reader_unittest.cc
index 7623a68..a7aeaf0 100644
--- a/base/json/json_reader_unittest.cc
+++ b/base/json/json_reader_unittest.cc
@@ -222,8 +222,8 @@ TEST(JSONReaderTest, Reading) {
// Basic array
root.reset(JSONReader::Read("[true, false, null]", false));
ASSERT_TRUE(root.get());
- ListValue* list = root->AsList();
- ASSERT_TRUE(list);
+ ASSERT_TRUE(root->IsType(Value::TYPE_LIST));
+ ListValue* list = static_cast<ListValue*>(root.get());
ASSERT_EQ(3U, list->GetSize());
// Test with trailing comma. Should be parsed the same as above.
@@ -234,16 +234,16 @@ TEST(JSONReaderTest, Reading) {
// Empty array
root.reset(JSONReader::Read("[]", false));
ASSERT_TRUE(root.get());
- list = root->AsList();
- ASSERT_TRUE(list);
+ ASSERT_TRUE(root->IsType(Value::TYPE_LIST));
+ list = static_cast<ListValue*>(root.get());
ASSERT_EQ(0U, list->GetSize());
// Nested arrays
root.reset(JSONReader::Read("[[true], [], [false, [], [null]], null]",
false));
ASSERT_TRUE(root.get());
- list = root->AsList();
- ASSERT_TRUE(list);
+ ASSERT_TRUE(root->IsType(Value::TYPE_LIST));
+ list = static_cast<ListValue*>(root.get());
ASSERT_EQ(4U, list->GetSize());
// Lots of trailing commas.
@@ -272,8 +272,8 @@ TEST(JSONReaderTest, Reading) {
// Valid if we set |allow_trailing_comma| to true.
root.reset(JSONReader::Read("[true,]", true));
ASSERT_TRUE(root.get());
- list = root->AsList();
- ASSERT_TRUE(list);
+ ASSERT_TRUE(root->IsType(Value::TYPE_LIST));
+ list = static_cast<ListValue*>(root.get());
EXPECT_EQ(1U, list->GetSize());
Value* tmp_value = NULL;
ASSERT_TRUE(list->Get(0, &tmp_value));
@@ -435,8 +435,8 @@ TEST(JSONReaderTest, Reading) {
not_evil.append("[]]");
root.reset(JSONReader::Read(not_evil, false));
ASSERT_TRUE(root.get());
- list = root->AsList();
- ASSERT_TRUE(list);
+ ASSERT_TRUE(root->IsType(Value::TYPE_LIST));
+ list = static_cast<ListValue*>(root.get());
ASSERT_EQ(5001U, list->GetSize());
// Test utf8 encoded input
diff --git a/base/values.cc b/base/values.cc
index ad53469..17aba16 100644
--- a/base/values.cc
+++ b/base/values.cc
@@ -18,7 +18,7 @@ Value* CopyWithoutEmptyChildren(Value* node) {
DCHECK(node);
switch (node->GetType()) {
case Value::TYPE_LIST: {
- ListValue* list = node->AsList();
+ ListValue* list = static_cast<ListValue*>(node);
ListValue* copy = new ListValue;
for (ListValue::const_iterator it = list->begin(); it != list->end();
++it) {
@@ -97,14 +97,6 @@ StringValue* Value::CreateStringValue(const string16& in_value) {
return new StringValue(in_value);
}
-BinaryValue* Value::AsBinary() {
- return NULL;
-}
-
-ListValue* Value::AsList() {
- return NULL;
-}
-
bool Value::GetAsBoolean(bool* out_value) const {
return false;
}
@@ -305,10 +297,6 @@ BinaryValue* BinaryValue::CreateWithCopiedBuffer(const char* buffer,
return new BinaryValue(buffer_copy, size);
}
-BinaryValue* BinaryValue::AsBinary() {
- return this;
-}
-
BinaryValue* BinaryValue::DeepCopy() const {
return CreateWithCopiedBuffer(buffer_, size_);
}
@@ -497,11 +485,11 @@ bool DictionaryValue::GetBinary(const std::string& path,
BinaryValue** out_value) const {
Value* value;
bool result = Get(path, &value);
- if (!result || !value->AsBinary())
+ if (!result || !value->IsType(TYPE_BINARY))
return false;
if (out_value)
- *out_value = value->AsBinary();
+ *out_value = static_cast<BinaryValue*>(value);
return true;
}
@@ -523,11 +511,11 @@ bool DictionaryValue::GetList(const std::string& path,
ListValue** out_value) const {
Value* value;
bool result = Get(path, &value);
- if (!result || !value->AsList())
+ if (!result || !value->IsType(TYPE_LIST))
return false;
if (out_value)
- *out_value = value->AsList();
+ *out_value = static_cast<ListValue*>(value);
return true;
}
@@ -601,11 +589,11 @@ bool DictionaryValue::GetListWithoutPathExpansion(const std::string& key,
ListValue** out_value) const {
Value* value;
bool result = GetWithoutPathExpansion(key, &value);
- if (!result || !value->AsList())
+ if (!result || !value->IsType(TYPE_LIST))
return false;
if (out_value)
- *out_value = value->AsList();
+ *out_value = static_cast<ListValue*>(value);
return true;
}
@@ -814,11 +802,11 @@ bool ListValue::GetDictionary(size_t index, DictionaryValue** out_value) const {
bool ListValue::GetList(size_t index, ListValue** out_value) const {
Value* value;
bool result = Get(index, &value);
- if (!result || !value->AsList())
+ if (!result || !value->IsType(TYPE_LIST))
return false;
if (out_value)
- *out_value = value->AsList();
+ *out_value = static_cast<ListValue*>(value);
return true;
}
@@ -877,10 +865,6 @@ bool ListValue::Insert(size_t index, Value* in_value) {
return true;
}
-ListValue* ListValue::AsList() {
- return this;
-}
-
bool ListValue::GetAsList(ListValue** out_value) {
if (out_value)
*out_value = this;
diff --git a/base/values.h b/base/values.h
index 185729d..a30791b 100644
--- a/base/values.h
+++ b/base/values.h
@@ -87,9 +87,6 @@ class BASE_EXPORT Value {
// Returns true if the current object represents a given type.
bool IsType(Type type) const { return type == type_; }
- virtual BinaryValue* AsBinary();
- virtual ListValue* AsList();
-
// These methods allow the convenient retrieval of settings.
// If the current setting object can be converted into the given type,
// the value is returned through the |out_value| parameter and true is
@@ -196,7 +193,6 @@ class BASE_EXPORT BinaryValue: public Value {
const char* GetBuffer() const { return buffer_; }
// Overridden from Value:
- virtual BinaryValue* AsBinary() OVERRIDE;
virtual BinaryValue* DeepCopy() const OVERRIDE;
virtual bool Equals(const Value* other) const OVERRIDE;
@@ -435,7 +431,6 @@ class BASE_EXPORT ListValue : public Value {
const_iterator end() const { return list_.end(); }
// Overridden from Value:
- virtual ListValue* AsList() OVERRIDE;
virtual bool GetAsList(ListValue** out_value) OVERRIDE;
virtual bool GetAsList(const ListValue** out_value) const OVERRIDE;
virtual ListValue* DeepCopy() const OVERRIDE;
diff --git a/base/values_unittest.cc b/base/values_unittest.cc
index 0ca19d9..553e8e1 100644
--- a/base/values_unittest.cc
+++ b/base/values_unittest.cc
@@ -416,20 +416,21 @@ TEST(ValuesTest, DeepCopy) {
ASSERT_TRUE(copy_dict->Get("binary", &copy_binary));
ASSERT_TRUE(copy_binary);
ASSERT_NE(copy_binary, original_binary);
- BinaryValue* binary_value = copy_binary->AsBinary();
- ASSERT_TRUE(binary_value);
- ASSERT_NE(original_binary->GetBuffer(), binary_value->GetBuffer());
- ASSERT_EQ(original_binary->GetSize(), binary_value->GetSize());
+ ASSERT_TRUE(copy_binary->IsType(Value::TYPE_BINARY));
+ ASSERT_NE(original_binary->GetBuffer(),
+ static_cast<BinaryValue*>(copy_binary)->GetBuffer());
+ ASSERT_EQ(original_binary->GetSize(),
+ static_cast<BinaryValue*>(copy_binary)->GetSize());
ASSERT_EQ(0, memcmp(original_binary->GetBuffer(),
- binary_value->GetBuffer(),
- original_binary->GetSize()));
+ static_cast<BinaryValue*>(copy_binary)->GetBuffer(),
+ original_binary->GetSize()));
Value* copy_value = NULL;
ASSERT_TRUE(copy_dict->Get("list", &copy_value));
ASSERT_TRUE(copy_value);
ASSERT_NE(copy_value, original_list);
- ListValue* copy_list = copy_value->AsList();
- ASSERT_TRUE(copy_list != NULL);
+ ASSERT_TRUE(copy_value->IsType(Value::TYPE_LIST));
+ ListValue* copy_list = static_cast<ListValue*>(copy_value);
ASSERT_EQ(2U, copy_list->GetSize());
Value* copy_list_element_0;
diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc
index 8bd3478..1dae40a 100644
--- a/chrome/browser/autocomplete/search_provider.cc
+++ b/chrome/browser/autocomplete/search_provider.cc
@@ -452,9 +452,9 @@ bool SearchProvider::ParseSuggestResults(Value* root_val,
bool is_keyword,
const string16& input_text,
SuggestResults* suggest_results) {
- ListValue* root_list = root_val->AsList();
- if (!root_list)
+ if (!root_val->IsType(Value::TYPE_LIST))
return false;
+ ListValue* root_list = static_cast<ListValue*>(root_val);
Value* query_val;
string16 query_str;
@@ -462,15 +462,16 @@ bool SearchProvider::ParseSuggestResults(Value* root_val,
if ((root_list->GetSize() < 2) || !root_list->Get(0, &query_val) ||
!query_val->GetAsString(&query_str) ||
(query_str != input_text) ||
- !root_list->Get(1, &result_val) || !result_val->AsList())
+ !root_list->Get(1, &result_val) || !result_val->IsType(Value::TYPE_LIST))
return false;
ListValue* description_list = NULL;
if (root_list->GetSize() > 2) {
// 3rd element: Description list.
Value* description_val;
- if (root_list->Get(2, &description_val))
- description_list = description_val->AsList();
+ if (root_list->Get(2, &description_val) &&
+ description_val->IsType(Value::TYPE_LIST))
+ description_list = static_cast<ListValue*>(description_val);
}
// We don't care about the query URL list (the fourth element in the
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(
diff --git a/chrome/browser/extensions/extension_bookmarks_module.cc b/chrome/browser/extensions/extension_bookmarks_module.cc
index f8b2c78..dce4b6f 100644
--- a/chrome/browser/extensions/extension_bookmarks_module.cc
+++ b/chrome/browser/extensions/extension_bookmarks_module.cc
@@ -285,7 +285,8 @@ bool GetBookmarksFunction::RunImpl() {
scoped_ptr<ListValue> json(new ListValue());
Value* arg0;
EXTENSION_FUNCTION_VALIDATE(args_->Get(0, &arg0));
- if (const ListValue* ids = arg0->AsList()) {
+ if (arg0->IsType(Value::TYPE_LIST)) {
+ const ListValue* ids = static_cast<const ListValue*>(arg0);
size_t count = ids->GetSize();
EXTENSION_FUNCTION_VALIDATE(count > 0);
for (size_t i = 0; i < count; ++i) {
diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc
index 9a6ded9..a949b4d 100644
--- a/chrome/browser/extensions/extension_tabs_module.cc
+++ b/chrome/browser/extensions/extension_tabs_module.cc
@@ -417,7 +417,8 @@ bool CreateWindowFunction::RunImpl() {
std::string url_string;
url_value->GetAsString(&url_string);
url_strings.push_back(url_string);
- } else if (const ListValue* url_list = url_value->AsList()) {
+ } else if (url_value->IsType(Value::TYPE_LIST)) {
+ const ListValue* url_list = static_cast<const ListValue*>(url_value);
for (size_t i = 0; i < url_list->GetSize(); ++i) {
std::string url_string;
EXTENSION_FUNCTION_VALIDATE(url_list->GetString(i, &url_string));
diff --git a/chrome/browser/extensions/extension_webrequest_api_unittest.cc b/chrome/browser/extensions/extension_webrequest_api_unittest.cc
index 0791a71..8398433 100644
--- a/chrome/browser/extensions/extension_webrequest_api_unittest.cc
+++ b/chrome/browser/extensions/extension_webrequest_api_unittest.cc
@@ -477,12 +477,13 @@ TEST_P(ExtensionWebRequestHeaderModificationTest, TestModifications) {
scoped_ptr<Value> event_arg_value(
JSONStringValueSerializer(event_arg_string).Deserialize(NULL, NULL));
- ASSERT_TRUE(event_arg_value.get());
- ListValue* list = event_arg_value->AsList();
- ASSERT_TRUE(list);
+ ASSERT_TRUE(event_arg_value.get() &&
+ event_arg_value->IsType(Value::TYPE_LIST));
DictionaryValue* event_arg_dict = NULL;
- ASSERT_TRUE(list->GetDictionary(0, &event_arg_dict));
+ ASSERT_TRUE(
+ static_cast<ListValue*>(event_arg_value.get())->GetDictionary(
+ 0, &event_arg_dict));
ListValue* request_headers = NULL;
ASSERT_TRUE(event_arg_dict->GetList(keys::kRequestHeadersKey,
diff --git a/chrome/common/json_value_serializer_unittest.cc b/chrome/common/json_value_serializer_unittest.cc
index abb3684..541ac8c 100644
--- a/chrome/common/json_value_serializer_unittest.cc
+++ b/chrome/common/json_value_serializer_unittest.cc
@@ -195,9 +195,8 @@ namespace {
void ValidateJsonList(const std::string& json) {
scoped_ptr<Value> root(base::JSONReader::Read(json, false));
- ASSERT_TRUE(root.get());
- ListValue* list = root->AsList();
- ASSERT_TRUE(list);
+ ASSERT_TRUE(root.get() && root->IsType(Value::TYPE_LIST));
+ ListValue* list = static_cast<ListValue*>(root.get());
ASSERT_EQ(1U, list->GetSize());
Value* elt = NULL;
ASSERT_TRUE(list->Get(0, &elt));
@@ -220,9 +219,8 @@ TEST(JSONValueSerializerTest, JSONReaderComments) {
// It's ok to have a comment in a string.
root.reset(base::JSONReader::Read("[\"// ok\\n /* foo */ \"]", false));
- ASSERT_TRUE(root.get());
- ListValue* list = root->AsList();
- ASSERT_TRUE(list);
+ ASSERT_TRUE(root.get() && root->IsType(Value::TYPE_LIST));
+ ListValue* list = static_cast<ListValue*>(root.get());
ASSERT_EQ(1U, list->GetSize());
Value* elt = NULL;
ASSERT_TRUE(list->Get(0, &elt));
diff --git a/chrome/renderer/extensions/extension_process_bindings.cc b/chrome/renderer/extensions/extension_process_bindings.cc
index 077c524..d96743c 100644
--- a/chrome/renderer/extensions/extension_process_bindings.cc
+++ b/chrome/renderer/extensions/extension_process_bindings.cc
@@ -467,12 +467,12 @@ class ExtensionImpl : public ExtensionBase {
// Since we do the serialization in the v8 extension, we should always get
// valid JSON.
- if (!value_args.get() || !value_args->AsList()) {
+ if (!value_args.get() || !value_args->IsType(Value::TYPE_LIST)) {
NOTREACHED() << "Invalid JSON passed to StartRequest.";
return v8::Undefined();
}
- return StartRequestCommon(args, value_args->AsList());
+ return StartRequestCommon(args, static_cast<ListValue*>(value_args.get()));
}
static bool ConvertImageDataToBitmapValue(
diff --git a/chrome/test/automation/automation_json_requests.cc b/chrome/test/automation/automation_json_requests.cc
index ecd932e..ab0de31 100644
--- a/chrome/test/automation/automation_json_requests.cc
+++ b/chrome/test/automation/automation_json_requests.cc
@@ -187,11 +187,11 @@ bool SendExecuteJavascriptJSONRequest(
JSONStringValueSerializer deserializer(json);
Value* value = deserializer.Deserialize(NULL, NULL);
- if (!value || !value->AsList()) {
+ if (!value || !value->IsType(Value::TYPE_LIST)) {
LOG(ERROR) << "Unable to deserialize returned JSON";
return false;
}
- scoped_ptr<ListValue> list(value->AsList());
+ scoped_ptr<ListValue> list(static_cast<ListValue*>(value));
return list->Remove(0, result);
}
@@ -297,9 +297,9 @@ bool SendGetCookiesJSONRequest(
if (!reply_dict.Remove("cookies", &cookies_unscoped_value))
return false;
scoped_ptr<Value> cookies_value(cookies_unscoped_value);
- if (!cookies_value->AsList())
+ if (!cookies_value->IsType(Value::TYPE_LIST))
return false;
- *cookies = cookies_value->AsList();
+ *cookies = static_cast<ListValue*>(cookies_value.release());
return true;
}
diff --git a/chrome/test/automation/javascript_execution_controller.cc b/chrome/test/automation/javascript_execution_controller.cc
index e4702c5..5be6b98 100644
--- a/chrome/test/automation/javascript_execution_controller.cc
+++ b/chrome/test/automation/javascript_execution_controller.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -89,11 +89,11 @@ bool JavaScriptExecutionController::ExecuteAndParseHelper(
bool success;
std::string evaluation_error;
Value* evaluation_result_value;
- ListValue* list = root_value->AsList();
- if (!list) {
+ if (!root_value->IsType(Value::TYPE_LIST)) {
LOG(ERROR) << "JSON response was not in correct format";
return false;
}
+ ListValue* list = static_cast<ListValue*>(root_value.get());
if (!list->GetBoolean(0, &success) ||
!list->GetString(1, &evaluation_error) ||
!list->Remove(2, &evaluation_result_value)) {
diff --git a/chrome/test/automation/javascript_message_utils.h b/chrome/test/automation/javascript_message_utils.h
index 1ccdc17..e4b61f4 100644
--- a/chrome/test/automation/javascript_message_utils.h
+++ b/chrome/test/automation/javascript_message_utils.h
@@ -51,11 +51,11 @@ struct ValueConversionTraits<std::vector<T> > {
}
return value;
}
- static bool SetFromValue(Value* value, std::vector<T>* t) {
- ListValue* list_value = value->AsList();
- if (!list_value)
+ static bool SetFromValue(const Value* value, std::vector<T>* t) {
+ if (!value->IsType(Value::TYPE_LIST))
return false;
+ const ListValue* list_value = static_cast<const ListValue*>(value);
ListValue::const_iterator iter;
for (iter = list_value->begin(); iter != list_value->end(); ++iter) {
if (!ValueConversionTraits<T>::CanConvert(*iter))
diff --git a/chrome/test/automation/tab_proxy.cc b/chrome/test/automation/tab_proxy.cc
index d30fd7d..49cd00c 100644
--- a/chrome/test/automation/tab_proxy.cc
+++ b/chrome/test/automation/tab_proxy.cc
@@ -266,9 +266,9 @@ bool TabProxy::ExecuteAndExtractString(const std::wstring& frame_xpath,
if (!succeeded)
return false;
- DCHECK(root->AsList());
+ DCHECK(root->IsType(Value::TYPE_LIST));
Value* value = NULL;
- succeeded = root->AsList()->Get(0, &value);
+ succeeded = static_cast<ListValue*>(root)->Get(0, &value);
if (succeeded) {
string16 read_value;
succeeded = value->GetAsString(&read_value);
@@ -291,9 +291,9 @@ bool TabProxy::ExecuteAndExtractBool(const std::wstring& frame_xpath,
return false;
bool read_value = false;
- DCHECK(root->AsList());
+ DCHECK(root->IsType(Value::TYPE_LIST));
Value* value = NULL;
- succeeded = root->AsList()->Get(0, &value);
+ succeeded = static_cast<ListValue*>(root)->Get(0, &value);
if (succeeded) {
succeeded = value->GetAsBoolean(&read_value);
if (succeeded) {
@@ -314,9 +314,9 @@ bool TabProxy::ExecuteAndExtractInt(const std::wstring& frame_xpath,
return false;
int read_value = 0;
- DCHECK(root->AsList());
+ DCHECK(root->IsType(Value::TYPE_LIST));
Value* value = NULL;
- succeeded = root->AsList()->Get(0, &value);
+ succeeded = static_cast<ListValue*>(root)->Get(0, &value);
if (succeeded) {
succeeded = value->GetAsInteger(&read_value);
if (succeeded) {
diff --git a/chrome/test/automation/value_conversion_traits.cc b/chrome/test/automation/value_conversion_traits.cc
index 16d6510..f5c1f2c 100644
--- a/chrome/test/automation/value_conversion_traits.cc
+++ b/chrome/test/automation/value_conversion_traits.cc
@@ -71,15 +71,14 @@ Value* ValueConversionTraits<ListValue*>::CreateValueFrom(const ListValue* t) {
bool ValueConversionTraits<ListValue*>::SetFromValue(const Value* value,
ListValue** t) {
- ListValue* list = const_cast<Value*>(value)->AsList();
- if (!list)
+ if (!value->IsType(Value::TYPE_LIST))
return false;
- *t = list->DeepCopy();
+ *t = static_cast<const ListValue*>(value)->DeepCopy();
return true;
}
bool ValueConversionTraits<ListValue*>::CanConvert(const Value* value) {
- return const_cast<Value*>(value)->AsList();
+ return value->IsType(Value::TYPE_LIST);
}
Value* ValueConversionTraits<DictionaryValue*>::CreateValueFrom(
diff --git a/chrome/test/base/ui_test_utils.cc b/chrome/test/base/ui_test_utils.cc
index 2234ba2..d087e68 100644
--- a/chrome/test/base/ui_test_utils.cc
+++ b/chrome/test/base/ui_test_utils.cc
@@ -206,10 +206,10 @@ bool ExecuteJavaScriptHelper(RenderViewHost* render_view_host,
json.append("]");
scoped_ptr<Value> root_val(base::JSONReader::Read(json, true));
- ListValue* list = root_val->AsList();
- if (!list)
+ if (!root_val->IsType(Value::TYPE_LIST))
return false;
+ ListValue* list = static_cast<ListValue*>(root_val.get());
Value* result_val;
if (!list || !list->GetSize() ||
!list->Remove(0, &result_val)) // Remove gives us ownership of the value.
@@ -925,9 +925,9 @@ class SnapshotTaker {
// Parse the JSON.
std::vector<int> dimensions;
scoped_ptr<Value> value(base::JSONReader::Read(json, true));
- ListValue* list = value->AsList();
- if (!list)
+ if (!value->IsType(Value::TYPE_LIST))
return false;
+ ListValue* list = static_cast<ListValue*>(value.get());
int width, height;
if (!list->GetInteger(0, &width) || !list->GetInteger(1, &height))
return false;
diff --git a/chrome/test/perf/dom_checker_uitest.cc b/chrome/test/perf/dom_checker_uitest.cc
index deceb9e..8255a94 100644
--- a/chrome/test/perf/dom_checker_uitest.cc
+++ b/chrome/test/perf/dom_checker_uitest.cc
@@ -175,11 +175,12 @@ class DomCheckerTest : public UITest {
if (!value.get())
return false;
- EXPECT_TRUE(value->AsList());
- ListValue* list_value = value->AsList();
- if (!list_value)
+ EXPECT_TRUE(value->IsType(Value::TYPE_LIST));
+ if (!value->IsType(Value::TYPE_LIST))
return false;
+ ListValue* list_value = static_cast<ListValue*>(value.get());
+
// The parsed JSON object will be an array of strings, each of which is a
// test failure. Add those strings to the results set.
ListValue::const_iterator it = list_value->begin();
diff --git a/chrome/test/webdriver/commands/response.cc b/chrome/test/webdriver/commands/response.cc
index 882dbeb..1c09d39 100644
--- a/chrome/test/webdriver/commands/response.cc
+++ b/chrome/test/webdriver/commands/response.cc
@@ -46,7 +46,7 @@ void Response::SetStatus(ErrorCode status) {
data_.SetInteger(kStatusKey, status);
}
-Value* Response::GetValue() const {
+const Value* Response::GetValue() const {
Value* out = NULL;
LOG_IF(WARNING, !data_.Get(kValueKey, &out))
<< "Accessing unset response value."; // Should never happen.
diff --git a/chrome/test/webdriver/commands/response.h b/chrome/test/webdriver/commands/response.h
index 0d25c48..9c44e60 100644
--- a/chrome/test/webdriver/commands/response.h
+++ b/chrome/test/webdriver/commands/response.h
@@ -28,7 +28,7 @@ class Response {
void SetStatus(ErrorCode status);
// Ownership of the returned pointer is kept by this object.
- Value* GetValue() const;
+ const Value* GetValue() const;
// Sets the |value| of this response, assuming ownership of the object in the
// process.
diff --git a/chrome/test/webdriver/webdriver_dispatch.cc b/chrome/test/webdriver/webdriver_dispatch.cc
index e079f12..a9dcd4a 100644
--- a/chrome/test/webdriver/webdriver_dispatch.cc
+++ b/chrome/test/webdriver/webdriver_dispatch.cc
@@ -152,7 +152,7 @@ void PrepareHttpResponse(const Response& command_response,
// and kMethodNotAllowed should be detected before creating
// a command_response, and should thus not need conversion.
case kSeeOther: {
- Value* value = command_response.GetValue();
+ const Value* const value = command_response.GetValue();
std::string location;
if (!value->GetAsString(&location)) {
// This should never happen.
@@ -173,9 +173,8 @@ void PrepareHttpResponse(const Response& command_response,
break;
case kMethodNotAllowed: {
- Value* value = command_response.GetValue();
- ListValue* list_value = value->AsList();
- if (!list_value) {
+ const Value* const value = command_response.GetValue();
+ if (!value->IsType(Value::TYPE_LIST)) {
// This should never happen.
http_response->set_status(HttpResponse::kInternalServerError);
http_response->SetBody(
@@ -184,6 +183,8 @@ void PrepareHttpResponse(const Response& command_response,
return;
}
+ const ListValue* const list_value =
+ static_cast<const ListValue* const>(value);
std::vector<std::string> allowed_methods;
for (size_t i = 0; i < list_value->GetSize(); ++i) {
std::string method;
diff --git a/chrome/test/webdriver/webdriver_session.cc b/chrome/test/webdriver/webdriver_session.cc
index c3a7c11..1a764a8 100644
--- a/chrome/test/webdriver/webdriver_session.cc
+++ b/chrome/test/webdriver/webdriver_session.cc
@@ -1240,9 +1240,9 @@ Error* Session::ExecuteFindElementScriptAndParse(
virtual ~FindElementsParser() { }
virtual bool Parse(base::Value* value) const OVERRIDE {
- ListValue* list = value->AsList();
- if (!list)
+ if (!value->IsType(Value::TYPE_LIST))
return false;
+ ListValue* list = static_cast<ListValue*>(value);
for (size_t i = 0; i < list->GetSize(); ++i) {
ElementId element;
Value* element_value = NULL;
diff --git a/content/browser/speech/speech_recognition_request.cc b/content/browser/speech/speech_recognition_request.cc
index 4cc8e19..645e75d 100644
--- a/content/browser/speech/speech_recognition_request.cc
+++ b/content/browser/speech/speech_recognition_request.cc
@@ -60,12 +60,12 @@ bool ParseServerResponse(const std::string& response_body,
return false;
}
DCHECK(hypotheses_value);
- const ListValue* hypotheses_list = hypotheses_value->AsList();
- if (!hypotheses_list) {
+ if (!hypotheses_value->IsType(Value::TYPE_LIST)) {
VLOG(1) << "ParseServerResponse: Unexpected hypotheses type "
<< hypotheses_value->GetType();
return false;
}
+ const ListValue* hypotheses_list = static_cast<ListValue*>(hypotheses_value);
size_t index = 0;
for (; index < hypotheses_list->GetSize(); ++index) {
diff --git a/content/renderer/web_ui_bindings.cc b/content/renderer/web_ui_bindings.cc
index 98a83c5..97037a4 100644
--- a/content/renderer/web_ui_bindings.cc
+++ b/content/renderer/web_ui_bindings.cc
@@ -77,7 +77,7 @@ void WebUIBindings::send(const CppArgumentList& args, CppVariant* result) {
return;
content.reset(CreateValueFromCppVariant(args[1]));
- CHECK(content->AsList());
+ CHECK(content->IsType(Value::TYPE_LIST));
} else {
content.reset(new ListValue());
}