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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 return true; | 821 return true; |
822 } | 822 } |
823 | 823 |
824 void ChromeContentRendererClient::GetNavigationErrorStrings( | 824 void ChromeContentRendererClient::GetNavigationErrorStrings( |
825 const WebKit::WebURLRequest& failed_request, | 825 const WebKit::WebURLRequest& failed_request, |
826 const WebKit::WebURLError& error, | 826 const WebKit::WebURLError& error, |
827 std::string* error_html, | 827 std::string* error_html, |
828 string16* error_description) { | 828 string16* error_description) { |
829 const GURL failed_url = error.unreachableURL; | 829 const GURL failed_url = error.unreachableURL; |
830 const Extension* extension = NULL; | 830 const Extension* extension = NULL; |
| 831 const bool is_repost = |
| 832 error.reason == net::ERR_CACHE_MISS && |
| 833 error.domain == WebString::fromUTF8(net::kErrorDomain) && |
| 834 EqualsASCII(failed_request.httpMethod(), "POST"); |
831 | 835 |
832 if (failed_url.is_valid() && | 836 if (failed_url.is_valid() && |
833 !failed_url.SchemeIs(extensions::kExtensionScheme)) { | 837 !failed_url.SchemeIs(extensions::kExtensionScheme)) { |
834 extension = extension_dispatcher_->extensions()->GetExtensionOrAppByURL( | 838 extension = extension_dispatcher_->extensions()->GetExtensionOrAppByURL( |
835 ExtensionURLInfo(failed_url)); | 839 ExtensionURLInfo(failed_url)); |
836 } | 840 } |
837 | 841 |
838 bool is_post = EqualsASCII(failed_request.httpMethod(), "POST"); | |
839 | |
840 if (error_html) { | 842 if (error_html) { |
841 // Use a local error page. | 843 // Use a local error page. |
842 int resource_id; | 844 int resource_id; |
843 DictionaryValue error_strings; | 845 DictionaryValue error_strings; |
844 if (extension && !extension->from_bookmark()) { | 846 if (extension && !extension->from_bookmark()) { |
845 LocalizedError::GetAppErrorStrings(error, failed_url, extension, | 847 LocalizedError::GetAppErrorStrings(error, failed_url, extension, |
846 &error_strings); | 848 &error_strings); |
847 | 849 |
848 // TODO(erikkay): Should we use a different template for different | 850 // TODO(erikkay): Should we use a different template for different |
849 // error messages? | 851 // error messages? |
850 resource_id = IDR_ERROR_APP_HTML; | 852 resource_id = IDR_ERROR_APP_HTML; |
851 } else { | 853 } else { |
852 LocalizedError::GetStrings( | 854 if (is_repost) { |
853 error, | 855 LocalizedError::GetFormRepostStrings(failed_url, &error_strings); |
854 is_post, | 856 } else { |
855 RenderThread::Get()->GetLocale(), | 857 LocalizedError::GetStrings(error, &error_strings, |
856 &error_strings); | 858 RenderThread::Get()->GetLocale()); |
| 859 } |
857 resource_id = IDR_NET_ERROR_HTML; | 860 resource_id = IDR_NET_ERROR_HTML; |
858 } | 861 } |
859 | 862 |
860 const base::StringPiece template_html( | 863 const base::StringPiece template_html( |
861 ResourceBundle::GetSharedInstance().GetRawDataResource( | 864 ResourceBundle::GetSharedInstance().GetRawDataResource( |
862 resource_id)); | 865 resource_id)); |
863 if (template_html.empty()) { | 866 if (template_html.empty()) { |
864 NOTREACHED() << "unable to load template. ID: " << resource_id; | 867 NOTREACHED() << "unable to load template. ID: " << resource_id; |
865 } else { | 868 } else { |
866 // "t" is the id of the templates root node. | 869 // "t" is the id of the templates root node. |
867 *error_html = webui::GetTemplatesHtml(template_html, &error_strings, "t"); | 870 *error_html = webui::GetTemplatesHtml(template_html, &error_strings, "t"); |
868 } | 871 } |
869 } | 872 } |
870 | 873 |
871 if (error_description) { | 874 if (error_description) { |
872 if (!extension) | 875 if (!extension && !is_repost) |
873 *error_description = LocalizedError::GetErrorDetails(error, is_post); | 876 *error_description = LocalizedError::GetErrorDetails(error); |
874 } | 877 } |
875 } | 878 } |
876 | 879 |
877 bool ChromeContentRendererClient::RunIdleHandlerWhenWidgetsHidden() { | 880 bool ChromeContentRendererClient::RunIdleHandlerWhenWidgetsHidden() { |
878 return !extension_dispatcher_->is_extension_process(); | 881 return !extension_dispatcher_->is_extension_process(); |
879 } | 882 } |
880 | 883 |
881 bool ChromeContentRendererClient::AllowPopup() { | 884 bool ChromeContentRendererClient::AllowPopup() { |
882 extensions::ChromeV8Context* current_context = | 885 extensions::ChromeV8Context* current_context = |
883 extension_dispatcher_->v8_context_set().GetCurrent(); | 886 extension_dispatcher_->v8_context_set().GetCurrent(); |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1229 | 1232 |
1230 for (size_t i = 0; i < request_os_file_handle_allowed_hosts_.size(); ++i) { | 1233 for (size_t i = 0; i < request_os_file_handle_allowed_hosts_.size(); ++i) { |
1231 if (MatchPattern(inner.host(), request_os_file_handle_allowed_hosts_[i])) | 1234 if (MatchPattern(inner.host(), request_os_file_handle_allowed_hosts_[i])) |
1232 return true; | 1235 return true; |
1233 } | 1236 } |
1234 | 1237 |
1235 return false; | 1238 return false; |
1236 } | 1239 } |
1237 | 1240 |
1238 } // namespace chrome | 1241 } // namespace chrome |
OLD | NEW |