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

Side by Side Diff: chrome/browser/webdata/web_data_service.h

Issue 12987023: Rip autofill code out of webdataservice (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change method name in AutofillTable 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 // Chromium settings and storage represent user-selected preferences and 5 // Chromium settings and storage represent user-selected preferences and
6 // information and MUST not be extracted, overwritten or modified except 6 // information and MUST not be extracted, overwritten or modified except
7 // through Chromium defined APIs. 7 // through Chromium defined APIs.
8 8
9 #ifndef CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__ 9 #ifndef CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__
10 #define CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__ 10 #define CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__
11 11
12 #include <map> 12 #include <map>
13 #include <string> 13 #include <string>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/callback_forward.h" 16 #include "base/callback_forward.h"
17 #include "base/files/file_path.h" 17 #include "base/files/file_path.h"
18 #include "base/location.h" 18 #include "base/location.h"
19 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
20 #include "base/sequenced_task_runner_helpers.h" 20 #include "base/sequenced_task_runner_helpers.h"
21 #include "chrome/browser/api/webdata/autofill_web_data_service.h"
22 #include "chrome/browser/api/webdata/web_data_results.h" 21 #include "chrome/browser/api/webdata/web_data_results.h"
23 #include "chrome/browser/api/webdata/web_data_service_base.h" 22 #include "chrome/browser/api/webdata/web_data_service_base.h"
24 #include "chrome/browser/api/webdata/web_data_service_consumer.h" 23 #include "chrome/browser/api/webdata/web_data_service_consumer.h"
25 #include "chrome/browser/search_engines/template_url.h" 24 #include "chrome/browser/search_engines/template_url.h"
26 #include "chrome/browser/search_engines/template_url_id.h" 25 #include "chrome/browser/search_engines/template_url_id.h"
27 #include "chrome/browser/webdata/keyword_table.h" 26 #include "chrome/browser/webdata/keyword_table.h"
28 #include "chrome/browser/webdata/web_database.h" 27 #include "chrome/browser/webdata/web_database.h"
29 28
30 class AutocompleteSyncableService;
31 class AutofillChange;
32 class AutofillProfileSyncableService;
33 struct DefaultWebIntentService; 29 struct DefaultWebIntentService;
34 class GURL; 30 class GURL;
35 #if defined(OS_WIN) 31 #if defined(OS_WIN)
36 struct IE7PasswordInfo; 32 struct IE7PasswordInfo;
37 #endif 33 #endif
38 class MessageLoop; 34 class MessageLoop;
39 class Profile; 35 class Profile;
40 class SkBitmap; 36 class SkBitmap;
41 class WebDatabaseService; 37 class WebDatabaseService;
42 38
(...skipping 18 matching lines...) Expand all
61 // 57 //
62 //////////////////////////////////////////////////////////////////////////////// 58 ////////////////////////////////////////////////////////////////////////////////
63 59
64 60
65 //////////////////////////////////////////////////////////////////////////////// 61 ////////////////////////////////////////////////////////////////////////////////
66 // 62 //
67 // WebDataService results 63 // WebDataService results
68 // 64 //
69 //////////////////////////////////////////////////////////////////////////////// 65 ////////////////////////////////////////////////////////////////////////////////
70 66
71 typedef std::vector<AutofillChange> AutofillChangeList;
72
73 typedef base::Callback<scoped_ptr<WDTypedResult>(void)> ResultTask; 67 typedef base::Callback<scoped_ptr<WDTypedResult>(void)> ResultTask;
74 68
75 // Result from GetWebAppImages. 69 // Result from GetWebAppImages.
76 struct WDAppImagesResult { 70 struct WDAppImagesResult {
77 WDAppImagesResult(); 71 WDAppImagesResult();
78 ~WDAppImagesResult(); 72 ~WDAppImagesResult();
79 73
80 // True if SetWebAppHasAllImages(true) was invoked. 74 // True if SetWebAppHasAllImages(true) was invoked.
81 bool has_all_images; 75 bool has_all_images;
82 76
83 // The images, may be empty. 77 // The images, may be empty.
84 std::vector<SkBitmap> images; 78 std::vector<SkBitmap> images;
85 }; 79 };
86 80
87 struct WDKeywordsResult { 81 struct WDKeywordsResult {
88 WDKeywordsResult(); 82 WDKeywordsResult();
89 ~WDKeywordsResult(); 83 ~WDKeywordsResult();
90 84
91 KeywordTable::Keywords keywords; 85 KeywordTable::Keywords keywords;
92 // Identifies the ID of the TemplateURL that is the default search. A value of 86 // Identifies the ID of the TemplateURL that is the default search. A value of
93 // 0 indicates there is no default search provider. 87 // 0 indicates there is no default search provider.
94 int64 default_search_provider_id; 88 int64 default_search_provider_id;
95 // Version of the built-in keywords. A value of 0 indicates a first run. 89 // Version of the built-in keywords. A value of 0 indicates a first run.
96 int builtin_keyword_version; 90 int builtin_keyword_version;
97 }; 91 };
98 92
99 class WebDataServiceConsumer; 93 class WebDataServiceConsumer;
100 94
101 class WebDataService 95 class WebDataService : public WebDataServiceBase {
102 : public WebDataServiceBase,
103 public AutofillWebData {
104 public: 96 public:
105 // Retrieve a WebDataService for the given context. 97 // Retrieve a WebDataService for the given context.
106 static scoped_refptr<WebDataService> FromBrowserContext( 98 static scoped_refptr<WebDataService> FromBrowserContext(
107 content::BrowserContext* context); 99 content::BrowserContext* context);
108 100
109 WebDataService(scoped_refptr<WebDatabaseService> wdbs, 101 WebDataService(scoped_refptr<WebDatabaseService> wdbs,
110 const ProfileErrorCallback& callback); 102 const ProfileErrorCallback& callback);
111 103
112 // Notifies listeners on the UI thread that multiple changes have been made to
113 // to Autofill records of the database.
114 // NOTE: This method is intended to be called from the DB thread. It
115 // it asynchronously notifies listeners on the UI thread.
116 // |web_data_service| may be NULL for testing purposes.
117 static void NotifyOfMultipleAutofillChanges(WebDataService* web_data_service);
118
119 ////////////////////////////////////////////////////////////////////////////// 104 //////////////////////////////////////////////////////////////////////////////
120 // 105 //
121 // Keywords 106 // Keywords
122 // 107 //
123 ////////////////////////////////////////////////////////////////////////////// 108 //////////////////////////////////////////////////////////////////////////////
124 109
125 // As the database processes requests at a later date, all deletion is 110 // As the database processes requests at a later date, all deletion is
126 // done on the background thread. 111 // done on the background thread.
127 // 112 //
128 // Many of the keyword related methods do not return a handle. This is because 113 // Many of the keyword related methods do not return a handle. This is because
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 void RemoveIE7Login(const IE7PasswordInfo& info); 226 void RemoveIE7Login(const IE7PasswordInfo& info);
242 227
243 // Get the login matching the information in |info|. |consumer| will be 228 // Get the login matching the information in |info|. |consumer| will be
244 // notified when the request is done. The result is of type 229 // notified when the request is done. The result is of type
245 // WDResult<IE7PasswordInfo>. 230 // WDResult<IE7PasswordInfo>.
246 // If there is no match, the fields of the IE7PasswordInfo will be empty. 231 // If there is no match, the fields of the IE7PasswordInfo will be empty.
247 Handle GetIE7Login(const IE7PasswordInfo& info, 232 Handle GetIE7Login(const IE7PasswordInfo& info,
248 WebDataServiceConsumer* consumer); 233 WebDataServiceConsumer* consumer);
249 #endif // defined(OS_WIN) 234 #endif // defined(OS_WIN)
250 235
251 //////////////////////////////////////////////////////////////////////////////
252 //
253 // Autofill.
254 //
255 //////////////////////////////////////////////////////////////////////////////
256
257 // AutofillWebData implementation.
258 virtual void AddFormFields(
259 const std::vector<FormFieldData>& fields) OVERRIDE;
260 virtual Handle GetFormValuesForElementName(
261 const string16& name,
262 const string16& prefix,
263 int limit,
264 WebDataServiceConsumer* consumer) OVERRIDE;
265 virtual void RemoveExpiredFormElements() OVERRIDE;
266 virtual void RemoveFormValueForElementName(const string16& name,
267 const string16& value) OVERRIDE;
268 virtual void AddAutofillProfile(const AutofillProfile& profile) OVERRIDE;
269 virtual void UpdateAutofillProfile(const AutofillProfile& profile) OVERRIDE;
270 virtual void RemoveAutofillProfile(const std::string& guid) OVERRIDE;
271 virtual Handle GetAutofillProfiles(WebDataServiceConsumer* consumer) OVERRIDE;
272 virtual void AddCreditCard(const CreditCard& credit_card) OVERRIDE;
273 virtual void UpdateCreditCard(const CreditCard& credit_card) OVERRIDE;
274 virtual void RemoveCreditCard(const std::string& guid) OVERRIDE;
275 virtual Handle GetCreditCards(WebDataServiceConsumer* consumer) OVERRIDE;
276
277 // Removes Autofill records from the database.
278 void RemoveAutofillProfilesAndCreditCardsModifiedBetween(
279 const base::Time& delete_begin,
280 const base::Time& delete_end);
281
282 // Removes form elements recorded for Autocomplete from the database.
283 void RemoveFormElementsAddedBetween(const base::Time& delete_begin,
284 const base::Time& delete_end);
285
286 protected: 236 protected:
287 // TODO(caitkp): We probably don't need these anymore.
288 friend class TemplateURLServiceTest;
289 friend class TemplateURLServiceTestingProfile;
290 friend class WebDataServiceTest;
291 friend class WebDataRequest;
292
293 // For unit tests, passes a null callback. 237 // For unit tests, passes a null callback.
294 WebDataService(); 238 WebDataService();
295 239
296 virtual ~WebDataService(); 240 virtual ~WebDataService();
297 241
298 private: 242 private:
299 ////////////////////////////////////////////////////////////////////////////// 243 //////////////////////////////////////////////////////////////////////////////
300 // 244 //
301 // The following methods are only invoked on the DB thread. 245 // The following methods are only invoked on the DB thread.
302 // 246 //
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 // 319 //
376 ////////////////////////////////////////////////////////////////////////////// 320 //////////////////////////////////////////////////////////////////////////////
377 WebDatabase::State AddIE7LoginImpl( 321 WebDatabase::State AddIE7LoginImpl(
378 const IE7PasswordInfo& info, WebDatabase* db); 322 const IE7PasswordInfo& info, WebDatabase* db);
379 WebDatabase::State RemoveIE7LoginImpl( 323 WebDatabase::State RemoveIE7LoginImpl(
380 const IE7PasswordInfo& info, WebDatabase* db); 324 const IE7PasswordInfo& info, WebDatabase* db);
381 scoped_ptr<WDTypedResult> GetIE7LoginImpl( 325 scoped_ptr<WDTypedResult> GetIE7LoginImpl(
382 const IE7PasswordInfo& info, WebDatabase* db); 326 const IE7PasswordInfo& info, WebDatabase* db);
383 #endif // defined(OS_WIN) 327 #endif // defined(OS_WIN)
384 328
385 //////////////////////////////////////////////////////////////////////////////
386 //
387 // Autofill.
388 //
389 //////////////////////////////////////////////////////////////////////////////
390 WebDatabase::State AddFormElementsImpl(
391 const std::vector<FormFieldData>& fields, WebDatabase* db);
392 scoped_ptr<WDTypedResult> GetFormValuesForElementNameImpl(
393 const string16& name, const string16& prefix, int limit, WebDatabase* db);
394 WebDatabase::State RemoveFormElementsAddedBetweenImpl(
395 const base::Time& delete_begin, const base::Time& delete_end,
396 WebDatabase* db);
397 WebDatabase::State RemoveExpiredFormElementsImpl(WebDatabase* db);
398 WebDatabase::State RemoveFormValueForElementNameImpl(
399 const string16& name, const string16& value, WebDatabase* db);
400 WebDatabase::State AddAutofillProfileImpl(
401 const AutofillProfile& profile, WebDatabase* db);
402 WebDatabase::State UpdateAutofillProfileImpl(
403 const AutofillProfile& profile, WebDatabase* db);
404 WebDatabase::State RemoveAutofillProfileImpl(
405 const std::string& guid, WebDatabase* db);
406 scoped_ptr<WDTypedResult> GetAutofillProfilesImpl(WebDatabase* db);
407 WebDatabase::State AddCreditCardImpl(
408 const CreditCard& credit_card, WebDatabase* db);
409 WebDatabase::State UpdateCreditCardImpl(
410 const CreditCard& credit_card, WebDatabase* db);
411 WebDatabase::State RemoveCreditCardImpl(
412 const std::string& guid, WebDatabase* db);
413 scoped_ptr<WDTypedResult> GetCreditCardsImpl(WebDatabase* db);
414 WebDatabase::State RemoveAutofillProfilesAndCreditCardsModifiedBetweenImpl(
415 const base::Time& delete_begin, const base::Time& delete_end,
416 WebDatabase* db);
417
418 // Callbacks to ensure that sensitive info is destroyed if request is
419 // cancelled.
420 void DestroyAutofillProfileResult(const WDTypedResult* result);
421 void DestroyAutofillCreditCardResult(const WDTypedResult* result);
422
423 DISALLOW_COPY_AND_ASSIGN(WebDataService); 329 DISALLOW_COPY_AND_ASSIGN(WebDataService);
424 }; 330 };
425 331
426 #endif // CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__ 332 #endif // CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__
OLDNEW
« no previous file with comments | « chrome/browser/webdata/autofill_web_data_service_impl.cc ('k') | chrome/browser/webdata/web_data_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698