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

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

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

Powered by Google App Engine
This is Rietveld 408576698