| 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 COMPONENTS_SYNC_BASE_MODEL_TYPE_H_ | 5 #ifndef COMPONENTS_SYNC_BASE_MODEL_TYPE_H_ |
| 6 #define COMPONENTS_SYNC_BASE_MODEL_TYPE_H_ | 6 #define COMPONENTS_SYNC_BASE_MODEL_TYPE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <ostream> | 10 #include <ostream> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "components/reading_list/core/reading_list_enable_flags.h" |
| 15 #include "components/sync/base/enum_set.h" | 16 #include "components/sync/base/enum_set.h" |
| 16 | 17 |
| 17 namespace base { | 18 namespace base { |
| 18 class ListValue; | 19 class ListValue; |
| 19 class Value; | 20 class Value; |
| 20 } | 21 } |
| 21 | 22 |
| 22 namespace sync_pb { | 23 namespace sync_pb { |
| 23 class EntitySpecifics; | 24 class EntitySpecifics; |
| 24 class SyncEntity; | 25 class SyncEntity; |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 ModelType GetModelTypeFromSpecifics(const sync_pb::EntitySpecifics& specifics); | 195 ModelType GetModelTypeFromSpecifics(const sync_pb::EntitySpecifics& specifics); |
| 195 | 196 |
| 196 // Protocol types are those types that have actual protocol buffer | 197 // Protocol types are those types that have actual protocol buffer |
| 197 // representations. This distinguishes them from Proxy types, which have no | 198 // representations. This distinguishes them from Proxy types, which have no |
| 198 // protocol representation and are never sent to the server. | 199 // protocol representation and are never sent to the server. |
| 199 ModelTypeSet ProtocolTypes(); | 200 ModelTypeSet ProtocolTypes(); |
| 200 | 201 |
| 201 // These are the normal user-controlled types. This is to distinguish from | 202 // These are the normal user-controlled types. This is to distinguish from |
| 202 // ControlTypes which are always enabled. Note that some of these share a | 203 // ControlTypes which are always enabled. Note that some of these share a |
| 203 // preference flag, so not all of them are individually user-selectable. | 204 // preference flag, so not all of them are individually user-selectable. |
| 204 ModelTypeSet UserTypes(); | 205 constexpr ModelTypeSet UserTypes() { |
| 206 return ModelTypeSet::FromRange(FIRST_USER_MODEL_TYPE, LAST_USER_MODEL_TYPE); |
| 207 } |
| 205 | 208 |
| 206 // These are the user-selectable data types. | 209 // These are the user-selectable data types. |
| 207 ModelTypeSet UserSelectableTypes(); | 210 constexpr ModelTypeSet UserSelectableTypes() { |
| 208 bool IsUserSelectableType(ModelType model_type); | 211 return ModelTypeSet({ |
| 212 BOOKMARKS, PREFERENCES, PASSWORDS, AUTOFILL, THEMES, TYPED_URLS, EXTENSIONS, |
| 213 APPS, |
| 214 #if BUILDFLAG(ENABLE_READING_LIST) |
| 215 READING_LIST, |
| 216 #endif |
| 217 PROXY_TABS |
| 218 }); |
| 219 } |
| 220 |
| 221 constexpr bool IsUserSelectableType(ModelType model_type) { |
| 222 return UserSelectableTypes().Has(model_type); |
| 223 } |
| 224 |
| 209 ModelTypeNameMap GetUserSelectableTypeNameMap(); | 225 ModelTypeNameMap GetUserSelectableTypeNameMap(); |
| 210 | 226 |
| 211 // This is the subset of UserTypes() that can be encrypted. | 227 // This is the subset of UserTypes() that can be encrypted. |
| 212 ModelTypeSet EncryptableUserTypes(); | 228 ModelTypeSet EncryptableUserTypes(); |
| 213 | 229 |
| 214 // This is the subset of UserTypes() that have priority over other types. These | 230 // This is the subset of UserTypes() that have priority over other types. These |
| 215 // types are synced before other user types and are never encrypted. | 231 // types are synced before other user types and are never encrypted. |
| 216 ModelTypeSet PriorityUserTypes(); | 232 constexpr ModelTypeSet PriorityUserTypes() { |
| 217 | 233 return ModelTypeSet({DEVICE_INFO, PRIORITY_PREFERENCES}); |
| 218 // Proxy types are placeholder types for handling implicitly enabling real | 234 } |
| 219 // types. They do not exist at the server, and are simply used for | |
| 220 // UI/Configuration logic. | |
| 221 ModelTypeSet ProxyTypes(); | |
| 222 | 235 |
| 223 // Returns a list of all control types. | 236 // Returns a list of all control types. |
| 224 // | 237 // |
| 225 // The control types are intended to contain metadata nodes that are essential | 238 // The control types are intended to contain metadata nodes that are essential |
| 226 // for the normal operation of the syncer. As such, they have the following | 239 // for the normal operation of the syncer. As such, they have the following |
| 227 // special properties: | 240 // special properties: |
| 228 // - They are downloaded early during SyncBackend initialization. | 241 // - They are downloaded early during SyncBackend initialization. |
| 229 // - They are always enabled. Users may not disable these types. | 242 // - They are always enabled. Users may not disable these types. |
| 230 // - Their contents are not encrypted automatically. | 243 // - Their contents are not encrypted automatically. |
| 231 // - They support custom update application and conflict resolution logic. | 244 // - They support custom update application and conflict resolution logic. |
| 232 // - All change processing occurs on the sync thread (GROUP_PASSIVE). | 245 // - All change processing occurs on the sync thread (GROUP_PASSIVE). |
| 233 ModelTypeSet ControlTypes(); | 246 constexpr ModelTypeSet ControlTypes() { |
| 247 return ModelTypeSet::FromRange(FIRST_CONTROL_MODEL_TYPE, |
| 248 LAST_CONTROL_MODEL_TYPE); |
| 249 } |
| 250 |
| 251 // Proxy types are placeholder types for handling implicitly enabling real |
| 252 // types. They do not exist at the server, and are simply used for |
| 253 // UI/Configuration logic. |
| 254 constexpr ModelTypeSet ProxyTypes() { |
| 255 return ModelTypeSet::FromRange(FIRST_PROXY_TYPE, LAST_PROXY_TYPE); |
| 256 } |
| 234 | 257 |
| 235 // Returns true if this is a control type. | 258 // Returns true if this is a control type. |
| 236 // | 259 // |
| 237 // See comment above for more information on what makes these types special. | 260 // See comment above for more information on what makes these types special. |
| 238 bool IsControlType(ModelType model_type); | 261 constexpr bool IsControlType(ModelType model_type) { |
| 262 return ControlTypes().Has(model_type); |
| 263 } |
| 239 | 264 |
| 240 // Core types are those data types used by sync's core functionality (i.e. not | 265 // Core types are those data types used by sync's core functionality (i.e. not |
| 241 // user data types). These types are always enabled, and include ControlTypes(). | 266 // user data types). These types are always enabled, and include ControlTypes(). |
| 242 // | 267 // |
| 243 // The set of all core types. | 268 // The set of all core types. |
| 244 ModelTypeSet CoreTypes(); | 269 ModelTypeSet CoreTypes(); |
| 245 // Those core types that have high priority (includes ControlTypes()). | 270 // Those core types that have high priority (includes ControlTypes()). |
| 246 ModelTypeSet PriorityCoreTypes(); | 271 ModelTypeSet PriorityCoreTypes(); |
| 247 | 272 |
| 248 // Determine a model type from the field number of its associated | 273 // Determine a model type from the field number of its associated |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 | 376 |
| 352 // Returns true if |model_type| supports parent-child hierarchy or entries. | 377 // Returns true if |model_type| supports parent-child hierarchy or entries. |
| 353 bool TypeSupportsHierarchy(ModelType model_type); | 378 bool TypeSupportsHierarchy(ModelType model_type); |
| 354 | 379 |
| 355 // Returns true if |model_type| supports ordering of sibling entries. | 380 // Returns true if |model_type| supports ordering of sibling entries. |
| 356 bool TypeSupportsOrdering(ModelType model_type); | 381 bool TypeSupportsOrdering(ModelType model_type); |
| 357 | 382 |
| 358 } // namespace syncer | 383 } // namespace syncer |
| 359 | 384 |
| 360 #endif // COMPONENTS_SYNC_BASE_MODEL_TYPE_H_ | 385 #endif // COMPONENTS_SYNC_BASE_MODEL_TYPE_H_ |
| OLD | NEW |