blob: 0e330682be5685627b6dffb0fa1e801409f584b0 [file] [log] [blame]
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_PLATFORM_WINDOW_ANDROID_PLATFORM_WINDOW_ANDROID_H_
#define UI_PLATFORM_WINDOW_ANDROID_PLATFORM_WINDOW_ANDROID_H_
#include "base/android/jni_weak_ref.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "ui/events/event_constants.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/sequential_id_generator.h"
#include "ui/platform_window/platform_window.h"
struct ANativeWindow;
namespace ui {
class PlatformWindowAndroid : public PlatformWindow {
public:
static bool Register(JNIEnv* env);
explicit PlatformWindowAndroid(PlatformWindowDelegate* delegate);
~PlatformWindowAndroid() override;
void Destroy(JNIEnv* env, jobject obj);
void SurfaceCreated(JNIEnv* env,
jobject obj,
jobject jsurface,
float device_pixel_ratio);
void SurfaceDestroyed(JNIEnv* env, jobject obj);
void SurfaceSetSize(JNIEnv* env,
jobject obj,
jint width,
jint height,
jfloat density);
bool TouchEvent(JNIEnv* env,
jobject obj,
jlong time_ms,
jint masked_action,
jint pointer_id,
jfloat x,
jfloat y,
jfloat pressure,
jfloat touch_major,
jfloat touch_minor,
jfloat orientation,
jfloat h_wheel,
jfloat v_wheel);
bool KeyEvent(JNIEnv* env,
jobject obj,
bool pressed,
jint key_code,
jint unicode_character);
private:
void ReleaseWindow();
// Overridden from PlatformWindow:
void Show() override;
void Hide() override;
void Close() override;
void SetBounds(const gfx::Rect& bounds) override;
gfx::Rect GetBounds() override;
void SetCapture() override;
void ReleaseCapture() override;
void ToggleFullscreen() override;
void Maximize() override;
void Minimize() override;
void Restore() override;
void SetCursor(PlatformCursor cursor) override;
void MoveCursorTo(const gfx::Point& location) override;
void ConfineCursorToBounds(const gfx::Rect& bounds) override;
PlatformWindowDelegate* delegate_;
JavaObjectWeakGlobalRef java_platform_window_android_;
ANativeWindow* window_;
ui::SequentialIDGenerator id_generator_;
gfx::Size size_; // Origin is always (0,0)
base::WeakPtrFactory<PlatformWindowAndroid> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(PlatformWindowAndroid);
};
} // namespace ui
#endif // UI_PLATFORM_WINDOW_ANDROID_PLATFORM_WINDOW_ANDROID_H_