Chromium Code Reviews| Index: chrome/browser/supervised_user/legacy/supervised_user_shared_settings_service.cc |
| diff --git a/chrome/browser/supervised_user/legacy/supervised_user_shared_settings_service.cc b/chrome/browser/supervised_user/legacy/supervised_user_shared_settings_service.cc |
| index 23df62a3ac1f9b82ec8210d6e2e9fa65c75dddfc..55aedbb13c9003a12fae13ca917680dc46ebedd5 100644 |
| --- a/chrome/browser/supervised_user/legacy/supervised_user_shared_settings_service.cc |
| +++ b/chrome/browser/supervised_user/legacy/supervised_user_shared_settings_service.cc |
| @@ -10,6 +10,7 @@ |
| #include "base/json/json_reader.h" |
| #include "base/json/json_writer.h" |
| +#include "base/memory/ptr_util.h" |
| #include "base/values.h" |
| #include "chrome/common/pref_names.h" |
| #include "components/pref_registry/pref_registry_syncable.h" |
| @@ -44,8 +45,9 @@ DictionaryValue* FindOrCreateDictionary(DictionaryValue* parent, |
| const std::string& key) { |
| DictionaryValue* dict = nullptr; |
| if (!parent->GetDictionaryWithoutPathExpansion(key, &dict)) { |
| - dict = new DictionaryValue; |
| - parent->SetWithoutPathExpansion(key, dict); |
| + parent->SetWithoutPathExpansion(key, |
| + base::MakeUnique<base::DictionaryValue>()); |
| + parent->GetDictionaryWithoutPathExpansion(key, &dict); |
|
Nico
2017/05/02 19:00:34
Use new form here too.
jdoerrie
2017/05/02 19:39:32
Done.
|
| } |
| return dict; |
| } |
| @@ -110,10 +112,11 @@ void SupervisedUserSharedSettingsService::SetValueInternal( |
| DictionaryValue* dict = nullptr; |
| bool has_key = update_dict->GetDictionaryWithoutPathExpansion(key, &dict); |
| if (!has_key) { |
| - dict = new DictionaryValue; |
| - update_dict->SetWithoutPathExpansion(key, dict); |
| + update_dict->SetWithoutPathExpansion( |
| + key, base::MakeUnique<base::DictionaryValue>()); |
| + update_dict->GetDictionaryWithoutPathExpansion(key, &dict); |
|
Nico
2017/05/02 19:00:34
Here too.
jdoerrie
2017/05/02 19:39:31
Done.
|
| } |
| - dict->SetWithoutPathExpansion(kValue, value.DeepCopy()); |
| + dict->SetWithoutPathExpansion(kValue, base::MakeUnique<base::Value>(value)); |
| dict->SetBooleanWithoutPathExpansion(kAcknowledged, acknowledged); |
| if (!sync_processor_) |
| @@ -230,7 +233,7 @@ SupervisedUserSharedSettingsService::MergeDataAndStartSyncing( |
| ScopedSupervisedUserSharedSettingsUpdate update(prefs_, su_id); |
| const std::string& key = supervised_user_shared_setting.key(); |
| DictionaryValue* dict = FindOrCreateDictionary(update.Get(), key); |
| - dict->SetWithoutPathExpansion(kValue, value.release()); |
| + dict->SetWithoutPathExpansion(kValue, std::move(value)); |
| // Every setting we get from the server should have the acknowledged flag |
| // set. |
| @@ -341,12 +344,13 @@ syncer::SyncError SupervisedUserSharedSettingsService::ProcessSyncChanges( |
| } else { |
| // Otherwise, it should be an add action. |
| DCHECK_EQ(SyncChange::ACTION_ADD, sync_change.change_type()); |
| - dict = new DictionaryValue; |
| - update_dict->SetWithoutPathExpansion(key, dict); |
| + update_dict->SetWithoutPathExpansion( |
| + key, base::MakeUnique<base::DictionaryValue>()); |
| + update_dict->GetDictionaryWithoutPathExpansion(key, &dict); |
|
Nico
2017/05/02 19:00:34
Here too
jdoerrie
2017/05/02 19:39:32
Done.
|
| } |
| std::unique_ptr<Value> value = |
| base::JSONReader::Read(supervised_user_shared_setting.value()); |
| - dict->SetWithoutPathExpansion(kValue, value.release()); |
| + dict->SetWithoutPathExpansion(kValue, std::move(value)); |
| dict->SetBooleanWithoutPathExpansion( |
| kAcknowledged, supervised_user_shared_setting.acknowledged()); |
| break; |