| 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 {
|
| + 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());
|
| + }
|
| + });
|
| + } 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.
|
| + */
|
| + @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);
|
| +}
|
|
|