Roll src/third_party/WebKit a3b4a2e:7441784 (svn 202551:202552)
[chromium-blink-merge.git] / ui / platform_window / android / platform_window_android.h
blobc8c646ebcdd265a6dff943fe57701d06c74e687c
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_PLATFORM_WINDOW_ANDROID_PLATFORM_WINDOW_ANDROID_H_
6 #define UI_PLATFORM_WINDOW_ANDROID_PLATFORM_WINDOW_ANDROID_H_
8 #include "base/android/jni_weak_ref.h"
9 #include "base/macros.h"
10 #include "base/memory/weak_ptr.h"
11 #include "ui/events/event_constants.h"
12 #include "ui/gfx/geometry/rect.h"
13 #include "ui/gfx/geometry/size.h"
14 #include "ui/gfx/sequential_id_generator.h"
15 #include "ui/platform_window/android/android_window_export.h"
16 #include "ui/platform_window/android/platform_ime_controller_android.h"
17 #include "ui/platform_window/platform_window.h"
19 struct ANativeWindow;
21 namespace ui {
23 class ANDROID_WINDOW_EXPORT PlatformWindowAndroid : public PlatformWindow {
24 public:
25 static bool Register(JNIEnv* env);
27 explicit PlatformWindowAndroid(PlatformWindowDelegate* delegate);
28 ~PlatformWindowAndroid() override;
30 void Destroy(JNIEnv* env, jobject obj);
31 void SurfaceCreated(JNIEnv* env,
32 jobject obj,
33 jobject jsurface,
34 float device_pixel_ratio);
35 void SurfaceDestroyed(JNIEnv* env, jobject obj);
36 void SurfaceSetSize(JNIEnv* env,
37 jobject obj,
38 jint width,
39 jint height,
40 jfloat density);
41 bool TouchEvent(JNIEnv* env,
42 jobject obj,
43 jlong time_ms,
44 jint masked_action,
45 jint pointer_id,
46 jfloat x,
47 jfloat y,
48 jfloat pressure,
49 jfloat touch_major,
50 jfloat touch_minor,
51 jfloat orientation,
52 jfloat h_wheel,
53 jfloat v_wheel);
54 bool KeyEvent(JNIEnv* env,
55 jobject obj,
56 bool pressed,
57 jint key_code,
58 jint unicode_character);
60 private:
61 void ReleaseWindow();
63 // Overridden from PlatformWindow:
64 void Show() override;
65 void Hide() override;
66 void Close() override;
67 void SetBounds(const gfx::Rect& bounds) override;
68 gfx::Rect GetBounds() override;
69 void SetTitle(const base::string16& title) override;
70 void SetCapture() override;
71 void ReleaseCapture() override;
72 void ToggleFullscreen() override;
73 void Maximize() override;
74 void Minimize() override;
75 void Restore() override;
76 void SetCursor(PlatformCursor cursor) override;
77 void MoveCursorTo(const gfx::Point& location) override;
78 void ConfineCursorToBounds(const gfx::Rect& bounds) override;
79 PlatformImeController* GetPlatformImeController() override;
81 PlatformWindowDelegate* delegate_;
83 JavaObjectWeakGlobalRef java_platform_window_android_;
84 ANativeWindow* window_;
85 ui::SequentialIDGenerator id_generator_;
87 gfx::Size size_; // Origin is always (0,0)
89 PlatformImeControllerAndroid platform_ime_controller_;
91 base::WeakPtrFactory<PlatformWindowAndroid> weak_factory_;
93 DISALLOW_COPY_AND_ASSIGN(PlatformWindowAndroid);
96 } // namespace ui
98 #endif // UI_PLATFORM_WINDOW_ANDROID_PLATFORM_WINDOW_ANDROID_H_