Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Side by Side Diff: content/renderer/renderer_webkitplatformsupport_impl.cc

Issue 17447011: Shuffle media-related WebMimeRegistry code from webkit/ to content/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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.
jamesr 2013/06/21 01:24:14 could you check and see if this TODO is still rele
scherkus (not reviewing) 2013/06/21 02:44:06 Done.
120 virtual WebKit::WebMimeRegistry::SupportsType supportsMediaMIMEType(
121 const WebKit::WebString&, const WebKit::WebString&);
122 virtual WebKit::WebMimeRegistry::SupportsType supportsMediaMIMEType(
123 const WebKit::WebString&,
jamesr 2013/06/21 01:24:14 this is chromium style, so all parameters need chr
scherkus (not reviewing) 2013/06/21 02:44:06 Done.
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 229
217 WebKit::WebClipboard* RendererWebKitPlatformSupportImpl::clipboard() { 230 WebKit::WebClipboard* RendererWebKitPlatformSupportImpl::clipboard() {
218 WebKit::WebClipboard* clipboard = 231 WebKit::WebClipboard* clipboard =
219 GetContentClient()->renderer()->OverrideWebClipboard(); 232 GetContentClient()->renderer()->OverrideWebClipboard();
220 if (clipboard) 233 if (clipboard)
221 return clipboard; 234 return clipboard;
222 return clipboard_.get(); 235 return clipboard_.get();
223 } 236 }
224 237
225 WebKit::WebMimeRegistry* RendererWebKitPlatformSupportImpl::mimeRegistry() { 238 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(); 239 return mime_registry_.get();
231 } 240 }
232 241
233 WebKit::WebFileUtilities* 242 WebKit::WebFileUtilities*
234 RendererWebKitPlatformSupportImpl::fileUtilities() { 243 RendererWebKitPlatformSupportImpl::fileUtilities() {
235 if (!file_utilities_) { 244 if (!file_utilities_) {
236 file_utilities_.reset(new FileUtilities(thread_safe_sender_.get())); 245 file_utilities_.reset(new FileUtilities(thread_safe_sender_.get()));
237 file_utilities_->set_sandbox_enabled(sandboxEnabled()); 246 file_utilities_->set_sandbox_enabled(sandboxEnabled());
238 } 247 }
239 return file_utilities_.get(); 248 return file_utilities_.get();
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 //------------------------------------------------------------------------------ 382 //------------------------------------------------------------------------------
374 383
375 WebFileSystem* RendererWebKitPlatformSupportImpl::fileSystem() { 384 WebFileSystem* RendererWebKitPlatformSupportImpl::fileSystem() {
376 if (!web_file_system_) 385 if (!web_file_system_)
377 web_file_system_.reset(new WebFileSystemImpl()); 386 web_file_system_.reset(new WebFileSystemImpl());
378 return web_file_system_.get(); 387 return web_file_system_.get();
379 } 388 }
380 389
381 //------------------------------------------------------------------------------ 390 //------------------------------------------------------------------------------
382 391
392 WebMimeRegistry::SupportsType
393 RendererWebKitPlatformSupportImpl::MimeRegistry::supportsMediaMIMEType(
394 const WebString& mime_type,
395 const WebString& codecs) {
396 return supportsMediaMIMEType(mime_type, codecs, WebString());
397 }
398
399 WebMimeRegistry::SupportsType
400 RendererWebKitPlatformSupportImpl::MimeRegistry::supportsMediaMIMEType(
401 const WebString& mime_type,
402 const WebString& codecs,
403 const WebString& key_system) {
404 const std::string mime_type_ascii = ToASCIIOrEmpty(mime_type);
405 // Not supporting the container is a flat-out no.
406 if (!net::IsSupportedMediaMimeType(mime_type_ascii))
407 return IsNotSupported;
408
409 if (!key_system.isEmpty()) {
410 // Check whether the key system is supported with the mime_type and codecs.
411
412 // Not supporting the key system is a flat-out no.
413 if (!webkit_media::IsSupportedKeySystem(key_system))
414 return IsNotSupported;
415
416 std::vector<std::string> strict_codecs;
417 bool strip_suffix = !net::IsStrictMediaMimeType(mime_type_ascii);
418 net::ParseCodecString(ToASCIIOrEmpty(codecs), &strict_codecs, strip_suffix);
419
420 if (!webkit_media::IsSupportedKeySystemWithMediaMimeType(
421 mime_type_ascii, strict_codecs, ToASCIIOrEmpty(key_system)))
422 return IsNotSupported;
423
424 // Continue processing the mime_type and codecs.
425 }
426
427 // Check list of strict codecs to see if it is supported.
428 if (net::IsStrictMediaMimeType(mime_type_ascii)) {
429 // We support the container, but no codecs were specified.
430 if (codecs.isNull())
431 return MayBeSupported;
432
433 // Check if the codecs are a perfect match.
434 std::vector<std::string> strict_codecs;
435 net::ParseCodecString(ToASCIIOrEmpty(codecs), &strict_codecs, false);
436 if (!net::IsSupportedStrictMediaMimeType(mime_type_ascii, strict_codecs))
437 return IsNotSupported;
438
439 // Good to go!
440 return IsSupported;
441 }
442
443 // If we don't recognize the codec, it's possible we support it.
444 std::vector<std::string> parsed_codecs;
445 net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codecs, true);
446 if (!net::AreSupportedMediaCodecs(parsed_codecs))
447 return MayBeSupported;
448
449 // Otherwise we have a perfect match.
450 return IsSupported;
451 }
452
453 bool
454 RendererWebKitPlatformSupportImpl::MimeRegistry::supportsMediaSourceMIMEType(
455 const WebKit::WebString& mime_type,
456 const WebString& codecs) {
457 const std::string mime_type_ascii = ToASCIIOrEmpty(mime_type);
458 std::vector<std::string> parsed_codec_ids;
459 net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codec_ids, false);
460 if (mime_type_ascii.empty() || parsed_codec_ids.size() == 0)
461 return false;
462 return media::StreamParserFactory::IsTypeSupported(
463 mime_type_ascii, parsed_codec_ids);
464 }
465
383 WebString 466 WebString
384 RendererWebKitPlatformSupportImpl::MimeRegistry::mimeTypeForExtension( 467 RendererWebKitPlatformSupportImpl::MimeRegistry::mimeTypeForExtension(
385 const WebString& file_extension) { 468 const WebString& file_extension) {
386 if (IsPluginProcess()) 469 if (IsPluginProcess())
387 return SimpleWebMimeRegistryImpl::mimeTypeForExtension(file_extension); 470 return SimpleWebMimeRegistryImpl::mimeTypeForExtension(file_extension);
388 471
389 // The sandbox restricts our access to the registry, so we need to proxy 472 // The sandbox restricts our access to the registry, so we need to proxy
390 // these calls over to the browser process. 473 // these calls over to the browser process.
391 std::string mime_type; 474 std::string mime_type;
392 RenderThread::Get()->Send( 475 RenderThread::Get()->Send(
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 1028
946 //------------------------------------------------------------------------------ 1029 //------------------------------------------------------------------------------
947 1030
948 WebKit::WebString RendererWebKitPlatformSupportImpl::convertIDNToUnicode( 1031 WebKit::WebString RendererWebKitPlatformSupportImpl::convertIDNToUnicode(
949 const WebKit::WebString& host, 1032 const WebKit::WebString& host,
950 const WebKit::WebString& languages) { 1033 const WebKit::WebString& languages) {
951 return net::IDNToUnicode(host.utf8(), languages.utf8()); 1034 return net::IDNToUnicode(host.utf8(), languages.utf8());
952 } 1035 }
953 1036
954 } // namespace content 1037 } // namespace content
OLDNEW
« no previous file with comments | « content/public/renderer/content_renderer_client.cc ('k') | content/shell/app/shell_main_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698