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 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 if (!LocalizedError::HasStrings(LocalizedError::kHttpErrorDomain, | 802 if (!LocalizedError::HasStrings(LocalizedError::kHttpErrorDomain, |
803 http_status_code)) { | 803 http_status_code)) { |
804 return false; | 804 return false; |
805 } | 805 } |
806 | 806 |
807 *error_domain = LocalizedError::kHttpErrorDomain; | 807 *error_domain = LocalizedError::kHttpErrorDomain; |
808 return true; | 808 return true; |
809 } | 809 } |
810 | 810 |
811 void ChromeContentRendererClient::GetNavigationErrorStrings( | 811 void ChromeContentRendererClient::GetNavigationErrorStrings( |
812 WebKit::WebFrame* /* frame */, | 812 WebKit::WebFrame* frame, |
813 const WebKit::WebURLRequest& failed_request, | 813 const WebKit::WebURLRequest& failed_request, |
814 const WebKit::WebURLError& error, | 814 const WebKit::WebURLError& error, |
815 std::string* error_html, | 815 std::string* error_html, |
816 string16* error_description) { | 816 string16* error_description) { |
817 const GURL failed_url = error.unreachableURL; | 817 const GURL failed_url = error.unreachableURL; |
818 const Extension* extension = NULL; | 818 const Extension* extension = NULL; |
819 | 819 |
820 if (failed_url.is_valid() && | 820 if (failed_url.is_valid() && |
821 !failed_url.SchemeIs(extensions::kExtensionScheme)) { | 821 !failed_url.SchemeIs(extensions::kExtensionScheme)) { |
822 extension = extension_dispatcher_->extensions()->GetExtensionOrAppByURL( | 822 extension = extension_dispatcher_->extensions()->GetExtensionOrAppByURL( |
823 ExtensionURLInfo(failed_url)); | 823 ExtensionURLInfo(failed_url)); |
824 } | 824 } |
825 | 825 |
826 bool is_post = EqualsASCII(failed_request.httpMethod(), "POST"); | 826 bool is_post = EqualsASCII(failed_request.httpMethod(), "POST"); |
827 | 827 |
828 if (error_html) { | 828 if (error_html) { |
829 // Use a local error page. | 829 // Use a local error page. |
830 int resource_id; | 830 int resource_id; |
831 DictionaryValue error_strings; | 831 DictionaryValue error_strings; |
832 if (extension && !extension->from_bookmark()) { | 832 if (extension && !extension->from_bookmark()) { |
833 LocalizedError::GetAppErrorStrings(error, failed_url, extension, | 833 LocalizedError::GetAppErrorStrings(error, failed_url, extension, |
834 &error_strings); | 834 &error_strings); |
835 | 835 |
836 // TODO(erikkay): Should we use a different template for different | 836 // TODO(erikkay): Should we use a different template for different |
837 // error messages? | 837 // error messages? |
838 resource_id = IDR_ERROR_APP_HTML; | 838 resource_id = IDR_ERROR_APP_HTML; |
839 } else { | 839 } else { |
840 LocalizedError::GetStrings( | 840 const std::string locale = RenderThread::Get()->GetLocale(); |
841 error, | 841 if (NetErrorHelper::GetErrorStringsForDnsProbe( |
842 is_post, | 842 frame, error, is_post, locale, &error_strings)) { |
843 RenderThread::Get()->GetLocale(), | 843 // We got error strings for the "DNS probe possible" page. |
844 &error_strings); | 844 // NetErrorHelper will update it later. |
| 845 } else { |
| 846 LocalizedError::GetStrings(error, is_post, locale, &error_strings); |
| 847 } |
845 resource_id = IDR_NET_ERROR_HTML; | 848 resource_id = IDR_NET_ERROR_HTML; |
846 } | 849 } |
847 | 850 |
848 const base::StringPiece template_html( | 851 const base::StringPiece template_html( |
849 ResourceBundle::GetSharedInstance().GetRawDataResource( | 852 ResourceBundle::GetSharedInstance().GetRawDataResource( |
850 resource_id)); | 853 resource_id)); |
851 if (template_html.empty()) { | 854 if (template_html.empty()) { |
852 NOTREACHED() << "unable to load template. ID: " << resource_id; | 855 NOTREACHED() << "unable to load template. ID: " << resource_id; |
853 } else { | 856 } else { |
854 // "t" is the id of the templates root node. | 857 // "t" is the id of the templates root node. |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1179 | 1182 |
1180 if (container->element().shadowHost().isNull()) | 1183 if (container->element().shadowHost().isNull()) |
1181 return false; | 1184 return false; |
1182 | 1185 |
1183 WebString tag_name = container->element().shadowHost().tagName(); | 1186 WebString tag_name = container->element().shadowHost().tagName(); |
1184 return tag_name.equals(WebString::fromUTF8(kWebViewTagName)) || | 1187 return tag_name.equals(WebString::fromUTF8(kWebViewTagName)) || |
1185 tag_name.equals(WebString::fromUTF8(kAdViewTagName)); | 1188 tag_name.equals(WebString::fromUTF8(kAdViewTagName)); |
1186 } | 1189 } |
1187 | 1190 |
1188 } // namespace chrome | 1191 } // namespace chrome |
OLD | NEW |