| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.chrome.browser.autofill; |
| 6 |
| 7 import android.app.Activity; |
| 8 import android.os.Handler; |
| 9 |
| 10 import org.chromium.base.CalledByNative; |
| 11 import org.chromium.base.JNINamespace; |
| 12 import org.chromium.ui.autofill.InstrumentUnmaskPrompt; |
| 13 import org.chromium.ui.autofill.InstrumentUnmaskPrompt.InstrumentUnmaskPromptDel
egate; |
| 14 import org.chromium.ui.base.WindowAndroid; |
| 15 |
| 16 /** |
| 17 * JNI call glue for InstrumentUnmaskPrompt C++ and Java objects. |
| 18 */ |
| 19 @JNINamespace("autofill") |
| 20 public class InstrumentUnmaskBridge implements InstrumentUnmaskPromptDelegate { |
| 21 private final long mNativeInstrumentUnmaskPromptViewAndroid; |
| 22 private final InstrumentUnmaskPrompt mInstrumentUnmaskPrompt; |
| 23 |
| 24 public InstrumentUnmaskBridge(long nativeInstrumentUnmaskPromptViewAndroid, |
| 25 WindowAndroid windowAndroid) { |
| 26 mNativeInstrumentUnmaskPromptViewAndroid = nativeInstrumentUnmaskPromptV
iewAndroid; |
| 27 Activity activity = windowAndroid.getActivity().get(); |
| 28 if (activity == null) { |
| 29 mInstrumentUnmaskPrompt = null; |
| 30 // Clean up the native counterpart. This is posted to allow the nat
ive counterpart |
| 31 // to fully finish the construction of this glue object before we at
tempt to delete it. |
| 32 new Handler().post(new Runnable() { |
| 33 @Override |
| 34 public void run() { |
| 35 dismissed(new String()); |
| 36 } |
| 37 }); |
| 38 } else { |
| 39 mInstrumentUnmaskPrompt = new InstrumentUnmaskPrompt(activity, this)
; |
| 40 } |
| 41 } |
| 42 |
| 43 @CalledByNative |
| 44 private static InstrumentUnmaskBridge create(long nativeUnmaskPrompt, |
| 45 WindowAndroid windowAndroid) { |
| 46 return new InstrumentUnmaskBridge(nativeUnmaskPrompt, windowAndroid); |
| 47 } |
| 48 |
| 49 @Override |
| 50 public void dismissed(String response) { |
| 51 nativePromptDismissed(mNativeInstrumentUnmaskPromptViewAndroid, response
); |
| 52 } |
| 53 |
| 54 /** |
| 55 * Hides the Autofill Popup and removes its anchor from the ContainerView. |
| 56 */ |
| 57 @CalledByNative |
| 58 private void hide() { |
| 59 if (mInstrumentUnmaskPrompt != null) mInstrumentUnmaskPrompt.hide(); |
| 60 } |
| 61 |
| 62 /** |
| 63 * Shows an Autofill popup with specified suggestions. |
| 64 * @param suggestions Autofill suggestions to be displayed. |
| 65 */ |
| 66 @CalledByNative |
| 67 private void show() { |
| 68 if (mInstrumentUnmaskPrompt != null) mInstrumentUnmaskPrompt.show(); |
| 69 } |
| 70 |
| 71 private native void nativePromptDismissed(long nativeInstrumentUnmaskPromptV
iewAndroid, |
| 72 String response); |
| 73 } |
| OLD | NEW |