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