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

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

Issue 11884017: Show a localized and detailed error page when a page load fails due to ERR_NETWORK_CHANGED. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/string16.h"
10 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
11 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
12 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/common/extensions/extension.h"
13 #include "chrome/common/extensions/extension_constants.h" 13 #include "chrome/common/extensions/extension_constants.h"
14 #include "chrome/common/extensions/extension_icon_set.h" 14 #include "chrome/common/extensions/extension_icon_set.h"
15 #include "chrome/common/extensions/extension_set.h" 15 #include "chrome/common/extensions/extension_set.h"
16 #include "googleurl/src/gurl.h" 16 #include "googleurl/src/gurl.h"
17 #include "grit/chromium_strings.h" 17 #include "grit/chromium_strings.h"
18 #include "grit/generated_resources.h" 18 #include "grit/generated_resources.h"
19 #include "net/base/escape.h" 19 #include "net/base/escape.h"
20 #include "net/base/net_errors.h" 20 #include "net/base/net_errors.h"
21 #include "third_party/WebKit/Source/Platform/chromium/public/WebURLError.h" 21 #include "third_party/WebKit/Source/Platform/chromium/public/WebURLError.h"
22 #include "ui/base/l10n/l10n_util.h" 22 #include "ui/base/l10n/l10n_util.h"
23 #include "webkit/glue/webkit_glue.h" 23 #include "webkit/glue/webkit_glue.h"
24 24
25 #if defined(OS_WIN) 25 #if defined(OS_WIN)
26 #include "base/win/windows_version.h" 26 #include "base/win/windows_version.h"
27 #endif 27 #endif
28 28
29 using WebKit::WebURLError;
jochen (gone - plz use gerrit) 2013/01/14 13:45:37 please leave this in.
Joao da Silva 2013/01/14 13:49:45 Done. This was removed because the 2 out of 3 uses
30
31 namespace { 29 namespace {
32 30
33 static const char kRedirectLoopLearnMoreUrl[] = 31 static const char kRedirectLoopLearnMoreUrl[] =
34 "https://www.google.com/support/chrome/bin/answer.py?answer=95626"; 32 "https://www.google.com/support/chrome/bin/answer.py?answer=95626";
35 static const char kWeakDHKeyLearnMoreUrl[] = 33 static const char kWeakDHKeyLearnMoreUrl[] =
36 "http://sites.google.com/a/chromium.org/dev/" 34 "http://sites.google.com/a/chromium.org/dev/"
37 "err_ssl_weak_server_ephemeral_dh_key"; 35 "err_ssl_weak_server_ephemeral_dh_key";
38 #if defined(OS_CHROMEOS) 36 #if defined(OS_CHROMEOS)
39 static const char kAppWarningLearnMoreUrl[] = 37 static const char kAppWarningLearnMoreUrl[] =
40 "chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html" 38 "chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html"
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 IDS_ERRORPAGES_DETAILS_TEMPORARILY_THROTTLED, 262 IDS_ERRORPAGES_DETAILS_TEMPORARILY_THROTTLED,
265 SUGGEST_NONE, 263 SUGGEST_NONE,
266 }, 264 },
267 {net::ERR_BLOCKED_BY_CLIENT, 265 {net::ERR_BLOCKED_BY_CLIENT,
268 IDS_ERRORPAGES_TITLE_BLOCKED, 266 IDS_ERRORPAGES_TITLE_BLOCKED,
269 IDS_ERRORPAGES_HEADING_BLOCKED, 267 IDS_ERRORPAGES_HEADING_BLOCKED,
270 IDS_ERRORPAGES_SUMMARY_BLOCKED, 268 IDS_ERRORPAGES_SUMMARY_BLOCKED,
271 IDS_ERRORPAGES_DETAILS_BLOCKED, 269 IDS_ERRORPAGES_DETAILS_BLOCKED,
272 SUGGEST_DISABLE_EXTENSION, 270 SUGGEST_DISABLE_EXTENSION,
273 }, 271 },
272 {net::ERR_NETWORK_CHANGED,
273 IDS_ERRORPAGES_TITLE_LOAD_FAILED,
274 IDS_ERRORPAGES_HEADING_NETWORK_ACCESS_DENIED,
275 IDS_ERRORPAGES_SUMMARY_NETWORK_CHANGED,
276 IDS_ERRORPAGES_DETAILS_NETWORK_CHANGED,
277 SUGGEST_RELOAD | SUGGEST_CHECK_CONNECTION,
278 },
274 }; 279 };
275 280
276 const LocalizedErrorMap http_error_options[] = { 281 const LocalizedErrorMap http_error_options[] = {
277 {403, 282 {403,
278 IDS_ERRORPAGES_TITLE_ACCESS_DENIED, 283 IDS_ERRORPAGES_TITLE_ACCESS_DENIED,
279 IDS_ERRORPAGES_HEADING_ACCESS_DENIED, 284 IDS_ERRORPAGES_HEADING_ACCESS_DENIED,
280 IDS_ERRORPAGES_SUMMARY_FORBIDDEN, 285 IDS_ERRORPAGES_SUMMARY_FORBIDDEN,
281 IDS_ERRORPAGES_DETAILS_FORBIDDEN, 286 IDS_ERRORPAGES_DETAILS_FORBIDDEN,
282 SUGGEST_NONE, 287 SUGGEST_NONE,
283 }, 288 },
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 return string16(); 379 return string16();
375 } 380 }
376 return l10n_util::GetStringFUTF16( 381 return l10n_util::GetStringFUTF16(
377 error_page_template, 382 error_page_template,
378 base::IntToString16(error_code), 383 base::IntToString16(error_code),
379 ASCIIToUTF16(error_string), 384 ASCIIToUTF16(error_string),
380 details); 385 details);
381 } 386 }
382 387
383 const LocalizedErrorMap* FindErrorMapInArray(const LocalizedErrorMap* maps, 388 const LocalizedErrorMap* FindErrorMapInArray(const LocalizedErrorMap* maps,
384 size_t num_maps, 389 size_t num_maps,
385 int error_code) { 390 int error_code) {
386 for (size_t i = 0; i < num_maps; ++i) { 391 for (size_t i = 0; i < num_maps; ++i) {
387 if (maps[i].error_code == error_code) 392 if (maps[i].error_code == error_code)
388 return &maps[i]; 393 return &maps[i];
389 } 394 }
390 return NULL; 395 return NULL;
391 } 396 }
392 397
393 const LocalizedErrorMap* LookupErrorMap(const std::string& error_domain, 398 const LocalizedErrorMap* LookupErrorMap(const std::string& error_domain,
394 int error_code) { 399 int error_code) {
395 if (error_domain == net::kErrorDomain) { 400 if (error_domain == net::kErrorDomain) {
(...skipping 28 matching lines...) Expand all
424 l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE)); 429 l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE));
425 standard_menu_items_text->SetString("advancedTitle", 430 standard_menu_items_text->SetString("advancedTitle",
426 l10n_util::GetStringUTF16(IDS_SETTINGS_SHOW_ADVANCED_SETTINGS)); 431 l10n_util::GetStringUTF16(IDS_SETTINGS_SHOW_ADVANCED_SETTINGS));
427 return standard_menu_items_text; 432 return standard_menu_items_text;
428 } 433 }
429 434
430 } // namespace 435 } // namespace
431 436
432 const char LocalizedError::kHttpErrorDomain[] = "http"; 437 const char LocalizedError::kHttpErrorDomain[] = "http";
433 438
439 // static
434 void LocalizedError::GetStrings(const WebKit::WebURLError& error, 440 void LocalizedError::GetStrings(const WebKit::WebURLError& error,
435 DictionaryValue* error_strings, 441 DictionaryValue* error_strings,
436 const std::string& locale) { 442 const std::string& locale) {
437 bool rtl = LocaleIsRTL(); 443 bool rtl = LocaleIsRTL();
438 error_strings->SetString("textdirection", rtl ? "rtl" : "ltr"); 444 error_strings->SetString("textdirection", rtl ? "rtl" : "ltr");
439 445
440 // Grab the strings and settings that depend on the error type. Init 446 // Grab the strings and settings that depend on the error type. Init
441 // options with default values. 447 // options with default values.
442 LocalizedErrorMap options = { 448 LocalizedErrorMap options = {
443 0, 449 0,
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 655
650 DictionaryValue* suggest_learn_more = new DictionaryValue; 656 DictionaryValue* suggest_learn_more = new DictionaryValue;
651 suggest_learn_more->SetString("msg", 657 suggest_learn_more->SetString("msg",
652 l10n_util::GetStringUTF16(IDS_ERRORPAGES_SUGGESTION_LEARNMORE)); 658 l10n_util::GetStringUTF16(IDS_ERRORPAGES_SUGGESTION_LEARNMORE));
653 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec()); 659 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec());
654 error_strings->Set("suggestionsLearnMore", suggest_learn_more); 660 error_strings->Set("suggestionsLearnMore", suggest_learn_more);
655 } 661 }
656 } 662 }
657 } 663 }
658 664
665 // static
659 string16 LocalizedError::GetErrorDetails(const WebKit::WebURLError& error) { 666 string16 LocalizedError::GetErrorDetails(const WebKit::WebURLError& error) {
660 const LocalizedErrorMap* error_map = 667 const LocalizedErrorMap* error_map =
661 LookupErrorMap(error.domain.utf8(), error.reason); 668 LookupErrorMap(error.domain.utf8(), error.reason);
662 if (error_map) 669 if (error_map)
663 return l10n_util::GetStringUTF16(error_map->details_resource_id); 670 return l10n_util::GetStringUTF16(error_map->details_resource_id);
664 else 671 else
665 return l10n_util::GetStringUTF16(IDS_ERRORPAGES_DETAILS_UNKNOWN); 672 return l10n_util::GetStringUTF16(IDS_ERRORPAGES_DETAILS_UNKNOWN);
666 } 673 }
667 674
675 // static
668 bool LocalizedError::HasStrings(const std::string& error_domain, 676 bool LocalizedError::HasStrings(const std::string& error_domain,
669 int error_code) { 677 int error_code) {
670 return LookupErrorMap(error_domain, error_code) != NULL; 678 return LookupErrorMap(error_domain, error_code) != NULL;
671 } 679 }
672 680
681 // static
673 void LocalizedError::GetFormRepostStrings(const GURL& display_url, 682 void LocalizedError::GetFormRepostStrings(const GURL& display_url,
674 DictionaryValue* error_strings) { 683 DictionaryValue* error_strings) {
675 bool rtl = LocaleIsRTL(); 684 bool rtl = LocaleIsRTL();
676 error_strings->SetString("textdirection", rtl ? "rtl" : "ltr"); 685 error_strings->SetString("textdirection", rtl ? "rtl" : "ltr");
677 686
678 string16 failed_url(ASCIIToUTF16(display_url.spec())); 687 string16 failed_url(ASCIIToUTF16(display_url.spec()));
679 // URLs are always LTR. 688 // URLs are always LTR.
680 if (rtl) 689 if (rtl)
681 base::i18n::WrapStringWithLTRFormatting(&failed_url); 690 base::i18n::WrapStringWithLTRFormatting(&failed_url);
682 error_strings->SetString( 691 error_strings->SetString(
683 "title", l10n_util::GetStringFUTF16(IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, 692 "title", l10n_util::GetStringFUTF16(IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
684 failed_url)); 693 failed_url));
685 error_strings->SetString( 694 error_strings->SetString(
686 "heading", l10n_util::GetStringUTF16(IDS_HTTP_POST_WARNING_TITLE)); 695 "heading", l10n_util::GetStringUTF16(IDS_HTTP_POST_WARNING_TITLE));
687 DictionaryValue* summary = new DictionaryValue; 696 DictionaryValue* summary = new DictionaryValue;
688 summary->SetString( 697 summary->SetString(
689 "msg", l10n_util::GetStringUTF16(IDS_ERRORPAGES_HTTP_POST_WARNING)); 698 "msg", l10n_util::GetStringUTF16(IDS_ERRORPAGES_HTTP_POST_WARNING));
690 error_strings->Set("summary", summary); 699 error_strings->Set("summary", summary);
691 } 700 }
692 701
702 // static
693 void LocalizedError::GetAppErrorStrings( 703 void LocalizedError::GetAppErrorStrings(
694 const WebURLError& error, 704 const WebKit::WebURLError& error,
695 const GURL& display_url, 705 const GURL& display_url,
696 const extensions::Extension* app, 706 const extensions::Extension* app,
697 DictionaryValue* error_strings) { 707 DictionaryValue* error_strings) {
698 DCHECK(app); 708 DCHECK(app);
699 709
700 bool rtl = LocaleIsRTL(); 710 bool rtl = LocaleIsRTL();
701 error_strings->SetString("textdirection", rtl ? "rtl" : "ltr"); 711 error_strings->SetString("textdirection", rtl ? "rtl" : "ltr");
702 712
703 string16 failed_url(ASCIIToUTF16(display_url.spec())); 713 string16 failed_url(ASCIIToUTF16(display_url.spec()));
704 // URLs are always LTR. 714 // URLs are always LTR.
(...skipping 14 matching lines...) Expand all
719 #if defined(OS_CHROMEOS) 729 #if defined(OS_CHROMEOS)
720 GURL learn_more_url(kAppWarningLearnMoreUrl); 730 GURL learn_more_url(kAppWarningLearnMoreUrl);
721 DictionaryValue* suggest_learn_more = new DictionaryValue(); 731 DictionaryValue* suggest_learn_more = new DictionaryValue();
722 suggest_learn_more->SetString("msg", 732 suggest_learn_more->SetString("msg",
723 l10n_util::GetStringUTF16( 733 l10n_util::GetStringUTF16(
724 IDS_ERRORPAGES_SUGGESTION_LEARNMORE)); 734 IDS_ERRORPAGES_SUGGESTION_LEARNMORE));
725 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec()); 735 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec());
726 error_strings->Set("suggestionsLearnMore", suggest_learn_more); 736 error_strings->Set("suggestionsLearnMore", suggest_learn_more);
727 #endif // defined(OS_CHROMEOS) 737 #endif // defined(OS_CHROMEOS)
728 } 738 }
OLDNEW
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698