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

Side by Side Diff: content/browser/android/content_video_view.h

Issue 13669003: Refactoring ContentVideoViewContextDelegate.java (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix tests Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_ANDROID_CONTENT_VIDEO_VIEW_H_ 5 #ifndef CONTENT_BROWSER_ANDROID_CONTENT_VIDEO_VIEW_H_
6 #define CONTENT_BROWSER_ANDROID_CONTENT_VIDEO_VIEW_H_ 6 #define CONTENT_BROWSER_ANDROID_CONTENT_VIDEO_VIEW_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 9
10 #include "base/android/jni_helper.h"
10 #include "base/android/scoped_java_ref.h" 11 #include "base/android/scoped_java_ref.h"
11 #include "base/basictypes.h" 12 #include "base/basictypes.h"
12 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 #include "base/timer.h" 15 #include "base/timer.h"
15 16
16 namespace content { 17 namespace content {
17 18
18 class MediaPlayerManagerImpl; 19 class MediaPlayerManagerImpl;
19 20
20 // Native mirror of ContentVideoView.java. This class is responsible for 21 // Native mirror of ContentVideoView.java. This class is responsible for
21 // creating the Java video view and pass all the player status change to 22 // creating the Java video view and pass all the player status change to
22 // it. It accepts media control from Java class, and forwards it to 23 // it. It accepts media control from Java class, and forwards it to
23 // MediaPlayerManagerImpl. 24 // MediaPlayerManagerImpl.
24 class ContentVideoView { 25 class ContentVideoView {
25 public: 26 public:
26 // Construct a ContentVideoView object. The |manager| will handle all the 27 // Construct a ContentVideoView object. The |manager| will handle all the
27 // playback controls from the Java class. 28 // playback controls from the Java class.
28 explicit ContentVideoView(MediaPlayerManagerImpl* manager); 29 ContentVideoView(
30 const base::android::ScopedJavaLocalRef<jobject>& context,
31 const base::android::ScopedJavaLocalRef<jobject>& client,
32 MediaPlayerManagerImpl* manager);
33
29 ~ContentVideoView(); 34 ~ContentVideoView();
30 35
36 // To open another video on existing ContentVideoView.
37 void OpenVideo();
38
31 static bool RegisterContentVideoView(JNIEnv* env); 39 static bool RegisterContentVideoView(JNIEnv* env);
32 static void KeepScreenOn(bool screen_on); 40 static void KeepScreenOn(bool screen_on);
33 41
42 // Return true if there is existing ContentVideoView object.
43 static bool HasContentVideoView();
44
34 // Getter method called by the Java class to get the media information. 45 // Getter method called by the Java class to get the media information.
35 int GetVideoWidth(JNIEnv*, jobject obj) const; 46 int GetVideoWidth(JNIEnv*, jobject obj) const;
36 int GetVideoHeight(JNIEnv*, jobject obj) const; 47 int GetVideoHeight(JNIEnv*, jobject obj) const;
37 int GetDurationInMilliSeconds(JNIEnv*, jobject obj) const; 48 int GetDurationInMilliSeconds(JNIEnv*, jobject obj) const;
38 int GetCurrentPosition(JNIEnv*, jobject obj) const; 49 int GetCurrentPosition(JNIEnv*, jobject obj) const;
39 bool IsPlaying(JNIEnv*, jobject obj); 50 bool IsPlaying(JNIEnv*, jobject obj);
40 void UpdateMediaMetadata(JNIEnv*, jobject obj); 51 void UpdateMediaMetadata(JNIEnv*, jobject obj);
41 52
42 // Method to create and destroy the Java view.
43 void DestroyContentVideoView();
44 void CreateContentVideoView();
45
46 // Called when the Java fullscreen view is destroyed. If 53 // Called when the Java fullscreen view is destroyed. If
47 // |release_media_player| is true, |manager_| needs to release the player 54 // |release_media_player| is true, |manager_| needs to release the player
48 // as we are quitting the app. 55 // as we are quitting the app.
49 void ExitFullscreen(JNIEnv*, jobject, jboolean release_media_player); 56 void ExitFullscreen(JNIEnv*, jobject, jboolean release_media_player);
50 57
51 // Media control method called by the Java class. 58 // Media control method called by the Java class.
52 void SeekTo(JNIEnv*, jobject obj, jint msec); 59 void SeekTo(JNIEnv*, jobject obj, jint msec);
53 void Play(JNIEnv*, jobject obj); 60 void Play(JNIEnv*, jobject obj);
54 void Pause(JNIEnv*, jobject obj); 61 void Pause(JNIEnv*, jobject obj);
55 62
56 // Called by the Java class to pass the surface object to the player. 63 // Called by the Java class to pass the surface object to the player.
57 void SetSurface(JNIEnv*, jobject obj, jobject surface); 64 void SetSurface(JNIEnv*, jobject obj, jobject surface);
58 65
59 // Method called by |manager_| to inform the Java class about player status 66 // Method called by |manager_| to inform the Java class about player status
60 // change. 67 // change.
61 void UpdateMediaMetadata(); 68 void UpdateMediaMetadata();
62 void OnMediaPlayerError(int errorType); 69 void OnMediaPlayerError(int errorType);
63 void OnVideoSizeChanged(int width, int height); 70 void OnVideoSizeChanged(int width, int height);
64 void OnBufferingUpdate(int percent); 71 void OnBufferingUpdate(int percent);
65 void OnPlaybackComplete(); 72 void OnPlaybackComplete();
73 void OnExitFullscreen();
74
75 // Return the corresponing ContentVideoView Java object if any.
76 base::android::ScopedJavaLocalRef<jobject> GetJavaObject(JNIEnv* env);
66 77
67 private: 78 private:
68 // Object that manages the fullscreen media player. It is responsible for 79 // Object that manages the fullscreen media player. It is responsible for
69 // handling all the playback controls. 80 // handling all the playback controls.
70 MediaPlayerManagerImpl* manager_; 81 MediaPlayerManagerImpl* manager_;
71 82
72 // Reference to the Java object. 83 // Weak reference of corresponding Java object.
73 base::android::ScopedJavaGlobalRef<jobject> j_content_video_view_; 84 JavaObjectWeakGlobalRef j_content_video_view_;
74 85
75 DISALLOW_COPY_AND_ASSIGN(ContentVideoView); 86 DISALLOW_COPY_AND_ASSIGN(ContentVideoView);
76 }; 87 };
77 88
78 } // namespace content 89 } // namespace content
79 90
80 #endif // CONTENT_BROWSER_ANDROID_CONTENT_VIDEO_VIEW_H_ 91 #endif // CONTENT_BROWSER_ANDROID_CONTENT_VIDEO_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698