| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_AUTOFILL_WALLET_DATA_TYPE_CONTROLLER_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_WALLET_DATA_TYPE_CONTROLLER_H_ |
| 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_WALLET_DATA_TYPE_CONTROLLER_H_ | 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_WALLET_DATA_TYPE_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "components/prefs/pref_change_registrar.h" | 9 #include "components/prefs/pref_change_registrar.h" |
| 10 #include "components/sync/driver/non_ui_data_type_controller.h" | 10 #include "components/sync/driver/async_directory_type_controller.h" |
| 11 | 11 |
| 12 namespace autofill { | 12 namespace autofill { |
| 13 class AutofillWebDataService; | 13 class AutofillWebDataService; |
| 14 } | 14 } |
| 15 | 15 |
| 16 namespace browser_sync { | 16 namespace browser_sync { |
| 17 | 17 |
| 18 // Controls syncing of either AUTOFILL_WALLET or AUTOFILL_WALLET_METADATA. | 18 // Controls syncing of either AUTOFILL_WALLET or AUTOFILL_WALLET_METADATA. |
| 19 class AutofillWalletDataTypeController | 19 class AutofillWalletDataTypeController |
| 20 : public syncer::NonUIDataTypeController { | 20 : public syncer::AsyncDirectoryTypeController { |
| 21 public: | 21 public: |
| 22 // |type| should be either AUTOFILL_WALLET or AUTOFILL_WALLET_METADATA. | 22 // |type| should be either AUTOFILL_WALLET or AUTOFILL_WALLET_METADATA. |
| 23 // |dump_stack| is called when an unrecoverable error occurs. | 23 // |dump_stack| is called when an unrecoverable error occurs. |
| 24 AutofillWalletDataTypeController( | 24 AutofillWalletDataTypeController( |
| 25 syncer::ModelType type, | 25 syncer::ModelType type, |
| 26 scoped_refptr<base::SingleThreadTaskRunner> db_thread, | 26 scoped_refptr<base::SingleThreadTaskRunner> db_thread, |
| 27 const base::Closure& dump_stack, | 27 const base::Closure& dump_stack, |
| 28 syncer::SyncClient* sync_client, | 28 syncer::SyncClient* sync_client, |
| 29 const scoped_refptr<autofill::AutofillWebDataService>& web_data_service); | 29 const scoped_refptr<autofill::AutofillWebDataService>& web_data_service); |
| 30 ~AutofillWalletDataTypeController() override; | 30 ~AutofillWalletDataTypeController() override; |
| 31 | 31 |
| 32 private: | 32 private: |
| 33 // NonUIDataTypeController implementation. | 33 // AsyncDirectoryTypeController implementation. |
| 34 bool StartModels() override; | 34 bool StartModels() override; |
| 35 void StopModels() override; | 35 void StopModels() override; |
| 36 bool ReadyForStart() const override; | 36 bool ReadyForStart() const override; |
| 37 | 37 |
| 38 // Callback for changes to the autofill pref. | 38 // Callback for changes to the autofill pref. |
| 39 void OnUserPrefChanged(); | 39 void OnUserPrefChanged(); |
| 40 | 40 |
| 41 // Returns true if the prefs are set such that wallet sync should be enabled. | 41 // Returns true if the prefs are set such that wallet sync should be enabled. |
| 42 bool IsEnabled(); | 42 bool IsEnabled(); |
| 43 | 43 |
| 44 // Whether the database loaded callback has been registered. | 44 // Whether the database loaded callback has been registered. |
| 45 bool callback_registered_; | 45 bool callback_registered_; |
| 46 | 46 |
| 47 // A reference to the AutofillWebDataService for this controller. | 47 // A reference to the AutofillWebDataService for this controller. |
| 48 scoped_refptr<autofill::AutofillWebDataService> web_data_service_; | 48 scoped_refptr<autofill::AutofillWebDataService> web_data_service_; |
| 49 | 49 |
| 50 // Stores whether we're currently syncing wallet data. This is the last | 50 // Stores whether we're currently syncing wallet data. This is the last |
| 51 // value computed by IsEnabled. | 51 // value computed by IsEnabled. |
| 52 bool currently_enabled_; | 52 bool currently_enabled_; |
| 53 | 53 |
| 54 // Registrar for listening to kAutofillWalletSyncExperimentEnabled status. | 54 // Registrar for listening to kAutofillWalletSyncExperimentEnabled status. |
| 55 PrefChangeRegistrar pref_registrar_; | 55 PrefChangeRegistrar pref_registrar_; |
| 56 | 56 |
| 57 DISALLOW_COPY_AND_ASSIGN(AutofillWalletDataTypeController); | 57 DISALLOW_COPY_AND_ASSIGN(AutofillWalletDataTypeController); |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 } // namespace browser_sync | 60 } // namespace browser_sync |
| 61 | 61 |
| 62 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_WALLET_DATA_TYPE_CONTROLLER
_H_ | 62 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_WALLET_DATA_TYPE_CONTROLLER
_H_ |
| OLD | NEW |