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

Unified Diff: content/public/android/java/src/org/chromium/content_public/common/MediaMetadata.java

Issue 1458703003: Media Session API: use MediaMetadata in the browser process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@media_session_browser_side
Patch Set: remove dependencies from other CLs Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
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
new file mode 100644
index 0000000000000000000000000000000000000000..fc58e18a56eac62a6f39bfbc2b79cbe25a4689d0
--- /dev/null
+++ b/content/public/android/java/src/org/chromium/content_public/common/MediaMetadata.java
@@ -0,0 +1,68 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.content_public.common;
+
+import org.chromium.base.annotations.CalledByNative;
+import org.chromium.base.annotations.JNINamespace;
+
+/**
+ * The MediaMetadata class carries information related to a media session. It is
+ * the Java counterpart of content::MediaMetadata.
+ */
+@JNINamespace("content")
+public class MediaMetadata {
+
+ /**
+ * Title associated to the media session.
+ */
+ public String title;
Ted C 2016/03/01 17:18:11 Can these be final? Not a big fan of mutable memb
mlamouri (slow - plz ping) 2016/03/16 15:47:16 Hmm, I guess I tried to use this like a struct (ie
+
+ /**
+ * Artist name associated to the media session.
+ */
+ public String artist;
+
+ /**
+ * Album name associated to the media session.
+ */
+ public String album;
+
+ /*
+ * Creates a new MediaMetadat from the C++ code. This is exactly like the
+ * constructor below apart that it can be called by native code.
+ */
+ @CalledByNative
+ private static MediaMetadata create(String title, String artist, String album) {
+ return new MediaMetadata(title, artist, album);
+ }
+
+ /**
+ * Creates a new MediaMetadata.
+ */
+ public MediaMetadata(String title, String artist, String album) {
+ this.title = title;
Ted C 2016/03/01 17:18:11 from my comment earlier in the change, there is no
mlamouri (slow - plz ping) 2016/03/16 15:47:16 Done. Used @NonNull and checked values coming from
+ this.artist = artist;
+ this.album = album;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) return true;
+ if (!(obj instanceof MediaMetadata)) return false;
+
+ MediaMetadata other = (MediaMetadata) obj;
+ return title.equals(other.title)
Ted C 2016/03/01 17:18:11 Use TextUtils.equals
mlamouri (slow - plz ping) 2016/03/16 15:47:16 Done.
+ && artist.equals(other.artist)
+ && album.equals(other.album);
+ }
+
+ @Override
+ public int hashCode() {
+ int result = title == null ? 0 : title.hashCode();
+ result = 31 * result + (artist == null ? 0 : artist.hashCode());
+ result = 31 * result + (album == null ? 0 : album.hashCode());
+ return result;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698