| 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" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "chrome/common/net/net_error_info.h" | |
| 15 #include "chrome/grit/chromium_strings.h" | 14 #include "chrome/grit/chromium_strings.h" |
| 16 #include "chrome/grit/generated_resources.h" | 15 #include "chrome/grit/generated_resources.h" |
| 16 #include "components/error_page/common/error_page_params.h" |
| 17 #include "components/error_page/common/net_error_info.h" |
| 17 #include "extensions/common/constants.h" | 18 #include "extensions/common/constants.h" |
| 18 #include "extensions/common/extension_icon_set.h" | 19 #include "extensions/common/extension_icon_set.h" |
| 19 #include "extensions/common/manifest_handlers/icons_handler.h" | 20 #include "extensions/common/manifest_handlers/icons_handler.h" |
| 20 #include "net/base/escape.h" | 21 #include "net/base/escape.h" |
| 21 #include "net/base/net_errors.h" | 22 #include "net/base/net_errors.h" |
| 22 #include "net/base/net_util.h" | 23 #include "net/base/net_util.h" |
| 23 #include "third_party/WebKit/public/platform/WebURLError.h" | 24 #include "third_party/WebKit/public/platform/WebURLError.h" |
| 24 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
| 25 #include "ui/base/webui/web_ui_util.h" | 26 #include "ui/base/webui/web_ui_util.h" |
| 26 | 27 |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 error_domain == chrome_common_net::kDnsProbeErrorDomain)) | 493 error_domain == chrome_common_net::kDnsProbeErrorDomain)) |
| 493 return "icon-offline"; | 494 return "icon-offline"; |
| 494 | 495 |
| 495 return "icon-generic"; | 496 return "icon-generic"; |
| 496 } | 497 } |
| 497 | 498 |
| 498 } // namespace | 499 } // namespace |
| 499 | 500 |
| 500 const char LocalizedError::kHttpErrorDomain[] = "http"; | 501 const char LocalizedError::kHttpErrorDomain[] = "http"; |
| 501 | 502 |
| 502 LocalizedError::ErrorPageParams::ErrorPageParams() | |
| 503 : suggest_reload(false), | |
| 504 reload_tracking_id(-1), | |
| 505 search_tracking_id(-1) { | |
| 506 } | |
| 507 | |
| 508 LocalizedError::ErrorPageParams::~ErrorPageParams() { | |
| 509 } | |
| 510 | |
| 511 void LocalizedError::GetStrings(int error_code, | 503 void LocalizedError::GetStrings(int error_code, |
| 512 const std::string& error_domain, | 504 const std::string& error_domain, |
| 513 const GURL& failed_url, | 505 const GURL& failed_url, |
| 514 bool is_post, | 506 bool is_post, |
| 515 bool show_stale_load_button, | 507 bool show_stale_load_button, |
| 516 const std::string& locale, | 508 const std::string& locale, |
| 517 const std::string& accept_languages, | 509 const std::string& accept_languages, |
| 518 scoped_ptr<ErrorPageParams> params, | 510 scoped_ptr<error_page::ErrorPageParams> params, |
| 519 base::DictionaryValue* error_strings) { | 511 base::DictionaryValue* error_strings) { |
| 520 bool rtl = LocaleIsRTL(); | 512 bool rtl = LocaleIsRTL(); |
| 521 error_strings->SetString("textdirection", rtl ? "rtl" : "ltr"); | 513 error_strings->SetString("textdirection", rtl ? "rtl" : "ltr"); |
| 522 webui::SetFontAndTextDirection(error_strings); | 514 webui::SetFontAndTextDirection(error_strings); |
| 523 | 515 |
| 524 // Grab the strings and settings that depend on the error type. Init | 516 // Grab the strings and settings that depend on the error type. Init |
| 525 // options with default values. | 517 // options with default values. |
| 526 LocalizedErrorMap options = { | 518 LocalizedErrorMap options = { |
| 527 0, | 519 0, |
| 528 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, | 520 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 // Platform dependent portion of the summary section. | 625 // Platform dependent portion of the summary section. |
| 634 summary->SetString("msg", | 626 summary->SetString("msg", |
| 635 l10n_util::GetStringFUTF16( | 627 l10n_util::GetStringFUTF16( |
| 636 IDS_ERRORPAGES_SUMMARY_INTERNET_DISCONNECTED_INSTRUCTIONS_TEMPLATE, | 628 IDS_ERRORPAGES_SUMMARY_INTERNET_DISCONNECTED_INSTRUCTIONS_TEMPLATE, |
| 637 l10n_util::GetStringUTF16(platform_string_id))); | 629 l10n_util::GetStringUTF16(platform_string_id))); |
| 638 } | 630 } |
| 639 #endif // defined(OS_MACOSX) || defined(OS_WIN) | 631 #endif // defined(OS_MACOSX) || defined(OS_WIN) |
| 640 | 632 |
| 641 // If no parameters were provided, use the defaults. | 633 // If no parameters were provided, use the defaults. |
| 642 if (!params) { | 634 if (!params) { |
| 643 params.reset(new ErrorPageParams()); | 635 params.reset(new error_page::ErrorPageParams()); |
| 644 params->suggest_reload = !!(options.suggestions & SUGGEST_RELOAD); | 636 params->suggest_reload = !!(options.suggestions & SUGGEST_RELOAD); |
| 645 } | 637 } |
| 646 | 638 |
| 647 base::ListValue* suggestions = NULL; | 639 base::ListValue* suggestions = NULL; |
| 648 bool use_default_suggestions = true; | 640 bool use_default_suggestions = true; |
| 649 if (!params->override_suggestions) { | 641 if (!params->override_suggestions) { |
| 650 suggestions = new base::ListValue(); | 642 suggestions = new base::ListValue(); |
| 651 } else { | 643 } else { |
| 652 suggestions = params->override_suggestions.release(); | 644 suggestions = params->override_suggestions.release(); |
| 653 use_default_suggestions = false; | 645 use_default_suggestions = false; |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 887 #if defined(OS_CHROMEOS) | 879 #if defined(OS_CHROMEOS) |
| 888 GURL learn_more_url(kAppWarningLearnMoreUrl); | 880 GURL learn_more_url(kAppWarningLearnMoreUrl); |
| 889 base::DictionaryValue* suggest_learn_more = new base::DictionaryValue(); | 881 base::DictionaryValue* suggest_learn_more = new base::DictionaryValue(); |
| 890 suggest_learn_more->SetString("msg", | 882 suggest_learn_more->SetString("msg", |
| 891 l10n_util::GetStringUTF16( | 883 l10n_util::GetStringUTF16( |
| 892 IDS_ERRORPAGES_SUGGESTION_LEARNMORE_BODY)); | 884 IDS_ERRORPAGES_SUGGESTION_LEARNMORE_BODY)); |
| 893 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec()); | 885 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec()); |
| 894 error_strings->Set("suggestionsLearnMore", suggest_learn_more); | 886 error_strings->Set("suggestionsLearnMore", suggest_learn_more); |
| 895 #endif // defined(OS_CHROMEOS) | 887 #endif // defined(OS_CHROMEOS) |
| 896 } | 888 } |
| OLD | NEW |