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 "components/sync/base/model_type.h" | 5 #include "components/sync/base/model_type.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 ModelTypeSet set; | 550 ModelTypeSet set; |
551 set.Put(PROXY_TABS); | 551 set.Put(PROXY_TABS); |
552 return set; | 552 return set; |
553 } | 553 } |
554 | 554 |
555 bool IsControlType(ModelType model_type) { | 555 bool IsControlType(ModelType model_type) { |
556 return ControlTypes().Has(model_type); | 556 return ControlTypes().Has(model_type); |
557 } | 557 } |
558 | 558 |
559 ModelTypeSet CoreTypes() { | 559 ModelTypeSet CoreTypes() { |
560 syncer::ModelTypeSet result; | 560 ModelTypeSet result; |
561 result.PutAll(PriorityCoreTypes()); | 561 result.PutAll(PriorityCoreTypes()); |
562 | 562 |
563 // The following are low priority core types. | 563 // The following are low priority core types. |
564 result.Put(SYNCED_NOTIFICATIONS); | 564 result.Put(SYNCED_NOTIFICATIONS); |
565 result.Put(SYNCED_NOTIFICATION_APP_INFO); | 565 result.Put(SYNCED_NOTIFICATION_APP_INFO); |
566 result.Put(SUPERVISED_USER_SHARED_SETTINGS); | 566 result.Put(SUPERVISED_USER_SHARED_SETTINGS); |
567 result.Put(SUPERVISED_USER_WHITELISTS); | 567 result.Put(SUPERVISED_USER_WHITELISTS); |
568 | 568 |
569 return result; | 569 return result; |
570 } | 570 } |
571 | 571 |
572 ModelTypeSet PriorityCoreTypes() { | 572 ModelTypeSet PriorityCoreTypes() { |
573 syncer::ModelTypeSet result; | 573 ModelTypeSet result; |
574 result.PutAll(ControlTypes()); | 574 result.PutAll(ControlTypes()); |
575 | 575 |
576 // The following are non-control core types. | 576 // The following are non-control core types. |
577 result.Put(SUPERVISED_USERS); | 577 result.Put(SUPERVISED_USERS); |
578 result.Put(SUPERVISED_USER_SETTINGS); | 578 result.Put(SUPERVISED_USER_SETTINGS); |
579 | 579 |
580 return result; | 580 return result; |
581 } | 581 } |
582 | 582 |
583 const char* ModelTypeToString(ModelType model_type) { | 583 const char* ModelTypeToString(ModelType model_type) { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 if (working_copy.empty()) | 666 if (working_copy.empty()) |
667 break; | 667 break; |
668 std::string type_str; | 668 std::string type_str; |
669 size_t end = working_copy.find(','); | 669 size_t end = working_copy.find(','); |
670 if (end == std::string::npos) { | 670 if (end == std::string::npos) { |
671 end = working_copy.length() - 1; | 671 end = working_copy.length() - 1; |
672 type_str = working_copy; | 672 type_str = working_copy; |
673 } else { | 673 } else { |
674 type_str = working_copy.substr(0, end); | 674 type_str = working_copy.substr(0, end); |
675 } | 675 } |
676 syncer::ModelType type = ModelTypeFromString(type_str); | 676 ModelType type = ModelTypeFromString(type_str); |
677 if (IsRealDataType(type)) | 677 if (IsRealDataType(type)) |
678 model_types.Put(type); | 678 model_types.Put(type); |
679 working_copy = working_copy.substr(end + 1); | 679 working_copy = working_copy.substr(end + 1); |
680 } | 680 } |
681 return model_types; | 681 return model_types; |
682 } | 682 } |
683 | 683 |
684 std::unique_ptr<base::ListValue> ModelTypeSetToValue(ModelTypeSet model_types) { | 684 std::unique_ptr<base::ListValue> ModelTypeSetToValue(ModelTypeSet model_types) { |
685 std::unique_ptr<base::ListValue> value(new base::ListValue()); | 685 std::unique_ptr<base::ListValue> value(new base::ListValue()); |
686 for (ModelTypeSet::Iterator it = model_types.First(); it.Good(); it.Inc()) { | 686 for (ModelTypeSet::Iterator it = model_types.First(); it.Good(); it.Inc()) { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 bool TypeSupportsHierarchy(ModelType model_type) { | 765 bool TypeSupportsHierarchy(ModelType model_type) { |
766 // TODO(stanisc): crbug/438313: Should this also include TOP_LEVEL_FOLDER? | 766 // TODO(stanisc): crbug/438313: Should this also include TOP_LEVEL_FOLDER? |
767 return model_type == BOOKMARKS; | 767 return model_type == BOOKMARKS; |
768 } | 768 } |
769 | 769 |
770 bool TypeSupportsOrdering(ModelType model_type) { | 770 bool TypeSupportsOrdering(ModelType model_type) { |
771 return model_type == BOOKMARKS; | 771 return model_type == BOOKMARKS; |
772 } | 772 } |
773 | 773 |
774 } // namespace syncer | 774 } // namespace syncer |
OLD | NEW |