Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: components/error_page/common/localized_error.cc

Issue 1841653003: Drop |languages| from {Format,Elide}Url* and IDNToUnicode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix typo in elide_url.cc Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 const char LocalizedError::kHttpErrorDomain[] = "http"; 838 const char LocalizedError::kHttpErrorDomain[] = "http";
839 839
840 void LocalizedError::GetStrings(int error_code, 840 void LocalizedError::GetStrings(int error_code,
841 const std::string& error_domain, 841 const std::string& error_domain,
842 const GURL& failed_url, 842 const GURL& failed_url,
843 bool is_post, 843 bool is_post,
844 bool stale_copy_in_cache, 844 bool stale_copy_in_cache,
845 bool can_show_network_diagnostics_dialog, 845 bool can_show_network_diagnostics_dialog,
846 bool has_offline_pages, 846 bool has_offline_pages,
847 const std::string& locale, 847 const std::string& locale,
848 const std::string& accept_languages,
849 scoped_ptr<error_page::ErrorPageParams> params, 848 scoped_ptr<error_page::ErrorPageParams> params,
850 base::DictionaryValue* error_strings) { 849 base::DictionaryValue* error_strings) {
851 webui::SetLoadTimeDataDefaults(locale, error_strings); 850 webui::SetLoadTimeDataDefaults(locale, error_strings);
852 851
853 // Grab the strings and settings that depend on the error type. Init 852 // Grab the strings and settings that depend on the error type. Init
854 // options with default values. 853 // options with default values.
855 LocalizedErrorMap options = { 854 LocalizedErrorMap options = {
856 0, 855 0,
857 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, 856 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
858 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE, 857 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE,
(...skipping 15 matching lines...) Expand all
874 error_code == net::ERR_ACCESS_DENIED && 873 error_code == net::ERR_ACCESS_DENIED &&
875 failed_url.scheme() == "file") { 874 failed_url.scheme() == "file") {
876 options.title_resource_id = IDS_ERRORPAGES_TITLE_ACCESS_DENIED; 875 options.title_resource_id = IDS_ERRORPAGES_TITLE_ACCESS_DENIED;
877 options.heading_resource_id = IDS_ERRORPAGES_HEADING_FILE_ACCESS_DENIED; 876 options.heading_resource_id = IDS_ERRORPAGES_HEADING_FILE_ACCESS_DENIED;
878 options.summary_resource_id = IDS_ERRORPAGES_SUMMARY_FILE_ACCESS_DENIED; 877 options.summary_resource_id = IDS_ERRORPAGES_SUMMARY_FILE_ACCESS_DENIED;
879 options.details_resource_id = IDS_ERRORPAGES_DETAILS_FILE_ACCESS_DENIED; 878 options.details_resource_id = IDS_ERRORPAGES_DETAILS_FILE_ACCESS_DENIED;
880 options.suggestions = SUGGEST_NONE; 879 options.suggestions = SUGGEST_NONE;
881 } 880 }
882 881
883 base::string16 failed_url_string(url_formatter::FormatUrl( 882 base::string16 failed_url_string(url_formatter::FormatUrl(
884 failed_url, accept_languages, url_formatter::kFormatUrlOmitNothing, 883 failed_url, url_formatter::kFormatUrlOmitNothing,
885 net::UnescapeRule::NORMAL, nullptr, nullptr, nullptr)); 884 net::UnescapeRule::NORMAL, nullptr, nullptr, nullptr));
886 // URLs are always LTR. 885 // URLs are always LTR.
887 if (base::i18n::IsRTL()) 886 if (base::i18n::IsRTL())
888 base::i18n::WrapStringWithLTRFormatting(&failed_url_string); 887 base::i18n::WrapStringWithLTRFormatting(&failed_url_string);
889 error_strings->SetString("title", 888 error_strings->SetString("title",
890 l10n_util::GetStringFUTF16(options.title_resource_id, failed_url_string)); 889 l10n_util::GetStringFUTF16(options.title_resource_id, failed_url_string));
891 std::string icon_class = GetIconClassForError(error_domain, error_code); 890 std::string icon_class = GetIconClassForError(error_domain, error_code);
892 error_strings->SetString("iconClass", icon_class); 891 error_strings->SetString("iconClass", icon_class);
893 892
894 base::string16 host_name(url_formatter::IDNToUnicode(failed_url.host(), 893 base::string16 host_name(url_formatter::IDNToUnicode(failed_url.host()));
895 accept_languages));
896 894
897 base::DictionaryValue* heading = new base::DictionaryValue; 895 base::DictionaryValue* heading = new base::DictionaryValue;
898 heading->SetString("msg", 896 heading->SetString("msg",
899 l10n_util::GetStringUTF16(options.heading_resource_id)); 897 l10n_util::GetStringUTF16(options.heading_resource_id));
900 heading->SetString("hostName", host_name); 898 heading->SetString("hostName", host_name);
901 error_strings->Set("heading", heading); 899 error_strings->Set("heading", heading);
902 900
903 base::DictionaryValue* summary = new base::DictionaryValue; 901 base::DictionaryValue* summary = new base::DictionaryValue;
904 902
905 // Set summary message under the heading. 903 // Set summary message under the heading.
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1099 1097
1100 bool LocalizedError::HasStrings(const std::string& error_domain, 1098 bool LocalizedError::HasStrings(const std::string& error_domain,
1101 int error_code) { 1099 int error_code) {
1102 // Whether or not the there are strings for an error does not depend on 1100 // Whether or not the there are strings for an error does not depend on
1103 // whether or not the page was be generated by a POST, so just claim it was 1101 // whether or not the page was be generated by a POST, so just claim it was
1104 // not. 1102 // not.
1105 return LookupErrorMap(error_domain, error_code, /*is_post=*/false) != nullptr; 1103 return LookupErrorMap(error_domain, error_code, /*is_post=*/false) != nullptr;
1106 } 1104 }
1107 1105
1108 } // namespace error_page 1106 } // namespace error_page
OLDNEW
« no previous file with comments | « components/error_page/common/localized_error.h ('k') | components/error_page/renderer/net_error_helper_core.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698