Index: ui/android/view_android.cc |
diff --git a/ui/android/view_android.cc b/ui/android/view_android.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..fe8240ebe4a184e08e45db85e3cd32891002cc53 |
--- /dev/null |
+++ b/ui/android/view_android.cc |
@@ -0,0 +1,56 @@ |
+// Copyright (c) 2012 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 "view_android.h" |
nilesh
2013/04/12 19:07:10
ui/android/vew_android.h
Does this compile?
aurimas (slooooooooow)
2013/04/12 22:00:41
Done.
|
+ |
+#include "base/android/jni_android.h" |
+#include "base/android/jni_helper.h" |
+#include "base/android/scoped_java_ref.h" |
+#include "jni/NativeView_jni.h" |
+#include "ui/gfx/android/window_android.h" |
+ |
+namespace ui { |
+ |
+using base::android::AttachCurrentThread; |
+using base::android::ScopedJavaLocalRef; |
+ |
+ViewAndroid::ViewAndroid(JNIEnv* env, jobject obj, WindowAndroid* window) |
+ : weak_java_view_(env, obj), |
+ window_android_(window) |
+ { |
joth
2013/04/12 19:00:48
on prev line
nilesh
2013/04/12 19:07:10
{} on line 20
aurimas (slooooooooow)
2013/04/12 22:00:41
Done.
|
+} |
+ |
+void ViewAndroid::Destroy(JNIEnv* env, jobject obj) { |
+ // This object can only be destroyed by it's native counterpart. |
joth
2013/04/12 19:00:48
this smells like a programming error and should be
nilesh
2013/04/12 19:07:10
which object?
aurimas (slooooooooow)
2013/04/12 22:00:41
Done.
|
+ if (env->IsSameObject(weak_java_view_.get(env).obj(), obj)) |
joth
2013/04/12 19:00:48
in the window between GC and finalization, this me
aurimas (slooooooooow)
2013/04/12 22:00:41
Should I check if obj is !null too?
joth
2013/04/16 04:02:42
you got it ( PS#5.)
|
+ delete this; |
+} |
+ |
+ScopedJavaLocalRef<jobject> ViewAndroid::GetJavaObject() { |
+ JNIEnv* env = AttachCurrentThread(); |
nilesh
2013/04/12 19:07:10
no need of variable env
aurimas (slooooooooow)
2013/04/12 22:00:41
Done.
|
+ return weak_java_view_.get(env); |
+} |
+ |
+WindowAndroid* ViewAndroid::GetWindowAndroid() { |
+ return window_android_; |
+} |
+ |
+bool ViewAndroid::RegisterViewAndroid(JNIEnv* env) { |
+ return RegisterNativesImpl(env); |
+} |
+ |
+ViewAndroid::~ViewAndroid() { |
+} |
+ |
+// ---------------------------------------------------------------------------- |
+// Native JNI methods |
nilesh
2013/04/12 19:07:10
remove this comment block. I dont think it is help
aurimas (slooooooooow)
2013/04/12 22:00:41
Done.
|
+// ---------------------------------------------------------------------------- |
+ |
+jint Init(JNIEnv* env, jobject obj, jint window) { |
+ ViewAndroid* view = new ViewAndroid( |
+ env, obj, reinterpret_cast<ui::WindowAndroid*>(window)); |
+ return reinterpret_cast<jint>(view); |
+} |
+ |
+} // namespace ui |