Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(805)

Side by Side Diff: chrome/renderer/chrome_content_renderer_client.cc

Issue 13811022: New network error page: Fix resubmit warning page (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: sync Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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");
835 831
836 if (failed_url.is_valid() && 832 if (failed_url.is_valid() &&
837 !failed_url.SchemeIs(extensions::kExtensionScheme)) { 833 !failed_url.SchemeIs(extensions::kExtensionScheme)) {
838 extension = extension_dispatcher_->extensions()->GetExtensionOrAppByURL( 834 extension = extension_dispatcher_->extensions()->GetExtensionOrAppByURL(
839 ExtensionURLInfo(failed_url)); 835 ExtensionURLInfo(failed_url));
840 } 836 }
841 837
838 bool is_post = EqualsASCII(failed_request.httpMethod(), "POST");
eroman 2013/04/16 00:22:49 Is this guaranteed to be upper case?
mmenke 2013/04/16 14:46:18 Per RFC 2616, the method is actually case sensitiv
839
842 if (error_html) { 840 if (error_html) {
843 // Use a local error page. 841 // Use a local error page.
844 int resource_id; 842 int resource_id;
845 DictionaryValue error_strings; 843 DictionaryValue error_strings;
846 if (extension && !extension->from_bookmark()) { 844 if (extension && !extension->from_bookmark()) {
847 LocalizedError::GetAppErrorStrings(error, failed_url, extension, 845 LocalizedError::GetAppErrorStrings(error, failed_url, extension,
848 &error_strings); 846 &error_strings);
849 847
850 // TODO(erikkay): Should we use a different template for different 848 // TODO(erikkay): Should we use a different template for different
851 // error messages? 849 // error messages?
852 resource_id = IDR_ERROR_APP_HTML; 850 resource_id = IDR_ERROR_APP_HTML;
853 } else { 851 } else {
854 if (is_repost) { 852 LocalizedError::GetStrings(
855 LocalizedError::GetFormRepostStrings(failed_url, &error_strings); 853 error,
856 } else { 854 is_post,
857 LocalizedError::GetStrings(error, &error_strings, 855 RenderThread::Get()->GetLocale(),
858 RenderThread::Get()->GetLocale()); 856 &error_strings);
859 }
860 resource_id = IDR_NET_ERROR_HTML; 857 resource_id = IDR_NET_ERROR_HTML;
861 } 858 }
862 859
863 const base::StringPiece template_html( 860 const base::StringPiece template_html(
864 ResourceBundle::GetSharedInstance().GetRawDataResource( 861 ResourceBundle::GetSharedInstance().GetRawDataResource(
865 resource_id)); 862 resource_id));
866 if (template_html.empty()) { 863 if (template_html.empty()) {
867 NOTREACHED() << "unable to load template. ID: " << resource_id; 864 NOTREACHED() << "unable to load template. ID: " << resource_id;
868 } else { 865 } else {
869 // "t" is the id of the templates root node. 866 // "t" is the id of the templates root node.
870 *error_html = webui::GetTemplatesHtml(template_html, &error_strings, "t"); 867 *error_html = webui::GetTemplatesHtml(template_html, &error_strings, "t");
871 } 868 }
872 } 869 }
873 870
874 if (error_description) { 871 if (error_description) {
875 if (!extension && !is_repost) 872 if (!extension)
876 *error_description = LocalizedError::GetErrorDetails(error); 873 *error_description = LocalizedError::GetErrorDetails(error, is_post);
877 } 874 }
878 } 875 }
879 876
880 bool ChromeContentRendererClient::RunIdleHandlerWhenWidgetsHidden() { 877 bool ChromeContentRendererClient::RunIdleHandlerWhenWidgetsHidden() {
881 return !extension_dispatcher_->is_extension_process(); 878 return !extension_dispatcher_->is_extension_process();
882 } 879 }
883 880
884 bool ChromeContentRendererClient::AllowPopup() { 881 bool ChromeContentRendererClient::AllowPopup() {
885 extensions::ChromeV8Context* current_context = 882 extensions::ChromeV8Context* current_context =
886 extension_dispatcher_->v8_context_set().GetCurrent(); 883 extension_dispatcher_->v8_context_set().GetCurrent();
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 1229
1233 for (size_t i = 0; i < request_os_file_handle_allowed_hosts_.size(); ++i) { 1230 for (size_t i = 0; i < request_os_file_handle_allowed_hosts_.size(); ++i) {
1234 if (MatchPattern(inner.host(), request_os_file_handle_allowed_hosts_[i])) 1231 if (MatchPattern(inner.host(), request_os_file_handle_allowed_hosts_[i]))
1235 return true; 1232 return true;
1236 } 1233 }
1237 1234
1238 return false; 1235 return false;
1239 } 1236 }
1240 1237
1241 } // namespace chrome 1238 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698