Commit d4b70039 authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

removes ui/platform_window/android

This code dates back to Mandoline and is not used anywhere.

BUG=none
TEST=none

Change-Id: Ieb5ee4c851bc88ffc4b50058ee4665b270eca87c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1642980Reviewed-by: default avatarEvan Stade <estade@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#666138}
parent eb510d37
......@@ -162,13 +162,6 @@ jumbo_component("aura") {
public += [ "screen_ozone.h" ]
sources += [ "screen_ozone.cc" ]
}
if (is_android) {
deps += [
"//ui/platform_window/android",
"//ui/platform_window/android:platform_window_java",
]
}
}
jumbo_static_library("test_support") {
......
......@@ -24,10 +24,6 @@
#include "ui/events/keycodes/dom/dom_keyboard_layout_map.h"
#include "ui/platform_window/platform_window_init_properties.h"
#if defined(OS_ANDROID)
#include "ui/platform_window/android/platform_window_android.h"
#endif
#if defined(USE_OZONE)
#include "ui/ozone/public/ozone_platform.h"
#endif
......@@ -76,8 +72,6 @@ void WindowTreeHostPlatform::CreateAndSetPlatformWindow(
this, std::move(properties));
#elif defined(OS_WIN)
platform_window_.reset(new ui::WinWindow(this, properties.bounds));
#elif defined(OS_ANDROID)
platform_window_.reset(new ui::PlatformWindowAndroid(this));
#elif defined(USE_X11)
platform_window_.reset(new ui::X11Window(this, properties.bounds));
#else
......
......@@ -40,12 +40,7 @@ group("platform_impls") {
public_deps = [
"//ui/platform_window/stub",
]
if (is_android) {
public_deps += [
"//ui/platform_window/android",
"//ui/platform_window/android:jni_headers",
]
} else if (use_x11) {
if (use_x11) {
public_deps += [ "//ui/platform_window/x11" ]
} else if (is_win) {
public_deps += [ "//ui/platform_window/win" ]
......
# Copyright 2015 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.
import("//build/config/android/rules.gni")
import("//build/config/jumbo.gni")
import("//testing/test.gni")
assert(is_android)
jumbo_component("android") {
output_name = "android_window"
sources = [
"android_window_export.h",
"platform_ime_controller_android.cc",
"platform_ime_controller_android.h",
"platform_window_android.cc",
"platform_window_android.h",
]
defines = [ "ANDROID_WINDOW_IMPLEMENTATION" ]
deps = [
":jni_headers",
":platform_window_java",
"//base",
"//skia",
"//ui/events:dom_keycode_converter",
"//ui/events:events",
"//ui/events:events_base",
"//ui/gfx",
"//ui/gfx/geometry",
"//ui/platform_window",
"//ui/platform_window/stub",
]
libs = [ "android" ]
}
generate_jni("jni_headers") {
sources = [
"java/src/org/chromium/ui/PlatformImeControllerAndroid.java",
"java/src/org/chromium/ui/PlatformWindowAndroid.java",
]
jni_package = "android_window"
}
android_library("platform_window_java") {
java_files = [
"java/src/org/chromium/ui/PlatformImeControllerAndroid.java",
"java/src/org/chromium/ui/PlatformWindowAndroid.java",
]
deps = [
"//base:base_java",
]
}
include_rules = [
"+jni",
"+ui/events",
"+ui/gfx",
]
// Copyright 2015 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_ANDROID_WINDOW_EXPORT_H_
#define UI_PLATFORM_WINDOW_ANDROID_ANDROID_WINDOW_EXPORT_H_
#if defined(COMPONENT_BUILD)
#if defined(WIN32)
#if defined(ANDROID_WINDOW_IMPLEMENTATION)
#define ANDROID_WINDOW_EXPORT __declspec(dllexport)
#else
#define ANDROID_WINDOW_EXPORT __declspec(dllimport)
#endif // defined(ANDROID_WINDOW_IMPLEMENTATION)
#else // defined(WIN32)
#if defined(ANDROID_WINDOW_IMPLEMENTATION)
#define ANDROID_WINDOW_EXPORT __attribute__((visibility("default")))
#else
#define ANDROID_WINDOW_EXPORT
#endif
#endif
#else // defined(COMPONENT_BUILD)
#define ANDROID_WINDOW_EXPORT
#endif
#endif // UI_PLATFORM_WINDOW_ANDROID_ANDROID_WINDOW_EXPORT_H_
// Copyright 2015 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.
package org.chromium.ui;
import android.content.Context;
import android.view.inputmethod.BaseInputConnection;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodManager;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
/**
* Exposes IME related code to native code.
*/
@JNINamespace("ui")
class PlatformImeControllerAndroid {
private int mInputType;
private int mInputFlags;
private String mText = "";
private int mSelectionStart;
private int mSelectionEnd;
private int mCompositionStart;
private int mCompositionEnd;
private final PlatformWindowAndroid mWindow;
private final long mNativeHandle;
private final InputMethodManager mInputMethodManager;
private InputConnection mInputConnection;
PlatformImeControllerAndroid(PlatformWindowAndroid window, long nativeHandle) {
mWindow = window;
mNativeHandle = nativeHandle;
mInputMethodManager = (InputMethodManager) mWindow.getContext().getSystemService(
Context.INPUT_METHOD_SERVICE);
assert mNativeHandle != 0;
nativeInit(mNativeHandle);
}
boolean isTextEditorType() {
return mInputType != 0;
}
InputConnection onCreateInputConnection(EditorInfo outAttrs) {
if (mInputType == 0) {
// Although onCheckIsTextEditor will return false in this case, the EditorInfo
// is still used by the InputMethodService. Need to make sure the IME doesn't
// enter fullscreen mode.
outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_FULLSCREEN;
}
// TODO(penghuang): Support full editor.
final boolean fullEditor = false;
mInputConnection = new BaseInputConnection(mWindow, fullEditor);
outAttrs.actionLabel = null;
// TODO(penghuang): Pass blink text input type to Android framework.
outAttrs.inputType =
EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT;
outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_EXTRACT_UI | EditorInfo.IME_FLAG_NO_FULLSCREEN
| EditorInfo.IME_ACTION_GO;
return mInputConnection;
}
@CalledByNative
private void updateTextInputState(int textInputType, int textInputFlags, String text,
int selectionStart, int selectionEnd, int compositionStart, int compositionEnd) {
mInputType = textInputType;
mInputFlags = textInputFlags;
mText = text;
mSelectionStart = selectionStart;
mSelectionEnd = selectionEnd;
mCompositionStart = compositionStart;
mCompositionEnd = compositionEnd;
// Update keyboard visibility
if (mInputType == 0) {
dismissInput();
}
}
@CalledByNative
private void setImeVisibility(boolean visible) {
// The IME is visible only if |mInputType| isn't 0, so we don't need
// change the visibility if |mInputType| is 0.
if (mInputType != 0) {
if (visible) {
showKeyboard();
} else {
dismissInput();
}
}
}
private void showKeyboard() {
mInputMethodManager.showSoftInput(mWindow, 0);
}
private void dismissInput() {
mInputMethodManager.hideSoftInputFromWindow(mWindow.getWindowToken(), 0);
}
// The generated native method implementation will call
// PlatformImeControllerAndroid::Init(JNIEnv* env, jobject self)
private native void nativeInit(long nativePlatformImeControllerAndroid);
}
// 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.
package org.chromium.ui;
import android.app.Activity;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import org.chromium.base.ContextUtils;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
/**
* Exposes SurfaceView to native code.
*/
@JNINamespace("ui")
public class PlatformWindowAndroid extends SurfaceView {
private long mNativeMojoViewport;
private final SurfaceHolder.Callback mSurfaceCallback;
private final PlatformImeControllerAndroid mImeController;
@CalledByNative
public static PlatformWindowAndroid createForActivity(
long nativeViewport, long nativeImeController) {
PlatformWindowAndroid rv = new PlatformWindowAndroid(nativeViewport, nativeImeController);
((Activity) ContextUtils.getApplicationContext()).setContentView(rv);
return rv;
}
private PlatformWindowAndroid(long nativeViewport, long nativeImeController) {
super(ContextUtils.getApplicationContext());
setFocusable(true);
setFocusableInTouchMode(true);
mNativeMojoViewport = nativeViewport;
assert mNativeMojoViewport != 0;
final float density =
ContextUtils.getApplicationContext().getResources().getDisplayMetrics().density;
mSurfaceCallback = new SurfaceHolder.Callback() {
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
assert mNativeMojoViewport != 0;
nativeSurfaceSetSize(mNativeMojoViewport, width, height, density);
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
assert mNativeMojoViewport != 0;
nativeSurfaceCreated(mNativeMojoViewport, holder.getSurface(), density);
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
assert mNativeMojoViewport != 0;
nativeSurfaceDestroyed(mNativeMojoViewport);
}
};
getHolder().addCallback(mSurfaceCallback);
mImeController = new PlatformImeControllerAndroid(this, nativeImeController);
}
@CalledByNative
public void detach() {
getHolder().removeCallback(mSurfaceCallback);
mNativeMojoViewport = 0;
}
@Override
protected void onWindowVisibilityChanged(int visibility) {
super.onWindowVisibilityChanged(visibility);
if (visibility == View.VISIBLE) {
requestFocusFromTouch();
requestFocus();
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
final int actionMasked = event.getActionMasked();
if (actionMasked == MotionEvent.ACTION_POINTER_DOWN
|| actionMasked == MotionEvent.ACTION_POINTER_UP) {
// Up/down events identify a single point.
return notifyTouchEventAtIndex(event, event.getActionIndex());
}
assert event.getPointerCount() != 0;
// All other types can have more than one point.
boolean result = false;
for (int i = 0, count = event.getPointerCount(); i < count; i++) {
final boolean sub_result = notifyTouchEventAtIndex(event, i);
result |= sub_result;
}
return result;
}
@Override
public boolean onCheckIsTextEditor() {
return mImeController.isTextEditorType();
}
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
return mImeController.onCreateInputConnection(outAttrs);
}
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if (privateDispatchKeyEvent(event)) {
return true;
}
return super.dispatchKeyEvent(event);
}
@Override
public boolean dispatchKeyEventPreIme(KeyEvent event) {
if (privateDispatchKeyEvent(event)) {
return true;
}
return super.dispatchKeyEventPreIme(event);
}
@Override
public boolean dispatchKeyShortcutEvent(KeyEvent event) {
if (privateDispatchKeyEvent(event)) {
return true;
}
return super.dispatchKeyShortcutEvent(event);
}
private boolean notifyTouchEventAtIndex(MotionEvent event, int index) {
float touchMajor = event.getTouchMajor(index);
float touchMinor = event.getTouchMinor(index);
if (touchMajor < touchMinor) {
float tmp = touchMajor;
touchMajor = touchMinor;
touchMinor = tmp;
}
return nativeTouchEvent(mNativeMojoViewport, event.getEventTime(), event.getActionMasked(),
event.getPointerId(index), event.getX(index), event.getY(index),
event.getPressure(index), touchMajor, touchMinor,
event.getOrientation(index), event.getAxisValue(MotionEvent.AXIS_HSCROLL, index),
event.getAxisValue(MotionEvent.AXIS_VSCROLL, index));
}
private boolean privateDispatchKeyEvent(KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_MULTIPLE) {
boolean result = false;
if (event.getKeyCode() == KeyEvent.KEYCODE_UNKNOWN && event.getCharacters() != null) {
String characters = event.getCharacters();
for (int i = 0; i < characters.length(); ++i) {
char c = characters.charAt(i);
int codepoint = c;
if (codepoint >= Character.MIN_SURROGATE
&& codepoint < (Character.MAX_SURROGATE + 1)) {
i++;
char c2 = characters.charAt(i);
codepoint = Character.toCodePoint(c, c2);
}
result |= nativeKeyEvent(mNativeMojoViewport, true, 0, codepoint);
result |= nativeKeyEvent(mNativeMojoViewport, false, 0, codepoint);
}
} else {
for (int i = 0; i < event.getRepeatCount(); ++i) {
result |= nativeKeyEvent(
mNativeMojoViewport, true, event.getKeyCode(), event.getUnicodeChar());
result |= nativeKeyEvent(
mNativeMojoViewport, false, event.getKeyCode(), event.getUnicodeChar());
}
}
return result;
} else {
return nativeKeyEvent(mNativeMojoViewport, event.getAction() == KeyEvent.ACTION_DOWN,
event.getKeyCode(), event.getUnicodeChar());
}
}
private static native void nativeDestroy(long nativePlatformWindowAndroid);
private static native void nativeSurfaceCreated(
long nativePlatformWindowAndroid, Surface surface, float devicePixelRatio);
private static native void nativeSurfaceDestroyed(
long nativePlatformWindowAndroid);
private static native void nativeSurfaceSetSize(
long nativePlatformWindowAndroid, int width, int height, float density);
private static native boolean nativeTouchEvent(long nativePlatformWindowAndroid, long timeMs,
int maskedAction, int pointerId, float x, float y, float pressure, float touchMajor,
float touchMinor, float orientation, float hWheel, float vWheel);
private static native boolean nativeKeyEvent(
long nativePlatformWindowAndroid, boolean pressed, int keyCode, int unicodeCharacter);
}
// Copyright 2015 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.
#include "ui/platform_window/android/platform_ime_controller_android.h"
#include "base/android/jni_android.h"
#include "base/android/jni_string.h"
#include "jni/PlatformImeControllerAndroid_jni.h"
using base::android::JavaParamRef;
using base::android::ScopedJavaLocalRef;
namespace ui {
PlatformImeControllerAndroid::PlatformImeControllerAndroid() {
}
PlatformImeControllerAndroid::~PlatformImeControllerAndroid() {
}
void PlatformImeControllerAndroid::Init(JNIEnv* env,
const JavaParamRef<jobject>& jobj) {
DCHECK(java_platform_ime_controller_android_.is_uninitialized());
java_platform_ime_controller_android_ = JavaObjectWeakGlobalRef(env, jobj);
}
void PlatformImeControllerAndroid::UpdateTextInputState(
const TextInputState& state) {
JNIEnv* env = base::android::AttachCurrentThread();
ScopedJavaLocalRef<jobject> scoped_obj =
java_platform_ime_controller_android_.get(env);
if (scoped_obj.is_null())
return;
Java_PlatformImeControllerAndroid_updateTextInputState(
env, scoped_obj, state.type, state.flags,
base::android::ConvertUTF8ToJavaString(env, state.text),
state.selection_start, state.selection_end, state.composition_start,
state.composition_end);
}
void PlatformImeControllerAndroid::SetImeVisibility(bool visible) {
JNIEnv* env = base::android::AttachCurrentThread();
ScopedJavaLocalRef<jobject> scoped_obj =
java_platform_ime_controller_android_.get(env);
if (scoped_obj.is_null())
return;
Java_PlatformImeControllerAndroid_setImeVisibility(env, scoped_obj, visible);
}
} // namespace ui
// Copyright 2015 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_IME_CONTROLLER_ANDROID_H_
#define UI_PLATFORM_WINDOW_ANDROID_PLATFORM_IME_CONTROLLER_ANDROID_H_
#include "base/android/jni_weak_ref.h"
#include "base/macros.h"
#include "ui/platform_window/android/android_window_export.h"
#include "ui/platform_window/platform_ime_controller.h"
namespace ui {
class ANDROID_WINDOW_EXPORT PlatformImeControllerAndroid :
public PlatformImeController {
public:
PlatformImeControllerAndroid();
~PlatformImeControllerAndroid() override;
// Native methods called by Java code.
void Init(JNIEnv* env, const base::android::JavaParamRef<jobject>& jobj);
private:
// Overridden from PlatformImeController:
void UpdateTextInputState(const TextInputState& state) override;
void SetImeVisibility(bool visible) override;
JavaObjectWeakGlobalRef java_platform_ime_controller_android_;
DISALLOW_COPY_AND_ASSIGN(PlatformImeControllerAndroid);
};
} // namespace ui
#endif // UI_PLATFORM_WINDOW_ANDROID_PLATFORM_IME_CONTROLLER_ANDROID_H_
// Copyright 2015 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.
#include "ui/platform_window/android/platform_window_android.h"
#include <android/input.h>
#include <android/native_window_jni.h>
#include "base/android/jni_android.h"
#include "jni/PlatformWindowAndroid_jni.h"
#include "ui/events/event.h"
#include "ui/events/keycodes/dom/dom_code.h"
#include "ui/events/keycodes/keyboard_code_conversion_android.h"
#include "ui/gfx/geometry/point.h"
#include "ui/platform_window/platform_window_delegate.h"
using base::android::JavaParamRef;
using base::android::ScopedJavaLocalRef;
namespace ui {
namespace {
ui::EventType MotionEventActionToEventType(jint action) {
switch (action) {
case AMOTION_EVENT_ACTION_DOWN:
case AMOTION_EVENT_ACTION_POINTER_DOWN:
return ui::ET_TOUCH_PRESSED;
case AMOTION_EVENT_ACTION_UP:
case AMOTION_EVENT_ACTION_POINTER_UP:
return ui::ET_TOUCH_RELEASED;
case AMOTION_EVENT_ACTION_MOVE:
return ui::ET_TOUCH_MOVED;
case AMOTION_EVENT_ACTION_CANCEL:
return ui::ET_TOUCH_CANCELLED;
case AMOTION_EVENT_ACTION_OUTSIDE:
case AMOTION_EVENT_ACTION_HOVER_MOVE:
case AMOTION_EVENT_ACTION_SCROLL:
case AMOTION_EVENT_ACTION_HOVER_ENTER:
case AMOTION_EVENT_ACTION_HOVER_EXIT:
default:
NOTIMPLEMENTED() << "Unimplemented motion action: " << action;
}
return ui::ET_UNKNOWN;
}
} // namespace
////////////////////////////////////////////////////////////////////////////////
// PlatformWindowAndroid, public:
PlatformWindowAndroid::PlatformWindowAndroid(PlatformWindowDelegate* delegate)
: StubWindow(delegate, false), window_(nullptr) {}
PlatformWindowAndroid::~PlatformWindowAndroid() {
if (window_)
ReleaseWindow();
JNIEnv* env = base::android::AttachCurrentThread();
ScopedJavaLocalRef<jobject> scoped_obj =
java_platform_window_android_.get(env);
if (!scoped_obj.is_null()) {
Java_PlatformWindowAndroid_detach(env, scoped_obj);
}
}
void PlatformWindowAndroid::Destroy(JNIEnv* env,
const JavaParamRef<jobject>& obj) {
delegate()->OnClosed();
}
void PlatformWindowAndroid::SurfaceCreated(
JNIEnv* env,
const JavaParamRef<jobject>& obj,
const JavaParamRef<jobject>& jsurface,
float device_pixel_ratio) {
// Note: This ensures that any local references used by
// ANativeWindow_fromSurface are released immediately. This is needed as a
// workaround for https://code.google.com/p/android/issues/detail?id=68174
{
base::android::ScopedJavaLocalFrame scoped_local_reference_frame(env);
window_ = ANativeWindow_fromSurface(env, jsurface);
}
delegate()->OnAcceleratedWidgetAvailable(window_);
}
void PlatformWindowAndroid::SurfaceDestroyed(JNIEnv* env,
const JavaParamRef<jobject>& obj) {
DCHECK(window_);
delegate()->OnAcceleratedWidgetDestroyed();
ReleaseWindow();
}
void PlatformWindowAndroid::SurfaceSetSize(JNIEnv* env,
const JavaParamRef<jobject>& obj,
jint width,
jint height,
jfloat density) {
size_ = gfx::Size(static_cast<int>(width), static_cast<int>(height));
delegate()->OnBoundsChanged(gfx::Rect(size_));
}
bool PlatformWindowAndroid::TouchEvent(JNIEnv* env,
const JavaParamRef<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) {
ui::EventType event_type = MotionEventActionToEventType(masked_action);
if (event_type == ui::ET_UNKNOWN)
return false;
ui::TouchEvent touch(
event_type, gfx::Point(),
base::TimeTicks() + base::TimeDelta::FromMilliseconds(time_ms),
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, pointer_id,
touch_major, touch_minor, pressure, orientation),
ui::EF_NONE);
touch.set_location_f(gfx::PointF(x, y));
touch.set_root_location_f(gfx::PointF(x, y));
delegate()->DispatchEvent(&touch);
return true;
}
bool PlatformWindowAndroid::KeyEvent(JNIEnv* env,
const JavaParamRef<jobject>& obj,
bool pressed,
jint key_code,
jint unicode_character) {
ui::KeyEvent key_event(pressed ? ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED,
ui::KeyboardCodeFromAndroidKeyCode(key_code), 0);
delegate()->DispatchEvent(&key_event);
if (pressed && unicode_character) {
ui::KeyEvent char_event(unicode_character,
ui::KeyboardCodeFromAndroidKeyCode(key_code),
ui::DomCode::NONE, 0);
delegate()->DispatchEvent(&char_event);
}
return true;
}
void PlatformWindowAndroid::ReleaseWindow() {
ANativeWindow_release(window_);
window_ = NULL;
}
////////////////////////////////////////////////////////////////////////////////
// PlatformWindowAndroid, PlatformWindow implementation:
void PlatformWindowAndroid::Show() {
if (!java_platform_window_android_.is_uninitialized())
return;
JNIEnv* env = base::android::AttachCurrentThread();
java_platform_window_android_ = JavaObjectWeakGlobalRef(
env, Java_PlatformWindowAndroid_createForActivity(
env, reinterpret_cast<jlong>(this),
reinterpret_cast<jlong>(&platform_ime_controller_))
.obj());
}
void PlatformWindowAndroid::Hide() {
// Nothing to do. View is always visible.
}
void PlatformWindowAndroid::SetBounds(const gfx::Rect& bounds) {
NOTIMPLEMENTED();
}
gfx::Rect PlatformWindowAndroid::GetBounds() {
return gfx::Rect(size_);
}
PlatformImeController* PlatformWindowAndroid::GetPlatformImeController() {
return &platform_ime_controller_;
}
} // namespace ui
// 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 "ui/events/event_constants.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
#include "ui/platform_window/android/android_window_export.h"
#include "ui/platform_window/android/platform_ime_controller_android.h"
#include "ui/platform_window/stub/stub_window.h"
struct ANativeWindow;
namespace ui {
class PlatformWindowDelegate;
// NOTE: This class extends StubWindow because it's very much a work in
// progress. If we make it real then it should subclass PlatformWindow directly.
class ANDROID_WINDOW_EXPORT PlatformWindowAndroid : public StubWindow {
public:
explicit PlatformWindowAndroid(PlatformWindowDelegate* delegate);
~PlatformWindowAndroid() override;
void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj);
void SurfaceCreated(JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj,
const base::android::JavaParamRef<jobject>& jsurface,
float device_pixel_ratio);
void SurfaceDestroyed(JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj);
void SurfaceSetSize(JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj,
jint width,
jint height,
jfloat density);
bool TouchEvent(JNIEnv* env,
const base::android::JavaParamRef<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,
const base::android::JavaParamRef<jobject>& obj,
bool pressed,
jint key_code,
jint unicode_character);
private:
void ReleaseWindow();
// Overridden from PlatformWindow:
void Show() override;
void Hide() override;
void SetBounds(const gfx::Rect& bounds) override;
gfx::Rect GetBounds() override;
PlatformImeController* GetPlatformImeController() override;
JavaObjectWeakGlobalRef java_platform_window_android_;
ANativeWindow* window_;
gfx::Size size_; // Origin is always (0,0)
PlatformImeControllerAndroid platform_ime_controller_;
DISALLOW_COPY_AND_ASSIGN(PlatformWindowAndroid);
};
} // namespace ui
#endif // UI_PLATFORM_WINDOW_ANDROID_PLATFORM_WINDOW_ANDROID_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment