OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.autofill; | 5 package org.chromium.chrome.browser.autofill; |
6 | 6 |
7 import android.app.Activity; | 7 import android.app.Activity; |
8 import android.os.Handler; | 8 import android.os.Handler; |
9 | 9 |
10 import org.chromium.base.CalledByNative; | 10 import org.chromium.base.CalledByNative; |
11 import org.chromium.base.JNINamespace; | 11 import org.chromium.base.JNINamespace; |
12 import org.chromium.ui.autofill.CardUnmaskPrompt; | 12 import org.chromium.ui.autofill.CardUnmaskPrompt; |
13 import org.chromium.ui.autofill.CardUnmaskPrompt.CardUnmaskPromptDelegate; | 13 import org.chromium.ui.autofill.CardUnmaskPrompt.CardUnmaskPromptDelegate; |
14 import org.chromium.ui.base.WindowAndroid; | 14 import org.chromium.ui.base.WindowAndroid; |
15 | 15 |
16 /** | 16 /** |
17 * JNI call glue for CardUnmaskPrompt C++ and Java objects. | 17 * JNI call glue for CardUnmaskPrompt C++ and Java objects. |
18 */ | 18 */ |
19 @JNINamespace("autofill") | 19 @JNINamespace("autofill") |
20 public class CardUnmaskBridge implements CardUnmaskPromptDelegate { | 20 public class CardUnmaskBridge implements CardUnmaskPromptDelegate { |
21 private final long mNativeCardUnmaskPromptViewAndroid; | 21 private final long mNativeCardUnmaskPromptViewAndroid; |
22 private final CardUnmaskPrompt mCardUnmaskPrompt; | 22 private final CardUnmaskPrompt mCardUnmaskPrompt; |
23 | 23 |
24 public CardUnmaskBridge(long nativeCardUnmaskPromptViewAndroid, WindowAndroi
d windowAndroid) { | 24 public CardUnmaskBridge(long nativeCardUnmaskPromptViewAndroid, String title
, |
| 25 String instructions, WindowAndroid windowAndroid) { |
25 mNativeCardUnmaskPromptViewAndroid = nativeCardUnmaskPromptViewAndroid; | 26 mNativeCardUnmaskPromptViewAndroid = nativeCardUnmaskPromptViewAndroid; |
26 Activity activity = windowAndroid.getActivity().get(); | 27 Activity activity = windowAndroid.getActivity().get(); |
27 if (activity == null) { | 28 if (activity == null) { |
28 mCardUnmaskPrompt = null; | 29 mCardUnmaskPrompt = null; |
29 // Clean up the native counterpart. This is posted to allow the nat
ive counterpart | 30 // Clean up the native counterpart. This is posted to allow the nat
ive counterpart |
30 // to fully finish the construction of this glue object before we at
tempt to delete it. | 31 // to fully finish the construction of this glue object before we at
tempt to delete it. |
31 new Handler().post(new Runnable() { | 32 new Handler().post(new Runnable() { |
32 @Override | 33 @Override |
33 public void run() { | 34 public void run() { |
34 dismissed(); | 35 dismissed(); |
35 } | 36 } |
36 }); | 37 }); |
37 } else { | 38 } else { |
38 mCardUnmaskPrompt = new CardUnmaskPrompt(activity, this); | 39 mCardUnmaskPrompt = new CardUnmaskPrompt(activity, this, title, inst
ructions); |
39 } | 40 } |
40 } | 41 } |
41 | 42 |
42 @CalledByNative | 43 @CalledByNative |
43 private static CardUnmaskBridge create(long nativeUnmaskPrompt, | 44 private static CardUnmaskBridge create(long nativeUnmaskPrompt, String title
, |
44 WindowAndroid windowAndroid) { | 45 String instructions, WindowAndroid windowAndroid) { |
45 return new CardUnmaskBridge(nativeUnmaskPrompt, windowAndroid); | 46 return new CardUnmaskBridge(nativeUnmaskPrompt, title, instructions, win
dowAndroid); |
46 } | 47 } |
47 | 48 |
48 @Override | 49 @Override |
49 public void dismissed() { | 50 public void dismissed() { |
50 nativePromptDismissed(mNativeCardUnmaskPromptViewAndroid); | 51 nativePromptDismissed(mNativeCardUnmaskPromptViewAndroid); |
51 } | 52 } |
52 | 53 |
53 @Override | 54 @Override |
| 55 public boolean checkUserInputValidity(String userResponse) { |
| 56 return nativeCheckUserInputValidity(mNativeCardUnmaskPromptViewAndroid,
userResponse); |
| 57 } |
| 58 |
| 59 @Override |
54 public void onUserInput(String userResponse) { | 60 public void onUserInput(String userResponse) { |
55 nativeOnUserInput(mNativeCardUnmaskPromptViewAndroid, userResponse); | 61 nativeOnUserInput(mNativeCardUnmaskPromptViewAndroid, userResponse); |
56 } | 62 } |
57 | 63 |
58 /** | 64 /** |
59 * Shows a prompt for unmasking a Wallet credit card. | 65 * Shows a prompt for unmasking a Wallet credit card. |
60 */ | 66 */ |
61 @CalledByNative | 67 @CalledByNative |
62 private void show() { | 68 private void show() { |
63 if (mCardUnmaskPrompt != null) mCardUnmaskPrompt.show(); | 69 if (mCardUnmaskPrompt != null) mCardUnmaskPrompt.show(); |
(...skipping 12 matching lines...) Expand all Loading... |
76 */ | 82 */ |
77 @CalledByNative | 83 @CalledByNative |
78 private void disableAndWaitForVerification() { | 84 private void disableAndWaitForVerification() { |
79 if (mCardUnmaskPrompt != null) mCardUnmaskPrompt.disableAndWaitForVerifi
cation(); | 85 if (mCardUnmaskPrompt != null) mCardUnmaskPrompt.disableAndWaitForVerifi
cation(); |
80 } | 86 } |
81 | 87 |
82 /** | 88 /** |
83 * Indicate that verification failed, allow user to retry. | 89 * Indicate that verification failed, allow user to retry. |
84 */ | 90 */ |
85 @CalledByNative | 91 @CalledByNative |
86 private void verificationFailed() { | 92 private void verificationFinished(boolean success) { |
87 if (mCardUnmaskPrompt != null) mCardUnmaskPrompt.verificationFailed(); | 93 if (mCardUnmaskPrompt != null) mCardUnmaskPrompt.verificationFinished(su
ccess); |
88 } | 94 } |
89 | 95 |
90 private native void nativePromptDismissed(long nativeCardUnmaskPromptViewAnd
roid); | 96 private native void nativePromptDismissed(long nativeCardUnmaskPromptViewAnd
roid); |
| 97 private native boolean nativeCheckUserInputValidity( |
| 98 long nativeCardUnmaskPromptViewAndroid, String userResponse); |
91 private native void nativeOnUserInput( | 99 private native void nativeOnUserInput( |
92 long nativeCardUnmaskPromptViewAndroid, String userResponse); | 100 long nativeCardUnmaskPromptViewAndroid, String userResponse); |
93 } | 101 } |
OLD | NEW |