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

Side by Side Diff: android_webview/renderer/aw_content_renderer_client.cc

Issue 15979017: [Android WebView] Provide a minimal error description for nav errors (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added a test 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "android_webview/renderer/aw_content_renderer_client.h" 5 #include "android_webview/renderer/aw_content_renderer_client.h"
6 6
7 #include "android_webview/common/aw_resource.h" 7 #include "android_webview/common/aw_resource.h"
8 #include "android_webview/common/url_constants.h" 8 #include "android_webview/common/url_constants.h"
9 #include "android_webview/renderer/aw_render_view_ext.h" 9 #include "android_webview/renderer/aw_render_view_ext.h"
10 #include "android_webview/renderer/view_renderer.h" 10 #include "android_webview/renderer/view_renderer.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "components/visitedlink/renderer/visitedlink_slave.h" 13 #include "components/visitedlink/renderer/visitedlink_slave.h"
14 #include "content/public/renderer/render_thread.h" 14 #include "content/public/renderer/render_thread.h"
15 #include "googleurl/src/gurl.h" 15 #include "googleurl/src/gurl.h"
16 #include "net/base/net_errors.h"
16 #include "third_party/WebKit/public/platform/WebString.h" 17 #include "third_party/WebKit/public/platform/WebString.h"
17 #include "third_party/WebKit/public/platform/WebURL.h" 18 #include "third_party/WebKit/public/platform/WebURL.h"
18 #include "third_party/WebKit/public/platform/WebURLError.h" 19 #include "third_party/WebKit/public/platform/WebURLError.h"
19 #include "third_party/WebKit/public/platform/WebURLRequest.h" 20 #include "third_party/WebKit/public/platform/WebURLRequest.h"
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h"
21 22
22 namespace android_webview { 23 namespace android_webview {
23 24
24 AwContentRendererClient::AwContentRendererClient() { 25 AwContentRendererClient::AwContentRendererClient() {
25 } 26 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 const WebKit::WebURLRequest& failed_request, 62 const WebKit::WebURLRequest& failed_request,
62 const WebKit::WebURLError& error, 63 const WebKit::WebURLError& error,
63 std::string* error_html, 64 std::string* error_html,
64 string16* error_description) { 65 string16* error_description) {
65 if (error_html) { 66 if (error_html) {
66 GURL error_url(failed_request.url()); 67 GURL error_url(failed_request.url());
67 std::string err = UTF16ToUTF8(error.localizedDescription); 68 std::string err = UTF16ToUTF8(error.localizedDescription);
68 std::string contents; 69 std::string contents;
69 if (err.empty()) { 70 if (err.empty()) {
70 contents = AwResource::GetNoDomainPageContent(); 71 contents = AwResource::GetNoDomainPageContent();
72 if (error_description)
73 *error_description = ASCIIToUTF16(net::ErrorToString(error.reason));
71 } else { 74 } else {
72 contents = AwResource::GetLoadErrorPageContent(); 75 contents = AwResource::GetLoadErrorPageContent();
73 ReplaceSubstringsAfterOffset(&contents, 0, "%e", err); 76 ReplaceSubstringsAfterOffset(&contents, 0, "%e", err);
77 if (error_description)
78 *error_description = error.localizedDescription;
74 } 79 }
75 80
76 ReplaceSubstringsAfterOffset(&contents, 0, "%s", 81 ReplaceSubstringsAfterOffset(&contents, 0, "%s",
77 error_url.possibly_invalid_spec()); 82 error_url.possibly_invalid_spec());
78 *error_html = contents; 83 *error_html = contents;
79 } 84 }
80 } 85 }
81 86
82 unsigned long long AwContentRendererClient::VisitedLinkHash( 87 unsigned long long AwContentRendererClient::VisitedLinkHash(
83 const char* canonical_url, 88 const char* canonical_url,
84 size_t length) { 89 size_t length) {
85 return visited_link_slave_->ComputeURLFingerprint(canonical_url, length); 90 return visited_link_slave_->ComputeURLFingerprint(canonical_url, length);
86 } 91 }
87 92
88 bool AwContentRendererClient::IsLinkVisited(unsigned long long link_hash) { 93 bool AwContentRendererClient::IsLinkVisited(unsigned long long link_hash) {
89 return visited_link_slave_->IsVisited(link_hash); 94 return visited_link_slave_->IsVisited(link_hash);
90 } 95 }
91 96
92 void AwContentRendererClient::PrefetchHostName(const char* hostname, 97 void AwContentRendererClient::PrefetchHostName(const char* hostname,
93 size_t length) { 98 size_t length) {
94 // TODO(boliu): Implement hostname prefetch for Android WebView. 99 // TODO(boliu): Implement hostname prefetch for Android WebView.
95 // Perhaps componentize chrome implementation or move to content/? 100 // Perhaps componentize chrome implementation or move to content/?
96 } 101 }
97 102
98 } // namespace android_webview 103 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698