Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(362)

Side by Side Diff: components/sync/syncable/model_type.cc

Issue 2306763002: Add PrinterSpecifics to the sync protos. (Closed)
Patch Set: rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 {APP_LIST, "APP_LIST", "app_list", "App List", 126 {APP_LIST, "APP_LIST", "app_list", "App List",
127 sync_pb::EntitySpecifics::kAppListFieldNumber, 29}, 127 sync_pb::EntitySpecifics::kAppListFieldNumber, 29},
128 {WIFI_CREDENTIALS, "WIFI_CREDENTIAL", "wifi_credentials", 128 {WIFI_CREDENTIALS, "WIFI_CREDENTIAL", "wifi_credentials",
129 "WiFi Credentials", sync_pb::EntitySpecifics::kWifiCredentialFieldNumber, 129 "WiFi Credentials", sync_pb::EntitySpecifics::kWifiCredentialFieldNumber,
130 32}, 130 32},
131 {SUPERVISED_USER_WHITELISTS, "MANAGED_USER_WHITELIST", 131 {SUPERVISED_USER_WHITELISTS, "MANAGED_USER_WHITELIST",
132 "managed_user_whitelists", "Managed User Whitelists", 132 "managed_user_whitelists", "Managed User Whitelists",
133 sync_pb::EntitySpecifics::kManagedUserWhitelistFieldNumber, 33}, 133 sync_pb::EntitySpecifics::kManagedUserWhitelistFieldNumber, 33},
134 {ARC_PACKAGE, "ARC_PACKAGE", "arc_package", "Arc Package", 134 {ARC_PACKAGE, "ARC_PACKAGE", "arc_package", "Arc Package",
135 sync_pb::EntitySpecifics::kArcPackageFieldNumber, 36}, 135 sync_pb::EntitySpecifics::kArcPackageFieldNumber, 36},
136 {PRINTER, "PRINTER", "printer", "Printer",
Nicolas Zea 2016/09/07 00:18:04 Given the other change to make the enum be PRINTER
skau 2016/09/09 19:02:15 Done.
137 sync_pb::EntitySpecifics::kPrinterFieldNumber, 37},
136 {PROXY_TABS, "", "", "Tabs", -1, 25}, 138 {PROXY_TABS, "", "", "Tabs", -1, 25},
137 {NIGORI, "NIGORI", "nigori", "Encryption keys", 139 {NIGORI, "NIGORI", "nigori", "Encryption keys",
138 sync_pb::EntitySpecifics::kNigoriFieldNumber, 17}, 140 sync_pb::EntitySpecifics::kNigoriFieldNumber, 17},
139 {EXPERIMENTS, "EXPERIMENTS", "experiments", "Experiments", 141 {EXPERIMENTS, "EXPERIMENTS", "experiments", "Experiments",
140 sync_pb::EntitySpecifics::kExperimentsFieldNumber, 19}, 142 sync_pb::EntitySpecifics::kExperimentsFieldNumber, 19},
141 }; 143 };
142 144
143 static_assert(arraysize(kModelTypeInfoMap) == MODEL_TYPE_COUNT, 145 static_assert(arraysize(kModelTypeInfoMap) == MODEL_TYPE_COUNT,
144 "kModelTypeInfoMap should have MODEL_TYPE_COUNT elements"); 146 "kModelTypeInfoMap should have MODEL_TYPE_COUNT elements");
145 147
146 // Notes: 148 // Notes:
147 // 1) This list must contain exactly the same elements as the set returned by 149 // 1) This list must contain exactly the same elements as the set returned by
148 // UserSelectableTypes(). 150 // UserSelectableTypes().
149 // 2) This list must be in the same order as the respective values in the 151 // 2) This list must be in the same order as the respective values in the
150 // ModelType enum. 152 // ModelType enum.
151 const char* kUserSelectableDataTypeNames[] = { 153 const char* kUserSelectableDataTypeNames[] = {
152 "bookmarks", "preferences", "passwords", "autofill", "themes", 154 "bookmarks", "preferences", "passwords", "autofill", "themes",
153 "typedUrls", "extensions", "apps", "tabs", 155 "typedUrls", "extensions", "apps", "tabs",
154 }; 156 };
155 157
156 static_assert( 158 static_assert(
157 37 == MODEL_TYPE_COUNT, 159 38 == MODEL_TYPE_COUNT,
158 "update kUserSelectableDataTypeName to match UserSelectableTypes"); 160 "update kUserSelectableDataTypeName to match UserSelectableTypes");
159 161
160 void AddDefaultFieldValue(ModelType datatype, 162 void AddDefaultFieldValue(ModelType datatype,
161 sync_pb::EntitySpecifics* specifics) { 163 sync_pb::EntitySpecifics* specifics) {
162 if (!ProtocolTypes().Has(datatype)) { 164 if (!ProtocolTypes().Has(datatype)) {
163 NOTREACHED() << "Only protocol types have field values."; 165 NOTREACHED() << "Only protocol types have field values.";
164 return; 166 return;
165 } 167 }
166 switch (datatype) { 168 switch (datatype) {
167 case BOOKMARKS: 169 case BOOKMARKS:
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 break; 231 break;
230 case SYNCED_NOTIFICATION_APP_INFO: 232 case SYNCED_NOTIFICATION_APP_INFO:
231 specifics->mutable_synced_notification_app_info(); 233 specifics->mutable_synced_notification_app_info();
232 break; 234 break;
233 case DEVICE_INFO: 235 case DEVICE_INFO:
234 specifics->mutable_device_info(); 236 specifics->mutable_device_info();
235 break; 237 break;
236 case EXPERIMENTS: 238 case EXPERIMENTS:
237 specifics->mutable_experiments(); 239 specifics->mutable_experiments();
238 break; 240 break;
241 case PRINTER:
242 specifics->mutable_printer();
243 break;
239 case PRIORITY_PREFERENCES: 244 case PRIORITY_PREFERENCES:
240 specifics->mutable_priority_preference(); 245 specifics->mutable_priority_preference();
241 break; 246 break;
242 case DICTIONARY: 247 case DICTIONARY:
243 specifics->mutable_dictionary(); 248 specifics->mutable_dictionary();
244 break; 249 break;
245 case FAVICON_IMAGES: 250 case FAVICON_IMAGES:
246 specifics->mutable_favicon_image(); 251 specifics->mutable_favicon_image();
247 break; 252 break;
248 case FAVICON_TRACKING: 253 case FAVICON_TRACKING:
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 398
394 if (specifics.has_device_info()) 399 if (specifics.has_device_info())
395 return DEVICE_INFO; 400 return DEVICE_INFO;
396 401
397 if (specifics.has_experiments()) 402 if (specifics.has_experiments())
398 return EXPERIMENTS; 403 return EXPERIMENTS;
399 404
400 if (specifics.has_priority_preference()) 405 if (specifics.has_priority_preference())
401 return PRIORITY_PREFERENCES; 406 return PRIORITY_PREFERENCES;
402 407
408 if (specifics.has_printer())
409 return PRINTER;
410
403 if (specifics.has_dictionary()) 411 if (specifics.has_dictionary())
404 return DICTIONARY; 412 return DICTIONARY;
405 413
406 if (specifics.has_favicon_image()) 414 if (specifics.has_favicon_image())
407 return FAVICON_IMAGES; 415 return FAVICON_IMAGES;
408 416
409 if (specifics.has_favicon_tracking()) 417 if (specifics.has_favicon_tracking())
410 return FAVICON_TRACKING; 418 return FAVICON_TRACKING;
411 419
412 if (specifics.has_managed_user_setting()) 420 if (specifics.has_managed_user_setting())
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 bool TypeSupportsHierarchy(ModelType model_type) { 756 bool TypeSupportsHierarchy(ModelType model_type) {
749 // TODO(stanisc): crbug/438313: Should this also include TOP_LEVEL_FOLDER? 757 // TODO(stanisc): crbug/438313: Should this also include TOP_LEVEL_FOLDER?
750 return model_type == BOOKMARKS; 758 return model_type == BOOKMARKS;
751 } 759 }
752 760
753 bool TypeSupportsOrdering(ModelType model_type) { 761 bool TypeSupportsOrdering(ModelType model_type) {
754 return model_type == BOOKMARKS; 762 return model_type == BOOKMARKS;
755 } 763 }
756 764
757 } // namespace syncer 765 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698