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. 4 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_ANDROID_AUXILIARY_PROFILE_LOADER_ANDROID_H_ 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_ANDROID_AUXILIARY_PROFILE_LOADER_ANDROID_H_ 7 8 #include <vector> 9 10 #include "base/android/jni_android.h" 11 #include "base/strings/string16.h" 12 13 namespace autofill { 14 15 bool RegisterAuxiliaryProfileLoader(JNIEnv* env); 16 17 // This class loads user's contact information from their device. 18 // The populated data corresponds to the user's 'Me' profile in their 19 // contact list. 20 class AuxiliaryProfileLoaderAndroid { 21 public: 22 AuxiliaryProfileLoaderAndroid(); 23 virtual ~AuxiliaryProfileLoaderAndroid(); 24 25 // Init method should be called after object initialization. 26 // context parameter is an Android context. 27 void Init(JNIEnv* env, const jobject& context); 28 29 // Returns true IFF the application has priviledges to access the user's 30 // contact information. 31 virtual bool GetHasPermissions() const; 32 // Returns address street. 33 virtual base::string16 GetStreet() const; 34 // Returns address post office box. 35 virtual base::string16 GetPostOfficeBox() const; 36 // Returns address neighborhood (e.g. Noe Valley, Nob Hill, Twin Peaks, ...). 37 virtual base::string16 GetNeighborhood() const; 38 // Returns address region such as state or province information 39 // (e.g. Ontario, California, Hubei). 40 virtual base::string16 GetRegion() const; 41 // Returns address city. 42 virtual base::string16 GetCity() const; 43 // Returns address postal code or zip code. 44 virtual base::string16 GetPostalCode() const; 45 // Returns address country. 46 virtual base::string16 GetCountry() const; 47 48 // Returns contact's first name. 49 virtual base::string16 GetFirstName() const; 50 // Returns contact's middle name. 51 virtual base::string16 GetMiddleName() const; 52 // Returns contact's last name. 53 virtual base::string16 GetLastName() const; 54 // Returns contact's suffix (e.g. Ph.D, M.D., ...). 55 virtual base::string16 GetSuffix() const; 56 57 // Populates string vector parameter with contact's email addresses. 58 virtual void GetEmailAddresses( 59 std::vector<base::string16>* email_addresses) const; 60 61 // Populates string vector parameter with contact's phones numbers. 62 virtual void GetPhoneNumbers( 63 std::vector<base::string16>* phone_numbers) const; 64 65 private: 66 JNIEnv* env_; 67 // The reference to java |PersonalAutofillPopulator| which 68 // actually extracts users contact information from the physical device 69 base::android::ScopedJavaLocalRef<jobject> populator_; 70 DISALLOW_COPY_AND_ASSIGN(AuxiliaryProfileLoaderAndroid); 71 }; 72 73 } // namespace 74 75 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_ANDROID_AUXILIARY_PROFILE_LOADER_ANDROID_H_ 76