OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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.content.Context; | 7 import android.content.Context; |
8 | 8 |
9 import org.chromium.base.ThreadUtils; | 9 import org.chromium.base.ThreadUtils; |
10 import org.chromium.base.VisibleForTesting; | 10 import org.chromium.base.VisibleForTesting; |
11 import org.chromium.base.annotations.CalledByNative; | 11 import org.chromium.base.annotations.CalledByNative; |
12 import org.chromium.base.annotations.JNINamespace; | 12 import org.chromium.base.annotations.JNINamespace; |
13 import org.chromium.chrome.R; | 13 import org.chromium.chrome.R; |
14 import org.chromium.chrome.browser.ResourceId; | 14 import org.chromium.chrome.browser.ResourceId; |
| 15 import org.chromium.content_public.browser.WebContents; |
15 | 16 |
16 import java.util.ArrayList; | 17 import java.util.ArrayList; |
17 import java.util.List; | 18 import java.util.List; |
18 | 19 |
19 /** | 20 /** |
20 * Android wrapper of the PersonalDataManager which provides access from the Jav
a | 21 * Android wrapper of the PersonalDataManager which provides access from the Jav
a |
21 * layer. | 22 * layer. |
22 * | 23 * |
23 * Only usable from the UI thread as it's primary purpose is for supporting the
Android | 24 * Only usable from the UI thread as it's primary purpose is for supporting the
Android |
24 * preferences UI. | 25 * preferences UI. |
25 * | 26 * |
26 * See chrome/browser/autofill/personal_data_manager.h for more details. | 27 * See chrome/browser/autofill/personal_data_manager.h for more details. |
27 */ | 28 */ |
28 @JNINamespace("autofill") | 29 @JNINamespace("autofill") |
29 public class PersonalDataManager { | 30 public class PersonalDataManager { |
30 | 31 |
31 /** | 32 /** |
32 * Observer of PersonalDataManager events. | 33 * Observer of PersonalDataManager events. |
33 */ | 34 */ |
34 public interface PersonalDataManagerObserver { | 35 public interface PersonalDataManagerObserver { |
35 /** | 36 /** |
36 * Called when the data is changed. | 37 * Called when the data is changed. |
37 */ | 38 */ |
38 public abstract void onPersonalDataChanged(); | 39 void onPersonalDataChanged(); |
39 } | 40 } |
40 | 41 |
41 /** | 42 /** |
| 43 * Callback for full card request. |
| 44 */ |
| 45 public interface FullCardRequestDelegate { |
| 46 /** |
| 47 * Called when user provided the full card details, including the CVC an
d the full PAN. |
| 48 * |
| 49 * @param card The full card. |
| 50 * @param cvc The CVC for the card. |
| 51 */ |
| 52 @CalledByNative("FullCardRequestDelegate") |
| 53 void onFullCardDetails(CreditCard card, String cvc); |
| 54 |
| 55 /** |
| 56 * Called when user did not provide full card details. |
| 57 */ |
| 58 @CalledByNative("FullCardRequestDelegate") |
| 59 void onFullCardError(); |
| 60 } |
| 61 |
| 62 /** |
42 * Autofill address information. | 63 * Autofill address information. |
43 */ | 64 */ |
44 public static class AutofillProfile { | 65 public static class AutofillProfile { |
45 private String mGUID; | 66 private String mGUID; |
46 private String mOrigin; | 67 private String mOrigin; |
47 private boolean mIsLocal; | 68 private boolean mIsLocal; |
48 private String mFullName; | 69 private String mFullName; |
49 private String mCompanyName; | 70 private String mCompanyName; |
50 private String mStreetAddress; | 71 private String mStreetAddress; |
51 private String mRegion; | 72 private String mRegion; |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 | 526 |
506 public void deleteCreditCard(String guid) { | 527 public void deleteCreditCard(String guid) { |
507 ThreadUtils.assertOnUiThread(); | 528 ThreadUtils.assertOnUiThread(); |
508 nativeRemoveByGUID(mPersonalDataManagerAndroid, guid); | 529 nativeRemoveByGUID(mPersonalDataManagerAndroid, guid); |
509 } | 530 } |
510 | 531 |
511 public void clearUnmaskedCache(String guid) { | 532 public void clearUnmaskedCache(String guid) { |
512 nativeClearUnmaskedCache(mPersonalDataManagerAndroid, guid); | 533 nativeClearUnmaskedCache(mPersonalDataManagerAndroid, guid); |
513 } | 534 } |
514 | 535 |
| 536 public void unmaskCard(WebContents webContents, String guid, FullCardRequest
Delegate delegate) { |
| 537 nativeGetFullCardForPaymentRequest( |
| 538 mPersonalDataManagerAndroid, webContents, guid, delegate); |
| 539 } |
| 540 |
515 /** | 541 /** |
516 * @return Whether the Autofill feature is enabled. | 542 * @return Whether the Autofill feature is enabled. |
517 */ | 543 */ |
518 public static boolean isAutofillEnabled() { | 544 public static boolean isAutofillEnabled() { |
519 return nativeIsAutofillEnabled(); | 545 return nativeIsAutofillEnabled(); |
520 } | 546 } |
521 | 547 |
522 /** | 548 /** |
523 * Enables or disables the Autofill feature. | 549 * Enables or disables the Autofill feature. |
524 * @param enable True to disable Autofill, false otherwise. | 550 * @param enable True to disable Autofill, false otherwise. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 private native int nativeGetCreditCardCount(long nativePersonalDataManagerAn
droid); | 587 private native int nativeGetCreditCardCount(long nativePersonalDataManagerAn
droid); |
562 private native CreditCard nativeGetCreditCardByIndex(long nativePersonalData
ManagerAndroid, | 588 private native CreditCard nativeGetCreditCardByIndex(long nativePersonalData
ManagerAndroid, |
563 int index); | 589 int index); |
564 private native CreditCard nativeGetCreditCardByGUID(long nativePersonalDataM
anagerAndroid, | 590 private native CreditCard nativeGetCreditCardByGUID(long nativePersonalDataM
anagerAndroid, |
565 String guid); | 591 String guid); |
566 private native String nativeSetCreditCard(long nativePersonalDataManagerAndr
oid, | 592 private native String nativeSetCreditCard(long nativePersonalDataManagerAndr
oid, |
567 CreditCard card); | 593 CreditCard card); |
568 private native void nativeRemoveByGUID(long nativePersonalDataManagerAndroid
, String guid); | 594 private native void nativeRemoveByGUID(long nativePersonalDataManagerAndroid
, String guid); |
569 private native void nativeClearUnmaskedCache( | 595 private native void nativeClearUnmaskedCache( |
570 long nativePersonalDataManagerAndroid, String guid); | 596 long nativePersonalDataManagerAndroid, String guid); |
| 597 private native void nativeGetFullCardForPaymentRequest(long nativePersonalDa
taManagerAndroid, |
| 598 WebContents webContents, String guid, FullCardRequestDelegate delega
te); |
571 private static native boolean nativeIsAutofillEnabled(); | 599 private static native boolean nativeIsAutofillEnabled(); |
572 private static native void nativeSetAutofillEnabled(boolean enable); | 600 private static native void nativeSetAutofillEnabled(boolean enable); |
573 private static native boolean nativeIsAutofillManaged(); | 601 private static native boolean nativeIsAutofillManaged(); |
574 private static native boolean nativeIsPaymentsIntegrationEnabled(); | 602 private static native boolean nativeIsPaymentsIntegrationEnabled(); |
575 private static native void nativeSetPaymentsIntegrationEnabled(boolean enabl
e); | 603 private static native void nativeSetPaymentsIntegrationEnabled(boolean enabl
e); |
576 private static native String nativeToCountryCode(String countryName); | 604 private static native String nativeToCountryCode(String countryName); |
577 } | 605 } |
OLD | NEW |