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 class PrefService; | 17 class PrefService; |
18 | 18 |
19 namespace syncer { | 19 namespace syncer { |
20 class SyncService; | 20 class SyncService; |
21 class SyncSetupInProgressHandle; | 21 class SyncSetupInProgressHandle; |
22 } // namespace syncer | 22 } // namespace syncer |
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 using SyncServiceState = 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 }; |
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 using SyncableDatatype = 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 kSyncReadingList, | 47 kSyncReadingList, |
48 kNumberOfSyncableDatatypes | 48 kNumberOfSyncableDatatypes |
49 } SyncableDatatype; | 49 }; |
50 | 50 |
51 SyncSetupService(syncer::SyncService* sync_service, PrefService* prefs); | 51 SyncSetupService(syncer::SyncService* sync_service, PrefService* prefs); |
52 ~SyncSetupService() override; | 52 ~SyncSetupService() override; |
53 | 53 |
54 // Returns the |syncer::ModelType| associated to the given | 54 // Returns the |syncer::ModelType| associated to the given |
55 // |SyncableDatatypes|. | 55 // |SyncableDatatypes|. |
56 syncer::ModelType GetModelType(SyncableDatatype datatype); | 56 syncer::ModelType GetModelType(SyncableDatatype datatype); |
57 | 57 |
58 // Returns whether sync is enabled. | 58 // Returns whether sync is enabled. |
59 virtual bool IsSyncEnabled() const; | 59 virtual bool IsSyncEnabled() const; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 PrefService* const prefs_; | 109 PrefService* const prefs_; |
110 syncer::ModelTypeSet user_selectable_types_; | 110 syncer::ModelTypeSet user_selectable_types_; |
111 | 111 |
112 // Prevents Sync from running until configuration is complete. | 112 // Prevents Sync from running until configuration is complete. |
113 std::unique_ptr<syncer::SyncSetupInProgressHandle> sync_blocker_; | 113 std::unique_ptr<syncer::SyncSetupInProgressHandle> sync_blocker_; |
114 | 114 |
115 DISALLOW_COPY_AND_ASSIGN(SyncSetupService); | 115 DISALLOW_COPY_AND_ASSIGN(SyncSetupService); |
116 }; | 116 }; |
117 | 117 |
118 #endif // IOS_CHROME_BROWSER_SYNC_SYNC_SETUP_SERVICE_H_ | 118 #endif // IOS_CHROME_BROWSER_SYNC_SYNC_SETUP_SERVICE_H_ |
OLD | NEW |