| OLD | NEW |
| 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 COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ |
| 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ | 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
| 14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
| 15 #include "base/prefs/pref_member.h" | 15 #include "base/prefs/pref_member.h" |
| 16 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
| 17 #include "components/autofill/core/browser/autofill_metrics.h" | 17 #include "components/autofill/core/browser/autofill_metrics.h" |
| 18 #include "components/autofill/core/browser/autofill_profile.h" | 18 #include "components/autofill/core/browser/autofill_profile.h" |
| 19 #include "components/autofill/core/browser/credit_card.h" | 19 #include "components/autofill/core/browser/credit_card.h" |
| 20 #include "components/autofill/core/browser/field_types.h" | 20 #include "components/autofill/core/browser/field_types.h" |
| 21 #include "components/autofill/core/browser/suggestion.h" |
| 21 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 22 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
| 22 #include "components/autofill/core/browser/webdata/autofill_webdata_service_obse
rver.h" | 23 #include "components/autofill/core/browser/webdata/autofill_webdata_service_obse
rver.h" |
| 23 #include "components/keyed_service/core/keyed_service.h" | 24 #include "components/keyed_service/core/keyed_service.h" |
| 24 #include "components/webdata/common/web_data_service_consumer.h" | 25 #include "components/webdata/common/web_data_service_consumer.h" |
| 25 | 26 |
| 26 class PrefService; | 27 class PrefService; |
| 27 class RemoveAutofillTester; | 28 class RemoveAutofillTester; |
| 28 | 29 |
| 29 namespace autofill { | 30 namespace autofill { |
| 30 class AutofillInteractiveTest; | 31 class AutofillInteractiveTest; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 41 | 42 |
| 42 namespace autofill { | 43 namespace autofill { |
| 43 | 44 |
| 44 // Handles loading and saving Autofill profile information to the web database. | 45 // Handles loading and saving Autofill profile information to the web database. |
| 45 // This class also stores the profiles loaded from the database for use during | 46 // This class also stores the profiles loaded from the database for use during |
| 46 // Autofill. | 47 // Autofill. |
| 47 class PersonalDataManager : public KeyedService, | 48 class PersonalDataManager : public KeyedService, |
| 48 public WebDataServiceConsumer, | 49 public WebDataServiceConsumer, |
| 49 public AutofillWebDataServiceObserverOnUIThread { | 50 public AutofillWebDataServiceObserverOnUIThread { |
| 50 public: | 51 public: |
| 51 // A pair of GUID and variant index. Represents a single FormGroup and a | |
| 52 // specific data variant. | |
| 53 typedef std::pair<std::string, size_t> GUIDPair; | |
| 54 | |
| 55 explicit PersonalDataManager(const std::string& app_locale); | 52 explicit PersonalDataManager(const std::string& app_locale); |
| 56 ~PersonalDataManager() override; | 53 ~PersonalDataManager() override; |
| 57 | 54 |
| 58 // Kicks off asynchronous loading of profiles and credit cards. | 55 // Kicks off asynchronous loading of profiles and credit cards. |
| 59 // |pref_service| must outlive this instance. |is_off_the_record| informs | 56 // |pref_service| must outlive this instance. |is_off_the_record| informs |
| 60 // this instance whether the user is currently operating in an off-the-record | 57 // this instance whether the user is currently operating in an off-the-record |
| 61 // context. | 58 // context. |
| 62 void Init(scoped_refptr<AutofillWebDataService> database, | 59 void Init(scoped_refptr<AutofillWebDataService> database, |
| 63 PrefService* pref_service, | 60 PrefService* pref_service, |
| 64 bool is_off_the_record); | 61 bool is_off_the_record); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 // auxiliary profiles. |web_profiles()| returns only web profiles. | 130 // auxiliary profiles. |web_profiles()| returns only web profiles. |
| 134 virtual const std::vector<AutofillProfile*>& GetProfiles() const; | 131 virtual const std::vector<AutofillProfile*>& GetProfiles() const; |
| 135 virtual const std::vector<AutofillProfile*>& web_profiles() const; | 132 virtual const std::vector<AutofillProfile*>& web_profiles() const; |
| 136 virtual const std::vector<CreditCard*>& GetCreditCards() const; | 133 virtual const std::vector<CreditCard*>& GetCreditCards() const; |
| 137 | 134 |
| 138 // Loads profiles that can suggest data for |type|. |field_contents| is the | 135 // Loads profiles that can suggest data for |type|. |field_contents| is the |
| 139 // part the user has already typed. |field_is_autofilled| is true if the field | 136 // part the user has already typed. |field_is_autofilled| is true if the field |
| 140 // has already been autofilled. |other_field_types| represents the rest of | 137 // has already been autofilled. |other_field_types| represents the rest of |
| 141 // form. |filter| is run on each potential suggestion. If |filter| returns | 138 // form. |filter| is run on each potential suggestion. If |filter| returns |
| 142 // true, the profile added to the last four outparams (else it's omitted). | 139 // true, the profile added to the last four outparams (else it's omitted). |
| 143 void GetProfileSuggestions( | 140 std::vector<Suggestion> GetProfileSuggestions( |
| 144 const AutofillType& type, | 141 const AutofillType& type, |
| 145 const base::string16& field_contents, | 142 const base::string16& field_contents, |
| 146 bool field_is_autofilled, | 143 bool field_is_autofilled, |
| 147 const std::vector<ServerFieldType>& other_field_types, | 144 const std::vector<ServerFieldType>& other_field_types, |
| 148 const base::Callback<bool(const AutofillProfile&)>& filter, | 145 const base::Callback<bool(const AutofillProfile&)>& filter); |
| 149 std::vector<base::string16>* values, | |
| 150 std::vector<base::string16>* labels, | |
| 151 std::vector<base::string16>* icons, | |
| 152 std::vector<GUIDPair>* guid_pairs); | |
| 153 | 146 |
| 154 // Gets credit cards that can suggest data for |type|. See | 147 // Gets credit cards that can suggest data for |type|. See |
| 155 // GetProfileSuggestions for argument descriptions. The variant in each | 148 // GetProfileSuggestions for argument descriptions. The variant in each |
| 156 // GUID pair should be ignored. | 149 // GUID pair should be ignored. |
| 157 void GetCreditCardSuggestions( | 150 std::vector<Suggestion> GetCreditCardSuggestions( |
| 158 const AutofillType& type, | 151 const AutofillType& type, |
| 159 const base::string16& field_contents, | 152 const base::string16& field_contents); |
| 160 std::vector<base::string16>* values, | |
| 161 std::vector<base::string16>* labels, | |
| 162 std::vector<base::string16>* icons, | |
| 163 std::vector<GUIDPair>* guid_pairs); | |
| 164 | 153 |
| 165 // Re-loads profiles and credit cards from the WebDatabase asynchronously. | 154 // Re-loads profiles and credit cards from the WebDatabase asynchronously. |
| 166 // In the general case, this is a no-op and will re-create the same | 155 // In the general case, this is a no-op and will re-create the same |
| 167 // in-memory model as existed prior to the call. If any change occurred to | 156 // in-memory model as existed prior to the call. If any change occurred to |
| 168 // profiles in the WebDatabase directly, as is the case if the browser sync | 157 // profiles in the WebDatabase directly, as is the case if the browser sync |
| 169 // engine processed a change from the cloud, we will learn of these as a | 158 // engine processed a change from the cloud, we will learn of these as a |
| 170 // result of this call. | 159 // result of this call. |
| 171 // | 160 // |
| 172 // Also see SetProfile for more details. | 161 // Also see SetProfile for more details. |
| 173 virtual void Refresh(); | 162 virtual void Refresh(); |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 | 360 |
| 372 // An observer to listen for changes to prefs::kAutofillEnabled. | 361 // An observer to listen for changes to prefs::kAutofillEnabled. |
| 373 scoped_ptr<BooleanPrefMember> enabled_pref_; | 362 scoped_ptr<BooleanPrefMember> enabled_pref_; |
| 374 | 363 |
| 375 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); | 364 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); |
| 376 }; | 365 }; |
| 377 | 366 |
| 378 } // namespace autofill | 367 } // namespace autofill |
| 379 | 368 |
| 380 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ | 369 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ |
| OLD | NEW |