Chromium Code Reviews| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 void 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, | 146 std::vector<Suggestion>* suggestions); |
|
Evan Stade
2014/12/10 23:11:14
can be a return value now instead of a series of o
| |
| 150 std::vector<base::string16>* labels, | |
| 151 std::vector<base::string16>* icons, | |
| 152 std::vector<GUIDPair>* guid_pairs); | |
| 153 | 147 |
| 154 // Gets credit cards that can suggest data for |type|. See | 148 // Gets credit cards that can suggest data for |type|. See |
| 155 // GetProfileSuggestions for argument descriptions. The variant in each | 149 // GetProfileSuggestions for argument descriptions. The variant in each |
| 156 // GUID pair should be ignored. | 150 // GUID pair should be ignored. |
| 157 void GetCreditCardSuggestions( | 151 void GetCreditCardSuggestions( |
| 158 const AutofillType& type, | 152 const AutofillType& type, |
| 159 const base::string16& field_contents, | 153 const base::string16& field_contents, |
| 160 std::vector<base::string16>* values, | 154 std::vector<Suggestion>* suggestions); |
| 161 std::vector<base::string16>* labels, | |
| 162 std::vector<base::string16>* icons, | |
| 163 std::vector<GUIDPair>* guid_pairs); | |
| 164 | 155 |
| 165 // Re-loads profiles and credit cards from the WebDatabase asynchronously. | 156 // 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 | 157 // 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 | 158 // 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 | 159 // 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 | 160 // engine processed a change from the cloud, we will learn of these as a |
| 170 // result of this call. | 161 // result of this call. |
| 171 // | 162 // |
| 172 // Also see SetProfile for more details. | 163 // Also see SetProfile for more details. |
| 173 virtual void Refresh(); | 164 virtual void Refresh(); |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 371 | 362 |
| 372 // An observer to listen for changes to prefs::kAutofillEnabled. | 363 // An observer to listen for changes to prefs::kAutofillEnabled. |
| 373 scoped_ptr<BooleanPrefMember> enabled_pref_; | 364 scoped_ptr<BooleanPrefMember> enabled_pref_; |
| 374 | 365 |
| 375 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); | 366 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); |
| 376 }; | 367 }; |
| 377 | 368 |
| 378 } // namespace autofill | 369 } // namespace autofill |
| 379 | 370 |
| 380 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ | 371 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ |
| OLD | NEW |