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