Update V8 to version 4.7.45.
[chromium-blink-merge.git] / ui / android / window_android.h
blob58f1e280bd6a9639ac9368cce647ed9a1ef2c86b
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
3 // found in the LICENSE file.
5 #ifndef UI_ANDROID_WINDOW_ANDROID_H_
6 #define UI_ANDROID_WINDOW_ANDROID_H_
8 #include <jni.h>
9 #include <string>
10 #include <vector>
12 #include "base/android/jni_weak_ref.h"
13 #include "base/android/scoped_java_ref.h"
14 #include "base/observer_list.h"
15 #include "base/time/time.h"
16 #include "ui/android/ui_android_export.h"
17 #include "ui/gfx/geometry/vector2d_f.h"
19 namespace ui {
21 class WindowAndroidCompositor;
22 class WindowAndroidObserver;
24 // Android implementation of the activity window.
25 class UI_ANDROID_EXPORT WindowAndroid {
26 public:
27 WindowAndroid(JNIEnv* env, jobject obj);
29 void Destroy(JNIEnv* env, jobject obj);
31 base::android::ScopedJavaLocalRef<jobject> GetJavaObject();
33 static bool RegisterWindowAndroid(JNIEnv* env);
35 // The content offset is used to translate snapshots to the correct part of
36 // the window.
37 void set_content_offset(const gfx::Vector2dF& content_offset) {
38 content_offset_ = content_offset;
41 gfx::Vector2dF content_offset() const {
42 return content_offset_;
45 // Compositor callback relay.
46 void OnCompositingDidCommit();
48 void AttachCompositor(WindowAndroidCompositor* compositor);
49 void DetachCompositor();
51 void AddObserver(WindowAndroidObserver* observer);
52 void RemoveObserver(WindowAndroidObserver* observer);
54 WindowAndroidCompositor* GetCompositor() { return compositor_; }
56 void RequestVSyncUpdate();
57 void SetNeedsAnimate();
58 void Animate(base::TimeTicks begin_frame_time);
59 void OnVSync(JNIEnv* env,
60 jobject obj,
61 jlong time_micros,
62 jlong period_micros);
63 void OnVisibilityChanged(JNIEnv* env, jobject obj, bool visible);
64 void OnActivityStopped(JNIEnv* env, jobject obj);
65 void OnActivityStarted(JNIEnv* env, jobject obj);
67 // Return whether the specified Android permission is granted.
68 bool HasPermission(const std::string& permission);
69 // Return whether the specified Android permission can be requested by Chrome.
70 bool CanRequestPermission(const std::string& permission);
72 private:
73 ~WindowAndroid();
75 base::android::ScopedJavaGlobalRef<jobject> java_window_;
76 gfx::Vector2dF content_offset_;
77 WindowAndroidCompositor* compositor_;
79 base::ObserverList<WindowAndroidObserver> observer_list_;
81 DISALLOW_COPY_AND_ASSIGN(WindowAndroid);
84 } // namespace ui
86 #endif // UI_ANDROID_WINDOW_ANDROID_H_