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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_AUTOFILL_ANDROID_PERSONAL_DATA_MANAGER_ANDROID_H_
6 #define CHROME_BROWSER_AUTOFILL_ANDROID_PERSONAL_DATA_MANAGER_ANDROID_H_
8 #include "base/android/jni_weak_ref.h"
9 #include "base/android/scoped_java_ref.h"
10 #include "components/autofill/core/browser/personal_data_manager.h"
11 #include "components/autofill/core/browser/personal_data_manager_observer.h"
15 // Android wrapper of the PersonalDataManager which provides access from the
16 // Java layer. Note that on Android, there's only a single profile, and
17 // therefore a single instance of this wrapper.
18 class PersonalDataManagerAndroid : public PersonalDataManagerObserver {
20 PersonalDataManagerAndroid(JNIEnv* env, jobject obj);
22 // Regular Autofill Profiles
23 // -------------------------
25 // Returns the number of web and auxiliary profiles.
26 jint GetProfileCount(JNIEnv* unused_env, jobject unused_obj);
28 // Returns the profile as indexed by |index| in the PersonalDataManager's
29 // |GetProfiles()| collection.
30 base::android::ScopedJavaLocalRef<jobject> GetProfileByIndex(
35 // Returns the profile with the specified |jguid|, or NULL if there is no
36 // profile with the specified |jguid|. Both web and auxiliary profiles may
38 base::android::ScopedJavaLocalRef<jobject> GetProfileByGUID(
43 // Adds or modifies a profile. If |jguid| is an empty string, we are creating
44 // a new profile. Else we are updating an existing profile. Always returns
45 // the GUID for this profile; the GUID it may have just been created.
46 base::android::ScopedJavaLocalRef<jstring> SetProfile(JNIEnv* env,
50 // Credit Card Profiles
51 // --------------------
53 // Returns the number of credit cards.
54 jint GetCreditCardCount(JNIEnv* unused_env, jobject unused_obj);
56 // Returns the credit card as indexed by |index| in the PersonalDataManager's
57 // |GetCreditCards()| collection.
58 base::android::ScopedJavaLocalRef<jobject> GetCreditCardByIndex(
63 // Returns the credit card with the specified |jguid|, or NULL if there is
64 // no credit card with the specified |jguid|.
65 base::android::ScopedJavaLocalRef<jobject> GetCreditCardByGUID(
70 // Adds or modifies a credit card. If |jguid| is an empty string, we are
71 // creating a new profile. Else we are updating an existing profile. Always
72 // returns the GUID for this profile; the GUID it may have just been created.
73 base::android::ScopedJavaLocalRef<jstring> SetCreditCard(
78 // Gets the labels for all known profiles. These labels are useful for
79 // distinguishing the profiles from one another.
80 base::android::ScopedJavaLocalRef<jobjectArray> GetProfileLabels(
84 // Removes the profile or credit card represented by |jguid|.
85 void RemoveByGUID(JNIEnv* env, jobject unused_obj, jstring jguid);
87 // PersonalDataManagerObserver:
88 virtual void OnPersonalDataChanged() OVERRIDE;
90 // Registers the JNI bindings for this class.
91 static bool Register(JNIEnv* env);
94 virtual ~PersonalDataManagerAndroid();
96 // Pointer to the java counterpart.
97 JavaObjectWeakGlobalRef weak_java_obj_;
99 // Pointer to the PersonalDataManager for the main profile.
100 PersonalDataManager* personal_data_manager_;
102 DISALLOW_COPY_AND_ASSIGN(PersonalDataManagerAndroid);
105 } // namespace autofill
107 #endif // CHROME_BROWSER_AUTOFILL_ANDROID_PERSONAL_DATA_MANAGER_ANDROID_H_