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

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: Touch ups Created 3 years, 9 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 <map>
sebsg 2017/02/28 16:14:00 Needed?
Parastoo 2017/03/21 14:30:44 Not really. It was either suggested by git cl form
9 #include <memory>
10 #include <string>
11 #include <vector>
12
8 #include "base/android/jni_weak_ref.h" 13 #include "base/android/jni_weak_ref.h"
9 #include "base/android/scoped_java_ref.h" 14 #include "base/android/scoped_java_ref.h"
10 #include "base/macros.h" 15 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
12 #include "components/autofill/core/browser/personal_data_manager.h" 17 #include "components/autofill/core/browser/personal_data_manager.h"
13 #include "components/autofill/core/browser/personal_data_manager_observer.h" 18 #include "components/autofill/core/browser/personal_data_manager_observer.h"
14 #include "components/payments/address_normalizer.h" 19 #include "components/payments/address_normalizer.h"
20 #include "third_party/libaddressinput/chromium/chrome_address_validator.h"
15 21
16 namespace autofill { 22 namespace autofill {
17 23
18 // Android wrapper of the PersonalDataManager which provides access from the 24 // Android wrapper of the PersonalDataManager which provides access from the
19 // Java layer. Note that on Android, there's only a single profile, and 25 // Java layer. Note that on Android, there's only a single profile, and
20 // therefore a single instance of this wrapper. 26 // therefore a single instance of this wrapper.
21 class PersonalDataManagerAndroid : public PersonalDataManagerObserver { 27 class PersonalDataManagerAndroid
28 : public PersonalDataManagerObserver,
29 public LoadRulesListener,
30 public base::SupportsWeakPtr<PersonalDataManagerAndroid> {
22 public: 31 public:
32 // The interface for the sub-key request.
33 class Delegate {
34 public:
35 virtual void OnRulesSuccessfullyLoaded() = 0;
36 virtual ~Delegate() {}
37 };
38
23 PersonalDataManagerAndroid(JNIEnv* env, jobject obj); 39 PersonalDataManagerAndroid(JNIEnv* env, jobject obj);
24 40
25 // Returns true if personal data manager has loaded the initial data. 41 // Returns true if personal data manager has loaded the initial data.
26 jboolean IsDataLoaded( 42 jboolean IsDataLoaded(
27 JNIEnv* env, 43 JNIEnv* env,
28 const base::android::JavaParamRef<jobject>& unused_obj) const; 44 const base::android::JavaParamRef<jobject>& unused_obj) const;
29 45
30 // These functions act on "web profiles" aka "LOCAL_PROFILE" profiles. 46 // These functions act on "web profiles" aka "LOCAL_PROFILE" profiles.
31 // ------------------------- 47 // -------------------------
32 48
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 // more details see the comment header in time.h 293 // more details see the comment header in time.h
278 jlong GetCurrentDateForTesting( 294 jlong GetCurrentDateForTesting(
279 JNIEnv* env, 295 JNIEnv* env,
280 const base::android::JavaParamRef<jobject>& unused_obj); 296 const base::android::JavaParamRef<jobject>& unused_obj);
281 297
282 // These functions help address normalization. 298 // These functions help address normalization.
283 // -------------------- 299 // --------------------
284 300
285 // Starts loading the address validation rules for the specified 301 // Starts loading the address validation rules for the specified
286 // |region_code|. 302 // |region_code|.
287 void LoadRulesForRegion( 303 void LoadRulesForAddressNormalization(
288 JNIEnv* env, 304 JNIEnv* env,
289 const base::android::JavaParamRef<jobject>& unused_obj, 305 const base::android::JavaParamRef<jobject>& unused_obj,
290 const base::android::JavaParamRef<jstring>& region_code); 306 const base::android::JavaParamRef<jstring>& region_code);
307
308 // Starts loading the rules for the specified |region_code| for the further
309 // sub-key request.
310 void LoadRulesForSubKeys(
311 JNIEnv* env,
312 const base::android::JavaParamRef<jobject>& unused_obj,
313 const base::android::JavaParamRef<jstring>& region_code);
291 314
292 // Normalizes the address of the profile associated with the |jguid| 315 // Normalizes the address of the profile associated with the |jguid|
293 // synchronously if the |jregion_code| rules have finished loading. Otherwise 316 // synchronously if the |jregion_code| rules have finished loading. Otherwise
294 // sets up the task to start the address normalization when the rules have 317 // sets up the task to start the address normalization when the rules have
295 // finished loading. Also defines a time limit for the normalization, in which 318 // finished loading. Also defines a time limit for the normalization, in which
296 // case the the |jdelegate| will be notified. If the rules are loaded before 319 // case the the |jdelegate| will be notified. If the rules are loaded before
297 // the timeout, |jdelegate| will receive the normalized profile. 320 // the timeout, |jdelegate| will receive the normalized profile.
298 void StartAddressNormalization( 321 void StartAddressNormalization(
299 JNIEnv* env, 322 JNIEnv* env,
300 const base::android::JavaParamRef<jobject>& unused_obj, 323 const base::android::JavaParamRef<jobject>& unused_obj,
301 const base::android::JavaParamRef<jstring>& jguid, 324 const base::android::JavaParamRef<jstring>& jguid,
302 const base::android::JavaParamRef<jstring>& jregion_code, 325 const base::android::JavaParamRef<jstring>& jregion_code,
303 jint jtimeout_seconds, 326 jint jtimeout_seconds,
304 const base::android::JavaParamRef<jobject>& jdelegate); 327 const base::android::JavaParamRef<jobject>& jdelegate);
305 328
306 // Checks whether the Autofill PersonalDataManager has profiles. 329 // Checks whether the Autofill PersonalDataManager has profiles.
307 jboolean HasProfiles(JNIEnv* env, 330 jboolean HasProfiles(JNIEnv* env,
308 const base::android::JavaParamRef<jobject>& unused_obj); 331 const base::android::JavaParamRef<jobject>& unused_obj);
309 332
310 // Checks whether the Autofill PersonalDataManager has credit cards. 333 // Checks whether the Autofill PersonalDataManager has credit cards.
311 jboolean HasCreditCards( 334 jboolean HasCreditCards(
312 JNIEnv* env, 335 JNIEnv* env,
313 const base::android::JavaParamRef<jobject>& unused_obj); 336 const base::android::JavaParamRef<jobject>& unused_obj);
314 337
338 // Gets the sub-keys for the region with |jregion_code| code, if the
339 // |jregion_code| rules have finished loading. Otherwise, sets up a task to
340 // get the sub-keys, when the rules are loaded.
341 void StartGettingRegionSubKeys(
342 JNIEnv* env,
343 const base::android::JavaParamRef<jobject>& unused_obj,
344 const base::android::JavaParamRef<jstring>& jregion_code,
345 const base::android::JavaParamRef<jobject>& jdelegate);
346
347 // Gets the sub-keys of the rule associated with |jregion_code|. Should only
348 // be called when the rules are loaded.
349 base::android::ScopedJavaLocalRef<jobjectArray> GetSubKeys(
350 JNIEnv* env,
351 const std::string& jregion_code);
352
353 // Callback of the sub-keys request.
354 // This is called when the sub-keys are loaded.
355 void OnAddressRulesLoaded(const std::string& region_code,
356 bool success) override;
357
358 // Cancels the pending sub-key request task.
359 void CancelPendingGetSubKeys(
360 JNIEnv* env,
361 const base::android::JavaParamRef<jobject>& unused_obj);
362
315 private: 363 private:
316 ~PersonalDataManagerAndroid() override; 364 ~PersonalDataManagerAndroid() override;
317 365
318 // Returns the GUIDs of the |profiles| passed as parameter. 366 // Returns the GUIDs of the |profiles| passed as parameter.
319 base::android::ScopedJavaLocalRef<jobjectArray> GetProfileGUIDs( 367 base::android::ScopedJavaLocalRef<jobjectArray> GetProfileGUIDs(
320 JNIEnv* env, 368 JNIEnv* env,
321 const std::vector<AutofillProfile*>& profiles); 369 const std::vector<AutofillProfile*>& profiles);
322 370
323 // Returns the GUIDs of the |credit_cards| passed as parameter. 371 // Returns the GUIDs of the |credit_cards| passed as parameter.
324 base::android::ScopedJavaLocalRef<jobjectArray> GetCreditCardGUIDs( 372 base::android::ScopedJavaLocalRef<jobjectArray> GetCreditCardGUIDs(
(...skipping 30 matching lines...) Expand all
355 403
356 // Pointer to the java counterpart. 404 // Pointer to the java counterpart.
357 JavaObjectWeakGlobalRef weak_java_obj_; 405 JavaObjectWeakGlobalRef weak_java_obj_;
358 406
359 // Pointer to the PersonalDataManager for the main profile. 407 // Pointer to the PersonalDataManager for the main profile.
360 PersonalDataManager* personal_data_manager_; 408 PersonalDataManager* personal_data_manager_;
361 409
362 // The address validator used to normalize addresses. 410 // The address validator used to normalize addresses.
363 payments::AddressNormalizer address_normalizer_; 411 payments::AddressNormalizer address_normalizer_;
364 412
413 AddressValidator address_validator_;
sebsg 2017/02/28 16:14:00 Add comment that this is used for the sub keys.
Parastoo 2017/03/21 14:30:44 Done.
414
415 // Map associating a region code to pending sub-keys' request.
416 std::map<std::string, std::vector<std::unique_ptr<Delegate>>>
sebsg 2017/02/28 16:14:00 Like mentioned in another comment, maybe we can si
Parastoo 2017/03/21 14:30:44 Done.
417 pending_subkeys_request_;
418
365 DISALLOW_COPY_AND_ASSIGN(PersonalDataManagerAndroid); 419 DISALLOW_COPY_AND_ASSIGN(PersonalDataManagerAndroid);
366 }; 420 };
367 421
368 } // namespace autofill 422 } // namespace autofill
369 423
370 #endif // CHROME_BROWSER_AUTOFILL_ANDROID_PERSONAL_DATA_MANAGER_ANDROID_H_ 424 #endif // CHROME_BROWSER_AUTOFILL_ANDROID_PERSONAL_DATA_MANAGER_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698