Include the proper animated gif for thread_times.key_idle_power_cases
[chromium-blink-merge.git] / chrome / common / localized_error.cc
blobcb3aaee940099eaacaf61c75356c95b60c233f38
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/common/localized_error.h"
7 #include "base/command_line.h"
8 #include "base/i18n/rtl.h"
9 #include "base/logging.h"
10 #include "base/metrics/field_trial.h"
11 #include "base/strings/string16.h"
12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/string_util.h"
14 #include "base/strings/utf_string_conversions.h"
15 #include "base/values.h"
16 #include "chrome/common/chrome_switches.h"
17 #include "chrome/grit/chromium_strings.h"
18 #include "chrome/grit/generated_resources.h"
19 #include "components/error_page/common/error_page_params.h"
20 #include "components/error_page/common/net_error_info.h"
21 #include "net/base/escape.h"
22 #include "net/base/net_errors.h"
23 #include "net/base/net_util.h"
24 #include "third_party/WebKit/public/platform/WebURLError.h"
25 #include "ui/base/l10n/l10n_util.h"
26 #include "ui/base/webui/web_ui_util.h"
28 #if defined(OS_WIN)
29 #include "base/win/windows_version.h"
30 #endif
32 #if defined(OS_CHROMEOS)
33 #include "base/command_line.h"
34 #include "chrome/common/chrome_switches.h"
35 #endif
37 #if defined(ENABLE_EXTENSIONS)
38 #include "extensions/common/constants.h"
39 #include "extensions/common/extension_icon_set.h"
40 #include "extensions/common/manifest_handlers/icons_handler.h"
41 #endif
43 using blink::WebURLError;
45 // Some error pages have no details.
46 const unsigned int kErrorPagesNoDetails = 0;
48 namespace {
50 static const char kRedirectLoopLearnMoreUrl[] =
51 "https://support.google.com/chrome/answer/95626";
52 static const char kWeakDHKeyLearnMoreUrl[] =
53 "https://www.chromium.org/administrators/"
54 "err_ssl_weak_server_ephemeral_dh_key";
55 #if defined(OS_CHROMEOS)
56 static const char kAppWarningLearnMoreUrl[] =
57 "chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html"
58 "?answer=1721911";
59 #endif // defined(OS_CHROMEOS)
60 static const char kCachedCopyButtonFieldTrial[] =
61 "EnableGoogleCachedCopyTextExperiment";
62 static const char kCachedCopyButtonExpTypeControl[] = "control";
63 static const char kCachedCopyButtonExpTypeCopy[] = "copy";
64 static const int kGoogleCachedCopySuggestionType = 0;
66 enum NAV_SUGGESTIONS {
67 SUGGEST_NONE = 0,
68 SUGGEST_RELOAD = 1 << 0,
69 SUGGEST_CHECK_CONNECTION = 1 << 1,
70 SUGGEST_DNS_CONFIG = 1 << 2,
71 SUGGEST_FIREWALL_CONFIG = 1 << 3,
72 SUGGEST_PROXY_CONFIG = 1 << 4,
73 SUGGEST_DISABLE_EXTENSION = 1 << 5,
74 SUGGEST_LEARNMORE = 1 << 6,
75 SUGGEST_VIEW_POLICIES = 1 << 7,
76 SUGGEST_CONTACT_ADMINISTRATOR = 1 << 8,
79 struct LocalizedErrorMap {
80 int error_code;
81 unsigned int title_resource_id;
82 unsigned int heading_resource_id;
83 // Detailed summary used when the error is in the main frame.
84 unsigned int summary_resource_id;
85 // Short one sentence description shown on mouse over when the error is in
86 // a frame.
87 unsigned int details_resource_id;
88 int suggestions; // Bitmap of SUGGEST_* values.
91 const LocalizedErrorMap net_error_options[] = {
92 {net::ERR_TIMED_OUT,
93 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
94 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE,
95 IDS_ERRORPAGES_SUMMARY_TIMED_OUT,
96 IDS_ERRORPAGES_DETAILS_TIMED_OUT,
97 SUGGEST_RELOAD | SUGGEST_CHECK_CONNECTION | SUGGEST_FIREWALL_CONFIG |
98 SUGGEST_PROXY_CONFIG,
100 {net::ERR_CONNECTION_TIMED_OUT,
101 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
102 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE,
103 IDS_ERRORPAGES_SUMMARY_TIMED_OUT,
104 IDS_ERRORPAGES_DETAILS_TIMED_OUT,
105 SUGGEST_RELOAD | SUGGEST_CHECK_CONNECTION | SUGGEST_FIREWALL_CONFIG |
106 SUGGEST_PROXY_CONFIG,
108 {net::ERR_CONNECTION_CLOSED,
109 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
110 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE,
111 IDS_ERRORPAGES_SUMMARY_NOT_AVAILABLE,
112 IDS_ERRORPAGES_DETAILS_CONNECTION_CLOSED,
113 SUGGEST_RELOAD,
115 {net::ERR_CONNECTION_RESET,
116 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
117 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE,
118 IDS_ERRORPAGES_SUMMARY_CONNECTION_RESET,
119 IDS_ERRORPAGES_DETAILS_CONNECTION_RESET,
120 SUGGEST_RELOAD | SUGGEST_CHECK_CONNECTION | SUGGEST_FIREWALL_CONFIG |
121 SUGGEST_PROXY_CONFIG,
123 {net::ERR_CONNECTION_REFUSED,
124 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
125 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE,
126 IDS_ERRORPAGES_SUMMARY_CONNECTION_REFUSED,
127 IDS_ERRORPAGES_DETAILS_CONNECTION_REFUSED,
128 SUGGEST_RELOAD | SUGGEST_CHECK_CONNECTION | SUGGEST_FIREWALL_CONFIG |
129 SUGGEST_PROXY_CONFIG,
131 {net::ERR_CONNECTION_FAILED,
132 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
133 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE,
134 IDS_ERRORPAGES_SUMMARY_NOT_AVAILABLE,
135 IDS_ERRORPAGES_DETAILS_CONNECTION_FAILED,
136 SUGGEST_RELOAD,
138 {net::ERR_NAME_NOT_RESOLVED,
139 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
140 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE,
141 IDS_ERRORPAGES_SUMMARY_NAME_NOT_RESOLVED,
142 IDS_ERRORPAGES_DETAILS_NAME_NOT_RESOLVED,
143 SUGGEST_RELOAD | SUGGEST_CHECK_CONNECTION | SUGGEST_DNS_CONFIG |
144 SUGGEST_FIREWALL_CONFIG | SUGGEST_PROXY_CONFIG,
146 {net::ERR_ICANN_NAME_COLLISION,
147 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
148 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE,
149 IDS_ERRORPAGES_SUMMARY_ICANN_NAME_COLLISION,
150 IDS_ERRORPAGES_DETAILS_ICANN_NAME_COLLISION,
151 SUGGEST_NONE,
153 {net::ERR_ADDRESS_UNREACHABLE,
154 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
155 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE,
156 IDS_ERRORPAGES_SUMMARY_ADDRESS_UNREACHABLE,
157 IDS_ERRORPAGES_DETAILS_ADDRESS_UNREACHABLE,
158 SUGGEST_RELOAD | SUGGEST_FIREWALL_CONFIG | SUGGEST_PROXY_CONFIG,
160 {net::ERR_NETWORK_ACCESS_DENIED,
161 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
162 IDS_ERRORPAGES_HEADING_NETWORK_ACCESS_DENIED,
163 IDS_ERRORPAGES_SUMMARY_NETWORK_ACCESS_DENIED,
164 IDS_ERRORPAGES_DETAILS_NETWORK_ACCESS_DENIED,
165 SUGGEST_FIREWALL_CONFIG,
167 {net::ERR_PROXY_CONNECTION_FAILED,
168 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
169 IDS_ERRORPAGES_HEADING_PROXY_CONNECTION_FAILED,
170 IDS_ERRORPAGES_SUMMARY_PROXY_CONNECTION_FAILED,
171 IDS_ERRORPAGES_DETAILS_PROXY_CONNECTION_FAILED,
172 SUGGEST_PROXY_CONFIG,
174 {net::ERR_INTERNET_DISCONNECTED,
175 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
176 IDS_ERRORPAGES_HEADING_INTERNET_DISCONNECTED,
177 IDS_ERRORPAGES_SUMMARY_INTERNET_DISCONNECTED,
178 IDS_ERRORPAGES_DETAILS_INTERNET_DISCONNECTED,
179 SUGGEST_NONE,
181 {net::ERR_FILE_NOT_FOUND,
182 IDS_ERRORPAGES_TITLE_NOT_FOUND,
183 IDS_ERRORPAGES_HEADING_NOT_FOUND,
184 IDS_ERRORPAGES_SUMMARY_NOT_FOUND,
185 IDS_ERRORPAGES_DETAILS_FILE_NOT_FOUND,
186 SUGGEST_NONE,
188 {net::ERR_CACHE_MISS,
189 IDS_ERRORPAGES_TITLE_LOAD_FAILED,
190 IDS_ERRORPAGES_HEADING_CACHE_MISS,
191 IDS_ERRORPAGES_SUMMARY_CACHE_MISS,
192 IDS_ERRORPAGES_DETAILS_CACHE_MISS,
193 SUGGEST_RELOAD,
195 {net::ERR_CACHE_READ_FAILURE,
196 IDS_ERRORPAGES_TITLE_LOAD_FAILED,
197 IDS_ERRORPAGES_HEADING_CACHE_READ_FAILURE,
198 IDS_ERRORPAGES_SUMMARY_CACHE_READ_FAILURE,
199 IDS_ERRORPAGES_DETAILS_CACHE_READ_FAILURE,
200 SUGGEST_RELOAD,
202 {net::ERR_NETWORK_IO_SUSPENDED,
203 IDS_ERRORPAGES_TITLE_LOAD_FAILED,
204 IDS_ERRORPAGES_HEADING_NETWORK_IO_SUSPENDED,
205 IDS_ERRORPAGES_SUMMARY_NETWORK_IO_SUSPENDED,
206 IDS_ERRORPAGES_DETAILS_NETWORK_IO_SUSPENDED,
207 SUGGEST_RELOAD,
209 {net::ERR_TOO_MANY_REDIRECTS,
210 IDS_ERRORPAGES_TITLE_LOAD_FAILED,
211 IDS_ERRORPAGES_HEADING_TOO_MANY_REDIRECTS,
212 IDS_ERRORPAGES_SUMMARY_TOO_MANY_REDIRECTS,
213 IDS_ERRORPAGES_DETAILS_TOO_MANY_REDIRECTS,
214 SUGGEST_RELOAD | SUGGEST_LEARNMORE,
216 {net::ERR_EMPTY_RESPONSE,
217 IDS_ERRORPAGES_TITLE_LOAD_FAILED,
218 IDS_ERRORPAGES_HEADING_EMPTY_RESPONSE,
219 IDS_ERRORPAGES_SUMMARY_EMPTY_RESPONSE,
220 IDS_ERRORPAGES_DETAILS_EMPTY_RESPONSE,
221 SUGGEST_RELOAD,
223 {net::ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_LENGTH,
224 IDS_ERRORPAGES_TITLE_LOAD_FAILED,
225 IDS_ERRORPAGES_HEADING_DUPLICATE_HEADERS,
226 IDS_ERRORPAGES_SUMMARY_DUPLICATE_HEADERS,
227 IDS_ERRORPAGES_DETAILS_RESPONSE_HEADERS_MULTIPLE_CONTENT_LENGTH,
228 SUGGEST_NONE,
230 {net::ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION,
231 IDS_ERRORPAGES_TITLE_LOAD_FAILED,
232 IDS_ERRORPAGES_HEADING_DUPLICATE_HEADERS,
233 IDS_ERRORPAGES_SUMMARY_DUPLICATE_HEADERS,
234 IDS_ERRORPAGES_DETAILS_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION,
235 SUGGEST_NONE,
237 {net::ERR_RESPONSE_HEADERS_MULTIPLE_LOCATION,
238 IDS_ERRORPAGES_TITLE_LOAD_FAILED,
239 IDS_ERRORPAGES_HEADING_DUPLICATE_HEADERS,
240 IDS_ERRORPAGES_SUMMARY_DUPLICATE_HEADERS,
241 IDS_ERRORPAGES_DETAILS_RESPONSE_HEADERS_MULTIPLE_LOCATION,
242 SUGGEST_NONE,
244 {net::ERR_CONTENT_LENGTH_MISMATCH,
245 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
246 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE,
247 IDS_ERRORPAGES_SUMMARY_NOT_AVAILABLE,
248 IDS_ERRORPAGES_DETAILS_CONNECTION_CLOSED,
249 SUGGEST_RELOAD,
251 {net::ERR_INCOMPLETE_CHUNKED_ENCODING,
252 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
253 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE,
254 IDS_ERRORPAGES_SUMMARY_NOT_AVAILABLE,
255 IDS_ERRORPAGES_DETAILS_CONNECTION_CLOSED,
256 SUGGEST_RELOAD,
258 {net::ERR_SSL_PROTOCOL_ERROR,
259 IDS_ERRORPAGES_TITLE_LOAD_FAILED,
260 IDS_ERRORPAGES_HEADING_SSL_PROTOCOL_ERROR,
261 IDS_ERRORPAGES_SUMMARY_SSL_PROTOCOL_ERROR,
262 IDS_ERRORPAGES_DETAILS_SSL_PROTOCOL_ERROR,
263 SUGGEST_NONE,
265 {net::ERR_BAD_SSL_CLIENT_AUTH_CERT,
266 IDS_ERRORPAGES_TITLE_LOAD_FAILED,
267 IDS_ERRORPAGES_HEADING_BAD_SSL_CLIENT_AUTH_CERT,
268 IDS_ERRORPAGES_SUMMARY_BAD_SSL_CLIENT_AUTH_CERT,
269 IDS_ERRORPAGES_DETAILS_BAD_SSL_CLIENT_AUTH_CERT,
270 SUGGEST_NONE,
272 {net::ERR_SSL_WEAK_SERVER_EPHEMERAL_DH_KEY,
273 IDS_ERRORPAGES_TITLE_LOAD_FAILED,
274 IDS_ERRORPAGES_HEADING_WEAK_SERVER_EPHEMERAL_DH_KEY,
275 IDS_ERRORPAGES_SUMMARY_WEAK_SERVER_EPHEMERAL_DH_KEY,
276 IDS_ERRORPAGES_DETAILS_SSL_PROTOCOL_ERROR,
277 SUGGEST_LEARNMORE,
279 {net::ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN,
280 IDS_ERRORPAGES_TITLE_LOAD_FAILED,
281 IDS_ERRORPAGES_HEADING_PINNING_FAILURE,
282 IDS_ERRORPAGES_SUMMARY_PINNING_FAILURE,
283 IDS_ERRORPAGES_DETAILS_PINNING_FAILURE,
284 SUGGEST_NONE,
286 {net::ERR_TEMPORARILY_THROTTLED,
287 IDS_ERRORPAGES_TITLE_ACCESS_DENIED,
288 IDS_ERRORPAGES_HEADING_ACCESS_DENIED,
289 IDS_ERRORPAGES_SUMMARY_TEMPORARILY_THROTTLED,
290 IDS_ERRORPAGES_DETAILS_TEMPORARILY_THROTTLED,
291 SUGGEST_NONE,
293 {net::ERR_BLOCKED_BY_CLIENT,
294 IDS_ERRORPAGES_TITLE_BLOCKED,
295 IDS_ERRORPAGES_HEADING_BLOCKED,
296 IDS_ERRORPAGES_SUMMARY_BLOCKED,
297 IDS_ERRORPAGES_DETAILS_BLOCKED,
298 SUGGEST_RELOAD | SUGGEST_DISABLE_EXTENSION,
300 {net::ERR_NETWORK_CHANGED,
301 IDS_ERRORPAGES_TITLE_LOAD_FAILED,
302 IDS_ERRORPAGES_HEADING_NETWORK_ACCESS_DENIED,
303 IDS_ERRORPAGES_SUMMARY_NETWORK_CHANGED,
304 IDS_ERRORPAGES_DETAILS_NETWORK_CHANGED,
305 SUGGEST_RELOAD | SUGGEST_CHECK_CONNECTION,
307 {net::ERR_BLOCKED_BY_ADMINISTRATOR,
308 IDS_ERRORPAGES_TITLE_BLOCKED,
309 IDS_ERRORPAGES_HEADING_BLOCKED_BY_ADMINISTRATOR,
310 IDS_ERRORPAGES_SUMMARY_BLOCKED_BY_ADMINISTRATOR,
311 IDS_ERRORPAGES_DETAILS_BLOCKED_BY_ADMINISTRATOR,
312 SUGGEST_VIEW_POLICIES | SUGGEST_CONTACT_ADMINISTRATOR,
314 {net::ERR_BLOCKED_ENROLLMENT_CHECK_PENDING,
315 IDS_ERRORPAGES_TITLE_BLOCKED,
316 IDS_ERRORPAGES_HEADING_BLOCKED_BY_ADMINISTRATOR,
317 IDS_ERRORPAGES_SUMMARY_BLOCKED_ENROLLMENT_CHECK_PENDING,
318 IDS_ERRORPAGES_DETAILS_BLOCKED_ENROLLMENT_CHECK_PENDING,
319 SUGGEST_CHECK_CONNECTION,
321 {net::ERR_SSL_FALLBACK_BEYOND_MINIMUM_VERSION,
322 IDS_ERRORPAGES_TITLE_LOAD_FAILED,
323 IDS_ERRORPAGES_HEADING_SSL_FALLBACK_BEYOND_MINIMUM_VERSION,
324 IDS_ERRORPAGES_SUMMARY_SSL_FALLBACK_BEYOND_MINIMUM_VERSION,
325 IDS_ERRORPAGES_DETAILS_SSL_FALLBACK_BEYOND_MINIMUM_VERSION,
326 SUGGEST_NONE,
328 {net::ERR_SSL_VERSION_OR_CIPHER_MISMATCH,
329 IDS_ERRORPAGES_TITLE_LOAD_FAILED,
330 IDS_ERRORPAGES_HEADING_SSL_VERSION_OR_CIPHER_MISMATCH,
331 IDS_ERRORPAGES_SUMMARY_SSL_VERSION_OR_CIPHER_MISMATCH,
332 IDS_ERRORPAGES_DETAILS_SSL_VERSION_OR_CIPHER_MISMATCH,
333 SUGGEST_NONE,
337 // Special error page to be used in the case of navigating back to a page
338 // generated by a POST. LocalizedError::HasStrings expects this net error code
339 // to also appear in the array above.
340 const LocalizedErrorMap repost_error = {
341 net::ERR_CACHE_MISS,
342 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
343 IDS_HTTP_POST_WARNING_TITLE,
344 IDS_ERRORPAGES_HTTP_POST_WARNING,
345 IDS_ERRORPAGES_DETAILS_CACHE_MISS,
346 SUGGEST_RELOAD,
349 const LocalizedErrorMap http_error_options[] = {
350 {403,
351 IDS_ERRORPAGES_TITLE_ACCESS_DENIED,
352 IDS_ERRORPAGES_HEADING_ACCESS_DENIED,
353 IDS_ERRORPAGES_SUMMARY_FORBIDDEN,
354 IDS_ERRORPAGES_DETAILS_FORBIDDEN,
355 SUGGEST_NONE,
357 {410,
358 IDS_ERRORPAGES_TITLE_NOT_FOUND,
359 IDS_ERRORPAGES_HEADING_NOT_FOUND,
360 IDS_ERRORPAGES_SUMMARY_GONE,
361 IDS_ERRORPAGES_DETAILS_GONE,
362 SUGGEST_NONE,
365 {500,
366 IDS_ERRORPAGES_TITLE_LOAD_FAILED,
367 IDS_ERRORPAGES_HEADING_HTTP_SERVER_ERROR,
368 IDS_ERRORPAGES_SUMMARY_INTERNAL_SERVER_ERROR,
369 IDS_ERRORPAGES_DETAILS_INTERNAL_SERVER_ERROR,
370 SUGGEST_RELOAD,
372 {501,
373 IDS_ERRORPAGES_TITLE_LOAD_FAILED,
374 IDS_ERRORPAGES_HEADING_HTTP_SERVER_ERROR,
375 IDS_ERRORPAGES_SUMMARY_WEBSITE_CANNOT_HANDLE,
376 IDS_ERRORPAGES_DETAILS_NOT_IMPLEMENTED,
377 SUGGEST_NONE,
379 {502,
380 IDS_ERRORPAGES_TITLE_LOAD_FAILED,
381 IDS_ERRORPAGES_HEADING_HTTP_SERVER_ERROR,
382 IDS_ERRORPAGES_SUMMARY_BAD_GATEWAY,
383 IDS_ERRORPAGES_DETAILS_BAD_GATEWAY,
384 SUGGEST_RELOAD,
386 {503,
387 IDS_ERRORPAGES_TITLE_LOAD_FAILED,
388 IDS_ERRORPAGES_HEADING_HTTP_SERVER_ERROR,
389 IDS_ERRORPAGES_SUMMARY_SERVICE_UNAVAILABLE,
390 IDS_ERRORPAGES_DETAILS_SERVICE_UNAVAILABLE,
391 SUGGEST_RELOAD,
393 {504,
394 IDS_ERRORPAGES_TITLE_LOAD_FAILED,
395 IDS_ERRORPAGES_HEADING_HTTP_SERVER_ERROR,
396 IDS_ERRORPAGES_SUMMARY_GATEWAY_TIMEOUT,
397 IDS_ERRORPAGES_DETAILS_GATEWAY_TIMEOUT,
398 SUGGEST_RELOAD,
400 {505,
401 IDS_ERRORPAGES_TITLE_LOAD_FAILED,
402 IDS_ERRORPAGES_HEADING_HTTP_SERVER_ERROR,
403 IDS_ERRORPAGES_SUMMARY_WEBSITE_CANNOT_HANDLE,
404 IDS_ERRORPAGES_DETAILS_HTTP_VERSION_NOT_SUPPORTED,
405 SUGGEST_NONE,
409 const LocalizedErrorMap dns_probe_error_options[] = {
410 {chrome_common_net::DNS_PROBE_POSSIBLE,
411 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
412 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE,
413 IDS_ERRORPAGES_SUMMARY_DNS_PROBE_RUNNING,
414 IDS_ERRORPAGES_DETAILS_DNS_PROBE_RUNNING,
415 SUGGEST_RELOAD,
418 // DNS_PROBE_NOT_RUN is not here; NetErrorHelper will restore the original
419 // error, which might be one of several DNS-related errors.
421 {chrome_common_net::DNS_PROBE_STARTED,
422 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
423 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE,
424 IDS_ERRORPAGES_SUMMARY_DNS_PROBE_RUNNING,
425 IDS_ERRORPAGES_DETAILS_DNS_PROBE_RUNNING,
426 // Include SUGGEST_RELOAD so the More button doesn't jump when we update.
427 SUGGEST_RELOAD,
430 // DNS_PROBE_FINISHED_UNKNOWN is not here; NetErrorHelper will restore the
431 // original error, which might be one of several DNS-related errors.
433 {chrome_common_net::DNS_PROBE_FINISHED_NO_INTERNET,
434 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
435 IDS_ERRORPAGES_HEADING_INTERNET_DISCONNECTED,
436 IDS_ERRORPAGES_SUMMARY_INTERNET_DISCONNECTED,
437 IDS_ERRORPAGES_DETAILS_INTERNET_DISCONNECTED,
438 SUGGEST_RELOAD | SUGGEST_CHECK_CONNECTION | SUGGEST_FIREWALL_CONFIG,
440 {chrome_common_net::DNS_PROBE_FINISHED_BAD_CONFIG,
441 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
442 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE,
443 IDS_ERRORPAGES_SUMMARY_NAME_NOT_RESOLVED,
444 IDS_ERRORPAGES_DETAILS_NAME_NOT_RESOLVED,
445 SUGGEST_RELOAD | SUGGEST_DNS_CONFIG | SUGGEST_FIREWALL_CONFIG,
447 {chrome_common_net::DNS_PROBE_FINISHED_NXDOMAIN,
448 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
449 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE,
450 IDS_ERRORPAGES_SUMMARY_NAME_NOT_RESOLVED,
451 IDS_ERRORPAGES_DETAILS_NAME_NOT_RESOLVED,
452 SUGGEST_RELOAD,
456 const LocalizedErrorMap* FindErrorMapInArray(const LocalizedErrorMap* maps,
457 size_t num_maps,
458 int error_code) {
459 for (size_t i = 0; i < num_maps; ++i) {
460 if (maps[i].error_code == error_code)
461 return &maps[i];
463 return NULL;
466 const LocalizedErrorMap* LookupErrorMap(const std::string& error_domain,
467 int error_code, bool is_post) {
468 if (error_domain == net::kErrorDomain) {
469 // Display a different page in the special case of navigating through the
470 // history to an uncached page created by a POST.
471 if (is_post && error_code == net::ERR_CACHE_MISS)
472 return &repost_error;
473 return FindErrorMapInArray(net_error_options,
474 arraysize(net_error_options),
475 error_code);
476 } else if (error_domain == LocalizedError::kHttpErrorDomain) {
477 return FindErrorMapInArray(http_error_options,
478 arraysize(http_error_options),
479 error_code);
480 } else if (error_domain == chrome_common_net::kDnsProbeErrorDomain) {
481 const LocalizedErrorMap* map =
482 FindErrorMapInArray(dns_probe_error_options,
483 arraysize(dns_probe_error_options),
484 error_code);
485 DCHECK(map);
486 return map;
487 } else {
488 NOTREACHED();
489 return NULL;
493 // Returns a dictionary containing the strings for the settings menu under the
494 // wrench, and the advanced settings button.
495 base::DictionaryValue* GetStandardMenuItemsText() {
496 base::DictionaryValue* standard_menu_items_text = new base::DictionaryValue();
497 standard_menu_items_text->SetString("settingsTitle",
498 l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE));
499 standard_menu_items_text->SetString("advancedTitle",
500 l10n_util::GetStringUTF16(IDS_SETTINGS_SHOW_ADVANCED_SETTINGS));
501 return standard_menu_items_text;
504 // Gets the icon class for a given |error_domain| and |error_code|.
505 const char* GetIconClassForError(const std::string& error_domain,
506 int error_code) {
507 if ((error_code == net::ERR_INTERNET_DISCONNECTED &&
508 error_domain == net::kErrorDomain) ||
509 (error_code == chrome_common_net::DNS_PROBE_FINISHED_NO_INTERNET &&
510 error_domain == chrome_common_net::kDnsProbeErrorDomain))
511 return "icon-offline";
513 return "icon-generic";
516 } // namespace
518 const char LocalizedError::kHttpErrorDomain[] = "http";
520 void LocalizedError::GetStrings(int error_code,
521 const std::string& error_domain,
522 const GURL& failed_url,
523 bool is_post,
524 bool stale_copy_in_cache,
525 const std::string& locale,
526 const std::string& accept_languages,
527 scoped_ptr<error_page::ErrorPageParams> params,
528 base::DictionaryValue* error_strings) {
529 webui::SetLoadTimeDataDefaults(locale, error_strings);
531 // Grab the strings and settings that depend on the error type. Init
532 // options with default values.
533 LocalizedErrorMap options = {
535 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
536 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE,
537 IDS_ERRORPAGES_SUMMARY_NOT_AVAILABLE,
538 kErrorPagesNoDetails,
539 SUGGEST_NONE,
542 const LocalizedErrorMap* error_map = LookupErrorMap(error_domain, error_code,
543 is_post);
544 if (error_map)
545 options = *error_map;
547 // If we got "access denied" but the url was a file URL, then we say it was a
548 // file instead of just using the "not available" default message. Just adding
549 // ERR_ACCESS_DENIED to the map isn't sufficient, since that message may be
550 // generated by some OSs when the operation doesn't involve a file URL.
551 if (error_domain == net::kErrorDomain &&
552 error_code == net::ERR_ACCESS_DENIED &&
553 failed_url.scheme() == "file") {
554 options.title_resource_id = IDS_ERRORPAGES_TITLE_ACCESS_DENIED;
555 options.heading_resource_id = IDS_ERRORPAGES_HEADING_FILE_ACCESS_DENIED;
556 options.summary_resource_id = IDS_ERRORPAGES_SUMMARY_FILE_ACCESS_DENIED;
557 options.details_resource_id = IDS_ERRORPAGES_DETAILS_FILE_ACCESS_DENIED;
558 options.suggestions = SUGGEST_NONE;
561 base::string16 failed_url_string(net::FormatUrl(
562 failed_url, accept_languages, net::kFormatUrlOmitNothing,
563 net::UnescapeRule::NORMAL, NULL, NULL, NULL));
564 // URLs are always LTR.
565 if (base::i18n::IsRTL())
566 base::i18n::WrapStringWithLTRFormatting(&failed_url_string);
567 error_strings->SetString("title",
568 l10n_util::GetStringFUTF16(options.title_resource_id, failed_url_string));
569 error_strings->SetString("heading",
570 l10n_util::GetStringUTF16(options.heading_resource_id));
572 std::string icon_class = GetIconClassForError(error_domain, error_code);
573 error_strings->SetString("iconClass", icon_class);
575 base::DictionaryValue* summary = new base::DictionaryValue;
577 // For offline show a summary message underneath the heading.
578 if (error_code == net::ERR_INTERNET_DISCONNECTED ||
579 error_code == chrome_common_net::DNS_PROBE_FINISHED_NO_INTERNET) {
580 error_strings->SetString("primaryParagraph",
581 l10n_util::GetStringUTF16(options.summary_resource_id));
583 #if defined(OS_CHROMEOS)
584 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
586 // Check if easter egg should be disabled.
587 if (command_line->HasSwitch(switches::kDisableDinosaurEasterEgg)) {
588 // The prescence of this string disables the easter egg. Acts as a flag.
589 error_strings->SetString("disabledEasterEgg",
590 l10n_util::GetStringUTF16(IDS_ERRORPAGE_FUN_DISABLED));
592 #endif
594 } else {
595 // Set summary message in the details.
596 summary->SetString("msg",
597 l10n_util::GetStringUTF16(options.summary_resource_id));
599 summary->SetString("failedUrl", failed_url_string);
600 summary->SetString("hostName", net::IDNToUnicode(failed_url.host(),
601 accept_languages));
602 summary->SetString("productName",
603 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
605 error_strings->SetString(
606 "details", l10n_util::GetStringUTF16(IDS_ERRORPAGE_NET_BUTTON_DETAILS));
607 error_strings->SetString(
608 "hideDetails", l10n_util::GetStringUTF16(
609 IDS_ERRORPAGE_NET_BUTTON_HIDE_DETAILS));
610 error_strings->Set("summary", summary);
612 if (options.details_resource_id != kErrorPagesNoDetails) {
613 error_strings->SetString(
614 "errorDetails", l10n_util::GetStringUTF16(options.details_resource_id));
617 base::string16 error_string;
618 if (error_domain == net::kErrorDomain) {
619 // Non-internationalized error string, for debugging Chrome itself.
620 error_string = base::ASCIIToUTF16(net::ErrorToShortString(error_code));
621 } else if (error_domain == chrome_common_net::kDnsProbeErrorDomain) {
622 std::string ascii_error_string =
623 chrome_common_net::DnsProbeStatusToString(error_code);
624 error_string = base::ASCIIToUTF16(ascii_error_string);
625 } else {
626 DCHECK_EQ(LocalizedError::kHttpErrorDomain, error_domain);
627 error_string = base::IntToString16(error_code);
629 error_strings->SetString("errorCode",
630 l10n_util::GetStringFUTF16(IDS_ERRORPAGES_ERROR_CODE, error_string));
632 // Platform specific information for diagnosing network issues on OSX and
633 // Windows.
634 #if defined(OS_MACOSX) || defined(OS_WIN)
635 if (error_domain == net::kErrorDomain &&
636 error_code == net::ERR_INTERNET_DISCONNECTED) {
637 int platform_string_id =
638 IDS_ERRORPAGES_SUMMARY_INTERNET_DISCONNECTED_PLATFORM;
639 #if defined(OS_WIN)
640 // Different versions of Windows have different instructions.
641 base::win::Version windows_version = base::win::GetVersion();
642 if (windows_version < base::win::VERSION_VISTA) {
643 // XP, XP64, and Server 2003.
644 platform_string_id =
645 IDS_ERRORPAGES_SUMMARY_INTERNET_DISCONNECTED_PLATFORM_XP;
646 } else if (windows_version == base::win::VERSION_VISTA) {
647 // Vista
648 platform_string_id =
649 IDS_ERRORPAGES_SUMMARY_INTERNET_DISCONNECTED_PLATFORM_VISTA;
651 #endif // defined(OS_WIN)
652 // Platform dependent portion of the summary section.
653 summary->SetString("msg",
654 l10n_util::GetStringFUTF16(
655 IDS_ERRORPAGES_SUMMARY_INTERNET_DISCONNECTED_INSTRUCTIONS_TEMPLATE,
656 l10n_util::GetStringUTF16(platform_string_id)));
658 #endif // defined(OS_MACOSX) || defined(OS_WIN)
660 // If no parameters were provided, use the defaults.
661 if (!params) {
662 params.reset(new error_page::ErrorPageParams());
663 params->suggest_reload = !!(options.suggestions & SUGGEST_RELOAD);
666 base::ListValue* suggestions = NULL;
667 bool use_default_suggestions = true;
668 if (!params->override_suggestions) {
669 suggestions = new base::ListValue();
670 } else {
671 suggestions = params->override_suggestions.release();
672 use_default_suggestions = false;
673 EnableGoogleCachedCopyButtonExperiment(suggestions, error_strings);
676 error_strings->Set("suggestions", suggestions);
678 if (params->search_url.is_valid()) {
679 error_strings->SetString("searchHeader",
680 l10n_util::GetStringUTF16(IDS_ERRORPAGES_SUGGESTION_GOOGLE_SEARCH));
681 error_strings->SetString("searchUrl", params->search_url.spec());
682 error_strings->SetString("searchTerms", params->search_terms);
683 error_strings->SetInteger("searchTrackingId", params->search_tracking_id);
686 // Add the reload suggestion, if needed.
687 if (params->suggest_reload) {
688 if (!is_post) {
689 base::DictionaryValue* reload_button = new base::DictionaryValue;
690 reload_button->SetString(
691 "msg", l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_RELOAD));
692 reload_button->SetString("reloadUrl", failed_url.spec());
693 error_strings->Set("reloadButton", reload_button);
694 reload_button->SetInteger("reloadTrackingId", params->reload_tracking_id);
695 } else {
696 // If the page was created by a post, it can't be reloaded in the same
697 // way, so just add a suggestion instead.
698 // TODO(mmenke): Make the reload button bring up the repost confirmation
699 // dialog for pages resulting from posts.
700 base::DictionaryValue* suggest_reload_repost = new base::DictionaryValue;
701 suggest_reload_repost->SetString("header",
702 l10n_util::GetStringUTF16(
703 IDS_ERRORPAGES_SUGGESTION_RELOAD_REPOST_HEADER));
704 suggest_reload_repost->SetString("body",
705 l10n_util::GetStringUTF16(
706 IDS_ERRORPAGES_SUGGESTION_RELOAD_REPOST_BODY));
707 // Add at the front, so it appears before other suggestions, in the case
708 // suggestions are being overridden by |params|.
709 suggestions->Insert(0, suggest_reload_repost);
713 // If not using the default suggestions, nothing else to do.
714 if (!use_default_suggestions)
715 return;
717 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
718 const std::string& show_saved_copy_value =
719 command_line->GetSwitchValueASCII(switches::kShowSavedCopy);
720 bool show_saved_copy_primary = (show_saved_copy_value ==
721 switches::kEnableShowSavedCopyPrimary);
722 bool show_saved_copy_secondary = (show_saved_copy_value ==
723 switches::kEnableShowSavedCopySecondary);
724 bool show_saved_copy_visible =
725 (stale_copy_in_cache && !is_post &&
726 (show_saved_copy_primary || show_saved_copy_secondary));
728 if (show_saved_copy_visible) {
729 base::DictionaryValue* show_saved_copy_button = new base::DictionaryValue;
730 show_saved_copy_button->SetString(
731 "msg", l10n_util::GetStringUTF16(
732 IDS_ERRORPAGES_BUTTON_SHOW_SAVED_COPY));
733 show_saved_copy_button->SetString(
734 "title",
735 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_SHOW_SAVED_COPY_HELP));
736 if (show_saved_copy_primary)
737 show_saved_copy_button->SetString("primary", "true");
738 error_strings->Set("showSavedCopyButton", show_saved_copy_button);
741 #if defined(OS_CHROMEOS)
742 error_strings->SetString(
743 "diagnose", l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_DIAGNOSE));
744 #endif // defined(OS_CHROMEOS)
746 if (options.suggestions & SUGGEST_CHECK_CONNECTION) {
747 base::DictionaryValue* suggest_check_connection = new base::DictionaryValue;
748 suggest_check_connection->SetString("header",
749 l10n_util::GetStringUTF16(
750 IDS_ERRORPAGES_SUGGESTION_CHECK_CONNECTION_HEADER));
751 suggest_check_connection->SetString("body",
752 l10n_util::GetStringUTF16(
753 IDS_ERRORPAGES_SUGGESTION_CHECK_CONNECTION_BODY));
754 suggestions->Append(suggest_check_connection);
757 if (options.suggestions & SUGGEST_DNS_CONFIG) {
758 base::DictionaryValue* suggest_dns_config = new base::DictionaryValue;
759 suggest_dns_config->SetString("header",
760 l10n_util::GetStringUTF16(
761 IDS_ERRORPAGES_SUGGESTION_DNS_CONFIG_HEADER));
762 suggest_dns_config->SetString("body",
763 l10n_util::GetStringUTF16(
764 IDS_ERRORPAGES_SUGGESTION_DNS_CONFIG_BODY));
765 suggestions->Append(suggest_dns_config);
767 base::DictionaryValue* suggest_network_prediction =
768 GetStandardMenuItemsText();
769 suggest_network_prediction->SetString("header",
770 l10n_util::GetStringUTF16(
771 IDS_ERRORPAGES_SUGGESTION_NETWORK_PREDICTION_HEADER));
772 suggest_network_prediction->SetString("body",
773 l10n_util::GetStringUTF16(
774 IDS_ERRORPAGES_SUGGESTION_NETWORK_PREDICTION_BODY));
775 suggest_network_prediction->SetString(
776 "noNetworkPredictionTitle",
777 l10n_util::GetStringUTF16(
778 IDS_NETWORK_PREDICTION_ENABLED_DESCRIPTION));
779 suggestions->Append(suggest_network_prediction);
782 if (options.suggestions & SUGGEST_FIREWALL_CONFIG) {
783 base::DictionaryValue* suggest_firewall_config = new base::DictionaryValue;
784 suggest_firewall_config->SetString("header",
785 l10n_util::GetStringUTF16(
786 IDS_ERRORPAGES_SUGGESTION_FIREWALL_CONFIG_HEADER));
787 suggest_firewall_config->SetString("body",
788 l10n_util::GetStringUTF16(
789 IDS_ERRORPAGES_SUGGESTION_FIREWALL_CONFIG_BODY));
790 suggestions->Append(suggest_firewall_config);
793 if (options.suggestions & SUGGEST_PROXY_CONFIG) {
794 base::DictionaryValue* suggest_proxy_config = GetStandardMenuItemsText();
795 suggest_proxy_config->SetString("header",
796 l10n_util::GetStringUTF16(
797 IDS_ERRORPAGES_SUGGESTION_PROXY_CONFIG_HEADER));
798 suggest_proxy_config->SetString("body",
799 l10n_util::GetStringFUTF16(IDS_ERRORPAGES_SUGGESTION_PROXY_CONFIG_BODY,
800 l10n_util::GetStringUTF16(
801 IDS_ERRORPAGES_SUGGESTION_PROXY_DISABLE_PLATFORM)));
802 suggest_proxy_config->SetString("proxyTitle",
803 l10n_util::GetStringUTF16(IDS_OPTIONS_PROXIES_CONFIGURE_BUTTON));
805 suggestions->Append(suggest_proxy_config);
808 if (options.suggestions & SUGGEST_DISABLE_EXTENSION) {
809 base::DictionaryValue* suggest_disable_extension =
810 new base::DictionaryValue;
811 // There's only a header for this suggestion.
812 suggest_disable_extension->SetString("header",
813 l10n_util::GetStringUTF16(
814 IDS_ERRORPAGES_SUGGESTION_DISABLE_EXTENSION_HEADER));
815 suggestions->Append(suggest_disable_extension);
818 if (options.suggestions & SUGGEST_VIEW_POLICIES) {
819 base::DictionaryValue* suggest_view_policies = new base::DictionaryValue;
820 suggest_view_policies->SetString(
821 "header",
822 l10n_util::GetStringUTF16(
823 IDS_ERRORPAGES_SUGGESTION_VIEW_POLICIES_HEADER));
824 suggest_view_policies->SetString(
825 "body",
826 l10n_util::GetStringUTF16(
827 IDS_ERRORPAGES_SUGGESTION_VIEW_POLICIES_BODY));
828 suggestions->Append(suggest_view_policies);
831 if (options.suggestions & SUGGEST_CONTACT_ADMINISTRATOR) {
832 base::DictionaryValue* suggest_contant_administrator =
833 new base::DictionaryValue;
834 suggest_contant_administrator->SetString(
835 "body",
836 l10n_util::GetStringUTF16(
837 IDS_ERRORPAGES_SUGGESTION_CONTACT_ADMINISTRATOR_BODY));
838 suggestions->Append(suggest_contant_administrator);
841 if (options.suggestions & SUGGEST_LEARNMORE) {
842 GURL learn_more_url;
843 switch (options.error_code) {
844 case net::ERR_TOO_MANY_REDIRECTS:
845 learn_more_url = GURL(kRedirectLoopLearnMoreUrl);
846 break;
847 case net::ERR_SSL_WEAK_SERVER_EPHEMERAL_DH_KEY:
848 learn_more_url = GURL(kWeakDHKeyLearnMoreUrl);
849 break;
850 default:
851 break;
854 if (learn_more_url.is_valid()) {
855 // Add the language parameter to the URL.
856 std::string query = learn_more_url.query() + "&hl=" + locale;
857 GURL::Replacements repl;
858 repl.SetQueryStr(query);
859 learn_more_url = learn_more_url.ReplaceComponents(repl);
861 base::DictionaryValue* suggest_learn_more = new base::DictionaryValue;
862 // There's only a body for this suggestion.
863 suggest_learn_more->SetString("body",
864 l10n_util::GetStringUTF16(IDS_ERRORPAGES_SUGGESTION_LEARNMORE_BODY));
865 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec());
866 suggestions->Append(suggest_learn_more);
871 base::string16 LocalizedError::GetErrorDetails(const blink::WebURLError& error,
872 bool is_post) {
873 const LocalizedErrorMap* error_map =
874 LookupErrorMap(error.domain.utf8(), error.reason, is_post);
875 if (error_map)
876 return l10n_util::GetStringUTF16(error_map->details_resource_id);
877 else
878 return l10n_util::GetStringUTF16(IDS_ERRORPAGES_DETAILS_UNKNOWN);
881 bool LocalizedError::HasStrings(const std::string& error_domain,
882 int error_code) {
883 // Whether or not the there are strings for an error does not depend on
884 // whether or not the page was be generated by a POST, so just claim it was
885 // not.
886 return LookupErrorMap(error_domain, error_code, /*is_post=*/false) != NULL;
889 #if defined(ENABLE_EXTENSIONS)
890 void LocalizedError::GetAppErrorStrings(
891 const GURL& display_url,
892 const extensions::Extension* app,
893 const std::string& locale,
894 base::DictionaryValue* error_strings) {
895 DCHECK(app);
897 webui::SetLoadTimeDataDefaults(locale, error_strings);
899 base::string16 failed_url(base::ASCIIToUTF16(display_url.spec()));
900 // URLs are always LTR.
901 if (base::i18n::IsRTL())
902 base::i18n::WrapStringWithLTRFormatting(&failed_url);
903 error_strings->SetString(
904 "url", l10n_util::GetStringFUTF16(IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
905 failed_url.c_str()));
907 error_strings->SetString("title", app->name());
908 error_strings->SetString(
909 "icon",
910 extensions::IconsInfo::GetIconURL(
911 app,
912 extension_misc::EXTENSION_ICON_GIGANTOR,
913 ExtensionIconSet::MATCH_SMALLER).spec());
914 error_strings->SetString("name", app->name());
915 error_strings->SetString(
916 "msg",
917 l10n_util::GetStringUTF16(IDS_ERRORPAGES_APP_WARNING));
919 #if defined(OS_CHROMEOS)
920 GURL learn_more_url(kAppWarningLearnMoreUrl);
921 base::DictionaryValue* suggest_learn_more = new base::DictionaryValue();
922 suggest_learn_more->SetString("msg",
923 l10n_util::GetStringUTF16(
924 IDS_ERRORPAGES_SUGGESTION_LEARNMORE_BODY));
925 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec());
926 error_strings->Set("suggestionsLearnMore", suggest_learn_more);
927 #endif // defined(OS_CHROMEOS)
929 #endif
931 void LocalizedError::EnableGoogleCachedCopyButtonExperiment(
932 base::ListValue* suggestions,
933 base::DictionaryValue* error_strings) {
934 std::string field_trial_exp_type_ =
935 base::FieldTrialList::FindFullName(kCachedCopyButtonFieldTrial);
937 // If the first suggestion is for a Google cache copy. Promote the
938 // suggestion to a separate set of strings for displaying as a button.
939 if (!suggestions->empty() && !field_trial_exp_type_.empty() &&
940 field_trial_exp_type_ != kCachedCopyButtonExpTypeControl) {
941 base::DictionaryValue* suggestion;
942 suggestions->GetDictionary(0, &suggestion);
943 int type = -1;
944 suggestion->GetInteger("type", &type);
946 if (type == kGoogleCachedCopySuggestionType) {
947 base::string16 cache_url;
948 suggestion->GetString("urlCorrection", &cache_url);
949 int cache_tracking_id = -1;
950 suggestion->GetInteger("trackingId", &cache_tracking_id);
952 scoped_ptr<base::DictionaryValue> cache_button(new base::DictionaryValue);
954 if (field_trial_exp_type_ == kCachedCopyButtonExpTypeCopy) {
955 cache_button->SetString(
956 "msg",
957 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_SHOW_CACHED_COPY));
958 } else {
959 // Default to "Show cached page" button label.
960 cache_button->SetString(
961 "msg",
962 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_SHOW_CACHED_PAGE));
964 cache_button->SetString("cacheUrl", cache_url);
965 cache_button->SetInteger("trackingId", cache_tracking_id);
966 error_strings->Set("cacheButton", cache_button.release());
968 // Remove the item from suggestions dictionary so that it does not get
969 // displayed by the template in the details section.
970 suggestions->Remove(0, nullptr);