[Mac, iOS] Add source application accounting to AVURLAsset.
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 May 2014 01:06:28 +0000 (01:06 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 May 2014 01:06:28 +0000 (01:06 +0000)
https://bugs.webkit.org/show_bug.cgi?id=132637

Reviewed by Eric Carlson.

Source/WebCore:
Properly account for the application responisble for data loading by passing the source
application identifier through to AVFoundation through AVURLAsset options.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::parseAttribute):
* html/HTMLMediaElement.h:
* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::sourceApplicationIdentifier):
* platform/graphics/MediaPlayer.h:
(WebCore::MediaPlayerClient::mediaPlayerSourceApplicationIdentifier):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL):
* platform/network/NetworkingContext.h:

Source/WebKit/mac:
Add accessor for sourceApplicationIdentifier.

* WebCoreSupport/WebFrameNetworkingContext.h:
* WebCoreSupport/WebFrameNetworkingContext.mm:
(WebFrameNetworkingContext::sourceApplicationIdentifier):

Source/WebKit2:
Add accessor for sourceApplicationIdentifier.

* NetworkProcess/RemoteNetworkingContext.h:
* NetworkProcess/mac/RemoteNetworkingContext.mm:
(WebKit::RemoteNetworkingContext::sourceApplicationIdentifier):
* WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.h:
* WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm:
(WebKit::WebFrameNetworkingContext::sourceApplicationIdentifier):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@168512 268f45cc-cd09-0410-ab3c-d52691b4dbfc

15 files changed:
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/platform/graphics/MediaPlayer.cpp
Source/WebCore/platform/graphics/MediaPlayer.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
Source/WebCore/platform/network/NetworkingContext.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebFrameNetworkingContext.h
Source/WebKit/mac/WebCoreSupport/WebFrameNetworkingContext.mm
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/RemoteNetworkingContext.h
Source/WebKit2/NetworkProcess/mac/RemoteNetworkingContext.mm
Source/WebKit2/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.h
Source/WebKit2/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm

index a85bb63..76cd4fa 100644 (file)
@@ -1,5 +1,26 @@
 2014-05-08  Jer Noble  <jer.noble@apple.com>
 
+        [Mac, iOS] Add source application accounting to AVURLAsset.
+        https://bugs.webkit.org/show_bug.cgi?id=132637
+
+        Reviewed by Eric Carlson.
+
+        Properly account for the application responisble for data loading by passing the source
+        application identifier through to AVFoundation through AVURLAsset options.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::parseAttribute):
+        * html/HTMLMediaElement.h:
+        * platform/graphics/MediaPlayer.cpp:
+        (WebCore::MediaPlayer::sourceApplicationIdentifier):
+        * platform/graphics/MediaPlayer.h:
+        (WebCore::MediaPlayerClient::mediaPlayerSourceApplicationIdentifier):
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL):
+        * platform/network/NetworkingContext.h:
+
+2014-05-08  Jer Noble  <jer.noble@apple.com>
+
         [MSE][Mac] Move AVStreamDataParser off-main-thread.
         https://bugs.webkit.org/show_bug.cgi?id=132698
 
index 758c47c..b194638 100644 (file)
@@ -62,6 +62,7 @@
 #include "MediaList.h"
 #include "MediaQueryEvaluator.h"
 #include "MediaSessionManager.h"
+#include "NetworkingContext.h"
 #include "PageActivityAssertionToken.h"
 #include "PageGroup.h"
 #include "PageThrottler.h"
@@ -5628,6 +5629,15 @@ bool HTMLMediaElement::mediaPlayerShouldWaitForResponseToAuthenticationChallenge
     return true;
 }
 
+String HTMLMediaElement::mediaPlayerSourceApplicationIdentifier() const
+{
+    if (Frame* frame = document().frame()) {
+        if (NetworkingContext* networkingContext = frame->loader().networkingContext())
+            return networkingContext->sourceApplicationIdentifier();
+    }
+    return emptyString();
+}
+
 void HTMLMediaElement::removeBehaviorsRestrictionsAfterFirstUserGesture()
 {
     m_mediaSession->removeBehaviorRestriction(HTMLMediaSession::RequireUserGestureForLoad);
index 4d44d95..f51c0f1 100644 (file)
@@ -566,6 +566,7 @@ private:
 
     virtual bool mediaPlayerShouldWaitForResponseToAuthenticationChallenge(const AuthenticationChallenge&) override;
     virtual void mediaPlayerHandlePlaybackCommand(MediaSession::RemoteControlCommandType command) override { didReceiveRemoteControlCommand(command); }
+    virtual String mediaPlayerSourceApplicationIdentifier() const;
 
     void loadTimerFired(Timer<HTMLMediaElement>&);
     void progressEventTimerFired(Timer<HTMLMediaElement>&);
index a10e392..a53a8f9 100644 (file)
@@ -1389,6 +1389,14 @@ void MediaPlayer::handlePlaybackCommand(MediaSession::RemoteControlCommandType c
     m_mediaPlayerClient->mediaPlayerHandlePlaybackCommand(command);
 }
 
+String MediaPlayer::sourceApplicationIdentifier() const
+{
+    if (!m_mediaPlayerClient)
+        return emptyString();
+
+    return m_mediaPlayerClient->mediaPlayerSourceApplicationIdentifier();
+}
+
 void MediaPlayerFactorySupport::callRegisterMediaEngine(MediaEngineRegister registerMediaEngine)
 {
     registerMediaEngine(addMediaEngine);
index 20a910a..9a65d0c 100644 (file)
@@ -264,6 +264,8 @@ public:
 
     virtual bool mediaPlayerShouldWaitForResponseToAuthenticationChallenge(const AuthenticationChallenge&) { return false; }
     virtual void mediaPlayerHandlePlaybackCommand(MediaSession::RemoteControlCommandType) { }
+
+    virtual String mediaPlayerSourceApplicationIdentifier() const { return emptyString(); }
 };
 
 class MediaPlayerSupportsTypeClient {
@@ -575,6 +577,7 @@ public:
 
     bool shouldWaitForResponseToAuthenticationChallenge(const AuthenticationChallenge&);
     void handlePlaybackCommand(MediaSession::RemoteControlCommandType);
+    String sourceApplicationIdentifier() const;
 
 private:
     MediaPlayer(MediaPlayerClient*);
index 7e3e9fb..58c3ca1 100644 (file)
@@ -158,6 +158,8 @@ SOFT_LINK_POINTER(AVFoundation, AVLayerVideoGravityResizeAspectFill, NSString *)
 SOFT_LINK_POINTER(AVFoundation, AVLayerVideoGravityResize, NSString *)
 SOFT_LINK_POINTER(CoreVideo, kCVPixelBufferPixelFormatTypeKey, NSString *)
 
+SOFT_LINK_POINTER_OPTIONAL(AVFoundation, AVURLAssetClientBundleIdentifierKey, NSString *)
+
 SOFT_LINK_CONSTANT(CoreMedia, kCMTimeZero, CMTime)
 
 #define AVPlayer getAVPlayerClass()
@@ -175,6 +177,7 @@ SOFT_LINK_CONSTANT(CoreMedia, kCMTimeZero, CMTime)
 #define AVMediaTypeMetadata getAVMediaTypeMetadata()
 #define AVPlayerItemDidPlayToEndTimeNotification getAVPlayerItemDidPlayToEndTimeNotification()
 #define AVURLAssetInheritURIQueryComponentFromReferencingURIKey getAVURLAssetInheritURIQueryComponentFromReferencingURIKey()
+#define AVURLAssetClientBundleIdentifierKey getAVURLAssetClientBundleIdentifierKey()
 #define AVAssetImageGeneratorApertureModeCleanAperture getAVAssetImageGeneratorApertureModeCleanAperture()
 #define AVURLAssetReferenceRestrictionsKey getAVURLAssetReferenceRestrictionsKey()
 #define AVLayerVideoGravityResizeAspect getAVLayerVideoGravityResizeAspect()
@@ -660,6 +663,10 @@ void MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL(const String& url)
     if (player()->doesHaveAttribute("x-itunes-inherit-uri-query-component"))
         [options.get() setObject: [NSNumber numberWithBool: TRUE] forKey: AVURLAssetInheritURIQueryComponentFromReferencingURIKey];
 
+    String identifier = player()->sourceApplicationIdentifier();
+    if (!identifier.isEmpty() && AVURLAssetClientBundleIdentifierKey)
+        [options setObject:identifier forKey:AVURLAssetClientBundleIdentifierKey];
+
 #if ENABLE(AVF_CAPTIONS)
     const Vector<RefPtr<PlatformTextTrack>>& outOfBandTrackSources = player()->outOfBandTrackSources();
     if (!outOfBandTrackSources.isEmpty()) {
index fcffc04..40908ef 100644 (file)
@@ -57,6 +57,8 @@ public:
     virtual ResourceError blockedError(const ResourceRequest&) const = 0;
 #endif
 
+    virtual String sourceApplicationIdentifier() const { return emptyString(); }
+
 #if PLATFORM(COCOA) || USE(CFNETWORK) || USE(SOUP)
     virtual NetworkStorageSession& storageSession() const = 0;
 #endif
index e7c8573..97f262e 100644 (file)
@@ -1,3 +1,16 @@
+2014-05-08  Jer Noble  <jer.noble@apple.com>
+
+        [Mac, iOS] Add source application accounting to AVURLAsset.
+        https://bugs.webkit.org/show_bug.cgi?id=132637
+
+        Reviewed by Eric Carlson.
+
+        Add accessor for sourceApplicationIdentifier.
+
+        * WebCoreSupport/WebFrameNetworkingContext.h:
+        * WebCoreSupport/WebFrameNetworkingContext.mm:
+        (WebFrameNetworkingContext::sourceApplicationIdentifier):
+
 2014-05-08  Anders Carlsson  <andersca@apple.com>
 
         Use a different install name for WebKitLegacy.framework for staged framework builds
index eb20cfd..8226c8e 100644 (file)
@@ -55,6 +55,7 @@ private:
     virtual bool localFileContentSniffingEnabled() const override;
     virtual SchedulePairHashSet* scheduledRunLoopPairs() const override;
     virtual RetainPtr<CFDataRef> sourceApplicationAuditData() const override;
+    virtual String sourceApplicationIdentifier() const override;
     virtual WebCore::ResourceError blockedError(const WebCore::ResourceRequest&) const override;
     virtual WebCore::NetworkStorageSession& storageSession() const override;
 
index 1b15eab..896067a 100644 (file)
@@ -104,6 +104,11 @@ RetainPtr<CFDataRef> WebFrameNetworkingContext::sourceApplicationAuditData() con
     return reinterpret_cast<CFDataRef>(webview._sourceApplicationAuditData);
 }
 
+String WebFrameNetworkingContext::sourceApplicationIdentifier() const
+{
+    return [[NSBundle mainBundle] bundleIdentifier];
+}
+
 ResourceError WebFrameNetworkingContext::blockedError(const ResourceRequest& request) const
 {
     return frame()->loader().client().blockedError(request);
index 56325b8..7d8d049 100644 (file)
@@ -1,3 +1,19 @@
+2014-05-08  Jer Noble  <jer.noble@apple.com>
+
+        [Mac, iOS] Add source application accounting to AVURLAsset.
+        https://bugs.webkit.org/show_bug.cgi?id=132637
+
+        Reviewed by Eric Carlson.
+
+        Add accessor for sourceApplicationIdentifier.
+
+        * NetworkProcess/RemoteNetworkingContext.h:
+        * NetworkProcess/mac/RemoteNetworkingContext.mm:
+        (WebKit::RemoteNetworkingContext::sourceApplicationIdentifier):
+        * WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.h:
+        * WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm:
+        (WebKit::WebFrameNetworkingContext::sourceApplicationIdentifier):
+
 2014-05-08  Tim Horton  <timothy_horton@apple.com>
 
         [iOS WebKit2] Flush RemoteLayerBackingStore contexts on a secondary queue
index f5cccc1..1fa32e2 100644 (file)
@@ -64,6 +64,7 @@ private:
     void setLocalFileContentSniffingEnabled(bool value) { m_localFileContentSniffingEnabled = value; }
     virtual bool localFileContentSniffingEnabled() const override;
     virtual RetainPtr<CFDataRef> sourceApplicationAuditData() const override;
+    virtual String sourceApplicationIdentifier() const override;
     virtual WebCore::ResourceError blockedError(const WebCore::ResourceRequest&) const override;
 #endif
 
index 5b9eb38..b321efb 100644 (file)
@@ -80,6 +80,11 @@ RetainPtr<CFDataRef> RemoteNetworkingContext::sourceApplicationAuditData() const
 #endif
 }
 
+String RemoteNetworkingContext::sourceApplicationIdentifier() const
+{
+    return SessionTracker::getIdentifierBase();
+}
+
 ResourceError RemoteNetworkingContext::blockedError(const ResourceRequest& request) const
 {
     return WebKit::blockedError(request);
index def2038..fde6d78 100644 (file)
@@ -57,6 +57,7 @@ private:
     virtual bool localFileContentSniffingEnabled() const override;
     virtual SchedulePairHashSet* scheduledRunLoopPairs() const override;
     virtual RetainPtr<CFDataRef> sourceApplicationAuditData() const override;
+    virtual String sourceApplicationIdentifier() const override;
     virtual WebCore::ResourceError blockedError(const WebCore::ResourceRequest&) const override;
     virtual WebCore::NetworkStorageSession& storageSession() const override;
 };
index bbc92d9..5edb425 100644 (file)
@@ -101,6 +101,11 @@ RetainPtr<CFDataRef> WebFrameNetworkingContext::sourceApplicationAuditData() con
 #endif
 }
 
+String WebFrameNetworkingContext::sourceApplicationIdentifier() const
+{
+    return SessionTracker::getIdentifierBase();
+}
+
 ResourceError WebFrameNetworkingContext::blockedError(const ResourceRequest& request) const
 {
     return frame()->loader().client().blockedError(request);