OLD | NEW |
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 "content/renderer/renderer_webkitplatformsupport_impl.h" | 5 #include "content/renderer/renderer_webkitplatformsupport_impl.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 #include "content/renderer/media/webcontentdecryptionmodule_impl.h" | 34 #include "content/renderer/media/webcontentdecryptionmodule_impl.h" |
35 #include "content/renderer/render_thread_impl.h" | 35 #include "content/renderer/render_thread_impl.h" |
36 #include "content/renderer/renderer_clipboard_client.h" | 36 #include "content/renderer/renderer_clipboard_client.h" |
37 #include "content/renderer/webclipboard_impl.h" | 37 #include "content/renderer/webclipboard_impl.h" |
38 #include "content/renderer/websharedworkerrepository_impl.h" | 38 #include "content/renderer/websharedworkerrepository_impl.h" |
39 #include "googleurl/src/gurl.h" | 39 #include "googleurl/src/gurl.h" |
40 #include "gpu/config/gpu_info.h" | 40 #include "gpu/config/gpu_info.h" |
41 #include "ipc/ipc_sync_message_filter.h" | 41 #include "ipc/ipc_sync_message_filter.h" |
42 #include "media/audio/audio_output_device.h" | 42 #include "media/audio/audio_output_device.h" |
43 #include "media/base/audio_hardware_config.h" | 43 #include "media/base/audio_hardware_config.h" |
| 44 #include "media/filters/stream_parser_factory.h" |
| 45 #include "net/base/mime_util.h" |
44 #include "net/base/net_util.h" | 46 #include "net/base/net_util.h" |
45 #include "third_party/WebKit/public/web/WebFrame.h" | 47 #include "third_party/WebKit/public/web/WebFrame.h" |
46 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 48 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
47 #include "third_party/WebKit/public/platform/WebBlobRegistry.h" | 49 #include "third_party/WebKit/public/platform/WebBlobRegistry.h" |
48 #include "third_party/WebKit/public/platform/WebFileInfo.h" | 50 #include "third_party/WebKit/public/platform/WebFileInfo.h" |
49 #include "third_party/WebKit/public/platform/WebGamepads.h" | 51 #include "third_party/WebKit/public/platform/WebGamepads.h" |
50 #include "third_party/WebKit/public/platform/WebHyphenator.h" | 52 #include "third_party/WebKit/public/platform/WebHyphenator.h" |
51 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h" | 53 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h" |
52 #include "third_party/WebKit/public/platform/WebMediaStreamCenterClient.h" | 54 #include "third_party/WebKit/public/platform/WebMediaStreamCenterClient.h" |
53 #include "third_party/WebKit/public/platform/WebURL.h" | 55 #include "third_party/WebKit/public/platform/WebURL.h" |
54 #include "third_party/WebKit/public/platform/WebVector.h" | 56 #include "third_party/WebKit/public/platform/WebVector.h" |
55 #include "webkit/base/file_path_string_conversions.h" | 57 #include "webkit/base/file_path_string_conversions.h" |
56 #include "webkit/common/gpu/webgraphicscontext3d_provider_impl.h" | 58 #include "webkit/common/gpu/webgraphicscontext3d_provider_impl.h" |
57 #include "webkit/glue/simple_webmimeregistry_impl.h" | 59 #include "webkit/glue/simple_webmimeregistry_impl.h" |
58 #include "webkit/glue/webfileutilities_impl.h" | 60 #include "webkit/glue/webfileutilities_impl.h" |
59 #include "webkit/glue/webkit_glue.h" | 61 #include "webkit/glue/webkit_glue.h" |
60 #include "webkit/renderer/media/audio_decoder.h" | 62 #include "webkit/renderer/media/audio_decoder.h" |
| 63 #include "webkit/renderer/media/crypto/key_systems.h" |
61 | 64 |
62 #if defined(OS_WIN) | 65 #if defined(OS_WIN) |
63 #include "content/common/child_process_messages.h" | 66 #include "content/common/child_process_messages.h" |
64 #include "third_party/WebKit/public/platform/win/WebSandboxSupport.h" | 67 #include "third_party/WebKit/public/platform/win/WebSandboxSupport.h" |
65 #endif | 68 #endif |
66 | 69 |
67 #if defined(OS_MACOSX) | 70 #if defined(OS_MACOSX) |
68 #include "content/common/mac/font_descriptor.h" | 71 #include "content/common/mac/font_descriptor.h" |
69 #include "content/common/mac/font_loader.h" | 72 #include "content/common/mac/font_loader.h" |
70 #include "third_party/WebKit/public/platform/mac/WebSandboxSupport.h" | 73 #include "third_party/WebKit/public/platform/mac/WebSandboxSupport.h" |
(...skipping 16 matching lines...) Expand all Loading... |
87 using WebKit::WebAudioDevice; | 90 using WebKit::WebAudioDevice; |
88 using WebKit::WebBlobRegistry; | 91 using WebKit::WebBlobRegistry; |
89 using WebKit::WebFileInfo; | 92 using WebKit::WebFileInfo; |
90 using WebKit::WebFileSystem; | 93 using WebKit::WebFileSystem; |
91 using WebKit::WebFrame; | 94 using WebKit::WebFrame; |
92 using WebKit::WebGamepads; | 95 using WebKit::WebGamepads; |
93 using WebKit::WebIDBFactory; | 96 using WebKit::WebIDBFactory; |
94 using WebKit::Platform; | 97 using WebKit::Platform; |
95 using WebKit::WebMediaStreamCenter; | 98 using WebKit::WebMediaStreamCenter; |
96 using WebKit::WebMediaStreamCenterClient; | 99 using WebKit::WebMediaStreamCenterClient; |
| 100 using WebKit::WebMimeRegistry; |
97 using WebKit::WebRTCPeerConnectionHandler; | 101 using WebKit::WebRTCPeerConnectionHandler; |
98 using WebKit::WebRTCPeerConnectionHandlerClient; | 102 using WebKit::WebRTCPeerConnectionHandlerClient; |
99 using WebKit::WebStorageNamespace; | 103 using WebKit::WebStorageNamespace; |
100 using WebKit::WebString; | 104 using WebKit::WebString; |
101 using WebKit::WebURL; | 105 using WebKit::WebURL; |
102 using WebKit::WebVector; | 106 using WebKit::WebVector; |
103 | 107 |
104 namespace content { | 108 namespace content { |
105 | 109 |
106 static bool g_sandbox_enabled = true; | 110 static bool g_sandbox_enabled = true; |
107 base::LazyInstance<WebGamepads>::Leaky g_test_gamepads = | 111 base::LazyInstance<WebGamepads>::Leaky g_test_gamepads = |
108 LAZY_INSTANCE_INITIALIZER; | 112 LAZY_INSTANCE_INITIALIZER; |
109 | 113 |
110 //------------------------------------------------------------------------------ | 114 //------------------------------------------------------------------------------ |
111 | 115 |
112 class RendererWebKitPlatformSupportImpl::MimeRegistry | 116 class RendererWebKitPlatformSupportImpl::MimeRegistry |
113 : public webkit_glue::SimpleWebMimeRegistryImpl { | 117 : public webkit_glue::SimpleWebMimeRegistryImpl { |
114 public: | 118 public: |
115 virtual WebKit::WebString mimeTypeForExtension(const WebKit::WebString&); | 119 // TODO(ddorwin): Remove after http://webk.it/82983 lands. |
116 virtual WebKit::WebString mimeTypeFromFile(const WebKit::WebString&); | 120 virtual WebKit::WebMimeRegistry::SupportsType supportsMediaMIMEType( |
| 121 const WebKit::WebString& mime_type, |
| 122 const WebKit::WebString& codecs); |
| 123 virtual WebKit::WebMimeRegistry::SupportsType supportsMediaMIMEType( |
| 124 const WebKit::WebString& mime_type, |
| 125 const WebKit::WebString& codecs, |
| 126 const WebKit::WebString& key_system); |
| 127 virtual bool supportsMediaSourceMIMEType(const WebKit::WebString& mime_type, |
| 128 const WebKit::WebString& codecs); |
| 129 virtual WebKit::WebString mimeTypeForExtension( |
| 130 const WebKit::WebString& file_extension); |
| 131 virtual WebKit::WebString mimeTypeFromFile( |
| 132 const WebKit::WebString& file_path); |
117 virtual WebKit::WebString preferredExtensionForMIMEType( | 133 virtual WebKit::WebString preferredExtensionForMIMEType( |
118 const WebKit::WebString&); | 134 const WebKit::WebString& mime_type); |
119 }; | 135 }; |
120 | 136 |
121 class RendererWebKitPlatformSupportImpl::FileUtilities | 137 class RendererWebKitPlatformSupportImpl::FileUtilities |
122 : public webkit_glue::WebFileUtilitiesImpl { | 138 : public webkit_glue::WebFileUtilitiesImpl { |
123 public: | 139 public: |
124 explicit FileUtilities(ThreadSafeSender* sender) | 140 explicit FileUtilities(ThreadSafeSender* sender) |
125 : thread_safe_sender_(sender) {} | 141 : thread_safe_sender_(sender) {} |
126 virtual bool getFileInfo(const WebString& path, WebFileInfo& result); | 142 virtual bool getFileInfo(const WebString& path, WebFileInfo& result); |
127 virtual base::PlatformFile openFile(const WebKit::WebString& path, | 143 virtual base::PlatformFile openFile(const WebKit::WebString& path, |
128 int mode); | 144 int mode); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 | 232 |
217 WebKit::WebClipboard* RendererWebKitPlatformSupportImpl::clipboard() { | 233 WebKit::WebClipboard* RendererWebKitPlatformSupportImpl::clipboard() { |
218 WebKit::WebClipboard* clipboard = | 234 WebKit::WebClipboard* clipboard = |
219 GetContentClient()->renderer()->OverrideWebClipboard(); | 235 GetContentClient()->renderer()->OverrideWebClipboard(); |
220 if (clipboard) | 236 if (clipboard) |
221 return clipboard; | 237 return clipboard; |
222 return clipboard_.get(); | 238 return clipboard_.get(); |
223 } | 239 } |
224 | 240 |
225 WebKit::WebMimeRegistry* RendererWebKitPlatformSupportImpl::mimeRegistry() { | 241 WebKit::WebMimeRegistry* RendererWebKitPlatformSupportImpl::mimeRegistry() { |
226 WebKit::WebMimeRegistry* mime_registry = | |
227 GetContentClient()->renderer()->OverrideWebMimeRegistry(); | |
228 if (mime_registry) | |
229 return mime_registry; | |
230 return mime_registry_.get(); | 242 return mime_registry_.get(); |
231 } | 243 } |
232 | 244 |
233 WebKit::WebFileUtilities* | 245 WebKit::WebFileUtilities* |
234 RendererWebKitPlatformSupportImpl::fileUtilities() { | 246 RendererWebKitPlatformSupportImpl::fileUtilities() { |
235 if (!file_utilities_) { | 247 if (!file_utilities_) { |
236 file_utilities_.reset(new FileUtilities(thread_safe_sender_.get())); | 248 file_utilities_.reset(new FileUtilities(thread_safe_sender_.get())); |
237 file_utilities_->set_sandbox_enabled(sandboxEnabled()); | 249 file_utilities_->set_sandbox_enabled(sandboxEnabled()); |
238 } | 250 } |
239 return file_utilities_.get(); | 251 return file_utilities_.get(); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 //------------------------------------------------------------------------------ | 385 //------------------------------------------------------------------------------ |
374 | 386 |
375 WebFileSystem* RendererWebKitPlatformSupportImpl::fileSystem() { | 387 WebFileSystem* RendererWebKitPlatformSupportImpl::fileSystem() { |
376 if (!web_file_system_) | 388 if (!web_file_system_) |
377 web_file_system_.reset(new WebFileSystemImpl()); | 389 web_file_system_.reset(new WebFileSystemImpl()); |
378 return web_file_system_.get(); | 390 return web_file_system_.get(); |
379 } | 391 } |
380 | 392 |
381 //------------------------------------------------------------------------------ | 393 //------------------------------------------------------------------------------ |
382 | 394 |
| 395 WebMimeRegistry::SupportsType |
| 396 RendererWebKitPlatformSupportImpl::MimeRegistry::supportsMediaMIMEType( |
| 397 const WebString& mime_type, |
| 398 const WebString& codecs) { |
| 399 return supportsMediaMIMEType(mime_type, codecs, WebString()); |
| 400 } |
| 401 |
| 402 WebMimeRegistry::SupportsType |
| 403 RendererWebKitPlatformSupportImpl::MimeRegistry::supportsMediaMIMEType( |
| 404 const WebString& mime_type, |
| 405 const WebString& codecs, |
| 406 const WebString& key_system) { |
| 407 const std::string mime_type_ascii = ToASCIIOrEmpty(mime_type); |
| 408 // Not supporting the container is a flat-out no. |
| 409 if (!net::IsSupportedMediaMimeType(mime_type_ascii)) |
| 410 return IsNotSupported; |
| 411 |
| 412 if (!key_system.isEmpty()) { |
| 413 // Check whether the key system is supported with the mime_type and codecs. |
| 414 |
| 415 // Not supporting the key system is a flat-out no. |
| 416 if (!webkit_media::IsSupportedKeySystem(key_system)) |
| 417 return IsNotSupported; |
| 418 |
| 419 std::vector<std::string> strict_codecs; |
| 420 bool strip_suffix = !net::IsStrictMediaMimeType(mime_type_ascii); |
| 421 net::ParseCodecString(ToASCIIOrEmpty(codecs), &strict_codecs, strip_suffix); |
| 422 |
| 423 if (!webkit_media::IsSupportedKeySystemWithMediaMimeType( |
| 424 mime_type_ascii, strict_codecs, ToASCIIOrEmpty(key_system))) |
| 425 return IsNotSupported; |
| 426 |
| 427 // Continue processing the mime_type and codecs. |
| 428 } |
| 429 |
| 430 // Check list of strict codecs to see if it is supported. |
| 431 if (net::IsStrictMediaMimeType(mime_type_ascii)) { |
| 432 // We support the container, but no codecs were specified. |
| 433 if (codecs.isNull()) |
| 434 return MayBeSupported; |
| 435 |
| 436 // Check if the codecs are a perfect match. |
| 437 std::vector<std::string> strict_codecs; |
| 438 net::ParseCodecString(ToASCIIOrEmpty(codecs), &strict_codecs, false); |
| 439 if (!net::IsSupportedStrictMediaMimeType(mime_type_ascii, strict_codecs)) |
| 440 return IsNotSupported; |
| 441 |
| 442 // Good to go! |
| 443 return IsSupported; |
| 444 } |
| 445 |
| 446 // If we don't recognize the codec, it's possible we support it. |
| 447 std::vector<std::string> parsed_codecs; |
| 448 net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codecs, true); |
| 449 if (!net::AreSupportedMediaCodecs(parsed_codecs)) |
| 450 return MayBeSupported; |
| 451 |
| 452 // Otherwise we have a perfect match. |
| 453 return IsSupported; |
| 454 } |
| 455 |
| 456 bool |
| 457 RendererWebKitPlatformSupportImpl::MimeRegistry::supportsMediaSourceMIMEType( |
| 458 const WebKit::WebString& mime_type, |
| 459 const WebString& codecs) { |
| 460 const std::string mime_type_ascii = ToASCIIOrEmpty(mime_type); |
| 461 std::vector<std::string> parsed_codec_ids; |
| 462 net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codec_ids, false); |
| 463 if (mime_type_ascii.empty() || parsed_codec_ids.size() == 0) |
| 464 return false; |
| 465 return media::StreamParserFactory::IsTypeSupported( |
| 466 mime_type_ascii, parsed_codec_ids); |
| 467 } |
| 468 |
383 WebString | 469 WebString |
384 RendererWebKitPlatformSupportImpl::MimeRegistry::mimeTypeForExtension( | 470 RendererWebKitPlatformSupportImpl::MimeRegistry::mimeTypeForExtension( |
385 const WebString& file_extension) { | 471 const WebString& file_extension) { |
386 if (IsPluginProcess()) | 472 if (IsPluginProcess()) |
387 return SimpleWebMimeRegistryImpl::mimeTypeForExtension(file_extension); | 473 return SimpleWebMimeRegistryImpl::mimeTypeForExtension(file_extension); |
388 | 474 |
389 // The sandbox restricts our access to the registry, so we need to proxy | 475 // The sandbox restricts our access to the registry, so we need to proxy |
390 // these calls over to the browser process. | 476 // these calls over to the browser process. |
391 std::string mime_type; | 477 std::string mime_type; |
392 RenderThread::Get()->Send( | 478 RenderThread::Get()->Send( |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 | 1031 |
946 //------------------------------------------------------------------------------ | 1032 //------------------------------------------------------------------------------ |
947 | 1033 |
948 WebKit::WebString RendererWebKitPlatformSupportImpl::convertIDNToUnicode( | 1034 WebKit::WebString RendererWebKitPlatformSupportImpl::convertIDNToUnicode( |
949 const WebKit::WebString& host, | 1035 const WebKit::WebString& host, |
950 const WebKit::WebString& languages) { | 1036 const WebKit::WebString& languages) { |
951 return net::IDNToUnicode(host.utf8(), languages.utf8()); | 1037 return net::IDNToUnicode(host.utf8(), languages.utf8()); |
952 } | 1038 } |
953 | 1039 |
954 } // namespace content | 1040 } // namespace content |
OLD | NEW |