| 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 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 const char kExperimentsNotificationType[] = "EXPERIMENTS"; | 908 const char kExperimentsNotificationType[] = "EXPERIMENTS"; |
| 909 const char kPriorityPreferenceNotificationType[] = "PRIORITY_PREFERENCE"; | 909 const char kPriorityPreferenceNotificationType[] = "PRIORITY_PREFERENCE"; |
| 910 const char kDictionaryNotificationType[] = "DICTIONARY"; | 910 const char kDictionaryNotificationType[] = "DICTIONARY"; |
| 911 const char kFaviconImageNotificationType[] = "FAVICON_IMAGE"; | 911 const char kFaviconImageNotificationType[] = "FAVICON_IMAGE"; |
| 912 const char kFaviconTrackingNotificationType[] = "FAVICON_TRACKING"; | 912 const char kFaviconTrackingNotificationType[] = "FAVICON_TRACKING"; |
| 913 const char kSupervisedUserSettingNotificationType[] = "MANAGED_USER_SETTING"; | 913 const char kSupervisedUserSettingNotificationType[] = "MANAGED_USER_SETTING"; |
| 914 const char kSupervisedUserNotificationType[] = "MANAGED_USER"; | 914 const char kSupervisedUserNotificationType[] = "MANAGED_USER"; |
| 915 const char kSupervisedUserSharedSettingNotificationType[] = | 915 const char kSupervisedUserSharedSettingNotificationType[] = |
| 916 "MANAGED_USER_SHARED_SETTING"; | 916 "MANAGED_USER_SHARED_SETTING"; |
| 917 const char kArticleNotificationType[] = "ARTICLE"; | 917 const char kArticleNotificationType[] = "ARTICLE"; |
| 918 const char kWifiCredentialNotificationType[] = "WIFI_CREDENTIAL"; |
| 918 } // namespace | 919 } // namespace |
| 919 | 920 |
| 920 bool RealModelTypeToNotificationType(ModelType model_type, | 921 bool RealModelTypeToNotificationType(ModelType model_type, |
| 921 std::string* notification_type) { | 922 std::string* notification_type) { |
| 922 switch (model_type) { | 923 switch (model_type) { |
| 923 case BOOKMARKS: | 924 case BOOKMARKS: |
| 924 *notification_type = kBookmarkNotificationType; | 925 *notification_type = kBookmarkNotificationType; |
| 925 return true; | 926 return true; |
| 926 case PREFERENCES: | 927 case PREFERENCES: |
| 927 *notification_type = kPreferenceNotificationType; | 928 *notification_type = kPreferenceNotificationType; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1000 return true; | 1001 return true; |
| 1001 case SUPERVISED_USERS: | 1002 case SUPERVISED_USERS: |
| 1002 *notification_type = kSupervisedUserNotificationType; | 1003 *notification_type = kSupervisedUserNotificationType; |
| 1003 return true; | 1004 return true; |
| 1004 case SUPERVISED_USER_SHARED_SETTINGS: | 1005 case SUPERVISED_USER_SHARED_SETTINGS: |
| 1005 *notification_type = kSupervisedUserSharedSettingNotificationType; | 1006 *notification_type = kSupervisedUserSharedSettingNotificationType; |
| 1006 return true; | 1007 return true; |
| 1007 case ARTICLES: | 1008 case ARTICLES: |
| 1008 *notification_type = kArticleNotificationType; | 1009 *notification_type = kArticleNotificationType; |
| 1009 return true; | 1010 return true; |
| 1011 case WIFI_CREDENTIALS: |
| 1012 *notification_type = kWifiCredentialNotificationType; |
| 1013 return true; |
| 1010 default: | 1014 default: |
| 1011 break; | 1015 break; |
| 1012 } | 1016 } |
| 1013 notification_type->clear(); | 1017 notification_type->clear(); |
| 1014 return false; | 1018 return false; |
| 1015 } | 1019 } |
| 1016 | 1020 |
| 1017 bool NotificationTypeToRealModelType(const std::string& notification_type, | 1021 bool NotificationTypeToRealModelType(const std::string& notification_type, |
| 1018 ModelType* model_type) { | 1022 ModelType* model_type) { |
| 1019 if (notification_type == kBookmarkNotificationType) { | 1023 if (notification_type == kBookmarkNotificationType) { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1097 } else if (notification_type == kSupervisedUserNotificationType) { | 1101 } else if (notification_type == kSupervisedUserNotificationType) { |
| 1098 *model_type = SUPERVISED_USERS; | 1102 *model_type = SUPERVISED_USERS; |
| 1099 return true; | 1103 return true; |
| 1100 } else if (notification_type == | 1104 } else if (notification_type == |
| 1101 kSupervisedUserSharedSettingNotificationType) { | 1105 kSupervisedUserSharedSettingNotificationType) { |
| 1102 *model_type = SUPERVISED_USER_SHARED_SETTINGS; | 1106 *model_type = SUPERVISED_USER_SHARED_SETTINGS; |
| 1103 return true; | 1107 return true; |
| 1104 } else if (notification_type == kArticleNotificationType) { | 1108 } else if (notification_type == kArticleNotificationType) { |
| 1105 *model_type = ARTICLES; | 1109 *model_type = ARTICLES; |
| 1106 return true; | 1110 return true; |
| 1111 } else if (notification_type == kWifiCredentialNotificationType) { |
| 1112 *model_type = WIFI_CREDENTIALS; |
| 1113 return true; |
| 1107 } | 1114 } |
| 1108 *model_type = UNSPECIFIED; | 1115 *model_type = UNSPECIFIED; |
| 1109 return false; | 1116 return false; |
| 1110 } | 1117 } |
| 1111 | 1118 |
| 1112 bool IsRealDataType(ModelType model_type) { | 1119 bool IsRealDataType(ModelType model_type) { |
| 1113 return model_type >= FIRST_REAL_MODEL_TYPE && model_type < MODEL_TYPE_COUNT; | 1120 return model_type >= FIRST_REAL_MODEL_TYPE && model_type < MODEL_TYPE_COUNT; |
| 1114 } | 1121 } |
| 1115 | 1122 |
| 1116 bool IsProxyType(ModelType model_type) { | 1123 bool IsProxyType(ModelType model_type) { |
| 1117 return model_type >= FIRST_PROXY_TYPE && model_type <= LAST_PROXY_TYPE; | 1124 return model_type >= FIRST_PROXY_TYPE && model_type <= LAST_PROXY_TYPE; |
| 1118 } | 1125 } |
| 1119 | 1126 |
| 1120 bool IsActOnceDataType(ModelType model_type) { | 1127 bool IsActOnceDataType(ModelType model_type) { |
| 1121 return model_type == HISTORY_DELETE_DIRECTIVES; | 1128 return model_type == HISTORY_DELETE_DIRECTIVES; |
| 1122 } | 1129 } |
| 1123 | 1130 |
| 1124 } // namespace syncer | 1131 } // namespace syncer |
| OLD | NEW |