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

Side by Side Diff: chrome/renderer/chrome_content_renderer_client.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/renderer/chrome_content_renderer_client.h" 5 #include "chrome/renderer/chrome_content_renderer_client.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/debug/crash_logging.h" 8 #include "base/debug/crash_logging.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 872
873 bool ChromeContentRendererClient::ShouldSuppressErrorPage(const GURL& url) { 873 bool ChromeContentRendererClient::ShouldSuppressErrorPage(const GURL& url) {
874 // Do not flash an error page if the Instant new tab page fails to load. 874 // Do not flash an error page if the Instant new tab page fails to load.
875 return search_bouncer_.get() && search_bouncer_->IsNewTabPage(url); 875 return search_bouncer_.get() && search_bouncer_->IsNewTabPage(url);
876 } 876 }
877 877
878 void ChromeContentRendererClient::GetNavigationErrorStrings( 878 void ChromeContentRendererClient::GetNavigationErrorStrings(
879 WebKit::WebFrame* frame, 879 WebKit::WebFrame* frame,
880 const WebKit::WebURLRequest& failed_request, 880 const WebKit::WebURLRequest& failed_request,
881 const WebKit::WebURLError& error, 881 const WebKit::WebURLError& error,
882 const std::string& accept_languages,
882 std::string* error_html, 883 std::string* error_html,
883 string16* error_description) { 884 string16* error_description) {
884 const GURL failed_url = error.unreachableURL; 885 const GURL failed_url = error.unreachableURL;
885 const Extension* extension = NULL; 886 const Extension* extension = NULL;
886 887
887 if (failed_url.is_valid() && 888 if (failed_url.is_valid() &&
888 !failed_url.SchemeIs(extensions::kExtensionScheme)) { 889 !failed_url.SchemeIs(extensions::kExtensionScheme)) {
889 extension = extension_dispatcher_->extensions()->GetExtensionOrAppByURL( 890 extension = extension_dispatcher_->extensions()->GetExtensionOrAppByURL(
890 failed_url); 891 failed_url);
891 } 892 }
892 893
893 bool is_post = EqualsASCII(failed_request.httpMethod(), "POST"); 894 bool is_post = EqualsASCII(failed_request.httpMethod(), "POST");
894 895
895 if (error_html) { 896 if (error_html) {
896 // Use a local error page. 897 // Use a local error page.
897 int resource_id; 898 int resource_id;
898 base::DictionaryValue error_strings; 899 base::DictionaryValue error_strings;
899 if (extension && !extension->from_bookmark()) { 900 if (extension && !extension->from_bookmark()) {
900 LocalizedError::GetAppErrorStrings(failed_url, extension, &error_strings); 901 LocalizedError::GetAppErrorStrings(failed_url, extension, &error_strings);
901 902
902 // TODO(erikkay): Should we use a different template for different 903 // TODO(erikkay): Should we use a different template for different
903 // error messages? 904 // error messages?
904 resource_id = IDR_ERROR_APP_HTML; 905 resource_id = IDR_ERROR_APP_HTML;
905 } else { 906 } else {
906 const std::string locale = RenderThread::Get()->GetLocale(); 907 const std::string locale = RenderThread::Get()->GetLocale();
907 if (!NetErrorHelper::GetErrorStringsForDnsProbe( 908 if (!NetErrorHelper::GetErrorStringsForDnsProbe(
908 frame, error, is_post, locale, &error_strings)) { 909 frame, error, is_post, locale, accept_languages,
910 &error_strings)) {
909 // In most cases, the NetErrorHelper won't provide DNS-probe-specific 911 // In most cases, the NetErrorHelper won't provide DNS-probe-specific
910 // error pages, so fall back to LocalizedError. 912 // error pages, so fall back to LocalizedError.
911 LocalizedError::GetStrings(error.reason, error.domain.utf8(), 913 LocalizedError::GetStrings(error.reason, error.domain.utf8(),
912 error.unreachableURL, is_post, locale, 914 error.unreachableURL, is_post, locale,
913 &error_strings); 915 accept_languages, &error_strings);
914 } 916 }
915 resource_id = IDR_NET_ERROR_HTML; 917 resource_id = IDR_NET_ERROR_HTML;
916 } 918 }
917 919
918 const base::StringPiece template_html( 920 const base::StringPiece template_html(
919 ResourceBundle::GetSharedInstance().GetRawDataResource( 921 ResourceBundle::GetSharedInstance().GetRawDataResource(
920 resource_id)); 922 resource_id));
921 if (template_html.empty()) { 923 if (template_html.empty()) {
922 NOTREACHED() << "unable to load template. ID: " << resource_id; 924 NOTREACHED() << "unable to load template. ID: " << resource_id;
923 } else { 925 } else {
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 // SiteIsolationPolicy is off by default. We would like to activate cross-site 1347 // SiteIsolationPolicy is off by default. We would like to activate cross-site
1346 // document blocking (for UMA data collection) for normal renderer processes 1348 // document blocking (for UMA data collection) for normal renderer processes
1347 // running a normal web page from the Internet. We only turn on 1349 // running a normal web page from the Internet. We only turn on
1348 // SiteIsolationPolicy for a renderer process that does not have the extension 1350 // SiteIsolationPolicy for a renderer process that does not have the extension
1349 // flag on. 1351 // flag on.
1350 CommandLine* command_line = CommandLine::ForCurrentProcess(); 1352 CommandLine* command_line = CommandLine::ForCurrentProcess();
1351 return !command_line->HasSwitch(switches::kExtensionProcess); 1353 return !command_line->HasSwitch(switches::kExtensionProcess);
1352 } 1354 }
1353 1355
1354 } // namespace chrome 1356 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/renderer/chrome_content_renderer_client.h ('k') | chrome/renderer/net/net_error_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698