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 number of web and auxiliary profiles. |
| 27 jint GetProfileCount(JNIEnv* unused_env, | 27 jint GetProfileCount(JNIEnv* unused_env, |
| 28 const base::android::JavaParamRef<jobject>& unused_obj); | 28 const base::android::JavaParamRef<jobject>& unused_obj); |
| 29 | 29 |
| 30 // Returns the profile as indexed by |index| in the PersonalDataManager's | 30 // Returns the GUIDs of the profiles that should be suggested to the user. The |
| 31 // |GetProfiles()| collection. | 31 // profiles are already sorted by frecency. |
| 32 base::android::ScopedJavaLocalRef<jobject> GetProfileByIndex( | 32 base::android::ScopedJavaLocalRef<jobjectArray> GetProfileGUIDsToSuggest( |
| 33 JNIEnv* env, | 33 JNIEnv* env, |
| 34 const base::android::JavaParamRef<jobject>& unused_obj, | 34 const base::android::JavaParamRef<jobject>& unused_obj); |
| 35 jint index); | |
| 36 | 35 |
| 37 // Returns the profile with the specified |jguid|, or NULL if there is no | 36 // 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 | 37 // profile with the specified |jguid|. Both web and auxiliary profiles may |
| 39 // be returned. | 38 // be returned. |
| 40 base::android::ScopedJavaLocalRef<jobject> GetProfileByGUID( | 39 base::android::ScopedJavaLocalRef<jobject> GetProfileByGUID( |
| 41 JNIEnv* env, | 40 JNIEnv* env, |
| 42 const base::android::JavaParamRef<jobject>& unused_obj, | 41 const base::android::JavaParamRef<jobject>& unused_obj, |
| 43 const base::android::JavaParamRef<jstring>& jguid); | 42 const base::android::JavaParamRef<jstring>& jguid); |
| 44 | 43 |
| 45 // Adds or modifies a profile. If |jguid| is an empty string, we are creating | 44 // Adds or modifies a profile. If |jguid| is an empty string, we are creating |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 63 bool address_only); | 62 bool address_only); |
| 64 | 63 |
| 65 // These functions act on local credit cards. | 64 // These functions act on local credit cards. |
| 66 // -------------------- | 65 // -------------------- |
| 67 | 66 |
| 68 // Returns the number of credit cards. | 67 // Returns the number of credit cards. |
| 69 jint GetCreditCardCount( | 68 jint GetCreditCardCount( |
| 70 JNIEnv* unused_env, | 69 JNIEnv* unused_env, |
| 71 const base::android::JavaParamRef<jobject>& unused_obj); | 70 const base::android::JavaParamRef<jobject>& unused_obj); |
| 72 | 71 |
| 73 // Returns the credit card as indexed by |index| in the PersonalDataManager's | 72 // Returns the GUIDs of the credit cards that should be suggested to the |
| 74 // |GetCreditCards()| collection. | 73 // user. The cards are already deduped and sorted by frecency with the |
|
Mathieu
2016/05/20 13:57:08
nit: I wouldn't make implementation specific comme
sebsg
2016/05/24 17:27:32
Good point.
| |
| 75 base::android::ScopedJavaLocalRef<jobject> GetCreditCardByIndex( | 74 // expired cards last. |
| 75 base::android::ScopedJavaLocalRef<jobjectArray> GetCreditCardGUIDsToSuggest( | |
| 76 JNIEnv* env, | 76 JNIEnv* env, |
| 77 const base::android::JavaParamRef<jobject>& unused_obj, | 77 const base::android::JavaParamRef<jobject>& unused_ob); |
| 78 jint index); | |
| 79 | 78 |
| 80 // Returns the credit card with the specified |jguid|, or NULL if there is | 79 // Returns the credit card with the specified |jguid|, or NULL if there is |
| 81 // no credit card with the specified |jguid|. | 80 // no credit card with the specified |jguid|. |
| 82 base::android::ScopedJavaLocalRef<jobject> GetCreditCardByGUID( | 81 base::android::ScopedJavaLocalRef<jobject> GetCreditCardByGUID( |
| 83 JNIEnv* env, | 82 JNIEnv* env, |
| 84 const base::android::JavaParamRef<jobject>& unused_obj, | 83 const base::android::JavaParamRef<jobject>& unused_obj, |
| 85 const base::android::JavaParamRef<jstring>& jguid); | 84 const base::android::JavaParamRef<jstring>& jguid); |
| 86 | 85 |
| 87 // Adds or modifies a credit card. If |jguid| is an empty string, we are | 86 // 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 | 87 // 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, | 109 const base::android::JavaParamRef<jobject>& jweb_contents, |
| 111 const base::android::JavaParamRef<jstring>& jguid, | 110 const base::android::JavaParamRef<jstring>& jguid, |
| 112 const base::android::JavaParamRef<jobject>& jdelegate); | 111 const base::android::JavaParamRef<jobject>& jdelegate); |
| 113 | 112 |
| 114 // PersonalDataManagerObserver: | 113 // PersonalDataManagerObserver: |
| 115 void OnPersonalDataChanged() override; | 114 void OnPersonalDataChanged() override; |
| 116 | 115 |
| 117 // Registers the JNI bindings for this class. | 116 // Registers the JNI bindings for this class. |
| 118 static bool Register(JNIEnv* env); | 117 static bool Register(JNIEnv* env); |
| 119 | 118 |
| 119 // Sets the use count and use date of the profile associated to the |jguid|. | |
| 120 void SetProfileUseStatsForTest( | |
| 121 JNIEnv* env, | |
| 122 const base::android::JavaParamRef<jobject>& unused_obj, | |
| 123 const base::android::JavaParamRef<jstring>& jguid, | |
| 124 jint count, | |
| 125 jint date); | |
| 126 | |
| 127 // Sets the use count and use date of the credit card associated to the | |
| 128 // |jguid|. | |
| 129 void SetCreditCardUseStatsForTest( | |
| 130 JNIEnv* env, | |
| 131 const base::android::JavaParamRef<jobject>& unused_obj, | |
| 132 const base::android::JavaParamRef<jstring>& jguid, | |
| 133 jint count, | |
| 134 jint date); | |
| 135 | |
| 120 private: | 136 private: |
| 121 ~PersonalDataManagerAndroid() override; | 137 ~PersonalDataManagerAndroid() override; |
| 122 | 138 |
| 123 // Pointer to the java counterpart. | 139 // Pointer to the java counterpart. |
| 124 JavaObjectWeakGlobalRef weak_java_obj_; | 140 JavaObjectWeakGlobalRef weak_java_obj_; |
| 125 | 141 |
| 126 // Pointer to the PersonalDataManager for the main profile. | 142 // Pointer to the PersonalDataManager for the main profile. |
| 127 PersonalDataManager* personal_data_manager_; | 143 PersonalDataManager* personal_data_manager_; |
| 128 | 144 |
| 129 DISALLOW_COPY_AND_ASSIGN(PersonalDataManagerAndroid); | 145 DISALLOW_COPY_AND_ASSIGN(PersonalDataManagerAndroid); |
| 130 }; | 146 }; |
| 131 | 147 |
| 132 } // namespace autofill | 148 } // namespace autofill |
| 133 | 149 |
| 134 #endif // CHROME_BROWSER_AUTOFILL_ANDROID_PERSONAL_DATA_MANAGER_ANDROID_H_ | 150 #endif // CHROME_BROWSER_AUTOFILL_ANDROID_PERSONAL_DATA_MANAGER_ANDROID_H_ |
| OLD | NEW |