| 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/string_split.h" | 7 #include "base/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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 } | 283 } |
| 284 return set; | 284 return set; |
| 285 } | 285 } |
| 286 | 286 |
| 287 ModelTypeSet EncryptableUserTypes() { | 287 ModelTypeSet EncryptableUserTypes() { |
| 288 ModelTypeSet encryptable_user_types = UserTypes(); | 288 ModelTypeSet encryptable_user_types = UserTypes(); |
| 289 // We never encrypt history delete directives. | 289 // We never encrypt history delete directives. |
| 290 encryptable_user_types.Remove(HISTORY_DELETE_DIRECTIVES); | 290 encryptable_user_types.Remove(HISTORY_DELETE_DIRECTIVES); |
| 291 // Synced notifications are not encrypted since the server must see changes. | 291 // Synced notifications are not encrypted since the server must see changes. |
| 292 encryptable_user_types.Remove(SYNCED_NOTIFICATIONS); | 292 encryptable_user_types.Remove(SYNCED_NOTIFICATIONS); |
| 293 // Virtual types have no sync representation and are therefore not encrypted |
| 294 // either. Their underlying representations may or may not be encrypted |
| 295 // though. |
| 296 encryptable_user_types.RemoveAll(VirtualTypes()); |
| 293 return encryptable_user_types; | 297 return encryptable_user_types; |
| 294 } | 298 } |
| 295 | 299 |
| 296 ModelTypeSet ControlTypes() { | 300 ModelTypeSet ControlTypes() { |
| 297 ModelTypeSet set; | 301 ModelTypeSet set; |
| 298 for (int i = FIRST_CONTROL_MODEL_TYPE; i <= LAST_CONTROL_MODEL_TYPE; ++i) { | 302 for (int i = FIRST_CONTROL_MODEL_TYPE; i <= LAST_CONTROL_MODEL_TYPE; ++i) { |
| 299 set.Put(ModelTypeFromInt(i)); | 303 set.Put(ModelTypeFromInt(i)); |
| 300 } | 304 } |
| 301 | 305 |
| 302 // TODO(albertb): Re-enable this when the server supports it. | 306 // TODO(albertb): Re-enable this when the server supports it. |
| 303 set.Remove(PRIORITY_PREFERENCES); | 307 set.Remove(PRIORITY_PREFERENCES); |
| 304 | 308 |
| 305 return set; | 309 return set; |
| 306 } | 310 } |
| 307 | 311 |
| 312 ModelTypeSet VirtualTypes() { |
| 313 ModelTypeSet set; |
| 314 // TODO(zea): add a TABS type here. |
| 315 return set; |
| 316 } |
| 317 |
| 308 bool IsControlType(ModelType model_type) { | 318 bool IsControlType(ModelType model_type) { |
| 309 return ControlTypes().Has(model_type); | 319 return ControlTypes().Has(model_type); |
| 310 } | 320 } |
| 311 | 321 |
| 312 const char* ModelTypeToString(ModelType model_type) { | 322 const char* ModelTypeToString(ModelType model_type) { |
| 313 // This is used in serialization routines as well as for displaying debug | 323 // This is used in serialization routines as well as for displaying debug |
| 314 // information. Do not attempt to change these string values unless you know | 324 // information. Do not attempt to change these string values unless you know |
| 315 // what you're doing. | 325 // what you're doing. |
| 316 switch (model_type) { | 326 switch (model_type) { |
| 317 case TOP_LEVEL_FOLDER: | 327 case TOP_LEVEL_FOLDER: |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 } | 681 } |
| 672 *model_type = UNSPECIFIED; | 682 *model_type = UNSPECIFIED; |
| 673 return false; | 683 return false; |
| 674 } | 684 } |
| 675 | 685 |
| 676 bool IsRealDataType(ModelType model_type) { | 686 bool IsRealDataType(ModelType model_type) { |
| 677 return model_type >= FIRST_REAL_MODEL_TYPE && model_type < MODEL_TYPE_COUNT; | 687 return model_type >= FIRST_REAL_MODEL_TYPE && model_type < MODEL_TYPE_COUNT; |
| 678 } | 688 } |
| 679 | 689 |
| 680 } // namespace syncer | 690 } // namespace syncer |
| OLD | NEW |