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

Unified Diff: components/error_page/common/localized_error.cc

Issue 2889163002: Remove raw DictionaryValue::Set in //components (Closed)
Patch Set: Nits Created 3 years, 7 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
« no previous file with comments | « components/domain_reliability/context.cc ('k') | components/error_page/renderer/net_error_helper_core.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/error_page/common/localized_error.cc
diff --git a/components/error_page/common/localized_error.cc b/components/error_page/common/localized_error.cc
index 580d3d746b0e071f3f58c28e9ab174c7cf95958e..7400c61131426654fc5a7837b2e6f0e2aa9173bf 100644
--- a/components/error_page/common/localized_error.cc
+++ b/components/error_page/common/localized_error.cc
@@ -506,7 +506,7 @@ void AddGoogleCachedCopyButton(base::ListValue* suggestions_summary_list,
l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_SHOW_SAVED_COPY));
cache_button->SetString("cacheUrl", cache_url);
cache_button->SetInteger("trackingId", cache_tracking_id);
- error_strings->Set("cacheButton", cache_button.release());
+ error_strings->Set("cacheButton", std::move(cache_button));
// Remove the item from suggestions dictionary so that it does not get
// displayed by the template in the details section.
@@ -900,13 +900,13 @@ void LocalizedError::GetStrings(
std::string icon_class = GetIconClassForError(error_domain, error_code);
error_strings->SetString("iconClass", icon_class);
- base::DictionaryValue* heading = new base::DictionaryValue;
+ auto heading = base::MakeUnique<base::DictionaryValue>();
heading->SetString("msg",
l10n_util::GetStringUTF16(options.heading_resource_id));
heading->SetString("hostName", host_name);
- error_strings->Set("heading", heading);
+ error_strings->Set("heading", std::move(heading));
- base::DictionaryValue* summary = new base::DictionaryValue;
+ auto summary = base::MakeUnique<base::DictionaryValue>();
// Set summary message under the heading.
summary->SetString(
@@ -934,7 +934,7 @@ void LocalizedError::GetStrings(
error_strings->SetString(
"hideDetails", l10n_util::GetStringUTF16(
IDS_ERRORPAGE_NET_BUTTON_HIDE_DETAILS));
- error_strings->Set("summary", summary);
+ error_strings->Set("summary", std::move(summary));
base::string16 error_string;
if (error_domain == net::kErrorDomain) {
@@ -961,16 +961,17 @@ void LocalizedError::GetStrings(
bool use_default_suggestions = true;
if (!params->override_suggestions) {
- suggestions_details = new base::ListValue();
- suggestions_summary_list = new base::ListValue();
// Detailed suggestion information.
- error_strings->Set("suggestionsDetails", suggestions_details);
+ suggestions_details = error_strings->SetList(
+ "suggestionsDetails", base::MakeUnique<base::ListValue>());
+ suggestions_summary_list = error_strings->SetList(
+ "suggestionsSummaryList", base::MakeUnique<base::ListValue>());
} else {
- suggestions_summary_list = params->override_suggestions.release();
+ suggestions_summary_list = error_strings->SetList(
+ "suggestionsSummaryList", std::move(params->override_suggestions));
use_default_suggestions = false;
AddGoogleCachedCopyButton(suggestions_summary_list, error_strings);
}
- error_strings->Set("suggestionsSummaryList", suggestions_summary_list);
if (params->search_url.is_valid()) {
std::unique_ptr<base::DictionaryValue> search_suggestion(
@@ -994,12 +995,12 @@ void LocalizedError::GetStrings(
#if defined(OS_ANDROID)
reload_visible = true;
#endif // defined(OS_ANDROID)
- base::DictionaryValue* reload_button = new base::DictionaryValue;
+ auto reload_button = base::MakeUnique<base::DictionaryValue>();
reload_button->SetString(
"msg", l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_RELOAD));
reload_button->SetString("reloadUrl", failed_url.spec());
- error_strings->Set("reloadButton", reload_button);
reload_button->SetInteger("reloadTrackingId", params->reload_tracking_id);
+ error_strings->Set("reloadButton", std::move(reload_button));
}
// If not using the default suggestions, nothing else to do.
@@ -1033,7 +1034,7 @@ void LocalizedError::GetStrings(
(show_saved_copy_primary || show_saved_copy_secondary));
if (show_saved_copy_visible) {
- base::DictionaryValue* show_saved_copy_button = new base::DictionaryValue;
+ auto show_saved_copy_button = base::MakeUnique<base::DictionaryValue>();
show_saved_copy_button->SetString(
"msg", l10n_util::GetStringUTF16(
IDS_ERRORPAGES_BUTTON_SHOW_SAVED_COPY));
@@ -1042,7 +1043,8 @@ void LocalizedError::GetStrings(
l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_SHOW_SAVED_COPY_HELP));
if (show_saved_copy_primary)
show_saved_copy_button->SetString("primary", "true");
- error_strings->Set("showSavedCopyButton", show_saved_copy_button);
+ error_strings->Set("showSavedCopyButton",
+ std::move(show_saved_copy_button));
}
#if defined(OS_ANDROID)
« no previous file with comments | « components/domain_reliability/context.cc ('k') | components/error_page/renderer/net_error_helper_core.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698