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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp

Issue 2444873002: Move WebMIMERegistry impl from //content to blink:platform/network/mime (Closed)
Patch Set: rebased Created 4 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 #include "core/layout/api/LayoutViewItem.h" 70 #include "core/layout/api/LayoutViewItem.h"
71 #include "core/layout/compositing/PaintLayerCompositor.h" 71 #include "core/layout/compositing/PaintLayerCompositor.h"
72 #include "core/loader/FrameLoader.h" 72 #include "core/loader/FrameLoader.h"
73 #include "core/loader/FrameLoaderClient.h" 73 #include "core/loader/FrameLoaderClient.h"
74 #include "core/page/ChromeClient.h" 74 #include "core/page/ChromeClient.h"
75 #include "core/page/NetworkStateNotifier.h" 75 #include "core/page/NetworkStateNotifier.h"
76 #include "platform/ContentType.h" 76 #include "platform/ContentType.h"
77 #include "platform/Histogram.h" 77 #include "platform/Histogram.h"
78 #include "platform/LayoutTestSupport.h" 78 #include "platform/LayoutTestSupport.h"
79 #include "platform/MIMETypeFromURL.h" 79 #include "platform/MIMETypeFromURL.h"
80 #include "platform/MIMETypeRegistry.h"
81 #include "platform/RuntimeEnabledFeatures.h" 80 #include "platform/RuntimeEnabledFeatures.h"
82 #include "platform/UserGestureIndicator.h" 81 #include "platform/UserGestureIndicator.h"
83 #include "platform/audio/AudioBus.h" 82 #include "platform/audio/AudioBus.h"
84 #include "platform/audio/AudioSourceProviderClient.h" 83 #include "platform/audio/AudioSourceProviderClient.h"
85 #include "platform/graphics/GraphicsLayer.h" 84 #include "platform/graphics/GraphicsLayer.h"
86 #include "platform/mediastream/MediaStreamDescriptor.h" 85 #include "platform/mediastream/MediaStreamDescriptor.h"
87 #include "platform/weborigin/SecurityOrigin.h" 86 #include "platform/weborigin/SecurityOrigin.h"
88 #include "public/platform/Platform.h" 87 #include "public/platform/Platform.h"
89 #include "public/platform/WebAudioSourceProvider.h" 88 #include "public/platform/WebAudioSourceProvider.h"
90 #include "public/platform/WebContentDecryptionModule.h" 89 #include "public/platform/WebContentDecryptionModule.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 // If no MIME type is specified, always attempt to load. 255 // If no MIME type is specified, always attempt to load.
257 if (contentMIMEType.isEmpty()) 256 if (contentMIMEType.isEmpty())
258 return true; 257 return true;
259 258
260 // 4.8.10.3 MIME types - In the absence of a specification to the contrary, 259 // 4.8.10.3 MIME types - In the absence of a specification to the contrary,
261 // the MIME type "application/octet-stream" when used with parameters, e.g. 260 // the MIME type "application/octet-stream" when used with parameters, e.g.
262 // "application/octet-stream;codecs=theora", is a type that the user agent 261 // "application/octet-stream;codecs=theora", is a type that the user agent
263 // knows it cannot render. 262 // knows it cannot render.
264 if (contentMIMEType != "application/octet-stream" || 263 if (contentMIMEType != "application/octet-stream" ||
265 contentTypeCodecs.isEmpty()) { 264 contentTypeCodecs.isEmpty()) {
266 WebMimeRegistry::SupportsType supported = 265 return MIMETypeRegistry::supportsMediaMIMEType(contentMIMEType,
267 Platform::current()->mimeRegistry()->supportsMediaMIMEType( 266 contentTypeCodecs);
268 contentMIMEType, contentTypeCodecs);
269 return supported > WebMimeRegistry::IsNotSupported;
270 } 267 }
271 268
272 return false; 269 return false;
273 } 270 }
274 271
275 String preloadTypeToString(WebMediaPlayer::Preload preloadType) { 272 String preloadTypeToString(WebMediaPlayer::Preload preloadType) {
276 switch (preloadType) { 273 switch (preloadType) {
277 case WebMediaPlayer::PreloadNone: 274 case WebMediaPlayer::PreloadNone:
278 return "none"; 275 return "none";
279 case WebMediaPlayer::PreloadMetaData: 276 case WebMediaPlayer::PreloadMetaData:
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 348
352 Member<HTMLMediaElement> m_element; 349 Member<HTMLMediaElement> m_element;
353 }; 350 };
354 351
355 void HTMLMediaElement::recordAutoplayMetric(AutoplayMetrics metric) { 352 void HTMLMediaElement::recordAutoplayMetric(AutoplayMetrics metric) {
356 DEFINE_STATIC_LOCAL(EnumerationHistogram, autoplayHistogram, 353 DEFINE_STATIC_LOCAL(EnumerationHistogram, autoplayHistogram,
357 ("Blink.MediaElement.Autoplay", NumberOfAutoplayMetrics)); 354 ("Blink.MediaElement.Autoplay", NumberOfAutoplayMetrics));
358 autoplayHistogram.count(metric); 355 autoplayHistogram.count(metric);
359 } 356 }
360 357
361 WebMimeRegistry::SupportsType HTMLMediaElement::supportsType( 358 MIMETypeRegistry::SupportsType HTMLMediaElement::supportsType(
362 const ContentType& contentType) { 359 const ContentType& contentType) {
363 DEFINE_STATIC_LOCAL(const String, codecs, ("codecs")); 360 DEFINE_STATIC_LOCAL(const String, codecs, ("codecs"));
364 361
365 String type = contentType.type().lower(); 362 String type = contentType.type().lower();
366 // The codecs string is not lower-cased because MP4 values are case sensitive 363 // The codecs string is not lower-cased because MP4 values are case sensitive
367 // per http://tools.ietf.org/html/rfc4281#page-7. 364 // per http://tools.ietf.org/html/rfc4281#page-7.
368 String typeCodecs = contentType.parameter(codecs); 365 String typeCodecs = contentType.parameter(codecs);
369 366
370 if (type.isEmpty()) 367 if (type.isEmpty())
371 return WebMimeRegistry::IsNotSupported; 368 return MIMETypeRegistry::IsNotSupported;
372 369
373 // 4.8.10.3 MIME types - The canPlayType(type) method must return the empty 370 // 4.8.10.3 MIME types - The canPlayType(type) method must return the empty
374 // string if type is a type that the user agent knows it cannot render or is 371 // string if type is a type that the user agent knows it cannot render or is
375 // the type "application/octet-stream" 372 // the type "application/octet-stream"
376 if (type == "application/octet-stream") 373 if (type == "application/octet-stream")
377 return WebMimeRegistry::IsNotSupported; 374 return MIMETypeRegistry::IsNotSupported;
378 375
379 return Platform::current()->mimeRegistry()->supportsMediaMIMEType(type, 376 return MIMETypeRegistry::supportsMediaMIMEType(type, typeCodecs);
380 typeCodecs);
381 } 377 }
382 378
383 URLRegistry* HTMLMediaElement::s_mediaStreamRegistry = 0; 379 URLRegistry* HTMLMediaElement::s_mediaStreamRegistry = 0;
384 380
385 void HTMLMediaElement::setMediaStreamRegistry(URLRegistry* registry) { 381 void HTMLMediaElement::setMediaStreamRegistry(URLRegistry* registry) {
386 DCHECK(!s_mediaStreamRegistry); 382 DCHECK(!s_mediaStreamRegistry);
387 s_mediaStreamRegistry = registry; 383 s_mediaStreamRegistry = registry;
388 } 384 }
389 385
390 bool HTMLMediaElement::isMediaStreamURL(const String& url) { 386 bool HTMLMediaElement::isMediaStreamURL(const String& url) {
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 BLINK_MEDIA_LOG << "setSrcObject(" << (void*)this << ")"; 710 BLINK_MEDIA_LOG << "setSrcObject(" << (void*)this << ")";
715 m_srcObject = srcObject; 711 m_srcObject = srcObject;
716 invokeLoadAlgorithm(); 712 invokeLoadAlgorithm();
717 } 713 }
718 714
719 HTMLMediaElement::NetworkState HTMLMediaElement::getNetworkState() const { 715 HTMLMediaElement::NetworkState HTMLMediaElement::getNetworkState() const {
720 return m_networkState; 716 return m_networkState;
721 } 717 }
722 718
723 String HTMLMediaElement::canPlayType(const String& mimeType) const { 719 String HTMLMediaElement::canPlayType(const String& mimeType) const {
724 WebMimeRegistry::SupportsType support = supportsType(ContentType(mimeType)); 720 MIMETypeRegistry::SupportsType support = supportsType(ContentType(mimeType));
725 String canPlay; 721 String canPlay;
726 722
727 // 4.8.10.3 723 // 4.8.10.3
728 switch (support) { 724 switch (support) {
729 case WebMimeRegistry::IsNotSupported: 725 case MIMETypeRegistry::IsNotSupported:
730 canPlay = emptyString(); 726 canPlay = emptyString();
731 break; 727 break;
732 case WebMimeRegistry::MayBeSupported: 728 case MIMETypeRegistry::MayBeSupported:
733 canPlay = "maybe"; 729 canPlay = "maybe";
734 break; 730 break;
735 case WebMimeRegistry::IsSupported: 731 case MIMETypeRegistry::IsSupported:
736 canPlay = "probably"; 732 canPlay = "probably";
737 break; 733 break;
738 } 734 }
739 735
740 BLINK_MEDIA_LOG << "canPlayType(" << (void*)this << ", " << mimeType 736 BLINK_MEDIA_LOG << "canPlayType(" << (void*)this << ", " << mimeType
741 << ") -> " << canPlay; 737 << ") -> " << canPlay;
742 738
743 return canPlay; 739 return canPlay;
744 } 740 }
745 741
(...skipping 3417 matching lines...) Expand 10 before | Expand all | Expand 10 after
4163 4159
4164 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() 4160 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect()
4165 const { 4161 const {
4166 IntRect result; 4162 IntRect result;
4167 if (LayoutObject* object = m_element->layoutObject()) 4163 if (LayoutObject* object = m_element->layoutObject())
4168 result = object->absoluteBoundingBoxRect(); 4164 result = object->absoluteBoundingBoxRect();
4169 return result; 4165 return result;
4170 } 4166 }
4171 4167
4172 } // namespace blink 4168 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLMediaElement.h ('k') | third_party/WebKit/Source/core/loader/DocumentLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698