Title: [148613] trunk/Source/WebCore
Revision
148613
Author
[email protected]
Date
2013-04-17 08:56:46 -0700 (Wed, 17 Apr 2013)

Log Message

[BlackBerry] Add support for filesystem: URLs to BlackBerry Media Player.
https://bugs.webkit.org/show_bug.cgi?id=114686
https://przilla.ott.qnx.com/bugzilla/show_bug.cgi?id=314865

Patch by John Griggs <[email protected]> on 2013-04-17
Reviewed by Rob Buis.

Translate filesystem: URLs to file:// URLs for use by the media player, but only after the filesystem: URL has been checked for security, etc.

* platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp:
(WebCore::MediaPlayerPrivate::load):
(WebCore::MediaPlayerPrivate::onError):
(WebCore::MediaPlayerPrivate::onDurationChanged):
(WebCore::MediaPlayerPrivate::notifyChallengeResult):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (148612 => 148613)


--- trunk/Source/WebCore/ChangeLog	2013-04-17 15:54:47 UTC (rev 148612)
+++ trunk/Source/WebCore/ChangeLog	2013-04-17 15:56:46 UTC (rev 148613)
@@ -1,3 +1,19 @@
+2013-04-17  John Griggs  <[email protected]>
+
+        [BlackBerry] Add support for filesystem: URLs to BlackBerry Media Player.
+        https://bugs.webkit.org/show_bug.cgi?id=114686
+        https://przilla.ott.qnx.com/bugzilla/show_bug.cgi?id=314865
+
+        Reviewed by Rob Buis.
+
+        Translate filesystem: URLs to file:// URLs for use by the media player, but only after the filesystem: URL has been checked for security, etc.
+
+        * platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp:
+        (WebCore::MediaPlayerPrivate::load):
+        (WebCore::MediaPlayerPrivate::onError):
+        (WebCore::MediaPlayerPrivate::onDurationChanged):
+        (WebCore::MediaPlayerPrivate::notifyChallengeResult):
+
 2013-04-17  Brendan Long  <[email protected]>
 
         [GStreamer] Eclipse warnings in MediaPlayerPrivateGStreamer

Modified: trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp (148612 => 148613)


--- trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp	2013-04-17 15:54:47 UTC (rev 148612)
+++ trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp	2013-04-17 15:56:46 UTC (rev 148613)
@@ -23,13 +23,16 @@
 
 #include "CookieManager.h"
 #include "CredentialStorage.h"
+#include "DOMFileSystemBase.h"
 #include "HostWindow.h"
 #include "MediaStreamDescriptor.h"
 #include "MediaStreamRegistry.h"
+#include "SecurityOrigin.h"
 
 #include <BlackBerryPlatformDeviceInfo.h>
 #include <BlackBerryPlatformPrimitives.h>
 #include <BlackBerryPlatformSettings.h>
+#include <BlackBerryPlatformWebFileSystem.h>
 #include <FrameLoaderClientBlackBerry.h>
 
 #if USE(ACCELERATED_COMPOSITING)
@@ -146,7 +149,41 @@
         kurl.setPath(tempPath);
         modifiedUrl = kurl.string();
     }
-    if (modifiedUrl.startsWith("file://")) {
+    // filesystem: URLs refer to entities in the Web File System (WFS) and are
+    // intended to be useable by HTML 5 media elements directly. Unfortunately
+    // the loader for our media player is implemented in a separate process and
+    // does not have access to WFS, so we translate to a file:// URL. Normally
+    // this would be a security violation, but since the MediaElement has
+    // already done a security check on the filesystem: URL as part of the
+    // media resource selection algorithm, we should be OK here.
+    if (modifiedUrl.startsWith("filesystem:")) {
+        KURL kurl = KURL(KURL(), modifiedUrl);
+        KURL mediaURL;
+        WTF::String fsPath;
+        FileSystemType fsType;
+        WebFileSystem::Type type;
+
+        // Extract the root and file paths from WFS
+        DOMFileSystemBase::crackFileSystemURL(kurl, fsType, fsPath);
+        if (fsType == FileSystemTypeTemporary)
+            type = WebFileSystem::Temporary;
+        else
+            type = WebFileSystem::Persistent;
+        WTF::String fsRoot = BlackBerry::Platform::WebFileSystem::rootPathForWebFileSystem(type);
+
+        // Build a BlackBerry::Platform::SecurityOrigin from the document's 
+        // WebCore::SecurityOrigin and serialize it to build the last
+        // path component
+        WebCore::SecurityOrigin* wkOrigin = m_webCorePlayer->mediaPlayerClient()->mediaPlayerOwningDocument()->securityOrigin();
+        BlackBerry::Platform::SecurityOrigin bbOrigin(wkOrigin->protocol(), wkOrigin->host(), wkOrigin->port());
+        WTF::String secOrigin(bbOrigin.serialize('_'));
+
+        // Build a file:// URL from the path components and extract it to 
+        // a string for further processing
+        mediaURL.setProtocol("file");
+        mediaURL.setPath(fsRoot + "/" + secOrigin + "/" + fsPath);
+        modifiedUrl = mediaURL.string();
+    } else if (modifiedUrl.startsWith("file://")) {
         // The QNX Multimedia Framework cannot handle filenames containing URL escape sequences.
         modifiedUrl = decodeURLEscapeSequences(modifiedUrl);
     }
@@ -576,12 +613,12 @@
     updateStates();
 }
 
-void MediaPlayerPrivate::onError(PlatformPlayer::Error type)
+void MediaPlayerPrivate::onError(PlatformPlayer::Error)
 {
     updateStates();
 }
 
-void MediaPlayerPrivate::onDurationChanged(float duration)
+void MediaPlayerPrivate::onDurationChanged(float)
 {
     updateStates();
     m_webCorePlayer->durationChanged();
@@ -722,7 +759,7 @@
         this, m_webCorePlayer->mediaPlayerClient()->mediaPlayerHostWindow()->platformPageClient());
 }
 
-void MediaPlayerPrivate::notifyChallengeResult(const KURL& url, const ProtectionSpace& protectionSpace, AuthenticationChallengeResult result, const Credential& credential)
+void MediaPlayerPrivate::notifyChallengeResult(const KURL& url, const ProtectionSpace&, AuthenticationChallengeResult result, const Credential& credential)
 {
     m_isAuthenticationChallenging = false;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to