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

Side by Side Diff: chrome/common/localized_error.cc

Issue 24503004: Show IDN in error screens (DNS failure etc.) (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 2 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 "chrome/common/localized_error.h" 5 #include "chrome/common/localized_error.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/common/extensions/extension_constants.h" 14 #include "chrome/common/extensions/extension_constants.h"
15 #include "chrome/common/extensions/extension_icon_set.h" 15 #include "chrome/common/extensions/extension_icon_set.h"
16 #include "chrome/common/extensions/extension_set.h" 16 #include "chrome/common/extensions/extension_set.h"
17 #include "chrome/common/extensions/manifest_handlers/icons_handler.h" 17 #include "chrome/common/extensions/manifest_handlers/icons_handler.h"
18 #include "chrome/common/net/net_error_info.h" 18 #include "chrome/common/net/net_error_info.h"
19 #include "grit/chromium_strings.h" 19 #include "grit/chromium_strings.h"
20 #include "grit/generated_resources.h" 20 #include "grit/generated_resources.h"
21 #include "net/base/escape.h" 21 #include "net/base/escape.h"
22 #include "net/base/net_errors.h" 22 #include "net/base/net_errors.h"
23 #include "net/base/net_util.h"
23 #include "third_party/WebKit/public/platform/WebURLError.h" 24 #include "third_party/WebKit/public/platform/WebURLError.h"
24 #include "ui/base/l10n/l10n_util.h" 25 #include "ui/base/l10n/l10n_util.h"
25 #include "ui/webui/web_ui_util.h" 26 #include "ui/webui/web_ui_util.h"
26 #include "url/gurl.h" 27 #include "url/gurl.h"
27 #include "webkit/glue/webkit_glue.h" 28 #include "webkit/glue/webkit_glue.h"
28 29
29 #if defined(OS_WIN) 30 #if defined(OS_WIN)
30 #include "base/win/windows_version.h" 31 #include "base/win/windows_version.h"
31 #endif 32 #endif
32 33
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 490
490 } // namespace 491 } // namespace
491 492
492 const char LocalizedError::kHttpErrorDomain[] = "http"; 493 const char LocalizedError::kHttpErrorDomain[] = "http";
493 494
494 void LocalizedError::GetStrings(int error_code, 495 void LocalizedError::GetStrings(int error_code,
495 const std::string& error_domain, 496 const std::string& error_domain,
496 const GURL& failed_url, 497 const GURL& failed_url,
497 bool is_post, 498 bool is_post,
498 const std::string& locale, 499 const std::string& locale,
500 const std::string& accept_languages,
499 base::DictionaryValue* error_strings) { 501 base::DictionaryValue* error_strings) {
500 bool rtl = LocaleIsRTL(); 502 bool rtl = LocaleIsRTL();
501 error_strings->SetString("textdirection", rtl ? "rtl" : "ltr"); 503 error_strings->SetString("textdirection", rtl ? "rtl" : "ltr");
502 504
503 // Grab the strings and settings that depend on the error type. Init 505 // Grab the strings and settings that depend on the error type. Init
504 // options with default values. 506 // options with default values.
505 LocalizedErrorMap options = { 507 LocalizedErrorMap options = {
506 0, 508 0,
507 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, 509 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
508 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE, 510 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE,
(...skipping 14 matching lines...) Expand all
523 if (error_domain == net::kErrorDomain && 525 if (error_domain == net::kErrorDomain &&
524 error_code == net::ERR_ACCESS_DENIED && 526 error_code == net::ERR_ACCESS_DENIED &&
525 failed_url.scheme() == "file") { 527 failed_url.scheme() == "file") {
526 options.title_resource_id = IDS_ERRORPAGES_TITLE_ACCESS_DENIED; 528 options.title_resource_id = IDS_ERRORPAGES_TITLE_ACCESS_DENIED;
527 options.heading_resource_id = IDS_ERRORPAGES_HEADING_FILE_ACCESS_DENIED; 529 options.heading_resource_id = IDS_ERRORPAGES_HEADING_FILE_ACCESS_DENIED;
528 options.summary_resource_id = IDS_ERRORPAGES_SUMMARY_FILE_ACCESS_DENIED; 530 options.summary_resource_id = IDS_ERRORPAGES_SUMMARY_FILE_ACCESS_DENIED;
529 options.details_resource_id = IDS_ERRORPAGES_DETAILS_FILE_ACCESS_DENIED; 531 options.details_resource_id = IDS_ERRORPAGES_DETAILS_FILE_ACCESS_DENIED;
530 options.suggestions = SUGGEST_NONE; 532 options.suggestions = SUGGEST_NONE;
531 } 533 }
532 534
533 string16 failed_url_string(UTF8ToUTF16(failed_url.spec())); 535 string16 failed_url_string(net::FormatUrl(failed_url, accept_languages,
mmenke 2013/09/26 16:23:01 Believe this formatting violates the style guide.
yuusuke 2013/09/27 14:16:52 Done.
536 net::kFormatUrlOmitNothing, net::UnescapeRule::NORMAL, NULL, NULL,
537 NULL));
534 // URLs are always LTR. 538 // URLs are always LTR.
535 if (rtl) 539 if (rtl)
536 base::i18n::WrapStringWithLTRFormatting(&failed_url_string); 540 base::i18n::WrapStringWithLTRFormatting(&failed_url_string);
537 error_strings->SetString("title", 541 error_strings->SetString("title",
538 l10n_util::GetStringFUTF16(options.title_resource_id, failed_url_string)); 542 l10n_util::GetStringFUTF16(options.title_resource_id, failed_url_string));
539 error_strings->SetString("heading", 543 error_strings->SetString("heading",
540 l10n_util::GetStringUTF16(options.heading_resource_id)); 544 l10n_util::GetStringUTF16(options.heading_resource_id));
541 545
542 std::string icon_class = GetIconClassForError(error_domain, error_code); 546 std::string icon_class = GetIconClassForError(error_domain, error_code);
543 error_strings->SetString("iconClass", icon_class); 547 error_strings->SetString("iconClass", icon_class);
544 548
545 base::DictionaryValue* summary = new base::DictionaryValue; 549 base::DictionaryValue* summary = new base::DictionaryValue;
546 summary->SetString("msg", 550 summary->SetString("msg",
547 l10n_util::GetStringUTF16(options.summary_resource_id)); 551 l10n_util::GetStringUTF16(options.summary_resource_id));
548 // TODO(tc): We want the unicode url and host here since they're being
549 // displayed.
550 summary->SetString("failedUrl", failed_url_string); 552 summary->SetString("failedUrl", failed_url_string);
551 summary->SetString("hostName", failed_url.host()); 553 summary->SetString("hostName", net::IDNToUnicode(failed_url.host(),
554 accept_languages));
552 summary->SetString("productName", 555 summary->SetString("productName",
553 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); 556 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
554 557
555 error_strings->SetString( 558 error_strings->SetString(
556 "more", l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_MORE)); 559 "more", l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_MORE));
557 error_strings->SetString( 560 error_strings->SetString(
558 "less", l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_LESS)); 561 "less", l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_LESS));
559 error_strings->Set("summary", summary); 562 error_strings->Set("summary", summary);
560 #if defined(OS_CHROMEOS) 563 #if defined(OS_CHROMEOS)
561 error_strings->SetString( 564 error_strings->SetString(
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 #if defined(OS_CHROMEOS) 820 #if defined(OS_CHROMEOS)
818 GURL learn_more_url(kAppWarningLearnMoreUrl); 821 GURL learn_more_url(kAppWarningLearnMoreUrl);
819 base::DictionaryValue* suggest_learn_more = new base::DictionaryValue(); 822 base::DictionaryValue* suggest_learn_more = new base::DictionaryValue();
820 suggest_learn_more->SetString("msg", 823 suggest_learn_more->SetString("msg",
821 l10n_util::GetStringUTF16( 824 l10n_util::GetStringUTF16(
822 IDS_ERRORPAGES_SUGGESTION_LEARNMORE_BODY)); 825 IDS_ERRORPAGES_SUGGESTION_LEARNMORE_BODY));
823 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec()); 826 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec());
824 error_strings->Set("suggestionsLearnMore", suggest_learn_more); 827 error_strings->Set("suggestionsLearnMore", suggest_learn_more);
825 #endif // defined(OS_CHROMEOS) 828 #endif // defined(OS_CHROMEOS)
826 } 829 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698