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

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/MediaSessionImpl.java

Issue 2526533002: Allow MediaSession in iframes to be routed (Closed)
Patch Set: nits Created 4 years 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 package org.chromium.content.browser; 5 package org.chromium.content.browser;
6 6
7 import org.chromium.base.ObserverList; 7 import org.chromium.base.ObserverList;
8 import org.chromium.base.annotations.CalledByNative; 8 import org.chromium.base.annotations.CalledByNative;
9 import org.chromium.base.annotations.JNINamespace; 9 import org.chromium.base.annotations.JNINamespace;
10 import org.chromium.content_public.browser.MediaSession; 10 import org.chromium.content_public.browser.MediaSession;
11 import org.chromium.content_public.browser.MediaSessionObserver; 11 import org.chromium.content_public.browser.MediaSessionObserver;
12 import org.chromium.content_public.browser.WebContents; 12 import org.chromium.content_public.browser.WebContents;
13 import org.chromium.content_public.common.MediaMetadata; 13 import org.chromium.content_public.common.MediaMetadata;
14 14
15 import java.util.HashSet;
16
15 /** 17 /**
16 * The MediaSessionImpl Java wrapper to allow communicating with the native Medi aSessionImpl object. 18 * The MediaSessionImpl Java wrapper to allow communicating with the native Medi aSessionImpl object.
17 * The object is owned by Java WebContentsImpl instead of native to avoid introd ucing a new garbage 19 * The object is owned by Java WebContentsImpl instead of native to avoid introd ucing a new garbage
18 * collection root. 20 * collection root.
19 */ 21 */
20 @JNINamespace("content") 22 @JNINamespace("content")
21 public class MediaSessionImpl extends MediaSession { 23 public class MediaSessionImpl extends MediaSession {
22 private long mNativeMediaSessionAndroid; 24 private long mNativeMediaSessionAndroid;
23 25
24 private ObserverList<MediaSessionObserver> mObservers; 26 private ObserverList<MediaSessionObserver> mObservers;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 } 88 }
87 89
88 @CalledByNative 90 @CalledByNative
89 private void mediaSessionMetadataChanged(MediaMetadata metadata) { 91 private void mediaSessionMetadataChanged(MediaMetadata metadata) {
90 for (mObserversIterator.rewind(); mObserversIterator.hasNext();) { 92 for (mObserversIterator.rewind(); mObserversIterator.hasNext();) {
91 mObserversIterator.next().mediaSessionMetadataChanged(metadata); 93 mObserversIterator.next().mediaSessionMetadataChanged(metadata);
92 } 94 }
93 } 95 }
94 96
95 @CalledByNative 97 @CalledByNative
96 private void mediaSessionEnabledAction(int action) { 98 private void mediaSessionActionsChanged(int[] actions) {
99 HashSet<Integer> actionSet = new HashSet<Integer>();
100 for (int action : actions) actionSet.add(action);
101
97 for (mObserversIterator.rewind(); mObserversIterator.hasNext();) { 102 for (mObserversIterator.rewind(); mObserversIterator.hasNext();) {
98 mObserversIterator.next().mediaSessionEnabledAction(action); 103 mObserversIterator.next().mediaSessionActionsChanged(actionSet);
99 } 104 }
100 } 105 }
101 106
102 @CalledByNative
103 private void mediaSessionDisabledAction(int action) {
104 for (mObserversIterator.rewind(); mObserversIterator.hasNext();) {
105 mObserversIterator.next().mediaSessionDisabledAction(action);
106 }
107 }
108
109 @CalledByNative 107 @CalledByNative
110 private static MediaSessionImpl create(long nativeMediaSession) { 108 private static MediaSessionImpl create(long nativeMediaSession) {
111 return new MediaSessionImpl(nativeMediaSession); 109 return new MediaSessionImpl(nativeMediaSession);
112 } 110 }
113 111
114 private MediaSessionImpl(long nativeMediaSession) { 112 private MediaSessionImpl(long nativeMediaSession) {
115 mNativeMediaSessionAndroid = nativeMediaSession; 113 mNativeMediaSessionAndroid = nativeMediaSession;
116 mObservers = new ObserverList<MediaSessionObserver>(); 114 mObservers = new ObserverList<MediaSessionObserver>();
117 mObserversIterator = mObservers.rewindableIterator(); 115 mObserversIterator = mObservers.rewindableIterator();
118 } 116 }
119 117
120 private native void nativeResume(long nativeMediaSessionAndroid); 118 private native void nativeResume(long nativeMediaSessionAndroid);
121 private native void nativeSuspend(long nativeMediaSessionAndroid); 119 private native void nativeSuspend(long nativeMediaSessionAndroid);
122 private native void nativeStop(long nativeMediaSessionAndroid); 120 private native void nativeStop(long nativeMediaSessionAndroid);
123 private native void nativeDidReceiveAction(long nativeMediaSessionAndroid, i nt action); 121 private native void nativeDidReceiveAction(long nativeMediaSessionAndroid, i nt action);
124 private static native MediaSessionImpl nativeGetMediaSessionFromWebContents( 122 private static native MediaSessionImpl nativeGetMediaSessionFromWebContents(
125 WebContents contents); 123 WebContents contents);
126 } 124 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698