Apply _RELATIVE relocations ahead of others.
[chromium-blink-merge.git] / content / browser / android / content_video_view.h
blob7946792cf29937c2cf9ee07d8a7805e63bc6285a
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_ANDROID_CONTENT_VIDEO_VIEW_H_
6 #define CONTENT_BROWSER_ANDROID_CONTENT_VIDEO_VIEW_H_
8 #include <jni.h>
10 #include "base/android/jni_weak_ref.h"
11 #include "base/android/scoped_java_ref.h"
12 #include "base/basictypes.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h"
16 #include "ui/gfx/native_widget_types.h"
18 namespace content {
20 class BrowserMediaPlayerManager;
22 // Native mirror of ContentVideoView.java. This class is responsible for
23 // creating the Java video view and pass all the player status change to
24 // it. It accepts media control from Java class, and forwards it to
25 // MediaPlayerManagerImpl.
26 class ContentVideoView {
27 public:
28 // Construct a ContentVideoView object. The |manager| will handle all the
29 // playback controls from the Java class.
30 explicit ContentVideoView(BrowserMediaPlayerManager* manager);
32 ~ContentVideoView();
34 // To open another video on existing ContentVideoView.
35 void OpenVideo();
37 static bool RegisterContentVideoView(JNIEnv* env);
38 static void KeepScreenOn(bool screen_on);
40 // Return the singleton object or NULL.
41 static ContentVideoView* GetInstance();
43 // Getter method called by the Java class to get the media information.
44 int GetVideoWidth(JNIEnv*, jobject obj) const;
45 int GetVideoHeight(JNIEnv*, jobject obj) const;
46 int GetDurationInMilliSeconds(JNIEnv*, jobject obj) const;
47 int GetCurrentPosition(JNIEnv*, jobject obj) const;
48 bool IsPlaying(JNIEnv*, jobject obj);
49 void RequestMediaMetadata(JNIEnv*, jobject obj);
51 // Called when the Java fullscreen view is destroyed. If
52 // |release_media_player| is true, |manager_| needs to release the player
53 // as we are quitting the app.
54 void ExitFullscreen(JNIEnv*, jobject, jboolean release_media_player);
56 // Media control method called by the Java class.
57 void SeekTo(JNIEnv*, jobject obj, jint msec);
58 void Play(JNIEnv*, jobject obj);
59 void Pause(JNIEnv*, jobject obj);
61 // Called by the Java class to pass the surface object to the player.
62 void SetSurface(JNIEnv*, jobject obj, jobject surface);
64 // Method called by |manager_| to inform the Java class about player status
65 // change.
66 void UpdateMediaMetadata();
67 void OnMediaPlayerError(int errorType);
68 void OnVideoSizeChanged(int width, int height);
69 void OnBufferingUpdate(int percent);
70 void OnPlaybackComplete();
71 void OnExitFullscreen();
73 // Functions called to record fullscreen playback UMA metrics.
74 void RecordFullscreenPlayback(
75 JNIEnv*, jobject, bool is_portrait_video, bool is_orientation_portrait);
76 void RecordExitFullscreenPlayback(
77 JNIEnv*, jobject, bool is_portrait_video,
78 long playback_duration_in_milliseconds_before_orientation_change,
79 long playback_duration_in_milliseconds_after_orientation_change);
81 // Return the corresponing ContentVideoView Java object if any.
82 base::android::ScopedJavaLocalRef<jobject> GetJavaObject(JNIEnv* env);
84 private:
85 // Creates the corresponding ContentVideoView Java object.
86 JavaObjectWeakGlobalRef CreateJavaObject();
88 // Object that manages the fullscreen media player. It is responsible for
89 // handling all the playback controls.
90 BrowserMediaPlayerManager* manager_;
92 // Weak reference of corresponding Java object.
93 JavaObjectWeakGlobalRef j_content_video_view_;
95 // Weak pointer for posting tasks.
96 base::WeakPtrFactory<ContentVideoView> weak_factory_;
98 DISALLOW_COPY_AND_ASSIGN(ContentVideoView);
101 } // namespace content
103 #endif // CONTENT_BROWSER_ANDROID_CONTENT_VIDEO_VIEW_H_