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

Side by Side Diff: android_webview/java/src/org/chromium/android_webview/AwContents.java

Issue 2745803003: autofill-try
Patch Set: before I leave Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.android_webview; 5 package org.chromium.android_webview;
6 6
7 import android.annotation.SuppressLint; 7 import android.annotation.SuppressLint;
8 import android.annotation.TargetApi; 8 import android.annotation.TargetApi;
9 import android.app.Activity; 9 import android.app.Activity;
10 import android.content.ComponentCallbacks2; 10 import android.content.ComponentCallbacks2;
(...skipping 10 matching lines...) Expand all
21 import android.net.http.SslCertificate; 21 import android.net.http.SslCertificate;
22 import android.os.AsyncTask; 22 import android.os.AsyncTask;
23 import android.os.Build; 23 import android.os.Build;
24 import android.os.Bundle; 24 import android.os.Bundle;
25 import android.os.Handler; 25 import android.os.Handler;
26 import android.os.Message; 26 import android.os.Message;
27 import android.os.SystemClock; 27 import android.os.SystemClock;
28 import android.text.TextUtils; 28 import android.text.TextUtils;
29 import android.util.Base64; 29 import android.util.Base64;
30 import android.util.Pair; 30 import android.util.Pair;
31 import android.util.SparseArray;
31 import android.view.DragEvent; 32 import android.view.DragEvent;
32 import android.view.KeyEvent; 33 import android.view.KeyEvent;
33 import android.view.MotionEvent; 34 import android.view.MotionEvent;
34 import android.view.View; 35 import android.view.View;
35 import android.view.ViewGroup; 36 import android.view.ViewGroup;
36 import android.view.ViewStructure; 37 import android.view.ViewStructure;
37 import android.view.accessibility.AccessibilityEvent; 38 import android.view.accessibility.AccessibilityEvent;
38 import android.view.accessibility.AccessibilityNodeInfo; 39 import android.view.accessibility.AccessibilityNodeInfo;
39 import android.view.accessibility.AccessibilityNodeProvider; 40 import android.view.accessibility.AccessibilityNodeProvider;
41 import android.view.autofill.AutofillValue;
40 import android.view.animation.AnimationUtils; 42 import android.view.animation.AnimationUtils;
41 import android.view.inputmethod.EditorInfo; 43 import android.view.inputmethod.EditorInfo;
42 import android.view.inputmethod.InputConnection; 44 import android.view.inputmethod.InputConnection;
43 import android.webkit.JavascriptInterface; 45 import android.webkit.JavascriptInterface;
44 import android.webkit.ValueCallback; 46 import android.webkit.ValueCallback;
45 47
46 import org.chromium.android_webview.permission.AwGeolocationCallback; 48 import org.chromium.android_webview.permission.AwGeolocationCallback;
47 import org.chromium.android_webview.permission.AwPermissionRequest; 49 import org.chromium.android_webview.permission.AwPermissionRequest;
48 import org.chromium.android_webview.renderer_priority.RendererPriority.RendererP riorityEnum; 50 import org.chromium.android_webview.renderer_priority.RendererPriority.RendererP riorityEnum;
49 import org.chromium.base.LocaleUtils; 51 import org.chromium.base.LocaleUtils;
(...skipping 27 matching lines...) Expand all
77 import org.chromium.ui.base.PageTransition; 79 import org.chromium.ui.base.PageTransition;
78 import org.chromium.ui.base.ViewAndroidDelegate; 80 import org.chromium.ui.base.ViewAndroidDelegate;
79 import org.chromium.ui.base.WindowAndroid; 81 import org.chromium.ui.base.WindowAndroid;
80 import org.chromium.ui.display.DisplayAndroid.DisplayAndroidObserver; 82 import org.chromium.ui.display.DisplayAndroid.DisplayAndroidObserver;
81 83
82 import java.io.File; 84 import java.io.File;
83 import java.lang.annotation.Annotation; 85 import java.lang.annotation.Annotation;
84 import java.net.MalformedURLException; 86 import java.net.MalformedURLException;
85 import java.net.URL; 87 import java.net.URL;
86 import java.util.HashMap; 88 import java.util.HashMap;
89 import java.util.List;
87 import java.util.Locale; 90 import java.util.Locale;
88 import java.util.Map; 91 import java.util.Map;
89 import java.util.WeakHashMap; 92 import java.util.WeakHashMap;
90 import java.util.concurrent.Callable; 93 import java.util.concurrent.Callable;
91 94
92 /** 95 /**
93 * Exposes the native AwContents class, and together these classes wrap the Cont entViewCore 96 * Exposes the native AwContents class, and together these classes wrap the Cont entViewCore
94 * and Browser components that are required to implement Android WebView API. Th is is the 97 * and Browser components that are required to implement Android WebView API. Th is is the
95 * primary entry point for the WebViewProvider implementation; it holds a 1:1 ob ject 98 * primary entry point for the WebViewProvider implementation; it holds a 1:1 ob ject
96 * relationship with application WebView instances. 99 * relationship with application WebView instances.
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 */ 238 */
236 public static class DependencyFactory { 239 public static class DependencyFactory {
237 public AwLayoutSizer createLayoutSizer() { 240 public AwLayoutSizer createLayoutSizer() {
238 return new AwLayoutSizer(); 241 return new AwLayoutSizer();
239 } 242 }
240 243
241 public AwScrollOffsetManager createScrollOffsetManager( 244 public AwScrollOffsetManager createScrollOffsetManager(
242 AwScrollOffsetManager.Delegate delegate) { 245 AwScrollOffsetManager.Delegate delegate) {
243 return new AwScrollOffsetManager(delegate); 246 return new AwScrollOffsetManager(delegate);
244 } 247 }
248
249 public AwAutofillManager createAwAutofillManager(Context context, AwCont ents awContents) {
250 // Remove the AwContents parameter.
251 return new DummyAwAutofillManager(context, awContents);
252 }
245 } 253 }
246 254
247 /** 255 /**
248 * Visual state callback, see {@link #insertVisualStateCallback} for details . 256 * Visual state callback, see {@link #insertVisualStateCallback} for details .
249 * 257 *
250 */ 258 */
251 @VisibleForTesting 259 @VisibleForTesting
252 public abstract static class VisualStateCallback { 260 public abstract static class VisualStateCallback {
253 /** 261 /**
254 * @param requestId the id passed to {@link AwContents#insertVisualState Callback} 262 * @param requestId the id passed to {@link AwContents#insertVisualState Callback}
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 private Handler mHandler; 360 private Handler mHandler;
353 361
354 // True when this AwContents has been destroyed. 362 // True when this AwContents has been destroyed.
355 // Do not use directly, call isDestroyed() instead. 363 // Do not use directly, call isDestroyed() instead.
356 private boolean mIsDestroyed; 364 private boolean mIsDestroyed;
357 365
358 // True if this AwContents is in no operation state. 366 // True if this AwContents is in no operation state.
359 // Do not use directly, call isNoOperation() instead. 367 // Do not use directly, call isNoOperation() instead.
360 private boolean mIsNoOperation; 368 private boolean mIsNoOperation;
361 369
370 private AwAutofillProvider mAwAutofillProvider;
371
362 private static String sCurrentLocales = ""; 372 private static String sCurrentLocales = "";
363 373
364 private static final class AwContentsDestroyRunnable implements Runnable { 374 private static final class AwContentsDestroyRunnable implements Runnable {
365 private final long mNativeAwContents; 375 private final long mNativeAwContents;
366 // Hold onto a reference to the window (via its wrapper), so that it is not destroyed 376 // Hold onto a reference to the window (via its wrapper), so that it is not destroyed
367 // until we are done here. 377 // until we are done here.
368 private final WindowAndroidWrapper mWindowAndroid; 378 private final WindowAndroidWrapper mWindowAndroid;
369 379
370 private AwContentsDestroyRunnable( 380 private AwContentsDestroyRunnable(
371 long nativeAwContents, WindowAndroidWrapper windowAndroid) { 381 long nativeAwContents, WindowAndroidWrapper windowAndroid) {
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 mBrowserContext = browserContext; 744 mBrowserContext = browserContext;
735 745
736 // setWillNotDraw(false) is required since WebView draws it's own conten ts using it's 746 // setWillNotDraw(false) is required since WebView draws it's own conten ts using it's
737 // container view. If this is ever not the case we should remove this, a s it removes 747 // container view. If this is ever not the case we should remove this, a s it removes
738 // Android's gatherTransparentRegion optimization for the view. 748 // Android's gatherTransparentRegion optimization for the view.
739 mContainerView = containerView; 749 mContainerView = containerView;
740 mContainerView.setWillNotDraw(false); 750 mContainerView.setWillNotDraw(false);
741 751
742 mHandler = new Handler(); 752 mHandler = new Handler();
743 mContext = context; 753 mContext = context;
754 AwAutofillManager awAutofillManager = dependencyFactory.createAwAutofill Manager(context,
755 this);
756 if (awAutofillManager != null) {
757 mAwAutofillProvider = new AwAutofillProvider(context, mContainerView ,
758 awAutofillManager);
759 }
744 mAppTargetSdkVersion = mContext.getApplicationInfo().targetSdkVersion; 760 mAppTargetSdkVersion = mContext.getApplicationInfo().targetSdkVersion;
745 mInternalAccessAdapter = internalAccessAdapter; 761 mInternalAccessAdapter = internalAccessAdapter;
746 mNativeDrawGLFunctorFactory = nativeDrawGLFunctorFactory; 762 mNativeDrawGLFunctorFactory = nativeDrawGLFunctorFactory;
747 mInitialFunctor = new AwGLFunctor(mNativeDrawGLFunctorFactory, mContaine rView); 763 mInitialFunctor = new AwGLFunctor(mNativeDrawGLFunctorFactory, mContaine rView);
748 mCurrentFunctor = mInitialFunctor; 764 mCurrentFunctor = mInitialFunctor;
749 mContentsClient = contentsClient; 765 mContentsClient = contentsClient;
750 mContentsClient.getCallbackHelper().setCancelCallbackPoller( 766 mContentsClient.getCallbackHelper().setCancelCallbackPoller(
751 new AwContentsClientCallbackHelper.CancelCallbackPoller() { 767 new AwContentsClientCallbackHelper.CancelCallbackPoller() {
752 @Override 768 @Override
753 public boolean cancelAllCallbacks() { 769 public boolean cancelAllCallbacks() {
(...skipping 1568 matching lines...) Expand 10 before | Expand all | Expand 10 after
2322 if (!mWebContentsObserver.didEverCommitNavigation()) { 2338 if (!mWebContentsObserver.didEverCommitNavigation()) {
2323 // TODO(sgurun) write a test case for this condition crbug/605251 2339 // TODO(sgurun) write a test case for this condition crbug/605251
2324 structure.setChildCount(0); 2340 structure.setChildCount(0);
2325 return; 2341 return;
2326 } 2342 }
2327 // for webview, the platform already calculates the scroll (as it is a v iew) in 2343 // for webview, the platform already calculates the scroll (as it is a v iew) in
2328 // ViewStructure tree. Do not offset for it in the snapshop x,y position calculations. 2344 // ViewStructure tree. Do not offset for it in the snapshop x,y position calculations.
2329 mContentViewCore.onProvideVirtualStructure(structure, true); 2345 mContentViewCore.onProvideVirtualStructure(structure, true);
2330 } 2346 }
2331 2347
2348 public void onProvideAutoFillVirtualStructure(ViewStructure structure, int f lags) {
2349 mAwAutofillProvider.onProvideAutoFillVirtualStructure(structure, flags);
2350 }
2351
2352 public void autofill(final SparseArray<AutofillValue> values) {
2353 mAwAutofillProvider.autofill(values);
2354 }
2355
2332 public boolean isSelectActionModeAllowed(int actionModeItem) { 2356 public boolean isSelectActionModeAllowed(int actionModeItem) {
2333 return (mSettings.getDisabledActionModeMenuItems() & actionModeItem) != actionModeItem; 2357 return (mSettings.getDisabledActionModeMenuItems() & actionModeItem) != actionModeItem;
2334 } 2358 }
2335 2359
2336 //-------------------------------------------------------------------------- ------------------ 2360 //-------------------------------------------------------------------------- ------------------
2337 // View and ViewGroup method implementations 2361 // View and ViewGroup method implementations
2338 //-------------------------------------------------------------------------- ------------------ 2362 //-------------------------------------------------------------------------- ------------------
2339 /** 2363 /**
2340 * Calls android.view.View#startActivityForResult. A RuntimeException will 2364 * Calls android.view.View#startActivityForResult. A RuntimeException will
2341 * be thrown by Android framework if startActivityForResult is called with 2365 * be thrown by Android framework if startActivityForResult is called with
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
2875 setPageScaleFactorAndLimits(pageScaleFactor, minPageScaleFactor, maxPage ScaleFactor); 2899 setPageScaleFactorAndLimits(pageScaleFactor, minPageScaleFactor, maxPage ScaleFactor);
2876 } 2900 }
2877 2901
2878 @CalledByNative 2902 @CalledByNative
2879 private void setAwAutofillClient(AwAutofillClient client) { 2903 private void setAwAutofillClient(AwAutofillClient client) {
2880 mAwAutofillClient = client; 2904 mAwAutofillClient = client;
2881 client.init(mContentViewCore); 2905 client.init(mContentViewCore);
2882 } 2906 }
2883 2907
2884 @CalledByNative 2908 @CalledByNative
2909 private long getNativeAutofillAndroid() {
2910 if (mAwAutofillProvider == null) return 0;
2911 return mAwAutofillProvider.getNativeAutofillProviderAndroid();
2912 }
2913
2914 @CalledByNative
2885 private void didOverscroll(int deltaX, int deltaY, float velocityX, float ve locityY) { 2915 private void didOverscroll(int deltaX, int deltaY, float velocityX, float ve locityY) {
2886 mScrollOffsetManager.overScrollBy(deltaX, deltaY); 2916 mScrollOffsetManager.overScrollBy(deltaX, deltaY);
2887 2917
2888 if (mOverScrollGlow == null) return; 2918 if (mOverScrollGlow == null) return;
2889 2919
2890 mOverScrollGlow.setOverScrollDeltas(deltaX, deltaY); 2920 mOverScrollGlow.setOverScrollDeltas(deltaX, deltaY);
2891 final int oldX = mContainerView.getScrollX(); 2921 final int oldX = mContainerView.getScrollX();
2892 final int oldY = mContainerView.getScrollY(); 2922 final int oldY = mContainerView.getScrollY();
2893 final int x = oldX + deltaX; 2923 final int x = oldX + deltaX;
2894 final int y = oldY + deltaY; 2924 final int y = oldY + deltaY;
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
3458 3488
3459 private native void nativePreauthorizePermission(long nativeAwContents, Stri ng origin, 3489 private native void nativePreauthorizePermission(long nativeAwContents, Stri ng origin,
3460 long resources); 3490 long resources);
3461 3491
3462 private native void nativePostMessageToFrame(long nativeAwContents, String f rameId, 3492 private native void nativePostMessageToFrame(long nativeAwContents, String f rameId,
3463 String message, String targetOrigin, MessagePort[] ports); 3493 String message, String targetOrigin, MessagePort[] ports);
3464 3494
3465 private native void nativeGrantFileSchemeAccesstoChildProcess(long nativeAwC ontents); 3495 private native void nativeGrantFileSchemeAccesstoChildProcess(long nativeAwC ontents);
3466 private native void nativeResumeLoadingCreatedPopupWebContents(long nativeAw Contents); 3496 private native void nativeResumeLoadingCreatedPopupWebContents(long nativeAw Contents);
3467 } 3497 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698