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" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 using WebKit::WebAudioDevice; | 89 using WebKit::WebAudioDevice; |
88 using WebKit::WebBlobRegistry; | 90 using WebKit::WebBlobRegistry; |
89 using WebKit::WebFileInfo; | 91 using WebKit::WebFileInfo; |
90 using WebKit::WebFileSystem; | 92 using WebKit::WebFileSystem; |
91 using WebKit::WebFrame; | 93 using WebKit::WebFrame; |
92 using WebKit::WebGamepads; | 94 using WebKit::WebGamepads; |
93 using WebKit::WebIDBFactory; | 95 using WebKit::WebIDBFactory; |
94 using WebKit::Platform; | 96 using WebKit::Platform; |
95 using WebKit::WebMediaStreamCenter; | 97 using WebKit::WebMediaStreamCenter; |
96 using WebKit::WebMediaStreamCenterClient; | 98 using WebKit::WebMediaStreamCenterClient; |
| 99 using WebKit::WebMimeRegistry; |
97 using WebKit::WebRTCPeerConnectionHandler; | 100 using WebKit::WebRTCPeerConnectionHandler; |
98 using WebKit::WebRTCPeerConnectionHandlerClient; | 101 using WebKit::WebRTCPeerConnectionHandlerClient; |
99 using WebKit::WebStorageNamespace; | 102 using WebKit::WebStorageNamespace; |
100 using WebKit::WebString; | 103 using WebKit::WebString; |
101 using WebKit::WebURL; | 104 using WebKit::WebURL; |
102 using WebKit::WebVector; | 105 using WebKit::WebVector; |
103 | 106 |
104 namespace content { | 107 namespace content { |
105 | 108 |
106 static bool g_sandbox_enabled = true; | 109 static bool g_sandbox_enabled = true; |
107 base::LazyInstance<WebGamepads>::Leaky g_test_gamepads = | 110 base::LazyInstance<WebGamepads>::Leaky g_test_gamepads = |
108 LAZY_INSTANCE_INITIALIZER; | 111 LAZY_INSTANCE_INITIALIZER; |
109 | 112 |
110 //------------------------------------------------------------------------------ | 113 //------------------------------------------------------------------------------ |
111 | 114 |
112 class RendererWebKitPlatformSupportImpl::MimeRegistry | 115 class RendererWebKitPlatformSupportImpl::MimeRegistry |
113 : public webkit_glue::SimpleWebMimeRegistryImpl { | 116 : public webkit_glue::SimpleWebMimeRegistryImpl { |
114 public: | 117 public: |
115 virtual WebKit::WebString mimeTypeForExtension(const WebKit::WebString&); | 118 // TODO(ddorwin): Remove after http://webk.it/82983 lands. |
116 virtual WebKit::WebString mimeTypeFromFile(const WebKit::WebString&); | 119 virtual WebKit::WebMimeRegistry::SupportsType supportsMediaMIMEType( |
| 120 const WebKit::WebString& mime_type, |
| 121 const WebKit::WebString& codecs); |
| 122 virtual WebKit::WebMimeRegistry::SupportsType supportsMediaMIMEType( |
| 123 const WebKit::WebString& mime_type, |
| 124 const WebKit::WebString& codecs, |
| 125 const WebKit::WebString& key_system); |
| 126 virtual bool supportsMediaSourceMIMEType(const WebKit::WebString& mime_type, |
| 127 const WebKit::WebString& codecs); |
| 128 virtual WebKit::WebString mimeTypeForExtension( |
| 129 const WebKit::WebString& file_extension); |
| 130 virtual WebKit::WebString mimeTypeFromFile( |
| 131 const WebKit::WebString& file_path); |
117 virtual WebKit::WebString preferredExtensionForMIMEType( | 132 virtual WebKit::WebString preferredExtensionForMIMEType( |
118 const WebKit::WebString&); | 133 const WebKit::WebString& mime_type); |
119 }; | 134 }; |
120 | 135 |
121 class RendererWebKitPlatformSupportImpl::FileUtilities | 136 class RendererWebKitPlatformSupportImpl::FileUtilities |
122 : public webkit_glue::WebFileUtilitiesImpl { | 137 : public webkit_glue::WebFileUtilitiesImpl { |
123 public: | 138 public: |
124 explicit FileUtilities(ThreadSafeSender* sender) | 139 explicit FileUtilities(ThreadSafeSender* sender) |
125 : thread_safe_sender_(sender) {} | 140 : thread_safe_sender_(sender) {} |
126 virtual bool getFileInfo(const WebString& path, WebFileInfo& result); | 141 virtual bool getFileInfo(const WebString& path, WebFileInfo& result); |
127 virtual base::PlatformFile openFile(const WebKit::WebString& path, | 142 virtual base::PlatformFile openFile(const WebKit::WebString& path, |
128 int mode); | 143 int mode); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 | 231 |
217 WebKit::WebClipboard* RendererWebKitPlatformSupportImpl::clipboard() { | 232 WebKit::WebClipboard* RendererWebKitPlatformSupportImpl::clipboard() { |
218 WebKit::WebClipboard* clipboard = | 233 WebKit::WebClipboard* clipboard = |
219 GetContentClient()->renderer()->OverrideWebClipboard(); | 234 GetContentClient()->renderer()->OverrideWebClipboard(); |
220 if (clipboard) | 235 if (clipboard) |
221 return clipboard; | 236 return clipboard; |
222 return clipboard_.get(); | 237 return clipboard_.get(); |
223 } | 238 } |
224 | 239 |
225 WebKit::WebMimeRegistry* RendererWebKitPlatformSupportImpl::mimeRegistry() { | 240 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(); | 241 return mime_registry_.get(); |
231 } | 242 } |
232 | 243 |
233 WebKit::WebFileUtilities* | 244 WebKit::WebFileUtilities* |
234 RendererWebKitPlatformSupportImpl::fileUtilities() { | 245 RendererWebKitPlatformSupportImpl::fileUtilities() { |
235 if (!file_utilities_) { | 246 if (!file_utilities_) { |
236 file_utilities_.reset(new FileUtilities(thread_safe_sender_.get())); | 247 file_utilities_.reset(new FileUtilities(thread_safe_sender_.get())); |
237 file_utilities_->set_sandbox_enabled(sandboxEnabled()); | 248 file_utilities_->set_sandbox_enabled(sandboxEnabled()); |
238 } | 249 } |
239 return file_utilities_.get(); | 250 return file_utilities_.get(); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 //------------------------------------------------------------------------------ | 384 //------------------------------------------------------------------------------ |
374 | 385 |
375 WebFileSystem* RendererWebKitPlatformSupportImpl::fileSystem() { | 386 WebFileSystem* RendererWebKitPlatformSupportImpl::fileSystem() { |
376 if (!web_file_system_) | 387 if (!web_file_system_) |
377 web_file_system_.reset(new WebFileSystemImpl()); | 388 web_file_system_.reset(new WebFileSystemImpl()); |
378 return web_file_system_.get(); | 389 return web_file_system_.get(); |
379 } | 390 } |
380 | 391 |
381 //------------------------------------------------------------------------------ | 392 //------------------------------------------------------------------------------ |
382 | 393 |
| 394 WebMimeRegistry::SupportsType |
| 395 RendererWebKitPlatformSupportImpl::MimeRegistry::supportsMediaMIMEType( |
| 396 const WebString& mime_type, |
| 397 const WebString& codecs) { |
| 398 return supportsMediaMIMEType(mime_type, codecs, WebString()); |
| 399 } |
| 400 |
| 401 WebMimeRegistry::SupportsType |
| 402 RendererWebKitPlatformSupportImpl::MimeRegistry::supportsMediaMIMEType( |
| 403 const WebString& mime_type, |
| 404 const WebString& codecs, |
| 405 const WebString& key_system) { |
| 406 const std::string mime_type_ascii = ToASCIIOrEmpty(mime_type); |
| 407 // Not supporting the container is a flat-out no. |
| 408 if (!net::IsSupportedMediaMimeType(mime_type_ascii)) |
| 409 return IsNotSupported; |
| 410 |
| 411 // Check list of strict codecs to see if it is supported. |
| 412 if (net::IsStrictMediaMimeType(mime_type_ascii)) { |
| 413 // We support the container, but no codecs were specified. |
| 414 if (codecs.isNull()) |
| 415 return MayBeSupported; |
| 416 |
| 417 // Check if the codecs are a perfect match. |
| 418 std::vector<std::string> strict_codecs; |
| 419 net::ParseCodecString(ToASCIIOrEmpty(codecs), &strict_codecs, false); |
| 420 if (!net::IsSupportedStrictMediaMimeType(mime_type_ascii, strict_codecs)) |
| 421 return IsNotSupported; |
| 422 |
| 423 // Good to go! |
| 424 return IsSupported; |
| 425 } |
| 426 |
| 427 // If we don't recognize the codec, it's possible we support it. |
| 428 std::vector<std::string> parsed_codecs; |
| 429 net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codecs, true); |
| 430 if (!net::AreSupportedMediaCodecs(parsed_codecs)) |
| 431 return MayBeSupported; |
| 432 |
| 433 // Otherwise we have a perfect match. |
| 434 return IsSupported; |
| 435 } |
| 436 |
| 437 bool |
| 438 RendererWebKitPlatformSupportImpl::MimeRegistry::supportsMediaSourceMIMEType( |
| 439 const WebKit::WebString& mime_type, |
| 440 const WebString& codecs) { |
| 441 const std::string mime_type_ascii = ToASCIIOrEmpty(mime_type); |
| 442 std::vector<std::string> parsed_codec_ids; |
| 443 net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codec_ids, false); |
| 444 if (mime_type_ascii.empty() || parsed_codec_ids.size() == 0) |
| 445 return false; |
| 446 return media::StreamParserFactory::IsTypeSupported( |
| 447 mime_type_ascii, parsed_codec_ids); |
| 448 } |
| 449 |
383 WebString | 450 WebString |
384 RendererWebKitPlatformSupportImpl::MimeRegistry::mimeTypeForExtension( | 451 RendererWebKitPlatformSupportImpl::MimeRegistry::mimeTypeForExtension( |
385 const WebString& file_extension) { | 452 const WebString& file_extension) { |
386 if (IsPluginProcess()) | 453 if (IsPluginProcess()) |
387 return SimpleWebMimeRegistryImpl::mimeTypeForExtension(file_extension); | 454 return SimpleWebMimeRegistryImpl::mimeTypeForExtension(file_extension); |
388 | 455 |
389 // The sandbox restricts our access to the registry, so we need to proxy | 456 // The sandbox restricts our access to the registry, so we need to proxy |
390 // these calls over to the browser process. | 457 // these calls over to the browser process. |
391 std::string mime_type; | 458 std::string mime_type; |
392 RenderThread::Get()->Send( | 459 RenderThread::Get()->Send( |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 | 1012 |
946 //------------------------------------------------------------------------------ | 1013 //------------------------------------------------------------------------------ |
947 | 1014 |
948 WebKit::WebString RendererWebKitPlatformSupportImpl::convertIDNToUnicode( | 1015 WebKit::WebString RendererWebKitPlatformSupportImpl::convertIDNToUnicode( |
949 const WebKit::WebString& host, | 1016 const WebKit::WebString& host, |
950 const WebKit::WebString& languages) { | 1017 const WebKit::WebString& languages) { |
951 return net::IDNToUnicode(host.utf8(), languages.utf8()); | 1018 return net::IDNToUnicode(host.utf8(), languages.utf8()); |
952 } | 1019 } |
953 | 1020 |
954 } // namespace content | 1021 } // namespace content |
OLD | NEW |