Commit 2570c079 authored by Tao Bai's avatar Tao Bai Committed by Commit Bot

Log disabled warning when autofill triggered.

Currently, we issue the warning log when webview is created, it is
hard to tell which webview's autofill is disabled, changed to log the
warning when autofill is triggered.

Bug: 
Change-Id: I4fa480db7f8d825f29b980b44c80add732c35407
Reviewed-on: https://chromium-review.googlesource.com/794528Reviewed-by: default avatarChangwan Ryu <changwan@chromium.org>
Commit-Queue: Tao Bai <michaelbai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#520225}
parent 41658d02
...@@ -43,13 +43,12 @@ public class AwAutofillManager { ...@@ -43,13 +43,12 @@ public class AwAutofillManager {
private boolean mIsAutofillInputUIShowing; private boolean mIsAutofillInputUIShowing;
private AutofillInputUIMonitor mMonitor; private AutofillInputUIMonitor mMonitor;
private boolean mDestroyed; private boolean mDestroyed;
private boolean mDisabled;
public AwAutofillManager(Context context) { public AwAutofillManager(Context context) {
if (DEBUG) Log.i(TAG, "constructor"); if (DEBUG) Log.i(TAG, "constructor");
if (AwContents.activityFromContext(context) == null) { if (AwContents.activityFromContext(context) == null) {
Log.w(TAG, mDisabled = true;
"WebView autofill is disabled because WebView isn't created with "
+ "activity context.");
return; return;
} }
mAutofillManager = context.getSystemService(AutofillManager.class); mAutofillManager = context.getSystemService(AutofillManager.class);
...@@ -58,56 +57,63 @@ public class AwAutofillManager { ...@@ -58,56 +57,63 @@ public class AwAutofillManager {
} }
public void notifyVirtualValueChanged(View parent, int childId, AutofillValue value) { public void notifyVirtualValueChanged(View parent, int childId, AutofillValue value) {
if (isDestroyed() || mAutofillManager == null) return; if (mDisabled || checkAndWarnIfDestroyed()) return;
if (DEBUG) Log.i(TAG, "notifyVirtualValueChanged"); if (DEBUG) Log.i(TAG, "notifyVirtualValueChanged");
mAutofillManager.notifyValueChanged(parent, childId, value); mAutofillManager.notifyValueChanged(parent, childId, value);
} }
public void commit() { public void commit() {
if (isDestroyed() || mAutofillManager == null) return; if (mDisabled || checkAndWarnIfDestroyed()) return;
if (DEBUG) Log.i(TAG, "commit"); if (DEBUG) Log.i(TAG, "commit");
mAutofillManager.commit(); mAutofillManager.commit();
} }
public void cancel() { public void cancel() {
if (isDestroyed() || mAutofillManager == null) return; if (mDisabled || checkAndWarnIfDestroyed()) return;
if (DEBUG) Log.i(TAG, "cancel"); if (DEBUG) Log.i(TAG, "cancel");
mAutofillManager.cancel(); mAutofillManager.cancel();
} }
public void notifyVirtualViewEntered(View parent, int childId, Rect absBounds) { public void notifyVirtualViewEntered(View parent, int childId, Rect absBounds) {
if (isDestroyed() || mAutofillManager == null) return; // Log warning only when the autofill is triggered.
if (mDisabled) {
Log.w(TAG,
"WebView autofill is disabled because WebView isn't created with "
+ "activity context.");
return;
}
if (checkAndWarnIfDestroyed()) return;
if (DEBUG) Log.i(TAG, "notifyVirtualViewEntered"); if (DEBUG) Log.i(TAG, "notifyVirtualViewEntered");
mAutofillManager.notifyViewEntered(parent, childId, absBounds); mAutofillManager.notifyViewEntered(parent, childId, absBounds);
} }
public void notifyVirtualViewExited(View parent, int childId) { public void notifyVirtualViewExited(View parent, int childId) {
if (isDestroyed() || mAutofillManager == null) return; if (mDisabled || checkAndWarnIfDestroyed()) return;
if (DEBUG) Log.i(TAG, "notifyVirtualViewExited"); if (DEBUG) Log.i(TAG, "notifyVirtualViewExited");
mAutofillManager.notifyViewExited(parent, childId); mAutofillManager.notifyViewExited(parent, childId);
} }
public void requestAutofill(View parent, int virtualId, Rect absBounds) { public void requestAutofill(View parent, int virtualId, Rect absBounds) {
if (isDestroyed() || mAutofillManager == null) return; if (mDisabled || checkAndWarnIfDestroyed()) return;
if (DEBUG) Log.i(TAG, "requestAutofill"); if (DEBUG) Log.i(TAG, "requestAutofill");
mAutofillManager.requestAutofill(parent, virtualId, absBounds); mAutofillManager.requestAutofill(parent, virtualId, absBounds);
} }
public boolean isAutofillInputUIShowing() { public boolean isAutofillInputUIShowing() {
if (isDestroyed() || mAutofillManager == null) return false; if (mDisabled || checkAndWarnIfDestroyed()) return false;
if (DEBUG) Log.i(TAG, "isAutofillInputUIShowing: " + mIsAutofillInputUIShowing); if (DEBUG) Log.i(TAG, "isAutofillInputUIShowing: " + mIsAutofillInputUIShowing);
return mIsAutofillInputUIShowing; return mIsAutofillInputUIShowing;
} }
public void destroy() { public void destroy() {
if (isDestroyed() || mAutofillManager == null) return; if (mDisabled || checkAndWarnIfDestroyed()) return;
if (DEBUG) Log.i(TAG, "destroy"); if (DEBUG) Log.i(TAG, "destroy");
mAutofillManager.unregisterCallback(mMonitor); mAutofillManager.unregisterCallback(mMonitor);
mAutofillManager = null; mAutofillManager = null;
mDestroyed = true; mDestroyed = true;
} }
private boolean isDestroyed() { private boolean checkAndWarnIfDestroyed() {
if (mDestroyed) { if (mDestroyed) {
Log.w(TAG, "Application attempted to call on a destroyed AwAutofillManager", Log.w(TAG, "Application attempted to call on a destroyed AwAutofillManager",
new Throwable()); new Throwable());
......
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