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/non_ui_data_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 sync_driver::NonUIDataTypeController { |
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 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread, | 26 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread, |
27 const base::Closure& dump_stack, | 27 const base::Closure& dump_stack, |
28 syncer::SyncClient* sync_client, | 28 sync_driver::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 // NonUIDataTypeController implementation. | 32 // NonUIDataTypeController implementation. |
33 syncer::ModelSafeGroup model_safe_group() const override; | 33 syncer::ModelSafeGroup model_safe_group() const override; |
34 | 34 |
35 private: | 35 private: |
36 // NonUIDataTypeController implementation. | 36 // NonUIDataTypeController implementation. |
37 bool PostTaskOnBackendThread(const tracked_objects::Location& from_here, | 37 bool PostTaskOnBackendThread(const tracked_objects::Location& from_here, |
38 const base::Closure& task) override; | 38 const base::Closure& task) override; |
39 bool StartModels() override; | 39 bool StartModels() override; |
40 void StopModels() override; | 40 void StopModels() override; |
41 bool ReadyForStart() const override; | 41 bool ReadyForStart() const override; |
42 | 42 |
43 // Callback for changes to the autofill pref. | 43 // Callback for changes to the autofill pref. |
44 void OnUserPrefChanged(); | 44 void OnUserPrefChanged(); |
45 | 45 |
46 // Returns true if the prefs are set such that wallet sync should be enabled. | 46 // Returns true if the prefs are set such that wallet sync should be enabled. |
47 bool IsEnabled(); | 47 bool IsEnabled(); |
48 | 48 |
49 // A reference to the DB thread's task runner. | 49 // A reference to the DB thread's task runner. |
50 const scoped_refptr<base::SingleThreadTaskRunner> db_thread_; | 50 const scoped_refptr<base::SingleThreadTaskRunner> db_thread_; |
51 | 51 |
52 // A pointer to the sync client. | 52 // A pointer to the sync client. |
53 syncer::SyncClient* const sync_client_; | 53 sync_driver::SyncClient* const sync_client_; |
54 | 54 |
55 // Whether the database loaded callback has been registered. | 55 // Whether the database loaded callback has been registered. |
56 bool callback_registered_; | 56 bool callback_registered_; |
57 | 57 |
58 // A reference to the AutofillWebDataService for this controller. | 58 // A reference to the AutofillWebDataService for this controller. |
59 scoped_refptr<autofill::AutofillWebDataService> web_data_service_; | 59 scoped_refptr<autofill::AutofillWebDataService> web_data_service_; |
60 | 60 |
61 // Stores whether we're currently syncing wallet data. This is the last | 61 // Stores whether we're currently syncing wallet data. This is the last |
62 // value computed by IsEnabled. | 62 // value computed by IsEnabled. |
63 bool currently_enabled_; | 63 bool currently_enabled_; |
64 | 64 |
65 // Registrar for listening to kAutofillWalletSyncExperimentEnabled status. | 65 // Registrar for listening to kAutofillWalletSyncExperimentEnabled status. |
66 PrefChangeRegistrar pref_registrar_; | 66 PrefChangeRegistrar pref_registrar_; |
67 | 67 |
68 DISALLOW_COPY_AND_ASSIGN(AutofillWalletDataTypeController); | 68 DISALLOW_COPY_AND_ASSIGN(AutofillWalletDataTypeController); |
69 }; | 69 }; |
70 | 70 |
71 } // namespace browser_sync | 71 } // namespace browser_sync |
72 | 72 |
73 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_WALLET_DATA_TYPE_CONTROLLER
_H_ | 73 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_WALLET_DATA_TYPE_CONTROLLER
_H_ |
OLD | NEW |