| OLD | NEW |
| 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__ |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 class WebDataService | 102 class WebDataService |
| 103 : public WebDataServiceBase, | 103 : public WebDataServiceBase, |
| 104 public AutofillWebData { | 104 public AutofillWebData { |
| 105 public: | 105 public: |
| 106 // Retrieve a WebDataService for the given context. | 106 // Retrieve a WebDataService for the given context. |
| 107 static scoped_refptr<WebDataService> FromBrowserContext( | 107 static scoped_refptr<WebDataService> FromBrowserContext( |
| 108 content::BrowserContext* context); | 108 content::BrowserContext* context); |
| 109 | 109 |
| 110 explicit WebDataService(const ProfileErrorCallback& callback); | 110 explicit WebDataService(const ProfileErrorCallback& callback); |
| 111 | 111 |
| 112 // WebDataServiceBase implementation. | |
| 113 virtual void ShutdownOnUIThread() OVERRIDE; | |
| 114 virtual void Init(const base::FilePath& path) OVERRIDE; | |
| 115 | |
| 116 // Notifies listeners on the UI thread that multiple changes have been made to | 112 // Notifies listeners on the UI thread that multiple changes have been made to |
| 117 // to Autofill records of the database. | 113 // to Autofill records of the database. |
| 118 // NOTE: This method is intended to be called from the DB thread. It | 114 // NOTE: This method is intended to be called from the DB thread. It |
| 119 // it asynchronously notifies listeners on the UI thread. | 115 // it asynchronously notifies listeners on the UI thread. |
| 120 // |web_data_service| may be NULL for testing purposes. | 116 // |web_data_service| may be NULL for testing purposes. |
| 121 static void NotifyOfMultipleAutofillChanges(WebDataService* web_data_service); | 117 static void NotifyOfMultipleAutofillChanges(WebDataService* web_data_service); |
| 122 | 118 |
| 123 | 119 |
| 124 | 120 |
| 125 ////////////////////////////////////////////////////////////////////////////// | 121 ////////////////////////////////////////////////////////////////////////////// |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 | 278 |
| 283 // Removes Autofill records from the database. | 279 // Removes Autofill records from the database. |
| 284 void RemoveAutofillProfilesAndCreditCardsModifiedBetween( | 280 void RemoveAutofillProfilesAndCreditCardsModifiedBetween( |
| 285 const base::Time& delete_begin, | 281 const base::Time& delete_begin, |
| 286 const base::Time& delete_end); | 282 const base::Time& delete_end); |
| 287 | 283 |
| 288 // Removes form elements recorded for Autocomplete from the database. | 284 // Removes form elements recorded for Autocomplete from the database. |
| 289 void RemoveFormElementsAddedBetween(const base::Time& delete_begin, | 285 void RemoveFormElementsAddedBetween(const base::Time& delete_begin, |
| 290 const base::Time& delete_end); | 286 const base::Time& delete_end); |
| 291 | 287 |
| 292 // Returns the syncable service for Autofill addresses and credit cards stored | |
| 293 // in this table. The returned service is owned by |this| object. | |
| 294 virtual AutofillProfileSyncableService* | |
| 295 GetAutofillProfileSyncableService() const; | |
| 296 | |
| 297 // Returns the syncable service for field autocomplete stored in this table. | |
| 298 // The returned service is owned by |this| object. | |
| 299 virtual AutocompleteSyncableService* | |
| 300 GetAutocompleteSyncableService() const; | |
| 301 | |
| 302 protected: | 288 protected: |
| 303 // TODO(caitkp): We probably don't need these anymore. | 289 // TODO(caitkp): We probably don't need these anymore. |
| 304 friend class TemplateURLServiceTest; | 290 friend class TemplateURLServiceTest; |
| 305 friend class TemplateURLServiceTestingProfile; | 291 friend class TemplateURLServiceTestingProfile; |
| 306 friend class WebDataServiceTest; | 292 friend class WebDataServiceTest; |
| 307 friend class WebDataRequest; | 293 friend class WebDataRequest; |
| 308 | 294 |
| 309 // For unit tests, passes a null callback. | 295 // For unit tests, passes a null callback. |
| 310 WebDataService(); | 296 WebDataService(); |
| 311 | 297 |
| 312 virtual ~WebDataService(); | 298 virtual ~WebDataService(); |
| 313 | 299 |
| 300 private: |
| 314 ////////////////////////////////////////////////////////////////////////////// | 301 ////////////////////////////////////////////////////////////////////////////// |
| 315 // | 302 // |
| 316 // The following methods are only invoked in the web data service thread. | 303 // The following methods are only invoked in the web data service thread. |
| 317 // | 304 // |
| 318 ////////////////////////////////////////////////////////////////////////////// | 305 ////////////////////////////////////////////////////////////////////////////// |
| 319 private: | |
| 320 // Initialize any syncable services. | |
| 321 void InitializeSyncableServices(); | |
| 322 | |
| 323 // Deletes the syncable services. | |
| 324 void ShutdownSyncableServices(); | |
| 325 | 306 |
| 326 ////////////////////////////////////////////////////////////////////////////// | 307 ////////////////////////////////////////////////////////////////////////////// |
| 327 // | 308 // |
| 328 // Keywords. | 309 // Keywords. |
| 329 // | 310 // |
| 330 ////////////////////////////////////////////////////////////////////////////// | 311 ////////////////////////////////////////////////////////////////////////////// |
| 331 WebDatabase::State AddKeywordImpl( | 312 WebDatabase::State AddKeywordImpl( |
| 332 const TemplateURLData& data, WebDatabase* db); | 313 const TemplateURLData& data, WebDatabase* db); |
| 333 WebDatabase::State RemoveKeywordImpl( | 314 WebDatabase::State RemoveKeywordImpl( |
| 334 TemplateURLID id, WebDatabase* db); | 315 TemplateURLID id, WebDatabase* db); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 scoped_ptr<WDTypedResult> GetCreditCardsImpl(WebDatabase* db); | 415 scoped_ptr<WDTypedResult> GetCreditCardsImpl(WebDatabase* db); |
| 435 WebDatabase::State RemoveAutofillProfilesAndCreditCardsModifiedBetweenImpl( | 416 WebDatabase::State RemoveAutofillProfilesAndCreditCardsModifiedBetweenImpl( |
| 436 const base::Time& delete_begin, const base::Time& delete_end, | 417 const base::Time& delete_begin, const base::Time& delete_end, |
| 437 WebDatabase* db); | 418 WebDatabase* db); |
| 438 | 419 |
| 439 // Callbacks to ensure that sensitive info is destroyed if request is | 420 // Callbacks to ensure that sensitive info is destroyed if request is |
| 440 // cancelled. | 421 // cancelled. |
| 441 void DestroyAutofillProfileResult(const WDTypedResult* result); | 422 void DestroyAutofillProfileResult(const WDTypedResult* result); |
| 442 void DestroyAutofillCreditCardResult(const WDTypedResult* result); | 423 void DestroyAutofillCreditCardResult(const WDTypedResult* result); |
| 443 | 424 |
| 444 // Syncable services for the database data. We own the services, but don't | |
| 445 // use |scoped_ptr|s because the lifetimes must be managed on the database | |
| 446 // thread. | |
| 447 // Currently only Autocomplete and Autofill profiles use the new Sync API, but | |
| 448 // all the database data should migrate to this API over time. | |
| 449 AutocompleteSyncableService* autocomplete_syncable_service_; | |
| 450 AutofillProfileSyncableService* autofill_profile_syncable_service_; | |
| 451 | |
| 452 DISALLOW_COPY_AND_ASSIGN(WebDataService); | 425 DISALLOW_COPY_AND_ASSIGN(WebDataService); |
| 453 }; | 426 }; |
| 454 | 427 |
| 455 #endif // CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__ | 428 #endif // CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__ |
| OLD | NEW |