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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
334 } | 334 } |
335 | 335 |
336 // TODO(albertb): Re-enable this when the server supports it. | 336 // TODO(albertb): Re-enable this when the server supports it. |
337 set.Remove(PRIORITY_PREFERENCES); | 337 set.Remove(PRIORITY_PREFERENCES); |
338 | 338 |
339 return set; | 339 return set; |
340 } | 340 } |
341 | 341 |
342 ModelTypeSet ProxyTypes() { | 342 ModelTypeSet ProxyTypes() { |
343 ModelTypeSet set; | 343 ModelTypeSet set; |
344 // TODO(zea): add a TABS type here. | 344 set.Put(TABS); |
345 return set; | 345 return set; |
346 } | 346 } |
347 | 347 |
348 bool IsControlType(ModelType model_type) { | 348 bool IsControlType(ModelType model_type) { |
349 return ControlTypes().Has(model_type); | 349 return ControlTypes().Has(model_type); |
350 } | 350 } |
351 | 351 |
352 const char* ModelTypeToString(ModelType model_type) { | 352 const char* ModelTypeToString(ModelType model_type) { |
353 // This is used in serialization routines as well as for displaying debug | 353 // This is used in serialization routines as well as for displaying debug |
354 // information. Do not attempt to change these string values unless you know | 354 // information. Do not attempt to change these string values unless you know |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
393 case SYNCED_NOTIFICATIONS: | 393 case SYNCED_NOTIFICATIONS: |
394 return "Synced Notifications"; | 394 return "Synced Notifications"; |
395 case DEVICE_INFO: | 395 case DEVICE_INFO: |
396 return "Device Info"; | 396 return "Device Info"; |
397 case EXPERIMENTS: | 397 case EXPERIMENTS: |
398 return "Experiments"; | 398 return "Experiments"; |
399 case PRIORITY_PREFERENCES: | 399 case PRIORITY_PREFERENCES: |
400 return "Priority Preferences"; | 400 return "Priority Preferences"; |
401 case DICTIONARY: | 401 case DICTIONARY: |
402 return "Dictionary"; | 402 return "Dictionary"; |
403 case TABS: | |
404 return "Tabs"; | |
403 default: | 405 default: |
404 break; | 406 break; |
405 } | 407 } |
406 NOTREACHED() << "No known extension for model type."; | 408 NOTREACHED() << "No known extension for model type."; |
407 return "INVALID"; | 409 return "INVALID"; |
408 } | 410 } |
409 | 411 |
410 StringValue* ModelTypeToValue(ModelType model_type) { | 412 StringValue* ModelTypeToValue(ModelType model_type) { |
411 if (model_type >= FIRST_REAL_MODEL_TYPE) { | 413 if (model_type >= FIRST_REAL_MODEL_TYPE) { |
412 return Value::CreateStringValue(ModelTypeToString(model_type)); | 414 return Value::CreateStringValue(ModelTypeToString(model_type)); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
470 else if (model_type_string == "Synced Notifications") | 472 else if (model_type_string == "Synced Notifications") |
471 return SYNCED_NOTIFICATIONS; | 473 return SYNCED_NOTIFICATIONS; |
472 else if (model_type_string == "Device Info") | 474 else if (model_type_string == "Device Info") |
473 return DEVICE_INFO; | 475 return DEVICE_INFO; |
474 else if (model_type_string == "Experiments") | 476 else if (model_type_string == "Experiments") |
475 return EXPERIMENTS; | 477 return EXPERIMENTS; |
476 else if (model_type_string == "Priority Preferences") | 478 else if (model_type_string == "Priority Preferences") |
477 return PRIORITY_PREFERENCES; | 479 return PRIORITY_PREFERENCES; |
478 else if (model_type_string == "Dictionary") | 480 else if (model_type_string == "Dictionary") |
479 return DICTIONARY; | 481 return DICTIONARY; |
482 else if (model_type_string == "Tabs") | |
483 return TABS; | |
480 else | 484 else |
481 NOTREACHED() << "No known model type corresponding to " | 485 NOTREACHED() << "No known model type corresponding to " |
482 << model_type_string << "."; | 486 << model_type_string << "."; |
483 return UNSPECIFIED; | 487 return UNSPECIFIED; |
484 } | 488 } |
485 | 489 |
486 std::string ModelTypeSetToString(ModelTypeSet model_types) { | 490 std::string ModelTypeSetToString(ModelTypeSet model_types) { |
487 std::string result; | 491 std::string result; |
488 for (ModelTypeSet::Iterator it = model_types.First(); it.Good(); it.Inc()) { | 492 for (ModelTypeSet::Iterator it = model_types.First(); it.Good(); it.Inc()) { |
489 if (!result.empty()) { | 493 if (!result.empty()) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
552 case SYNCED_NOTIFICATIONS: | 556 case SYNCED_NOTIFICATIONS: |
553 return "google_chrome_synced_notifications"; | 557 return "google_chrome_synced_notifications"; |
554 case DEVICE_INFO: | 558 case DEVICE_INFO: |
555 return "google_chrome_device_info"; | 559 return "google_chrome_device_info"; |
556 case EXPERIMENTS: | 560 case EXPERIMENTS: |
557 return "google_chrome_experiments"; | 561 return "google_chrome_experiments"; |
558 case PRIORITY_PREFERENCES: | 562 case PRIORITY_PREFERENCES: |
559 return "google_chrome_priority_preferences"; | 563 return "google_chrome_priority_preferences"; |
560 case DICTIONARY: | 564 case DICTIONARY: |
561 return "google_chrome_dictionary"; | 565 return "google_chrome_dictionary"; |
566 case TABS: | |
567 return ""; | |
tim (not reviewing)
2013/02/09 01:23:59
nit - prefer std::string()
Nicolas Zea
2013/02/12 23:44:49
Done.
| |
562 default: | 568 default: |
563 break; | 569 break; |
564 } | 570 } |
565 NOTREACHED() << "No known extension for model type."; | 571 NOTREACHED() << "No known extension for model type."; |
566 return "INVALID"; | 572 return "INVALID"; |
567 } | 573 } |
568 | 574 |
569 // TODO(akalin): Figure out a better way to do these mappings. | 575 // TODO(akalin): Figure out a better way to do these mappings. |
570 // Note: Do not include proxy types in this list. They should never receive | 576 // Note: Do not include proxy types in this list. They should never receive |
571 // or trigger notifications. | 577 // or trigger notifications. |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
735 } | 741 } |
736 *model_type = UNSPECIFIED; | 742 *model_type = UNSPECIFIED; |
737 return false; | 743 return false; |
738 } | 744 } |
739 | 745 |
740 bool IsRealDataType(ModelType model_type) { | 746 bool IsRealDataType(ModelType model_type) { |
741 return model_type >= FIRST_REAL_MODEL_TYPE && model_type < MODEL_TYPE_COUNT; | 747 return model_type >= FIRST_REAL_MODEL_TYPE && model_type < MODEL_TYPE_COUNT; |
742 } | 748 } |
743 | 749 |
744 } // namespace syncer | 750 } // namespace syncer |
OLD | NEW |