OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #ifndef IOS_CHROME_BROWSER_SYNC_SYNC_SETUP_SERVICE_H_ | 5 #ifndef IOS_CHROME_BROWSER_SYNC_SYNC_SETUP_SERVICE_H_ |
6 #define IOS_CHROME_BROWSER_SYNC_SYNC_SETUP_SERVICE_H_ | 6 #define IOS_CHROME_BROWSER_SYNC_SYNC_SETUP_SERVICE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
13 #include "components/keyed_service/core/keyed_service.h" | 13 #include "components/keyed_service/core/keyed_service.h" |
14 #include "components/sync/base/model_type.h" | 14 #include "components/sync/base/model_type.h" |
15 #include "components/sync/base/syncer_error.h" | 15 #include "components/sync/base/syncer_error.h" |
16 | 16 |
17 namespace sync_driver { | 17 class PrefService; |
| 18 |
| 19 namespace syncer { |
18 class SyncService; | 20 class SyncService; |
19 class SyncSetupInProgressHandle; | 21 class SyncSetupInProgressHandle; |
20 } | 22 } // namespace syncer |
21 | |
22 class PrefService; | |
23 | 23 |
24 // Class that allows configuring sync. It handles enabling and disabling it, as | 24 // Class that allows configuring sync. It handles enabling and disabling it, as |
25 // well as choosing datatypes. Most actions are delayed until a commit is done, | 25 // well as choosing datatypes. Most actions are delayed until a commit is done, |
26 // to allow the complex sync setup flow on iOS. | 26 // to allow the complex sync setup flow on iOS. |
27 class SyncSetupService : public KeyedService { | 27 class SyncSetupService : public KeyedService { |
28 public: | 28 public: |
29 typedef enum { | 29 typedef enum { |
30 kNoSyncServiceError, | 30 kNoSyncServiceError, |
31 kSyncServiceSignInNeedsUpdate, | 31 kSyncServiceSignInNeedsUpdate, |
32 kSyncServiceCouldNotConnect, | 32 kSyncServiceCouldNotConnect, |
33 kSyncServiceServiceUnavailable, | 33 kSyncServiceServiceUnavailable, |
34 kSyncServiceNeedsPassphrase, | 34 kSyncServiceNeedsPassphrase, |
35 kSyncServiceUnrecoverableError, | 35 kSyncServiceUnrecoverableError, |
36 kLastSyncServiceError = kSyncServiceUnrecoverableError | 36 kLastSyncServiceError = kSyncServiceUnrecoverableError |
37 } SyncServiceState; | 37 } SyncServiceState; |
38 | 38 |
39 // The set of user-selectable datatypes handled by Chrome for iOS. | 39 // The set of user-selectable datatypes handled by Chrome for iOS. |
40 typedef enum { | 40 typedef enum { |
41 kSyncBookmarks, | 41 kSyncBookmarks, |
42 kSyncOmniboxHistory, | 42 kSyncOmniboxHistory, |
43 kSyncPasswords, | 43 kSyncPasswords, |
44 kSyncOpenTabs, | 44 kSyncOpenTabs, |
45 kSyncAutofill, | 45 kSyncAutofill, |
46 kSyncPreferences, | 46 kSyncPreferences, |
47 kNumberOfSyncableDatatypes | 47 kNumberOfSyncableDatatypes |
48 } SyncableDatatype; | 48 } SyncableDatatype; |
49 | 49 |
50 SyncSetupService(sync_driver::SyncService* sync_service, PrefService* prefs); | 50 SyncSetupService(syncer::SyncService* sync_service, PrefService* prefs); |
51 ~SyncSetupService() override; | 51 ~SyncSetupService() override; |
52 | 52 |
53 // Returns the |syncer::ModelType| associated to the given | 53 // Returns the |syncer::ModelType| associated to the given |
54 // |SyncableDatatypes|. | 54 // |SyncableDatatypes|. |
55 syncer::ModelType GetModelType(SyncableDatatype datatype); | 55 syncer::ModelType GetModelType(SyncableDatatype datatype); |
56 | 56 |
57 // Returns whether sync is enabled. | 57 // Returns whether sync is enabled. |
58 virtual bool IsSyncEnabled() const; | 58 virtual bool IsSyncEnabled() const; |
59 // Enables or disables sync. Changes won't take effect in the sync backend | 59 // Enables or disables sync. Changes won't take effect in the sync backend |
60 // before the next call to |CommitChanges|. | 60 // before the next call to |CommitChanges|. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 97 |
98 // Returns true if there are uncommitted sync changes; | 98 // Returns true if there are uncommitted sync changes; |
99 bool HasUncommittedChanges(); | 99 bool HasUncommittedChanges(); |
100 | 100 |
101 private: | 101 private: |
102 // Enables or disables sync. Changes won't take effect in the sync backend | 102 // Enables or disables sync. Changes won't take effect in the sync backend |
103 // before the next call to |CommitChanges|. No changes are made to the | 103 // before the next call to |CommitChanges|. No changes are made to the |
104 // currently selected datatypes. | 104 // currently selected datatypes. |
105 void SetSyncEnabledWithoutChangingDatatypes(bool sync_enabled); | 105 void SetSyncEnabledWithoutChangingDatatypes(bool sync_enabled); |
106 | 106 |
107 sync_driver::SyncService* const sync_service_; | 107 syncer::SyncService* const sync_service_; |
108 PrefService* const prefs_; | 108 PrefService* const prefs_; |
109 syncer::ModelTypeSet user_selectable_types_; | 109 syncer::ModelTypeSet user_selectable_types_; |
110 | 110 |
111 // Prevents Sync from running until configuration is complete. | 111 // Prevents Sync from running until configuration is complete. |
112 std::unique_ptr<sync_driver::SyncSetupInProgressHandle> sync_blocker_; | 112 std::unique_ptr<syncer::SyncSetupInProgressHandle> sync_blocker_; |
113 | 113 |
114 DISALLOW_COPY_AND_ASSIGN(SyncSetupService); | 114 DISALLOW_COPY_AND_ASSIGN(SyncSetupService); |
115 }; | 115 }; |
116 | 116 |
117 #endif // IOS_CHROME_BROWSER_SYNC_SYNC_SETUP_SERVICE_H_ | 117 #endif // IOS_CHROME_BROWSER_SYNC_SYNC_SETUP_SERVICE_H_ |
OLD | NEW |