| Index: sky/shell/android/platform_view_android.cc
|
| diff --git a/sky/shell/android/platform_view_android.cc b/sky/shell/android/platform_view_android.cc
|
| index a27246743eec20c8bc7d562f87de0e208ce1a056..7b47d40d6260c3b750df77177ff0ffed15009fed 100644
|
| --- a/sky/shell/android/platform_view_android.cc
|
| +++ b/sky/shell/android/platform_view_android.cc
|
| @@ -12,16 +12,19 @@
|
| #include "base/location.h"
|
| #include "jni/PlatformViewAndroid_jni.h"
|
| #include "sky/shell/shell.h"
|
| +#include "sky/shell/shell_view.h"
|
|
|
| namespace sky {
|
| namespace shell {
|
|
|
| static jlong Attach(JNIEnv* env, jclass clazz, jint viewportObserverHandle) {
|
| - PlatformView* view = Shell::Shared().view();
|
| + ShellView* shell_view = new ShellView(Shell::Shared());
|
| + auto view = static_cast<PlatformViewAndroid*>(shell_view->view());
|
| + view->SetShellView(make_scoped_ptr(shell_view));
|
| view->ConnectToViewportObserver(
|
| mojo::MakeRequest<ViewportObserver>(mojo::ScopedMessagePipeHandle(
|
| mojo::MessagePipeHandle(viewportObserverHandle))));
|
| - return reinterpret_cast<jlong>(view);
|
| + return reinterpret_cast<jlong>(shell_view->view());
|
| }
|
|
|
| // static
|
| @@ -29,6 +32,14 @@ bool PlatformViewAndroid::Register(JNIEnv* env) {
|
| return RegisterNativesImpl(env);
|
| }
|
|
|
| +PlatformView* PlatformView::Create(const Config& config) {
|
| + return new PlatformViewAndroid(config);
|
| +}
|
| +
|
| +PlatformViewAndroid::PlatformViewAndroid(const Config& config)
|
| + : PlatformView(config) {
|
| +}
|
| +
|
| PlatformViewAndroid::~PlatformViewAndroid() {
|
| if (window_)
|
| ReleaseWindow();
|
| @@ -36,6 +47,8 @@ PlatformViewAndroid::~PlatformViewAndroid() {
|
|
|
| void PlatformViewAndroid::Detach(JNIEnv* env, jobject obj) {
|
| DCHECK(!window_);
|
| + shell_view_.reset();
|
| + // Note: |this| has been destroyed at this point.
|
| }
|
|
|
| void PlatformViewAndroid::SurfaceCreated(JNIEnv* env, jobject obj, jobject jsurface) {
|
| @@ -56,6 +69,11 @@ void PlatformViewAndroid::SurfaceDestroyed(JNIEnv* env, jobject obj) {
|
| ReleaseWindow();
|
| }
|
|
|
| +void PlatformViewAndroid::SetShellView(scoped_ptr<ShellView> shell_view) {
|
| + DCHECK(!shell_view_);
|
| + shell_view_ = shell_view.Pass();
|
| +}
|
| +
|
| void PlatformViewAndroid::ReleaseWindow() {
|
| ANativeWindow_release(window_);
|
| window_ = nullptr;
|
|
|