Chromium Code Reviews| Index: services/native_viewport/platform_viewport_android.cc |
| diff --git a/services/native_viewport/platform_viewport_android.cc b/services/native_viewport/platform_viewport_android.cc |
| index a19d5c0dea643194bc5df660e9c88d2776b0c9c7..0363a98d45ea405c0e10c22d3317326d77b3815c 100644 |
| --- a/services/native_viewport/platform_viewport_android.cc |
| +++ b/services/native_viewport/platform_viewport_android.cc |
| @@ -11,6 +11,8 @@ |
| #include "jni/PlatformViewportAndroid_jni.h" |
| #include "mojo/converters/geometry/geometry_type_converters.h" |
| #include "mojo/converters/input_events/input_events_type_converters.h" |
| +#include "mojo/public/cpp/application/application_impl.h" |
| +#include "services/native_viewport/native_viewport_internal.mojom.h" |
| #include "ui/events/event.h" |
| #include "ui/events/keycodes/keyboard_code_conversion_android.h" |
| #include "ui/gfx/point.h" |
| @@ -51,20 +53,25 @@ bool PlatformViewportAndroid::Register(JNIEnv* env) { |
| return RegisterNativesImpl(env); |
| } |
| -PlatformViewportAndroid::PlatformViewportAndroid(Delegate* delegate) |
| - : delegate_(delegate), |
| +PlatformViewportAndroid::PlatformViewportAndroid( |
| + mojo::ApplicationImpl* application, |
| + Delegate* delegate) |
| + : application_(application), |
| + delegate_(delegate), |
| window_(NULL), |
| id_generator_(0), |
| - weak_factory_(this) { |
| -} |
| + weak_factory_(this) {} |
| PlatformViewportAndroid::~PlatformViewportAndroid() { |
| if (window_) |
| ReleaseWindow(); |
| + JNIEnv* env = base::android::AttachCurrentThread(); |
| if (!java_platform_viewport_android_.is_empty()) { |
| - JNIEnv* env = base::android::AttachCurrentThread(); |
| Java_PlatformViewportAndroid_detach( |
| env, java_platform_viewport_android_.get(env).obj()); |
| + } else { |
| + Java_PlatformViewportAndroid_withdrawRequest(env, |
| + reinterpret_cast<jlong>(this)); |
|
qsr
2015/08/07 14:09:39
reinterpret_cast should be to intptr_t, here and e
etiennej
2015/08/07 14:15:40
Done.
|
| } |
| } |
| @@ -72,6 +79,13 @@ void PlatformViewportAndroid::Destroy(JNIEnv* env, jobject obj) { |
| delegate_->OnDestroyed(); |
| } |
| +void PlatformViewportAndroid::SurfaceAttached(JNIEnv* env, |
| + jobject obj, |
| + jobject platform_viewport) { |
| + java_platform_viewport_android_ = |
| + JavaObjectWeakGlobalRef(env, platform_viewport); |
| +} |
| + |
| void PlatformViewportAndroid::SurfaceCreated(JNIEnv* env, |
| jobject obj, |
| jobject jsurface) { |
| @@ -148,10 +162,13 @@ bool PlatformViewportAndroid::TouchEvent(JNIEnv* env, |
| void PlatformViewportAndroid::Init(const gfx::Rect& bounds) { |
| JNIEnv* env = base::android::AttachCurrentThread(); |
| - java_platform_viewport_android_ = JavaObjectWeakGlobalRef( |
| - env, |
| - Java_PlatformViewportAndroid_create(env, reinterpret_cast<jlong>(this)) |
| - .obj()); |
| + Java_PlatformViewportAndroid_createRequest(env, |
| + reinterpret_cast<jlong>(this)); |
| + |
| + NativeViewportShellServicePtr shell_service; |
| + application_->ConnectToService("mojo:native_viewport_support", |
| + &shell_service); |
| + shell_service->CreateNewNativeWindow(); |
| } |
| void PlatformViewportAndroid::Show() { |
| @@ -189,9 +206,12 @@ void PlatformViewportAndroid::ReleaseWindow() { |
| // PlatformViewport, public: |
| // static |
| -scoped_ptr<PlatformViewport> PlatformViewport::Create(Delegate* delegate) { |
| +scoped_ptr<PlatformViewport> PlatformViewport::Create( |
| + mojo::ApplicationImpl* application_, |
| + Delegate* delegate) { |
| return scoped_ptr<PlatformViewport>( |
| - new PlatformViewportAndroid(delegate)).Pass(); |
| + new PlatformViewportAndroid(application_, delegate)) |
| + .Pass(); |
| } |
| } // namespace native_viewport |