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; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 */ | 53 */ |
54 @CalledByNative("FullCardRequestDelegate") | 54 @CalledByNative("FullCardRequestDelegate") |
55 void onFullCardDetails(CreditCard card, String cvc); | 55 void onFullCardDetails(CreditCard card, String cvc); |
56 | 56 |
57 /** | 57 /** |
58 * Called when user did not provide full card details. | 58 * Called when user did not provide full card details. |
59 */ | 59 */ |
60 @CalledByNative("FullCardRequestDelegate") | 60 @CalledByNative("FullCardRequestDelegate") |
61 void onFullCardError(); | 61 void onFullCardError(); |
62 } | 62 } |
63 | 63 |
please use gerrit instead
2016/09/23 09:04:39
Put NormalizedAddressRequester here.
sebsg
2016/09/27 18:48:37
Done.
| |
64 /** | 64 /** |
65 * Autofill address information. | 65 * Autofill address information. |
66 */ | 66 */ |
67 public static class AutofillProfile { | 67 public static class AutofillProfile { |
68 private String mGUID; | 68 private String mGUID; |
69 private String mOrigin; | 69 private String mOrigin; |
70 private boolean mIsLocal; | 70 private boolean mIsLocal; |
71 private String mFullName; | 71 private String mFullName; |
72 private String mCompanyName; | 72 private String mCompanyName; |
73 private String mStreetAddress; | 73 private String mStreetAddress; |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
471 if (sManager == null) { | 471 if (sManager == null) { |
472 sManager = new PersonalDataManager(); | 472 sManager = new PersonalDataManager(); |
473 } | 473 } |
474 return sManager; | 474 return sManager; |
475 } | 475 } |
476 | 476 |
477 private final long mPersonalDataManagerAndroid; | 477 private final long mPersonalDataManagerAndroid; |
478 private final List<PersonalDataManagerObserver> mDataObservers = | 478 private final List<PersonalDataManagerObserver> mDataObservers = |
479 new ArrayList<PersonalDataManagerObserver>(); | 479 new ArrayList<PersonalDataManagerObserver>(); |
480 | 480 |
481 // The requester of the address normalization. | |
482 private NormalizedAddressRequester mRequester; | |
please use gerrit instead
2016/09/23 09:04:39
Don't save the pointer here. Follow the pattern of
sebsg
2016/09/27 18:48:37
Done.
| |
483 | |
481 private PersonalDataManager() { | 484 private PersonalDataManager() { |
482 // Note that this technically leaks the native object, however, Personal DataManager | 485 // Note that this technically leaks the native object, however, Personal DataManager |
483 // is a singleton that lives forever and there's no clean shutdown of Ch rome on Android | 486 // is a singleton that lives forever and there's no clean shutdown of Ch rome on Android |
484 mPersonalDataManagerAndroid = nativeInit(); | 487 mPersonalDataManagerAndroid = nativeInit(); |
485 } | 488 } |
486 | 489 |
487 /** | 490 /** |
488 * Called from native when template URL service is done loading. | 491 * Called from native when template URL service is done loading. |
489 */ | 492 */ |
490 @CalledByNative | 493 @CalledByNative |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
711 return nativeGetCreditCardUseDateForTesting(mPersonalDataManagerAndroid, guid); | 714 return nativeGetCreditCardUseDateForTesting(mPersonalDataManagerAndroid, guid); |
712 } | 715 } |
713 | 716 |
714 @VisibleForTesting | 717 @VisibleForTesting |
715 long getCurrentDateForTesting() { | 718 long getCurrentDateForTesting() { |
716 ThreadUtils.assertOnUiThread(); | 719 ThreadUtils.assertOnUiThread(); |
717 return nativeGetCurrentDateForTesting(mPersonalDataManagerAndroid); | 720 return nativeGetCurrentDateForTesting(mPersonalDataManagerAndroid); |
718 } | 721 } |
719 | 722 |
720 /** | 723 /** |
724 * Starts loading the address validation rules for the specified {@code regi onCode}. | |
725 * | |
726 * @param regionCode The code of the region for which to load the rules. | |
727 */ | |
728 public void loadRulesForRegion(String regionCode) { | |
729 ThreadUtils.assertOnUiThread(); | |
730 nativeLoadRulesForRegion(mPersonalDataManagerAndroid, regionCode); | |
731 } | |
732 | |
733 /** | |
734 * Sets up the task to start normalizing the address of the profile associat ed with the | |
735 * specified {@code guid} when the rules associated with the {@code regionCo de} are done | |
736 * loading. After completion, the normalized profile will be sent to the {@c ode requester}. | |
737 * | |
738 * @param guid The GUID of the profile to normalize. | |
739 * @param regionCode The region code indicating which rules to use for norma lization. | |
740 * @param requester The object requesting the normalization. | |
741 */ | |
742 public void startAddressNormalizationTask( | |
please use gerrit instead
2016/09/23 09:04:39
"normalizeAddress()" is a simpler name.
sebsg
2016/09/27 18:48:37
I wanted the name to reflect the fact that it can
| |
743 String guid, String regionCode, NormalizedAddressRequester requester ) { | |
744 ThreadUtils.assertOnUiThread(); | |
745 mRequester = requester; | |
746 nativeStartAddressNormalizationTask(mPersonalDataManagerAndroid, guid, r egionCode); | |
747 } | |
748 | |
749 /** | |
750 * Cancels the pending normalization task. | |
751 */ | |
752 public void cancelAddressNormalizationTask() { | |
please use gerrit instead
2016/09/23 09:04:39
"cancelPendingAddressNormalization()"
sebsg
2016/09/27 18:48:37
Done.
| |
753 ThreadUtils.assertOnUiThread(); | |
754 if (mRequester != null) { | |
755 mRequester = null; | |
756 nativeCancelAddressNormalizationTask(mPersonalDataManagerAndroid); | |
757 } | |
758 } | |
759 | |
760 /** | |
761 * Called from native when the requested address normalization has been comp leted. | |
762 * | |
763 * @param profile The profile with the normalized address. | |
764 */ | |
765 @CalledByNative | |
766 private void onAddressNormalized(AutofillProfile profile) { | |
767 ThreadUtils.assertOnUiThread(); | |
768 if (mRequester != null) { | |
769 mRequester.onAddressNormalized(profile); | |
770 mRequester = null; | |
771 } | |
772 } | |
773 | |
774 /** | |
721 * @return Whether the Autofill feature is enabled. | 775 * @return Whether the Autofill feature is enabled. |
722 */ | 776 */ |
723 public static boolean isAutofillEnabled() { | 777 public static boolean isAutofillEnabled() { |
724 return nativeIsAutofillEnabled(); | 778 return nativeIsAutofillEnabled(); |
725 } | 779 } |
726 | 780 |
727 /** | 781 /** |
728 * Enables or disables the Autofill feature. | 782 * Enables or disables the Autofill feature. |
729 * @param enable True to disable Autofill, false otherwise. | 783 * @param enable True to disable Autofill, false otherwise. |
730 */ | 784 */ |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
799 long nativePersonalDataManagerAndroid, String guid, int count, long date); | 853 long nativePersonalDataManagerAndroid, String guid, int count, long date); |
800 private native int nativeGetCreditCardUseCountForTesting(long nativePersonal DataManagerAndroid, | 854 private native int nativeGetCreditCardUseCountForTesting(long nativePersonal DataManagerAndroid, |
801 String guid); | 855 String guid); |
802 private native long nativeGetCreditCardUseDateForTesting(long nativePersonal DataManagerAndroid, | 856 private native long nativeGetCreditCardUseDateForTesting(long nativePersonal DataManagerAndroid, |
803 String guid); | 857 String guid); |
804 private native long nativeGetCurrentDateForTesting(long nativePersonalDataMa nagerAndroid); | 858 private native long nativeGetCurrentDateForTesting(long nativePersonalDataMa nagerAndroid); |
805 private native void nativeClearUnmaskedCache( | 859 private native void nativeClearUnmaskedCache( |
806 long nativePersonalDataManagerAndroid, String guid); | 860 long nativePersonalDataManagerAndroid, String guid); |
807 private native void nativeGetFullCardForPaymentRequest(long nativePersonalDa taManagerAndroid, | 861 private native void nativeGetFullCardForPaymentRequest(long nativePersonalDa taManagerAndroid, |
808 WebContents webContents, CreditCard card, FullCardRequestDelegate de legate); | 862 WebContents webContents, CreditCard card, FullCardRequestDelegate de legate); |
863 private native void nativeLoadRulesForRegion( | |
864 long nativePersonalDataManagerAndroid, String regionCode); | |
865 private native void nativeStartAddressNormalizationTask( | |
866 long nativePersonalDataManagerAndroid, String guid, String regionCod e); | |
867 private native void nativeCancelAddressNormalizationTask(long nativePersonal DataManagerAndroid); | |
809 private static native boolean nativeIsAutofillEnabled(); | 868 private static native boolean nativeIsAutofillEnabled(); |
810 private static native void nativeSetAutofillEnabled(boolean enable); | 869 private static native void nativeSetAutofillEnabled(boolean enable); |
811 private static native boolean nativeIsAutofillManaged(); | 870 private static native boolean nativeIsAutofillManaged(); |
812 private static native boolean nativeIsPaymentsIntegrationEnabled(); | 871 private static native boolean nativeIsPaymentsIntegrationEnabled(); |
813 private static native void nativeSetPaymentsIntegrationEnabled(boolean enabl e); | 872 private static native void nativeSetPaymentsIntegrationEnabled(boolean enabl e); |
814 private static native String nativeToCountryCode(String countryName); | 873 private static native String nativeToCountryCode(String countryName); |
815 } | 874 } |
OLD | NEW |