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/common/aw_switches.h" | 9 #include "android_webview/common/aw_switches.h" |
10 #include "android_webview/common/render_view_messages.h" | 10 #include "android_webview/common/render_view_messages.h" |
11 #include "android_webview/common/url_constants.h" | 11 #include "android_webview/common/url_constants.h" |
12 #include "android_webview/grit/aw_resources.h" | 12 #include "android_webview/grit/aw_resources.h" |
13 #include "android_webview/grit/aw_strings.h" | 13 #include "android_webview/grit/aw_strings.h" |
14 #include "android_webview/renderer/aw_content_settings_client.h" | 14 #include "android_webview/renderer/aw_content_settings_client.h" |
15 #include "android_webview/renderer/aw_key_systems.h" | 15 #include "android_webview/renderer/aw_key_systems.h" |
16 #include "android_webview/renderer/aw_print_web_view_helper_delegate.h" | 16 #include "android_webview/renderer/aw_print_web_view_helper_delegate.h" |
17 #include "android_webview/renderer/aw_render_frame_ext.h" | 17 #include "android_webview/renderer/aw_render_frame_ext.h" |
18 #include "android_webview/renderer/aw_render_view_ext.h" | 18 #include "android_webview/renderer/aw_render_view_ext.h" |
19 #include "android_webview/renderer/print_render_frame_observer.h" | 19 #include "android_webview/renderer/print_render_frame_observer.h" |
20 #include "base/command_line.h" | 20 #include "base/command_line.h" |
21 #include "base/i18n/rtl.h" | 21 #include "base/i18n/rtl.h" |
22 #include "base/memory/ptr_util.h" | 22 #include "base/memory/ptr_util.h" |
23 #include "base/message_loop/message_loop.h" | 23 #include "base/message_loop/message_loop.h" |
24 #include "base/strings/string_util.h" | 24 #include "base/strings/string_util.h" |
25 #include "base/strings/utf_string_conversions.h" | 25 #include "base/strings/utf_string_conversions.h" |
26 #include "components/autofill/content/renderer/autofill_agent.h" | 26 #include "components/autofill/content/renderer/autofill_agent.h" |
27 #include "components/autofill/content/renderer/password_autofill_agent.h" | 27 #include "components/autofill/content/renderer/password_autofill_agent.h" |
28 #include "components/printing/renderer/print_web_view_helper.h" | 28 #include "components/printing/renderer/print_web_view_helper.h" |
| 29 #include "components/safe_browsing/renderer/websocket_sb_handshake_throttle.h" |
29 #include "components/spellcheck/spellcheck_build_features.h" | 30 #include "components/spellcheck/spellcheck_build_features.h" |
30 #include "components/supervised_user_error_page/gin_wrapper.h" | 31 #include "components/supervised_user_error_page/gin_wrapper.h" |
31 #include "components/supervised_user_error_page/supervised_user_error_page_andro
id.h" | 32 #include "components/supervised_user_error_page/supervised_user_error_page_andro
id.h" |
32 #include "components/visitedlink/renderer/visitedlink_slave.h" | 33 #include "components/visitedlink/renderer/visitedlink_slave.h" |
33 #include "components/web_restrictions/interfaces/web_restrictions.mojom.h" | 34 #include "components/web_restrictions/interfaces/web_restrictions.mojom.h" |
34 #include "content/public/child/child_thread.h" | 35 #include "content/public/child/child_thread.h" |
| 36 #include "content/public/common/content_switches.h" |
35 #include "content/public/common/service_manager_connection.h" | 37 #include "content/public/common/service_manager_connection.h" |
| 38 #include "content/public/common/service_names.mojom.h" |
36 #include "content/public/common/simple_connection_filter.h" | 39 #include "content/public/common/simple_connection_filter.h" |
37 #include "content/public/common/url_constants.h" | 40 #include "content/public/common/url_constants.h" |
38 #include "content/public/renderer/document_state.h" | 41 #include "content/public/renderer/document_state.h" |
39 #include "content/public/renderer/navigation_state.h" | 42 #include "content/public/renderer/navigation_state.h" |
40 #include "content/public/renderer/render_frame.h" | 43 #include "content/public/renderer/render_frame.h" |
41 #include "content/public/renderer/render_thread.h" | 44 #include "content/public/renderer/render_thread.h" |
42 #include "content/public/renderer/render_view.h" | 45 #include "content/public/renderer/render_view.h" |
43 #include "net/base/escape.h" | 46 #include "net/base/escape.h" |
44 #include "net/base/net_errors.h" | 47 #include "net/base/net_errors.h" |
45 #include "services/service_manager/public/cpp/binder_registry.h" | 48 #include "services/service_manager/public/cpp/binder_registry.h" |
| 49 #include "services/service_manager/public/cpp/connector.h" |
46 #include "services/service_manager/public/cpp/interface_provider.h" | 50 #include "services/service_manager/public/cpp/interface_provider.h" |
47 #include "third_party/WebKit/public/platform/WebString.h" | 51 #include "third_party/WebKit/public/platform/WebString.h" |
48 #include "third_party/WebKit/public/platform/WebURL.h" | 52 #include "third_party/WebKit/public/platform/WebURL.h" |
49 #include "third_party/WebKit/public/platform/WebURLError.h" | 53 #include "third_party/WebKit/public/platform/WebURLError.h" |
50 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 54 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
51 #include "third_party/WebKit/public/web/WebFrame.h" | 55 #include "third_party/WebKit/public/web/WebFrame.h" |
52 #include "third_party/WebKit/public/web/WebNavigationType.h" | 56 #include "third_party/WebKit/public/web/WebNavigationType.h" |
53 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 57 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
54 #include "ui/base/l10n/l10n_util.h" | 58 #include "ui/base/l10n/l10n_util.h" |
55 #include "ui/base/resource/resource_bundle.h" | 59 #include "ui/base/resource/resource_bundle.h" |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 | 294 |
291 bool AwContentRendererClient::IsLinkVisited(unsigned long long link_hash) { | 295 bool AwContentRendererClient::IsLinkVisited(unsigned long long link_hash) { |
292 return visited_link_slave_->IsVisited(link_hash); | 296 return visited_link_slave_->IsVisited(link_hash); |
293 } | 297 } |
294 | 298 |
295 void AwContentRendererClient::AddSupportedKeySystems( | 299 void AwContentRendererClient::AddSupportedKeySystems( |
296 std::vector<std::unique_ptr<::media::KeySystemProperties>>* key_systems) { | 300 std::vector<std::unique_ptr<::media::KeySystemProperties>>* key_systems) { |
297 AwAddKeySystems(key_systems); | 301 AwAddKeySystems(key_systems); |
298 } | 302 } |
299 | 303 |
| 304 std::unique_ptr<blink::WebSocketHandshakeThrottle> |
| 305 AwContentRendererClient::CreateWebSocketHandshakeThrottle() { |
| 306 if (!UsingSafeBrowsingMojoService()) |
| 307 return nullptr; |
| 308 return base::MakeUnique<safe_browsing::WebSocketSBHandshakeThrottle>( |
| 309 safe_browsing_.get()); |
| 310 } |
| 311 |
300 bool AwContentRendererClient::ShouldUseMediaPlayerForURL(const GURL& url) { | 312 bool AwContentRendererClient::ShouldUseMediaPlayerForURL(const GURL& url) { |
301 // Android WebView needs to support codecs that Chrome does not, for these | 313 // Android WebView needs to support codecs that Chrome does not, for these |
302 // cases we must force the usage of Android MediaPlayer instead of Chrome's | 314 // cases we must force the usage of Android MediaPlayer instead of Chrome's |
303 // internal player. | 315 // internal player. |
304 // | 316 // |
305 // Note: Despite these extensions being forwarded for playback to MediaPlayer, | 317 // Note: Despite these extensions being forwarded for playback to MediaPlayer, |
306 // HTMLMediaElement.canPlayType() will return empty for these containers. | 318 // HTMLMediaElement.canPlayType() will return empty for these containers. |
307 // TODO(boliu): If this is important, extend media::MimeUtil for WebView. | 319 // TODO(boliu): If this is important, extend media::MimeUtil for WebView. |
308 // | 320 // |
309 // Format list mirrors: | 321 // Format list mirrors: |
310 // http://developer.android.com/guide/appendix/media-formats.html | 322 // http://developer.android.com/guide/appendix/media-formats.html |
311 static const char* kMediaPlayerExtensions[] = { | 323 static const char* kMediaPlayerExtensions[] = { |
312 ".3gp", ".ts", ".flac", ".mid", ".xmf", | 324 ".3gp", ".ts", ".flac", ".mid", ".xmf", |
313 ".mxmf", ".rtttl", ".rtx", ".ota", ".imy"}; | 325 ".mxmf", ".rtttl", ".rtx", ".ota", ".imy"}; |
314 for (auto* extension : kMediaPlayerExtensions) { | 326 for (auto* extension : kMediaPlayerExtensions) { |
315 if (base::EndsWith(url.path(), extension, | 327 if (base::EndsWith(url.path(), extension, |
316 base::CompareCase::INSENSITIVE_ASCII)) { | 328 base::CompareCase::INSENSITIVE_ASCII)) { |
317 return true; | 329 return true; |
318 } | 330 } |
319 } | 331 } |
320 return false; | 332 return false; |
321 } | 333 } |
322 | 334 |
| 335 bool AwContentRendererClient::UsingSafeBrowsingMojoService() { |
| 336 if (safe_browsing_) |
| 337 return true; |
| 338 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 339 switches::kEnableNetworkService)) { |
| 340 return false; |
| 341 } |
| 342 RenderThread::Get()->GetConnector()->BindInterface( |
| 343 content::mojom::kBrowserServiceName, &safe_browsing_); |
| 344 return true; |
| 345 } |
| 346 |
323 } // namespace android_webview | 347 } // namespace android_webview |
OLD | NEW |