Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(240)

Side by Side Diff: chrome/browser/autofill/android/personal_data_manager_android.h

Issue 1982623002: [Autofill] Sort profiles and credit cards by frecency in PaymentRequest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed unnecessary method Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 // 57 //
58 // If |address_only| is true, then such fields as phone number and email 58 // 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. 59 // address are also omitted, but all fields are included in the label.
60 base::android::ScopedJavaLocalRef<jobjectArray> GetProfileLabels( 60 base::android::ScopedJavaLocalRef<jobjectArray> GetProfileLabelsForSettings(
61 JNIEnv* env, 61 JNIEnv* env,
62 const base::android::JavaParamRef<jobject>& unused_obj, 62 const base::android::JavaParamRef<jobject>& unused_obj,
63 bool address_only); 63 bool address_only);
please use gerrit instead 2016/05/27 21:47:30 This param will be always false, so there's no nee
sebsg 2016/05/31 15:26:14 Done.
64
65 // Gets the labels for the profiles to suggest to the user. These labels are
66 // useful for distinguishing the profiles from one another.
67 //
68 // The labels never contain the full name and include at least 2 fields.
69 //
70 // If |address_only| is true, then such fields as phone number and email
71 // address are also omitted, but all fields are included in the label.
72 base::android::ScopedJavaLocalRef<jobjectArray> GetProfileLabelsToSuggest(
73 JNIEnv* env,
74 const base::android::JavaParamRef<jobject>& unused_obj,
75 bool address_only);
please use gerrit instead 2016/05/27 21:47:30 This param will be always true, so there's no need
sebsg 2016/05/31 15:26:14 Done.
64 76
65 // These functions act on local credit cards. 77 // These functions act on local credit cards.
66 // -------------------- 78 // --------------------
67 79
68 // Returns the number of credit cards. 80 // Returns the GUIDs of all the credit cards.
69 jint GetCreditCardCount( 81 base::android::ScopedJavaLocalRef<jobjectArray> GetCreditCardGUIDsForSettings(
70 JNIEnv* unused_env, 82 JNIEnv* env,
71 const base::android::JavaParamRef<jobject>& unused_obj); 83 const base::android::JavaParamRef<jobject>& unused_ob);
please use gerrit instead 2016/05/27 21:47:30 s/unused_ob/unused_obj/
sebsg 2016/05/31 15:26:14 Done.
72 84
73 // Returns the credit card as indexed by |index| in the PersonalDataManager's 85 // Returns the GUIDs of the credit cards to suggest to the user. See
74 // |GetCreditCards()| collection. 86 // PersonalDataManager::GetCreditCardsToSuggest for more details.
75 base::android::ScopedJavaLocalRef<jobject> GetCreditCardByIndex( 87 base::android::ScopedJavaLocalRef<jobjectArray> GetCreditCardGUIDsToSuggest(
76 JNIEnv* env, 88 JNIEnv* env,
77 const base::android::JavaParamRef<jobject>& unused_obj, 89 const base::android::JavaParamRef<jobject>& unused_ob);
please use gerrit instead 2016/05/27 21:47:30 s/unused_ob/unused_obj/
sebsg 2016/05/31 15:26:14 Done.
78 jint index);
79 90
80 // Returns the credit card with the specified |jguid|, or NULL if there is 91 // Returns the credit card with the specified |jguid|, or NULL if there is
81 // no credit card with the specified |jguid|. 92 // no credit card with the specified |jguid|.
82 base::android::ScopedJavaLocalRef<jobject> GetCreditCardByGUID( 93 base::android::ScopedJavaLocalRef<jobject> GetCreditCardByGUID(
83 JNIEnv* env, 94 JNIEnv* env,
84 const base::android::JavaParamRef<jobject>& unused_obj, 95 const base::android::JavaParamRef<jobject>& unused_obj,
85 const base::android::JavaParamRef<jstring>& jguid); 96 const base::android::JavaParamRef<jstring>& jguid);
86 97
87 // Adds or modifies a local credit card. If |jguid| is an empty string, we 98 // 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 99 // are creating a new card. Else we are updating an existing profile. Always
(...skipping 27 matching lines...) Expand all
116 const base::android::JavaParamRef<jobject>& jweb_contents, 127 const base::android::JavaParamRef<jobject>& jweb_contents,
117 const base::android::JavaParamRef<jstring>& jguid, 128 const base::android::JavaParamRef<jstring>& jguid,
118 const base::android::JavaParamRef<jobject>& jdelegate); 129 const base::android::JavaParamRef<jobject>& jdelegate);
119 130
120 // PersonalDataManagerObserver: 131 // PersonalDataManagerObserver:
121 void OnPersonalDataChanged() override; 132 void OnPersonalDataChanged() override;
122 133
123 // Registers the JNI bindings for this class. 134 // Registers the JNI bindings for this class.
124 static bool Register(JNIEnv* env); 135 static bool Register(JNIEnv* env);
125 136
137 // Sets the use count and use date of the profile associated to the |jguid|.
138 // Both |count| and |date| should be non-negative. |date| represents an
139 // absolute point in coordinated universal time (UTC) represented as
140 // microseconds since the Windows epoch. For more details see the comment
141 // header in time.h.
142 void SetProfileUseStatsForTesting(
143 JNIEnv* env,
144 const base::android::JavaParamRef<jobject>& unused_obj,
145 const base::android::JavaParamRef<jstring>& jguid,
146 jint count,
147 jint date);
148
149 // Sets the use count and use date of the credit card associated to the
150 // |jguid|. Both |count| and |date| should be non-negative. |date| represents
151 // an absolute point in coordinated universal time (UTC) represented as
152 // microseconds since the Windows epoch. For more details see the comment
153 // header in time.h.
154 void SetCreditCardUseStatsForTesting(
155 JNIEnv* env,
156 const base::android::JavaParamRef<jobject>& unused_obj,
157 const base::android::JavaParamRef<jstring>& jguid,
158 jint count,
159 jint date);
160
126 private: 161 private:
127 ~PersonalDataManagerAndroid() override; 162 ~PersonalDataManagerAndroid() override;
128 163
164 // Returns the GUIDs of the |profiles| passed as parameter.
165 base::android::ScopedJavaLocalRef<jobjectArray> GetProfileGUIDs(
166 JNIEnv* env,
167 const std::vector<AutofillProfile*>& profiles);
168
169 // Returns the GUIDs of the |credit_cards| passed as parameter.
170 base::android::ScopedJavaLocalRef<jobjectArray> GetCreditCardGUIDs(
171 JNIEnv* env,
172 const std::vector<CreditCard*>& credit_cards);
173
174 // Gets the labels for the |profiles| passed as paremeters. These labels are
175 // useful for distinguishing the profiles from one another.
176 //
177 // The labels never contain the full name and include at least 2 fields.
178 //
179 // If |address_only| is true, then such fields as phone number and email
180 // address are also omitted, but all fields are included in the label.
181 base::android::ScopedJavaLocalRef<jobjectArray> GetProfileLabels(
182 JNIEnv* env,
183 bool address_only,
184 std::vector<AutofillProfile*> profiles);
185
129 // Pointer to the java counterpart. 186 // Pointer to the java counterpart.
130 JavaObjectWeakGlobalRef weak_java_obj_; 187 JavaObjectWeakGlobalRef weak_java_obj_;
131 188
132 // Pointer to the PersonalDataManager for the main profile. 189 // Pointer to the PersonalDataManager for the main profile.
133 PersonalDataManager* personal_data_manager_; 190 PersonalDataManager* personal_data_manager_;
134 191
135 DISALLOW_COPY_AND_ASSIGN(PersonalDataManagerAndroid); 192 DISALLOW_COPY_AND_ASSIGN(PersonalDataManagerAndroid);
136 }; 193 };
137 194
138 } // namespace autofill 195 } // namespace autofill
139 196
140 #endif // CHROME_BROWSER_AUTOFILL_ANDROID_PERSONAL_DATA_MANAGER_ANDROID_H_ 197 #endif // CHROME_BROWSER_AUTOFILL_ANDROID_PERSONAL_DATA_MANAGER_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698