Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(691)

Unified Diff: ui/android/view_android.cc

Issue 14018004: [Android] Refactor NativeView to be able to use it for AutofillDialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/android/view_android.h ('k') | ui/gfx/native_widget_types.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..adfd987495e2fa602fab4b2562c2aa05f2f2a186
--- /dev/null
+++ b/ui/android/view_android.cc
@@ -0,0 +1,51 @@
+// Copyright (c) 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.
+
+#include "ui/android/view_android.h"
+
+#include "base/android/jni_android.h"
+#include "base/android/jni_helper.h"
+#include "base/android/scoped_java_ref.h"
+#include "jni/ViewAndroid_jni.h"
+#include "ui/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) {}
+
+void ViewAndroid::Destroy(JNIEnv* env, jobject obj) {
+ DCHECK(obj && env->IsSameObject(weak_java_view_.get(env).obj(), obj));
+ delete this;
+}
+
+ScopedJavaLocalRef<jobject> ViewAndroid::GetJavaObject() {
+ // It is mandatory to explicitly call destroy() before releasing the java
+ // side object. This could be changed in future by adding CleanupReference
+ // based destruct path;
+ return weak_java_view_.get(AttachCurrentThread());
+}
+
+WindowAndroid* ViewAndroid::GetWindowAndroid() {
+ return window_android_;
+}
+
+bool ViewAndroid::RegisterViewAndroid(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
+
+ViewAndroid::~ViewAndroid() {
+}
+
+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
« no previous file with comments | « ui/android/view_android.h ('k') | ui/gfx/native_widget_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698