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

Side by Side Diff: components/autofill/browser/personal_data_manager.h

Issue 13488009: Remove application locale cache in autofill code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync Created 7 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_BROWSER_PERSONAL_DATA_MANAGER_H_ 5 #ifndef COMPONENTS_AUTOFILL_BROWSER_PERSONAL_DATA_MANAGER_H_
6 #define COMPONENTS_AUTOFILL_BROWSER_PERSONAL_DATA_MANAGER_H_ 6 #define COMPONENTS_AUTOFILL_BROWSER_PERSONAL_DATA_MANAGER_H_
7 7
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 24 matching lines...) Expand all
35 // Handles loading and saving Autofill profile information to the web database. 35 // Handles loading and saving Autofill profile information to the web database.
36 // This class also stores the profiles loaded from the database for use during 36 // This class also stores the profiles loaded from the database for use during
37 // Autofill. 37 // Autofill.
38 class PersonalDataManager : public WebDataServiceConsumer, 38 class PersonalDataManager : public WebDataServiceConsumer,
39 public AutofillWebDataServiceObserverOnUIThread { 39 public AutofillWebDataServiceObserverOnUIThread {
40 public: 40 public:
41 // A pair of GUID and variant index. Represents a single FormGroup and a 41 // A pair of GUID and variant index. Represents a single FormGroup and a
42 // specific data variant. 42 // specific data variant.
43 typedef std::pair<std::string, size_t> GUIDPair; 43 typedef std::pair<std::string, size_t> GUIDPair;
44 44
45 PersonalDataManager(); 45 explicit PersonalDataManager(const std::string& app_locale);
46 virtual ~PersonalDataManager(); 46 virtual ~PersonalDataManager();
47 47
48 // Kicks off asynchronous loading of profiles and credit cards. 48 // Kicks off asynchronous loading of profiles and credit cards.
49 void Init(content::BrowserContext* context); 49 void Init(content::BrowserContext* context);
50 50
51 // WebDataServiceConsumer: 51 // WebDataServiceConsumer:
52 virtual void OnWebDataServiceRequestDone( 52 virtual void OnWebDataServiceRequestDone(
53 WebDataServiceBase::Handle h, 53 WebDataServiceBase::Handle h,
54 const WDTypedResult* result) OVERRIDE; 54 const WDTypedResult* result) OVERRIDE;
55 55
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // Re-loads profiles and credit cards from the WebDatabase asynchronously. 145 // Re-loads profiles and credit cards from the WebDatabase asynchronously.
146 // In the general case, this is a no-op and will re-create the same 146 // In the general case, this is a no-op and will re-create the same
147 // in-memory model as existed prior to the call. If any change occurred to 147 // in-memory model as existed prior to the call. If any change occurred to
148 // profiles in the WebDatabase directly, as is the case if the browser sync 148 // profiles in the WebDatabase directly, as is the case if the browser sync
149 // engine processed a change from the cloud, we will learn of these as a 149 // engine processed a change from the cloud, we will learn of these as a
150 // result of this call. 150 // result of this call.
151 // 151 //
152 // Also see SetProfile for more details. 152 // Also see SetProfile for more details.
153 virtual void Refresh(); 153 virtual void Refresh();
154 154
155 const std::string& app_locale() const { return app_locale_; }
156
155 // Checks suitability of |profile| for adding to the user's set of profiles. 157 // Checks suitability of |profile| for adding to the user's set of profiles.
156 static bool IsValidLearnableProfile(const AutofillProfile& profile); 158 static bool IsValidLearnableProfile(const AutofillProfile& profile,
159 const std::string& app_locale);
157 160
158 // Merges |profile| into one of the |existing_profiles| if possible; otherwise 161 // Merges |profile| into one of the |existing_profiles| if possible; otherwise
159 // appends |profile| to the end of that list. Fills |merged_profiles| with the 162 // appends |profile| to the end of that list. Fills |merged_profiles| with the
160 // result. 163 // result.
161 static bool MergeProfile( 164 static bool MergeProfile(
162 const AutofillProfile& profile, 165 const AutofillProfile& profile,
163 const std::vector<AutofillProfile*>& existing_profiles, 166 const std::vector<AutofillProfile*>& existing_profiles,
167 const std::string& app_locale,
164 std::vector<AutofillProfile>* merged_profiles); 168 std::vector<AutofillProfile>* merged_profiles);
165 169
166 protected: 170 protected:
167 // Only PersonalDataManagerFactory and certain tests can create instances of 171 // Only PersonalDataManagerFactory and certain tests can create instances of
168 // PersonalDataManager. 172 // PersonalDataManager.
169 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FirstMiddleLast); 173 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FirstMiddleLast);
170 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AutofillIsEnabledAtStartup); 174 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AutofillIsEnabledAtStartup);
171 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, 175 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest,
172 AggregateExistingAuxiliaryProfile); 176 AggregateExistingAuxiliaryProfile);
173 friend class AutofillTest; 177 friend class AutofillTest;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 // is queried on another thread, we record the query handle until we 258 // is queried on another thread, we record the query handle until we
255 // get called back. We store handles for both profile and credit card queries 259 // get called back. We store handles for both profile and credit card queries
256 // so they can be loaded at the same time. 260 // so they can be loaded at the same time.
257 WebDataServiceBase::Handle pending_profiles_query_; 261 WebDataServiceBase::Handle pending_profiles_query_;
258 WebDataServiceBase::Handle pending_creditcards_query_; 262 WebDataServiceBase::Handle pending_creditcards_query_;
259 263
260 // The observers. 264 // The observers.
261 ObserverList<PersonalDataManagerObserver> observers_; 265 ObserverList<PersonalDataManagerObserver> observers_;
262 266
263 private: 267 private:
268 std::string app_locale_;
264 269
265 // For logging UMA metrics. Overridden by metrics tests. 270 // For logging UMA metrics. Overridden by metrics tests.
266 scoped_ptr<const AutofillMetrics> metric_logger_; 271 scoped_ptr<const AutofillMetrics> metric_logger_;
267 272
268 // Whether we have already logged the number of profiles this session. 273 // Whether we have already logged the number of profiles this session.
269 mutable bool has_logged_profile_count_; 274 mutable bool has_logged_profile_count_;
270 275
271 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); 276 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager);
272 }; 277 };
273 278
274 #endif // COMPONENTS_AUTOFILL_BROWSER_PERSONAL_DATA_MANAGER_H_ 279 #endif // COMPONENTS_AUTOFILL_BROWSER_PERSONAL_DATA_MANAGER_H_
OLDNEW
« no previous file with comments | « components/autofill/browser/form_group.cc ('k') | components/autofill/browser/personal_data_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698