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

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

Issue 2103243002: Factor out ContentViewAndroidDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 5 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/base/ViewAndroid.java
diff --git a/ui/android/java/src/org/chromium/ui/base/ViewAndroid.java b/ui/android/java/src/org/chromium/ui/base/ViewAndroid.java
new file mode 100644
index 0000000000000000000000000000000000000000..5d383a0d2079d0431c06a5c04ec1fb4c5a8d3220
--- /dev/null
+++ b/ui/android/java/src/org/chromium/ui/base/ViewAndroid.java
@@ -0,0 +1,52 @@
+// Copyright 2016 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.base;
+
+import android.content.Context;
+import android.view.View;
+
+import org.chromium.base.annotations.CalledByNative;
+import org.chromium.base.annotations.JNINamespace;
+
+/**
+* Java counterpart for native ViewAndroid.
+*/
+@JNINamespace("ui")
+public class ViewAndroid {
+
+ private final Context mContext;
+ private final ViewAndroidDelegate mViewDelegate;
no sievers 2016/07/14 23:14:32 Do you think it's possible to not have this class
Jinsuk Kim 2016/07/15 05:46:26 I'm not sure... ViewAndroidDelegate can be overrid
no sievers 2016/07/15 18:35:00 I think that would call the correct overloaded fun
Jinsuk Kim 2016/07/18 06:45:46 Done. I tried to annotate the overriden methods of
+
+ private ViewAndroid(Context context, ViewAndroidDelegate delegate) {
no sievers 2016/07/14 23:14:32 You can actually get the right context from Window
Jinsuk Kim 2016/07/15 05:46:26 Nice! Removed the context passed from ContentViewC
+ mContext = context;
+ mViewDelegate = delegate;
+ }
+
+ @CalledByNative
+ private static ViewAndroid create(Context context, ViewAndroidDelegate delegate) {
+ return new ViewAndroid(context, delegate);
+ }
+
+ @CalledByNative
+ private View acquireAnchorView() {
+ View anchorView = new View(mContext);
+ mViewDelegate.addView(anchorView);
+ return anchorView;
+ }
+
+ @CalledByNative
+ private void setAnchorViewPosition(View anchorView, float x, float y, float width, float height,
+ float scale, int leftMargin, int topMargin) {
+ if (width > 0.f && height > 0.f) {
+ mViewDelegate.setViewPosition(anchorView, x, y, width, height, scale, leftMargin,
+ topMargin);
+ }
+ }
+
+ @CalledByNative
+ private void removeAnchorView(View anchorView) {
+ mViewDelegate.removeView(anchorView);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698