| 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 <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 search_suggestion->SetString("searchUrl", params->search_url.spec() + | 963 search_suggestion->SetString("searchUrl", params->search_url.spec() + |
| 964 params->search_terms); | 964 params->search_terms); |
| 965 search_suggestion->SetString("searchTerms", params->search_terms); | 965 search_suggestion->SetString("searchTerms", params->search_terms); |
| 966 search_suggestion->SetInteger("trackingId", | 966 search_suggestion->SetInteger("trackingId", |
| 967 params->search_tracking_id); | 967 params->search_tracking_id); |
| 968 suggestions_summary_list->Append(std::move(search_suggestion)); | 968 suggestions_summary_list->Append(std::move(search_suggestion)); |
| 969 } | 969 } |
| 970 | 970 |
| 971 // Add the reload suggestion, if needed for pages that didn't come | 971 // Add the reload suggestion, if needed for pages that didn't come |
| 972 // from a post. | 972 // from a post. |
| 973 #if defined(OS_ANDROID) |
| 974 bool reload_visible = false; |
| 975 #endif // defined(OS_ANDROID) |
| 973 if (params->suggest_reload && !is_post) { | 976 if (params->suggest_reload && !is_post) { |
| 977 #if defined(OS_ANDROID) |
| 978 reload_visible = true; |
| 979 #endif // defined(OS_ANDROID) |
| 974 base::DictionaryValue* reload_button = new base::DictionaryValue; | 980 base::DictionaryValue* reload_button = new base::DictionaryValue; |
| 975 reload_button->SetString( | 981 reload_button->SetString( |
| 976 "msg", l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_RELOAD)); | 982 "msg", l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_RELOAD)); |
| 977 reload_button->SetString("reloadUrl", failed_url.spec()); | 983 reload_button->SetString("reloadUrl", failed_url.spec()); |
| 978 error_strings->Set("reloadButton", reload_button); | 984 error_strings->Set("reloadButton", reload_button); |
| 979 reload_button->SetInteger("reloadTrackingId", params->reload_tracking_id); | 985 reload_button->SetInteger("reloadTrackingId", params->reload_tracking_id); |
| 980 } | 986 } |
| 981 | 987 |
| 982 // If not using the default suggestions, nothing else to do. | 988 // If not using the default suggestions, nothing else to do. |
| 983 if (!use_default_suggestions) | 989 if (!use_default_suggestions) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1016 IDS_ERRORPAGES_BUTTON_SHOW_SAVED_COPY)); | 1022 IDS_ERRORPAGES_BUTTON_SHOW_SAVED_COPY)); |
| 1017 show_saved_copy_button->SetString( | 1023 show_saved_copy_button->SetString( |
| 1018 "title", | 1024 "title", |
| 1019 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_SHOW_SAVED_COPY_HELP)); | 1025 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_SHOW_SAVED_COPY_HELP)); |
| 1020 if (show_saved_copy_primary) | 1026 if (show_saved_copy_primary) |
| 1021 show_saved_copy_button->SetString("primary", "true"); | 1027 show_saved_copy_button->SetString("primary", "true"); |
| 1022 error_strings->Set("showSavedCopyButton", show_saved_copy_button); | 1028 error_strings->Set("showSavedCopyButton", show_saved_copy_button); |
| 1023 } | 1029 } |
| 1024 | 1030 |
| 1025 #if defined(OS_ANDROID) | 1031 #if defined(OS_ANDROID) |
| 1026 if (!show_saved_copy_visible && !is_incognito && | 1032 if (!reload_visible && !show_saved_copy_visible && !is_incognito && |
| 1027 failed_url.SchemeIsHTTPOrHTTPS() && | 1033 failed_url.is_valid() && failed_url.SchemeIsHTTPOrHTTPS() && |
| 1028 offline_pages::IsOfflinePagesAsyncDownloadEnabled()) { | 1034 offline_pages::IsOfflinePagesAsyncDownloadEnabled()) { |
| 1029 std::unique_ptr<base::DictionaryValue> download_button = | 1035 std::unique_ptr<base::DictionaryValue> download_button = |
| 1030 base::MakeUnique<base::DictionaryValue>(); | 1036 base::MakeUnique<base::DictionaryValue>(); |
| 1031 download_button->SetString( | 1037 download_button->SetString( |
| 1032 "msg", | 1038 "msg", |
| 1033 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_DOWNLOAD)); | 1039 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_DOWNLOAD)); |
| 1034 download_button->SetString( | 1040 download_button->SetString( |
| 1035 "disabledMsg", | 1041 "disabledMsg", |
| 1036 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_DOWNLOADING)); | 1042 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_DOWNLOADING)); |
| 1037 error_strings->Set("downloadButton", std::move(download_button)); | 1043 error_strings->Set("downloadButton", std::move(download_button)); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1052 | 1058 |
| 1053 bool LocalizedError::HasStrings(const std::string& error_domain, | 1059 bool LocalizedError::HasStrings(const std::string& error_domain, |
| 1054 int error_code) { | 1060 int error_code) { |
| 1055 // Whether or not the there are strings for an error does not depend on | 1061 // Whether or not the there are strings for an error does not depend on |
| 1056 // whether or not the page was be generated by a POST, so just claim it was | 1062 // whether or not the page was be generated by a POST, so just claim it was |
| 1057 // not. | 1063 // not. |
| 1058 return LookupErrorMap(error_domain, error_code, /*is_post=*/false) != nullptr; | 1064 return LookupErrorMap(error_domain, error_code, /*is_post=*/false) != nullptr; |
| 1059 } | 1065 } |
| 1060 | 1066 |
| 1061 } // namespace error_page | 1067 } // namespace error_page |
| OLD | NEW |