Index: chrome/browser/ui/webui/ntp/app_launcher_handler.cc |
diff --git a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc |
index 488ace929ebf7eb5f3bff0869bc0c9251d81a700..b6b522a6821c98ef927d673b6188e436f06f977a 100644 |
--- a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc |
+++ b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc |
@@ -6,6 +6,8 @@ |
#include <stddef.h> |
+#include <string> |
+#include <utility> |
#include <vector> |
#include "apps/metrics_names.h" |
@@ -14,6 +16,7 @@ |
#include "base/bind_helpers.h" |
#include "base/command_line.h" |
#include "base/i18n/rtl.h" |
+#include "base/memory/ptr_util.h" |
#include "base/metrics/field_trial.h" |
#include "base/metrics/histogram_macros.h" |
#include "base/strings/string_util.h" |
@@ -359,7 +362,7 @@ void AppLauncherHandler::FillAppDictionary(base::DictionaryValue* dictionary) { |
// CreateAppInfo and ClearOrdinals can change the extension prefs. |
base::AutoReset<bool> auto_reset(&ignore_changes_, true); |
- base::ListValue* list = new base::ListValue(); |
+ auto installed_extensions = base::MakeUnique<base::ListValue>(); |
Profile* profile = Profile::FromWebUI(web_ui()); |
PrefService* prefs = profile->GetPrefs(); |
@@ -368,24 +371,23 @@ void AppLauncherHandler::FillAppDictionary(base::DictionaryValue* dictionary) { |
const Extension* extension = extension_service_->GetInstalledExtension(*it); |
if (extension && extensions::ui_util::ShouldDisplayInNewTabPage( |
extension, profile)) { |
- list->Append(GetAppInfo(extension)); |
+ installed_extensions->Append(GetAppInfo(extension)); |
} |
} |
- dictionary->Set("apps", list); |
+ dictionary->Set("apps", std::move(installed_extensions)); |
const base::ListValue* app_page_names = |
prefs->GetList(prefs::kNtpAppPageNames); |
if (!app_page_names || !app_page_names->GetSize()) { |
ListPrefUpdate update(prefs, prefs::kNtpAppPageNames); |
base::ListValue* list = update.Get(); |
- list->Set(0, new base::Value( |
+ list->Set(0, base::MakeUnique<base::Value>( |
l10n_util::GetStringUTF16(IDS_APP_DEFAULT_PAGE_NAME))); |
- dictionary->Set("appPageNames", |
- static_cast<base::ListValue*>(list->DeepCopy())); |
+ dictionary->Set("appPageNames", base::MakeUnique<base::Value>(*list)); |
} else { |
dictionary->Set("appPageNames", |
- static_cast<base::ListValue*>(app_page_names->DeepCopy())); |
+ base::MakeUnique<base::Value>(*app_page_names)); |
} |
} |
@@ -681,7 +683,7 @@ void AppLauncherHandler::HandleSetPageIndex(const base::ListValue* args) { |
} |
void AppLauncherHandler::HandleSaveAppPageName(const base::ListValue* args) { |
- base::string16 name; |
+ std::string name; |
CHECK(args->GetString(0, &name)); |
double page_index; |
@@ -691,7 +693,8 @@ void AppLauncherHandler::HandleSaveAppPageName(const base::ListValue* args) { |
PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); |
ListPrefUpdate update(prefs, prefs::kNtpAppPageNames); |
base::ListValue* list = update.Get(); |
- list->Set(static_cast<size_t>(page_index), new base::Value(name)); |
+ list->Set(static_cast<size_t>(page_index), |
+ base::MakeUnique<base::Value>(name)); |
} |
void AppLauncherHandler::HandleGenerateAppForLink(const base::ListValue* args) { |