| 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 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 if (!LocalizedError::HasStrings(LocalizedError::kHttpErrorDomain, | 840 if (!LocalizedError::HasStrings(LocalizedError::kHttpErrorDomain, |
| 841 http_status_code)) { | 841 http_status_code)) { |
| 842 return false; | 842 return false; |
| 843 } | 843 } |
| 844 | 844 |
| 845 *error_domain = LocalizedError::kHttpErrorDomain; | 845 *error_domain = LocalizedError::kHttpErrorDomain; |
| 846 return true; | 846 return true; |
| 847 } | 847 } |
| 848 | 848 |
| 849 void ChromeContentRendererClient::GetNavigationErrorStrings( | 849 void ChromeContentRendererClient::GetNavigationErrorStrings( |
| 850 WebKit::WebFrame* /* frame */, | 850 WebKit::WebFrame* frame, |
| 851 const WebKit::WebURLRequest& failed_request, | 851 const WebKit::WebURLRequest& failed_request, |
| 852 const WebKit::WebURLError& error, | 852 const WebKit::WebURLError& error, |
| 853 std::string* error_html, | 853 std::string* error_html, |
| 854 string16* error_description) { | 854 string16* error_description) { |
| 855 const GURL failed_url = error.unreachableURL; | 855 const GURL failed_url = error.unreachableURL; |
| 856 const Extension* extension = NULL; | 856 const Extension* extension = NULL; |
| 857 | 857 |
| 858 if (failed_url.is_valid() && | 858 if (failed_url.is_valid() && |
| 859 !failed_url.SchemeIs(extensions::kExtensionScheme)) { | 859 !failed_url.SchemeIs(extensions::kExtensionScheme)) { |
| 860 extension = extension_dispatcher_->extensions()->GetExtensionOrAppByURL( | 860 extension = extension_dispatcher_->extensions()->GetExtensionOrAppByURL( |
| 861 ExtensionURLInfo(failed_url)); | 861 ExtensionURLInfo(failed_url)); |
| 862 } | 862 } |
| 863 | 863 |
| 864 bool is_post = EqualsASCII(failed_request.httpMethod(), "POST"); | 864 bool is_post = EqualsASCII(failed_request.httpMethod(), "POST"); |
| 865 | 865 |
| 866 if (error_html) { | 866 if (error_html) { |
| 867 // Use a local error page. | 867 // Use a local error page. |
| 868 int resource_id; | 868 int resource_id; |
| 869 DictionaryValue error_strings; | 869 DictionaryValue error_strings; |
| 870 if (extension && !extension->from_bookmark()) { | 870 if (extension && !extension->from_bookmark()) { |
| 871 LocalizedError::GetAppErrorStrings(error, failed_url, extension, | 871 LocalizedError::GetAppErrorStrings(error, failed_url, extension, |
| 872 &error_strings); | 872 &error_strings); |
| 873 | 873 |
| 874 // TODO(erikkay): Should we use a different template for different | 874 // TODO(erikkay): Should we use a different template for different |
| 875 // error messages? | 875 // error messages? |
| 876 resource_id = IDR_ERROR_APP_HTML; | 876 resource_id = IDR_ERROR_APP_HTML; |
| 877 } else { | 877 } else { |
| 878 LocalizedError::GetStrings( | 878 const std::string locale = RenderThread::Get()->GetLocale(); |
| 879 error, | 879 if (!NetErrorHelper::GetErrorStringsForDnsProbe( |
| 880 is_post, | 880 frame, error, is_post, locale, &error_strings)) { |
| 881 RenderThread::Get()->GetLocale(), | 881 // In most cases, the NetErrorHelper won't provide DNS-probe-specific |
| 882 &error_strings); | 882 // error pages, so fall back to LocalizedError. |
| 883 LocalizedError::GetStrings(error, is_post, locale, &error_strings); |
| 884 } |
| 883 resource_id = IDR_NET_ERROR_HTML; | 885 resource_id = IDR_NET_ERROR_HTML; |
| 884 } | 886 } |
| 885 | 887 |
| 886 const base::StringPiece template_html( | 888 const base::StringPiece template_html( |
| 887 ResourceBundle::GetSharedInstance().GetRawDataResource( | 889 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 888 resource_id)); | 890 resource_id)); |
| 889 if (template_html.empty()) { | 891 if (template_html.empty()) { |
| 890 NOTREACHED() << "unable to load template. ID: " << resource_id; | 892 NOTREACHED() << "unable to load template. ID: " << resource_id; |
| 891 } else { | 893 } else { |
| 892 // "t" is the id of the templates root node. | 894 // "t" is the id of the templates root node. |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1254 | 1256 |
| 1255 if (container->element().shadowHost().isNull()) | 1257 if (container->element().shadowHost().isNull()) |
| 1256 return false; | 1258 return false; |
| 1257 | 1259 |
| 1258 WebString tag_name = container->element().shadowHost().tagName(); | 1260 WebString tag_name = container->element().shadowHost().tagName(); |
| 1259 return tag_name.equals(WebString::fromUTF8(kWebViewTagName)) || | 1261 return tag_name.equals(WebString::fromUTF8(kWebViewTagName)) || |
| 1260 tag_name.equals(WebString::fromUTF8(kAdViewTagName)); | 1262 tag_name.equals(WebString::fromUTF8(kAdViewTagName)); |
| 1261 } | 1263 } |
| 1262 | 1264 |
| 1263 } // namespace chrome | 1265 } // namespace chrome |
| OLD | NEW |