Commit 6b2ef8e8 authored by Javier Ernesto Flores Robles's avatar Javier Ernesto Flores Robles Committed by Commit Bot

[WidgetKit] Fix strings in dino game

Show instructions and hide error details when entering the dino game via
chrome://dino.

Bug: 1138722
Change-Id: Iacfc5a5bb836230e0e7b115ae8f6bea504dc9655
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2527641
Commit-Queue: Javier Flores <javierrobles@chromium.org>
Reviewed-by: default avatarJavier Flores <javierrobles@chromium.org>
Reviewed-by: default avatarEdward Jung (EMEA) <edwardjung@chromium.org>
Reviewed-by: default avatarAdam Langley <agl@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826485}
parent c672511a
...@@ -43,6 +43,10 @@ namespace error_page { ...@@ -43,6 +43,10 @@ namespace error_page {
namespace { namespace {
// Hardcode these constants to avoid dependences on //chrome and //content.
const char kChromeUIScheme[] = "chrome";
const char kChromeUIDinoHost[] = "dino";
static const char kRedirectLoopLearnMoreUrl[] = static const char kRedirectLoopLearnMoreUrl[] =
"https://support.google.com/chrome?p=rl_error"; "https://support.google.com/chrome?p=rl_error";
...@@ -906,6 +910,9 @@ LocalizedError::PageState LocalizedError::GetPageState( ...@@ -906,6 +910,9 @@ LocalizedError::PageState LocalizedError::GetPageState(
webui::SetLoadTimeDataDefaults(locale, &result.strings); webui::SetLoadTimeDataDefaults(locale, &result.strings);
bool show_game_instructions = failed_url.host() == kChromeUIDinoHost &&
failed_url.scheme() == kChromeUIScheme;
// Grab the strings and settings that depend on the error type. Init // Grab the strings and settings that depend on the error type. Init
// options with default values. // options with default values.
LocalizedErrorMap options = { LocalizedErrorMap options = {
...@@ -956,19 +963,14 @@ LocalizedError::PageState LocalizedError::GetPageState( ...@@ -956,19 +963,14 @@ LocalizedError::PageState LocalizedError::GetPageState(
result.strings.SetString("iconClass", icon_class); result.strings.SetString("iconClass", icon_class);
auto heading = std::make_unique<base::DictionaryValue>(); auto heading = std::make_unique<base::DictionaryValue>();
heading->SetString("msg",
l10n_util::GetStringUTF16(options.heading_resource_id)); int msg_id = show_game_instructions ? IDS_ERRORPAGES_GAME_INSTRUCTIONS
: options.heading_resource_id;
heading->SetString("msg", l10n_util::GetStringUTF16(msg_id));
heading->SetString("hostName", host_name); heading->SetString("hostName", host_name);
result.strings.Set("heading", std::move(heading)); result.strings.Set("heading", std::move(heading));
auto summary = std::make_unique<base::DictionaryValue>();
// Set summary message under the heading.
summary->SetString(
"msg", l10n_util::GetStringUTF16(options.summary_resource_id));
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)) {
...@@ -978,6 +980,19 @@ LocalizedError::PageState LocalizedError::GetPageState( ...@@ -978,6 +980,19 @@ LocalizedError::PageState LocalizedError::GetPageState(
l10n_util::GetStringUTF16(IDS_ERRORPAGE_FUN_DISABLED)); l10n_util::GetStringUTF16(IDS_ERRORPAGE_FUN_DISABLED));
} }
// Return early and don't add suggestions or other information when showing
// game instructions.
if (show_game_instructions) {
// When showing instructions, set an empty error to prevent a "NULL" string.
result.strings.SetString("errorCode", "");
return result;
}
auto summary = std::make_unique<base::DictionaryValue>();
// Set summary message under the heading.
summary->SetString("msg",
l10n_util::GetStringUTF16(options.summary_resource_id));
summary->SetString("failedUrl", failed_url_string); summary->SetString("failedUrl", failed_url_string);
summary->SetString("hostName", host_name); summary->SetString("hostName", host_name);
......
...@@ -369,5 +369,15 @@ ...@@ -369,5 +369,15 @@
If spelling is correct, <ph name="BEGIN_LINK">&lt;a href="javascript:diagnoseErrors()" id="diagnose-link"&gt;</ph>try running Connectivity Diagnostics<ph name="END_LINK">&lt;/a&gt;</ph>. If spelling is correct, <ph name="BEGIN_LINK">&lt;a href="javascript:diagnoseErrors()" id="diagnose-link"&gt;</ph>try running Connectivity Diagnostics<ph name="END_LINK">&lt;/a&gt;</ph>.
</message> </message>
</if> </if>
<if expr="is_android or is_ios">
<message name="IDS_ERRORPAGES_GAME_INSTRUCTIONS" desc="Mobile: Instructions on how to start playing the offline game. 'dino' is an acceptable English nickname that refers to 'dinosaur'">
Tap the dino to play
</message>
</if>
<if expr="not is_android and not is_ios">
<message name="IDS_ERRORPAGES_GAME_INSTRUCTIONS" desc="Instructions on how to start playing the offline game.">
Press space to play
</message>
</if>
</grit-part> </grit-part>
2cdc160e31c0a323842c4996a1a4c5bef05b5678
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment