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

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

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