OLD | NEW |
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 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
858 } | 858 } |
859 | 859 |
860 *error_domain = LocalizedError::kHttpErrorDomain; | 860 *error_domain = LocalizedError::kHttpErrorDomain; |
861 return true; | 861 return true; |
862 } | 862 } |
863 | 863 |
864 void ChromeContentRendererClient::GetNavigationErrorStrings( | 864 void ChromeContentRendererClient::GetNavigationErrorStrings( |
865 WebKit::WebFrame* frame, | 865 WebKit::WebFrame* frame, |
866 const WebKit::WebURLRequest& failed_request, | 866 const WebKit::WebURLRequest& failed_request, |
867 const WebKit::WebURLError& error, | 867 const WebKit::WebURLError& error, |
| 868 const std::string& accept_languages, |
868 std::string* error_html, | 869 std::string* error_html, |
869 string16* error_description) { | 870 string16* error_description) { |
870 const GURL failed_url = error.unreachableURL; | 871 const GURL failed_url = error.unreachableURL; |
871 const Extension* extension = NULL; | 872 const Extension* extension = NULL; |
872 | 873 |
873 if (failed_url.is_valid() && | 874 if (failed_url.is_valid() && |
874 !failed_url.SchemeIs(extensions::kExtensionScheme)) { | 875 !failed_url.SchemeIs(extensions::kExtensionScheme)) { |
875 extension = extension_dispatcher_->extensions()->GetExtensionOrAppByURL( | 876 extension = extension_dispatcher_->extensions()->GetExtensionOrAppByURL( |
876 failed_url); | 877 failed_url); |
877 } | 878 } |
878 | 879 |
879 bool is_post = EqualsASCII(failed_request.httpMethod(), "POST"); | 880 bool is_post = EqualsASCII(failed_request.httpMethod(), "POST"); |
880 | 881 |
881 if (error_html) { | 882 if (error_html) { |
882 // Use a local error page. | 883 // Use a local error page. |
883 int resource_id; | 884 int resource_id; |
884 base::DictionaryValue error_strings; | 885 base::DictionaryValue error_strings; |
885 if (extension && !extension->from_bookmark()) { | 886 if (extension && !extension->from_bookmark()) { |
886 LocalizedError::GetAppErrorStrings(failed_url, extension, &error_strings); | 887 LocalizedError::GetAppErrorStrings(failed_url, extension, &error_strings); |
887 | 888 |
888 // TODO(erikkay): Should we use a different template for different | 889 // TODO(erikkay): Should we use a different template for different |
889 // error messages? | 890 // error messages? |
890 resource_id = IDR_ERROR_APP_HTML; | 891 resource_id = IDR_ERROR_APP_HTML; |
891 } else { | 892 } else { |
892 const std::string locale = RenderThread::Get()->GetLocale(); | 893 const std::string locale = RenderThread::Get()->GetLocale(); |
893 if (!NetErrorHelper::GetErrorStringsForDnsProbe( | 894 if (!NetErrorHelper::GetErrorStringsForDnsProbe( |
894 frame, error, is_post, locale, &error_strings)) { | 895 frame, error, is_post, locale, accept_languages, |
| 896 &error_strings)) { |
895 // In most cases, the NetErrorHelper won't provide DNS-probe-specific | 897 // In most cases, the NetErrorHelper won't provide DNS-probe-specific |
896 // error pages, so fall back to LocalizedError. | 898 // error pages, so fall back to LocalizedError. |
897 LocalizedError::GetStrings(error.reason, error.domain.utf8(), | 899 LocalizedError::GetStrings(error.reason, error.domain.utf8(), |
898 error.unreachableURL, is_post, locale, | 900 error.unreachableURL, is_post, locale, |
899 &error_strings); | 901 accept_languages, &error_strings); |
900 } | 902 } |
901 resource_id = IDR_NET_ERROR_HTML; | 903 resource_id = IDR_NET_ERROR_HTML; |
902 } | 904 } |
903 | 905 |
904 const base::StringPiece template_html( | 906 const base::StringPiece template_html( |
905 ResourceBundle::GetSharedInstance().GetRawDataResource( | 907 ResourceBundle::GetSharedInstance().GetRawDataResource( |
906 resource_id)); | 908 resource_id)); |
907 if (template_html.empty()) { | 909 if (template_html.empty()) { |
908 NOTREACHED() << "unable to load template. ID: " << resource_id; | 910 NOTREACHED() << "unable to load template. ID: " << resource_id; |
909 } else { | 911 } else { |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1328 // SiteIsolationPolicy is off by default. We would like to activate cross-site | 1330 // SiteIsolationPolicy is off by default. We would like to activate cross-site |
1329 // document blocking (for UMA data collection) for normal renderer processes | 1331 // document blocking (for UMA data collection) for normal renderer processes |
1330 // running a normal web page from the Internet. We only turn on | 1332 // running a normal web page from the Internet. We only turn on |
1331 // SiteIsolationPolicy for a renderer process that does not have the extension | 1333 // SiteIsolationPolicy for a renderer process that does not have the extension |
1332 // flag on. | 1334 // flag on. |
1333 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 1335 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
1334 return !command_line->HasSwitch(switches::kExtensionProcess); | 1336 return !command_line->HasSwitch(switches::kExtensionProcess); |
1335 } | 1337 } |
1336 | 1338 |
1337 } // namespace chrome | 1339 } // namespace chrome |
OLD | NEW |