Index: chrome/android/java/src/org/chromium/chrome/browser/autofill/InstrumentUnmaskBridge.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/autofill/InstrumentUnmaskBridge.java b/chrome/android/java/src/org/chromium/chrome/browser/autofill/InstrumentUnmaskBridge.java |
new file mode 100644 |
index 0000000000000000000000000000000000000000..567e3daad375224e47e60e0e86eb97ed38e7fce0 |
--- /dev/null |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/autofill/InstrumentUnmaskBridge.java |
@@ -0,0 +1,73 @@ |
+// Copyright 2014 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.chrome.browser.autofill; |
+ |
+import android.app.Activity; |
+import android.os.Handler; |
+ |
+import org.chromium.base.CalledByNative; |
+import org.chromium.base.JNINamespace; |
+import org.chromium.ui.autofill.InstrumentUnmaskPrompt; |
+import org.chromium.ui.autofill.InstrumentUnmaskPrompt.InstrumentUnmaskPromptDelegate; |
+import org.chromium.ui.base.WindowAndroid; |
+ |
+/** |
+* JNI call glue for InstrumentUnmaskPrompt C++ and Java objects. |
+*/ |
+@JNINamespace("autofill") |
+public class InstrumentUnmaskBridge implements InstrumentUnmaskPromptDelegate { |
Ted C
2014/12/04 00:53:29
Did you forget to include InstrumentUnmaskPromptDe
Ted C
2014/12/04 00:57:16
Evan pointed it out that it's in the InstrumentUnm
|
+ private final long mNativeInstrumentUnmaskPromptViewAndroid; |
+ private final InstrumentUnmaskPrompt mInstrumentUnmaskPrompt; |
+ |
+ public InstrumentUnmaskBridge(long nativeInstrumentUnmaskPromptViewAndroid, |
+ WindowAndroid windowAndroid) { |
+ mNativeInstrumentUnmaskPromptViewAndroid = nativeInstrumentUnmaskPromptViewAndroid; |
+ Activity activity = windowAndroid.getActivity().get(); |
+ if (activity == null) { |
+ mInstrumentUnmaskPrompt = null; |
+ // Clean up the native counterpart. This is posted to allow the native counterpart |
+ // to fully finish the construction of this glue object before we attempt to delete it. |
+ new Handler().post(new Runnable() { |
+ @Override |
+ public void run() { |
+ dismissed(new String()); |
aruslan
2014/12/04 00:15:47
Should we separate "dismissed with a response" and
Ted C
2014/12/04 00:53:29
and in general, we'd do "" instead of new String()
Evan Stade
2014/12/05 03:46:21
Done.
Evan Stade
2014/12/05 03:46:21
Generally, this prompt is going to get more compli
|
+ } |
+ }); |
+ } else { |
+ mInstrumentUnmaskPrompt = new InstrumentUnmaskPrompt(activity, this); |
+ } |
+ } |
+ |
+ @CalledByNative |
+ private static InstrumentUnmaskBridge create(long nativeUnmaskPrompt, |
+ WindowAndroid windowAndroid) { |
+ return new InstrumentUnmaskBridge(nativeUnmaskPrompt, windowAndroid); |
+ } |
+ |
+ @Override |
+ public void dismissed(String response) { |
+ nativePromptDismissed(mNativeInstrumentUnmaskPromptViewAndroid, response); |
+ } |
+ |
+ /** |
+ * Hides the Autofill Popup and removes its anchor from the ContainerView. |
aruslan
2014/12/04 00:15:47
There is no anchor I guess.
Evan Stade
2014/12/05 03:46:21
thanks for pointing this out. The function actuall
|
+ */ |
+ @CalledByNative |
+ private void hide() { |
+ if (mInstrumentUnmaskPrompt != null) mInstrumentUnmaskPrompt.hide(); |
+ } |
+ |
+ /** |
+ * Shows an Autofill popup with specified suggestions. |
+ * @param suggestions Autofill suggestions to be displayed. |
+ */ |
+ @CalledByNative |
+ private void show() { |
+ if (mInstrumentUnmaskPrompt != null) mInstrumentUnmaskPrompt.show(); |
+ } |
+ |
+ private native void nativePromptDismissed(long nativeInstrumentUnmaskPromptViewAndroid, |
+ String response); |
aruslan
2014/12/04 00:15:47
indent +8 starting from the start of the "private"
Evan Stade
2014/12/05 03:46:21
Done.
|
+} |