Chromium Code Reviews| 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 #ifndef CHROME_BROWSER_AUTOFILL_ANDROID_PERSONAL_DATA_MANAGER_ANDROID_H_ | 5 #ifndef CHROME_BROWSER_AUTOFILL_ANDROID_PERSONAL_DATA_MANAGER_ANDROID_H_ |
| 6 #define CHROME_BROWSER_AUTOFILL_ANDROID_PERSONAL_DATA_MANAGER_ANDROID_H_ | 6 #define CHROME_BROWSER_AUTOFILL_ANDROID_PERSONAL_DATA_MANAGER_ANDROID_H_ |
| 7 | 7 |
| 8 #include "base/android/jni_weak_ref.h" | 8 #include "base/android/jni_weak_ref.h" |
| 9 #include "base/android/scoped_java_ref.h" | 9 #include "base/android/scoped_java_ref.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "components/autofill/core/browser/personal_data_manager.h" | 11 #include "components/autofill/core/browser/personal_data_manager.h" |
| 12 #include "components/autofill/core/browser/personal_data_manager_observer.h" | 12 #include "components/autofill/core/browser/personal_data_manager_observer.h" |
| 13 | 13 |
| 14 namespace autofill { | 14 namespace autofill { |
| 15 | 15 |
| 16 // Android wrapper of the PersonalDataManager which provides access from the | 16 // Android wrapper of the PersonalDataManager which provides access from the |
| 17 // Java layer. Note that on Android, there's only a single profile, and | 17 // Java layer. Note that on Android, there's only a single profile, and |
| 18 // therefore a single instance of this wrapper. | 18 // therefore a single instance of this wrapper. |
| 19 class PersonalDataManagerAndroid : public PersonalDataManagerObserver { | 19 class PersonalDataManagerAndroid : public PersonalDataManagerObserver { |
| 20 public: | 20 public: |
| 21 PersonalDataManagerAndroid(JNIEnv* env, jobject obj); | 21 PersonalDataManagerAndroid(JNIEnv* env, jobject obj); |
| 22 | 22 |
| 23 // These functions act on "web profiles" aka "LOCAL_PROFILE" profiles. | 23 // These functions act on "web profiles" aka "LOCAL_PROFILE" profiles. |
| 24 // ------------------------- | 24 // ------------------------- |
| 25 | 25 |
| 26 // Returns the number of web and auxiliary profiles. | 26 // Returns the GUIDs of the profiles to suggest to the user. See |
| 27 jint GetProfileCount(JNIEnv* unused_env, | 27 // PersonalDataManager::GetProfilesToSuggest for more details. |
| 28 const base::android::JavaParamRef<jobject>& unused_obj); | 28 base::android::ScopedJavaLocalRef<jobjectArray> GetProfileGUIDsToSuggest( |
| 29 | |
| 30 // Returns the profile as indexed by |index| in the PersonalDataManager's | |
| 31 // |GetProfiles()| collection. | |
| 32 base::android::ScopedJavaLocalRef<jobject> GetProfileByIndex( | |
| 33 JNIEnv* env, | 29 JNIEnv* env, |
| 34 const base::android::JavaParamRef<jobject>& unused_obj, | 30 const base::android::JavaParamRef<jobject>& unused_obj); |
| 35 jint index); | |
| 36 | 31 |
| 37 // Returns the profile with the specified |jguid|, or NULL if there is no | 32 // Returns the profile with the specified |jguid|, or NULL if there is no |
| 38 // profile with the specified |jguid|. Both web and auxiliary profiles may | 33 // profile with the specified |jguid|. Both web and auxiliary profiles may |
| 39 // be returned. | 34 // be returned. |
| 40 base::android::ScopedJavaLocalRef<jobject> GetProfileByGUID( | 35 base::android::ScopedJavaLocalRef<jobject> GetProfileByGUID( |
| 41 JNIEnv* env, | 36 JNIEnv* env, |
| 42 const base::android::JavaParamRef<jobject>& unused_obj, | 37 const base::android::JavaParamRef<jobject>& unused_obj, |
| 43 const base::android::JavaParamRef<jstring>& jguid); | 38 const base::android::JavaParamRef<jstring>& jguid); |
| 44 | 39 |
| 45 // Adds or modifies a profile. If |jguid| is an empty string, we are creating | 40 // Adds or modifies a profile. If |jguid| is an empty string, we are creating |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 58 // If |address_only| is true, then such fields as phone number and email | 53 // If |address_only| is true, then such fields as phone number and email |
| 59 // address are also omitted, but all fields are included in the label. | 54 // address are also omitted, but all fields are included in the label. |
| 60 base::android::ScopedJavaLocalRef<jobjectArray> GetProfileLabels( | 55 base::android::ScopedJavaLocalRef<jobjectArray> GetProfileLabels( |
| 61 JNIEnv* env, | 56 JNIEnv* env, |
| 62 const base::android::JavaParamRef<jobject>& unused_obj, | 57 const base::android::JavaParamRef<jobject>& unused_obj, |
| 63 bool address_only); | 58 bool address_only); |
| 64 | 59 |
| 65 // These functions act on local credit cards. | 60 // These functions act on local credit cards. |
| 66 // -------------------- | 61 // -------------------- |
| 67 | 62 |
| 68 // Returns the number of credit cards. | 63 // Returns the GUIDs of the credit cards to suggest to the user. See |
| 69 jint GetCreditCardCount( | 64 // PersonalDataManager::GetCreditCardsToSuggest for more details. |
| 70 JNIEnv* unused_env, | 65 base::android::ScopedJavaLocalRef<jobjectArray> GetCreditCardGUIDsToSuggest( |
| 71 const base::android::JavaParamRef<jobject>& unused_obj); | |
| 72 | |
| 73 // Returns the credit card as indexed by |index| in the PersonalDataManager's | |
| 74 // |GetCreditCards()| collection. | |
| 75 base::android::ScopedJavaLocalRef<jobject> GetCreditCardByIndex( | |
| 76 JNIEnv* env, | 66 JNIEnv* env, |
| 77 const base::android::JavaParamRef<jobject>& unused_obj, | 67 const base::android::JavaParamRef<jobject>& unused_ob); |
| 78 jint index); | |
| 79 | 68 |
| 80 // Returns the credit card with the specified |jguid|, or NULL if there is | 69 // Returns the credit card with the specified |jguid|, or NULL if there is |
| 81 // no credit card with the specified |jguid|. | 70 // no credit card with the specified |jguid|. |
| 82 base::android::ScopedJavaLocalRef<jobject> GetCreditCardByGUID( | 71 base::android::ScopedJavaLocalRef<jobject> GetCreditCardByGUID( |
| 83 JNIEnv* env, | 72 JNIEnv* env, |
| 84 const base::android::JavaParamRef<jobject>& unused_obj, | 73 const base::android::JavaParamRef<jobject>& unused_obj, |
| 85 const base::android::JavaParamRef<jstring>& jguid); | 74 const base::android::JavaParamRef<jstring>& jguid); |
| 86 | 75 |
| 87 // Adds or modifies a credit card. If |jguid| is an empty string, we are | 76 // Adds or modifies a credit card. If |jguid| is an empty string, we are |
| 88 // creating a new profile. Else we are updating an existing profile. Always | 77 // creating a new profile. Else we are updating an existing profile. Always |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 110 const base::android::JavaParamRef<jobject>& jweb_contents, | 99 const base::android::JavaParamRef<jobject>& jweb_contents, |
| 111 const base::android::JavaParamRef<jstring>& jguid, | 100 const base::android::JavaParamRef<jstring>& jguid, |
| 112 const base::android::JavaParamRef<jobject>& jdelegate); | 101 const base::android::JavaParamRef<jobject>& jdelegate); |
| 113 | 102 |
| 114 // PersonalDataManagerObserver: | 103 // PersonalDataManagerObserver: |
| 115 void OnPersonalDataChanged() override; | 104 void OnPersonalDataChanged() override; |
| 116 | 105 |
| 117 // Registers the JNI bindings for this class. | 106 // Registers the JNI bindings for this class. |
| 118 static bool Register(JNIEnv* env); | 107 static bool Register(JNIEnv* env); |
| 119 | 108 |
| 109 // Sets the use count and use date of the profile associated to the |jguid|. | |
|
please use gerrit instead
2016/05/24 20:21:48
Ditto about |count| and |date| range assumptions a
sebsg
2016/05/24 21:41:22
Done.
| |
| 110 void SetProfileUseStatsForTest( | |
| 111 JNIEnv* env, | |
| 112 const base::android::JavaParamRef<jobject>& unused_obj, | |
| 113 const base::android::JavaParamRef<jstring>& jguid, | |
| 114 jint count, | |
| 115 jint date); | |
| 116 | |
| 117 // Sets the use count and use date of the credit card associated to the | |
| 118 // |jguid|. | |
| 119 void SetCreditCardUseStatsForTest( | |
|
please use gerrit instead
2016/05/24 20:21:48
Ditto.
sebsg
2016/05/24 21:41:22
Done.
| |
| 120 JNIEnv* env, | |
| 121 const base::android::JavaParamRef<jobject>& unused_obj, | |
| 122 const base::android::JavaParamRef<jstring>& jguid, | |
| 123 jint count, | |
| 124 jint date); | |
| 125 | |
| 120 private: | 126 private: |
| 121 ~PersonalDataManagerAndroid() override; | 127 ~PersonalDataManagerAndroid() override; |
| 122 | 128 |
| 123 // Pointer to the java counterpart. | 129 // Pointer to the java counterpart. |
| 124 JavaObjectWeakGlobalRef weak_java_obj_; | 130 JavaObjectWeakGlobalRef weak_java_obj_; |
| 125 | 131 |
| 126 // Pointer to the PersonalDataManager for the main profile. | 132 // Pointer to the PersonalDataManager for the main profile. |
| 127 PersonalDataManager* personal_data_manager_; | 133 PersonalDataManager* personal_data_manager_; |
| 128 | 134 |
| 129 DISALLOW_COPY_AND_ASSIGN(PersonalDataManagerAndroid); | 135 DISALLOW_COPY_AND_ASSIGN(PersonalDataManagerAndroid); |
| 130 }; | 136 }; |
| 131 | 137 |
| 132 } // namespace autofill | 138 } // namespace autofill |
| 133 | 139 |
| 134 #endif // CHROME_BROWSER_AUTOFILL_ANDROID_PERSONAL_DATA_MANAGER_ANDROID_H_ | 140 #endif // CHROME_BROWSER_AUTOFILL_ANDROID_PERSONAL_DATA_MANAGER_ANDROID_H_ |
| OLD | NEW |