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"
23 class ANDROID_WINDOW_EXPORT PlatformWindowAndroid
: public PlatformWindow
{
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
,
34 float device_pixel_ratio
);
35 void SurfaceDestroyed(JNIEnv
* env
, jobject obj
);
36 void SurfaceSetSize(JNIEnv
* env
,
41 bool TouchEvent(JNIEnv
* env
,
54 bool KeyEvent(JNIEnv
* env
,
58 jint unicode_character
);
63 // Overridden from PlatformWindow:
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
);
98 #endif // UI_PLATFORM_WINDOW_ANDROID_PLATFORM_WINDOW_ANDROID_H_