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

Unified Diff: ui/android/java/src/org/chromium/ui/ViewAndroid.java

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
Index: ui/android/java/src/org/chromium/ui/ViewAndroid.java
diff --git a/ui/android/java/src/org/chromium/ui/ViewAndroid.java b/ui/android/java/src/org/chromium/ui/ViewAndroid.java
new file mode 100644
index 0000000000000000000000000000000000000000..0f0ca116a79c753f2058de2842c15b91ae4ebc2c
--- /dev/null
+++ b/ui/android/java/src/org/chromium/ui/ViewAndroid.java
@@ -0,0 +1,60 @@
+// 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.
+
+package org.chromium.ui;
+
+import org.chromium.base.JNINamespace;
+import org.chromium.ui.ViewAndroidDelegate;
+import org.chromium.ui.WindowAndroid;
+
+/**
+ * From the Chromium architecture point of view, ViewAndroid and its native counterpart
+ * serve purpose of representing Android view where Chrome expects to have a cross platform
+ * handle to the system view type. As Views are Java object on Android, this ViewAndroid
+ * and its native counterpart provide the expected abstractions on the C++ side and allow
+ * it to be flexibly glued to an actual Android Java View at runtime.
+ *
+ * It should only be used where access to Android Views is needed from the C++ code.
+ */
+@JNINamespace("ui")
+public class ViewAndroid {
+ // Native pointer to the c++ ViewAndroid object.
+ private int mNativeViewAndroid = 0;
+ private final ViewAndroidDelegate mViewAndroidDelegate;
+ private final WindowAndroid mWindowAndroid;
+
+ /**
+ * Constructs a View object.
+ */
+ public ViewAndroid(WindowAndroid nativeWindow, ViewAndroidDelegate viewAndroidDelegate) {
+ mWindowAndroid = nativeWindow;
+ mViewAndroidDelegate = viewAndroidDelegate;
+ mNativeViewAndroid = nativeInit(mWindowAndroid.getNativePointer());
+ }
+
+ public ViewAndroidDelegate getViewAndroidDelegate() {
+ return mViewAndroidDelegate;
+ }
+
+ /**
+ * Destroys the c++ ViewAndroid object if one has been created.
+ */
+ public void destroy() {
+ if (mNativeViewAndroid != 0) {
+ nativeDestroy(mNativeViewAndroid);
+ mNativeViewAndroid = 0;
+ }
+ }
+
+ /**
+ * Returns a pointer to the c++ AndroidWindow object.
+ * @return A pointer to the c++ AndroidWindow.
+ */
+ public int getNativePointer() {
+ return mNativeViewAndroid;
+ }
+
+ private native int nativeInit(int windowPtr);
+ private native void nativeDestroy(int nativeViewAndroid);
+}

Powered by Google App Engine
This is Rietveld 408576698