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

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

Issue 2680143002: Use dropdown list for admin areas in pr form. (Closed)
Patch Set: Another one with addressing Math's comments. Created 3 years, 8 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 "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "components/autofill/core/browser/personal_data_manager.h" 12 #include "components/autofill/core/browser/personal_data_manager.h"
13 #include "components/autofill/core/browser/personal_data_manager_observer.h" 13 #include "components/autofill/core/browser/personal_data_manager_observer.h"
14 #include "components/payments/core/address_normalizer.h" 14 #include "components/payments/core/address_normalizer.h"
15 #include "third_party/libaddressinput/chromium/chrome_address_validator.h"
15 16
16 namespace autofill { 17 namespace autofill {
17 18
18 // Android wrapper of the PersonalDataManager which provides access from the 19 // Android wrapper of the PersonalDataManager which provides access from the
19 // Java layer. Note that on Android, there's only a single profile, and 20 // Java layer. Note that on Android, there's only a single profile, and
20 // therefore a single instance of this wrapper. 21 // therefore a single instance of this wrapper.
21 class PersonalDataManagerAndroid : public PersonalDataManagerObserver { 22 class PersonalDataManagerAndroid
23 : public PersonalDataManagerObserver,
24 public LoadRulesListener,
25 public base::SupportsWeakPtr<PersonalDataManagerAndroid> {
22 public: 26 public:
23 // Registers the JNI bindings for this class. 27 // Registers the JNI bindings for this class.
24 static bool Register(JNIEnv* env); 28 static bool Register(JNIEnv* env);
29 // The interface for the sub-key request.
30 class SubKeyRequestDelegate {
31 public:
32 virtual void OnRulesSuccessfullyLoaded() = 0;
33 virtual ~SubKeyRequestDelegate() {}
34 };
please use gerrit instead 2017/03/30 18:48:58 Let's put the interface first in the class (before
Parastoo 2017/03/31 15:44:14 Done.
25 35
26 PersonalDataManagerAndroid(JNIEnv* env, jobject obj); 36 PersonalDataManagerAndroid(JNIEnv* env, jobject obj);
27 37
28 // Returns true if personal data manager has loaded the initial data. 38 // Returns true if personal data manager has loaded the initial data.
29 jboolean IsDataLoaded( 39 jboolean IsDataLoaded(
30 JNIEnv* env, 40 JNIEnv* env,
31 const base::android::JavaParamRef<jobject>& unused_obj) const; 41 const base::android::JavaParamRef<jobject>& unused_obj) const;
32 42
33 // These functions act on "web profiles" aka "LOCAL_PROFILE" profiles. 43 // These functions act on "web profiles" aka "LOCAL_PROFILE" profiles.
34 // ------------------------- 44 // -------------------------
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 // more details see the comment header in time.h 287 // more details see the comment header in time.h
278 jlong GetCurrentDateForTesting( 288 jlong GetCurrentDateForTesting(
279 JNIEnv* env, 289 JNIEnv* env,
280 const base::android::JavaParamRef<jobject>& unused_obj); 290 const base::android::JavaParamRef<jobject>& unused_obj);
281 291
282 // These functions help address normalization. 292 // These functions help address normalization.
283 // -------------------- 293 // --------------------
284 294
285 // Starts loading the address validation rules for the specified 295 // Starts loading the address validation rules for the specified
286 // |region_code|. 296 // |region_code|.
287 void LoadRulesForRegion( 297 void LoadRulesForAddressNormalization(
288 JNIEnv* env, 298 JNIEnv* env,
289 const base::android::JavaParamRef<jobject>& unused_obj, 299 const base::android::JavaParamRef<jobject>& unused_obj,
290 const base::android::JavaParamRef<jstring>& region_code); 300 const base::android::JavaParamRef<jstring>& region_code);
301
302 // Starts loading the rules for the specified |region_code| for the further
303 // sub-key request.
304 void LoadRulesForSubKeys(
305 JNIEnv* env,
306 const base::android::JavaParamRef<jobject>& unused_obj,
307 const base::android::JavaParamRef<jstring>& region_code);
291 308
292 // Normalizes the address of the |jprofile| synchronously if the 309 // Normalizes the address of the |jprofile| synchronously if the
293 // |jregion_code| rules have finished loading. Otherwise sets up the task to 310 // |jregion_code| rules have finished loading. Otherwise sets up the task to
294 // start the address normalization when the rules have finished loading. Also 311 // start the address normalization when the rules have finished loading. Also
295 // defines a time limit for the normalization, in which case the the 312 // defines a time limit for the normalization, in which case the the
296 // |jdelegate| will be notified. If the rules are loaded before the timeout, 313 // |jdelegate| will be notified. If the rules are loaded before the timeout,
297 // |jdelegate| will receive the normalized profile. 314 // |jdelegate| will receive the normalized profile.
298 void StartAddressNormalization( 315 void StartAddressNormalization(
299 JNIEnv* env, 316 JNIEnv* env,
300 const base::android::JavaParamRef<jobject>& unused_obj, 317 const base::android::JavaParamRef<jobject>& unused_obj,
301 const base::android::JavaParamRef<jobject>& jprofile, 318 const base::android::JavaParamRef<jobject>& jprofile,
302 const base::android::JavaParamRef<jstring>& jregion_code, 319 const base::android::JavaParamRef<jstring>& jregion_code,
303 jint jtimeout_seconds, 320 jint jtimeout_seconds,
304 const base::android::JavaParamRef<jobject>& jdelegate); 321 const base::android::JavaParamRef<jobject>& jdelegate);
305 322
306 // Checks whether the Autofill PersonalDataManager has profiles. 323 // Checks whether the Autofill PersonalDataManager has profiles.
307 jboolean HasProfiles(JNIEnv* env, 324 jboolean HasProfiles(JNIEnv* env,
308 const base::android::JavaParamRef<jobject>& unused_obj); 325 const base::android::JavaParamRef<jobject>& unused_obj);
309 326
310 // Checks whether the Autofill PersonalDataManager has credit cards. 327 // Checks whether the Autofill PersonalDataManager has credit cards.
311 jboolean HasCreditCards( 328 jboolean HasCreditCards(
312 JNIEnv* env, 329 JNIEnv* env,
313 const base::android::JavaParamRef<jobject>& unused_obj); 330 const base::android::JavaParamRef<jobject>& unused_obj);
314 331
332 // Gets the sub-keys for the region with |jregion_code| code, if the
333 // |jregion_code| rules have finished loading. Otherwise, sets up a task to
334 // get the sub-keys, when the rules are loaded.
335 void StartRegionSubKeysRequest(
336 JNIEnv* env,
337 const base::android::JavaParamRef<jobject>& unused_obj,
338 const base::android::JavaParamRef<jstring>& jregion_code,
339 const base::android::JavaParamRef<jobject>& jdelegate);
340
341 // Gets the sub-keys of the rule associated with |jregion_code|. Should only
342 // be called when the rules are loaded.
343 base::android::ScopedJavaLocalRef<jobjectArray> GetSubKeys(
344 JNIEnv* env,
345 const std::string& jregion_code);
346
347 // Callback of the sub-keys request.
348 // This is called when the sub-keys are loaded.
349 void OnAddressRulesLoaded(const std::string& region_code,
350 bool success) override;
351
352 // Cancels the pending sub-key request task.
353 void CancelPendingGetSubKeys(
354 JNIEnv* env,
355 const base::android::JavaParamRef<jobject>& unused_obj);
356
315 private: 357 private:
316 ~PersonalDataManagerAndroid() override; 358 ~PersonalDataManagerAndroid() override;
317 359
318 // Returns the GUIDs of the |profiles| passed as parameter. 360 // Returns the GUIDs of the |profiles| passed as parameter.
319 base::android::ScopedJavaLocalRef<jobjectArray> GetProfileGUIDs( 361 base::android::ScopedJavaLocalRef<jobjectArray> GetProfileGUIDs(
320 JNIEnv* env, 362 JNIEnv* env,
321 const std::vector<AutofillProfile*>& profiles); 363 const std::vector<AutofillProfile*>& profiles);
322 364
323 // Returns the GUIDs of the |credit_cards| passed as parameter. 365 // Returns the GUIDs of the |credit_cards| passed as parameter.
324 base::android::ScopedJavaLocalRef<jobjectArray> GetCreditCardGUIDs( 366 base::android::ScopedJavaLocalRef<jobjectArray> GetCreditCardGUIDs(
(...skipping 27 matching lines...) Expand all
352 JNIEnv* env, 394 JNIEnv* env,
353 const base::android::JavaParamRef<jobject>& jprofile, 395 const base::android::JavaParamRef<jobject>& jprofile,
354 bool inlude_country_in_label); 396 bool inlude_country_in_label);
355 397
356 // Pointer to the java counterpart. 398 // Pointer to the java counterpart.
357 JavaObjectWeakGlobalRef weak_java_obj_; 399 JavaObjectWeakGlobalRef weak_java_obj_;
358 400
359 // Pointer to the PersonalDataManager for the main profile. 401 // Pointer to the PersonalDataManager for the main profile.
360 PersonalDataManager* personal_data_manager_; 402 PersonalDataManager* personal_data_manager_;
361 403
362 // The address validator used to normalize addresses. 404 // The address validator used to normalize address.
363 payments::AddressNormalizer address_normalizer_; 405 payments::AddressNormalizer address_normalizer_;
please use gerrit instead 2017/03/30 18:48:58 payments::AddressNormalizer has an AddressValidato
Parastoo 2017/03/31 15:44:14 In the next CL (that is almost done), all these co
please use gerrit instead 2017/03/31 16:06:20 I'm fairly certain that disk storage will be share
Parastoo 2017/04/03 16:18:23 Acknowledged.
364 406
407 // The address validator used for sub key request.
408 AddressValidator address_validator_;
409
410 // The region code and the request for the pending sub-key request.
411 std::unique_ptr<SubKeyRequestDelegate> pending_subkey_request_;
412 std::string pending_subkey_region_code_;
413
365 DISALLOW_COPY_AND_ASSIGN(PersonalDataManagerAndroid); 414 DISALLOW_COPY_AND_ASSIGN(PersonalDataManagerAndroid);
366 }; 415 };
367 416
368 } // namespace autofill 417 } // namespace autofill
369 418
370 #endif // CHROME_BROWSER_AUTOFILL_ANDROID_PERSONAL_DATA_MANAGER_ANDROID_H_ 419 #endif // CHROME_BROWSER_AUTOFILL_ANDROID_PERSONAL_DATA_MANAGER_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698