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

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 23 matching lines...) Expand all
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
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 virtual WebKit::WebMimeRegistry::SupportsType supportsMediaMIMEType(
scherkus (not reviewing) 2013/06/21 02:44:06 ddorwin: FYI
ddorwin 2013/06/21 02:58:19 You removed the wrong one. The three-parameter one
scherkus (not reviewing) 2013/06/21 17:02:16 Looks like I can't remove it yet. Requires a Blink
116 virtual WebKit::WebString mimeTypeFromFile(const WebKit::WebString&); 119 const WebKit::WebString& mime_type,
120 const WebKit::WebString& codecs);
121 virtual bool supportsMediaSourceMIMEType(const WebKit::WebString& mime_type,
122 const WebKit::WebString& codecs);
123 virtual WebKit::WebString mimeTypeForExtension(
124 const WebKit::WebString& file_extension);
125 virtual WebKit::WebString mimeTypeFromFile(
126 const WebKit::WebString& file_path);
117 virtual WebKit::WebString preferredExtensionForMIMEType( 127 virtual WebKit::WebString preferredExtensionForMIMEType(
118 const WebKit::WebString&); 128 const WebKit::WebString& mime_type);
119 }; 129 };
120 130
121 class RendererWebKitPlatformSupportImpl::FileUtilities 131 class RendererWebKitPlatformSupportImpl::FileUtilities
122 : public webkit_glue::WebFileUtilitiesImpl { 132 : public webkit_glue::WebFileUtilitiesImpl {
123 public: 133 public:
124 explicit FileUtilities(ThreadSafeSender* sender) 134 explicit FileUtilities(ThreadSafeSender* sender)
125 : thread_safe_sender_(sender) {} 135 : thread_safe_sender_(sender) {}
126 virtual bool getFileInfo(const WebString& path, WebFileInfo& result); 136 virtual bool getFileInfo(const WebString& path, WebFileInfo& result);
127 virtual base::PlatformFile openFile(const WebKit::WebString& path, 137 virtual base::PlatformFile openFile(const WebKit::WebString& path,
128 int mode); 138 int mode);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 226
217 WebKit::WebClipboard* RendererWebKitPlatformSupportImpl::clipboard() { 227 WebKit::WebClipboard* RendererWebKitPlatformSupportImpl::clipboard() {
218 WebKit::WebClipboard* clipboard = 228 WebKit::WebClipboard* clipboard =
219 GetContentClient()->renderer()->OverrideWebClipboard(); 229 GetContentClient()->renderer()->OverrideWebClipboard();
220 if (clipboard) 230 if (clipboard)
221 return clipboard; 231 return clipboard;
222 return clipboard_.get(); 232 return clipboard_.get();
223 } 233 }
224 234
225 WebKit::WebMimeRegistry* RendererWebKitPlatformSupportImpl::mimeRegistry() { 235 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(); 236 return mime_registry_.get();
231 } 237 }
232 238
233 WebKit::WebFileUtilities* 239 WebKit::WebFileUtilities*
234 RendererWebKitPlatformSupportImpl::fileUtilities() { 240 RendererWebKitPlatformSupportImpl::fileUtilities() {
235 if (!file_utilities_) { 241 if (!file_utilities_) {
236 file_utilities_.reset(new FileUtilities(thread_safe_sender_.get())); 242 file_utilities_.reset(new FileUtilities(thread_safe_sender_.get()));
237 file_utilities_->set_sandbox_enabled(sandboxEnabled()); 243 file_utilities_->set_sandbox_enabled(sandboxEnabled());
238 } 244 }
239 return file_utilities_.get(); 245 return file_utilities_.get();
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 //------------------------------------------------------------------------------ 379 //------------------------------------------------------------------------------
374 380
375 WebFileSystem* RendererWebKitPlatformSupportImpl::fileSystem() { 381 WebFileSystem* RendererWebKitPlatformSupportImpl::fileSystem() {
376 if (!web_file_system_) 382 if (!web_file_system_)
377 web_file_system_.reset(new WebFileSystemImpl()); 383 web_file_system_.reset(new WebFileSystemImpl());
378 return web_file_system_.get(); 384 return web_file_system_.get();
379 } 385 }
380 386
381 //------------------------------------------------------------------------------ 387 //------------------------------------------------------------------------------
382 388
389 WebMimeRegistry::SupportsType
390 RendererWebKitPlatformSupportImpl::MimeRegistry::supportsMediaMIMEType(
391 const WebString& mime_type,
392 const WebString& codecs) {
393 const std::string mime_type_ascii = ToASCIIOrEmpty(mime_type);
394 // Not supporting the container is a flat-out no.
395 if (!net::IsSupportedMediaMimeType(mime_type_ascii))
396 return IsNotSupported;
397
ddorwin 2013/06/21 02:58:19 Restore the code you removed above to pass your te
scherkus (not reviewing) 2013/06/21 17:02:16 Done.
398 // Check list of strict codecs to see if it is supported.
399 if (net::IsStrictMediaMimeType(mime_type_ascii)) {
400 // We support the container, but no codecs were specified.
401 if (codecs.isNull())
402 return MayBeSupported;
403
404 // Check if the codecs are a perfect match.
405 std::vector<std::string> strict_codecs;
406 net::ParseCodecString(ToASCIIOrEmpty(codecs), &strict_codecs, false);
407 if (!net::IsSupportedStrictMediaMimeType(mime_type_ascii, strict_codecs))
408 return IsNotSupported;
409
410 // Good to go!
411 return IsSupported;
412 }
413
414 // If we don't recognize the codec, it's possible we support it.
415 std::vector<std::string> parsed_codecs;
416 net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codecs, true);
417 if (!net::AreSupportedMediaCodecs(parsed_codecs))
418 return MayBeSupported;
419
420 // Otherwise we have a perfect match.
421 return IsSupported;
422 }
423
424 bool
425 RendererWebKitPlatformSupportImpl::MimeRegistry::supportsMediaSourceMIMEType(
426 const WebKit::WebString& mime_type,
427 const WebString& codecs) {
428 const std::string mime_type_ascii = ToASCIIOrEmpty(mime_type);
429 std::vector<std::string> parsed_codec_ids;
430 net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codec_ids, false);
431 if (mime_type_ascii.empty() || parsed_codec_ids.size() == 0)
432 return false;
433 return media::StreamParserFactory::IsTypeSupported(
434 mime_type_ascii, parsed_codec_ids);
435 }
436
383 WebString 437 WebString
384 RendererWebKitPlatformSupportImpl::MimeRegistry::mimeTypeForExtension( 438 RendererWebKitPlatformSupportImpl::MimeRegistry::mimeTypeForExtension(
385 const WebString& file_extension) { 439 const WebString& file_extension) {
386 if (IsPluginProcess()) 440 if (IsPluginProcess())
387 return SimpleWebMimeRegistryImpl::mimeTypeForExtension(file_extension); 441 return SimpleWebMimeRegistryImpl::mimeTypeForExtension(file_extension);
388 442
389 // The sandbox restricts our access to the registry, so we need to proxy 443 // The sandbox restricts our access to the registry, so we need to proxy
390 // these calls over to the browser process. 444 // these calls over to the browser process.
391 std::string mime_type; 445 std::string mime_type;
392 RenderThread::Get()->Send( 446 RenderThread::Get()->Send(
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 999
946 //------------------------------------------------------------------------------ 1000 //------------------------------------------------------------------------------
947 1001
948 WebKit::WebString RendererWebKitPlatformSupportImpl::convertIDNToUnicode( 1002 WebKit::WebString RendererWebKitPlatformSupportImpl::convertIDNToUnicode(
949 const WebKit::WebString& host, 1003 const WebKit::WebString& host,
950 const WebKit::WebString& languages) { 1004 const WebKit::WebString& languages) {
951 return net::IDNToUnicode(host.utf8(), languages.utf8()); 1005 return net::IDNToUnicode(host.utf8(), languages.utf8());
952 } 1006 }
953 1007
954 } // namespace content 1008 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698