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..e6ef01e08d11d266c8d871d60146a0233a430b2e 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,86 @@ |
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. |
+ */ |
+ public String getSrc() { |
mlamouri (slow - plz ping)
2016/06/23 12:52:29
nit: @NonNull maybe?
Zhiqiang Zhang (Slow)
2016/06/23 14:19:25
Done.
|
+ 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 +94,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 +118,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. |
@@ -71,6 +146,11 @@ public class MediaMetadata { |
mAlbum = album; |
} |
+ @CalledByNative |
+ private void addArtwork(Artwork artwork) { |
+ mArtwork.add(artwork); |
+ } |
+ |
/** |
* Creates a new MediaMetadata from the C++ code. This is exactly like the |
* constructor below apart that it can be called by native code. |
@@ -82,6 +162,22 @@ public class MediaMetadata { |
} |
/** |
+ * Create a new MediaArtwork from the C++ code. |
+ * @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 static Artwork createArtwork(String src, String type, int[] flattenedSizes) { |
+ List<Rect> sizes = new ArrayList<Rect>(); |
+ for (int i = 0; i < flattenedSizes.length - 1; i += 2) { |
mlamouri (slow - plz ping)
2016/06/23 12:52:29
nit: add an assert that length is even?
and/or, y
Zhiqiang Zhang (Slow)
2016/06/23 14:19:25
Done.
|
+ sizes.add(new Rect(0, 0, flattenedSizes[i], flattenedSizes[i + 1])); |
+ } |
+ return new Artwork(src, type, sizes); |
+ } |
+ |
+ /** |
* Creates a new MediaMetadata. |
*/ |
public MediaMetadata(@NonNull String title, @NonNull String artist, @NonNull String album) { |