Index: extensions/browser/extension_prefs.cc |
diff --git a/extensions/browser/extension_prefs.cc b/extensions/browser/extension_prefs.cc |
index 83246170e3f07ee226d9db174e559f465d206d69..ee839b0a334e935e51badeed135c6e62ceeee69d 100644 |
--- a/extensions/browser/extension_prefs.cc |
+++ b/extensions/browser/extension_prefs.cc |
@@ -199,8 +199,9 @@ class ScopedExtensionPrefUpdate : public DictionaryPrefUpdate { |
base::DictionaryValue* extension = NULL; |
if (!dict->GetDictionary(extension_id_, &extension)) { |
// Extension pref does not exist, create it. |
- extension = new base::DictionaryValue(); |
- dict->SetWithoutPathExpansion(extension_id_, base::WrapUnique(extension)); |
+ dict->SetWithoutPathExpansion(extension_id_, |
+ base::MakeUnique<base::DictionaryValue>()); |
+ dict->GetDictionaryWithoutPathExpansion(extension_id_, &extension); |
} |
return extension; |
} |
@@ -298,14 +299,14 @@ T* ExtensionPrefs::ScopedUpdate<T, type_enum_value>::Create() { |
base::DictionaryValue* dict = update_.Get(); |
base::DictionaryValue* extension = nullptr; |
base::Value* key_value = nullptr; |
- T* value_as_t = nullptr; |
if (!dict->GetDictionary(extension_id_, &extension)) { |
- extension = new base::DictionaryValue; |
- dict->SetWithoutPathExpansion(extension_id_, base::WrapUnique(extension)); |
+ dict->SetWithoutPathExpansion(extension_id_, |
+ base::MakeUnique<base::DictionaryValue>()); |
+ dict->GetDictionaryWithoutPathExpansion(extension_id_, &extension); |
} |
if (!extension->Get(key_, &key_value)) { |
- value_as_t = new T; |
- extension->SetWithoutPathExpansion(key_, base::WrapUnique(value_as_t)); |
+ extension->SetWithoutPathExpansion(key_, base::MakeUnique<T>()); |
+ extension->GetWithoutPathExpansion(key_, &key_value); |
} else { |
// It would be nice to CHECK that this doesn't happen, but since prefs can |
// get into a mangled state, we can't really do that. Instead, handle it |
@@ -315,13 +316,11 @@ T* ExtensionPrefs::ScopedUpdate<T, type_enum_value>::Create() { |
// might be useful. Remove the dumps after we analyze them. |
if (key_value->GetType() != type_enum_value) { |
NOTREACHED(); |
- value_as_t = new T(); |
- extension->SetWithoutPathExpansion(key_, base::WrapUnique(value_as_t)); |
- } else { |
- value_as_t = static_cast<T*>(key_value); |
+ extension->SetWithoutPathExpansion(key_, base::MakeUnique<T>()); |
+ extension->GetWithoutPathExpansion(key_, &key_value); |
} |
} |
- return value_as_t; |
+ return static_cast<T*>(key_value); |
} |
// Explicit instantiations for Dictionary and List value types. |