Home | History | Annotate | Download | only in glue
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_BROWSER_SYNC_GLUE_AUTOFILL_DATA_TYPE_CONTROLLER_H__
      6 #define CHROME_BROWSER_SYNC_GLUE_AUTOFILL_DATA_TYPE_CONTROLLER_H__
      7 
      8 #include <string>
      9 
     10 #include "base/compiler_specific.h"
     11 #include "base/gtest_prod_util.h"
     12 #include "base/memory/ref_counted.h"
     13 #include "chrome/browser/sync/glue/non_ui_data_type_controller.h"
     14 
     15 namespace autofill {
     16 class AutofillWebDataService;
     17 }  // namespace autofill
     18 
     19 namespace browser_sync {
     20 
     21 // A class that manages the startup and shutdown of autofill sync.
     22 class AutofillDataTypeController
     23     : public NonUIDataTypeController {
     24  public:
     25   AutofillDataTypeController(
     26       ProfileSyncComponentsFactory* profile_sync_factory,
     27       Profile* profile,
     28       ProfileSyncService* sync_service);
     29 
     30   // NonUIDataTypeController implementation.
     31   virtual syncer::ModelType type() const OVERRIDE;
     32   virtual syncer::ModelSafeGroup model_safe_group() const OVERRIDE;
     33 
     34   // NonFrontendDatatypeController override, needed as stop-gap until bug
     35   // 163431 is addressed / implemented.
     36   virtual void StartAssociating(const StartCallback& start_callback) OVERRIDE;
     37 
     38  protected:
     39   virtual ~AutofillDataTypeController();
     40 
     41   // NonUIDataTypeController implementation.
     42   virtual bool PostTaskOnBackendThread(
     43       const tracked_objects::Location& from_here,
     44       const base::Closure& task) OVERRIDE;
     45   virtual bool StartModels() OVERRIDE;
     46   virtual void StopModels() OVERRIDE;
     47 
     48  private:
     49   friend class AutofillDataTypeControllerTest;
     50   FRIEND_TEST_ALL_PREFIXES(AutofillDataTypeControllerTest, StartWDSReady);
     51   FRIEND_TEST_ALL_PREFIXES(AutofillDataTypeControllerTest, StartWDSNotReady);
     52 
     53   // Self-invoked on the DB thread to call the AutocompleteSyncableService with
     54   // an updated value of autofill culling settings.
     55   void UpdateAutofillCullingSettings(bool cull_expired_entries,
     56       scoped_refptr<autofill::AutofillWebDataService> web_data_service);
     57 
     58   // Callback once WebDatabase has loaded.
     59   void WebDatabaseLoaded();
     60 
     61   DISALLOW_COPY_AND_ASSIGN(AutofillDataTypeController);
     62 };
     63 
     64 }  // namespace browser_sync
     65 
     66 #endif  // CHROME_BROWSER_SYNC_GLUE_AUTOFILL_DATA_TYPE_CONTROLLER_H__
     67