Index: chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaInfo.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaInfo.java b/chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaInfo.java |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3ee4276cb3618aa780a56e37cd05c06201f6f38d |
--- /dev/null |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaInfo.java |
@@ -0,0 +1,84 @@ |
+// Copyright 2015 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.chrome.browser.media.ui; |
+ |
+import android.text.TextUtils; |
+ |
+/** |
+ * Exposes information about the current media to the external clients. |
+ */ |
+public class MediaInfo { |
+ |
+ // Playback state enum. |
+ public static final int PLAYING = 0; |
+ public static final int PAUSED = 1; |
+ |
+ /** |
+ * The title of the media |
+ */ |
+ public String title; |
+ |
+ /** |
+ * The current state of the media, paused or not. |
+ */ |
+ public boolean isPaused; |
+ |
+ /** |
+ * The origin (scheme + host) of the tab containing the media |
mlamouri (slow - plz ping)
2015/06/22 14:34:17
Does it include the port? If not, just say "origin
whywhat
2015/06/23 19:39:10
It doesn't if the port is the default. Should just
|
+ */ |
+ public String origin; |
+ |
+ /** |
+ * The id of the tab containing the media |
+ */ |
+ public int tabId; |
+ |
+ /** |
+ * Create a new MediaInfo |
+ * @param title |
+ * @param state |
+ * @param origin |
+ * @param tabId |
+ */ |
+ public MediaInfo( |
+ String title, |
+ boolean isPaused, |
+ String origin, |
+ int tabId) { |
+ this.title = title; |
+ this.isPaused = isPaused; |
+ this.origin = origin; |
+ this.tabId = tabId; |
+ } |
+ |
+ /** |
+ * Copy a media info |
+ * @param other the source. |
+ */ |
+ public MediaInfo(MediaInfo other) { |
+ this(other.title, other.isPaused, other.origin, other.tabId); |
+ } |
+ |
+ @Override |
+ public boolean equals(Object obj) { |
+ if (obj == this) return true; |
+ if (!(obj instanceof MediaInfo)) return false; |
+ |
+ MediaInfo other = (MediaInfo) obj; |
+ return isPaused == other.isPaused |
+ && tabId == other.tabId |
+ && TextUtils.equals(title, other.title) |
+ && TextUtils.equals(origin, other.origin); |
+ } |
+ |
+ @Override |
+ public int hashCode() { |
+ int result = isPaused ? 1 : 0; |
+ result = 31 * result + (title == null ? 0 : title.hashCode()); |
+ result = 31 * result + (origin == null ? 0 : origin.hashCode()); |
+ result = 31 * result + tabId; |
+ return result; |
+ } |
+} |