Add remoting and PPAPI tests to GN build
[chromium-blink-merge.git] / content / browser / android / content_video_view.h
blob37b7f2e8be7738653147cc5bc7f46fd4e54cc180
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 bool IsPlaying(JNIEnv*, jobject obj);
45 void RequestMediaMetadata(JNIEnv*, jobject obj);
47 // Called when the Java fullscreen view is destroyed. If
48 // |release_media_player| is true, |manager_| needs to release the player
49 // as we are quitting the app.
50 void ExitFullscreen(JNIEnv*, jobject, jboolean release_media_player);
52 // Called by the Java class to pass the surface object to the player.
53 void SetSurface(JNIEnv*, jobject obj, jobject surface);
55 // Method called by |manager_| to inform the Java class about player status
56 // change.
57 void UpdateMediaMetadata();
58 void OnMediaPlayerError(int errorType);
59 void OnVideoSizeChanged(int width, int height);
60 void OnBufferingUpdate(int percent);
61 void OnPlaybackComplete();
62 void OnExitFullscreen();
64 // Functions called to record fullscreen playback UMA metrics.
65 void RecordFullscreenPlayback(
66 JNIEnv*, jobject, bool is_portrait_video, bool is_orientation_portrait);
67 void RecordExitFullscreenPlayback(
68 JNIEnv*, jobject, bool is_portrait_video,
69 long playback_duration_in_milliseconds_before_orientation_change,
70 long playback_duration_in_milliseconds_after_orientation_change);
72 // Return the corresponing ContentVideoView Java object if any.
73 base::android::ScopedJavaLocalRef<jobject> GetJavaObject(JNIEnv* env);
75 private:
76 // Creates the corresponding ContentVideoView Java object.
77 JavaObjectWeakGlobalRef CreateJavaObject();
79 // Object that manages the fullscreen media player. It is responsible for
80 // handling all the playback controls.
81 BrowserMediaPlayerManager* manager_;
83 // Weak reference of corresponding Java object.
84 JavaObjectWeakGlobalRef j_content_video_view_;
86 // Weak pointer for posting tasks.
87 base::WeakPtrFactory<ContentVideoView> weak_factory_;
89 DISALLOW_COPY_AND_ASSIGN(ContentVideoView);
92 } // namespace content
94 #endif // CONTENT_BROWSER_ANDROID_CONTENT_VIDEO_VIEW_H_