<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[185914] trunk/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/185914">185914</a></dd>
<dt>Author</dt> <dd>mrajca@apple.com</dd>
<dt>Date</dt> <dd>2015-06-24 09:38:55 -0700 (Wed, 24 Jun 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>MediaSession: Support setting of metadata
https://bugs.webkit.org/show_bug.cgi?id=146253
Reviewed by Eric Carlson.
* Modules/mediasession/MediaSession.cpp:
(WebCore::MediaSession::MediaSession): Store a reference to the document so we can use it in setMetadata.
(WebCore::MediaSession::setMetadata): Implemented as described in the Media Session spec.
* Modules/mediasession/MediaSession.h:
* Modules/mediasession/MediaSession.idl: Added the setMetadata method.
* Modules/mediasession/MediaSessionMetadata.h:
(WebCore::MediaSessionMetadata::MediaSessionMetadata): Added to keep track of media session metadata.
(WebCore::MediaSessionMetadata::title):
(WebCore::MediaSessionMetadata::artist):
(WebCore::MediaSessionMetadata::album):
(WebCore::MediaSessionMetadata::artworkURL):
* WebCore.xcodeproj/project.pbxproj: Added MediaSessionMetadata.h.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesmediasessionMediaSessioncpp">trunk/Source/WebCore/Modules/mediasession/MediaSession.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesmediasessionMediaSessionh">trunk/Source/WebCore/Modules/mediasession/MediaSession.h</a></li>
<li><a href="#trunkSourceWebCoreModulesmediasessionMediaSessionidl">trunk/Source/WebCore/Modules/mediasession/MediaSession.idl</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreModulesmediasessionMediaSessionMetadatah">trunk/Source/WebCore/Modules/mediasession/MediaSessionMetadata.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (185913 => 185914)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-06-24 16:36:34 UTC (rev 185913)
+++ trunk/Source/WebCore/ChangeLog        2015-06-24 16:38:55 UTC (rev 185914)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2015-06-23 Matt Rajca <mrajca@apple.com>
+
+ MediaSession: Support setting of metadata
+ https://bugs.webkit.org/show_bug.cgi?id=146253
+
+ Reviewed by Eric Carlson.
+
+ * Modules/mediasession/MediaSession.cpp:
+ (WebCore::MediaSession::MediaSession): Store a reference to the document so we can use it in setMetadata.
+ (WebCore::MediaSession::setMetadata): Implemented as described in the Media Session spec.
+ * Modules/mediasession/MediaSession.h:
+ * Modules/mediasession/MediaSession.idl: Added the setMetadata method.
+ * Modules/mediasession/MediaSessionMetadata.h:
+ (WebCore::MediaSessionMetadata::MediaSessionMetadata): Added to keep track of media session metadata.
+ (WebCore::MediaSessionMetadata::title):
+ (WebCore::MediaSessionMetadata::artist):
+ (WebCore::MediaSessionMetadata::album):
+ (WebCore::MediaSessionMetadata::artworkURL):
+ * WebCore.xcodeproj/project.pbxproj: Added MediaSessionMetadata.h.
+
</ins><span class="cx"> 2015-06-24 Daniel Bates <dabates@apple.com>
</span><span class="cx">
</span><span class="cx"> Content Security Policy error message when frame load is blocked does not read well
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediasessionMediaSessioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediasession/MediaSession.cpp (185913 => 185914)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediasession/MediaSession.cpp        2015-06-24 16:36:34 UTC (rev 185913)
+++ trunk/Source/WebCore/Modules/mediasession/MediaSession.cpp        2015-06-24 16:38:55 UTC (rev 185914)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx">
</span><span class="cx"> #if ENABLE(MEDIA_SESSION)
</span><span class="cx">
</span><ins>+#include "Dictionary.h"
</ins><span class="cx"> #include "Event.h"
</span><span class="cx"> #include "HTMLMediaElement.h"
</span><span class="cx"> #include "MediaSessionManager.h"
</span><span class="lines">@@ -35,7 +36,8 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="cx"> MediaSession::MediaSession(ScriptExecutionContext& context, const String& kind)
</span><del>- : m_kind(kind)
</del><ins>+ : m_document(downcast<Document>(context))
+ , m_kind(kind)
</ins><span class="cx"> {
</span><span class="cx"> if (m_kind == "content")
</span><span class="cx"> m_controls = adoptRef(*new MediaRemoteControls(context));
</span><span class="lines">@@ -72,6 +74,33 @@
</span><span class="cx"> m_activeParticipatingElements.add(&element);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void MediaSession::setMetadata(const Dictionary& metadata)
+{
+ // 5.1.3
+ // 1. Let media session be the current media session.
+ // 2. Let baseURL be the API base URL specified by the entry settings object.
+ // 3. Set media session's title to metadata's title.
+ String title;
+ metadata.get("title", title);
+
+ // 4. Set media session's artist name to metadata's artist.
+ String artist;
+ metadata.get("artist", artist);
+
+ // 5. Set media session's album name to metadata's album.
+ String album;
+ metadata.get("album", album);
+
+ // 6. If metadata's artwork is present, parse it using baseURL, and if that does not return failure, set media
+ // session's artwork URL to the return value.
+ URL artworkURL;
+ String artworkPath;
+ if (metadata.get("artwork", artworkPath))
+ artworkURL = m_document.completeURL(artworkPath);
+
+ m_metadata = MediaSessionMetadata(title, artist, album, artworkURL);
+}
+
</ins><span class="cx"> void MediaSession::releaseSession()
</span><span class="cx"> {
</span><span class="cx"> // 5.1.3
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediasessionMediaSessionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediasession/MediaSession.h (185913 => 185914)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediasession/MediaSession.h        2015-06-24 16:36:34 UTC (rev 185913)
+++ trunk/Source/WebCore/Modules/mediasession/MediaSession.h        2015-06-24 16:38:55 UTC (rev 185914)
</span><span class="lines">@@ -29,9 +29,12 @@
</span><span class="cx"> #if ENABLE(MEDIA_SESSION)
</span><span class="cx">
</span><span class="cx"> #include "MediaRemoteControls.h"
</span><ins>+#include "MediaSessionMetadata.h"
</ins><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><ins>+class Dictionary;
+class Document;
</ins><span class="cx"> class HTMLMediaElement;
</span><span class="cx">
</span><span class="cx"> class MediaSession final : public RefCounted<MediaSession> {
</span><span class="lines">@@ -41,7 +44,7 @@
</span><span class="cx"> Active,
</span><span class="cx"> Interrupted
</span><span class="cx"> };
</span><del>-
</del><ins>+
</ins><span class="cx"> static Ref<MediaSession> create(ScriptExecutionContext& context, const String& kind)
</span><span class="cx"> {
</span><span class="cx"> return adoptRef(*new MediaSession(context, kind));
</span><span class="lines">@@ -55,6 +58,8 @@
</span><span class="cx">
</span><span class="cx"> State currentState() const { return m_currentState; }
</span><span class="cx">
</span><ins>+ void setMetadata(const Dictionary&);
+
</ins><span class="cx"> void releaseSession();
</span><span class="cx">
</span><span class="cx"> // Runs the media session invocation algorithm and returns true on success.
</span><span class="lines">@@ -79,8 +84,10 @@
</span><span class="cx"> HashSet<HTMLMediaElement*> m_activeParticipatingElements;
</span><span class="cx"> HashSet<HTMLMediaElement*>* m_iteratedActiveParticipatingElements { nullptr };
</span><span class="cx">
</span><ins>+ Document& m_document;
</ins><span class="cx"> const String m_kind;
</span><span class="cx"> RefPtr<MediaRemoteControls> m_controls;
</span><ins>+ MediaSessionMetadata m_metadata;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediasessionMediaSessionidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediasession/MediaSession.idl (185913 => 185914)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediasession/MediaSession.idl        2015-06-24 16:36:34 UTC (rev 185913)
+++ trunk/Source/WebCore/Modules/mediasession/MediaSession.idl        2015-06-24 16:38:55 UTC (rev 185914)
</span><span class="lines">@@ -32,6 +32,8 @@
</span><span class="cx"> readonly attribute MediaSessionKind kind;
</span><span class="cx"> readonly attribute MediaRemoteControls? controls;
</span><span class="cx">
</span><ins>+ void setMetadata(Dictionary metadata);
+
</ins><span class="cx"> void releaseSession();
</span><span class="cx"> };
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediasessionMediaSessionMetadatahfromrev185912trunkSourceWebCoreModulesmediasessionMediaSessionidl"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/Modules/mediasession/MediaSessionMetadata.h (from rev 185912, trunk/Source/WebCore/Modules/mediasession/MediaSession.idl) (0 => 185914)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediasession/MediaSessionMetadata.h         (rev 0)
+++ trunk/Source/WebCore/Modules/mediasession/MediaSessionMetadata.h        2015-06-24 16:38:55 UTC (rev 185914)
</span><span class="lines">@@ -0,0 +1,60 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef MediaSessionMetadata_h
+#define MediaSessionMetadata_h
+
+#if ENABLE(MEDIA_SESSION)
+
+#include "URL.h"
+
+namespace WebCore {
+
+struct MediaSessionMetadata {
+ MediaSessionMetadata() = default;
+
+ MediaSessionMetadata(const String& title, const String& artist, const String& album, const URL& artworkURL)
+ : m_title(title)
+ , m_artist(artist)
+ , m_album(album)
+ , m_artworkURL(artworkURL) { }
+
+ String title() const { return m_title; }
+ String artist() const { return m_artist; }
+ String album() const { return m_album; }
+ URL artworkURL() const { return m_artworkURL; }
+
+private:
+ String m_title;
+ String m_artist;
+ String m_album;
+ URL m_artworkURL;
+};
+
+} // namespace WebCore
+
+#endif /* ENABLE(MEDIA_SESSION) */
+
+#endif /* MediaSessionMetadata_h */
</ins></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (185913 => 185914)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-06-24 16:36:34 UTC (rev 185913)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-06-24 16:38:55 UTC (rev 185914)
</span><span class="lines">@@ -5709,6 +5709,7 @@
</span><span class="cx">                 C90F65561B2253BE002163A1 /* MediaSessionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = C90F65541B225396002163A1 /* MediaSessionManager.h */; };
</span><span class="cx">                 C937FE8D1B1F6821008ECC5D /* HTMLMediaElementMediaSession.h in Headers */ = {isa = PBXBuildFile; fileRef = C968B2E61B1E72F700EF1F81 /* HTMLMediaElementMediaSession.h */; };
</span><span class="cx">                 C968B2E81B1E778100EF1F81 /* HTMLMediaElementMediaSession.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C968B2E71B1E778100EF1F81 /* HTMLMediaElementMediaSession.cpp */; };
</span><ins>+                C9D851F01B39DC780085062E /* MediaSessionMetadata.h in Headers */ = {isa = PBXBuildFile; fileRef = C9D851EE1B39DC780085062E /* MediaSessionMetadata.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 C9DADBCB1B1D3B97001F17D8 /* JSMediaSession.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C9DADBC91B1D3B25001F17D8 /* JSMediaSession.cpp */; };
</span><span class="cx">                 C9F87CFE1B28F40E00979B83 /* MediaEventTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = C9F87CFD1B28E5F600979B83 /* MediaEventTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 CA3BF67C10D99BAE00E6CE53 /* ScrollAnimator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CA3BF67B10D99BAE00E6CE53 /* ScrollAnimator.cpp */; };
</span><span class="lines">@@ -13291,6 +13292,7 @@
</span><span class="cx">                 C968B2E51B1E704500EF1F81 /* HTMLMediaElementMediaSession.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = HTMLMediaElementMediaSession.idl; sourceTree = "<group>"; };
</span><span class="cx">                 C968B2E61B1E72F700EF1F81 /* HTMLMediaElementMediaSession.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HTMLMediaElementMediaSession.h; sourceTree = "<group>"; };
</span><span class="cx">                 C968B2E71B1E778100EF1F81 /* HTMLMediaElementMediaSession.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLMediaElementMediaSession.cpp; sourceTree = "<group>"; };
</span><ins>+                C9D851EE1B39DC780085062E /* MediaSessionMetadata.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaSessionMetadata.h; sourceTree = "<group>"; };
</ins><span class="cx">                 C9DADBC91B1D3B25001F17D8 /* JSMediaSession.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaSession.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 C9DADBCA1B1D3B25001F17D8 /* JSMediaSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMediaSession.h; sourceTree = "<group>"; };
</span><span class="cx">                 C9F87CFD1B28E5F600979B83 /* MediaEventTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MediaEventTypes.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -14649,6 +14651,7 @@
</span><span class="cx">                                 C9027F3E1B1D0AB900BFBFEF /* MediaSession.idl */,
</span><span class="cx">                                 C90F65531B225396002163A1 /* MediaSessionManager.cpp */,
</span><span class="cx">                                 C90F65541B225396002163A1 /* MediaSessionManager.h */,
</span><ins>+                                C9D851EE1B39DC780085062E /* MediaSessionMetadata.h */,
</ins><span class="cx">                                 0709D78C1AE55554004E42F8 /* WebMediaSessionManager.cpp */,
</span><span class="cx">                                 0709D78D1AE55554004E42F8 /* WebMediaSessionManager.h */,
</span><span class="cx">                                 0709D7941AE55A29004E42F8 /* WebMediaSessionManagerClient.h */,
</span><span class="lines">@@ -25900,6 +25903,7 @@
</span><span class="cx">                                 C9027F421B1D0AD200BFBFEF /* MediaSession.h in Headers */,
</span><span class="cx">                                 C90F65561B2253BE002163A1 /* MediaSessionManager.h in Headers */,
</span><span class="cx">                                 07638A991884487200E15A1B /* MediaSessionManagerIOS.h in Headers */,
</span><ins>+                                C9D851F01B39DC780085062E /* MediaSessionMetadata.h in Headers */,
</ins><span class="cx">                                 CD3A495F17A9D01B00274E42 /* MediaSource.h in Headers */,
</span><span class="cx">                                 CD641EB31818F5ED00EE4C41 /* MediaSourcePrivate.h in Headers */,
</span><span class="cx">                                 CDC8B5A7180474F70016E685 /* MediaSourcePrivateAVFObjC.h in Headers */,
</span></span></pre>
</div>
</div>
</body>
</html>