| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/renderer/localized_error.h" | 5 #include "chrome/renderer/localized_error.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/i18n/rtl.h" |
| 8 #include "base/logging.h" | 9 #include "base/logging.h" |
| 9 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 10 #include "base/values.h" | 11 #include "base/values.h" |
| 11 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
| 12 #include "grit/generated_resources.h" | 13 #include "grit/generated_resources.h" |
| 13 #include "net/base/escape.h" | 14 #include "net/base/escape.h" |
| 14 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
| 15 #include "third_party/WebKit/WebKit/chromium/public/WebURLError.h" | 16 #include "third_party/WebKit/WebKit/chromium/public/WebURLError.h" |
| 16 #include "webkit/glue/webkit_glue.h" | 17 #include "webkit/glue/webkit_glue.h" |
| 17 | 18 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 IDS_ERRORPAGES_TITLE_LOAD_FAILED, | 100 IDS_ERRORPAGES_TITLE_LOAD_FAILED, |
| 100 IDS_ERRORPAGES_HEADING_BAD_SSL_CLIENT_AUTH_CERT, | 101 IDS_ERRORPAGES_HEADING_BAD_SSL_CLIENT_AUTH_CERT, |
| 101 IDS_ERRORPAGES_SUMMARY_BAD_SSL_CLIENT_AUTH_CERT, | 102 IDS_ERRORPAGES_SUMMARY_BAD_SSL_CLIENT_AUTH_CERT, |
| 102 IDS_ERRORPAGES_DETAILS_BAD_SSL_CLIENT_AUTH_CERT, | 103 IDS_ERRORPAGES_DETAILS_BAD_SSL_CLIENT_AUTH_CERT, |
| 103 SUGGEST_NONE, | 104 SUGGEST_NONE, |
| 104 }, | 105 }, |
| 105 }; | 106 }; |
| 106 | 107 |
| 107 bool LocaleIsRTL() { | 108 bool LocaleIsRTL() { |
| 108 #if defined(TOOLKIT_GTK) | 109 #if defined(TOOLKIT_GTK) |
| 109 // l10n_util::GetTextDirection uses the GTK text direction, which doesn't work | 110 // base::i18n::GetTextDirection uses the GTK text direction, which doesn't wor
k |
| 110 // within the renderer sandbox. | 111 // within the renderer sandbox. |
| 111 return l10n_util::GetICUTextDirection() == l10n_util::RIGHT_TO_LEFT; | 112 return base::i18n::GetICUTextDirection() == base::i18n::RIGHT_TO_LEFT; |
| 112 #else | 113 #else |
| 113 return l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT; | 114 return base::i18n::IsRTL(); |
| 114 #endif | 115 #endif |
| 115 } | 116 } |
| 116 | 117 |
| 117 } // namespace | 118 } // namespace |
| 118 | 119 |
| 119 void GetLocalizedErrorValues(const WebURLError& error, | 120 void GetLocalizedErrorValues(const WebURLError& error, |
| 120 DictionaryValue* error_strings) { | 121 DictionaryValue* error_strings) { |
| 121 bool rtl = LocaleIsRTL(); | 122 bool rtl = LocaleIsRTL(); |
| 122 error_strings->SetString(L"textdirection", rtl ? L"rtl" : L"ltr"); | 123 error_strings->SetString(L"textdirection", rtl ? L"rtl" : L"ltr"); |
| 123 | 124 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 149 if (options.suggestions != SUGGEST_NONE) { | 150 if (options.suggestions != SUGGEST_NONE) { |
| 150 suggestions_heading = | 151 suggestions_heading = |
| 151 l10n_util::GetString(IDS_ERRORPAGES_SUGGESTION_HEADING); | 152 l10n_util::GetString(IDS_ERRORPAGES_SUGGESTION_HEADING); |
| 152 } | 153 } |
| 153 error_strings->SetString(L"suggestionsHeading", suggestions_heading); | 154 error_strings->SetString(L"suggestionsHeading", suggestions_heading); |
| 154 | 155 |
| 155 std::wstring failed_url( | 156 std::wstring failed_url( |
| 156 ASCIIToWide(std::string(error.unreachableURL.spec()))); | 157 ASCIIToWide(std::string(error.unreachableURL.spec()))); |
| 157 // URLs are always LTR. | 158 // URLs are always LTR. |
| 158 if (rtl) | 159 if (rtl) |
| 159 l10n_util::WrapStringWithLTRFormatting(&failed_url); | 160 base::i18n::WrapStringWithLTRFormatting(&failed_url); |
| 160 error_strings->SetString(L"title", | 161 error_strings->SetString(L"title", |
| 161 l10n_util::GetStringF(options.title_resource_id, | 162 l10n_util::GetStringF(options.title_resource_id, |
| 162 failed_url)); | 163 failed_url)); |
| 163 error_strings->SetString(L"heading", | 164 error_strings->SetString(L"heading", |
| 164 l10n_util::GetString(options.heading_resource_id)); | 165 l10n_util::GetString(options.heading_resource_id)); |
| 165 | 166 |
| 166 DictionaryValue* summary = new DictionaryValue; | 167 DictionaryValue* summary = new DictionaryValue; |
| 167 summary->SetString(L"msg", | 168 summary->SetString(L"msg", |
| 168 l10n_util::GetString(options.summary_resource_id)); | 169 l10n_util::GetString(options.summary_resource_id)); |
| 169 // TODO(tc): we want the unicode url here since it's being displayed | 170 // TODO(tc): we want the unicode url here since it's being displayed |
| (...skipping 20 matching lines...) Expand all Loading... |
| 190 if (options.suggestions & SUGGEST_HOSTNAME) { | 191 if (options.suggestions & SUGGEST_HOSTNAME) { |
| 191 // Only show the "Go to hostname" suggestion if the failed_url has a path. | 192 // Only show the "Go to hostname" suggestion if the failed_url has a path. |
| 192 const GURL& failed_url = error.unreachableURL; | 193 const GURL& failed_url = error.unreachableURL; |
| 193 if (std::string() == failed_url.path()) { | 194 if (std::string() == failed_url.path()) { |
| 194 DictionaryValue* suggest_home_page = new DictionaryValue; | 195 DictionaryValue* suggest_home_page = new DictionaryValue; |
| 195 suggest_home_page->SetString(L"suggestionsHomepageMsg", | 196 suggest_home_page->SetString(L"suggestionsHomepageMsg", |
| 196 l10n_util::GetString(IDS_ERRORPAGES_SUGGESTION_HOMEPAGE)); | 197 l10n_util::GetString(IDS_ERRORPAGES_SUGGESTION_HOMEPAGE)); |
| 197 std::wstring homepage(ASCIIToWide(failed_url.GetWithEmptyPath().spec())); | 198 std::wstring homepage(ASCIIToWide(failed_url.GetWithEmptyPath().spec())); |
| 198 // URLs are always LTR. | 199 // URLs are always LTR. |
| 199 if (rtl) | 200 if (rtl) |
| 200 l10n_util::WrapStringWithLTRFormatting(&homepage); | 201 base::i18n::WrapStringWithLTRFormatting(&homepage); |
| 201 suggest_home_page->SetString(L"homePage", homepage); | 202 suggest_home_page->SetString(L"homePage", homepage); |
| 202 // TODO(tc): we actually want the unicode hostname | 203 // TODO(tc): we actually want the unicode hostname |
| 203 suggest_home_page->SetString(L"hostName", | 204 suggest_home_page->SetString(L"hostName", |
| 204 ASCIIToWide(failed_url.host())); | 205 ASCIIToWide(failed_url.host())); |
| 205 error_strings->Set(L"suggestionsHomepage", suggest_home_page); | 206 error_strings->Set(L"suggestionsHomepage", suggest_home_page); |
| 206 } | 207 } |
| 207 } | 208 } |
| 208 | 209 |
| 209 if (options.suggestions & SUGGEST_LEARNMORE) { | 210 if (options.suggestions & SUGGEST_LEARNMORE) { |
| 210 GURL learn_more_url; | 211 GURL learn_more_url; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 235 } | 236 } |
| 236 | 237 |
| 237 void GetFormRepostErrorValues(const GURL& display_url, | 238 void GetFormRepostErrorValues(const GURL& display_url, |
| 238 DictionaryValue* error_strings) { | 239 DictionaryValue* error_strings) { |
| 239 bool rtl = LocaleIsRTL(); | 240 bool rtl = LocaleIsRTL(); |
| 240 error_strings->SetString(L"textdirection", rtl ? L"rtl" : L"ltr"); | 241 error_strings->SetString(L"textdirection", rtl ? L"rtl" : L"ltr"); |
| 241 | 242 |
| 242 std::wstring failed_url(ASCIIToWide(display_url.spec())); | 243 std::wstring failed_url(ASCIIToWide(display_url.spec())); |
| 243 // URLs are always LTR. | 244 // URLs are always LTR. |
| 244 if (rtl) | 245 if (rtl) |
| 245 l10n_util::WrapStringWithLTRFormatting(&failed_url); | 246 base::i18n::WrapStringWithLTRFormatting(&failed_url); |
| 246 error_strings->SetString( | 247 error_strings->SetString( |
| 247 L"title", l10n_util::GetStringF(IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, | 248 L"title", l10n_util::GetStringF(IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, |
| 248 failed_url.c_str())); | 249 failed_url.c_str())); |
| 249 error_strings->SetString(L"heading", | 250 error_strings->SetString(L"heading", |
| 250 l10n_util::GetString(IDS_HTTP_POST_WARNING_TITLE)); | 251 l10n_util::GetString(IDS_HTTP_POST_WARNING_TITLE)); |
| 251 error_strings->SetString(L"suggestionsHeading", L""); | 252 error_strings->SetString(L"suggestionsHeading", L""); |
| 252 DictionaryValue* summary = new DictionaryValue; | 253 DictionaryValue* summary = new DictionaryValue; |
| 253 summary->SetString(L"msg", | 254 summary->SetString(L"msg", |
| 254 l10n_util::GetString(IDS_ERRORPAGES_HTTP_POST_WARNING)); | 255 l10n_util::GetString(IDS_ERRORPAGES_HTTP_POST_WARNING)); |
| 255 error_strings->Set(L"summary", summary); | 256 error_strings->Set(L"summary", summary); |
| 256 } | 257 } |
| OLD | NEW |