Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "sync/internal_api/public/base/model_type.h" | 5 #include "sync/internal_api/public/base/model_type.h" |
| 6 | 6 |
| 7 #include "base/strings/string_split.h" | 7 #include "base/strings/string_split.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "sync/protocol/app_notification_specifics.pb.h" | 9 #include "sync/protocol/app_notification_specifics.pb.h" |
| 10 #include "sync/protocol/app_setting_specifics.pb.h" | 10 #include "sync/protocol/app_setting_specifics.pb.h" |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 360 } | 360 } |
| 361 | 361 |
| 362 ModelTypeSet EncryptableUserTypes() { | 362 ModelTypeSet EncryptableUserTypes() { |
| 363 ModelTypeSet encryptable_user_types = UserTypes(); | 363 ModelTypeSet encryptable_user_types = UserTypes(); |
| 364 // We never encrypt history delete directives. | 364 // We never encrypt history delete directives. |
| 365 encryptable_user_types.Remove(HISTORY_DELETE_DIRECTIVES); | 365 encryptable_user_types.Remove(HISTORY_DELETE_DIRECTIVES); |
| 366 // Synced notifications are not encrypted since the server must see changes. | 366 // Synced notifications are not encrypted since the server must see changes. |
| 367 encryptable_user_types.Remove(SYNCED_NOTIFICATIONS); | 367 encryptable_user_types.Remove(SYNCED_NOTIFICATIONS); |
| 368 // Priority preferences are not encrypted because they might be synced before | 368 // Priority preferences are not encrypted because they might be synced before |
| 369 // encryption is ready. | 369 // encryption is ready. |
| 370 encryptable_user_types.RemoveAll(PriorityUserTypes()); | 370 encryptable_user_types.Remove(PRIORITY_PREFERENCES); |
| 371 // Managed user settings are not encrypted since they are set server-side. | 371 // Managed user settings are not encrypted since they are set server-side. |
| 372 encryptable_user_types.Remove(MANAGED_USER_SETTINGS); | 372 encryptable_user_types.Remove(MANAGED_USER_SETTINGS); |
| 373 // Managed users are not encrypted since they are managed server-side. | 373 // Managed users are not encrypted since they are managed server-side. |
| 374 encryptable_user_types.Remove(MANAGED_USERS); | 374 encryptable_user_types.Remove(MANAGED_USERS); |
| 375 // Proxy types have no sync representation and are therefore not encrypted. | 375 // Proxy types have no sync representation and are therefore not encrypted. |
| 376 // Note however that proxy types map to one or more protocol types, which | 376 // Note however that proxy types map to one or more protocol types, which |
| 377 // may or may not be encrypted themselves. | 377 // may or may not be encrypted themselves. |
| 378 encryptable_user_types.RemoveAll(ProxyTypes()); | 378 encryptable_user_types.RemoveAll(ProxyTypes()); |
| 379 return encryptable_user_types; | 379 return encryptable_user_types; |
| 380 } | 380 } |
| 381 | 381 |
| 382 ModelTypeSet PriorityUserTypes() { | 382 ModelTypeSet PriorityUserTypes() { |
| 383 return ModelTypeSet(PRIORITY_PREFERENCES, MANAGED_USERS); | 383 return ModelTypeSet(PRIORITY_PREFERENCES); |
| 384 } | 384 } |
| 385 | 385 |
| 386 ModelTypeSet ControlTypes() { | 386 ModelTypeSet ControlTypes() { |
| 387 ModelTypeSet set; | 387 ModelTypeSet set; |
| 388 // TODO(sync): We should be able to build the actual enumset's internal | 388 // TODO(sync): We should be able to build the actual enumset's internal |
| 389 // bitset value here at compile time, rather than performing an iteration | 389 // bitset value here at compile time, rather than performing an iteration |
| 390 // every time. | 390 // every time. |
| 391 for (int i = FIRST_CONTROL_MODEL_TYPE; i <= LAST_CONTROL_MODEL_TYPE; ++i) { | 391 for (int i = FIRST_CONTROL_MODEL_TYPE; i <= LAST_CONTROL_MODEL_TYPE; ++i) { |
| 392 set.Put(ModelTypeFromInt(i)); | 392 set.Put(ModelTypeFromInt(i)); |
| 393 } | 393 } |
| 394 | 394 |
| 395 return set; | 395 return set; |
| 396 } | 396 } |
| 397 | 397 |
| 398 ModelTypeSet ProxyTypes() { | 398 ModelTypeSet ProxyTypes() { |
| 399 ModelTypeSet set; | 399 ModelTypeSet set; |
| 400 set.Put(PROXY_TABS); | 400 set.Put(PROXY_TABS); |
| 401 return set; | 401 return set; |
| 402 } | 402 } |
| 403 | 403 |
| 404 bool IsControlType(ModelType model_type) { | 404 bool IsControlType(ModelType model_type) { |
| 405 return ControlTypes().Has(model_type); | 405 return ControlTypes().Has(model_type); |
| 406 } | 406 } |
| 407 | 407 |
| 408 ModelTypeSet PriorityCoreTypes() { | |
| 409 syncer::ModelTypeSet result; | |
| 410 result.Put(MANAGED_USERS); | |
|
tim (not reviewing)
2013/07/16 16:54:55
MANAGED_USER_SETTINGS fits the core type definitio
Nicolas Zea
2013/07/17 21:05:37
I don't think it's a core type either? We weren't
| |
| 411 return result; | |
| 412 } | |
| 413 | |
| 414 ModelTypeSet CoreTypes() { | |
|
tim (not reviewing)
2013/07/16 16:54:55
Should this include PriorityCoreTypes? What if I
Nicolas Zea
2013/07/17 21:05:37
Yeah, I suppose CoreTypes() makes more sense as th
| |
| 415 syncer::ModelTypeSet result; | |
| 416 result.Put(SYNCED_NOTIFICATIONS); | |
| 417 return result; | |
| 418 } | |
| 419 | |
| 408 const char* ModelTypeToString(ModelType model_type) { | 420 const char* ModelTypeToString(ModelType model_type) { |
| 409 // This is used in serialization routines as well as for displaying debug | 421 // This is used in serialization routines as well as for displaying debug |
| 410 // information. Do not attempt to change these string values unless you know | 422 // information. Do not attempt to change these string values unless you know |
| 411 // what you're doing. | 423 // what you're doing. |
| 412 switch (model_type) { | 424 switch (model_type) { |
| 413 case TOP_LEVEL_FOLDER: | 425 case TOP_LEVEL_FOLDER: |
| 414 return "Top Level Folder"; | 426 return "Top Level Folder"; |
| 415 case UNSPECIFIED: | 427 case UNSPECIFIED: |
| 416 return "Unspecified"; | 428 return "Unspecified"; |
| 417 case BOOKMARKS: | 429 case BOOKMARKS: |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 922 | 934 |
| 923 bool IsRealDataType(ModelType model_type) { | 935 bool IsRealDataType(ModelType model_type) { |
| 924 return model_type >= FIRST_REAL_MODEL_TYPE && model_type < MODEL_TYPE_COUNT; | 936 return model_type >= FIRST_REAL_MODEL_TYPE && model_type < MODEL_TYPE_COUNT; |
| 925 } | 937 } |
| 926 | 938 |
| 927 bool IsActOnceDataType(ModelType model_type) { | 939 bool IsActOnceDataType(ModelType model_type) { |
| 928 return model_type == HISTORY_DELETE_DIRECTIVES; | 940 return model_type == HISTORY_DELETE_DIRECTIVES; |
| 929 } | 941 } |
| 930 | 942 |
| 931 } // namespace syncer | 943 } // namespace syncer |
| OLD | NEW |