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

Side by Side Diff: third_party/WebKit/Source/modules/mediasession/MediaMetadata.cpp

Issue 2013813002: Implement MediaMetadata artwork in Blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed the copy of WebMediaMetadata from MediaMetadata Created 4 years, 6 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "modules/mediasession/MediaMetadata.h" 5 #include "modules/mediasession/MediaMetadata.h"
6 6
7 #include "core/dom/ExecutionContext.h"
8 #include "modules/mediasession/MediaArtwork.h"
7 #include "modules/mediasession/MediaMetadataInit.h" 9 #include "modules/mediasession/MediaMetadataInit.h"
8 #include "wtf/text/WTFString.h"
9 10
10 namespace blink { 11 namespace blink {
11 12
12 // static 13 // static
13 MediaMetadata* MediaMetadata::create(const MediaMetadataInit& metadata) 14 MediaMetadata* MediaMetadata::create(ExecutionContext* context, const MediaMetad ataInit& metadata)
14 { 15 {
15 return new MediaMetadata(metadata); 16 return new MediaMetadata(context, metadata);
16 } 17 }
17 18
18 MediaMetadata::MediaMetadata(const MediaMetadataInit& metadata) 19 MediaMetadata::MediaMetadata(ExecutionContext* context, const MediaMetadataInit& metadata)
19 { 20 {
20 m_data.title = metadata.title(); 21 m_title = metadata.title();
21 m_data.artist = metadata.artist(); 22 m_artist = metadata.artist();
22 m_data.album = metadata.album(); 23 m_album = metadata.album();
24 for (const auto &artwork : metadata.artworks())
25 m_artworks.append(MediaArtwork::create(context, artwork));
23 } 26 }
24 27
25 String MediaMetadata::title() const 28 String MediaMetadata::title() const
26 { 29 {
27 return m_data.title; 30 return m_title;
28 } 31 }
29 32
30 String MediaMetadata::artist() const 33 String MediaMetadata::artist() const
31 { 34 {
32 return m_data.artist; 35 return m_artist;
33 } 36 }
34 37
35 String MediaMetadata::album() const 38 String MediaMetadata::album() const
36 { 39 {
37 return m_data.album; 40 return m_album;
41 }
42
43 const HeapVector<Member<MediaArtwork>>& MediaMetadata::artworks() const
44 {
45 return m_artworks;
46 }
47
48 MediaMetadata::operator WebMediaMetadata() const
49 {
50 WebMediaMetadata webMetadata;
51 webMetadata.title = m_title;
52 webMetadata.artist = m_artist;
53 webMetadata.album = m_album;
54 WebVector<WebMediaArtwork> webArtworks(m_artworks.size());
55 for (size_t i = 0; i < m_artworks.size(); ++i) {
56 webArtworks[i] = *m_artworks[i]->data();
57 }
58 webMetadata.artworks.swap(webArtworks);
59 return webMetadata;
60 }
61
62 DEFINE_TRACE(MediaMetadata)
63 {
64 visitor->trace(m_artworks);
38 } 65 }
39 66
40 } // namespace blink 67 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698