| OLD | NEW |
| 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 #ifndef CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_DELEGATE_ANDROID_H_ | 5 #ifndef CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_DELEGATE_ANDROID_H_ |
| 6 #define CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_DELEGATE_ANDROID_H_ | 6 #define CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_DELEGATE_ANDROID_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 | 9 |
| 10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
| 11 #include "content/browser/media/session/media_session_delegate.h" | 11 #include "content/browser/media/session/media_session_delegate.h" |
| 12 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 | 14 |
| 15 // MediaSessionDelegateAndroid handles the audio focus at a system level on | 15 // MediaSessionDelegateAndroid handles the audio focus at a system level on |
| 16 // Android. It is also proxying the JNI calls. | 16 // Android. It is also proxying the JNI calls. |
| 17 class MediaSessionDelegateAndroid : public MediaSessionDelegate { | 17 class MediaSessionDelegateAndroid : public MediaSessionDelegate { |
| 18 public: | 18 public: |
| 19 static bool Register(JNIEnv* env); | 19 static bool Register(JNIEnv* env); |
| 20 | 20 |
| 21 explicit MediaSessionDelegateAndroid(MediaSession* media_session); | 21 explicit MediaSessionDelegateAndroid(MediaSession* media_session); |
| 22 ~MediaSessionDelegateAndroid(); | 22 ~MediaSessionDelegateAndroid(); |
| 23 | 23 |
| 24 void Initialize(); | 24 void Initialize(); |
| 25 | 25 |
| 26 bool RequestAudioFocus(MediaSession::Type type) override; | 26 bool RequestAudioFocus( |
| 27 AudioFocusManager::AudioFocusType audio_focus_type) override; |
| 27 void AbandonAudioFocus() override; | 28 void AbandonAudioFocus() override; |
| 28 | 29 |
| 29 // Called when the Android system requests the MediaSession to be suspended. | 30 // Called when the Android system requests the MediaSession to be suspended. |
| 30 // Called by Java through JNI. | 31 // Called by Java through JNI. |
| 31 void OnSuspend(JNIEnv* env, | 32 void OnSuspend(JNIEnv* env, |
| 32 const base::android::JavaParamRef<jobject>& obj, | 33 const base::android::JavaParamRef<jobject>& obj, |
| 33 jboolean temporary); | 34 jboolean temporary); |
| 34 | 35 |
| 35 // Called when the Android system requests the MediaSession to be resumed. | 36 // Called when the Android system requests the MediaSession to be resumed. |
| 36 // Called by Java through JNI. | 37 // Called by Java through JNI. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 49 private: | 50 private: |
| 50 // Weak pointer because |this| is owned by |media_session_|. | 51 // Weak pointer because |this| is owned by |media_session_|. |
| 51 MediaSession* media_session_; | 52 MediaSession* media_session_; |
| 52 base::android::ScopedJavaGlobalRef<jobject> j_media_session_delegate_; | 53 base::android::ScopedJavaGlobalRef<jobject> j_media_session_delegate_; |
| 53 | 54 |
| 54 DISALLOW_COPY_AND_ASSIGN(MediaSessionDelegateAndroid); | 55 DISALLOW_COPY_AND_ASSIGN(MediaSessionDelegateAndroid); |
| 55 }; | 56 }; |
| 56 | 57 |
| 57 } // namespace content | 58 } // namespace content |
| 58 | 59 |
| 59 #endif // CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_DELEGATE_ANDROID_H_ | 60 #endif // CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_DELEGATE_ANDROID_H_ |
| OLD | NEW |