| 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/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 const std::string& error_domain, | 503 const std::string& error_domain, |
| 504 const GURL& failed_url, | 504 const GURL& failed_url, |
| 505 bool is_post, | 505 bool is_post, |
| 506 bool show_stale_load_button, | 506 bool show_stale_load_button, |
| 507 const std::string& locale, | 507 const std::string& locale, |
| 508 const std::string& accept_languages, | 508 const std::string& accept_languages, |
| 509 scoped_ptr<ErrorPageParams> params, | 509 scoped_ptr<ErrorPageParams> params, |
| 510 base::DictionaryValue* error_strings) { | 510 base::DictionaryValue* error_strings) { |
| 511 bool rtl = LocaleIsRTL(); | 511 bool rtl = LocaleIsRTL(); |
| 512 error_strings->SetString("textdirection", rtl ? "rtl" : "ltr"); | 512 error_strings->SetString("textdirection", rtl ? "rtl" : "ltr"); |
| 513 webui::SetFontAndTextDirection(error_strings); |
| 513 | 514 |
| 514 // Grab the strings and settings that depend on the error type. Init | 515 // Grab the strings and settings that depend on the error type. Init |
| 515 // options with default values. | 516 // options with default values. |
| 516 LocalizedErrorMap options = { | 517 LocalizedErrorMap options = { |
| 517 0, | 518 0, |
| 518 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, | 519 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, |
| 519 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE, | 520 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE, |
| 520 IDS_ERRORPAGES_SUMMARY_NOT_AVAILABLE, | 521 IDS_ERRORPAGES_SUMMARY_NOT_AVAILABLE, |
| 521 kErrorPagesNoDetails, | 522 kErrorPagesNoDetails, |
| 522 SUGGEST_NONE, | 523 SUGGEST_NONE, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 549 base::i18n::WrapStringWithLTRFormatting(&failed_url_string); | 550 base::i18n::WrapStringWithLTRFormatting(&failed_url_string); |
| 550 error_strings->SetString("title", | 551 error_strings->SetString("title", |
| 551 l10n_util::GetStringFUTF16(options.title_resource_id, failed_url_string)); | 552 l10n_util::GetStringFUTF16(options.title_resource_id, failed_url_string)); |
| 552 error_strings->SetString("heading", | 553 error_strings->SetString("heading", |
| 553 l10n_util::GetStringUTF16(options.heading_resource_id)); | 554 l10n_util::GetStringUTF16(options.heading_resource_id)); |
| 554 | 555 |
| 555 std::string icon_class = GetIconClassForError(error_domain, error_code); | 556 std::string icon_class = GetIconClassForError(error_domain, error_code); |
| 556 error_strings->SetString("iconClass", icon_class); | 557 error_strings->SetString("iconClass", icon_class); |
| 557 | 558 |
| 558 base::DictionaryValue* summary = new base::DictionaryValue; | 559 base::DictionaryValue* summary = new base::DictionaryValue; |
| 559 summary->SetString("msg", | 560 |
| 560 l10n_util::GetStringUTF16(options.summary_resource_id)); | 561 // For offline show a summary message underneath the heading. |
| 562 if (error_code == net::ERR_INTERNET_DISCONNECTED) { |
| 563 error_strings->SetString("primaryParagraph", |
| 564 l10n_util::GetStringUTF16(options.summary_resource_id)); |
| 565 } else { |
| 566 // Set summary message in the details. |
| 567 summary->SetString("msg", |
| 568 l10n_util::GetStringUTF16(options.summary_resource_id)); |
| 569 } |
| 561 summary->SetString("failedUrl", failed_url_string); | 570 summary->SetString("failedUrl", failed_url_string); |
| 562 summary->SetString("hostName", net::IDNToUnicode(failed_url.host(), | 571 summary->SetString("hostName", net::IDNToUnicode(failed_url.host(), |
| 563 accept_languages)); | 572 accept_languages)); |
| 564 summary->SetString("productName", | 573 summary->SetString("productName", |
| 565 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 574 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
| 566 | 575 |
| 567 error_strings->SetString( | 576 error_strings->SetString( |
| 568 "details", l10n_util::GetStringUTF16(IDS_ERRORPAGE_NET_BUTTON_DETAILS)); | 577 "details", l10n_util::GetStringUTF16(IDS_ERRORPAGE_NET_BUTTON_DETAILS)); |
| 569 error_strings->SetString( | 578 error_strings->SetString( |
| 570 "hideDetails", l10n_util::GetStringUTF16( | 579 "hideDetails", l10n_util::GetStringUTF16( |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 if (windows_version < base::win::VERSION_VISTA) { | 613 if (windows_version < base::win::VERSION_VISTA) { |
| 605 // XP, XP64, and Server 2003. | 614 // XP, XP64, and Server 2003. |
| 606 platform_string_id = | 615 platform_string_id = |
| 607 IDS_ERRORPAGES_SUMMARY_INTERNET_DISCONNECTED_PLATFORM_XP; | 616 IDS_ERRORPAGES_SUMMARY_INTERNET_DISCONNECTED_PLATFORM_XP; |
| 608 } else if (windows_version == base::win::VERSION_VISTA) { | 617 } else if (windows_version == base::win::VERSION_VISTA) { |
| 609 // Vista | 618 // Vista |
| 610 platform_string_id = | 619 platform_string_id = |
| 611 IDS_ERRORPAGES_SUMMARY_INTERNET_DISCONNECTED_PLATFORM_VISTA; | 620 IDS_ERRORPAGES_SUMMARY_INTERNET_DISCONNECTED_PLATFORM_VISTA; |
| 612 } | 621 } |
| 613 #endif // defined(OS_WIN) | 622 #endif // defined(OS_WIN) |
| 614 // Lead with the general error description, and suffix with the platform | 623 // Platform dependent portion of the summary section. |
| 615 // dependent portion of the summary section. | |
| 616 summary->SetString("msg", | 624 summary->SetString("msg", |
| 617 l10n_util::GetStringFUTF16( | 625 l10n_util::GetStringFUTF16( |
| 618 IDS_ERRORPAGES_SUMMARY_INTERNET_DISCONNECTED_INSTRUCTIONS_TEMPLATE, | 626 IDS_ERRORPAGES_SUMMARY_INTERNET_DISCONNECTED_INSTRUCTIONS_TEMPLATE, |
| 619 l10n_util::GetStringUTF16(options.summary_resource_id), | |
| 620 l10n_util::GetStringUTF16(platform_string_id))); | 627 l10n_util::GetStringUTF16(platform_string_id))); |
| 621 } | 628 } |
| 622 #endif // defined(OS_MACOSX) || defined(OS_WIN) | 629 #endif // defined(OS_MACOSX) || defined(OS_WIN) |
| 623 | 630 |
| 624 // If no parameters were provided, use the defaults. | 631 // If no parameters were provided, use the defaults. |
| 625 if (!params) { | 632 if (!params) { |
| 626 params.reset(new ErrorPageParams()); | 633 params.reset(new ErrorPageParams()); |
| 627 params->suggest_reload = !!(options.suggestions & SUGGEST_RELOAD); | 634 params->suggest_reload = !!(options.suggestions & SUGGEST_RELOAD); |
| 628 } | 635 } |
| 629 | 636 |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 #if defined(OS_CHROMEOS) | 874 #if defined(OS_CHROMEOS) |
| 868 GURL learn_more_url(kAppWarningLearnMoreUrl); | 875 GURL learn_more_url(kAppWarningLearnMoreUrl); |
| 869 base::DictionaryValue* suggest_learn_more = new base::DictionaryValue(); | 876 base::DictionaryValue* suggest_learn_more = new base::DictionaryValue(); |
| 870 suggest_learn_more->SetString("msg", | 877 suggest_learn_more->SetString("msg", |
| 871 l10n_util::GetStringUTF16( | 878 l10n_util::GetStringUTF16( |
| 872 IDS_ERRORPAGES_SUGGESTION_LEARNMORE_BODY)); | 879 IDS_ERRORPAGES_SUGGESTION_LEARNMORE_BODY)); |
| 873 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec()); | 880 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec()); |
| 874 error_strings->Set("suggestionsLearnMore", suggest_learn_more); | 881 error_strings->Set("suggestionsLearnMore", suggest_learn_more); |
| 875 #endif // defined(OS_CHROMEOS) | 882 #endif // defined(OS_CHROMEOS) |
| 876 } | 883 } |
| OLD | NEW |