| 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 12 matching lines...) Expand all Loading... |
| 23 #include "components/error_page/common/error_page_params.h" | 23 #include "components/error_page/common/error_page_params.h" |
| 24 #include "components/error_page/common/error_page_switches.h" | 24 #include "components/error_page/common/error_page_switches.h" |
| 25 #include "components/error_page/common/net_error_info.h" | 25 #include "components/error_page/common/net_error_info.h" |
| 26 #include "components/strings/grit/components_chromium_strings.h" | 26 #include "components/strings/grit/components_chromium_strings.h" |
| 27 #include "components/strings/grit/components_strings.h" | 27 #include "components/strings/grit/components_strings.h" |
| 28 #include "components/url_formatter/url_formatter.h" | 28 #include "components/url_formatter/url_formatter.h" |
| 29 #include "net/base/escape.h" | 29 #include "net/base/escape.h" |
| 30 #include "net/base/net_errors.h" | 30 #include "net/base/net_errors.h" |
| 31 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
| 32 #include "ui/base/webui/web_ui_util.h" | 32 #include "ui/base/webui/web_ui_util.h" |
| 33 #include "url/origin.h" |
| 33 | 34 |
| 34 #if defined(OS_WIN) | 35 #if defined(OS_WIN) |
| 35 #include "base/win/windows_version.h" | 36 #include "base/win/windows_version.h" |
| 36 #endif | 37 #endif |
| 37 | 38 |
| 38 #if defined(OS_ANDROID) | 39 #if defined(OS_ANDROID) |
| 39 #include "components/offline_pages/offline_page_feature.h" | 40 #include "components/offline_pages/offline_page_feature.h" |
| 40 #endif | 41 #endif |
| 41 | 42 |
| 42 namespace error_page { | 43 namespace error_page { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 58 SUGGEST_PROXY_CONFIG = 1 << 4, | 59 SUGGEST_PROXY_CONFIG = 1 << 4, |
| 59 SUGGEST_DISABLE_EXTENSION = 1 << 5, | 60 SUGGEST_DISABLE_EXTENSION = 1 << 5, |
| 60 SUGGEST_LEARNMORE = 1 << 6, | 61 SUGGEST_LEARNMORE = 1 << 6, |
| 61 SUGGEST_CONTACT_ADMINISTRATOR = 1 << 7, | 62 SUGGEST_CONTACT_ADMINISTRATOR = 1 << 7, |
| 62 SUGGEST_UNSUPPORTED_CIPHER = 1 << 8, | 63 SUGGEST_UNSUPPORTED_CIPHER = 1 << 8, |
| 63 SUGGEST_ANTIVIRUS_CONFIG = 1 << 9, | 64 SUGGEST_ANTIVIRUS_CONFIG = 1 << 9, |
| 64 SUGGEST_OFFLINE_CHECKS = 1 << 10, | 65 SUGGEST_OFFLINE_CHECKS = 1 << 10, |
| 65 SUGGEST_COMPLETE_SETUP = 1 << 11, | 66 SUGGEST_COMPLETE_SETUP = 1 << 11, |
| 66 // Reload page suggestion for pages created by a post. | 67 // Reload page suggestion for pages created by a post. |
| 67 SUGGEST_REPOST_RELOAD = 1 << 12, | 68 SUGGEST_REPOST_RELOAD = 1 << 12, |
| 69 SUGGEST_NAVIGATE_TO_ORIGIN = 1 << 13, |
| 68 }; | 70 }; |
| 69 | 71 |
| 70 enum SHOW_BUTTONS { | 72 enum SHOW_BUTTONS { |
| 71 SHOW_NO_BUTTONS = 0, | 73 SHOW_NO_BUTTONS = 0, |
| 72 SHOW_BUTTON_RELOAD = 1, | 74 SHOW_BUTTON_RELOAD = 1, |
| 73 }; | 75 }; |
| 74 | 76 |
| 75 struct LocalizedErrorMap { | 77 struct LocalizedErrorMap { |
| 76 int error_code; | 78 int error_code; |
| 77 unsigned int heading_resource_id; | 79 unsigned int heading_resource_id; |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 IDS_ERRORPAGES_SUMMARY_NOT_AVAILABLE, | 264 IDS_ERRORPAGES_SUMMARY_NOT_AVAILABLE, |
| 263 SUGGEST_DISABLE_EXTENSION, | 265 SUGGEST_DISABLE_EXTENSION, |
| 264 SHOW_NO_BUTTONS, | 266 SHOW_NO_BUTTONS, |
| 265 }, | 267 }, |
| 266 {net::ERR_BLOCKED_BY_CLIENT, | 268 {net::ERR_BLOCKED_BY_CLIENT, |
| 267 IDS_ERRORPAGES_HEADING_BLOCKED, | 269 IDS_ERRORPAGES_HEADING_BLOCKED, |
| 268 IDS_ERRORPAGES_SUMMARY_BLOCKED_BY_EXTENSION, | 270 IDS_ERRORPAGES_SUMMARY_BLOCKED_BY_EXTENSION, |
| 269 SUGGEST_DISABLE_EXTENSION, | 271 SUGGEST_DISABLE_EXTENSION, |
| 270 SHOW_BUTTON_RELOAD, | 272 SHOW_BUTTON_RELOAD, |
| 271 }, | 273 }, |
| 274 {net::ERR_BLOCKED_BY_XSS_AUDITOR, |
| 275 IDS_ERRORPAGES_HEADING_PAGE_NOT_WORKING, |
| 276 IDS_ERRORPAGES_SUMMARY_BLOCKED_BY_XSS_AUDITOR, |
| 277 SUGGEST_NAVIGATE_TO_ORIGIN, |
| 278 SHOW_NO_BUTTONS, |
| 279 }, |
| 272 {net::ERR_NETWORK_CHANGED, | 280 {net::ERR_NETWORK_CHANGED, |
| 273 IDS_ERRORPAGES_HEADING_CONNECTION_INTERRUPTED, | 281 IDS_ERRORPAGES_HEADING_CONNECTION_INTERRUPTED, |
| 274 IDS_ERRORPAGES_SUMMARY_NETWORK_CHANGED, | 282 IDS_ERRORPAGES_SUMMARY_NETWORK_CHANGED, |
| 275 SUGGEST_NONE, | 283 SUGGEST_NONE, |
| 276 SHOW_BUTTON_RELOAD, | 284 SHOW_BUTTON_RELOAD, |
| 277 }, | 285 }, |
| 278 {net::ERR_BLOCKED_BY_ADMINISTRATOR, | 286 {net::ERR_BLOCKED_BY_ADMINISTRATOR, |
| 279 IDS_ERRORPAGES_HEADING_BLOCKED, | 287 IDS_ERRORPAGES_HEADING_BLOCKED, |
| 280 IDS_ERRORPAGES_SUMMARY_BLOCKED_BY_ADMINISTRATOR, | 288 IDS_ERRORPAGES_SUMMARY_BLOCKED_BY_ADMINISTRATOR, |
| 281 SUGGEST_CONTACT_ADMINISTRATOR, | 289 SUGGEST_CONTACT_ADMINISTRATOR, |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 // If the page was created by a post, it can't be reloaded in the same | 615 // If the page was created by a post, it can't be reloaded in the same |
| 608 // way, so just add a suggestion instead. | 616 // way, so just add a suggestion instead. |
| 609 // TODO(mmenke): Make the reload button bring up the repost confirmation | 617 // TODO(mmenke): Make the reload button bring up the repost confirmation |
| 610 // dialog for pages resulting from posts. | 618 // dialog for pages resulting from posts. |
| 611 AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", | 619 AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", |
| 612 IDS_ERRORPAGES_SUGGESTION_RELOAD_REPOST_SUMMARY, false); | 620 IDS_ERRORPAGES_SUGGESTION_RELOAD_REPOST_SUMMARY, false); |
| 613 return; | 621 return; |
| 614 } | 622 } |
| 615 DCHECK(!IsSuggested(suggestions, SUGGEST_REPOST_RELOAD)); | 623 DCHECK(!IsSuggested(suggestions, SUGGEST_REPOST_RELOAD)); |
| 616 | 624 |
| 625 if (IsOnlySuggestion(suggestions, SUGGEST_NAVIGATE_TO_ORIGIN)) { |
| 626 DCHECK(suggestions_summary_list->empty()); |
| 627 DCHECK(!(suggestions & ~SUGGEST_NAVIGATE_TO_ORIGIN)); |
| 628 url::Origin failed_origin(failed_url); |
| 629 if (failed_origin.unique()) |
| 630 return; |
| 631 |
| 632 auto suggestion = base::MakeUnique<base::DictionaryValue>(); |
| 633 suggestion->SetString("summary", |
| 634 l10n_util::GetStringUTF16( |
| 635 IDS_ERRORPAGES_SUGGESTION_NAVIGATE_TO_ORIGIN)); |
| 636 suggestion->SetString("originURL", failed_origin.Serialize()); |
| 637 suggestions_summary_list->Append(std::move(suggestion)); |
| 638 return; |
| 639 } |
| 640 DCHECK(!IsSuggested(suggestions, SUGGEST_NAVIGATE_TO_ORIGIN)); |
| 641 |
| 617 if (IsOnlySuggestion(suggestions, SUGGEST_LEARNMORE)) { | 642 if (IsOnlySuggestion(suggestions, SUGGEST_LEARNMORE)) { |
| 618 DCHECK(suggestions_summary_list->empty()); | 643 DCHECK(suggestions_summary_list->empty()); |
| 619 AddLinkedSuggestionToList(error_code, locale, suggestions_summary_list, | 644 AddLinkedSuggestionToList(error_code, locale, suggestions_summary_list, |
| 620 true); | 645 true); |
| 621 return; | 646 return; |
| 622 } | 647 } |
| 623 if (IsSuggested(suggestions, SUGGEST_LEARNMORE)) { | 648 if (IsSuggested(suggestions, SUGGEST_LEARNMORE)) { |
| 624 AddLinkedSuggestionToList(error_code, locale, suggestions_summary_list, | 649 AddLinkedSuggestionToList(error_code, locale, suggestions_summary_list, |
| 625 false); | 650 false); |
| 626 } | 651 } |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1027 | 1052 |
| 1028 bool LocalizedError::HasStrings(const std::string& error_domain, | 1053 bool LocalizedError::HasStrings(const std::string& error_domain, |
| 1029 int error_code) { | 1054 int error_code) { |
| 1030 // Whether or not the there are strings for an error does not depend on | 1055 // Whether or not the there are strings for an error does not depend on |
| 1031 // whether or not the page was be generated by a POST, so just claim it was | 1056 // whether or not the page was be generated by a POST, so just claim it was |
| 1032 // not. | 1057 // not. |
| 1033 return LookupErrorMap(error_domain, error_code, /*is_post=*/false) != nullptr; | 1058 return LookupErrorMap(error_domain, error_code, /*is_post=*/false) != nullptr; |
| 1034 } | 1059 } |
| 1035 | 1060 |
| 1036 } // namespace error_page | 1061 } // namespace error_page |
| OLD | NEW |