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/platform_window.h"
21 class PlatformWindowAndroid
: public PlatformWindow
{
23 static bool Register(JNIEnv
* env
);
25 explicit PlatformWindowAndroid(PlatformWindowDelegate
* delegate
);
26 ~PlatformWindowAndroid() override
;
28 void Destroy(JNIEnv
* env
, jobject obj
);
29 void SurfaceCreated(JNIEnv
* env
,
32 float device_pixel_ratio
);
33 void SurfaceDestroyed(JNIEnv
* env
, jobject obj
);
34 void SurfaceSetSize(JNIEnv
* env
,
39 bool TouchEvent(JNIEnv
* env
,
52 bool KeyEvent(JNIEnv
* env
,
56 jint unicode_character
);
60 // Overridden from PlatformWindow:
63 void Close() override
;
64 void SetBounds(const gfx::Rect
& bounds
) override
;
65 gfx::Rect
GetBounds() override
;
66 void SetCapture() override
;
67 void ReleaseCapture() override
;
68 void ToggleFullscreen() override
;
69 void Maximize() override
;
70 void Minimize() override
;
71 void Restore() override
;
72 void SetCursor(PlatformCursor cursor
) override
;
73 void MoveCursorTo(const gfx::Point
& location
) override
;
74 void ConfineCursorToBounds(const gfx::Rect
& bounds
) override
;
76 PlatformWindowDelegate
* delegate_
;
78 JavaObjectWeakGlobalRef java_platform_window_android_
;
79 ANativeWindow
* window_
;
80 ui::SequentialIDGenerator id_generator_
;
82 gfx::Size size_
; // Origin is always (0,0)
84 base::WeakPtrFactory
<PlatformWindowAndroid
> weak_factory_
;
86 DISALLOW_COPY_AND_ASSIGN(PlatformWindowAndroid
);
91 #endif // UI_PLATFORM_WINDOW_ANDROID_PLATFORM_WINDOW_ANDROID_H_