Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5510)

Unified Diff: chrome/browser/ui/webui/ntp/app_launcher_handler.cc

Issue 2812953002: Stop passing raw pointers to base::Value API in c/b/ui (Closed)
Patch Set: Rebased Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..075f9a57c34718fa9ed9a25ed4c7c30c3d58e7cc 100644
--- a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
+++ b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
@@ -14,6 +14,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 +360,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 +369,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)));
jdoerrie 2017/04/13 09:08:52 SetString
vabr (Chromium) 2017/04/13 12:03:14 There is no SetString in ListValue.
- 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));
}
}
@@ -691,7 +691,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));
jdoerrie 2017/04/13 09:08:52 SetString
vabr (Chromium) 2017/04/13 12:03:14 There is no SetString in ListValue. But I at least
jdoerrie 2017/04/13 12:09:41 True, my bad. I saw 'Set' and immediately assumed
}
void AppLauncherHandler::HandleGenerateAppForLink(const base::ListValue* args) {

Powered by Google App Engine
This is Rietveld 408576698