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 all profiles. |
27 jint GetProfileCount(JNIEnv* unused_env, | 27 base::android::ScopedJavaLocalRef<jobjectArray> GetProfileGUIDsForSettings( |
28 const base::android::JavaParamRef<jobject>& unused_obj); | 28 JNIEnv* env, |
29 const base::android::JavaParamRef<jobject>& unused_obj); | |
29 | 30 |
30 // Returns the profile as indexed by |index| in the PersonalDataManager's | 31 // Returns the GUIDs of the profiles to suggest to the user. See |
31 // |GetProfiles()| collection. | 32 // PersonalDataManager::GetProfilesToSuggest for more details. |
32 base::android::ScopedJavaLocalRef<jobject> GetProfileByIndex( | 33 base::android::ScopedJavaLocalRef<jobjectArray> GetProfileGUIDsToSuggest( |
33 JNIEnv* env, | 34 JNIEnv* env, |
34 const base::android::JavaParamRef<jobject>& unused_obj, | 35 const base::android::JavaParamRef<jobject>& unused_obj); |
35 jint index); | |
36 | 36 |
37 // Returns the profile with the specified |jguid|, or NULL if there is no | 37 // 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 | 38 // profile with the specified |jguid|. Both web and auxiliary profiles may |
39 // be returned. | 39 // be returned. |
40 base::android::ScopedJavaLocalRef<jobject> GetProfileByGUID( | 40 base::android::ScopedJavaLocalRef<jobject> GetProfileByGUID( |
41 JNIEnv* env, | 41 JNIEnv* env, |
42 const base::android::JavaParamRef<jobject>& unused_obj, | 42 const base::android::JavaParamRef<jobject>& unused_obj, |
43 const base::android::JavaParamRef<jstring>& jguid); | 43 const base::android::JavaParamRef<jstring>& jguid); |
44 | 44 |
45 // Adds or modifies a profile. If |jguid| is an empty string, we are creating | 45 // Adds or modifies a profile. If |jguid| is an empty string, we are creating |
46 // a new profile. Else we are updating an existing profile. Always returns | 46 // a new profile. Else we are updating an existing profile. Always returns |
47 // the GUID for this profile; the GUID it may have just been created. | 47 // the GUID for this profile; the GUID it may have just been created. |
48 base::android::ScopedJavaLocalRef<jstring> SetProfile( | 48 base::android::ScopedJavaLocalRef<jstring> SetProfile( |
49 JNIEnv* env, | 49 JNIEnv* env, |
50 const base::android::JavaParamRef<jobject>& unused_obj, | 50 const base::android::JavaParamRef<jobject>& unused_obj, |
51 const base::android::JavaParamRef<jobject>& jprofile); | 51 const base::android::JavaParamRef<jobject>& jprofile); |
52 | 52 |
53 // Gets the labels for all known profiles. These labels are useful for | 53 // Gets the labels for all known profiles. These labels are useful for |
54 // distinguishing the profiles from one another. | 54 // distinguishing the profiles from one another. |
55 // | 55 // |
56 // The labels never contain the full name and include at least 2 fields. | 56 // The labels never contain the full name and include at least 2 fields. |
57 base::android::ScopedJavaLocalRef<jobjectArray> GetProfileLabelsForSettings( | |
58 JNIEnv* env, | |
59 const base::android::JavaParamRef<jobject>& unused_obj); | |
60 | |
61 // Gets the labels for the profiles to suggest to the user. These labels are | |
62 // useful for distinguishing the profiles from one another. | |
57 // | 63 // |
58 // If |address_only| is true, then such fields as phone number and email | 64 // The labels never contain the full name and include at least 2 fields. |
59 // address are also omitted, but all fields are included in the label. | 65 // |
60 base::android::ScopedJavaLocalRef<jobjectArray> GetProfileLabels( | 66 // Fields such as phone number and email address are also omitted, but all |
please use gerrit instead
2016/05/31 18:51:56
This comment is inconsistent. Above you say "at le
sebsg
2016/06/01 20:58:24
Done.
| |
67 // fields are included in the label. | |
68 base::android::ScopedJavaLocalRef<jobjectArray> GetProfileLabelsToSuggest( | |
61 JNIEnv* env, | 69 JNIEnv* env, |
62 const base::android::JavaParamRef<jobject>& unused_obj, | 70 const base::android::JavaParamRef<jobject>& unused_obj); |
63 bool address_only); | |
64 | 71 |
65 // These functions act on local credit cards. | 72 // These functions act on local credit cards. |
66 // -------------------- | 73 // -------------------- |
67 | 74 |
68 // Returns the number of credit cards. | 75 // Returns the GUIDs of all the credit cards. |
69 jint GetCreditCardCount( | 76 base::android::ScopedJavaLocalRef<jobjectArray> GetCreditCardGUIDsForSettings( |
70 JNIEnv* unused_env, | 77 JNIEnv* env, |
71 const base::android::JavaParamRef<jobject>& unused_obj); | 78 const base::android::JavaParamRef<jobject>& unused_obj); |
72 | 79 |
73 // Returns the credit card as indexed by |index| in the PersonalDataManager's | 80 // Returns the GUIDs of the credit cards to suggest to the user. See |
74 // |GetCreditCards()| collection. | 81 // PersonalDataManager::GetCreditCardsToSuggest for more details. |
75 base::android::ScopedJavaLocalRef<jobject> GetCreditCardByIndex( | 82 base::android::ScopedJavaLocalRef<jobjectArray> GetCreditCardGUIDsToSuggest( |
76 JNIEnv* env, | 83 JNIEnv* env, |
77 const base::android::JavaParamRef<jobject>& unused_obj, | 84 const base::android::JavaParamRef<jobject>& unused_obj); |
78 jint index); | |
79 | 85 |
80 // Returns the credit card with the specified |jguid|, or NULL if there is | 86 // Returns the credit card with the specified |jguid|, or NULL if there is |
81 // no credit card with the specified |jguid|. | 87 // no credit card with the specified |jguid|. |
82 base::android::ScopedJavaLocalRef<jobject> GetCreditCardByGUID( | 88 base::android::ScopedJavaLocalRef<jobject> GetCreditCardByGUID( |
83 JNIEnv* env, | 89 JNIEnv* env, |
84 const base::android::JavaParamRef<jobject>& unused_obj, | 90 const base::android::JavaParamRef<jobject>& unused_obj, |
85 const base::android::JavaParamRef<jstring>& jguid); | 91 const base::android::JavaParamRef<jstring>& jguid); |
86 | 92 |
87 // Adds or modifies a local credit card. If |jguid| is an empty string, we | 93 // Adds or modifies a local credit card. If |jguid| is an empty string, we |
88 // are creating a new card. Else we are updating an existing profile. Always | 94 // are creating a new card. Else we are updating an existing profile. Always |
(...skipping 27 matching lines...) Expand all Loading... | |
116 const base::android::JavaParamRef<jobject>& jweb_contents, | 122 const base::android::JavaParamRef<jobject>& jweb_contents, |
117 const base::android::JavaParamRef<jstring>& jguid, | 123 const base::android::JavaParamRef<jstring>& jguid, |
118 const base::android::JavaParamRef<jobject>& jdelegate); | 124 const base::android::JavaParamRef<jobject>& jdelegate); |
119 | 125 |
120 // PersonalDataManagerObserver: | 126 // PersonalDataManagerObserver: |
121 void OnPersonalDataChanged() override; | 127 void OnPersonalDataChanged() override; |
122 | 128 |
123 // Registers the JNI bindings for this class. | 129 // Registers the JNI bindings for this class. |
124 static bool Register(JNIEnv* env); | 130 static bool Register(JNIEnv* env); |
125 | 131 |
132 // Sets the use count and use date of the profile associated to the |jguid|. | |
133 // Both |count| and |date| should be non-negative. |date| represents an | |
134 // absolute point in coordinated universal time (UTC) represented as | |
135 // microseconds since the Windows epoch. For more details see the comment | |
136 // header in time.h. | |
137 void SetProfileUseStatsForTesting( | |
138 JNIEnv* env, | |
139 const base::android::JavaParamRef<jobject>& unused_obj, | |
140 const base::android::JavaParamRef<jstring>& jguid, | |
141 jint count, | |
142 jint date); | |
143 | |
144 // Sets the use count and use date of the credit card associated to the | |
145 // |jguid|. Both |count| and |date| should be non-negative. |date| represents | |
146 // an absolute point in coordinated universal time (UTC) represented as | |
147 // microseconds since the Windows epoch. For more details see the comment | |
148 // header in time.h. | |
149 void SetCreditCardUseStatsForTesting( | |
150 JNIEnv* env, | |
151 const base::android::JavaParamRef<jobject>& unused_obj, | |
152 const base::android::JavaParamRef<jstring>& jguid, | |
153 jint count, | |
154 jint date); | |
155 | |
126 private: | 156 private: |
127 ~PersonalDataManagerAndroid() override; | 157 ~PersonalDataManagerAndroid() override; |
128 | 158 |
159 // Returns the GUIDs of the |profiles| passed as parameter. | |
160 base::android::ScopedJavaLocalRef<jobjectArray> GetProfileGUIDs( | |
161 JNIEnv* env, | |
162 const std::vector<AutofillProfile*>& profiles); | |
163 | |
164 // Returns the GUIDs of the |credit_cards| passed as parameter. | |
165 base::android::ScopedJavaLocalRef<jobjectArray> GetCreditCardGUIDs( | |
166 JNIEnv* env, | |
167 const std::vector<CreditCard*>& credit_cards); | |
168 | |
169 // Gets the labels for the |profiles| passed as paremeters. These labels are | |
gone
2016/05/31 22:39:42
nit: parameters
sebsg
2016/06/01 20:58:24
Done.
| |
170 // useful for distinguishing the profiles from one another. | |
171 // | |
172 // The labels never contain the full name and include at least 2 fields. | |
173 // | |
174 // If |address_only| is true, then such fields as phone number and email | |
175 // address are also omitted, but all fields are included in the label. | |
176 base::android::ScopedJavaLocalRef<jobjectArray> GetProfileLabels( | |
177 JNIEnv* env, | |
178 bool address_only, | |
179 std::vector<AutofillProfile*> profiles); | |
180 | |
129 // Pointer to the java counterpart. | 181 // Pointer to the java counterpart. |
130 JavaObjectWeakGlobalRef weak_java_obj_; | 182 JavaObjectWeakGlobalRef weak_java_obj_; |
131 | 183 |
132 // Pointer to the PersonalDataManager for the main profile. | 184 // Pointer to the PersonalDataManager for the main profile. |
133 PersonalDataManager* personal_data_manager_; | 185 PersonalDataManager* personal_data_manager_; |
134 | 186 |
135 DISALLOW_COPY_AND_ASSIGN(PersonalDataManagerAndroid); | 187 DISALLOW_COPY_AND_ASSIGN(PersonalDataManagerAndroid); |
136 }; | 188 }; |
137 | 189 |
138 } // namespace autofill | 190 } // namespace autofill |
139 | 191 |
140 #endif // CHROME_BROWSER_AUTOFILL_ANDROID_PERSONAL_DATA_MANAGER_ANDROID_H_ | 192 #endif // CHROME_BROWSER_AUTOFILL_ANDROID_PERSONAL_DATA_MANAGER_ANDROID_H_ |
OLD | NEW |