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

Unified Diff: content/browser/media/android/media_session.h

Issue 1159113006: [Android] A prototype of the interactive media notification. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added browser tests Created 5 years, 6 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/browser/media/android/media_session.h
diff --git a/content/browser/media/android/media_session.h b/content/browser/media/android/media_session.h
index f36bb4ef13d79f35abbb55269d149ea10be349a9..3d7f83eba362966f90583d3e3e40675eecb4e827 100644
--- a/content/browser/media/android/media_session.h
+++ b/content/browser/media/android/media_session.h
@@ -10,12 +10,15 @@
#include "base/android/scoped_java_ref.h"
#include "base/id_map.h"
#include "content/common/content_export.h"
+#include "content/public/browser/android/media_controls_delegate.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
-namespace content {
class MediaSessionBrowserTest;
+
+namespace content {
+
class MediaSessionObserver;
// MediaSession manages the Android AudioFocus for a given WebContents. It is
@@ -29,8 +32,9 @@ class MediaSessionObserver;
// case of Transient and Content audio focus are both requested.
// Android system interaction occurs in the Java counterpart to this class.
class CONTENT_EXPORT MediaSession
- : public content::WebContentsObserver,
- protected content::WebContentsUserData<MediaSession> {
+ : public WebContentsObserver,
+ public MediaControlsDelegate,
+ protected WebContentsUserData<MediaSession> {
public:
enum class Type {
Content,
@@ -66,21 +70,24 @@ class CONTENT_EXPORT MediaSession
// Called by Java through JNI.
void OnResume(JNIEnv* env, jobject obj);
- protected:
mlamouri (slow - plz ping) 2015/06/18 16:43:23 I had that so we had a very specific layer exposed
whywhat 2015/06/19 16:00:34 If you declare a friend class it has access to all
mlamouri (slow - plz ping) 2015/06/22 14:34:17 May I give you my resignation? :)
- friend class content::MediaSessionBrowserTest;
+ private:
+ friend class content::WebContentsUserData<MediaSession>;
+ friend class ::MediaSessionBrowserTest;
// Resets the |j_media_session_| ref to prevent calling the Java backend
// during content_browsertests.
void ResetJavaRefForTest();
-
bool IsActiveForTest() const;
Type audio_focus_type_for_test() const;
+ void RemoveAllPlayersForTest();
void OnSuspend(bool temporary);
void OnResume();
- private:
- friend class content::WebContentsUserData<MediaSession>;
+ // MediaControlsDelegate implementation.
+ void OnControlsPause() override;
+ void OnControlsResume() override;
+ bool IsPaused() override;
enum class State {
Active,
@@ -120,6 +127,12 @@ class CONTENT_EXPORT MediaSession
// MediaSession if the audio focus really need to be abandoned.
void AbandonSystemAudioFocusIfNeeded();
+ // Shows media controls if the type is right and WebContentsDelegate is set.
+ void ShowMediaControlsIfNeeded(Type type);
+
+ // Hides media controls if the type is right and WebContentsDelegate is set.
+ void HideMediaControlsIfNeeded(Type type);
+
base::android::ScopedJavaGlobalRef<jobject> j_media_session_;
PlayersMap players_;

Powered by Google App Engine
This is Rietveld 408576698