summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-25 14:03:30 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-25 14:03:30 +0000
commita7f1806937d541ab67e37dcc7451783679599384 (patch)
treeed879290929ef74833ca5e0af979c46a29297456
parent36d11e440238728c7854490485cc00c674a6e420 (diff)
downloadchromium_src-a7f1806937d541ab67e37dcc7451783679599384.zip
chromium_src-a7f1806937d541ab67e37dcc7451783679599384.tar.gz
chromium_src-a7f1806937d541ab67e37dcc7451783679599384.tar.bz2
base: Add AsList() function to Value API.
This function should simplify some constructions. Instead of: if (!value->IsType(Value::TYPE_LIST)) return false; ListValue* list_value = static_cast<ListValue*>(value); You can do: ListValue* list_value = value->AsList(); if (!list_value) return false; BUG=None TEST=base_unittests --gtest_filter=Values* R=evan@chromium.org,tony@chromium.org Review URL: http://codereview.chromium.org/7714004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98223 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/json/json_reader_unittest.cc20
-rw-r--r--base/values.cc14
-rw-r--r--base/values.h3
-rw-r--r--base/values_unittest.cc4
-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, 226 insertions, 205 deletions
diff --git a/base/json/json_reader_unittest.cc b/base/json/json_reader_unittest.cc
index a7aeaf0..7623a68 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());
- ASSERT_TRUE(root->IsType(Value::TYPE_LIST));
- ListValue* list = static_cast<ListValue*>(root.get());
+ ListValue* list = root->AsList();
+ ASSERT_TRUE(list);
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());
- ASSERT_TRUE(root->IsType(Value::TYPE_LIST));
- list = static_cast<ListValue*>(root.get());
+ list = root->AsList();
+ ASSERT_TRUE(list);
ASSERT_EQ(0U, list->GetSize());
// Nested arrays
root.reset(JSONReader::Read("[[true], [], [false, [], [null]], null]",
false));
ASSERT_TRUE(root.get());
- ASSERT_TRUE(root->IsType(Value::TYPE_LIST));
- list = static_cast<ListValue*>(root.get());
+ list = root->AsList();
+ ASSERT_TRUE(list);
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());
- ASSERT_TRUE(root->IsType(Value::TYPE_LIST));
- list = static_cast<ListValue*>(root.get());
+ list = root->AsList();
+ ASSERT_TRUE(list);
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());
- ASSERT_TRUE(root->IsType(Value::TYPE_LIST));
- list = static_cast<ListValue*>(root.get());
+ list = root->AsList();
+ ASSERT_TRUE(list);
ASSERT_EQ(5001U, list->GetSize());
// Test utf8 encoded input
diff --git a/base/values.cc b/base/values.cc
index 17aba16..1798695 100644
--- a/base/values.cc
+++ b/base/values.cc
@@ -97,6 +97,10 @@ StringValue* Value::CreateStringValue(const string16& in_value) {
return new StringValue(in_value);
}
+ListValue* Value::AsList() {
+ return NULL;
+}
+
bool Value::GetAsBoolean(bool* out_value) const {
return false;
}
@@ -511,7 +515,7 @@ bool DictionaryValue::GetList(const std::string& path,
ListValue** out_value) const {
Value* value;
bool result = Get(path, &value);
- if (!result || !value->IsType(TYPE_LIST))
+ if (!result || !value->AsList())
return false;
if (out_value)
@@ -589,7 +593,7 @@ bool DictionaryValue::GetListWithoutPathExpansion(const std::string& key,
ListValue** out_value) const {
Value* value;
bool result = GetWithoutPathExpansion(key, &value);
- if (!result || !value->IsType(TYPE_LIST))
+ if (!result || !value->AsList())
return false;
if (out_value)
@@ -802,7 +806,7 @@ 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->IsType(TYPE_LIST))
+ if (!result || !value->AsList())
return false;
if (out_value)
@@ -865,6 +869,10 @@ 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 a30791b..2f41215 100644
--- a/base/values.h
+++ b/base/values.h
@@ -87,6 +87,8 @@ class BASE_EXPORT Value {
// Returns true if the current object represents a given type.
bool IsType(Type type) const { return type == type_; }
+ 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
@@ -431,6 +433,7 @@ 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 553e8e1..c8d3e3c 100644
--- a/base/values_unittest.cc
+++ b/base/values_unittest.cc
@@ -429,8 +429,8 @@ TEST(ValuesTest, DeepCopy) {
ASSERT_TRUE(copy_dict->Get("list", &copy_value));
ASSERT_TRUE(copy_value);
ASSERT_NE(copy_value, original_list);
- ASSERT_TRUE(copy_value->IsType(Value::TYPE_LIST));
- ListValue* copy_list = static_cast<ListValue*>(copy_value);
+ ListValue* copy_list = copy_value->AsList();
+ ASSERT_TRUE(copy_list != NULL);
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 1dae40a..8bd3478 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) {
- if (!root_val->IsType(Value::TYPE_LIST))
+ ListValue* root_list = root_val->AsList();
+ if (!root_list)
return false;
- ListValue* root_list = static_cast<ListValue*>(root_val);
Value* query_val;
string16 query_str;
@@ -462,16 +462,15 @@ 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->IsType(Value::TYPE_LIST))
+ !root_list->Get(1, &result_val) || !result_val->AsList())
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_val->IsType(Value::TYPE_LIST))
- description_list = static_cast<ListValue*>(description_val);
+ if (root_list->Get(2, &description_val))
+ description_list = description_val->AsList();
}
// 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 3172025..24340b2 100644
--- a/chrome/browser/chromeos/cros/native_network_parser.cc
+++ b/chrome/browser/chromeos/cros/native_network_parser.cc
@@ -147,12 +147,13 @@ NativeNetworkDeviceParser::NativeNetworkDeviceParser()
NativeNetworkDeviceParser::~NativeNetworkDeviceParser() {
}
-bool NativeNetworkDeviceParser::ParseValue(
- PropertyIndex index, const Value& value, NetworkDevice* device) {
+bool NativeNetworkDeviceParser::ParseValue(PropertyIndex index,
+ 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;
}
@@ -160,79 +161,75 @@ bool NativeNetworkDeviceParser::ParseValue(
}
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 (value.IsType(Value::TYPE_LIST)) {
+ if (ListValue* list = value->AsList()) {
CellularApnList provider_apn_list;
- if (!ParseApnList(static_cast<const ListValue&>(value),
- &provider_apn_list))
+ if (!ParseApnList(*list, &provider_apn_list))
return false;
device->set_provider_apn_list(provider_apn_list);
return true;
}
break;
case PROPERTY_INDEX_NETWORKS:
- if (value.IsType(Value::TYPE_LIST)) {
+ if (value->AsList()) {
// Ignored.
return true;
}
break;
case PROPERTY_INDEX_FOUND_NETWORKS:
- if (value.IsType(Value::TYPE_LIST)) {
+ if (ListValue* list = value->AsList()) {
CellularNetworkList found_cellular_networks;
- if (!ParseFoundNetworksFromList(
- static_cast<const ListValue&>(value),
- &found_cellular_networks))
+ if (!ParseFoundNetworksFromList(*list, &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)) {
- const DictionaryValue& dict =
- static_cast<const DictionaryValue&>(value);
+ if (value->IsType(Value::TYPE_DICTIONARY)) {
+ DictionaryValue* dict = static_cast<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);
@@ -263,7 +260,7 @@ bool NativeNetworkDeviceParser::ParseValue(
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:
@@ -305,11 +302,11 @@ bool NativeNetworkDeviceParser::ParseValue(
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;
@@ -333,21 +330,21 @@ bool NativeNetworkDeviceParser::ParseValue(
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;
@@ -477,12 +474,12 @@ const ConnectionType NativeNetworkParser::ParseConnectionType(
}
bool NativeNetworkParser::ParseValue(PropertyIndex index,
- const Value& value,
+ 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()
@@ -493,21 +490,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;
@@ -515,14 +512,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;
}
@@ -530,7 +527,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;
}
@@ -538,7 +535,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;
}
@@ -546,14 +543,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;
@@ -563,21 +560,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;
@@ -660,7 +657,7 @@ NativeWirelessNetworkParser::NativeWirelessNetworkParser() {}
NativeWirelessNetworkParser::~NativeWirelessNetworkParser() {}
bool NativeWirelessNetworkParser::ParseValue(PropertyIndex index,
- const Value& value,
+ Value* value,
Network* network) {
DCHECK_NE(TYPE_ETHERNET, network->type());
DCHECK_NE(TYPE_VPN, network->type());
@@ -668,7 +665,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;
@@ -686,14 +683,14 @@ NativeCellularNetworkParser::NativeCellularNetworkParser() {}
NativeCellularNetworkParser::~NativeCellularNetworkParser() {}
bool NativeCellularNetworkParser::ParseValue(PropertyIndex index,
- const Value& value,
+ 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));
@@ -704,23 +701,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;
@@ -729,7 +726,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;
@@ -738,22 +735,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);
@@ -769,14 +766,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;
@@ -848,14 +845,14 @@ NativeWifiNetworkParser::NativeWifiNetworkParser() {}
NativeWifiNetworkParser::~NativeWifiNetworkParser() {}
bool NativeWifiNetworkParser::ParseValue(PropertyIndex index,
- const Value& value,
+ 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);
@@ -876,21 +873,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.
@@ -900,57 +897,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);
@@ -958,14 +955,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;
@@ -1055,14 +1052,14 @@ bool NativeVirtualNetworkParser::UpdateNetworkFromInfo(
}
bool NativeVirtualNetworkParser::ParseValue(PropertyIndex index,
- const Value& value,
+ 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 eee1384..29af4fe 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 "chrome/browser/chromeos/cros/network_parser.h"
#include "base/compiler_specific.h" // for OVERRIDE
+#include "chrome/browser/chromeos/cros/network_parser.h"
namespace chromeos {
@@ -18,9 +18,11 @@ class NativeNetworkDeviceParser : public NetworkDeviceParser {
public:
NativeNetworkDeviceParser();
virtual ~NativeNetworkDeviceParser();
+
virtual bool ParseValue(PropertyIndex index,
- const Value& value,
+ Value* value,
NetworkDevice* device) OVERRIDE;
+
protected:
virtual ConnectionType ParseType(const std::string& type) OVERRIDE;
@@ -46,11 +48,13 @@ 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,
- const Value& value,
+ Value* value,
Network* network) OVERRIDE;
virtual ConnectionType ParseType(const std::string& type) OVERRIDE;
virtual ConnectionType ParseTypeFromDictionary(
@@ -58,6 +62,7 @@ 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);
};
@@ -67,6 +72,7 @@ class NativeEthernetNetworkParser : public NativeNetworkParser {
public:
NativeEthernetNetworkParser();
virtual ~NativeEthernetNetworkParser();
+
private:
// NOTE: Uses base class ParseValue, etc.
@@ -79,8 +85,9 @@ class NativeWirelessNetworkParser : public NativeNetworkParser {
NativeWirelessNetworkParser();
virtual ~NativeWirelessNetworkParser();
virtual bool ParseValue(PropertyIndex index,
- const Value& value,
+ Value* value,
Network* network) OVERRIDE;
+
private:
DISALLOW_COPY_AND_ASSIGN(NativeWirelessNetworkParser);
};
@@ -90,12 +97,14 @@ class NativeWifiNetworkParser : public NativeWirelessNetworkParser {
NativeWifiNetworkParser();
virtual ~NativeWifiNetworkParser();
virtual bool ParseValue(PropertyIndex index,
- const Value& value,
+ 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);
};
@@ -105,14 +114,14 @@ class NativeCellularNetworkParser : public NativeWirelessNetworkParser {
NativeCellularNetworkParser();
virtual ~NativeCellularNetworkParser();
virtual bool ParseValue(PropertyIndex index,
- const Value& value,
+ 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);
};
@@ -122,20 +131,21 @@ class NativeVirtualNetworkParser : public NativeNetworkParser {
NativeVirtualNetworkParser();
virtual ~NativeVirtualNetworkParser();
virtual bool ParseValue(PropertyIndex index,
- const Value& value,
+ 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 a347ec7..c4f76d1 100644
--- a/chrome/browser/chromeos/cros/network_library.cc
+++ b/chrome/browser/chromeos/cros/network_library.cc
@@ -177,7 +177,7 @@ void NetworkDevice::ParseInfo(const DictionaryValue& info) {
}
bool NetworkDevice::UpdateStatus(const std::string& key,
- const Value& value,
+ Value* value,
PropertyIndex* index) {
if (device_parser_.get())
return device_parser_->UpdateStatus(key, value, this, index);
@@ -424,7 +424,7 @@ void Network::InitIPAddress() {
}
bool Network::UpdateStatus(const std::string& key,
- const Value& value,
+ Value* value,
PropertyIndex* index) {
if (network_parser_.get())
return network_parser_->UpdateStatus(key, value, this, index);
@@ -2973,13 +2973,14 @@ 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, const Value& value);
+ void UpdateNetworkStatus(const std::string& path,
+ const std::string& key,
+ 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, const Value& value);
+ const std::string& path, const std::string& key, Value* value);
static void PinOperationCallback(void* object,
const char* path,
@@ -3166,11 +3167,14 @@ void NetworkLibraryImplCros::NetworkStatusChangedHandler(
DCHECK(networklib);
if (key == NULL || value == NULL || path == NULL || object == NULL)
return;
- networklib->UpdateNetworkStatus(std::string(path), std::string(key), *value);
+ networklib->UpdateNetworkStatus(std::string(path),
+ std::string(key),
+ const_cast<Value*>(value));
}
-void NetworkLibraryImplCros::UpdateNetworkStatus(
- const std::string& path, const std::string& key, const Value& value) {
+void NetworkLibraryImplCros::UpdateNetworkStatus(const std::string& path,
+ const std::string& key,
+ Value* value) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
Network* network = FindNetworkByPath(path);
if (network) {
@@ -3199,11 +3203,12 @@ void NetworkLibraryImplCros::NetworkDevicePropertyChangedHandler(
return;
networklib->UpdateNetworkDeviceStatus(std::string(path),
std::string(key),
- *value);
+ const_cast<Value*>(value));
}
-void NetworkLibraryImplCros::UpdateNetworkDeviceStatus(
- const std::string& path, const std::string& key, const Value& value) {
+void NetworkLibraryImplCros::UpdateNetworkDeviceStatus(const std::string& path,
+ const std::string& key,
+ 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 271fe33..d5cd133 100644
--- a/chrome/browser/chromeos/cros/network_library.h
+++ b/chrome/browser/chromeos/cros/network_library.h
@@ -414,7 +414,7 @@ class NetworkDevice {
// PropertyIndex that was updated in |index|. |index| may be NULL
// if not needed.
bool UpdateStatus(const std::string& key,
- const Value& value,
+ Value* value,
PropertyIndex *index);
NativeNetworkDeviceParser* device_parser() { return device_parser_.get(); }
@@ -640,7 +640,7 @@ class Network {
}
virtual bool UpdateStatus(const std::string& key,
- const Value& value,
+ Value* value,
PropertyIndex* index);
protected:
diff --git a/chrome/browser/chromeos/cros/network_parser.cc b/chrome/browser/chromeos/cros/network_parser.cc
index 5d3dfd4..ecdfbdd 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,
- const Value& value,
+ 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,
- const Value& value,
+ 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,
- const Value& value,
+ 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 9181551..a06a792 100644
--- a/chrome/browser/chromeos/cros/network_parser.h
+++ b/chrome/browser/chromeos/cros/network_parser.h
@@ -83,16 +83,17 @@ class NetworkDeviceParser {
virtual bool UpdateDeviceFromInfo(const DictionaryValue& info,
NetworkDevice* device);
virtual bool UpdateStatus(const std::string& key,
- const Value& value,
+ 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,
- const Value& value,
+ Value* value,
NetworkDevice* device) = 0;
virtual ConnectionType ParseType(const std::string& type) = 0;
@@ -125,7 +126,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,
- const Value& value,
+ Value* value,
Network* network,
PropertyIndex* index);
protected:
@@ -134,7 +135,7 @@ class NetworkParser {
virtual ~NetworkParser();
virtual bool ParseValue(PropertyIndex index,
- const Value& value,
+ 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 dce4b6f..f8b2c78 100644
--- a/chrome/browser/extensions/extension_bookmarks_module.cc
+++ b/chrome/browser/extensions/extension_bookmarks_module.cc
@@ -285,8 +285,7 @@ bool GetBookmarksFunction::RunImpl() {
scoped_ptr<ListValue> json(new ListValue());
Value* arg0;
EXTENSION_FUNCTION_VALIDATE(args_->Get(0, &arg0));
- if (arg0->IsType(Value::TYPE_LIST)) {
- const ListValue* ids = static_cast<const ListValue*>(arg0);
+ if (const ListValue* ids = arg0->AsList()) {
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 a949b4d..9a6ded9 100644
--- a/chrome/browser/extensions/extension_tabs_module.cc
+++ b/chrome/browser/extensions/extension_tabs_module.cc
@@ -417,8 +417,7 @@ bool CreateWindowFunction::RunImpl() {
std::string url_string;
url_value->GetAsString(&url_string);
url_strings.push_back(url_string);
- } else if (url_value->IsType(Value::TYPE_LIST)) {
- const ListValue* url_list = static_cast<const ListValue*>(url_value);
+ } else if (const ListValue* url_list = url_value->AsList()) {
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 8398433..0791a71 100644
--- a/chrome/browser/extensions/extension_webrequest_api_unittest.cc
+++ b/chrome/browser/extensions/extension_webrequest_api_unittest.cc
@@ -477,13 +477,12 @@ TEST_P(ExtensionWebRequestHeaderModificationTest, TestModifications) {
scoped_ptr<Value> event_arg_value(
JSONStringValueSerializer(event_arg_string).Deserialize(NULL, NULL));
- ASSERT_TRUE(event_arg_value.get() &&
- event_arg_value->IsType(Value::TYPE_LIST));
+ ASSERT_TRUE(event_arg_value.get());
+ ListValue* list = event_arg_value->AsList();
+ ASSERT_TRUE(list);
DictionaryValue* event_arg_dict = NULL;
- ASSERT_TRUE(
- static_cast<ListValue*>(event_arg_value.get())->GetDictionary(
- 0, &event_arg_dict));
+ ASSERT_TRUE(list->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 541ac8c..abb3684 100644
--- a/chrome/common/json_value_serializer_unittest.cc
+++ b/chrome/common/json_value_serializer_unittest.cc
@@ -195,8 +195,9 @@ namespace {
void ValidateJsonList(const std::string& json) {
scoped_ptr<Value> root(base::JSONReader::Read(json, false));
- ASSERT_TRUE(root.get() && root->IsType(Value::TYPE_LIST));
- ListValue* list = static_cast<ListValue*>(root.get());
+ ASSERT_TRUE(root.get());
+ ListValue* list = root->AsList();
+ ASSERT_TRUE(list);
ASSERT_EQ(1U, list->GetSize());
Value* elt = NULL;
ASSERT_TRUE(list->Get(0, &elt));
@@ -219,8 +220,9 @@ 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() && root->IsType(Value::TYPE_LIST));
- ListValue* list = static_cast<ListValue*>(root.get());
+ ASSERT_TRUE(root.get());
+ ListValue* list = root->AsList();
+ ASSERT_TRUE(list);
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 d96743c..077c524 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->IsType(Value::TYPE_LIST)) {
+ if (!value_args.get() || !value_args->AsList()) {
NOTREACHED() << "Invalid JSON passed to StartRequest.";
return v8::Undefined();
}
- return StartRequestCommon(args, static_cast<ListValue*>(value_args.get()));
+ return StartRequestCommon(args, value_args->AsList());
}
static bool ConvertImageDataToBitmapValue(
diff --git a/chrome/test/automation/automation_json_requests.cc b/chrome/test/automation/automation_json_requests.cc
index ab0de31..ecd932e 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->IsType(Value::TYPE_LIST)) {
+ if (!value || !value->AsList()) {
LOG(ERROR) << "Unable to deserialize returned JSON";
return false;
}
- scoped_ptr<ListValue> list(static_cast<ListValue*>(value));
+ scoped_ptr<ListValue> list(value->AsList());
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->IsType(Value::TYPE_LIST))
+ if (!cookies_value->AsList())
return false;
- *cookies = static_cast<ListValue*>(cookies_value.release());
+ *cookies = cookies_value->AsList();
return true;
}
diff --git a/chrome/test/automation/javascript_execution_controller.cc b/chrome/test/automation/javascript_execution_controller.cc
index 5be6b98..e4702c5 100644
--- a/chrome/test/automation/javascript_execution_controller.cc
+++ b/chrome/test/automation/javascript_execution_controller.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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;
- if (!root_value->IsType(Value::TYPE_LIST)) {
+ ListValue* list = root_value->AsList();
+ if (!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 e4b61f4..1ccdc17 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(const Value* value, std::vector<T>* t) {
- if (!value->IsType(Value::TYPE_LIST))
+ static bool SetFromValue(Value* value, std::vector<T>* t) {
+ ListValue* list_value = value->AsList();
+ if (!list_value)
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 49cd00c..d30fd7d 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->IsType(Value::TYPE_LIST));
+ DCHECK(root->AsList());
Value* value = NULL;
- succeeded = static_cast<ListValue*>(root)->Get(0, &value);
+ succeeded = root->AsList()->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->IsType(Value::TYPE_LIST));
+ DCHECK(root->AsList());
Value* value = NULL;
- succeeded = static_cast<ListValue*>(root)->Get(0, &value);
+ succeeded = root->AsList()->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->IsType(Value::TYPE_LIST));
+ DCHECK(root->AsList());
Value* value = NULL;
- succeeded = static_cast<ListValue*>(root)->Get(0, &value);
+ succeeded = root->AsList()->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 f5c1f2c..16d6510 100644
--- a/chrome/test/automation/value_conversion_traits.cc
+++ b/chrome/test/automation/value_conversion_traits.cc
@@ -71,14 +71,15 @@ Value* ValueConversionTraits<ListValue*>::CreateValueFrom(const ListValue* t) {
bool ValueConversionTraits<ListValue*>::SetFromValue(const Value* value,
ListValue** t) {
- if (!value->IsType(Value::TYPE_LIST))
+ ListValue* list = const_cast<Value*>(value)->AsList();
+ if (!list)
return false;
- *t = static_cast<const ListValue*>(value)->DeepCopy();
+ *t = list->DeepCopy();
return true;
}
bool ValueConversionTraits<ListValue*>::CanConvert(const Value* value) {
- return value->IsType(Value::TYPE_LIST);
+ return const_cast<Value*>(value)->AsList();
}
Value* ValueConversionTraits<DictionaryValue*>::CreateValueFrom(
diff --git a/chrome/test/base/ui_test_utils.cc b/chrome/test/base/ui_test_utils.cc
index d087e68..2234ba2 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));
- if (!root_val->IsType(Value::TYPE_LIST))
+ ListValue* list = root_val->AsList();
+ if (!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));
- if (!value->IsType(Value::TYPE_LIST))
+ ListValue* list = value->AsList();
+ if (!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 6ca9c1a..4196666 100644
--- a/chrome/test/perf/dom_checker_uitest.cc
+++ b/chrome/test/perf/dom_checker_uitest.cc
@@ -175,12 +175,11 @@ class DomCheckerTest : public UITest {
if (!value.get())
return false;
- EXPECT_TRUE(value->IsType(Value::TYPE_LIST));
- if (!value->IsType(Value::TYPE_LIST))
+ EXPECT_TRUE(value->AsList());
+ ListValue* list_value = value->AsList();
+ if (!list_value)
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 1c09d39..882dbeb 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);
}
-const Value* Response::GetValue() 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 9c44e60..0d25c48 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.
- const Value* GetValue() 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 a9dcd4a..e079f12 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: {
- const Value* const value = command_response.GetValue();
+ Value* value = command_response.GetValue();
std::string location;
if (!value->GetAsString(&location)) {
// This should never happen.
@@ -173,8 +173,9 @@ void PrepareHttpResponse(const Response& command_response,
break;
case kMethodNotAllowed: {
- const Value* const value = command_response.GetValue();
- if (!value->IsType(Value::TYPE_LIST)) {
+ Value* value = command_response.GetValue();
+ ListValue* list_value = value->AsList();
+ if (!list_value) {
// This should never happen.
http_response->set_status(HttpResponse::kInternalServerError);
http_response->SetBody(
@@ -183,8 +184,6 @@ 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 1a764a8..c3a7c11 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 {
- if (!value->IsType(Value::TYPE_LIST))
+ ListValue* list = value->AsList();
+ if (!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 645e75d..4cc8e19 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);
- if (!hypotheses_value->IsType(Value::TYPE_LIST)) {
+ const ListValue* hypotheses_list = hypotheses_value->AsList();
+ if (!hypotheses_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 97037a4..98a83c5 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->IsType(Value::TYPE_LIST));
+ CHECK(content->AsList());
} else {
content.reset(new ListValue());
}