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 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 const char kDictionaryNotificationType[] = "DICTIONARY"; | 930 const char kDictionaryNotificationType[] = "DICTIONARY"; |
931 const char kFaviconImageNotificationType[] = "FAVICON_IMAGE"; | 931 const char kFaviconImageNotificationType[] = "FAVICON_IMAGE"; |
932 const char kFaviconTrackingNotificationType[] = "FAVICON_TRACKING"; | 932 const char kFaviconTrackingNotificationType[] = "FAVICON_TRACKING"; |
933 const char kSupervisedUserSettingNotificationType[] = "MANAGED_USER_SETTING"; | 933 const char kSupervisedUserSettingNotificationType[] = "MANAGED_USER_SETTING"; |
934 const char kSupervisedUserNotificationType[] = "MANAGED_USER"; | 934 const char kSupervisedUserNotificationType[] = "MANAGED_USER"; |
935 const char kSupervisedUserSharedSettingNotificationType[] = | 935 const char kSupervisedUserSharedSettingNotificationType[] = |
936 "MANAGED_USER_SHARED_SETTING"; | 936 "MANAGED_USER_SHARED_SETTING"; |
937 const char kSupervisedUserWhitelistNotificationType[] = | 937 const char kSupervisedUserWhitelistNotificationType[] = |
938 "MANAGED_USER_WHITELIST"; | 938 "MANAGED_USER_WHITELIST"; |
939 const char kArticleNotificationType[] = "ARTICLE"; | 939 const char kArticleNotificationType[] = "ARTICLE"; |
| 940 const char kWifiCredentialNotificationType[] = "WIFI_CREDENTIAL"; |
940 } // namespace | 941 } // namespace |
941 | 942 |
942 bool RealModelTypeToNotificationType(ModelType model_type, | 943 bool RealModelTypeToNotificationType(ModelType model_type, |
943 std::string* notification_type) { | 944 std::string* notification_type) { |
944 switch (model_type) { | 945 switch (model_type) { |
945 case BOOKMARKS: | 946 case BOOKMARKS: |
946 *notification_type = kBookmarkNotificationType; | 947 *notification_type = kBookmarkNotificationType; |
947 return true; | 948 return true; |
948 case PREFERENCES: | 949 case PREFERENCES: |
949 *notification_type = kPreferenceNotificationType; | 950 *notification_type = kPreferenceNotificationType; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1025 return true; | 1026 return true; |
1026 case SUPERVISED_USER_SHARED_SETTINGS: | 1027 case SUPERVISED_USER_SHARED_SETTINGS: |
1027 *notification_type = kSupervisedUserSharedSettingNotificationType; | 1028 *notification_type = kSupervisedUserSharedSettingNotificationType; |
1028 return true; | 1029 return true; |
1029 case SUPERVISED_USER_WHITELISTS: | 1030 case SUPERVISED_USER_WHITELISTS: |
1030 *notification_type = kSupervisedUserWhitelistNotificationType; | 1031 *notification_type = kSupervisedUserWhitelistNotificationType; |
1031 return true; | 1032 return true; |
1032 case ARTICLES: | 1033 case ARTICLES: |
1033 *notification_type = kArticleNotificationType; | 1034 *notification_type = kArticleNotificationType; |
1034 return true; | 1035 return true; |
| 1036 case WIFI_CREDENTIALS: |
| 1037 *notification_type = kWifiCredentialNotificationType; |
| 1038 return true; |
1035 default: | 1039 default: |
1036 break; | 1040 break; |
1037 } | 1041 } |
1038 notification_type->clear(); | 1042 notification_type->clear(); |
1039 return false; | 1043 return false; |
1040 } | 1044 } |
1041 | 1045 |
1042 bool NotificationTypeToRealModelType(const std::string& notification_type, | 1046 bool NotificationTypeToRealModelType(const std::string& notification_type, |
1043 ModelType* model_type) { | 1047 ModelType* model_type) { |
1044 if (notification_type == kBookmarkNotificationType) { | 1048 if (notification_type == kBookmarkNotificationType) { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1125 } else if (notification_type == | 1129 } else if (notification_type == |
1126 kSupervisedUserSharedSettingNotificationType) { | 1130 kSupervisedUserSharedSettingNotificationType) { |
1127 *model_type = SUPERVISED_USER_SHARED_SETTINGS; | 1131 *model_type = SUPERVISED_USER_SHARED_SETTINGS; |
1128 return true; | 1132 return true; |
1129 } else if (notification_type == kSupervisedUserWhitelistNotificationType) { | 1133 } else if (notification_type == kSupervisedUserWhitelistNotificationType) { |
1130 *model_type = SUPERVISED_USER_WHITELISTS; | 1134 *model_type = SUPERVISED_USER_WHITELISTS; |
1131 return true; | 1135 return true; |
1132 } else if (notification_type == kArticleNotificationType) { | 1136 } else if (notification_type == kArticleNotificationType) { |
1133 *model_type = ARTICLES; | 1137 *model_type = ARTICLES; |
1134 return true; | 1138 return true; |
| 1139 } else if (notification_type == kWifiCredentialNotificationType) { |
| 1140 *model_type = WIFI_CREDENTIALS; |
| 1141 return true; |
1135 } | 1142 } |
1136 *model_type = UNSPECIFIED; | 1143 *model_type = UNSPECIFIED; |
1137 return false; | 1144 return false; |
1138 } | 1145 } |
1139 | 1146 |
1140 bool IsRealDataType(ModelType model_type) { | 1147 bool IsRealDataType(ModelType model_type) { |
1141 return model_type >= FIRST_REAL_MODEL_TYPE && model_type < MODEL_TYPE_COUNT; | 1148 return model_type >= FIRST_REAL_MODEL_TYPE && model_type < MODEL_TYPE_COUNT; |
1142 } | 1149 } |
1143 | 1150 |
1144 bool IsProxyType(ModelType model_type) { | 1151 bool IsProxyType(ModelType model_type) { |
1145 return model_type >= FIRST_PROXY_TYPE && model_type <= LAST_PROXY_TYPE; | 1152 return model_type >= FIRST_PROXY_TYPE && model_type <= LAST_PROXY_TYPE; |
1146 } | 1153 } |
1147 | 1154 |
1148 bool IsActOnceDataType(ModelType model_type) { | 1155 bool IsActOnceDataType(ModelType model_type) { |
1149 return model_type == HISTORY_DELETE_DIRECTIVES; | 1156 return model_type == HISTORY_DELETE_DIRECTIVES; |
1150 } | 1157 } |
1151 | 1158 |
1152 } // namespace syncer | 1159 } // namespace syncer |
OLD | NEW |