| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 UI_ANDROID_WINDOW_ANDROID_H_ | 5 #ifndef UI_ANDROID_WINDOW_ANDROID_H_ |
| 6 #define UI_ANDROID_WINDOW_ANDROID_H_ | 6 #define UI_ANDROID_WINDOW_ANDROID_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 #include <memory> | |
| 10 #include <string> | 9 #include <string> |
| 11 #include <vector> | 10 #include <vector> |
| 12 | 11 |
| 13 #include "base/android/jni_weak_ref.h" | 12 #include "base/android/jni_weak_ref.h" |
| 14 #include "base/android/scoped_java_ref.h" | 13 #include "base/android/scoped_java_ref.h" |
| 15 #include "base/macros.h" | 14 #include "base/macros.h" |
| 16 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
| 17 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 18 #include "ui/android/ui_android_export.h" | 17 #include "ui/android/ui_android_export.h" |
| 19 #include "ui/android/view_android.h" | 18 #include "ui/android/view_android.h" |
| 20 #include "ui/gfx/geometry/vector2d_f.h" | 19 #include "ui/gfx/geometry/vector2d_f.h" |
| 21 | 20 |
| 22 namespace cc { | |
| 23 class BeginFrameSource; | |
| 24 } // namespace cc | |
| 25 | |
| 26 namespace display { | 21 namespace display { |
| 27 class DisplayAndroidManager; | 22 class DisplayAndroidManager; |
| 28 } // namespace display | 23 } |
| 29 | 24 |
| 30 namespace ui { | 25 namespace ui { |
| 31 | 26 |
| 32 class WindowAndroidCompositor; | 27 class WindowAndroidCompositor; |
| 33 class WindowAndroidObserver; | 28 class WindowAndroidObserver; |
| 34 | 29 |
| 35 // Android implementation of the activity window. | 30 // Android implementation of the activity window. |
| 36 // WindowAndroid is also the root of a ViewAndroid tree. | 31 // WindowAndroid is also the root of a ViewAndroid tree. |
| 37 class UI_ANDROID_EXPORT WindowAndroid : public ViewAndroid { | 32 class UI_ANDROID_EXPORT WindowAndroid : public ViewAndroid { |
| 38 public: | 33 public: |
| (...skipping 18 matching lines...) Expand all Loading... |
| 57 // Compositor callback relay. | 52 // Compositor callback relay. |
| 58 void OnCompositingDidCommit(); | 53 void OnCompositingDidCommit(); |
| 59 | 54 |
| 60 void AttachCompositor(WindowAndroidCompositor* compositor); | 55 void AttachCompositor(WindowAndroidCompositor* compositor); |
| 61 void DetachCompositor(); | 56 void DetachCompositor(); |
| 62 | 57 |
| 63 void AddObserver(WindowAndroidObserver* observer); | 58 void AddObserver(WindowAndroidObserver* observer); |
| 64 void RemoveObserver(WindowAndroidObserver* observer); | 59 void RemoveObserver(WindowAndroidObserver* observer); |
| 65 | 60 |
| 66 WindowAndroidCompositor* GetCompositor() { return compositor_; } | 61 WindowAndroidCompositor* GetCompositor() { return compositor_; } |
| 67 cc::BeginFrameSource* GetBeginFrameSource(); | |
| 68 | 62 |
| 63 void RequestVSyncUpdate(); |
| 69 void SetNeedsAnimate(); | 64 void SetNeedsAnimate(); |
| 70 void Animate(base::TimeTicks begin_frame_time); | 65 void Animate(base::TimeTicks begin_frame_time); |
| 71 void OnVSync(JNIEnv* env, | 66 void OnVSync(JNIEnv* env, |
| 72 const base::android::JavaParamRef<jobject>& obj, | 67 const base::android::JavaParamRef<jobject>& obj, |
| 73 jlong time_micros, | 68 jlong time_micros, |
| 74 jlong period_micros); | 69 jlong period_micros); |
| 75 void OnVisibilityChanged(JNIEnv* env, | 70 void OnVisibilityChanged(JNIEnv* env, |
| 76 const base::android::JavaParamRef<jobject>& obj, | 71 const base::android::JavaParamRef<jobject>& obj, |
| 77 bool visible); | 72 bool visible); |
| 78 void OnActivityStopped(JNIEnv* env, | 73 void OnActivityStopped(JNIEnv* env, |
| 79 const base::android::JavaParamRef<jobject>& obj); | 74 const base::android::JavaParamRef<jobject>& obj); |
| 80 void OnActivityStarted(JNIEnv* env, | 75 void OnActivityStarted(JNIEnv* env, |
| 81 const base::android::JavaParamRef<jobject>& obj); | 76 const base::android::JavaParamRef<jobject>& obj); |
| 82 | 77 |
| 83 // Return whether the specified Android permission is granted. | 78 // Return whether the specified Android permission is granted. |
| 84 bool HasPermission(const std::string& permission); | 79 bool HasPermission(const std::string& permission); |
| 85 // Return whether the specified Android permission can be requested by Chrome. | 80 // Return whether the specified Android permission can be requested by Chrome. |
| 86 bool CanRequestPermission(const std::string& permission); | 81 bool CanRequestPermission(const std::string& permission); |
| 87 | 82 |
| 88 static WindowAndroid* CreateForTesting(); | 83 static WindowAndroid* CreateForTesting(); |
| 89 void DestroyForTesting(); | 84 void DestroyForTesting(); |
| 90 | 85 |
| 91 private: | 86 private: |
| 92 class WindowBeginFrameSource; | |
| 93 friend class DisplayAndroidManager; | 87 friend class DisplayAndroidManager; |
| 94 friend class WindowBeginFrameSource; | |
| 95 | 88 |
| 96 ~WindowAndroid() override; | 89 ~WindowAndroid() override; |
| 97 | 90 |
| 98 void SetNeedsBeginFrames(bool needs_begin_frames); | |
| 99 void RequestVSyncUpdate(); | |
| 100 | |
| 101 // ViewAndroid overrides. | 91 // ViewAndroid overrides. |
| 102 WindowAndroid* GetWindowAndroid() const override; | 92 WindowAndroid* GetWindowAndroid() const override; |
| 103 | 93 |
| 104 // The ID of the display that this window belongs to. | 94 // The ID of the display that this window belongs to. |
| 105 int display_id() const { return display_id_; } | 95 int display_id() const { return display_id_; } |
| 106 | 96 |
| 107 base::android::ScopedJavaGlobalRef<jobject> java_window_; | 97 base::android::ScopedJavaGlobalRef<jobject> java_window_; |
| 108 const int display_id_; | 98 const int display_id_; |
| 109 gfx::Vector2dF content_offset_; | 99 gfx::Vector2dF content_offset_; |
| 110 WindowAndroidCompositor* compositor_; | 100 WindowAndroidCompositor* compositor_; |
| 111 | 101 |
| 112 base::ObserverList<WindowAndroidObserver> observer_list_; | 102 base::ObserverList<WindowAndroidObserver> observer_list_; |
| 113 | 103 |
| 114 std::unique_ptr<WindowBeginFrameSource> begin_frame_source_; | |
| 115 bool needs_begin_frames_; | |
| 116 | |
| 117 DISALLOW_COPY_AND_ASSIGN(WindowAndroid); | 104 DISALLOW_COPY_AND_ASSIGN(WindowAndroid); |
| 118 }; | 105 }; |
| 119 | 106 |
| 120 } // namespace ui | 107 } // namespace ui |
| 121 | 108 |
| 122 #endif // UI_ANDROID_WINDOW_ANDROID_H_ | 109 #endif // UI_ANDROID_WINDOW_ANDROID_H_ |
| OLD | NEW |