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

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

Issue 401523002: Move media related mimetype functionality out of net/ and into media/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and add content/common/mime_util.h for realz Created 6 years, 5 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/logging.h" 10 #include "base/logging.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" 52 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h"
53 #include "content/renderer/render_thread_impl.h" 53 #include "content/renderer/render_thread_impl.h"
54 #include "content/renderer/renderer_clipboard_client.h" 54 #include "content/renderer/renderer_clipboard_client.h"
55 #include "content/renderer/webclipboard_impl.h" 55 #include "content/renderer/webclipboard_impl.h"
56 #include "content/renderer/webgraphicscontext3d_provider_impl.h" 56 #include "content/renderer/webgraphicscontext3d_provider_impl.h"
57 #include "content/renderer/webpublicsuffixlist_impl.h" 57 #include "content/renderer/webpublicsuffixlist_impl.h"
58 #include "gpu/config/gpu_info.h" 58 #include "gpu/config/gpu_info.h"
59 #include "ipc/ipc_sync_message_filter.h" 59 #include "ipc/ipc_sync_message_filter.h"
60 #include "media/audio/audio_output_device.h" 60 #include "media/audio/audio_output_device.h"
61 #include "media/base/audio_hardware_config.h" 61 #include "media/base/audio_hardware_config.h"
62 #include "media/base/mime_util.h"
62 #include "media/filters/stream_parser_factory.h" 63 #include "media/filters/stream_parser_factory.h"
63 #include "net/base/mime_util.h" 64 #include "net/base/mime_util.h"
64 #include "net/base/net_util.h" 65 #include "net/base/net_util.h"
65 #include "third_party/WebKit/public/platform/WebBatteryStatusListener.h" 66 #include "third_party/WebKit/public/platform/WebBatteryStatusListener.h"
66 #include "third_party/WebKit/public/platform/WebBlobRegistry.h" 67 #include "third_party/WebKit/public/platform/WebBlobRegistry.h"
67 #include "third_party/WebKit/public/platform/WebDeviceLightListener.h" 68 #include "third_party/WebKit/public/platform/WebDeviceLightListener.h"
68 #include "third_party/WebKit/public/platform/WebDeviceMotionListener.h" 69 #include "third_party/WebKit/public/platform/WebDeviceMotionListener.h"
69 #include "third_party/WebKit/public/platform/WebDeviceOrientationListener.h" 70 #include "third_party/WebKit/public/platform/WebDeviceOrientationListener.h"
70 #include "third_party/WebKit/public/platform/WebFileInfo.h" 71 #include "third_party/WebKit/public/platform/WebFileInfo.h"
71 #include "third_party/WebKit/public/platform/WebGamepads.h" 72 #include "third_party/WebKit/public/platform/WebGamepads.h"
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 405
405 //------------------------------------------------------------------------------ 406 //------------------------------------------------------------------------------
406 407
407 WebMimeRegistry::SupportsType 408 WebMimeRegistry::SupportsType
408 RendererWebKitPlatformSupportImpl::MimeRegistry::supportsMediaMIMEType( 409 RendererWebKitPlatformSupportImpl::MimeRegistry::supportsMediaMIMEType(
409 const WebString& mime_type, 410 const WebString& mime_type,
410 const WebString& codecs, 411 const WebString& codecs,
411 const WebString& key_system) { 412 const WebString& key_system) {
412 const std::string mime_type_ascii = ToASCIIOrEmpty(mime_type); 413 const std::string mime_type_ascii = ToASCIIOrEmpty(mime_type);
413 // Not supporting the container is a flat-out no. 414 // Not supporting the container is a flat-out no.
414 if (!net::IsSupportedMediaMimeType(mime_type_ascii)) 415 if (!media::IsSupportedMediaMimeType(mime_type_ascii))
415 return IsNotSupported; 416 return IsNotSupported;
416 417
417 if (!key_system.isEmpty()) { 418 if (!key_system.isEmpty()) {
418 // Check whether the key system is supported with the mime_type and codecs. 419 // Check whether the key system is supported with the mime_type and codecs.
419 420
420 // Chromium only supports ASCII parameters. 421 // Chromium only supports ASCII parameters.
421 if (!base::IsStringASCII(key_system)) 422 if (!base::IsStringASCII(key_system))
422 return IsNotSupported; 423 return IsNotSupported;
423 424
424 std::string key_system_ascii = 425 std::string key_system_ascii =
425 GetUnprefixedKeySystemName(base::UTF16ToASCII(key_system)); 426 GetUnprefixedKeySystemName(base::UTF16ToASCII(key_system));
426 std::vector<std::string> strict_codecs; 427 std::vector<std::string> strict_codecs;
427 net::ParseCodecString(ToASCIIOrEmpty(codecs), &strict_codecs, true); 428 media::ParseCodecString(ToASCIIOrEmpty(codecs), &strict_codecs, true);
428 429
429 if (!IsSupportedKeySystemWithMediaMimeType( 430 if (!IsSupportedKeySystemWithMediaMimeType(
430 mime_type_ascii, strict_codecs, key_system_ascii)) { 431 mime_type_ascii, strict_codecs, key_system_ascii)) {
431 return IsNotSupported; 432 return IsNotSupported;
432 } 433 }
433 434
434 // Continue processing the mime_type and codecs. 435 // Continue processing the mime_type and codecs.
435 } 436 }
436 437
437 // Check list of strict codecs to see if it is supported. 438 // Check list of strict codecs to see if it is supported.
438 if (net::IsStrictMediaMimeType(mime_type_ascii)) { 439 if (media::IsStrictMediaMimeType(mime_type_ascii)) {
439 // Check if the codecs are a perfect match. 440 // Check if the codecs are a perfect match.
440 std::vector<std::string> strict_codecs; 441 std::vector<std::string> strict_codecs;
441 net::ParseCodecString(ToASCIIOrEmpty(codecs), &strict_codecs, false); 442 media::ParseCodecString(ToASCIIOrEmpty(codecs), &strict_codecs, false);
442 return static_cast<WebMimeRegistry::SupportsType> ( 443 return static_cast<WebMimeRegistry::SupportsType> (
443 net::IsSupportedStrictMediaMimeType(mime_type_ascii, strict_codecs)); 444 media::IsSupportedStrictMediaMimeType(mime_type_ascii, strict_codecs));
444 } 445 }
445 446
446 // If we don't recognize the codec, it's possible we support it. 447 // If we don't recognize the codec, it's possible we support it.
447 std::vector<std::string> parsed_codecs; 448 std::vector<std::string> parsed_codecs;
448 net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codecs, true); 449 media::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codecs, true);
449 if (!net::AreSupportedMediaCodecs(parsed_codecs)) 450 if (!media::AreSupportedMediaCodecs(parsed_codecs))
450 return MayBeSupported; 451 return MayBeSupported;
451 452
452 // Otherwise we have a perfect match. 453 // Otherwise we have a perfect match.
453 return IsSupported; 454 return IsSupported;
454 } 455 }
455 456
456 bool 457 bool
457 RendererWebKitPlatformSupportImpl::MimeRegistry::supportsMediaSourceMIMEType( 458 RendererWebKitPlatformSupportImpl::MimeRegistry::supportsMediaSourceMIMEType(
458 const blink::WebString& mime_type, 459 const blink::WebString& mime_type,
459 const WebString& codecs) { 460 const WebString& codecs) {
460 const std::string mime_type_ascii = ToASCIIOrEmpty(mime_type); 461 const std::string mime_type_ascii = ToASCIIOrEmpty(mime_type);
461 std::vector<std::string> parsed_codec_ids; 462 std::vector<std::string> parsed_codec_ids;
462 net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codec_ids, false); 463 media::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codec_ids, false);
463 if (mime_type_ascii.empty()) 464 if (mime_type_ascii.empty())
464 return false; 465 return false;
465 return media::StreamParserFactory::IsTypeSupported( 466 return media::StreamParserFactory::IsTypeSupported(
466 mime_type_ascii, parsed_codec_ids); 467 mime_type_ascii, parsed_codec_ids);
467 } 468 }
468 469
469 bool 470 bool
470 RendererWebKitPlatformSupportImpl::MimeRegistry::supportsEncryptedMediaMIMEType( 471 RendererWebKitPlatformSupportImpl::MimeRegistry::supportsEncryptedMediaMIMEType(
471 const WebString& key_system, 472 const WebString& key_system,
472 const WebString& mime_type, 473 const WebString& mime_type,
473 const WebString& codecs) { 474 const WebString& codecs) {
474 // Chromium only supports ASCII parameters. 475 // Chromium only supports ASCII parameters.
475 if (!base::IsStringASCII(key_system) || !base::IsStringASCII(mime_type) || 476 if (!base::IsStringASCII(key_system) || !base::IsStringASCII(mime_type) ||
476 !base::IsStringASCII(codecs)) { 477 !base::IsStringASCII(codecs)) {
477 return false; 478 return false;
478 } 479 }
479 480
480 if (key_system.isEmpty()) 481 if (key_system.isEmpty())
481 return false; 482 return false;
482 483
483 const std::string mime_type_ascii = base::UTF16ToASCII(mime_type); 484 const std::string mime_type_ascii = base::UTF16ToASCII(mime_type);
484 485
485 std::vector<std::string> codec_vector; 486 std::vector<std::string> codec_vector;
486 bool strip_suffix = !net::IsStrictMediaMimeType(mime_type_ascii); 487 bool strip_suffix = !media::IsStrictMediaMimeType(mime_type_ascii);
487 net::ParseCodecString(base::UTF16ToASCII(codecs), &codec_vector, 488 media::ParseCodecString(base::UTF16ToASCII(codecs), &codec_vector,
488 strip_suffix); 489 strip_suffix);
489 490
490 return IsSupportedKeySystemWithMediaMimeType( 491 return IsSupportedKeySystemWithMediaMimeType(
491 mime_type_ascii, codec_vector, base::UTF16ToASCII(key_system)); 492 mime_type_ascii, codec_vector, base::UTF16ToASCII(key_system));
492 } 493 }
493 494
494 WebString 495 WebString
495 RendererWebKitPlatformSupportImpl::MimeRegistry::mimeTypeForExtension( 496 RendererWebKitPlatformSupportImpl::MimeRegistry::mimeTypeForExtension(
496 const WebString& file_extension) { 497 const WebString& file_extension) {
497 if (IsPluginProcess()) 498 if (IsPluginProcess())
498 return SimpleWebMimeRegistryImpl::mimeTypeForExtension(file_extension); 499 return SimpleWebMimeRegistryImpl::mimeTypeForExtension(file_extension);
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 battery_status_dispatcher_->SetListener(listener); 1146 battery_status_dispatcher_->SetListener(listener);
1146 } 1147 }
1147 1148
1148 // static 1149 // static
1149 void RendererWebKitPlatformSupportImpl::MockBatteryStatusChangedForTesting( 1150 void RendererWebKitPlatformSupportImpl::MockBatteryStatusChangedForTesting(
1150 const blink::WebBatteryStatus& status) { 1151 const blink::WebBatteryStatus& status) {
1151 g_test_battery_status_dispatcher.Get().PostBatteryStatusChange(status); 1152 g_test_battery_status_dispatcher.Get().PostBatteryStatusChange(status);
1152 } 1153 }
1153 1154
1154 } // namespace content 1155 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698