diff options
author | kinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-15 02:22:19 +0000 |
---|---|---|
committer | kinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-15 02:22:19 +0000 |
commit | c8c3f37f7dc08aee5f9199aa00a3c36c5403d9c5 (patch) | |
tree | fe62f0694817ca5ecca557b667220039e5fc5101 | |
parent | 953067b9f13194d1ac77fc8652cbf1b1066f765b (diff) | |
download | chromium_src-c8c3f37f7dc08aee5f9199aa00a3c36c5403d9c5.zip chromium_src-c8c3f37f7dc08aee5f9199aa00a3c36c5403d9c5.tar.gz chromium_src-c8c3f37f7dc08aee5f9199aa00a3c36c5403d9c5.tar.bz2 |
Revert 167808 - Get rid of use of CreateStringValue in chromeos/ directory.
Reverting because the patch makes clang build failing:
> chrome/browser/chromeos/cros/network_library.cc:380:26:error: C++98 requires an
> accessible copy constructor for class 'base::StringValue' when binding a
> reference to a temporary; was private [-Werror,-Wbind-to-temporary-copy]
> SetValueProperty(prop, base::StringValue(str));
etc.
BUG=160586
Review URL: https://chromiumcodereview.appspot.com/11363203
TBR=estade@chromium.org
Review URL: https://codereview.chromium.org/11369258
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167826 0039d316-1c4b-4281-b951-d872f2087c98
21 files changed, 121 insertions, 119 deletions
diff --git a/base/values.h b/base/values.h index 6b65005..d7263df 100644 --- a/base/values.h +++ b/base/values.h @@ -66,9 +66,10 @@ class BASE_EXPORT Value { virtual ~Value(); + // Convenience methods for creating Value objects for various + // kinds of values without thinking about which class implements them. + // These can always be expected to return a valid Value*. static Value* CreateNullValue(); - // DEPRECATED: Do not use the following 5 functions. Instead, use - // new FundamentalValue or new StringValue. static FundamentalValue* CreateBooleanValue(bool in_value); static FundamentalValue* CreateIntegerValue(int in_value); static FundamentalValue* CreateDoubleValue(double in_value); diff --git a/chrome/browser/chromeos/cros/cros_network_functions.cc b/chrome/browser/chromeos/cros/cros_network_functions.cc index ea4cb80..54700fc 100644 --- a/chrome/browser/chromeos/cros/cros_network_functions.cc +++ b/chrome/browser/chromeos/cros/cros_network_functions.cc @@ -537,16 +537,16 @@ void CrosRequestHiddenWifiNetworkProperties( base::DictionaryValue properties; properties.SetWithoutPathExpansion( flimflam::kModeProperty, - new base::StringValue(flimflam::kModeManaged)); + base::Value::CreateStringValue(flimflam::kModeManaged)); properties.SetWithoutPathExpansion( flimflam::kTypeProperty, - new base::StringValue(flimflam::kTypeWifi)); + base::Value::CreateStringValue(flimflam::kTypeWifi)); properties.SetWithoutPathExpansion( flimflam::kSSIDProperty, - new base::StringValue(ssid)); + base::Value::CreateStringValue(ssid)); properties.SetWithoutPathExpansion( flimflam::kSecurityProperty, - new base::StringValue(security)); + base::Value::CreateStringValue(security)); // shill.Manger.GetService() will apply the property changes in // |properties| and return a new or existing service to OnGetService(). // OnGetService will then call GetProperties which will then call callback. @@ -563,20 +563,20 @@ void CrosRequestVirtualNetworkProperties( base::DictionaryValue properties; properties.SetWithoutPathExpansion( flimflam::kTypeProperty, - new base::StringValue(flimflam::kTypeVPN)); + base::Value::CreateStringValue(flimflam::kTypeVPN)); properties.SetWithoutPathExpansion( flimflam::kProviderNameProperty, - new base::StringValue(service_name)); + base::Value::CreateStringValue(service_name)); properties.SetWithoutPathExpansion( flimflam::kProviderHostProperty, - new base::StringValue(server_hostname)); + base::Value::CreateStringValue(server_hostname)); properties.SetWithoutPathExpansion( flimflam::kProviderTypeProperty, - new base::StringValue(provider_type)); + base::Value::CreateStringValue(provider_type)); // The actual value of Domain does not matter, so just use service_name. properties.SetWithoutPathExpansion( flimflam::kVPNDomainProperty, - new base::StringValue(service_name)); + base::Value::CreateStringValue(service_name)); // shill.Manger.GetService() will apply the property changes in // |properties| and pass a new or existing service to OnGetService(). diff --git a/chrome/browser/chromeos/cros/cros_network_functions_unittest.cc b/chrome/browser/chromeos/cros/cros_network_functions_unittest.cc index 04f72bc..24881d8 100644 --- a/chrome/browser/chromeos/cros/cros_network_functions_unittest.cc +++ b/chrome/browser/chromeos/cros/cros_network_functions_unittest.cc @@ -401,10 +401,10 @@ TEST_F(CrosNetworkFunctionsTest, CrosMonitorCellularDataPlan) { base::DictionaryValue* data_plan_dictionary = new base::DictionaryValue; data_plan_dictionary->SetWithoutPathExpansion( cashew::kCellularPlanNameProperty, - new base::StringValue(data_plan->plan_name)); + base::Value::CreateStringValue(data_plan->plan_name)); data_plan_dictionary->SetWithoutPathExpansion( cashew::kCellularPlanTypeProperty, - new base::StringValue(cashew::kCellularDataPlanMeteredPaid)); + base::Value::CreateStringValue(cashew::kCellularDataPlanMeteredPaid)); data_plan_dictionary->SetWithoutPathExpansion( cashew::kCellularPlanUpdateTimeProperty, base::Value::CreateDoubleValue(kUpdateTime)); @@ -449,10 +449,10 @@ TEST_F(CrosNetworkFunctionsTest, CrosMonitorSMS) { base::DictionaryValue device_properties; device_properties.SetWithoutPathExpansion( flimflam::kDBusConnectionProperty, - new base::StringValue(dbus_connection)); + base::Value::CreateStringValue(dbus_connection)); device_properties.SetWithoutPathExpansion( flimflam::kDBusObjectProperty, - new base::StringValue(object_path.value())); + base::Value::CreateStringValue(object_path.value())); const std::string number = "0123456789"; const std::string text = "Hello."; @@ -473,14 +473,14 @@ TEST_F(CrosNetworkFunctionsTest, CrosMonitorSMS) { const bool kComplete = true; base::DictionaryValue* sms_dictionary = new base::DictionaryValue; sms_dictionary->SetWithoutPathExpansion( - SMSWatcher::kNumberKey, new base::StringValue(number)); + SMSWatcher::kNumberKey, base::Value::CreateStringValue(number)); sms_dictionary->SetWithoutPathExpansion( - SMSWatcher::kTextKey, new base::StringValue(text)); + SMSWatcher::kTextKey, base::Value::CreateStringValue(text)); sms_dictionary->SetWithoutPathExpansion( SMSWatcher::kTimestampKey, - new base::StringValue(timestamp_string)); + base::Value::CreateStringValue(timestamp_string)); sms_dictionary->SetWithoutPathExpansion(SMSWatcher::kSmscKey, - new base::StringValue(smsc)); + base::Value::CreateStringValue(smsc)); sms_dictionary->SetWithoutPathExpansion( SMSWatcher::kValidityKey, base::Value::CreateDoubleValue(kValidity)); sms_dictionary->SetWithoutPathExpansion( @@ -563,8 +563,8 @@ TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkManagerProperties) { const std::string value2 = "value2"; // Create result value. base::DictionaryValue result; - result.SetWithoutPathExpansion(key1, new base::StringValue(value1)); - result.SetWithoutPathExpansion(key2, new base::StringValue(value2)); + result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); + result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); // Set expectations. dictionary_value_result_ = &result; EXPECT_CALL(*mock_manager_client_, @@ -585,8 +585,8 @@ TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkServiceProperties) { const std::string value2 = "value2"; // Create result value. base::DictionaryValue result; - result.SetWithoutPathExpansion(key1, new base::StringValue(value1)); - result.SetWithoutPathExpansion(key2, new base::StringValue(value2)); + result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); + result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); // Set expectations. dictionary_value_result_ = &result; EXPECT_CALL(*mock_service_client_, @@ -606,8 +606,8 @@ TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkDeviceProperties) { const std::string value2 = "value2"; // Create result value. base::DictionaryValue result; - result.SetWithoutPathExpansion(key1, new base::StringValue(value1)); - result.SetWithoutPathExpansion(key2, new base::StringValue(value2)); + result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); + result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); // Set expectations. dictionary_value_result_ = &result; EXPECT_CALL(*mock_device_client_, @@ -627,8 +627,8 @@ TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkProfileProperties) { const std::string value2 = "value2"; // Create result value. base::DictionaryValue result; - result.SetWithoutPathExpansion(key1, new base::StringValue(value1)); - result.SetWithoutPathExpansion(key2, new base::StringValue(value2)); + result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); + result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); // Set expectations. dictionary_value_result_ = &result; EXPECT_CALL( @@ -651,8 +651,8 @@ TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkProfileEntryProperties) { const std::string value2 = "value2"; // Create result value. base::DictionaryValue result; - result.SetWithoutPathExpansion(key1, new base::StringValue(value1)); - result.SetWithoutPathExpansion(key2, new base::StringValue(value2)); + result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); + result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); // Set expectations. dictionary_value_result_ = &result; EXPECT_CALL(*mock_profile_client_, @@ -675,23 +675,23 @@ TEST_F(CrosNetworkFunctionsTest, CrosRequestHiddenWifiNetworkProperties) { const std::string value2 = "value2"; // Create result value. base::DictionaryValue result; - result.SetWithoutPathExpansion(key1, new base::StringValue(value1)); - result.SetWithoutPathExpansion(key2, new base::StringValue(value2)); + result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); + result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); dictionary_value_result_ = &result; // Create expected argument to ShillManagerClient::GetService. base::DictionaryValue properties; properties.SetWithoutPathExpansion( flimflam::kModeProperty, - new base::StringValue(flimflam::kModeManaged)); + base::Value::CreateStringValue(flimflam::kModeManaged)); properties.SetWithoutPathExpansion( flimflam::kTypeProperty, - new base::StringValue(flimflam::kTypeWifi)); + base::Value::CreateStringValue(flimflam::kTypeWifi)); properties.SetWithoutPathExpansion( flimflam::kSSIDProperty, - new base::StringValue(ssid)); + base::Value::CreateStringValue(ssid)); properties.SetWithoutPathExpansion( flimflam::kSecurityProperty, - new base::StringValue(security)); + base::Value::CreateStringValue(security)); // Set expectations. const dbus::ObjectPath service_path("/service/path"); ObjectPathCallback callback; @@ -720,25 +720,25 @@ TEST_F(CrosNetworkFunctionsTest, CrosRequestVirtualNetworkProperties) { const std::string value2 = "value2"; // Create result value. base::DictionaryValue result; - result.SetWithoutPathExpansion(key1, new base::StringValue(value1)); - result.SetWithoutPathExpansion(key2, new base::StringValue(value2)); + result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); + result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); dictionary_value_result_ = &result; // Create expected argument to ShillManagerClient::GetService. base::DictionaryValue properties; properties.SetWithoutPathExpansion( - flimflam::kTypeProperty, new base::StringValue("vpn")); + flimflam::kTypeProperty, base::Value::CreateStringValue("vpn")); properties.SetWithoutPathExpansion( flimflam::kProviderNameProperty, - new base::StringValue(service_name)); + base::Value::CreateStringValue(service_name)); properties.SetWithoutPathExpansion( flimflam::kProviderHostProperty, - new base::StringValue(server_hostname)); + base::Value::CreateStringValue(server_hostname)); properties.SetWithoutPathExpansion( flimflam::kProviderTypeProperty, - new base::StringValue(provider_type)); + base::Value::CreateStringValue(provider_type)); properties.SetWithoutPathExpansion( flimflam::kVPNDomainProperty, - new base::StringValue(service_name)); + base::Value::CreateStringValue(service_name)); // Set expectations. const dbus::ObjectPath service_path("/service/path"); @@ -920,24 +920,24 @@ TEST_F(CrosNetworkFunctionsTest, CrosListIPConfigsAndBlock) { const std::string hardware_address = "hardware address"; base::ListValue* ipconfigs = new base::ListValue; - ipconfigs->Append(new base::StringValue(ipconfig_path)); + ipconfigs->Append(base::Value::CreateStringValue(ipconfig_path)); base::DictionaryValue* device_properties = new base::DictionaryValue; device_properties->SetWithoutPathExpansion( flimflam::kIPConfigsProperty, ipconfigs); device_properties->SetWithoutPathExpansion( flimflam::kAddressProperty, - new base::StringValue(hardware_address)); + base::Value::CreateStringValue(hardware_address)); base::ListValue* name_servers_list = new base::ListValue; - name_servers_list->Append(new base::StringValue(name_server1)); - name_servers_list->Append(new base::StringValue(name_server2)); + name_servers_list->Append(base::Value::CreateStringValue(name_server1)); + name_servers_list->Append(base::Value::CreateStringValue(name_server2)); base::DictionaryValue* ipconfig_properties = new base::DictionaryValue; ipconfig_properties->SetWithoutPathExpansion( flimflam::kMethodProperty, - new base::StringValue(flimflam::kTypeDHCP)); + base::Value::CreateStringValue(flimflam::kTypeDHCP)); ipconfig_properties->SetWithoutPathExpansion( flimflam::kAddressProperty, - new base::StringValue(address)); + base::Value::CreateStringValue(address)); ipconfig_properties->SetWithoutPathExpansion( flimflam::kMtuProperty, base::Value::CreateIntegerValue(kMtu)); @@ -946,16 +946,16 @@ TEST_F(CrosNetworkFunctionsTest, CrosListIPConfigsAndBlock) { base::Value::CreateIntegerValue(kPrefixlen)); ipconfig_properties->SetWithoutPathExpansion( flimflam::kBroadcastProperty, - new base::StringValue(broadcast)); + base::Value::CreateStringValue(broadcast)); ipconfig_properties->SetWithoutPathExpansion( flimflam::kPeerAddressProperty, - new base::StringValue(peer_address)); + base::Value::CreateStringValue(peer_address)); ipconfig_properties->SetWithoutPathExpansion( flimflam::kGatewayProperty, - new base::StringValue(gateway)); + base::Value::CreateStringValue(gateway)); ipconfig_properties->SetWithoutPathExpansion( flimflam::kDomainNameProperty, - new base::StringValue(domainname)); + base::Value::CreateStringValue(domainname)); ipconfig_properties->SetWithoutPathExpansion( flimflam::kNameServersProperty, name_servers_list); @@ -990,7 +990,7 @@ TEST_F(CrosNetworkFunctionsTest, CrosListIPConfigsAndBlock) { TEST_F(CrosNetworkFunctionsTest, CrosGetWifiAccessPoints) { const std::string device_path = "/device/path"; base::ListValue* devices = new base::ListValue; - devices->Append(new base::StringValue(device_path)); + devices->Append(base::Value::CreateStringValue(device_path)); base::DictionaryValue* manager_properties = new base::DictionaryValue; manager_properties->SetWithoutPathExpansion( flimflam::kDevicesProperty, devices); @@ -998,7 +998,7 @@ TEST_F(CrosNetworkFunctionsTest, CrosGetWifiAccessPoints) { const int kScanInterval = 42; const std::string network_path = "/network/path"; base::ListValue* networks = new base::ListValue; - networks->Append(new base::StringValue(network_path)); + networks->Append(base::Value::CreateStringValue(network_path)); base::DictionaryValue* device_properties = new base::DictionaryValue; device_properties->SetWithoutPathExpansion( flimflam::kNetworksProperty, networks); @@ -1019,9 +1019,9 @@ TEST_F(CrosNetworkFunctionsTest, CrosGetWifiAccessPoints) { base::DictionaryValue* network_properties = new base::DictionaryValue; network_properties->SetWithoutPathExpansion( - flimflam::kAddressProperty, new base::StringValue(address)); + flimflam::kAddressProperty, base::Value::CreateStringValue(address)); network_properties->SetWithoutPathExpansion( - flimflam::kNameProperty, new base::StringValue(name)); + flimflam::kNameProperty, base::Value::CreateStringValue(name)); network_properties->SetWithoutPathExpansion( flimflam::kSignalStrengthProperty, base::Value::CreateIntegerValue(kSignalStrength)); diff --git a/chrome/browser/chromeos/cros/network_library.cc b/chrome/browser/chromeos/cros/network_library.cc index f2f4a8c..8600d88 100644 --- a/chrome/browser/chromeos/cros/network_library.cc +++ b/chrome/browser/chromeos/cros/network_library.cc @@ -359,11 +359,12 @@ bool Network::RequiresUserProfile() const { void Network::CopyCredentialsFromRemembered(Network* remembered) { } -void Network::SetValueProperty(const char* prop, const base::Value& value) { +void Network::SetValueProperty(const char* prop, Value* value) { DCHECK(prop); + DCHECK(value); if (!EnsureCrosLoaded()) return; - CrosSetNetworkServiceProperty(service_path_, prop, value); + CrosSetNetworkServiceProperty(service_path_, prop, *value); } void Network::ClearProperty(const char* prop) { @@ -377,7 +378,8 @@ void Network::SetStringProperty( const char* prop, const std::string& str, std::string* dest) { if (dest) *dest = str; - SetValueProperty(prop, base::StringValue(str)); + scoped_ptr<Value> value(Value::CreateStringValue(str)); + SetValueProperty(prop, value.get()); } void Network::SetOrClearStringProperty(const char* prop, @@ -395,13 +397,15 @@ void Network::SetOrClearStringProperty(const char* prop, void Network::SetBooleanProperty(const char* prop, bool b, bool* dest) { if (dest) *dest = b; - SetValueProperty(prop, base::FundamentalValue(b)); + scoped_ptr<Value> value(Value::CreateBooleanValue(b)); + SetValueProperty(prop, value.get()); } void Network::SetIntegerProperty(const char* prop, int i, int* dest) { if (dest) *dest = i; - SetValueProperty(prop, base::FundamentalValue(i)); + scoped_ptr<Value> value(Value::CreateIntegerValue(i)); + SetValueProperty(prop, value.get()); } void Network::SetPreferred(bool preferred) { @@ -880,7 +884,7 @@ void CellularNetwork::SetApn(const CellularApn& apn) { value.SetString(flimflam::kApnNetworkIdProperty, apn.network_id); value.SetString(flimflam::kApnUsernameProperty, apn.username); value.SetString(flimflam::kApnPasswordProperty, apn.password); - SetValueProperty(flimflam::kCellularApnProperty, value); + SetValueProperty(flimflam::kCellularApnProperty, &value); } else { ClearProperty(flimflam::kCellularApnProperty); } diff --git a/chrome/browser/chromeos/cros/network_library.h b/chrome/browser/chromeos/cros/network_library.h index b7350ad..93b1286 100644 --- a/chrome/browser/chromeos/cros/network_library.h +++ b/chrome/browser/chromeos/cros/network_library.h @@ -492,7 +492,7 @@ class Network { std::string* dest); virtual void SetBooleanProperty(const char* prop, bool b, bool* dest); virtual void SetIntegerProperty(const char* prop, int i, int* dest); - virtual void SetValueProperty(const char* prop, const base::Value& val); + virtual void SetValueProperty(const char* prop, base::Value* val); virtual void ClearProperty(const char* prop); // This will clear the property if string is empty. Otherwise, it will set it. diff --git a/chrome/browser/chromeos/cros/network_ui_data_unittest.cc b/chrome/browser/chromeos/cros/network_ui_data_unittest.cc index 6a34406..3f5a24a 100644 --- a/chrome/browser/chromeos/cros/network_ui_data_unittest.cc +++ b/chrome/browser/chromeos/cros/network_ui_data_unittest.cc @@ -127,9 +127,9 @@ TEST_F(NetworkUIDataTest, ParseOncProperty) { onc.Set("a.a", val_a_a.DeepCopy()); onc.Set("a.b", val_a_b.DeepCopy()); base::ListValue recommended; - recommended.Append(new base::StringValue("b")); - recommended.Append(new base::StringValue("c")); - recommended.Append(new base::StringValue("a.a")); + recommended.Append(base::Value::CreateStringValue("b")); + recommended.Append(base::Value::CreateStringValue("c")); + recommended.Append(base::Value::CreateStringValue("a.a")); onc.Set("Recommended", recommended.DeepCopy()); onc.Set("a.Recommended", recommended.DeepCopy()); diff --git a/chrome/browser/chromeos/extensions/echo_private_api.cc b/chrome/browser/chromeos/extensions/echo_private_api.cc index 4d86957..c881138 100644 --- a/chrome/browser/chromeos/extensions/echo_private_api.cc +++ b/chrome/browser/chromeos/extensions/echo_private_api.cc @@ -34,7 +34,7 @@ base::Value* GetValueForRegistrationCodeType(std::string& type) { else if (type == kGroupType) provider->GetMachineStatistic(kGroupCodeKey, &result); } - return new base::StringValue(result); + return Value::CreateStringValue(result); } } // namespace diff --git a/chrome/browser/chromeos/extensions/file_browser_private_api.cc b/chrome/browser/chromeos/extensions/file_browser_private_api.cc index ff0748b7..764b1da 100644 --- a/chrome/browser/chromeos/extensions/file_browser_private_api.cc +++ b/chrome/browser/chromeos/extensions/file_browser_private_api.cc @@ -1346,7 +1346,7 @@ bool AddMountFunction::RunImpl() { } // Set default return source path to the empty string. - SetResult(new base::StringValue("")); + SetResult(Value::CreateStringValue("")); chromeos::MountType mount_type = DiskMountManager::MountTypeFromString(mount_type_str); @@ -1361,7 +1361,7 @@ bool AddMountFunction::RunImpl() { // Pass back the drive mount point path as source path. const std::string& drive_path = drive::util::GetDriveMountPointPathAsString(); - SetResult(new base::StringValue(drive_path)); + SetResult(Value::CreateStringValue(drive_path)); FileBrowserEventRouterFactory::GetForProfile(profile_)-> MountDrive(base::Bind(&AddMountFunction::SendResponse, this, @@ -1419,7 +1419,7 @@ void AddMountFunction::OnMountedStateSet(const std::string& mount_type, DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance(); // Pass back the actual source path of the mount point. - SetResult(new base::StringValue(file_path.value())); + SetResult(Value::CreateStringValue(file_path.value())); SendResponse(true); // MountPath() takes a std::string. disk_mount_manager->MountPath(file_path.AsUTF8Unsafe(), @@ -2426,9 +2426,9 @@ void GetFileLocationsFunction::GetLocalPathsResponseOnUIThread( ListValue* locations = new ListValue; for (size_t i = 0; i < files.size(); ++i) { if (drive::util::IsUnderDriveMountPoint(files[i].file_path)) { - locations->Append(new base::StringValue("drive")); + locations->Append(Value::CreateStringValue("drive")); } else { - locations->Append(new base::StringValue("local")); + locations->Append(Value::CreateStringValue("local")); } } @@ -2515,7 +2515,7 @@ void GetDriveFilesFunction::OnFileReady( FilePath drive_path = remaining_drive_paths_.front(); if (error == drive::DRIVE_FILE_OK) { - local_paths_->Append(new base::StringValue(local_path.value())); + local_paths_->Append(Value::CreateStringValue(local_path.value())); DVLOG(1) << "Got " << drive_path.value() << " as " << local_path.value(); // TODO(benchan): If the file is a hosted document, a temporary JSON file @@ -2524,7 +2524,7 @@ void GetDriveFilesFunction::OnFileReady( // file_manager.js to manage the lifetime of the temporary file. // See crosbug.com/28058. } else { - local_paths_->Append(new base::StringValue("")); + local_paths_->Append(Value::CreateStringValue("")); DVLOG(1) << "Failed to get " << drive_path.value() << " with error code: " << error; } diff --git a/chrome/browser/chromeos/extensions/file_handler_util.cc b/chrome/browser/chromeos/extensions/file_handler_util.cc index ed6473f..e4533ef 100644 --- a/chrome/browser/chromeos/extensions/file_handler_util.cc +++ b/chrome/browser/chromeos/extensions/file_handler_util.cc @@ -941,7 +941,7 @@ void ExtensionTaskExecutor::SetupPermissionsAndDispatchEvent( SetupHandlerHostFileAccessPermissions(handler_pid); scoped_ptr<ListValue> event_args(new ListValue()); - event_args->Append(new base::StringValue(action_id_)); + event_args->Append(Value::CreateStringValue(action_id_)); DictionaryValue* details = new DictionaryValue(); event_args->Append(details); // Get file definitions. These will be replaced with Entry instances by diff --git a/chrome/browser/chromeos/extensions/file_manager_util.cc b/chrome/browser/chromeos/extensions/file_manager_util.cc index 9ea26b5..ffd2cdd 100644 --- a/chrome/browser/chromeos/extensions/file_manager_util.cc +++ b/chrome/browser/chromeos/extensions/file_manager_util.cc @@ -341,7 +341,7 @@ GURL GetFileBrowserUrlWithParams( ListValue* extensions_list = new ListValue(); for (size_t j = 0; j < file_types->extensions[i].size(); ++j) { extensions_list->Append( - new base::StringValue(file_types->extensions[i][j])); + Value::CreateStringValue(file_types->extensions[i][j])); } DictionaryValue* dict = new DictionaryValue(); diff --git a/chrome/browser/chromeos/extensions/info_private_api.cc b/chrome/browser/chromeos/extensions/info_private_api.cc index bd7ed86..c09c38a 100644 --- a/chrome/browser/chromeos/extensions/info_private_api.cc +++ b/chrome/browser/chromeos/extensions/info_private_api.cc @@ -54,8 +54,8 @@ bool GetChromeosInfoFunction::RunImpl() { for (size_t i = 0; i < list->GetSize(); ++i) { std::string property_name; EXTENSION_FUNCTION_VALIDATE(list->GetString(i, &property_name)); - Value* value = GetValue(property_name); - if (value) + Value* value = NULL; + if (GetValue(property_name, &value)) result->Set(property_name, value); } SetResult(result.release()); @@ -63,33 +63,34 @@ bool GetChromeosInfoFunction::RunImpl() { return true; } -base::Value* GetChromeosInfoFunction::GetValue( - const std::string& property_name) { +bool GetChromeosInfoFunction::GetValue(const std::string& property_name, + Value** value) { if (property_name == kPropertyHWID) { std::string hwid; chromeos::system::StatisticsProvider* provider = chromeos::system::StatisticsProvider::GetInstance(); provider->GetMachineStatistic(kHardwareClass, &hwid); - return new base::StringValue(hwid); + *value = Value::CreateStringValue(hwid); } else if (property_name == kPropertyHomeProvider) { NetworkLibrary* netlib = CrosLibrary::Get()->GetNetworkLibrary(); - return new base::StringValue(netlib->GetCellularHomeCarrierId()); + *value = Value::CreateStringValue(netlib->GetCellularHomeCarrierId()); } else if (property_name == kPropertyInitialLocale) { - return new base::StringValue( + *value = Value::CreateStringValue( chromeos::WizardController::GetInitialLocale()); } else if (property_name == kPropertyBoard) { std::string board; chromeos::system::StatisticsProvider* provider = chromeos::system::StatisticsProvider::GetInstance(); provider->GetMachineStatistic(kPropertyReleaseBoard, &board); - return new base::StringValue(board); + *value = Value::CreateStringValue(board); } else if (property_name == kPropertyOwner) { - return Value::CreateBooleanValue( + *value = Value::CreateBooleanValue( chromeos::UserManager::Get()->IsCurrentUserOwner()); + } else { + LOG(ERROR) << "Unknown property request: " << property_name; + return false; } - - DLOG(ERROR) << "Unknown property request: " << property_name; - return NULL; + return true; } } // namespace extensions diff --git a/chrome/browser/chromeos/extensions/info_private_api.h b/chrome/browser/chromeos/extensions/info_private_api.h index 0e60a3f..f1703e7 100644 --- a/chrome/browser/chromeos/extensions/info_private_api.h +++ b/chrome/browser/chromeos/extensions/info_private_api.h @@ -10,10 +10,6 @@ #include "base/compiler_specific.h" #include "chrome/browser/extensions/extension_function.h" -namespace base { -class Value; -} - namespace extensions { class GetChromeosInfoFunction : public AsyncExtensionFunction { @@ -26,8 +22,7 @@ class GetChromeosInfoFunction : public AsyncExtensionFunction { virtual bool RunImpl() OVERRIDE; private: - // Returns a newly allocate value, or null. - base::Value* GetValue(const std::string& property_name); + bool GetValue(const std::string& property_name, Value** value); DECLARE_EXTENSION_FUNCTION_NAME("chromeosInfoPrivate.get"); }; diff --git a/chrome/browser/chromeos/login/user_image_manager_browsertest.cc b/chrome/browser/chromeos/login/user_image_manager_browsertest.cc index 8f140ee..ce32ad6 100644 --- a/chrome/browser/chromeos/login/user_image_manager_browsertest.cc +++ b/chrome/browser/chromeos/login/user_image_manager_browsertest.cc @@ -72,7 +72,7 @@ class UserImageManagerTest : public CrosInProcessBrowserTest, // Adds given user to Local State, if not there. void AddUser(const std::string& username) { ListPrefUpdate users_pref(local_state_, "LoggedInUsers"); - users_pref->AppendIfNotPresent(new base::StringValue(username)); + users_pref->AppendIfNotPresent(base::Value::CreateStringValue(username)); } // Logs in |username|. @@ -96,7 +96,7 @@ class UserImageManagerTest : public CrosInProcessBrowserTest, image_properties->Set( "index", base::Value::CreateIntegerValue(image_index)); image_properties->Set( - "path" , new base::StringValue(image_path.value())); + "path" , base::Value::CreateStringValue(image_path.value())); images_pref->SetWithoutPathExpansion(username, image_properties); } diff --git a/chrome/browser/chromeos/login/user_manager_impl.cc b/chrome/browser/chromeos/login/user_manager_impl.cc index 5aec8cb..e6ad13d 100644 --- a/chrome/browser/chromeos/login/user_manager_impl.cc +++ b/chrome/browser/chromeos/login/user_manager_impl.cc @@ -174,13 +174,13 @@ void UserManagerImpl::UserLoggedIn(const std::string& email, prefs_users_update->Clear(); // Make sure this user is first. - prefs_users_update->Append(new base::StringValue(email)); + prefs_users_update->Append(Value::CreateStringValue(email)); UserList::iterator logged_in_user = users_.end(); for (UserList::iterator it = users_.begin(); it != users_.end(); ++it) { std::string user_email = (*it)->email(); // Skip the most recent user. if (email != user_email) - prefs_users_update->Append(new base::StringValue(user_email)); + prefs_users_update->Append(Value::CreateStringValue(user_email)); else logged_in_user = it; } @@ -369,7 +369,7 @@ void UserManagerImpl::SaveUserDisplayName(const std::string& username, DictionaryPrefUpdate display_name_update(local_state, kUserDisplayName); display_name_update->SetWithoutPathExpansion( username, - new base::StringValue(display_name)); + base::Value::CreateStringValue(display_name)); } string16 UserManagerImpl::GetUserDisplayName( @@ -397,7 +397,7 @@ void UserManagerImpl::SaveUserDisplayEmail(const std::string& username, DictionaryPrefUpdate display_email_update(local_state, kUserDisplayEmail); display_email_update->SetWithoutPathExpansion( username, - new base::StringValue(display_email)); + base::Value::CreateStringValue(display_email)); } std::string UserManagerImpl::GetUserDisplayEmail( @@ -729,7 +729,7 @@ void UserManagerImpl::RemoveUserFromListInternal(const std::string& email) { std::string user_email = (*it)->email(); // Skip user that we would like to delete. if (email != user_email) - prefs_users_update->Append(new base::StringValue(user_email)); + prefs_users_update->Append(Value::CreateStringValue(user_email)); else user_to_remove = it; } diff --git a/chrome/browser/chromeos/login/wallpaper_manager_browsertest.cc b/chrome/browser/chromeos/login/wallpaper_manager_browsertest.cc index 18325bd..a5ed8af 100644 --- a/chrome/browser/chromeos/login/wallpaper_manager_browsertest.cc +++ b/chrome/browser/chromeos/login/wallpaper_manager_browsertest.cc @@ -88,7 +88,7 @@ class WallpaperManagerBrowserTest : public CrosInProcessBrowserTest, // Sets |username| wallpaper. void SetUserWallpaper(const std::string& username) { ListPrefUpdate users_pref(local_state_, "LoggedInUsers"); - users_pref->AppendIfNotPresent(new base::StringValue(username)); + users_pref->AppendIfNotPresent(base::Value::CreateStringValue(username)); WallpaperManager::Get()->SetUserWallpaper(username); } diff --git a/chrome/browser/chromeos/media/media_player_extension_api.cc b/chrome/browser/chromeos/media/media_player_extension_api.cc index 1f8449f..e0fcae9 100644 --- a/chrome/browser/chromeos/media/media_player_extension_api.cc +++ b/chrome/browser/chromeos/media/media_player_extension_api.cc @@ -46,7 +46,7 @@ static ListValue* GetPlaylistItems() { MediaPlayer::UrlVector const& src = MediaPlayer::GetInstance()->GetPlaylist(); for (size_t i = 0; i < src.size(); i++) { - result->Append(new base::StringValue(src[i].spec())); + result->Append(Value::CreateStringValue(src[i].spec())); } return result; } diff --git a/chrome/browser/chromeos/proxy_cros_settings_parser.cc b/chrome/browser/chromeos/proxy_cros_settings_parser.cc index 5dc5e27..2177095 100644 --- a/chrome/browser/chromeos/proxy_cros_settings_parser.cc +++ b/chrome/browser/chromeos/proxy_cros_settings_parser.cc @@ -56,7 +56,7 @@ namespace { base::Value* CreateServerHostValue( const ProxyConfigServiceImpl::ProxyConfig::ManualProxy& proxy) { return proxy.server.is_valid() ? - new base::StringValue(proxy.server.host_port_pair().host()) : + base::Value::CreateStringValue(proxy.server.host_port_pair().host()) : NULL; } @@ -298,7 +298,8 @@ bool GetProxyPrefValue(Profile* profile, if (config.mode == chromeos::ProxyConfigServiceImpl::ProxyConfig::MODE_PAC_SCRIPT && config.automatic_proxy.pac_url.is_valid()) { - data = new base::StringValue(config.automatic_proxy.pac_url.spec()); + data = + base::Value::CreateStringValue(config.automatic_proxy.pac_url.spec()); } } else if (path == kProxySingleHttp) { data = CreateServerHostValue(config.single_proxy); @@ -356,7 +357,7 @@ bool GetProxyPrefValue(Profile* profile, ListValue* list = new ListValue(); net::ProxyBypassRules::RuleList bypass_rules = config.bypass_rules.rules(); for (size_t x = 0; x < bypass_rules.size(); x++) { - list->Append(new base::StringValue(bypass_rules[x]->ToString())); + list->Append(base::Value::CreateStringValue(bypass_rules[x]->ToString())); } data = list; } else { @@ -367,7 +368,7 @@ bool GetProxyPrefValue(Profile* profile, // Decorate pref value as CoreOptionsHandler::CreateValueForPref() does. DictionaryValue* dict = new DictionaryValue; if (!data) - data = new base::StringValue(""); + data = base::Value::CreateStringValue(""); dict->Set("value", data); if (path == kProxyType) { dict->SetString("controlledBy", controlled_by); diff --git a/chrome/browser/chromeos/settings/cros_settings_unittest.cc b/chrome/browser/chromeos/settings/cros_settings_unittest.cc index fe76ec3..e3fc928 100644 --- a/chrome/browser/chromeos/settings/cros_settings_unittest.cc +++ b/chrome/browser/chromeos/settings/cros_settings_unittest.cc @@ -119,7 +119,7 @@ TEST_F(CrosSettingsTest, SetWhitelist) { // Setting the whitelist should also switch the value of // kAccountsPrefAllowNewUser to false. base::ListValue whitelist; - whitelist.Append(new base::StringValue("me@owner")); + whitelist.Append(base::Value::CreateStringValue("me@owner")); AddExpectation(kAccountsPrefAllowNewUser, base::Value::CreateBooleanValue(false)); AddExpectation(kAccountsPrefUsers, whitelist.DeepCopy()); @@ -179,7 +179,7 @@ TEST_F(CrosSettingsTest, SetWhitelistAndNoNewUsers) { // Setting the whitelist should allow us to set kAccountsPrefAllowNewUser to // false (which is the implicit value too). base::ListValue whitelist; - whitelist.Append(new base::StringValue("me@owner")); + whitelist.Append(base::Value::CreateStringValue("me@owner")); AddExpectation(kAccountsPrefUsers, whitelist.DeepCopy()); AddExpectation(kAccountsPrefAllowNewUser, base::Value::CreateBooleanValue(false)); @@ -209,10 +209,10 @@ TEST_F(CrosSettingsTest, SetEphemeralUsersEnabled) { TEST_F(CrosSettingsTest, FindEmailInList) { base::ListValue list; - list.Append(new base::StringValue("user@example.com")); - list.Append(new base::StringValue("nodomain")); - list.Append(new base::StringValue("with.dots@gmail.com")); - list.Append(new base::StringValue("Upper@example.com")); + list.Append(base::Value::CreateStringValue("user@example.com")); + list.Append(base::Value::CreateStringValue("nodomain")); + list.Append(base::Value::CreateStringValue("with.dots@gmail.com")); + list.Append(base::Value::CreateStringValue("Upper@example.com")); CrosSettings* cs = &settings_; cs->Set(kAccountsPrefUsers, list); diff --git a/chrome/browser/chromeos/settings/device_settings_provider.cc b/chrome/browser/chromeos/settings/device_settings_provider.cc index 932f796..5f28b16 100644 --- a/chrome/browser/chromeos/settings/device_settings_provider.cc +++ b/chrome/browser/chromeos/settings/device_settings_provider.cc @@ -358,7 +358,7 @@ void DeviceSettingsProvider::DecodeLoginPolicies( whitelist_proto.user_whitelist(); for (RepeatedPtrField<std::string>::const_iterator it = whitelist.begin(); it != whitelist.end(); ++it) { - list->Append(new base::StringValue(*it)); + list->Append(base::Value::CreateStringValue(*it)); } new_values_cache->SetValue(kAccountsPrefUsers, list); } @@ -418,7 +418,7 @@ void DeviceSettingsProvider::DecodeKioskPolicies( const RepeatedPtrField<std::string>& urls = urls_proto.start_up_urls(); for (RepeatedPtrField<std::string>::const_iterator it = urls.begin(); it != urls.end(); ++it) { - list->Append(new base::StringValue(*it)); + list->Append(base::Value::CreateStringValue(*it)); } new_values_cache->SetValue(kStartUpUrls, list); } diff --git a/chrome/browser/chromeos/settings/system_settings_provider.cc b/chrome/browser/chromeos/settings/system_settings_provider.cc index 54e873e..75a8656 100644 --- a/chrome/browser/chromeos/settings/system_settings_provider.cc +++ b/chrome/browser/chromeos/settings/system_settings_provider.cc @@ -21,7 +21,7 @@ SystemSettingsProvider::SystemSettingsProvider( system::TimezoneSettings *timezone_settings = system::TimezoneSettings::GetInstance(); timezone_settings->AddObserver(this); - timezone_value_.reset(new base::StringValue( + timezone_value_.reset(base::Value::CreateStringValue( timezone_settings->GetCurrentTimezoneID())); } @@ -62,7 +62,7 @@ bool SystemSettingsProvider::HandlesSetting(const std::string& path) const { void SystemSettingsProvider::TimezoneChanged(const icu::TimeZone& timezone) { // Fires system setting change notification. - timezone_value_.reset(new base::StringValue( + timezone_value_.reset(base::Value::CreateStringValue( system::TimezoneSettings::GetTimezoneID(timezone))); NotifyObservers(kSystemTimezone); } diff --git a/chrome/browser/chromeos/settings/system_settings_provider.h b/chrome/browser/chromeos/settings/system_settings_provider.h index ef7c174..578a1c5 100644 --- a/chrome/browser/chromeos/settings/system_settings_provider.h +++ b/chrome/browser/chromeos/settings/system_settings_provider.h @@ -14,7 +14,7 @@ #include "third_party/icu/public/i18n/unicode/timezone.h" namespace base { -class StringValue; +class Value; } namespace chromeos { @@ -39,7 +39,7 @@ class SystemSettingsProvider : public CrosSettingsProvider, virtual void DoSet(const std::string& path, const base::Value& in_value) OVERRIDE; - scoped_ptr<base::StringValue> timezone_value_; + scoped_ptr<base::Value> timezone_value_; DISALLOW_COPY_AND_ASSIGN(SystemSettingsProvider); }; |