| Index: components/policy/core/common/registry_dict_win.cc
|
| diff --git a/components/policy/core/common/registry_dict_win.cc b/components/policy/core/common/registry_dict_win.cc
|
| index a12ed43e35b00d8332265a596e3502dd5ebd697a..6451ea8bef48f5c6ef683f91f9e3bf89dd79cc85 100644
|
| --- a/components/policy/core/common/registry_dict_win.cc
|
| +++ b/components/policy/core/common/registry_dict_win.cc
|
| @@ -26,8 +26,8 @@ namespace {
|
| // Converts a value (as read from the registry) to meet |schema|, converting
|
| // types as necessary. Unconvertible types will show up as NULL values in the
|
| // result.
|
| -scoped_ptr<base::Value> ConvertValue(const base::Value& value,
|
| - const Schema& schema) {
|
| +std::unique_ptr<base::Value> ConvertValue(const base::Value& value,
|
| + const Schema& schema) {
|
| if (!schema.valid())
|
| return value.CreateDeepCopy();
|
|
|
| @@ -37,20 +37,21 @@ scoped_ptr<base::Value> ConvertValue(const base::Value& value,
|
| const base::DictionaryValue* dict = NULL;
|
| const base::ListValue* list = NULL;
|
| if (value.GetAsDictionary(&dict)) {
|
| - scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue());
|
| + std::unique_ptr<base::DictionaryValue> result(
|
| + new base::DictionaryValue());
|
| for (base::DictionaryValue::Iterator entry(*dict); !entry.IsAtEnd();
|
| entry.Advance()) {
|
| - scoped_ptr<base::Value> converted =
|
| + std::unique_ptr<base::Value> converted =
|
| ConvertValue(entry.value(), schema.GetProperty(entry.key()));
|
| if (converted)
|
| result->SetWithoutPathExpansion(entry.key(), converted.release());
|
| }
|
| return std::move(result);
|
| } else if (value.GetAsList(&list)) {
|
| - scoped_ptr<base::ListValue> result(new base::ListValue());
|
| + std::unique_ptr<base::ListValue> result(new base::ListValue());
|
| for (base::ListValue::const_iterator entry(list->begin());
|
| entry != list->end(); ++entry) {
|
| - scoped_ptr<base::Value> converted =
|
| + std::unique_ptr<base::Value> converted =
|
| ConvertValue(**entry, schema.GetItems());
|
| if (converted)
|
| result->Append(converted.release());
|
| @@ -72,7 +73,7 @@ scoped_ptr<base::Value> ConvertValue(const base::Value& value,
|
| if (value.GetAsInteger(&int_value) ||
|
| (value.GetAsString(&string_value) &&
|
| base::StringToInt(string_value, &int_value))) {
|
| - return scoped_ptr<base::Value>(
|
| + return std::unique_ptr<base::Value>(
|
| new base::FundamentalValue(int_value != 0));
|
| }
|
| break;
|
| @@ -81,7 +82,8 @@ scoped_ptr<base::Value> ConvertValue(const base::Value& value,
|
| // Integers may be string-encoded.
|
| if (value.GetAsString(&string_value) &&
|
| base::StringToInt(string_value, &int_value)) {
|
| - return scoped_ptr<base::Value>(new base::FundamentalValue(int_value));
|
| + return std::unique_ptr<base::Value>(
|
| + new base::FundamentalValue(int_value));
|
| }
|
| break;
|
| }
|
| @@ -91,7 +93,7 @@ scoped_ptr<base::Value> ConvertValue(const base::Value& value,
|
| if (value.GetAsDouble(&double_value) ||
|
| (value.GetAsString(&string_value) &&
|
| base::StringToDouble(string_value, &double_value))) {
|
| - return scoped_ptr<base::Value>(
|
| + return std::unique_ptr<base::Value>(
|
| new base::FundamentalValue(double_value));
|
| }
|
| break;
|
| @@ -100,12 +102,12 @@ scoped_ptr<base::Value> ConvertValue(const base::Value& value,
|
| // Lists are encoded as subkeys with numbered value in the registry.
|
| const base::DictionaryValue* dict = NULL;
|
| if (value.GetAsDictionary(&dict)) {
|
| - scoped_ptr<base::ListValue> result(new base::ListValue());
|
| + std::unique_ptr<base::ListValue> result(new base::ListValue());
|
| for (int i = 1; ; ++i) {
|
| const base::Value* entry = NULL;
|
| if (!dict->Get(base::IntToString(i), &entry))
|
| break;
|
| - scoped_ptr<base::Value> converted =
|
| + std::unique_ptr<base::Value> converted =
|
| ConvertValue(*entry, schema.GetItems());
|
| if (converted)
|
| result->Append(converted.release());
|
| @@ -117,7 +119,8 @@ scoped_ptr<base::Value> ConvertValue(const base::Value& value,
|
| case base::Value::TYPE_DICTIONARY: {
|
| // Dictionaries may be encoded as JSON strings.
|
| if (value.GetAsString(&string_value)) {
|
| - scoped_ptr<base::Value> result = base::JSONReader::Read(string_value);
|
| + std::unique_ptr<base::Value> result =
|
| + base::JSONReader::Read(string_value);
|
| if (result && result->IsType(schema.type()))
|
| return result;
|
| }
|
| @@ -159,7 +162,7 @@ const RegistryDict* RegistryDict::GetKey(const std::string& name) const {
|
| }
|
|
|
| void RegistryDict::SetKey(const std::string& name,
|
| - scoped_ptr<RegistryDict> dict) {
|
| + std::unique_ptr<RegistryDict> dict) {
|
| if (!dict) {
|
| RemoveKey(name);
|
| return;
|
| @@ -170,8 +173,8 @@ void RegistryDict::SetKey(const std::string& name,
|
| entry = dict.release();
|
| }
|
|
|
| -scoped_ptr<RegistryDict> RegistryDict::RemoveKey(const std::string& name) {
|
| - scoped_ptr<RegistryDict> result;
|
| +std::unique_ptr<RegistryDict> RegistryDict::RemoveKey(const std::string& name) {
|
| + std::unique_ptr<RegistryDict> result;
|
| KeyMap::iterator entry = keys_.find(name);
|
| if (entry != keys_.end()) {
|
| result.reset(entry->second);
|
| @@ -195,7 +198,7 @@ const base::Value* RegistryDict::GetValue(const std::string& name) const {
|
| }
|
|
|
| void RegistryDict::SetValue(const std::string& name,
|
| - scoped_ptr<base::Value> dict) {
|
| + std::unique_ptr<base::Value> dict) {
|
| if (!dict) {
|
| RemoveValue(name);
|
| return;
|
| @@ -206,8 +209,9 @@ void RegistryDict::SetValue(const std::string& name,
|
| entry = dict.release();
|
| }
|
|
|
| -scoped_ptr<base::Value> RegistryDict::RemoveValue(const std::string& name) {
|
| - scoped_ptr<base::Value> result;
|
| +std::unique_ptr<base::Value> RegistryDict::RemoveValue(
|
| + const std::string& name) {
|
| + std::unique_ptr<base::Value> result;
|
| ValueMap::iterator entry = values_.find(name);
|
| if (entry != values_.end()) {
|
| result.reset(entry->second);
|
| @@ -250,9 +254,8 @@ void RegistryDict::ReadRegistry(HKEY hive, const base::string16& root) {
|
| switch (it.Type()) {
|
| case REG_SZ:
|
| case REG_EXPAND_SZ:
|
| - SetValue(name,
|
| - scoped_ptr<base::Value>(
|
| - new base::StringValue(base::UTF16ToUTF8(it.Value()))));
|
| + SetValue(name, std::unique_ptr<base::Value>(new base::StringValue(
|
| + base::UTF16ToUTF8(it.Value()))));
|
| continue;
|
| case REG_DWORD_LITTLE_ENDIAN:
|
| case REG_DWORD_BIG_ENDIAN:
|
| @@ -263,7 +266,7 @@ void RegistryDict::ReadRegistry(HKEY hive, const base::string16& root) {
|
| else
|
| dword_value = base::ByteSwapToLE32(dword_value);
|
| SetValue(name,
|
| - scoped_ptr<base::Value>(new base::FundamentalValue(
|
| + std::unique_ptr<base::Value>(new base::FundamentalValue(
|
| static_cast<int>(dword_value))));
|
| continue;
|
| }
|
| @@ -286,24 +289,25 @@ void RegistryDict::ReadRegistry(HKEY hive, const base::string16& root) {
|
| // Recurse for all subkeys.
|
| for (RegistryKeyIterator it(hive, root.c_str()); it.Valid(); ++it) {
|
| std::string name(base::UTF16ToUTF8(it.Name()));
|
| - scoped_ptr<RegistryDict> subdict(new RegistryDict());
|
| + std::unique_ptr<RegistryDict> subdict(new RegistryDict());
|
| subdict->ReadRegistry(hive, root + L"\\" + it.Name());
|
| SetKey(name, std::move(subdict));
|
| }
|
| }
|
|
|
| -scoped_ptr<base::Value> RegistryDict::ConvertToJSON(
|
| +std::unique_ptr<base::Value> RegistryDict::ConvertToJSON(
|
| const Schema& schema) const {
|
| base::Value::Type type =
|
| schema.valid() ? schema.type() : base::Value::TYPE_DICTIONARY;
|
| switch (type) {
|
| case base::Value::TYPE_DICTIONARY: {
|
| - scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue());
|
| + std::unique_ptr<base::DictionaryValue> result(
|
| + new base::DictionaryValue());
|
| for (RegistryDict::ValueMap::const_iterator entry(values_.begin());
|
| entry != values_.end(); ++entry) {
|
| Schema subschema =
|
| schema.valid() ? schema.GetProperty(entry->first) : Schema();
|
| - scoped_ptr<base::Value> converted =
|
| + std::unique_ptr<base::Value> converted =
|
| ConvertValue(*entry->second, subschema);
|
| if (converted)
|
| result->SetWithoutPathExpansion(entry->first, converted.release());
|
| @@ -312,7 +316,7 @@ scoped_ptr<base::Value> RegistryDict::ConvertToJSON(
|
| entry != keys_.end(); ++entry) {
|
| Schema subschema =
|
| schema.valid() ? schema.GetProperty(entry->first) : Schema();
|
| - scoped_ptr<base::Value> converted =
|
| + std::unique_ptr<base::Value> converted =
|
| entry->second->ConvertToJSON(subschema);
|
| if (converted)
|
| result->SetWithoutPathExpansion(entry->first, converted.release());
|
| @@ -320,20 +324,22 @@ scoped_ptr<base::Value> RegistryDict::ConvertToJSON(
|
| return std::move(result);
|
| }
|
| case base::Value::TYPE_LIST: {
|
| - scoped_ptr<base::ListValue> result(new base::ListValue());
|
| + std::unique_ptr<base::ListValue> result(new base::ListValue());
|
| Schema item_schema = schema.valid() ? schema.GetItems() : Schema();
|
| for (int i = 1; ; ++i) {
|
| const std::string name(base::IntToString(i));
|
| const RegistryDict* key = GetKey(name);
|
| if (key) {
|
| - scoped_ptr<base::Value> converted = key->ConvertToJSON(item_schema);
|
| + std::unique_ptr<base::Value> converted =
|
| + key->ConvertToJSON(item_schema);
|
| if (converted)
|
| result->Append(converted.release());
|
| continue;
|
| }
|
| const base::Value* value = GetValue(name);
|
| if (value) {
|
| - scoped_ptr<base::Value> converted = ConvertValue(*value, item_schema);
|
| + std::unique_ptr<base::Value> converted =
|
| + ConvertValue(*value, item_schema);
|
| if (converted)
|
| result->Append(converted.release());
|
| continue;
|
|
|