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

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

Issue 13270005: Display DNS probe results. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix browser test nits Created 7 years, 6 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
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 "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 830 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 if (!LocalizedError::HasStrings(LocalizedError::kHttpErrorDomain, 841 if (!LocalizedError::HasStrings(LocalizedError::kHttpErrorDomain,
842 http_status_code)) { 842 http_status_code)) {
843 return false; 843 return false;
844 } 844 }
845 845
846 *error_domain = LocalizedError::kHttpErrorDomain; 846 *error_domain = LocalizedError::kHttpErrorDomain;
847 return true; 847 return true;
848 } 848 }
849 849
850 void ChromeContentRendererClient::GetNavigationErrorStrings( 850 void ChromeContentRendererClient::GetNavigationErrorStrings(
851 WebKit::WebFrame* /* frame */, 851 WebKit::WebFrame* frame,
852 const WebKit::WebURLRequest& failed_request, 852 const WebKit::WebURLRequest& failed_request,
853 const WebKit::WebURLError& error, 853 const WebKit::WebURLError& error,
854 std::string* error_html, 854 std::string* error_html,
855 string16* error_description) { 855 string16* error_description) {
856 const GURL failed_url = error.unreachableURL; 856 const GURL failed_url = error.unreachableURL;
857 const Extension* extension = NULL; 857 const Extension* extension = NULL;
858 858
859 if (failed_url.is_valid() && 859 if (failed_url.is_valid() &&
860 !failed_url.SchemeIs(extensions::kExtensionScheme)) { 860 !failed_url.SchemeIs(extensions::kExtensionScheme)) {
861 extension = extension_dispatcher_->extensions()->GetExtensionOrAppByURL( 861 extension = extension_dispatcher_->extensions()->GetExtensionOrAppByURL(
862 ExtensionURLInfo(failed_url)); 862 ExtensionURLInfo(failed_url));
863 } 863 }
864 864
865 bool is_post = EqualsASCII(failed_request.httpMethod(), "POST"); 865 bool is_post = EqualsASCII(failed_request.httpMethod(), "POST");
866 866
867 if (error_html) { 867 if (error_html) {
868 // Use a local error page. 868 // Use a local error page.
869 int resource_id; 869 int resource_id;
870 base::DictionaryValue error_strings; 870 base::DictionaryValue error_strings;
871 if (extension && !extension->from_bookmark()) { 871 if (extension && !extension->from_bookmark()) {
872 LocalizedError::GetAppErrorStrings(error, failed_url, extension, 872 LocalizedError::GetAppErrorStrings(error, failed_url, extension,
873 &error_strings); 873 &error_strings);
874 874
875 // TODO(erikkay): Should we use a different template for different 875 // TODO(erikkay): Should we use a different template for different
876 // error messages? 876 // error messages?
877 resource_id = IDR_ERROR_APP_HTML; 877 resource_id = IDR_ERROR_APP_HTML;
878 } else { 878 } else {
879 LocalizedError::GetStrings( 879 const std::string locale = RenderThread::Get()->GetLocale();
880 error, 880 if (!NetErrorHelper::GetErrorStringsForDnsProbe(
881 is_post, 881 frame, error, is_post, locale, &error_strings)) {
882 RenderThread::Get()->GetLocale(), 882 // In most cases, the NetErrorHelper won't provide DNS-probe-specific
883 &error_strings); 883 // error pages, so fall back to LocalizedError.
884 LocalizedError::GetStrings(error, is_post, locale, &error_strings);
885 }
884 resource_id = IDR_NET_ERROR_HTML; 886 resource_id = IDR_NET_ERROR_HTML;
885 } 887 }
886 888
887 const base::StringPiece template_html( 889 const base::StringPiece template_html(
888 ResourceBundle::GetSharedInstance().GetRawDataResource( 890 ResourceBundle::GetSharedInstance().GetRawDataResource(
889 resource_id)); 891 resource_id));
890 if (template_html.empty()) { 892 if (template_html.empty()) {
891 NOTREACHED() << "unable to load template. ID: " << resource_id; 893 NOTREACHED() << "unable to load template. ID: " << resource_id;
892 } else { 894 } else {
893 // "t" is the id of the templates root node. 895 // "t" is the id of the templates root node.
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 if (CommandLine::ForCurrentProcess()->HasSwitch( 1278 if (CommandLine::ForCurrentProcess()->HasSwitch(
1277 switches::kEnablePepperTesting)) { 1279 switches::kEnablePepperTesting)) {
1278 return true; 1280 return true;
1279 } 1281 }
1280 #endif // !defined(OS_ANDROID) 1282 #endif // !defined(OS_ANDROID)
1281 return false; 1283 return false;
1282 } 1284 }
1283 1285
1284 1286
1285 } // namespace chrome 1287 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698