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 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 LocalizedError::ErrorPageParams::ErrorPageParams() : suggest_reload(false) { | 486 LocalizedError::ErrorPageParams::ErrorPageParams() : suggest_reload(false) { |
487 } | 487 } |
488 | 488 |
489 LocalizedError::ErrorPageParams::~ErrorPageParams() { | 489 LocalizedError::ErrorPageParams::~ErrorPageParams() { |
490 } | 490 } |
491 | 491 |
492 void LocalizedError::GetStrings(int error_code, | 492 void LocalizedError::GetStrings(int error_code, |
493 const std::string& error_domain, | 493 const std::string& error_domain, |
494 const GURL& failed_url, | 494 const GURL& failed_url, |
495 bool is_post, | 495 bool is_post, |
496 bool stale_copy_in_cache, | 496 bool show_stale_load_button, |
497 const std::string& locale, | 497 const std::string& locale, |
498 const std::string& accept_languages, | 498 const std::string& accept_languages, |
499 scoped_ptr<ErrorPageParams> params, | 499 scoped_ptr<ErrorPageParams> params, |
500 base::DictionaryValue* error_strings) { | 500 base::DictionaryValue* error_strings) { |
501 bool rtl = LocaleIsRTL(); | 501 bool rtl = LocaleIsRTL(); |
502 error_strings->SetString("textdirection", rtl ? "rtl" : "ltr"); | 502 error_strings->SetString("textdirection", rtl ? "rtl" : "ltr"); |
503 | 503 |
504 // Grab the strings and settings that depend on the error type. Init | 504 // Grab the strings and settings that depend on the error type. Init |
505 // options with default values. | 505 // options with default values. |
506 LocalizedErrorMap options = { | 506 LocalizedErrorMap options = { |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 error_strings->SetString("searchHeader", | 634 error_strings->SetString("searchHeader", |
635 l10n_util::GetStringUTF16(IDS_ERRORPAGES_SUGGESTION_GOOGLE_SEARCH)); | 635 l10n_util::GetStringUTF16(IDS_ERRORPAGES_SUGGESTION_GOOGLE_SEARCH)); |
636 error_strings->SetString("searchUrl", params->search_url.spec()); | 636 error_strings->SetString("searchUrl", params->search_url.spec()); |
637 error_strings->SetString("searchTerms", params->search_terms); | 637 error_strings->SetString("searchTerms", params->search_terms); |
638 } | 638 } |
639 | 639 |
640 // Add the reload suggestion, if needed. | 640 // Add the reload suggestion, if needed. |
641 if (params->suggest_reload) { | 641 if (params->suggest_reload) { |
642 if (!is_post) { | 642 if (!is_post) { |
643 base::DictionaryValue* reload_button = new base::DictionaryValue; | 643 base::DictionaryValue* reload_button = new base::DictionaryValue; |
644 reload_button->SetString("msg", | 644 reload_button->SetString( |
645 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_RELOAD)); | 645 "msg", l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_RELOAD)); |
646 reload_button->SetString("reloadUrl", failed_url.spec()); | 646 reload_button->SetString("reloadUrl", failed_url.spec()); |
647 error_strings->Set("reload", reload_button); | 647 error_strings->Set("reloadButton", reload_button); |
648 } else { | 648 } else { |
649 // If the page was created by a post, it can't be reloaded in the same | 649 // If the page was created by a post, it can't be reloaded in the same |
650 // way, so just add a suggestion instead. | 650 // way, so just add a suggestion instead. |
651 // TODO(mmenke): Make the reload button bring up the repost confirmation | 651 // TODO(mmenke): Make the reload button bring up the repost confirmation |
652 // dialog for pages resulting from posts. | 652 // dialog for pages resulting from posts. |
653 base::DictionaryValue* suggest_reload_repost = new base::DictionaryValue; | 653 base::DictionaryValue* suggest_reload_repost = new base::DictionaryValue; |
654 suggest_reload_repost->SetString("header", | 654 suggest_reload_repost->SetString("header", |
655 l10n_util::GetStringUTF16( | 655 l10n_util::GetStringUTF16( |
656 IDS_ERRORPAGES_SUGGESTION_RELOAD_REPOST_HEADER)); | 656 IDS_ERRORPAGES_SUGGESTION_RELOAD_REPOST_HEADER)); |
657 suggest_reload_repost->SetString("body", | 657 suggest_reload_repost->SetString("body", |
658 l10n_util::GetStringUTF16( | 658 l10n_util::GetStringUTF16( |
659 IDS_ERRORPAGES_SUGGESTION_RELOAD_REPOST_BODY)); | 659 IDS_ERRORPAGES_SUGGESTION_RELOAD_REPOST_BODY)); |
660 // Add at the front, so it appears before other suggestions, in the case | 660 // Add at the front, so it appears before other suggestions, in the case |
661 // suggestions are being overridden by |params|. | 661 // suggestions are being overridden by |params|. |
662 suggestions->Insert(0, suggest_reload_repost); | 662 suggestions->Insert(0, suggest_reload_repost); |
663 } | 663 } |
664 } | 664 } |
665 | 665 |
666 // If not using the default suggestions, nothing else to do. | 666 // If not using the default suggestions, nothing else to do. |
667 if (!use_default_suggestions) | 667 if (!use_default_suggestions) |
668 return; | 668 return; |
669 | 669 |
670 error_strings->SetBoolean("staleCopyInCache", stale_copy_in_cache); | 670 if (show_stale_load_button) { |
| 671 base::DictionaryValue* stale_load_button = new base::DictionaryValue; |
| 672 stale_load_button->SetString( |
| 673 "msg", l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_LOAD_STALE)); |
| 674 stale_load_button->SetString( |
| 675 "title", |
| 676 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_LOAD_STALE_HELP)); |
| 677 error_strings->Set("staleLoadButton", stale_load_button); |
| 678 } |
671 | 679 |
672 #if defined(OS_CHROMEOS) | 680 #if defined(OS_CHROMEOS) |
673 error_strings->SetString( | 681 error_strings->SetString( |
674 "diagnose", l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_DIAGNOSE)); | 682 "diagnose", l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_DIAGNOSE)); |
675 #endif // defined(OS_CHROMEOS) | 683 #endif // defined(OS_CHROMEOS) |
676 | 684 |
677 if (options.suggestions & SUGGEST_CHECK_CONNECTION) { | 685 if (options.suggestions & SUGGEST_CHECK_CONNECTION) { |
678 base::DictionaryValue* suggest_check_connection = new base::DictionaryValue; | 686 base::DictionaryValue* suggest_check_connection = new base::DictionaryValue; |
679 suggest_check_connection->SetString("header", | 687 suggest_check_connection->SetString("header", |
680 l10n_util::GetStringUTF16( | 688 l10n_util::GetStringUTF16( |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 #if defined(OS_CHROMEOS) | 857 #if defined(OS_CHROMEOS) |
850 GURL learn_more_url(kAppWarningLearnMoreUrl); | 858 GURL learn_more_url(kAppWarningLearnMoreUrl); |
851 base::DictionaryValue* suggest_learn_more = new base::DictionaryValue(); | 859 base::DictionaryValue* suggest_learn_more = new base::DictionaryValue(); |
852 suggest_learn_more->SetString("msg", | 860 suggest_learn_more->SetString("msg", |
853 l10n_util::GetStringUTF16( | 861 l10n_util::GetStringUTF16( |
854 IDS_ERRORPAGES_SUGGESTION_LEARNMORE_BODY)); | 862 IDS_ERRORPAGES_SUGGESTION_LEARNMORE_BODY)); |
855 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec()); | 863 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec()); |
856 error_strings->Set("suggestionsLearnMore", suggest_learn_more); | 864 error_strings->Set("suggestionsLearnMore", suggest_learn_more); |
857 #endif // defined(OS_CHROMEOS) | 865 #endif // defined(OS_CHROMEOS) |
858 } | 866 } |
OLD | NEW |