| 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 "components/error_page/common/localized_error.h" | 5 #include "components/error_page/common/localized_error.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| (...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 } // namespace | 832 } // namespace |
| 833 | 833 |
| 834 const char LocalizedError::kHttpErrorDomain[] = "http"; | 834 const char LocalizedError::kHttpErrorDomain[] = "http"; |
| 835 | 835 |
| 836 void LocalizedError::GetStrings(int error_code, | 836 void LocalizedError::GetStrings(int error_code, |
| 837 const std::string& error_domain, | 837 const std::string& error_domain, |
| 838 const GURL& failed_url, | 838 const GURL& failed_url, |
| 839 bool is_post, | 839 bool is_post, |
| 840 bool stale_copy_in_cache, | 840 bool stale_copy_in_cache, |
| 841 bool can_show_network_diagnostics_dialog, | 841 bool can_show_network_diagnostics_dialog, |
| 842 OfflinePageStatus offline_page_status, | 842 bool has_offline_pages, |
| 843 const std::string& locale, | 843 const std::string& locale, |
| 844 const std::string& accept_languages, | 844 const std::string& accept_languages, |
| 845 scoped_ptr<error_page::ErrorPageParams> params, | 845 scoped_ptr<error_page::ErrorPageParams> params, |
| 846 base::DictionaryValue* error_strings) { | 846 base::DictionaryValue* error_strings) { |
| 847 webui::SetLoadTimeDataDefaults(locale, error_strings); | 847 webui::SetLoadTimeDataDefaults(locale, error_strings); |
| 848 | 848 |
| 849 // Grab the strings and settings that depend on the error type. Init | 849 // Grab the strings and settings that depend on the error type. Init |
| 850 // options with default values. | 850 // options with default values. |
| 851 LocalizedErrorMap options = { | 851 LocalizedErrorMap options = { |
| 852 0, | 852 0, |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1050 "title", | 1050 "title", |
| 1051 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_SHOW_SAVED_COPY_HELP)); | 1051 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_SHOW_SAVED_COPY_HELP)); |
| 1052 if (show_saved_copy_primary) | 1052 if (show_saved_copy_primary) |
| 1053 show_saved_copy_button->SetString("primary", "true"); | 1053 show_saved_copy_button->SetString("primary", "true"); |
| 1054 error_strings->Set("showSavedCopyButton", show_saved_copy_button); | 1054 error_strings->Set("showSavedCopyButton", show_saved_copy_button); |
| 1055 } | 1055 } |
| 1056 | 1056 |
| 1057 #if defined(OS_ANDROID) | 1057 #if defined(OS_ANDROID) |
| 1058 // Offline button will not be provided when we want to show something in the | 1058 // Offline button will not be provided when we want to show something in the |
| 1059 // cache. | 1059 // cache. |
| 1060 if (!show_saved_copy_visible) { | 1060 if (!show_saved_copy_visible && has_offline_pages) { |
| 1061 if (offline_page_status == OfflinePageStatus::HAS_OFFLINE_PAGE) { | 1061 base::DictionaryValue* show_offline_pages_button = |
| 1062 base::DictionaryValue* show_offline_copy_button = | 1062 new base::DictionaryValue; |
| 1063 new base::DictionaryValue; | 1063 base::string16 button_text = l10n_util::GetStringUTF16( |
| 1064 base::string16 button_text = | 1064 offline_pages::GetOfflinePageFeatureMode() == |
| 1065 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_SHOW_OFFLINE_COPY); | 1065 offline_pages::FeatureMode::ENABLED_AS_BOOKMARKS |
| 1066 show_offline_copy_button->SetString("msg", button_text); | 1066 ? IDS_ERRORPAGES_BUTTON_SHOW_OFFLINE_PAGES_AS_BOOKMARKS |
| 1067 error_strings->Set("showOfflineCopyButton", show_offline_copy_button); | 1067 : IDS_ERRORPAGES_BUTTON_SHOW_OFFLINE_PAGES); |
| 1068 } else if (offline_page_status == | 1068 show_offline_pages_button->SetString("msg", button_text); |
| 1069 OfflinePageStatus::HAS_OTHER_OFFLINE_PAGES) { | 1069 error_strings->Set("showOfflinePagesButton", show_offline_pages_button); |
| 1070 base::DictionaryValue* show_offline_pages_button = | |
| 1071 new base::DictionaryValue; | |
| 1072 base::string16 button_text = l10n_util::GetStringUTF16( | |
| 1073 offline_pages::GetOfflinePageFeatureMode() == | |
| 1074 offline_pages::FeatureMode::ENABLED_AS_BOOKMARKS | |
| 1075 ? IDS_ERRORPAGES_BUTTON_SHOW_OFFLINE_PAGES_AS_BOOKMARKS | |
| 1076 : IDS_ERRORPAGES_BUTTON_SHOW_OFFLINE_PAGES); | |
| 1077 show_offline_pages_button->SetString("msg", button_text); | |
| 1078 error_strings->Set("showOfflinePagesButton", show_offline_pages_button); | |
| 1079 } | |
| 1080 } | 1070 } |
| 1081 #endif // defined(OS_ANDROID) | 1071 #endif // defined(OS_ANDROID) |
| 1082 | 1072 |
| 1083 #if defined(OS_CHROMEOS) | 1073 #if defined(OS_CHROMEOS) |
| 1084 // ChromeOS has its own diagnostics extension, which doesn't rely on a | 1074 // ChromeOS has its own diagnostics extension, which doesn't rely on a |
| 1085 // browser-initiated dialog. | 1075 // browser-initiated dialog. |
| 1086 can_show_network_diagnostics_dialog = true; | 1076 can_show_network_diagnostics_dialog = true; |
| 1087 #endif | 1077 #endif |
| 1088 if (can_show_network_diagnostics_dialog && failed_url.is_valid() && | 1078 if (can_show_network_diagnostics_dialog && failed_url.is_valid() && |
| 1089 failed_url.SchemeIsHTTPOrHTTPS()) { | 1079 failed_url.SchemeIsHTTPOrHTTPS()) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1105 | 1095 |
| 1106 bool LocalizedError::HasStrings(const std::string& error_domain, | 1096 bool LocalizedError::HasStrings(const std::string& error_domain, |
| 1107 int error_code) { | 1097 int error_code) { |
| 1108 // Whether or not the there are strings for an error does not depend on | 1098 // Whether or not the there are strings for an error does not depend on |
| 1109 // whether or not the page was be generated by a POST, so just claim it was | 1099 // whether or not the page was be generated by a POST, so just claim it was |
| 1110 // not. | 1100 // not. |
| 1111 return LookupErrorMap(error_domain, error_code, /*is_post=*/false) != nullptr; | 1101 return LookupErrorMap(error_domain, error_code, /*is_post=*/false) != nullptr; |
| 1112 } | 1102 } |
| 1113 | 1103 |
| 1114 } // namespace error_page | 1104 } // namespace error_page |
| OLD | NEW |