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