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/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
843 if (!LocalizedError::HasStrings(LocalizedError::kHttpErrorDomain, | 843 if (!LocalizedError::HasStrings(LocalizedError::kHttpErrorDomain, |
844 http_status_code)) { | 844 http_status_code)) { |
845 return false; | 845 return false; |
846 } | 846 } |
847 | 847 |
848 *error_domain = LocalizedError::kHttpErrorDomain; | 848 *error_domain = LocalizedError::kHttpErrorDomain; |
849 return true; | 849 return true; |
850 } | 850 } |
851 | 851 |
852 void ChromeContentRendererClient::GetNavigationErrorStrings( | 852 void ChromeContentRendererClient::GetNavigationErrorStrings( |
853 WebKit::WebFrame* /* frame */, | 853 WebKit::WebFrame* frame, |
854 const WebKit::WebURLRequest& failed_request, | 854 const WebKit::WebURLRequest& failed_request, |
855 const WebKit::WebURLError& error, | 855 const WebKit::WebURLError& error, |
856 std::string* error_html, | 856 std::string* error_html, |
857 string16* error_description) { | 857 string16* error_description) { |
858 const GURL failed_url = error.unreachableURL; | 858 const GURL failed_url = error.unreachableURL; |
859 const Extension* extension = NULL; | 859 const Extension* extension = NULL; |
860 | 860 |
861 if (failed_url.is_valid() && | 861 if (failed_url.is_valid() && |
862 !failed_url.SchemeIs(extensions::kExtensionScheme)) { | 862 !failed_url.SchemeIs(extensions::kExtensionScheme)) { |
863 extension = extension_dispatcher_->extensions()->GetExtensionOrAppByURL( | 863 extension = extension_dispatcher_->extensions()->GetExtensionOrAppByURL( |
864 ExtensionURLInfo(failed_url)); | 864 ExtensionURLInfo(failed_url)); |
865 } | 865 } |
866 | 866 |
867 bool is_post = EqualsASCII(failed_request.httpMethod(), "POST"); | 867 bool is_post = EqualsASCII(failed_request.httpMethod(), "POST"); |
868 | 868 |
869 if (error_html) { | 869 if (error_html) { |
870 // Use a local error page. | 870 // Use a local error page. |
871 int resource_id; | 871 int resource_id; |
872 base::DictionaryValue error_strings; | 872 base::DictionaryValue error_strings; |
873 if (extension && !extension->from_bookmark()) { | 873 if (extension && !extension->from_bookmark()) { |
874 LocalizedError::GetAppErrorStrings(error, failed_url, extension, | 874 LocalizedError::GetAppErrorStrings(error, failed_url, extension, |
875 &error_strings); | 875 &error_strings); |
876 | 876 |
877 // TODO(erikkay): Should we use a different template for different | 877 // TODO(erikkay): Should we use a different template for different |
878 // error messages? | 878 // error messages? |
879 resource_id = IDR_ERROR_APP_HTML; | 879 resource_id = IDR_ERROR_APP_HTML; |
880 } else { | 880 } else { |
881 LocalizedError::GetStrings( | 881 const std::string locale = RenderThread::Get()->GetLocale(); |
882 error, | 882 if (!NetErrorHelper::GetErrorStringsForDnsProbe( |
883 is_post, | 883 frame, error, is_post, locale, &error_strings)) { |
884 RenderThread::Get()->GetLocale(), | 884 // In most cases, the NetErrorHelper won't provide DNS-probe-specific |
885 &error_strings); | 885 // error pages, so fall back to LocalizedError. |
| 886 LocalizedError::GetStrings(error, is_post, locale, &error_strings); |
| 887 } |
886 resource_id = IDR_NET_ERROR_HTML; | 888 resource_id = IDR_NET_ERROR_HTML; |
887 } | 889 } |
888 | 890 |
889 const base::StringPiece template_html( | 891 const base::StringPiece template_html( |
890 ResourceBundle::GetSharedInstance().GetRawDataResource( | 892 ResourceBundle::GetSharedInstance().GetRawDataResource( |
891 resource_id)); | 893 resource_id)); |
892 if (template_html.empty()) { | 894 if (template_html.empty()) { |
893 NOTREACHED() << "unable to load template. ID: " << resource_id; | 895 NOTREACHED() << "unable to load template. ID: " << resource_id; |
894 } else { | 896 } else { |
895 // "t" is the id of the templates root node. | 897 // "t" is the id of the templates root node. |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1278 if (CommandLine::ForCurrentProcess()->HasSwitch( | 1280 if (CommandLine::ForCurrentProcess()->HasSwitch( |
1279 switches::kEnablePepperTesting)) { | 1281 switches::kEnablePepperTesting)) { |
1280 return true; | 1282 return true; |
1281 } | 1283 } |
1282 #endif // !defined(OS_ANDROID) | 1284 #endif // !defined(OS_ANDROID) |
1283 return false; | 1285 return false; |
1284 } | 1286 } |
1285 | 1287 |
1286 | 1288 |
1287 } // namespace chrome | 1289 } // namespace chrome |
OLD | NEW |