| OLD | NEW |
| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "android_webview/browser/aw_browser_context.h" |
| 9 #include "android_webview/common/aw_resource.h" | 10 #include "android_webview/common/aw_resource.h" |
| 10 #include "android_webview/common/aw_switches.h" | 11 #include "android_webview/common/aw_switches.h" |
| 11 #include "android_webview/common/render_view_messages.h" | 12 #include "android_webview/common/render_view_messages.h" |
| 12 #include "android_webview/common/url_constants.h" | 13 #include "android_webview/common/url_constants.h" |
| 13 #include "android_webview/grit/aw_resources.h" | 14 #include "android_webview/grit/aw_resources.h" |
| 14 #include "android_webview/grit/aw_strings.h" | 15 #include "android_webview/grit/aw_strings.h" |
| 15 #include "android_webview/renderer/aw_content_settings_client.h" | 16 #include "android_webview/renderer/aw_content_settings_client.h" |
| 16 #include "android_webview/renderer/aw_key_systems.h" | 17 #include "android_webview/renderer/aw_key_systems.h" |
| 17 #include "android_webview/renderer/aw_message_port_client.h" | 18 #include "android_webview/renderer/aw_message_port_client.h" |
| 18 #include "android_webview/renderer/aw_print_web_view_helper_delegate.h" | 19 #include "android_webview/renderer/aw_print_web_view_helper_delegate.h" |
| 19 #include "android_webview/renderer/aw_render_frame_ext.h" | 20 #include "android_webview/renderer/aw_render_frame_ext.h" |
| 20 #include "android_webview/renderer/aw_render_view_ext.h" | 21 #include "android_webview/renderer/aw_render_view_ext.h" |
| 21 #include "android_webview/renderer/print_render_frame_observer.h" | 22 #include "android_webview/renderer/print_render_frame_observer.h" |
| 22 #include "base/command_line.h" | 23 #include "base/command_line.h" |
| 23 #include "base/i18n/rtl.h" | 24 #include "base/i18n/rtl.h" |
| 24 #include "base/message_loop/message_loop.h" | 25 #include "base/message_loop/message_loop.h" |
| 25 #include "base/strings/string_util.h" | 26 #include "base/strings/string_util.h" |
| 26 #include "base/strings/utf_string_conversions.h" | 27 #include "base/strings/utf_string_conversions.h" |
| 27 #include "components/autofill/content/renderer/autofill_agent.h" | 28 #include "components/autofill/content/renderer/autofill_agent.h" |
| 28 #include "components/autofill/content/renderer/password_autofill_agent.h" | 29 #include "components/autofill/content/renderer/password_autofill_agent.h" |
| 29 #include "components/printing/renderer/print_web_view_helper.h" | 30 #include "components/printing/renderer/print_web_view_helper.h" |
| 30 #include "components/visitedlink/renderer/visitedlink_slave.h" | 31 #include "components/visitedlink/renderer/visitedlink_slave.h" |
| 32 #include "components/web_restriction/web_restriction_gin_wrapper.h" |
| 33 #include "components/web_restriction/web_restriction_provider.h" |
| 31 #include "content/public/common/url_constants.h" | 34 #include "content/public/common/url_constants.h" |
| 32 #include "content/public/renderer/document_state.h" | 35 #include "content/public/renderer/document_state.h" |
| 33 #include "content/public/renderer/navigation_state.h" | 36 #include "content/public/renderer/navigation_state.h" |
| 34 #include "content/public/renderer/render_frame.h" | 37 #include "content/public/renderer/render_frame.h" |
| 35 #include "content/public/renderer/render_thread.h" | 38 #include "content/public/renderer/render_thread.h" |
| 36 #include "content/public/renderer/render_view.h" | 39 #include "content/public/renderer/render_view.h" |
| 37 #include "net/base/escape.h" | 40 #include "net/base/escape.h" |
| 38 #include "net/base/net_errors.h" | 41 #include "net/base/net_errors.h" |
| 39 #include "third_party/WebKit/public/platform/WebString.h" | 42 #include "third_party/WebKit/public/platform/WebString.h" |
| 40 #include "third_party/WebKit/public/platform/WebURL.h" | 43 #include "third_party/WebKit/public/platform/WebURL.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 scoped_ptr<printing::PrintWebViewHelper::Delegate>( | 171 scoped_ptr<printing::PrintWebViewHelper::Delegate>( |
| 169 new AwPrintWebViewHelperDelegate())); | 172 new AwPrintWebViewHelperDelegate())); |
| 170 } | 173 } |
| 171 | 174 |
| 172 bool AwContentRendererClient::HasErrorPage(int http_status_code, | 175 bool AwContentRendererClient::HasErrorPage(int http_status_code, |
| 173 std::string* error_domain) { | 176 std::string* error_domain) { |
| 174 return http_status_code >= 400; | 177 return http_status_code >= 400; |
| 175 } | 178 } |
| 176 | 179 |
| 177 void AwContentRendererClient::GetNavigationErrorStrings( | 180 void AwContentRendererClient::GetNavigationErrorStrings( |
| 178 content::RenderFrame* /* render_frame */, | 181 content::RenderFrame* render_frame, |
| 179 const blink::WebURLRequest& failed_request, | 182 const blink::WebURLRequest& failed_request, |
| 180 const blink::WebURLError& error, | 183 const blink::WebURLError& error, |
| 181 std::string* error_html, | 184 std::string* error_html, |
| 182 base::string16* error_description) { | 185 base::string16* error_description) { |
| 183 if (error_html) { | 186 if (error_html) { |
| 184 std::string url = | 187 std::string url = |
| 185 net::EscapeForHTML(GURL(failed_request.url()).possibly_invalid_spec()); | 188 net::EscapeForHTML(GURL(failed_request.url()).possibly_invalid_spec()); |
| 186 std::string err = | 189 std::string err = |
| 187 base::UTF16ToUTF8(base::StringPiece16(error.localizedDescription)); | 190 base::UTF16ToUTF8(base::StringPiece16(error.localizedDescription)); |
| 188 | 191 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 200 replacements.push_back(err); | 203 replacements.push_back(err); |
| 201 } | 204 } |
| 202 if (base::i18n::IsRTL()) | 205 if (base::i18n::IsRTL()) |
| 203 replacements.push_back("direction: rtl;"); | 206 replacements.push_back("direction: rtl;"); |
| 204 else | 207 else |
| 205 replacements.push_back(""); | 208 replacements.push_back(""); |
| 206 *error_html = base::ReplaceStringPlaceholders( | 209 *error_html = base::ReplaceStringPlaceholders( |
| 207 ResourceBundle::GetSharedInstance().GetRawDataResource( | 210 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 208 IDR_AW_LOAD_ERROR_HTML), | 211 IDR_AW_LOAD_ERROR_HTML), |
| 209 replacements, nullptr); | 212 replacements, nullptr); |
| 213 if (error.reason == net::ERR_BLOCKED_BY_ADMINISTRATOR) { |
| 214 // Move to aw/common/ if chrome's solution is too complicated |
| 215 auto web_restriction_provider = |
| 216 AwBrowserContext::GetDefault()->GetWebRestrictionProvider(); |
| 217 if (web_restriction_provider->SupportsCustomErrorPage()) |
| 218 *error_html = web_restriction_provider->GetErrorHtml(); |
| 219 if (web_restriction_provider->SupportsRequest()) |
| 220 web_restriction::WebRestrictionGinWrapper::Install(render_frame); |
| 221 } |
| 210 } | 222 } |
| 211 if (error_description) { | 223 if (error_description) { |
| 212 if (error.localizedDescription.isEmpty()) | 224 if (error.localizedDescription.isEmpty()) |
| 213 *error_description = base::ASCIIToUTF16(net::ErrorToString(error.reason)); | 225 *error_description = base::ASCIIToUTF16(net::ErrorToString(error.reason)); |
| 214 else | 226 else |
| 215 *error_description = error.localizedDescription; | 227 *error_description = error.localizedDescription; |
| 216 } | 228 } |
| 217 } | 229 } |
| 218 | 230 |
| 219 unsigned long long AwContentRendererClient::VisitedLinkHash( | 231 unsigned long long AwContentRendererClient::VisitedLinkHash( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 236 blink::WebPageVisibilityState* override_state) { | 248 blink::WebPageVisibilityState* override_state) { |
| 237 if (disable_page_visibility_) { | 249 if (disable_page_visibility_) { |
| 238 *override_state = blink::WebPageVisibilityStateVisible; | 250 *override_state = blink::WebPageVisibilityStateVisible; |
| 239 return true; | 251 return true; |
| 240 } | 252 } |
| 241 | 253 |
| 242 return false; | 254 return false; |
| 243 } | 255 } |
| 244 | 256 |
| 245 } // namespace android_webview | 257 } // namespace android_webview |
| OLD | NEW |