Commit a3970dd7 authored by Changwan Ryu's avatar Changwan Ryu Committed by Commit Bot

Add guarded logging for debugging webview autofill

Add some logging messages that are guarded by DEBUG = false.
With this, you can leave useful debugging messages without having to
resolve merge conflicts every time.

BUG=

Change-Id: Ic9b47bcd250e59021041bfe0ecfebb87a0a5182d
Reviewed-on: https://chromium-review.googlesource.com/792345Reviewed-by: default avatarTao Bai <michaelbai@chromium.org>
Commit-Queue: Changwan Ryu <changwan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#519510}
parent 1c3e620e
......@@ -22,6 +22,7 @@ import java.lang.ref.WeakReference;
@TargetApi(Build.VERSION_CODES.O)
public class AwAutofillManager {
private static final String TAG = "AwAutofillManager";
private static final boolean DEBUG = false;
private static class AutofillInputUIMonitor extends AutofillManager.AutofillCallback {
private WeakReference<AwAutofillManager> mManager;
......@@ -44,6 +45,7 @@ public class AwAutofillManager {
private boolean mDestroyed;
public AwAutofillManager(Context context) {
if (DEBUG) Log.i(TAG, "constructor");
if (AwContents.activityFromContext(context) == null) {
Log.w(TAG,
"WebView autofill is disabled because WebView isn't created with "
......@@ -57,41 +59,49 @@ public class AwAutofillManager {
public void notifyVirtualValueChanged(View parent, int childId, AutofillValue value) {
if (isDestroyed() || mAutofillManager == null) return;
if (DEBUG) Log.i(TAG, "notifyVirtualValueChanged");
mAutofillManager.notifyValueChanged(parent, childId, value);
}
public void commit() {
if (isDestroyed() || mAutofillManager == null) return;
if (DEBUG) Log.i(TAG, "commit");
mAutofillManager.commit();
}
public void cancel() {
if (isDestroyed() || mAutofillManager == null) return;
if (DEBUG) Log.i(TAG, "cancel");
mAutofillManager.cancel();
}
public void notifyVirtualViewEntered(View parent, int childId, Rect absBounds) {
if (isDestroyed() || mAutofillManager == null) return;
if (DEBUG) Log.i(TAG, "notifyVirtualViewEntered");
mAutofillManager.notifyViewEntered(parent, childId, absBounds);
}
public void notifyVirtualViewExited(View parent, int childId) {
if (isDestroyed() || mAutofillManager == null) return;
if (DEBUG) Log.i(TAG, "notifyVirtualViewExited");
mAutofillManager.notifyViewExited(parent, childId);
}
public void requestAutofill(View parent, int virtualId, Rect absBounds) {
if (isDestroyed() || mAutofillManager == null) return;
if (DEBUG) Log.i(TAG, "requestAutofill");
mAutofillManager.requestAutofill(parent, virtualId, absBounds);
}
public boolean isAutofillInputUIShowing() {
if (isDestroyed() || mAutofillManager == null) return false;
if (DEBUG) Log.i(TAG, "isAutofillInputUIShowing: " + mIsAutofillInputUIShowing);
return mIsAutofillInputUIShowing;
}
public void destroy() {
if (isDestroyed() || mAutofillManager == null) return;
if (DEBUG) Log.i(TAG, "destroy");
mAutofillManager.unregisterCallback(mMonitor);
mAutofillManager = null;
mDestroyed = true;
......
......@@ -41,6 +41,7 @@ import org.chromium.android_webview.AwContents;
import org.chromium.android_webview.AwContentsClient.AwWebResourceRequest;
import org.chromium.android_webview.AwWebResourceResponse;
import org.chromium.android_webview.test.AwActivityTestRule.TestDependencyFactory;
import org.chromium.base.Log;
import org.chromium.base.ThreadUtils;
import org.chromium.base.test.util.CallbackHelper;
import org.chromium.base.test.util.Feature;
......@@ -65,6 +66,18 @@ import java.util.concurrent.TimeoutException;
@MinAndroidSdkLevel(Build.VERSION_CODES.O)
@SuppressLint("NewApi")
public class AwAutofillTest {
public static final boolean DEBUG = false;
public static final String TAG = "AutofillTest";
public static final String FILE = "/login.html";
public static final String FILE_URL = "file:///android_asset/autofill.html";
public final static int AUTOFILL_VIEW_ENTERED = 1;
public final static int AUTOFILL_VIEW_EXITED = 2;
public final static int AUTOFILL_VALUE_CHANGED = 3;
public final static int AUTOFILL_COMMIT = 4;
public final static int AUTOFILL_CANCEL = 5;
/**
* This class only implements the necessary methods of ViewStructure for testing.
*/
......@@ -416,18 +429,21 @@ public class AwAutofillTest {
@Override
public void notifyVirtualViewEntered(View parent, int childId, Rect absBounds) {
if (DEBUG) Log.i(TAG, "notifyVirtualViewEntered");
mEventQueue.add(AUTOFILL_VIEW_ENTERED);
mCallbackHelper.notifyCalled();
}
@Override
public void notifyVirtualViewExited(View parent, int childId) {
if (DEBUG) Log.i(TAG, "notifyVirtualViewExited");
mEventQueue.add(AUTOFILL_VIEW_EXITED);
mCallbackHelper.notifyCalled();
}
@Override
public void notifyVirtualValueChanged(View parent, int childId, AutofillValue value) {
if (DEBUG) Log.i(TAG, "notifyVirtualValueChanged");
if (mTestValues.changedValues == null) {
mTestValues.changedValues = new ArrayList<Pair<Integer, AutofillValue>>();
}
......@@ -438,12 +454,14 @@ public class AwAutofillTest {
@Override
public void commit() {
if (DEBUG) Log.i(TAG, "commit");
mEventQueue.add(AUTOFILL_COMMIT);
mCallbackHelper.notifyCalled();
}
@Override
public void cancel() {
if (DEBUG) Log.i(TAG, "cancel");
mEventQueue.add(AUTOFILL_CANCEL);
mCallbackHelper.notifyCalled();
}
......@@ -471,15 +489,6 @@ public class AwAutofillTest {
}
}
public static final String FILE = "/login.html";
public static final String FILE_URL = "file:///android_asset/autofill.html";
public final static int AUTOFILL_VIEW_ENTERED = 1;
public final static int AUTOFILL_VIEW_EXITED = 2;
public final static int AUTOFILL_VALUE_CHANGED = 3;
public final static int AUTOFILL_COMMIT = 4;
public final static int AUTOFILL_CANCEL = 5;
@Rule
public AwActivityTestRule mRule = new AwActivityTestRule();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment