| 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 #include "content/browser/media/session/media_session_delegate_android.h" | 5 #include "content/browser/media/session/media_session_delegate_android.h" |
| 6 | 6 |
| 7 #include "base/android/context_utils.h" | 7 #include "base/android/context_utils.h" |
| 8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
| 9 #include "jni/MediaSessionDelegate_jni.h" | 9 #include "jni/MediaSessionDelegate_jni.h" |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 void MediaSessionDelegateAndroid::Initialize() { | 29 void MediaSessionDelegateAndroid::Initialize() { |
| 30 JNIEnv* env = base::android::AttachCurrentThread(); | 30 JNIEnv* env = base::android::AttachCurrentThread(); |
| 31 DCHECK(env); | 31 DCHECK(env); |
| 32 j_media_session_delegate_.Reset(Java_MediaSessionDelegate_create( | 32 j_media_session_delegate_.Reset(Java_MediaSessionDelegate_create( |
| 33 env, | 33 env, |
| 34 base::android::GetApplicationContext(), | 34 base::android::GetApplicationContext(), |
| 35 reinterpret_cast<intptr_t>(this))); | 35 reinterpret_cast<intptr_t>(this))); |
| 36 } | 36 } |
| 37 | 37 |
| 38 bool MediaSessionDelegateAndroid::RequestAudioFocus(MediaSession::Type type) { | 38 bool MediaSessionDelegateAndroid::RequestAudioFocus( |
| 39 MediaSession::AudioFocusType type) { |
| 39 JNIEnv* env = base::android::AttachCurrentThread(); | 40 JNIEnv* env = base::android::AttachCurrentThread(); |
| 40 DCHECK(env); | 41 DCHECK(env); |
| 41 return Java_MediaSessionDelegate_requestAudioFocus( | 42 return Java_MediaSessionDelegate_requestAudioFocus( |
| 42 env, j_media_session_delegate_.obj(), | 43 env, j_media_session_delegate_.obj(), |
| 43 type == MediaSession::Type::Transient); | 44 type == MediaSession::AudioFocusType::Transient); |
| 44 } | 45 } |
| 45 | 46 |
| 46 void MediaSessionDelegateAndroid::AbandonAudioFocus() { | 47 void MediaSessionDelegateAndroid::AbandonAudioFocus() { |
| 47 JNIEnv* env = base::android::AttachCurrentThread(); | 48 JNIEnv* env = base::android::AttachCurrentThread(); |
| 48 DCHECK(env); | 49 DCHECK(env); |
| 49 Java_MediaSessionDelegate_abandonAudioFocus( | 50 Java_MediaSessionDelegate_abandonAudioFocus( |
| 50 env, j_media_session_delegate_.obj()); | 51 env, j_media_session_delegate_.obj()); |
| 51 } | 52 } |
| 52 | 53 |
| 53 void MediaSessionDelegateAndroid::OnSuspend( | 54 void MediaSessionDelegateAndroid::OnSuspend( |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 // static | 87 // static |
| 87 std::unique_ptr<MediaSessionDelegate> MediaSessionDelegate::Create( | 88 std::unique_ptr<MediaSessionDelegate> MediaSessionDelegate::Create( |
| 88 MediaSession* media_session) { | 89 MediaSession* media_session) { |
| 89 MediaSessionDelegateAndroid* delegate = | 90 MediaSessionDelegateAndroid* delegate = |
| 90 new MediaSessionDelegateAndroid(media_session); | 91 new MediaSessionDelegateAndroid(media_session); |
| 91 delegate->Initialize(); | 92 delegate->Initialize(); |
| 92 return std::unique_ptr<MediaSessionDelegate>(delegate); | 93 return std::unique_ptr<MediaSessionDelegate>(delegate); |
| 93 } | 94 } |
| 94 | 95 |
| 95 } // namespace content | 96 } // namespace content |
| OLD | NEW |