Chromium Code Reviews| 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 22 matching lines...) Expand all Loading... | |
| 33 #include "content/renderer/media/renderer_webaudiodevice_impl.h" | 33 #include "content/renderer/media/renderer_webaudiodevice_impl.h" |
| 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/websharedworkerrepository_impl.h" | 37 #include "content/renderer/websharedworkerrepository_impl.h" |
| 38 #include "googleurl/src/gurl.h" | 38 #include "googleurl/src/gurl.h" |
| 39 #include "gpu/config/gpu_info.h" | 39 #include "gpu/config/gpu_info.h" |
| 40 #include "ipc/ipc_sync_message_filter.h" | 40 #include "ipc/ipc_sync_message_filter.h" |
| 41 #include "media/audio/audio_output_device.h" | 41 #include "media/audio/audio_output_device.h" |
| 42 #include "media/base/audio_hardware_config.h" | 42 #include "media/base/audio_hardware_config.h" |
| 43 #include "media/filters/stream_parser_factory.h" | |
| 44 #include "net/base/mime_util.h" | |
| 43 #include "net/base/net_util.h" | 45 #include "net/base/net_util.h" |
| 44 #include "third_party/WebKit/public/web/WebFrame.h" | 46 #include "third_party/WebKit/public/web/WebFrame.h" |
| 45 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 47 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
| 46 #include "third_party/WebKit/public/platform/WebBlobRegistry.h" | 48 #include "third_party/WebKit/public/platform/WebBlobRegistry.h" |
| 47 #include "third_party/WebKit/public/platform/WebFileInfo.h" | 49 #include "third_party/WebKit/public/platform/WebFileInfo.h" |
| 48 #include "third_party/WebKit/public/platform/WebGamepads.h" | 50 #include "third_party/WebKit/public/platform/WebGamepads.h" |
| 49 #include "third_party/WebKit/public/platform/WebHyphenator.h" | 51 #include "third_party/WebKit/public/platform/WebHyphenator.h" |
| 50 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h" | 52 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h" |
| 51 #include "third_party/WebKit/public/platform/WebMediaStreamCenterClient.h" | 53 #include "third_party/WebKit/public/platform/WebMediaStreamCenterClient.h" |
| 52 #include "third_party/WebKit/public/platform/WebURL.h" | 54 #include "third_party/WebKit/public/platform/WebURL.h" |
| 53 #include "third_party/WebKit/public/platform/WebVector.h" | 55 #include "third_party/WebKit/public/platform/WebVector.h" |
| 54 #include "webkit/base/file_path_string_conversions.h" | 56 #include "webkit/base/file_path_string_conversions.h" |
| 55 #include "webkit/common/gpu/webgraphicscontext3d_provider_impl.h" | 57 #include "webkit/common/gpu/webgraphicscontext3d_provider_impl.h" |
| 56 #include "webkit/glue/simple_webmimeregistry_impl.h" | 58 #include "webkit/glue/simple_webmimeregistry_impl.h" |
| 57 #include "webkit/glue/webclipboard_impl.h" | 59 #include "webkit/glue/webclipboard_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: |
| 119 // TODO(ddorwin): Remove after http://webk.it/82983 lands. | |
| 120 virtual WebKit::WebMimeRegistry::SupportsType supportsMediaMIMEType( | |
| 121 const WebKit::WebString&, const WebKit::WebString&); | |
| 122 virtual WebKit::WebMimeRegistry::SupportsType supportsMediaMIMEType( | |
| 123 const WebKit::WebString&, | |
| 124 const WebKit::WebString&, | |
| 125 const WebKit::WebString&); | |
| 126 virtual bool supportsMediaSourceMIMEType(const WebKit::WebString&, | |
| 127 const WebKit::WebString&); | |
| 115 virtual WebKit::WebString mimeTypeForExtension(const WebKit::WebString&); | 128 virtual WebKit::WebString mimeTypeForExtension(const WebKit::WebString&); |
| 116 virtual WebKit::WebString mimeTypeFromFile(const WebKit::WebString&); | 129 virtual WebKit::WebString mimeTypeFromFile(const WebKit::WebString&); |
| 117 virtual WebKit::WebString preferredExtensionForMIMEType( | 130 virtual WebKit::WebString preferredExtensionForMIMEType( |
| 118 const WebKit::WebString&); | 131 const WebKit::WebString&); |
| 119 }; | 132 }; |
| 120 | 133 |
| 121 class RendererWebKitPlatformSupportImpl::FileUtilities | 134 class RendererWebKitPlatformSupportImpl::FileUtilities |
| 122 : public webkit_glue::WebFileUtilitiesImpl { | 135 : public webkit_glue::WebFileUtilitiesImpl { |
| 123 public: | 136 public: |
| 124 explicit FileUtilities(ThreadSafeSender* sender) | 137 explicit FileUtilities(ThreadSafeSender* sender) |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 373 //------------------------------------------------------------------------------ | 386 //------------------------------------------------------------------------------ |
| 374 | 387 |
| 375 WebFileSystem* RendererWebKitPlatformSupportImpl::fileSystem() { | 388 WebFileSystem* RendererWebKitPlatformSupportImpl::fileSystem() { |
| 376 if (!web_file_system_) | 389 if (!web_file_system_) |
| 377 web_file_system_.reset(new WebFileSystemImpl()); | 390 web_file_system_.reset(new WebFileSystemImpl()); |
| 378 return web_file_system_.get(); | 391 return web_file_system_.get(); |
| 379 } | 392 } |
| 380 | 393 |
| 381 //------------------------------------------------------------------------------ | 394 //------------------------------------------------------------------------------ |
| 382 | 395 |
| 396 // When debugging layout tests failures in the test shell, | |
| 397 // see TestShellWebMimeRegistryImpl. | |
|
jochen (gone - plz use gerrit)
2013/06/20 10:39:44
TestShellWMRI doesn't exist anymore, no?
scherkus (not reviewing)
2013/06/20 22:28:42
Done.
| |
| 398 WebMimeRegistry::SupportsType | |
| 399 RendererWebKitPlatformSupportImpl::MimeRegistry::supportsMediaMIMEType( | |
| 400 const WebString& mime_type, | |
| 401 const WebString& codecs) { | |
| 402 return supportsMediaMIMEType(mime_type, codecs, WebString()); | |
| 403 } | |
| 404 | |
| 405 WebMimeRegistry::SupportsType | |
| 406 RendererWebKitPlatformSupportImpl::MimeRegistry::supportsMediaMIMEType( | |
| 407 const WebString& mime_type, | |
| 408 const WebString& codecs, | |
| 409 const WebString& key_system) { | |
| 410 const std::string mime_type_ascii = ToASCIIOrEmpty(mime_type); | |
| 411 // Not supporting the container is a flat-out no. | |
| 412 if (!net::IsSupportedMediaMimeType(mime_type_ascii)) | |
| 413 return IsNotSupported; | |
| 414 | |
| 415 if (!key_system.isEmpty()) { | |
| 416 // Check whether the key system is supported with the mime_type and codecs. | |
| 417 | |
| 418 // Not supporting the key system is a flat-out no. | |
| 419 if (!webkit_media::IsSupportedKeySystem(key_system)) | |
| 420 return IsNotSupported; | |
| 421 | |
| 422 std::vector<std::string> strict_codecs; | |
| 423 bool strip_suffix = !net::IsStrictMediaMimeType(mime_type_ascii); | |
| 424 net::ParseCodecString(ToASCIIOrEmpty(codecs), &strict_codecs, strip_suffix); | |
| 425 | |
| 426 if (!webkit_media::IsSupportedKeySystemWithMediaMimeType( | |
| 427 mime_type_ascii, strict_codecs, ToASCIIOrEmpty(key_system))) | |
| 428 return IsNotSupported; | |
| 429 | |
| 430 // Continue processing the mime_type and codecs. | |
| 431 } | |
| 432 | |
| 433 // Check list of strict codecs to see if it is supported. | |
| 434 if (net::IsStrictMediaMimeType(mime_type_ascii)) { | |
| 435 // We support the container, but no codecs were specified. | |
| 436 if (codecs.isNull()) | |
| 437 return MayBeSupported; | |
| 438 | |
| 439 // Check if the codecs are a perfect match. | |
| 440 std::vector<std::string> strict_codecs; | |
| 441 net::ParseCodecString(ToASCIIOrEmpty(codecs), &strict_codecs, false); | |
| 442 if (!net::IsSupportedStrictMediaMimeType(mime_type_ascii, strict_codecs)) | |
| 443 return IsNotSupported; | |
| 444 | |
| 445 // Good to go! | |
| 446 return IsSupported; | |
| 447 } | |
| 448 | |
| 449 // If we don't recognize the codec, it's possible we support it. | |
| 450 std::vector<std::string> parsed_codecs; | |
| 451 net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codecs, true); | |
| 452 if (!net::AreSupportedMediaCodecs(parsed_codecs)) | |
| 453 return MayBeSupported; | |
| 454 | |
| 455 // Otherwise we have a perfect match. | |
| 456 return IsSupported; | |
| 457 } | |
| 458 | |
| 459 bool | |
| 460 RendererWebKitPlatformSupportImpl::MimeRegistry::supportsMediaSourceMIMEType( | |
| 461 const WebKit::WebString& mime_type, | |
| 462 const WebString& codecs) { | |
| 463 const std::string mime_type_ascii = ToASCIIOrEmpty(mime_type); | |
| 464 std::vector<std::string> parsed_codec_ids; | |
| 465 net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codec_ids, false); | |
| 466 if (mime_type_ascii.empty() || parsed_codec_ids.size() == 0) | |
| 467 return false; | |
| 468 return media::StreamParserFactory::IsTypeSupported( | |
| 469 mime_type_ascii, parsed_codec_ids); | |
| 470 } | |
| 471 | |
| 383 WebString | 472 WebString |
| 384 RendererWebKitPlatformSupportImpl::MimeRegistry::mimeTypeForExtension( | 473 RendererWebKitPlatformSupportImpl::MimeRegistry::mimeTypeForExtension( |
| 385 const WebString& file_extension) { | 474 const WebString& file_extension) { |
| 386 if (IsPluginProcess()) | 475 if (IsPluginProcess()) |
| 387 return SimpleWebMimeRegistryImpl::mimeTypeForExtension(file_extension); | 476 return SimpleWebMimeRegistryImpl::mimeTypeForExtension(file_extension); |
| 388 | 477 |
| 389 // The sandbox restricts our access to the registry, so we need to proxy | 478 // The sandbox restricts our access to the registry, so we need to proxy |
| 390 // these calls over to the browser process. | 479 // these calls over to the browser process. |
| 391 std::string mime_type; | 480 std::string mime_type; |
| 392 RenderThread::Get()->Send( | 481 RenderThread::Get()->Send( |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 945 | 1034 |
| 946 //------------------------------------------------------------------------------ | 1035 //------------------------------------------------------------------------------ |
| 947 | 1036 |
| 948 WebKit::WebString RendererWebKitPlatformSupportImpl::convertIDNToUnicode( | 1037 WebKit::WebString RendererWebKitPlatformSupportImpl::convertIDNToUnicode( |
| 949 const WebKit::WebString& host, | 1038 const WebKit::WebString& host, |
| 950 const WebKit::WebString& languages) { | 1039 const WebKit::WebString& languages) { |
| 951 return net::IDNToUnicode(host.utf8(), languages.utf8()); | 1040 return net::IDNToUnicode(host.utf8(), languages.utf8()); |
| 952 } | 1041 } |
| 953 | 1042 |
| 954 } // namespace content | 1043 } // namespace content |
| OLD | NEW |