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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
32 #include "base/win/windows_version.h" | 32 #include "base/win/windows_version.h" |
33 #endif | 33 #endif |
34 | 34 |
35 #if defined(OS_CHROMEOS) | 35 #if defined(OS_CHROMEOS) |
36 #include "base/command_line.h" | 36 #include "base/command_line.h" |
37 #include "chrome/common/chrome_switches.h" | 37 #include "chrome/common/chrome_switches.h" |
38 #endif | 38 #endif |
39 | 39 |
40 using blink::WebURLError; | 40 using blink::WebURLError; |
| 41 using error_page::OfflinePageStatus; |
41 | 42 |
42 // Some error pages have no details. | 43 // Some error pages have no details. |
43 const unsigned int kErrorPagesNoDetails = 0; | 44 const unsigned int kErrorPagesNoDetails = 0; |
44 | 45 |
45 namespace { | 46 namespace { |
46 | 47 |
47 static const char kRedirectLoopLearnMoreUrl[] = | 48 static const char kRedirectLoopLearnMoreUrl[] = |
48 "https://support.google.com/chrome/answer/95626"; | 49 "https://support.google.com/chrome/answer/95626"; |
49 static const char kWeakDHKeyLearnMoreUrl[] = | 50 static const char kWeakDHKeyLearnMoreUrl[] = |
50 "https://support.google.com/chrome?p=dh_error"; | 51 "https://support.google.com/chrome?p=dh_error"; |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 } // namespace | 548 } // namespace |
548 | 549 |
549 const char LocalizedError::kHttpErrorDomain[] = "http"; | 550 const char LocalizedError::kHttpErrorDomain[] = "http"; |
550 | 551 |
551 void LocalizedError::GetStrings(int error_code, | 552 void LocalizedError::GetStrings(int error_code, |
552 const std::string& error_domain, | 553 const std::string& error_domain, |
553 const GURL& failed_url, | 554 const GURL& failed_url, |
554 bool is_post, | 555 bool is_post, |
555 bool stale_copy_in_cache, | 556 bool stale_copy_in_cache, |
556 bool can_show_network_diagnostics_dialog, | 557 bool can_show_network_diagnostics_dialog, |
557 bool has_offline_pages, | 558 OfflinePageStatus offline_page_status, |
558 const std::string& locale, | 559 const std::string& locale, |
559 const std::string& accept_languages, | 560 const std::string& accept_languages, |
560 scoped_ptr<error_page::ErrorPageParams> params, | 561 scoped_ptr<error_page::ErrorPageParams> params, |
561 base::DictionaryValue* error_strings) { | 562 base::DictionaryValue* error_strings) { |
562 webui::SetLoadTimeDataDefaults(locale, error_strings); | 563 webui::SetLoadTimeDataDefaults(locale, error_strings); |
563 | 564 |
564 // Grab the strings and settings that depend on the error type. Init | 565 // Grab the strings and settings that depend on the error type. Init |
565 // options with default values. | 566 // options with default values. |
566 LocalizedErrorMap options = { | 567 LocalizedErrorMap options = { |
567 0, | 568 0, |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
761 IDS_ERRORPAGES_BUTTON_SHOW_SAVED_COPY)); | 762 IDS_ERRORPAGES_BUTTON_SHOW_SAVED_COPY)); |
762 show_saved_copy_button->SetString( | 763 show_saved_copy_button->SetString( |
763 "title", | 764 "title", |
764 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_SHOW_SAVED_COPY_HELP)); | 765 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_SHOW_SAVED_COPY_HELP)); |
765 if (show_saved_copy_primary) | 766 if (show_saved_copy_primary) |
766 show_saved_copy_button->SetString("primary", "true"); | 767 show_saved_copy_button->SetString("primary", "true"); |
767 error_strings->Set("showSavedCopyButton", show_saved_copy_button); | 768 error_strings->Set("showSavedCopyButton", show_saved_copy_button); |
768 } | 769 } |
769 | 770 |
770 #if defined(OS_ANDROID) | 771 #if defined(OS_ANDROID) |
771 if (has_offline_pages) { | 772 // Offline button will not be provided when we want to show something in the |
772 base::DictionaryValue* show_saved_pages_button = new base::DictionaryValue; | 773 // cache. |
773 show_saved_pages_button->SetString( | 774 if (!show_saved_copy_visible) { |
774 "msg", | 775 if (offline_page_status == OfflinePageStatus::HAS_PAGE_COPY) { |
775 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_SHOW_SAVED_PAGES)); | 776 base::DictionaryValue* show_offline_copy_button = |
776 show_saved_pages_button->SetString( | 777 new base::DictionaryValue; |
777 "title", | 778 base::string16 button_text = |
778 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_SHOW_SAVED_PAGES)); | 779 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_SHOW_OFFLINE_COPY); |
779 error_strings->Set("showSavedPagesButton", show_saved_pages_button); | 780 show_offline_copy_button->SetString("msg", button_text); |
| 781 show_offline_copy_button->SetString("title", button_text); |
| 782 error_strings->Set("showOfflineCopyButton", show_offline_copy_button); |
| 783 } else if (offline_page_status == |
| 784 OfflinePageStatus::HAS_OTHER_PAGES_COPIES) { |
| 785 base::DictionaryValue* show_offline_pages_button = |
| 786 new base::DictionaryValue; |
| 787 base::string16 button_text = |
| 788 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_SHOW_OFFLINE_PAGES); |
| 789 show_offline_pages_button->SetString("msg", button_text); |
| 790 show_offline_pages_button->SetString("title", button_text); |
| 791 error_strings->Set("showOfflinePagesButton", show_offline_pages_button); |
| 792 } |
780 } | 793 } |
781 #endif | 794 #endif |
782 | 795 |
783 #if defined(OS_CHROMEOS) | 796 #if defined(OS_CHROMEOS) |
784 // ChromeOS has its own diagnostics extension, which doesn't rely on a | 797 // ChromeOS has its own diagnostics extension, which doesn't rely on a |
785 // browser-initiated dialog. | 798 // browser-initiated dialog. |
786 can_show_network_diagnostics_dialog = true; | 799 can_show_network_diagnostics_dialog = true; |
787 #endif | 800 #endif |
788 if (can_show_network_diagnostics_dialog && failed_url.is_valid() && | 801 if (can_show_network_diagnostics_dialog && failed_url.is_valid() && |
789 failed_url.SchemeIsHTTPOrHTTPS()) { | 802 failed_url.SchemeIsHTTPOrHTTPS()) { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 return l10n_util::GetStringUTF16(IDS_ERRORPAGES_DETAILS_UNKNOWN); | 939 return l10n_util::GetStringUTF16(IDS_ERRORPAGES_DETAILS_UNKNOWN); |
927 } | 940 } |
928 | 941 |
929 bool LocalizedError::HasStrings(const std::string& error_domain, | 942 bool LocalizedError::HasStrings(const std::string& error_domain, |
930 int error_code) { | 943 int error_code) { |
931 // Whether or not the there are strings for an error does not depend on | 944 // Whether or not the there are strings for an error does not depend on |
932 // whether or not the page was be generated by a POST, so just claim it was | 945 // whether or not the page was be generated by a POST, so just claim it was |
933 // not. | 946 // not. |
934 return LookupErrorMap(error_domain, error_code, /*is_post=*/false) != NULL; | 947 return LookupErrorMap(error_domain, error_code, /*is_post=*/false) != NULL; |
935 } | 948 } |
OLD | NEW |