0

Remove use of deprecated base::Value functionality

Bug: 1187105
Change-Id: I0f901d4bc22bbb651a593843fcfc1975191fca45
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2941822
Reviewed-by: Edward Jung (EMEA) <edwardjung@chromium.org>
Commit-Queue: Dan H <harringtond@chromium.org>
Cr-Commit-Position: refs/heads/master@{#890855}
This commit is contained in:
Dan Harrington
2021-06-09 17:56:51 +00:00
committed by Chromium LUCI CQ
parent 1003e90a26
commit e6c735ea78

@@ -515,11 +515,12 @@ const LocalizedErrorMap* LookupErrorMap(const std::string& error_domain,
// Returns a dictionary containing the strings for the settings menu under the // Returns a dictionary containing the strings for the settings menu under the
// app menu, and the advanced settings button. // app menu, and the advanced settings button.
base::DictionaryValue* GetStandardMenuItemsText() { base::DictionaryValue GetStandardMenuItemsText() {
base::DictionaryValue* standard_menu_items_text = new base::DictionaryValue(); base::DictionaryValue standard_menu_items_text;
standard_menu_items_text->SetString("settingsTitle", standard_menu_items_text.SetStringPath(
l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE)); "settingsTitle", l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE));
standard_menu_items_text->SetString("advancedTitle", standard_menu_items_text.SetStringPath(
"advancedTitle",
l10n_util::GetStringUTF16(IDS_SETTINGS_SHOW_ADVANCED_SETTINGS)); l10n_util::GetStringUTF16(IDS_SETTINGS_SHOW_ADVANCED_SETTINGS));
return standard_menu_items_text; return standard_menu_items_text;
} }
@@ -539,27 +540,19 @@ const char* GetIconClassForError(const std::string& error_domain,
: "icon-generic"; : "icon-generic";
} }
// Helper function that creates a single entry dictionary and adds it base::DictionaryValue SingleEntryDictionary(base::StringPiece path,
// to a ListValue, int message_id) {
void AddSingleEntryDictionaryToList(base::ListValue* list, base::DictionaryValue result;
const char* path, result.SetStringPath(path, l10n_util::GetStringUTF16(message_id));
int message_id, return result;
bool insert_as_first_item) {
auto suggestion_list_item = std::make_unique<base::DictionaryValue>();
suggestion_list_item->SetString(path, l10n_util::GetStringUTF16(message_id));
if (insert_as_first_item) {
list->Insert(0, std::move(suggestion_list_item));
} else {
list->Append(std::move(suggestion_list_item));
}
} }
// Adds a linked suggestion dictionary entry to the suggestions list. // Adds a linked suggestion dictionary entry to the suggestions list.
void AddLinkedSuggestionToList(const int error_code, void AddLinkedSuggestionToList(
const std::string& locale, const int error_code,
base::ListValue* suggestions_summary_list, const std::string& locale,
bool standalone_suggestion) { std::vector<base::Value>& suggestions_summary_list,
bool standalone_suggestion) {
GURL learn_more_url; GURL learn_more_url;
std::u16string suggestion_string = std::u16string suggestion_string =
standalone_suggestion standalone_suggestion
@@ -586,12 +579,11 @@ void AddLinkedSuggestionToList(const int error_code,
repl.SetQueryStr(query); repl.SetQueryStr(query);
GURL learn_more_url_with_locale = learn_more_url.ReplaceComponents(repl); GURL learn_more_url_with_locale = learn_more_url.ReplaceComponents(repl);
std::unique_ptr<base::DictionaryValue> suggestion_list_item( base::DictionaryValue suggestion_list_item;
new base::DictionaryValue); suggestion_list_item.SetStringPath("summary", suggestion_string);
suggestion_list_item->SetString("summary", suggestion_string); suggestion_list_item.SetStringPath("learnMoreUrl",
suggestion_list_item->SetString("learnMoreUrl", learn_more_url_with_locale.spec());
learn_more_url_with_locale.spec()); suggestions_summary_list.push_back(std::move(suggestion_list_item));
suggestions_summary_list->Append(std::move(suggestion_list_item));
} }
// Check if a suggestion is in the bitmap of suggestions. // Check if a suggestion is in the bitmap of suggestions.
@@ -606,13 +598,14 @@ bool IsOnlySuggestion(int suggestions, int suggestion) {
// Creates a list of suggestions that a user may try to resolve a particular // Creates a list of suggestions that a user may try to resolve a particular
// network error. Appears above the fold underneath heading and intro paragraph. // network error. Appears above the fold underneath heading and intro paragraph.
void GetSuggestionsSummaryList(int error_code, void GetSuggestionsSummaryList(
base::DictionaryValue* error_strings, int error_code,
int suggestions, base::DictionaryValue* error_strings,
const std::string& locale, int suggestions,
base::ListValue* suggestions_summary_list, const std::string& locale,
bool can_show_network_diagnostics_dialog, std::vector<base::Value>& suggestions_summary_list,
const GURL& failed_url) { bool can_show_network_diagnostics_dialog,
const GURL& failed_url) {
// Remove the diagnostic tool suggestion if the platform doesn't support it // Remove the diagnostic tool suggestion if the platform doesn't support it
// or the url isn't valid. // or the url isn't valid.
if (!can_show_network_diagnostics_dialog || !failed_url.is_valid() || if (!can_show_network_diagnostics_dialog || !failed_url.is_valid() ||
@@ -624,60 +617,60 @@ void GetSuggestionsSummaryList(int error_code,
return; return;
if (IsOnlySuggestion(suggestions, SUGGEST_CONTACT_ADMINISTRATOR)) { if (IsOnlySuggestion(suggestions, SUGGEST_CONTACT_ADMINISTRATOR)) {
DCHECK(suggestions_summary_list->GetList().empty()); DCHECK(suggestions_summary_list.empty());
DCHECK(!(suggestions & ~SUGGEST_CONTACT_ADMINISTRATOR)); DCHECK(!(suggestions & ~SUGGEST_CONTACT_ADMINISTRATOR));
AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", suggestions_summary_list.push_back(SingleEntryDictionary(
IDS_ERRORPAGES_SUGGESTION_CONTACT_ADMIN_SUMMARY_STANDALONE, false); "summary", IDS_ERRORPAGES_SUGGESTION_CONTACT_ADMIN_SUMMARY_STANDALONE));
return; return;
} }
if (IsSuggested(suggestions, SUGGEST_CONTACT_ADMINISTRATOR)) { if (IsSuggested(suggestions, SUGGEST_CONTACT_ADMINISTRATOR)) {
AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", suggestions_summary_list.push_back(SingleEntryDictionary(
IDS_ERRORPAGES_SUGGESTION_CONTACT_ADMIN_SUMMARY, false); "summary", IDS_ERRORPAGES_SUGGESTION_CONTACT_ADMIN_SUMMARY));
} }
if (IsOnlySuggestion(suggestions, SUGGEST_COMPLETE_SETUP)) { if (IsOnlySuggestion(suggestions, SUGGEST_COMPLETE_SETUP)) {
DCHECK(suggestions_summary_list->GetList().empty()); DCHECK(suggestions_summary_list.empty());
DCHECK(!(suggestions & ~SUGGEST_COMPLETE_SETUP)); DCHECK(!(suggestions & ~SUGGEST_COMPLETE_SETUP));
AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", suggestions_summary_list.push_back(SingleEntryDictionary(
IDS_ERRORPAGES_SUGGESTION_DIAGNOSE_CONNECTION_SUMMARY, false); "summary", IDS_ERRORPAGES_SUGGESTION_DIAGNOSE_CONNECTION_SUMMARY));
AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", suggestions_summary_list.push_back(SingleEntryDictionary(
IDS_ERRORPAGES_SUGGESTION_COMPLETE_SETUP_SUMMARY, false); "summary", IDS_ERRORPAGES_SUGGESTION_COMPLETE_SETUP_SUMMARY));
return; return;
} }
DCHECK(!IsSuggested(suggestions, SUGGEST_COMPLETE_SETUP)); DCHECK(!IsSuggested(suggestions, SUGGEST_COMPLETE_SETUP));
if (IsOnlySuggestion(suggestions,SUGGEST_REPOST_RELOAD)) { if (IsOnlySuggestion(suggestions,SUGGEST_REPOST_RELOAD)) {
DCHECK(suggestions_summary_list->GetList().empty()); DCHECK(suggestions_summary_list.empty());
DCHECK(!(suggestions & ~SUGGEST_REPOST_RELOAD)); DCHECK(!(suggestions & ~SUGGEST_REPOST_RELOAD));
// If the page was created by a post, it can't be reloaded in the same // If the page was created by a post, it can't be reloaded in the same
// way, so just add a suggestion instead. // way, so just add a suggestion instead.
// TODO(mmenke): Make the reload button bring up the repost confirmation // TODO(mmenke): Make the reload button bring up the repost confirmation
// dialog for pages resulting from posts. // dialog for pages resulting from posts.
AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", suggestions_summary_list.push_back(SingleEntryDictionary(
IDS_ERRORPAGES_SUGGESTION_RELOAD_REPOST_SUMMARY, false); "summary", IDS_ERRORPAGES_SUGGESTION_RELOAD_REPOST_SUMMARY));
return; return;
} }
DCHECK(!IsSuggested(suggestions, SUGGEST_REPOST_RELOAD)); DCHECK(!IsSuggested(suggestions, SUGGEST_REPOST_RELOAD));
if (IsOnlySuggestion(suggestions, SUGGEST_NAVIGATE_TO_ORIGIN)) { if (IsOnlySuggestion(suggestions, SUGGEST_NAVIGATE_TO_ORIGIN)) {
DCHECK(suggestions_summary_list->GetList().empty()); DCHECK(suggestions_summary_list.empty());
DCHECK(!(suggestions & ~SUGGEST_NAVIGATE_TO_ORIGIN)); DCHECK(!(suggestions & ~SUGGEST_NAVIGATE_TO_ORIGIN));
url::Origin failed_origin = url::Origin::Create(failed_url); url::Origin failed_origin = url::Origin::Create(failed_url);
if (failed_origin.opaque()) if (failed_origin.opaque())
return; return;
auto suggestion = std::make_unique<base::DictionaryValue>(); base::DictionaryValue suggestion;
suggestion->SetString("summary", suggestion.SetStringPath("summary",
l10n_util::GetStringUTF16( l10n_util::GetStringUTF16(
IDS_ERRORPAGES_SUGGESTION_NAVIGATE_TO_ORIGIN)); IDS_ERRORPAGES_SUGGESTION_NAVIGATE_TO_ORIGIN));
suggestion->SetString("originURL", failed_origin.Serialize()); suggestion.SetStringPath("originURL", failed_origin.Serialize());
suggestions_summary_list->Append(std::move(suggestion)); suggestions_summary_list.push_back(std::move(suggestion));
return; return;
} }
DCHECK(!IsSuggested(suggestions, SUGGEST_NAVIGATE_TO_ORIGIN)); DCHECK(!IsSuggested(suggestions, SUGGEST_NAVIGATE_TO_ORIGIN));
if (IsOnlySuggestion(suggestions, SUGGEST_LEARNMORE)) { if (IsOnlySuggestion(suggestions, SUGGEST_LEARNMORE)) {
DCHECK(suggestions_summary_list->GetList().empty()); DCHECK(suggestions_summary_list.empty());
AddLinkedSuggestionToList(error_code, locale, suggestions_summary_list, AddLinkedSuggestionToList(error_code, locale, suggestions_summary_list,
true); true);
return; return;
@@ -688,42 +681,41 @@ void GetSuggestionsSummaryList(int error_code,
} }
if (suggestions & SUGGEST_DISABLE_EXTENSION) { if (suggestions & SUGGEST_DISABLE_EXTENSION) {
DCHECK(suggestions_summary_list->GetList().empty()); DCHECK(suggestions_summary_list.empty());
AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", suggestions_summary_list.push_back(SingleEntryDictionary(
IDS_ERRORPAGES_SUGGESTION_DISABLE_EXTENSION_SUMMARY, false); "summary", IDS_ERRORPAGES_SUGGESTION_DISABLE_EXTENSION_SUMMARY));
return; return;
} }
DCHECK(!IsSuggested(suggestions, SUGGEST_DISABLE_EXTENSION)); DCHECK(!IsSuggested(suggestions, SUGGEST_DISABLE_EXTENSION));
if (suggestions & SUGGEST_CHECK_CONNECTION) { if (suggestions & SUGGEST_CHECK_CONNECTION) {
AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", suggestions_summary_list.push_back(SingleEntryDictionary(
IDS_ERRORPAGES_SUGGESTION_CHECK_CONNECTION_SUMMARY, false); "summary", IDS_ERRORPAGES_SUGGESTION_CHECK_CONNECTION_SUMMARY));
} }
#if !defined(OS_ANDROID) && !defined(OS_IOS) #if !defined(OS_ANDROID) && !defined(OS_IOS)
if (IsSuggested(suggestions, SUGGEST_DNS_CONFIG) && if (IsSuggested(suggestions, SUGGEST_DNS_CONFIG) &&
IsSuggested(suggestions, SUGGEST_FIREWALL_CONFIG) && IsSuggested(suggestions, SUGGEST_FIREWALL_CONFIG) &&
IsSuggested(suggestions, SUGGEST_PROXY_CONFIG)) { IsSuggested(suggestions, SUGGEST_PROXY_CONFIG)) {
AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", suggestions_summary_list.push_back(SingleEntryDictionary(
IDS_ERRORPAGES_SUGGESTION_CHECK_PROXY_FIREWALL_DNS_SUMMARY, false); "summary", IDS_ERRORPAGES_SUGGESTION_CHECK_PROXY_FIREWALL_DNS_SUMMARY));
} else if (IsSuggested(suggestions, SUGGEST_SECURE_DNS_CONFIG) && } else if (IsSuggested(suggestions, SUGGEST_SECURE_DNS_CONFIG) &&
IsSuggested(suggestions, SUGGEST_FIREWALL_CONFIG) && IsSuggested(suggestions, SUGGEST_FIREWALL_CONFIG) &&
IsSuggested(suggestions, SUGGEST_PROXY_CONFIG)) { IsSuggested(suggestions, SUGGEST_PROXY_CONFIG)) {
AddSingleEntryDictionaryToList( suggestions_summary_list.push_back(SingleEntryDictionary(
suggestions_summary_list, "summary", "summary",
IDS_ERRORPAGES_SUGGESTION_CHECK_PROXY_FIREWALL_SECURE_DNS_SUMMARY, IDS_ERRORPAGES_SUGGESTION_CHECK_PROXY_FIREWALL_SECURE_DNS_SUMMARY));
false);
} else if (IsSuggested(suggestions, SUGGEST_FIREWALL_CONFIG) && } else if (IsSuggested(suggestions, SUGGEST_FIREWALL_CONFIG) &&
IsSuggested(suggestions, SUGGEST_ANTIVIRUS_CONFIG)) { IsSuggested(suggestions, SUGGEST_ANTIVIRUS_CONFIG)) {
AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", suggestions_summary_list.push_back(SingleEntryDictionary(
IDS_ERRORPAGES_SUGGESTION_CHECK_FIREWALL_ANTIVIRUS_SUMMARY, false); "summary", IDS_ERRORPAGES_SUGGESTION_CHECK_FIREWALL_ANTIVIRUS_SUMMARY));
} else if (IsSuggested(suggestions, SUGGEST_PROXY_CONFIG) && } else if (IsSuggested(suggestions, SUGGEST_PROXY_CONFIG) &&
IsSuggested(suggestions, SUGGEST_FIREWALL_CONFIG)) { IsSuggested(suggestions, SUGGEST_FIREWALL_CONFIG)) {
AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", suggestions_summary_list.push_back(SingleEntryDictionary(
IDS_ERRORPAGES_SUGGESTION_CHECK_PROXY_FIREWALL_SUMMARY, false); "summary", IDS_ERRORPAGES_SUGGESTION_CHECK_PROXY_FIREWALL_SUMMARY));
} else if (IsSuggested(suggestions, SUGGEST_PROXY_CONFIG)) { } else if (IsSuggested(suggestions, SUGGEST_PROXY_CONFIG)) {
AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", suggestions_summary_list.push_back(SingleEntryDictionary(
IDS_ERRORPAGES_SUGGESTION_CHECK_PROXY_ADDRESS_SUMMARY, false); "summary", IDS_ERRORPAGES_SUGGESTION_CHECK_PROXY_ADDRESS_SUMMARY));
} else { } else {
DCHECK(!(suggestions & SUGGEST_PROXY_CONFIG)); DCHECK(!(suggestions & SUGGEST_PROXY_CONFIG));
DCHECK(!(suggestions & SUGGEST_FIREWALL_CONFIG)); DCHECK(!(suggestions & SUGGEST_FIREWALL_CONFIG));
@@ -732,25 +724,24 @@ void GetSuggestionsSummaryList(int error_code,
} }
#elif defined(OS_ANDROID) #elif defined(OS_ANDROID)
if (IsSuggested(suggestions, SUGGEST_SECURE_DNS_CONFIG)) { if (IsSuggested(suggestions, SUGGEST_SECURE_DNS_CONFIG)) {
AddSingleEntryDictionaryToList( suggestions_summary_list.push_back(SingleEntryDictionary(
suggestions_summary_list, "summary", "summary", IDS_ERRORPAGES_SUGGESTION_CHECK_SECURE_DNS_SUMMARY));
IDS_ERRORPAGES_SUGGESTION_CHECK_SECURE_DNS_SUMMARY, false);
} }
#endif #endif
if (IsSuggested(suggestions, SUGGEST_OFFLINE_CHECKS)) { if (IsSuggested(suggestions, SUGGEST_OFFLINE_CHECKS)) {
#if defined(OS_ANDROID) || defined(OS_IOS) #if defined(OS_ANDROID) || defined(OS_IOS)
AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", suggestions_summary_list.push_back(SingleEntryDictionary(
IDS_ERRORPAGES_SUGGESTION_TURN_OFF_AIRPLANE_SUMMARY, false); "summary", IDS_ERRORPAGES_SUGGESTION_TURN_OFF_AIRPLANE_SUMMARY));
AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", suggestions_summary_list.push_back(SingleEntryDictionary(
IDS_ERRORPAGES_SUGGESTION_TURN_ON_DATA_SUMMARY, false); "summary", IDS_ERRORPAGES_SUGGESTION_TURN_ON_DATA_SUMMARY));
AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", suggestions_summary_list.push_back(SingleEntryDictionary(
IDS_ERRORPAGES_SUGGESTION_CHECKING_SIGNAL_SUMMARY, false); "summary", IDS_ERRORPAGES_SUGGESTION_CHECKING_SIGNAL_SUMMARY));
#else #else
AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", suggestions_summary_list.push_back(SingleEntryDictionary(
IDS_ERRORPAGES_SUGGESTION_CHECK_HARDWARE_SUMMARY, false); "summary", IDS_ERRORPAGES_SUGGESTION_CHECK_HARDWARE_SUMMARY));
AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", suggestions_summary_list.push_back(SingleEntryDictionary(
IDS_ERRORPAGES_SUGGESTION_CHECK_WIFI_SUMMARY, false); "summary", IDS_ERRORPAGES_SUGGESTION_CHECK_WIFI_SUMMARY));
#endif #endif
} }
@@ -763,50 +754,42 @@ void GetSuggestionsSummaryList(int error_code,
? IDS_ERRORPAGES_SUGGESTION_DIAGNOSE_CHECK_TYPO_STANDALONE ? IDS_ERRORPAGES_SUGGESTION_DIAGNOSE_CHECK_TYPO_STANDALONE
: IDS_ERRORPAGES_SUGGESTION_DIAGNOSE_STANDALONE; : IDS_ERRORPAGES_SUGGESTION_DIAGNOSE_STANDALONE;
AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", suggestions_summary_list.push_back(
diagose_message_id, false); SingleEntryDictionary("summary", diagose_message_id));
return; return;
} }
if (IsSuggested(suggestions, SUGGEST_DIAGNOSE_TOOL)) { if (IsSuggested(suggestions, SUGGEST_DIAGNOSE_TOOL)) {
AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", suggestions_summary_list.push_back(
IDS_ERRORPAGES_SUGGESTION_DIAGNOSE, false); SingleEntryDictionary("summary", IDS_ERRORPAGES_SUGGESTION_DIAGNOSE));
} }
#else #else
DCHECK(!IsSuggested(suggestions, SUGGEST_DIAGNOSE_TOOL)); DCHECK(!IsSuggested(suggestions, SUGGEST_DIAGNOSE_TOOL));
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || defined(OS_WIN) || defined(OS_MAC) #endif // BUILDFLAG(IS_CHROMEOS_ASH) || defined(OS_WIN) || defined(OS_MAC)
// Add list prefix header. // Add list prefix header.
error_strings->SetString("suggestionsSummaryListHeader", error_strings->SetStringPath(
"suggestionsSummaryListHeader",
l10n_util::GetStringUTF16(IDS_ERRORPAGES_SUGGESTION_LIST_HEADER)); l10n_util::GetStringUTF16(IDS_ERRORPAGES_SUGGESTION_LIST_HEADER));
} }
// Creates a dictionary with "header" and "body" entries and adds it // Creates a dictionary with "header" and "body" entries and adds it to `list`.
// to a ListValue, Returns the dictionary to allow further items to be added. void AddSuggestionDetailDictionaryToList(std::vector<base::Value>& list,
base::DictionaryValue* AddSuggestionDetailDictionaryToList( int header_message_id,
base::ListValue* list, int body_message_id,
int header_message_id, bool append_standard_menu_items) {
int body_message_id, base::DictionaryValue suggestion_list_item;
bool append_standard_menu_items) { if (append_standard_menu_items)
base::DictionaryValue* suggestion_list_item;
if (append_standard_menu_items) {
suggestion_list_item = GetStandardMenuItemsText(); suggestion_list_item = GetStandardMenuItemsText();
} else {
suggestion_list_item = new base::DictionaryValue;
}
if (header_message_id) { if (header_message_id) {
suggestion_list_item->SetString("header", suggestion_list_item.SetStringPath(
l10n_util::GetStringUTF16(header_message_id)); "header", l10n_util::GetStringUTF16(header_message_id));
} }
if (body_message_id) { if (body_message_id) {
suggestion_list_item->SetString("body", suggestion_list_item.SetStringPath(
l10n_util::GetStringUTF16(body_message_id)); "body", l10n_util::GetStringUTF16(body_message_id));
} }
list->Append(base::WrapUnique(suggestion_list_item)); list.push_back(std::move(suggestion_list_item));
// |suggestion_list_item| is invalidated at this point, so it needs to be
// reset.
list->GetDictionary(list->GetSize() - 1, &suggestion_list_item);
return suggestion_list_item;
} }
// Certain suggestions have supporting details which get displayed under // Certain suggestions have supporting details which get displayed under
@@ -814,7 +797,7 @@ base::DictionaryValue* AddSuggestionDetailDictionaryToList(
void AddSuggestionsDetails(int error_code, void AddSuggestionsDetails(int error_code,
base::DictionaryValue* error_strings, base::DictionaryValue* error_strings,
int suggestions, int suggestions,
base::ListValue* suggestions_details) { std::vector<base::Value>& suggestions_details) {
if (suggestions & SUGGEST_CHECK_CONNECTION) { if (suggestions & SUGGEST_CHECK_CONNECTION) {
AddSuggestionDetailDictionaryToList(suggestions_details, AddSuggestionDetailDictionaryToList(suggestions_details,
IDS_ERRORPAGES_SUGGESTION_CHECK_CONNECTION_HEADER, IDS_ERRORPAGES_SUGGESTION_CHECK_CONNECTION_HEADER,
@@ -835,15 +818,13 @@ void AddSuggestionsDetails(int error_code,
IDS_ERRORPAGES_SUGGESTION_DNS_CONFIG_HEADER, IDS_ERRORPAGES_SUGGESTION_DNS_CONFIG_HEADER,
IDS_ERRORPAGES_SUGGESTION_DNS_CONFIG_BODY, false); IDS_ERRORPAGES_SUGGESTION_DNS_CONFIG_BODY, false);
base::DictionaryValue* suggest_network_prediction = AddSuggestionDetailDictionaryToList(
AddSuggestionDetailDictionaryToList(suggestions_details, suggestions_details,
IDS_ERRORPAGES_SUGGESTION_NETWORK_PREDICTION_HEADER, IDS_ERRORPAGES_SUGGESTION_NETWORK_PREDICTION_HEADER,
IDS_ERRORPAGES_SUGGESTION_NETWORK_PREDICTION_BODY, true); IDS_ERRORPAGES_SUGGESTION_NETWORK_PREDICTION_BODY, true);
suggestions_details.back().SetStringPath(
suggest_network_prediction->SetString(
"noNetworkPredictionTitle", "noNetworkPredictionTitle",
l10n_util::GetStringUTF16( l10n_util::GetStringUTF16(IDS_NETWORK_PREDICTION_ENABLED_DESCRIPTION));
IDS_NETWORK_PREDICTION_ENABLED_DESCRIPTION));
} }
if (suggestions & SUGGEST_FIREWALL_CONFIG) { if (suggestions & SUGGEST_FIREWALL_CONFIG) {
@@ -853,18 +834,18 @@ void AddSuggestionsDetails(int error_code,
} }
if (suggestions & SUGGEST_PROXY_CONFIG) { if (suggestions & SUGGEST_PROXY_CONFIG) {
base::DictionaryValue* suggest_proxy_config = AddSuggestionDetailDictionaryToList(
AddSuggestionDetailDictionaryToList(suggestions_details, suggestions_details, IDS_ERRORPAGES_SUGGESTION_PROXY_CONFIG_HEADER, 0,
IDS_ERRORPAGES_SUGGESTION_PROXY_CONFIG_HEADER, true);
0, true);
// Custom body string. // Custom body string.
suggest_proxy_config->SetString("body", suggestions_details.back().SetStringPath(
l10n_util::GetStringFUTF16(IDS_ERRORPAGES_SUGGESTION_PROXY_CONFIG_BODY, "body", l10n_util::GetStringFUTF16(
l10n_util::GetStringUTF16( IDS_ERRORPAGES_SUGGESTION_PROXY_CONFIG_BODY,
IDS_ERRORPAGES_SUGGESTION_PROXY_DISABLE_PLATFORM))); l10n_util::GetStringUTF16(
IDS_ERRORPAGES_SUGGESTION_PROXY_DISABLE_PLATFORM)));
suggest_proxy_config->SetString("proxyTitle", suggestions_details.back().SetStringPath(
"proxyTitle",
l10n_util::GetStringUTF16(IDS_OPTIONS_PROXIES_CONFIGURE_BUTTON)); l10n_util::GetStringUTF16(IDS_OPTIONS_PROXIES_CONFIGURE_BUTTON));
} }
#endif #endif
@@ -914,21 +895,21 @@ LocalizedError::PageState LocalizedError::GetPageState(
result.is_offline_error = true; result.is_offline_error = true;
// These strings are to be read by a screen reader during the dino game. // These strings are to be read by a screen reader during the dino game.
result.strings.SetString( result.strings.SetStringPath(
"dinoGameA11yAriaLabel", "dinoGameA11yAriaLabel",
l10n_util::GetStringUTF16(IDS_ERRORPAGE_DINO_ARIA_LABEL)); l10n_util::GetStringUTF16(IDS_ERRORPAGE_DINO_ARIA_LABEL));
result.strings.SetString( result.strings.SetStringPath(
"dinoGameA11yGameOver", "dinoGameA11yGameOver",
l10n_util::GetStringUTF16(IDS_ERRORPAGE_DINO_GAME_OVER)); l10n_util::GetStringUTF16(IDS_ERRORPAGE_DINO_GAME_OVER));
result.strings.SetString( result.strings.SetStringPath(
"dinoGameA11yHighScore", "dinoGameA11yHighScore",
l10n_util::GetStringUTF16(IDS_ERRORPAGE_DINO_HIGH_SCORE)); l10n_util::GetStringUTF16(IDS_ERRORPAGE_DINO_HIGH_SCORE));
result.strings.SetString( result.strings.SetStringPath(
"dinoGameA11yJump", l10n_util::GetStringUTF16(IDS_ERRORPAGE_DINO_JUMP)); "dinoGameA11yJump", l10n_util::GetStringUTF16(IDS_ERRORPAGE_DINO_JUMP));
result.strings.SetString( result.strings.SetStringPath(
"dinoGameA11yStartGame", "dinoGameA11yStartGame",
l10n_util::GetStringUTF16(IDS_ERRORPAGE_DINO_GAME_START)); l10n_util::GetStringUTF16(IDS_ERRORPAGE_DINO_GAME_START));
result.strings.SetString( result.strings.SetStringPath(
"dinoGameA11ySpeedToggle", "dinoGameA11ySpeedToggle",
l10n_util::GetStringUTF16(IDS_ERRORPAGE_DINO_SLOW_SPEED_TOGGLE)); l10n_util::GetStringUTF16(IDS_ERRORPAGE_DINO_SLOW_SPEED_TOGGLE));
@@ -936,16 +917,16 @@ LocalizedError::PageState LocalizedError::GetPageState(
result.strings.SetBoolean("enableAltGameMode", true); result.strings.SetBoolean("enableAltGameMode", true);
// We don't know yet which scale the page will use, so both 1x and 2x // We don't know yet which scale the page will use, so both 1x and 2x
// should be loaded. // should be loaded.
result.strings.SetString("altGameCommonImage1x", result.strings.SetStringPath(
GetAltGameImage(/*image_id=*/0, /*scale=*/1)); "altGameCommonImage1x", GetAltGameImage(/*image_id=*/0, /*scale=*/1));
result.strings.SetString("altGameCommonImage2x", result.strings.SetStringPath(
GetAltGameImage(/*image_id=*/0, /*scale=*/2)); "altGameCommonImage2x", GetAltGameImage(/*image_id=*/0, /*scale=*/2));
int choice = ChooseAltGame(); int choice = ChooseAltGame();
result.strings.SetString("altGameType", base::NumberToString(choice)); result.strings.SetStringPath("altGameType", base::NumberToString(choice));
result.strings.SetString("altGameSpecificImage1x", result.strings.SetStringPath("altGameSpecificImage1x",
GetAltGameImage(choice, 1)); GetAltGameImage(choice, 1));
result.strings.SetString("altGameSpecificImage2x", result.strings.SetStringPath("altGameSpecificImage2x",
GetAltGameImage(choice, 2)); GetAltGameImage(choice, 2));
} }
} }
@@ -996,27 +977,27 @@ LocalizedError::PageState LocalizedError::GetPageState(
std::u16string host_name(url_formatter::IDNToUnicode(failed_url.host())); std::u16string host_name(url_formatter::IDNToUnicode(failed_url.host()));
if (failed_url.SchemeIsHTTPOrHTTPS()) if (failed_url.SchemeIsHTTPOrHTTPS())
result.strings.SetString("title", host_name); result.strings.SetStringPath("title", host_name);
else else
result.strings.SetString("title", failed_url_string); result.strings.SetStringPath("title", failed_url_string);
std::string icon_class = GetIconClassForError(error_domain, error_code); result.strings.SetStringPath("iconClass",
result.strings.SetString("iconClass", icon_class); GetIconClassForError(error_domain, error_code));
auto heading = std::make_unique<base::DictionaryValue>(); base::DictionaryValue heading;
int msg_id = show_game_instructions ? IDS_ERRORPAGES_GAME_INSTRUCTIONS int msg_id = show_game_instructions ? IDS_ERRORPAGES_GAME_INSTRUCTIONS
: options.heading_resource_id; : options.heading_resource_id;
heading->SetString("msg", l10n_util::GetStringUTF16(msg_id)); heading.SetStringPath("msg", l10n_util::GetStringUTF16(msg_id));
heading->SetString("hostName", host_name); heading.SetStringPath("hostName", host_name);
result.strings.Set("heading", std::move(heading)); result.strings.SetPath("heading", std::move(heading));
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
// Check if easter egg should be disabled. // Check if easter egg should be disabled.
if (command_line->HasSwitch( if (command_line->HasSwitch(
error_page::switches::kDisableDinosaurEasterEgg)) { error_page::switches::kDisableDinosaurEasterEgg)) {
// The presence of this string disables the easter egg. Acts as a flag. // The presence of this string disables the easter egg. Acts as a flag.
result.strings.SetString( result.strings.SetStringPath(
"disabledEasterEgg", "disabledEasterEgg",
l10n_util::GetStringUTF16(IDS_ERRORPAGE_FUN_DISABLED)); l10n_util::GetStringUTF16(IDS_ERRORPAGE_FUN_DISABLED));
} }
@@ -1025,11 +1006,11 @@ LocalizedError::PageState LocalizedError::GetPageState(
// game instructions. // game instructions.
if (show_game_instructions) { if (show_game_instructions) {
// When showing instructions, set an empty error to prevent a "NULL" string. // When showing instructions, set an empty error to prevent a "NULL" string.
result.strings.SetString("errorCode", ""); result.strings.SetStringPath("errorCode", "");
return result; return result;
} }
auto summary = std::make_unique<base::DictionaryValue>(); base::DictionaryValue summary;
// Set summary message under the heading. // Set summary message under the heading.
std::u16string message; std::u16string message;
@@ -1042,17 +1023,17 @@ LocalizedError::PageState LocalizedError::GetPageState(
message = l10n_util::GetStringUTF16(options.summary_resource_id); message = l10n_util::GetStringUTF16(options.summary_resource_id);
} }
summary->SetString("msg", std::move(message)); summary.SetStringPath("msg", std::move(message));
summary->SetString("failedUrl", failed_url_string); summary.SetStringPath("failedUrl", failed_url_string);
summary->SetString("hostName", host_name); summary.SetStringPath("hostName", host_name);
result.strings.SetString( result.strings.SetStringPath(
"details", l10n_util::GetStringUTF16(IDS_ERRORPAGE_NET_BUTTON_DETAILS)); "details", l10n_util::GetStringUTF16(IDS_ERRORPAGE_NET_BUTTON_DETAILS));
result.strings.SetString( result.strings.SetStringPath(
"hideDetails", "hideDetails",
l10n_util::GetStringUTF16(IDS_ERRORPAGE_NET_BUTTON_HIDE_DETAILS)); l10n_util::GetStringUTF16(IDS_ERRORPAGE_NET_BUTTON_HIDE_DETAILS));
result.strings.Set("summary", std::move(summary)); result.strings.SetPath("summary", std::move(summary));
std::u16string error_string; std::u16string error_string;
if (error_domain == Error::kNetErrorDomain) { if (error_domain == Error::kNetErrorDomain) {
@@ -1066,22 +1047,20 @@ LocalizedError::PageState LocalizedError::GetPageState(
DCHECK_EQ(Error::kHttpErrorDomain, error_domain); DCHECK_EQ(Error::kHttpErrorDomain, error_domain);
error_string = base::ASCIIToUTF16(HttpErrorCodeToString(error_code)); error_string = base::ASCIIToUTF16(HttpErrorCodeToString(error_code));
} }
result.strings.SetString("errorCode", error_string); result.strings.SetStringPath("errorCode", error_string);
base::ListValue* suggestions_details = result.strings.SetList( std::vector<base::Value> suggestions_details;
"suggestionsDetails", std::make_unique<base::ListValue>()); std::vector<base::Value> suggestions_summary_list;
base::ListValue* suggestions_summary_list = result.strings.SetList(
"suggestionsSummaryList", std::make_unique<base::ListValue>());
// Add the reload suggestion, if needed, for pages that didn't come // Add the reload suggestion, if needed, for pages that didn't come
// from a post. // from a post.
if ((options.buttons & SHOW_BUTTON_RELOAD) && !is_post) { if ((options.buttons & SHOW_BUTTON_RELOAD) && !is_post) {
auto reload_button = std::make_unique<base::DictionaryValue>(); base::DictionaryValue reload_button;
result.reload_button_shown = true; result.reload_button_shown = true;
reload_button->SetString( reload_button.SetStringPath(
"msg", l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_RELOAD)); "msg", l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_RELOAD));
reload_button->SetString("reloadUrl", failed_url.spec()); reload_button.SetStringPath("reloadUrl", failed_url.spec());
result.strings.Set("reloadButton", std::move(reload_button)); result.strings.SetPath("reloadButton", std::move(reload_button));
} }
#if BUILDFLAG(IS_CHROMEOS_ASH) #if BUILDFLAG(IS_CHROMEOS_ASH)
@@ -1111,7 +1090,7 @@ LocalizedError::PageState LocalizedError::GetPageState(
IDS_ERRORPAGES_BUTTON_DOWNLOADING))); IDS_ERRORPAGES_BUTTON_DOWNLOADING)));
} else { } else {
result.auto_fetch_allowed = true; result.auto_fetch_allowed = true;
result.strings.SetString("attemptAutoFetch", "true"); result.strings.SetStringPath("attemptAutoFetch", "true");
result.strings.SetPath({"savePageLater", "savePageMsg"}, result.strings.SetPath({"savePageLater", "savePageMsg"},
base::Value(l10n_util::GetStringUTF16( base::Value(l10n_util::GetStringUTF16(
IDS_ERRORPAGES_SAVE_PAGE_BUTTON))); IDS_ERRORPAGES_SAVE_PAGE_BUTTON)));
@@ -1121,14 +1100,14 @@ LocalizedError::PageState LocalizedError::GetPageState(
} }
} }
result.strings.SetString( result.strings.SetStringPath(
"closeDescriptionPopup", "closeDescriptionPopup",
l10n_util::GetStringUTF16(IDS_ERRORPAGES_SUGGESTION_CLOSE_POPUP_BUTTON)); l10n_util::GetStringUTF16(IDS_ERRORPAGES_SUGGESTION_CLOSE_POPUP_BUTTON));
if (IsOfflineError(error_domain, error_code) && !is_incognito) { if (IsOfflineError(error_domain, error_code) && !is_incognito) {
result.offline_content_feature_enabled = offline_content_feature_enabled; result.offline_content_feature_enabled = offline_content_feature_enabled;
if (offline_content_feature_enabled) { if (offline_content_feature_enabled) {
result.strings.SetString("suggestedOfflineContentPresentation", "on"); result.strings.SetStringPath("suggestedOfflineContentPresentation", "on");
result.strings.SetPath({"offlineContentList", "title"}, result.strings.SetPath({"offlineContentList", "title"},
base::Value(l10n_util::GetStringUTF16( base::Value(l10n_util::GetStringUTF16(
IDS_ERRORPAGES_OFFLINE_CONTENT_LIST_TITLE))); IDS_ERRORPAGES_OFFLINE_CONTENT_LIST_TITLE)));
@@ -1145,6 +1124,11 @@ LocalizedError::PageState LocalizedError::GetPageState(
} }
} }
#endif // defined(OS_ANDROID) #endif // defined(OS_ANDROID)
result.strings.SetPath("suggestionsSummaryList",
base::Value(std::move(suggestions_summary_list)));
result.strings.SetPath("suggestionsDetails",
base::Value(std::move(suggestions_details)));
return result; return result;
} }