| Index: content/public/android/java/src/org/chromium/content_public/common/MediaMetadata.java
|
| diff --git a/content/public/android/java/src/org/chromium/content_public/common/MediaMetadata.java b/content/public/android/java/src/org/chromium/content_public/common/MediaMetadata.java
|
| index a1e982869563666dd3c1c09d5b083da7bd780092..93033475d9c806f3cd87147083c37759967d9e28 100644
|
| --- a/content/public/android/java/src/org/chromium/content_public/common/MediaMetadata.java
|
| +++ b/content/public/android/java/src/org/chromium/content_public/common/MediaMetadata.java
|
| @@ -4,18 +4,87 @@
|
|
|
| package org.chromium.content_public.common;
|
|
|
| +import android.graphics.Rect;
|
| import android.support.annotation.NonNull;
|
| import android.text.TextUtils;
|
|
|
| import org.chromium.base.annotations.CalledByNative;
|
| import org.chromium.base.annotations.JNINamespace;
|
|
|
| +import java.util.ArrayList;
|
| +import java.util.List;
|
| +
|
| /**
|
| * The MediaMetadata class carries information related to a media session. It is
|
| * the Java counterpart of content::MediaMetadata.
|
| */
|
| @JNINamespace("content")
|
| public class MediaMetadata {
|
| + /**
|
| + * The Artwork class carries the artwork information in MediaMetadata. It is the Java
|
| + * counterpart of content::MediaMetadata::Artwork.
|
| + */
|
| + public static class Artwork {
|
| + @NonNull
|
| + private String mSrc;
|
| +
|
| + private String mType;
|
| +
|
| + @NonNull
|
| + private List<Rect> mSizes = new ArrayList<Rect>();
|
| +
|
| + /**
|
| + * Creates a new Artwork.
|
| + */
|
| + public Artwork(@NonNull String src, String type, List<Rect> sizes) {
|
| + mSrc = src;
|
| + mType = type;
|
| + mSizes = sizes;
|
| + }
|
| +
|
| + /**
|
| + * Returns the URL of this Artwork.
|
| + */
|
| + @NonNull
|
| + public String getSrc() {
|
| + return mSrc;
|
| + }
|
| +
|
| + /**
|
| + * Returns the MIME type of this Artwork.
|
| + */
|
| + public String getType() {
|
| + return mType;
|
| + }
|
| +
|
| + /**
|
| + * Returns the hinted sizes of this Artwork.
|
| + */
|
| + public List<Rect> getSizes() {
|
| + return mSizes;
|
| + }
|
| +
|
| + /**
|
| + * Sets the URL of this Artwork.
|
| + */
|
| + public void setSrc(String src) {
|
| + mSrc = src;
|
| + }
|
| +
|
| + /**
|
| + * Sets the MIME type of this Artwork.
|
| + */
|
| + public void setType(String type) {
|
| + mType = type;
|
| + }
|
| +
|
| + /**
|
| + * Sets the sizes of this Artwork.
|
| + */
|
| + public void setSizes(List<Rect> sizes) {
|
| + mSizes = sizes;
|
| + }
|
| + }
|
|
|
| @NonNull
|
| private String mTitle;
|
| @@ -26,6 +95,9 @@ public class MediaMetadata {
|
| @NonNull
|
| private String mAlbum;
|
|
|
| + @NonNull
|
| + private List<Artwork> mArtwork = new ArrayList<Artwork>();
|
| +
|
| /**
|
| * Returns the title associated with the media session.
|
| */
|
| @@ -47,6 +119,10 @@ public class MediaMetadata {
|
| return mAlbum;
|
| }
|
|
|
| + public List<Artwork> getArtwork() {
|
| + return mArtwork;
|
| + }
|
| +
|
| /**
|
| * Sets the title associated with the media session.
|
| * @param title The title to use for the media session.
|
| @@ -72,6 +148,23 @@ public class MediaMetadata {
|
| }
|
|
|
| /**
|
| + * Create a new MediaArtwork from the C++ code, and add it to the Metadata.
|
| + * @param src The URL of the artwork.
|
| + * @param type The MIME type of the artwork.
|
| + * @param flattenedSizes The flattened array of Artwork sizes. In native code, it is of type
|
| + * `std::vector<gfx::Size>` before flattening.
|
| + */
|
| + @CalledByNative
|
| + private void createAndAddArtwork(String src, String type, int[] flattenedSizes) {
|
| + assert (flattenedSizes.length % 2) == 0;
|
| + List<Rect> sizes = new ArrayList<Rect>();
|
| + for (int i = 0; (i + 1) < flattenedSizes.length; i += 2) {
|
| + sizes.add(new Rect(0, 0, flattenedSizes[i], flattenedSizes[i + 1]));
|
| + }
|
| + mArtwork.add(new Artwork(src, type, sizes));
|
| + }
|
| +
|
| + /**
|
| * Creates a new MediaMetadata from the C++ code. This is exactly like the
|
| * constructor below apart that it can be called by native code.
|
| */
|
|
|