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 CoreTypes() { |
| 409 syncer::ModelTypeSet result; |
| 410 result.PutAll(PriorityCoreTypes()); |
| 411 |
| 412 // The following are low priority core types. |
| 413 result.Put(SYNCED_NOTIFICATIONS); |
| 414 |
| 415 return result; |
| 416 } |
| 417 |
| 418 ModelTypeSet PriorityCoreTypes() { |
| 419 syncer::ModelTypeSet result; |
| 420 result.PutAll(ControlTypes()); |
| 421 |
| 422 // The following are non-control core types. |
| 423 result.Put(MANAGED_USERS); |
| 424 |
| 425 return result; |
| 426 } |
| 427 |
408 const char* ModelTypeToString(ModelType model_type) { | 428 const char* ModelTypeToString(ModelType model_type) { |
409 // This is used in serialization routines as well as for displaying debug | 429 // 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 | 430 // information. Do not attempt to change these string values unless you know |
411 // what you're doing. | 431 // what you're doing. |
412 switch (model_type) { | 432 switch (model_type) { |
413 case TOP_LEVEL_FOLDER: | 433 case TOP_LEVEL_FOLDER: |
414 return "Top Level Folder"; | 434 return "Top Level Folder"; |
415 case UNSPECIFIED: | 435 case UNSPECIFIED: |
416 return "Unspecified"; | 436 return "Unspecified"; |
417 case BOOKMARKS: | 437 case BOOKMARKS: |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
922 | 942 |
923 bool IsRealDataType(ModelType model_type) { | 943 bool IsRealDataType(ModelType model_type) { |
924 return model_type >= FIRST_REAL_MODEL_TYPE && model_type < MODEL_TYPE_COUNT; | 944 return model_type >= FIRST_REAL_MODEL_TYPE && model_type < MODEL_TYPE_COUNT; |
925 } | 945 } |
926 | 946 |
927 bool IsActOnceDataType(ModelType model_type) { | 947 bool IsActOnceDataType(ModelType model_type) { |
928 return model_type == HISTORY_DELETE_DIRECTIVES; | 948 return model_type == HISTORY_DELETE_DIRECTIVES; |
929 } | 949 } |
930 | 950 |
931 } // namespace syncer | 951 } // namespace syncer |
OLD | NEW |