OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/common/localized_error.h" | 5 #include "chrome/common/localized_error.h" |
6 | 6 |
7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/string16.h" | 9 #include "base/string16.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "chrome/common/extensions/api/icons/icons_handler.h" | 14 #include "chrome/common/extensions/api/icons/icons_handler.h" |
15 #include "chrome/common/extensions/extension_constants.h" | 15 #include "chrome/common/extensions/extension_constants.h" |
16 #include "chrome/common/extensions/extension_icon_set.h" | 16 #include "chrome/common/extensions/extension_icon_set.h" |
17 #include "chrome/common/extensions/extension_set.h" | 17 #include "chrome/common/extensions/extension_set.h" |
18 #include "chrome/common/net/net_error_info.h" | |
18 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
19 #include "grit/chromium_strings.h" | 20 #include "grit/chromium_strings.h" |
20 #include "grit/generated_resources.h" | 21 #include "grit/generated_resources.h" |
21 #include "net/base/escape.h" | 22 #include "net/base/escape.h" |
22 #include "net/base/net_errors.h" | 23 #include "net/base/net_errors.h" |
23 #include "third_party/WebKit/Source/Platform/chromium/public/WebURLError.h" | 24 #include "third_party/WebKit/Source/Platform/chromium/public/WebURLError.h" |
24 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
25 #include "ui/webui/web_ui_util.h" | 26 #include "ui/webui/web_ui_util.h" |
26 #include "webkit/glue/webkit_glue.h" | 27 #include "webkit/glue/webkit_glue.h" |
27 | 28 |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
348 }, | 349 }, |
349 {505, | 350 {505, |
350 IDS_ERRORPAGES_TITLE_LOAD_FAILED, | 351 IDS_ERRORPAGES_TITLE_LOAD_FAILED, |
351 IDS_ERRORPAGES_HEADING_HTTP_SERVER_ERROR, | 352 IDS_ERRORPAGES_HEADING_HTTP_SERVER_ERROR, |
352 IDS_ERRORPAGES_SUMMARY_WEBSITE_CANNOT_HANDLE, | 353 IDS_ERRORPAGES_SUMMARY_WEBSITE_CANNOT_HANDLE, |
353 IDS_ERRORPAGES_DETAILS_HTTP_VERSION_NOT_SUPPORTED, | 354 IDS_ERRORPAGES_DETAILS_HTTP_VERSION_NOT_SUPPORTED, |
354 SUGGEST_NONE, | 355 SUGGEST_NONE, |
355 }, | 356 }, |
356 }; | 357 }; |
357 | 358 |
359 const LocalizedErrorMap dns_probe_error_options[] = { | |
360 {chrome_common_net::DNS_PROBE_POSSIBLE, | |
361 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, | |
362 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE, | |
363 IDS_ERRORPAGES_SUMMARY_DNS_PROBE_RUNNING, | |
364 IDS_ERRORPAGES_DETAILS_DNS_PROBE_RUNNING, | |
365 SUGGEST_NONE, | |
mmenke
2013/04/10 16:56:58
All the other results have "SUGGEST_RELOAD", and i
Deprecated (see juliatuttle)
2013/04/10 23:42:32
Done.
| |
366 }, | |
367 | |
368 // DNS_PROBE_NOT_RUN is not here; NetErrorHelper will restore the original | |
369 // error, which might be one of several DNS-related errors. | |
370 | |
371 {chrome_common_net::DNS_PROBE_STARTED, | |
372 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, | |
373 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE, | |
374 IDS_ERRORPAGES_SUMMARY_DNS_PROBE_RUNNING, | |
375 IDS_ERRORPAGES_DETAILS_DNS_PROBE_RUNNING, | |
376 // Include SUGGEST_RELOAD so the More button doesn't jump when we update. | |
377 SUGGEST_RELOAD | SUGGEST_NONE, | |
mmenke
2013/04/10 16:56:58
"| SUGGEST_NONE" doesn't make any sense. :)
mmenke
2013/04/10 16:56:58
Do we need a PROBE_STARTED page? I don't think we
Deprecated (see juliatuttle)
2013/04/10 23:42:32
Done.
Deprecated (see juliatuttle)
2013/04/10 23:42:32
It's there in case we want to show a spinner or di
| |
378 }, | |
379 | |
380 // DNS_PROBE_FINISHED_UNKNOWN is not here; NetErrorHelper will restore the | |
381 // original error, which might be one of several DNS-related errors. | |
mmenke
2013/04/10 16:56:58
Erm.... DNS_PROBE_FINISHED_UNKNOWN is here.
Deprecated (see juliatuttle)
2013/04/10 23:42:32
Done.
| |
382 | |
383 {chrome_common_net::DNS_PROBE_FINISHED_UNKNOWN, | |
384 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, | |
385 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE, | |
386 IDS_ERRORPAGES_SUMMARY_NAME_NOT_RESOLVED, | |
387 IDS_ERRORPAGES_DETAILS_NAME_NOT_RESOLVED, | |
388 SUGGEST_RELOAD | SUGGEST_CHECK_CONNECTION | SUGGEST_DNS_CONFIG | | |
389 SUGGEST_FIREWALL_CONFIG | SUGGEST_PROXY_CONFIG, | |
390 }, | |
391 {chrome_common_net::DNS_PROBE_FINISHED_NO_INTERNET, | |
392 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, | |
393 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE, | |
394 IDS_ERRORPAGES_SUMMARY_INTERNET_DISCONNECTED, | |
395 IDS_ERRORPAGES_DETAILS_INTERNET_DISCONNECTED, | |
396 SUGGEST_RELOAD | SUGGEST_CHECK_CONNECTION | SUGGEST_FIREWALL_CONFIG, | |
397 }, | |
398 {chrome_common_net::DNS_PROBE_FINISHED_BAD_CONFIG, | |
399 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, | |
400 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE, | |
401 IDS_ERRORPAGES_SUMMARY_NAME_NOT_RESOLVED, | |
402 IDS_ERRORPAGES_DETAILS_NAME_NOT_RESOLVED, | |
403 SUGGEST_RELOAD | SUGGEST_DNS_CONFIG | SUGGEST_FIREWALL_CONFIG, | |
404 }, | |
405 {chrome_common_net::DNS_PROBE_FINISHED_NXDOMAIN, | |
406 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, | |
407 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE, | |
408 IDS_ERRORPAGES_SUMMARY_NAME_NOT_RESOLVED, | |
409 IDS_ERRORPAGES_DETAILS_NAME_NOT_RESOLVED, | |
410 SUGGEST_RELOAD | SUGGEST_HOSTNAME, | |
411 }, | |
412 }; | |
413 | |
358 const LocalizedErrorMap* FindErrorMapInArray(const LocalizedErrorMap* maps, | 414 const LocalizedErrorMap* FindErrorMapInArray(const LocalizedErrorMap* maps, |
359 size_t num_maps, | 415 size_t num_maps, |
360 int error_code) { | 416 int error_code) { |
361 for (size_t i = 0; i < num_maps; ++i) { | 417 for (size_t i = 0; i < num_maps; ++i) { |
362 if (maps[i].error_code == error_code) | 418 if (maps[i].error_code == error_code) |
363 return &maps[i]; | 419 return &maps[i]; |
364 } | 420 } |
365 return NULL; | 421 return NULL; |
366 } | 422 } |
367 | 423 |
368 const LocalizedErrorMap* LookupErrorMap(const std::string& error_domain, | 424 const LocalizedErrorMap* LookupErrorMap(const std::string& error_domain, |
369 int error_code) { | 425 int error_code) { |
370 if (error_domain == net::kErrorDomain) { | 426 if (error_domain == net::kErrorDomain) { |
371 return FindErrorMapInArray(net_error_options, | 427 return FindErrorMapInArray(net_error_options, |
372 arraysize(net_error_options), | 428 arraysize(net_error_options), |
373 error_code); | 429 error_code); |
374 } else if (error_domain == LocalizedError::kHttpErrorDomain) { | 430 } else if (error_domain == LocalizedError::kHttpErrorDomain) { |
375 return FindErrorMapInArray(http_error_options, | 431 return FindErrorMapInArray(http_error_options, |
376 arraysize(http_error_options), | 432 arraysize(http_error_options), |
377 error_code); | 433 error_code); |
434 } else if (error_domain == chrome_common_net::kDnsProbeErrorDomain) { | |
435 return FindErrorMapInArray(dns_probe_error_options, | |
436 arraysize(dns_probe_error_options), | |
437 error_code); | |
378 } else { | 438 } else { |
379 NOTREACHED(); | 439 NOTREACHED(); |
380 return NULL; | 440 return NULL; |
381 } | 441 } |
382 } | 442 } |
383 | 443 |
384 bool LocaleIsRTL() { | 444 bool LocaleIsRTL() { |
385 #if defined(TOOLKIT_GTK) | 445 #if defined(TOOLKIT_GTK) |
386 // base::i18n::IsRTL() uses the GTK text direction, which doesn't work within | 446 // base::i18n::IsRTL() uses the GTK text direction, which doesn't work within |
387 // the renderer sandbox. | 447 // the renderer sandbox. |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
484 "errorDetails", l10n_util::GetStringUTF16(options.details_resource_id)); | 544 "errorDetails", l10n_util::GetStringUTF16(options.details_resource_id)); |
485 } | 545 } |
486 | 546 |
487 string16 error_string; | 547 string16 error_string; |
488 if (error_domain == net::kErrorDomain) { | 548 if (error_domain == net::kErrorDomain) { |
489 // Non-internationalized error string, for debugging Chrome itself. | 549 // Non-internationalized error string, for debugging Chrome itself. |
490 std::string ascii_error_string = net::ErrorToString(error_code); | 550 std::string ascii_error_string = net::ErrorToString(error_code); |
491 // Remove the leading "net::" from the returned string. | 551 // Remove the leading "net::" from the returned string. |
492 RemoveChars(ascii_error_string, "net:", &ascii_error_string); | 552 RemoveChars(ascii_error_string, "net:", &ascii_error_string); |
493 error_string = ASCIIToUTF16(ascii_error_string); | 553 error_string = ASCIIToUTF16(ascii_error_string); |
554 } else if (error_domain == chrome_common_net::kDnsProbeErrorDomain) { | |
555 std::string ascii_error_string = | |
556 chrome_common_net::DnsProbeStatusToString(error_code); | |
557 error_string = ASCIIToUTF16(ascii_error_string); | |
mmenke
2013/04/10 16:56:58
Per other comment, we may just want to use the ERR
Deprecated (see juliatuttle)
2013/04/10 23:42:32
I'd rather have the detail, in case things break.
| |
494 } else { | 558 } else { |
495 DCHECK_EQ(LocalizedError::kHttpErrorDomain, error_domain); | 559 DCHECK_EQ(LocalizedError::kHttpErrorDomain, error_domain); |
496 error_string = base::IntToString16(error_code); | 560 error_string = base::IntToString16(error_code); |
497 } | 561 } |
498 error_strings->SetString("errorCode", | 562 error_strings->SetString("errorCode", |
499 l10n_util::GetStringFUTF16(IDS_ERRORPAGES_ERROR_CODE, error_string)); | 563 l10n_util::GetStringFUTF16(IDS_ERRORPAGES_ERROR_CODE, error_string)); |
500 | 564 |
501 // Platform specific instructions for diagnosing network issues on OSX and | 565 // Platform specific instructions for diagnosing network issues on OSX and |
502 // Windows. | 566 // Windows. |
503 #if defined(OS_MACOSX) || defined(OS_WIN) | 567 #if defined(OS_MACOSX) || defined(OS_WIN) |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
736 #if defined(OS_CHROMEOS) | 800 #if defined(OS_CHROMEOS) |
737 GURL learn_more_url(kAppWarningLearnMoreUrl); | 801 GURL learn_more_url(kAppWarningLearnMoreUrl); |
738 DictionaryValue* suggest_learn_more = new DictionaryValue(); | 802 DictionaryValue* suggest_learn_more = new DictionaryValue(); |
739 suggest_learn_more->SetString("msg", | 803 suggest_learn_more->SetString("msg", |
740 l10n_util::GetStringUTF16( | 804 l10n_util::GetStringUTF16( |
741 IDS_ERRORPAGES_SUGGESTION_LEARNMORE)); | 805 IDS_ERRORPAGES_SUGGESTION_LEARNMORE)); |
742 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec()); | 806 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec()); |
743 error_strings->Set("suggestionsLearnMore", suggest_learn_more); | 807 error_strings->Set("suggestionsLearnMore", suggest_learn_more); |
744 #endif // defined(OS_CHROMEOS) | 808 #endif // defined(OS_CHROMEOS) |
745 } | 809 } |
OLD | NEW |