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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 // bitset value here at compile time, rather than performing an iteration | 322 // bitset value here at compile time, rather than performing an iteration |
323 // every time. | 323 // every time. |
324 for (int i = FIRST_USER_MODEL_TYPE; i <= LAST_USER_MODEL_TYPE; ++i) { | 324 for (int i = FIRST_USER_MODEL_TYPE; i <= LAST_USER_MODEL_TYPE; ++i) { |
325 set.Put(ModelTypeFromInt(i)); | 325 set.Put(ModelTypeFromInt(i)); |
326 } | 326 } |
327 return set; | 327 return set; |
328 } | 328 } |
329 | 329 |
330 ModelTypeSet UserSelectableTypes() { | 330 ModelTypeSet UserSelectableTypes() { |
331 ModelTypeSet set; | 331 ModelTypeSet set; |
332 set.Put(APPS); | 332 // Although the order doesn't technically matter here, it's clearer to keep |
| 333 // these in the same order as their definition in the ModelType enum. |
| 334 set.Put(BOOKMARKS); |
| 335 set.Put(PREFERENCES);; |
| 336 set.Put(PASSWORDS); |
333 set.Put(AUTOFILL); | 337 set.Put(AUTOFILL); |
334 set.Put(BOOKMARKS); | |
335 set.Put(EXTENSIONS); | |
336 set.Put(PASSWORDS); | |
337 set.Put(PREFERENCES); | |
338 set.Put(SESSIONS); | |
339 set.Put(THEMES); | 338 set.Put(THEMES); |
340 set.Put(TYPED_URLS); | 339 set.Put(TYPED_URLS); |
| 340 set.Put(EXTENSIONS); |
| 341 set.Put(APPS); |
| 342 set.Put(PROXY_TABS); |
341 return set; | 343 return set; |
342 } | 344 } |
343 | 345 |
344 bool IsUserSelectableType(ModelType model_type) { | 346 bool IsUserSelectableType(ModelType model_type) { |
345 return UserSelectableTypes().Has(model_type); | 347 return UserSelectableTypes().Has(model_type); |
346 } | 348 } |
347 | 349 |
348 ModelTypeSet EncryptableUserTypes() { | 350 ModelTypeSet EncryptableUserTypes() { |
349 ModelTypeSet encryptable_user_types = UserTypes(); | 351 ModelTypeSet encryptable_user_types = UserTypes(); |
350 // We never encrypt history delete directives. | 352 // We never encrypt history delete directives. |
(...skipping 17 matching lines...) Expand all Loading... |
368 } | 370 } |
369 | 371 |
370 // TODO(albertb): Re-enable this when the server supports it. | 372 // TODO(albertb): Re-enable this when the server supports it. |
371 set.Remove(PRIORITY_PREFERENCES); | 373 set.Remove(PRIORITY_PREFERENCES); |
372 | 374 |
373 return set; | 375 return set; |
374 } | 376 } |
375 | 377 |
376 ModelTypeSet ProxyTypes() { | 378 ModelTypeSet ProxyTypes() { |
377 ModelTypeSet set; | 379 ModelTypeSet set; |
378 // TODO(zea): add a TABS type here. | 380 set.Put(PROXY_TABS); |
379 return set; | 381 return set; |
380 } | 382 } |
381 | 383 |
382 bool IsControlType(ModelType model_type) { | 384 bool IsControlType(ModelType model_type) { |
383 return ControlTypes().Has(model_type); | 385 return ControlTypes().Has(model_type); |
384 } | 386 } |
385 | 387 |
386 const char* ModelTypeToString(ModelType model_type) { | 388 const char* ModelTypeToString(ModelType model_type) { |
387 // This is used in serialization routines as well as for displaying debug | 389 // This is used in serialization routines as well as for displaying debug |
388 // information. Do not attempt to change these string values unless you know | 390 // information. Do not attempt to change these string values unless you know |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 case EXPERIMENTS: | 433 case EXPERIMENTS: |
432 return "Experiments"; | 434 return "Experiments"; |
433 case PRIORITY_PREFERENCES: | 435 case PRIORITY_PREFERENCES: |
434 return "Priority Preferences"; | 436 return "Priority Preferences"; |
435 case DICTIONARY: | 437 case DICTIONARY: |
436 return "Dictionary"; | 438 return "Dictionary"; |
437 case FAVICON_IMAGES: | 439 case FAVICON_IMAGES: |
438 return "Favicon Images"; | 440 return "Favicon Images"; |
439 case FAVICON_TRACKING: | 441 case FAVICON_TRACKING: |
440 return "Favicon Tracking"; | 442 return "Favicon Tracking"; |
| 443 case PROXY_TABS: |
| 444 return "Tabs"; |
441 default: | 445 default: |
442 break; | 446 break; |
443 } | 447 } |
444 NOTREACHED() << "No known extension for model type."; | 448 NOTREACHED() << "No known extension for model type."; |
445 return "INVALID"; | 449 return "INVALID"; |
446 } | 450 } |
447 | 451 |
448 base::StringValue* ModelTypeToValue(ModelType model_type) { | 452 base::StringValue* ModelTypeToValue(ModelType model_type) { |
449 if (model_type >= FIRST_REAL_MODEL_TYPE) { | 453 if (model_type >= FIRST_REAL_MODEL_TYPE) { |
450 return new base::StringValue(ModelTypeToString(model_type)); | 454 return new base::StringValue(ModelTypeToString(model_type)); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 else if (model_type_string == "Experiments") | 516 else if (model_type_string == "Experiments") |
513 return EXPERIMENTS; | 517 return EXPERIMENTS; |
514 else if (model_type_string == "Priority Preferences") | 518 else if (model_type_string == "Priority Preferences") |
515 return PRIORITY_PREFERENCES; | 519 return PRIORITY_PREFERENCES; |
516 else if (model_type_string == "Dictionary") | 520 else if (model_type_string == "Dictionary") |
517 return DICTIONARY; | 521 return DICTIONARY; |
518 else if (model_type_string == "Favicon Images") | 522 else if (model_type_string == "Favicon Images") |
519 return FAVICON_IMAGES; | 523 return FAVICON_IMAGES; |
520 else if (model_type_string == "Favicon Tracking") | 524 else if (model_type_string == "Favicon Tracking") |
521 return FAVICON_TRACKING; | 525 return FAVICON_TRACKING; |
| 526 else if (model_type_string == "Tabs") |
| 527 return PROXY_TABS; |
522 else | 528 else |
523 NOTREACHED() << "No known model type corresponding to " | 529 NOTREACHED() << "No known model type corresponding to " |
524 << model_type_string << "."; | 530 << model_type_string << "."; |
525 return UNSPECIFIED; | 531 return UNSPECIFIED; |
526 } | 532 } |
527 | 533 |
528 std::string ModelTypeSetToString(ModelTypeSet model_types) { | 534 std::string ModelTypeSetToString(ModelTypeSet model_types) { |
529 std::string result; | 535 std::string result; |
530 for (ModelTypeSet::Iterator it = model_types.First(); it.Good(); it.Inc()) { | 536 for (ModelTypeSet::Iterator it = model_types.First(); it.Good(); it.Inc()) { |
531 if (!result.empty()) { | 537 if (!result.empty()) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 case EXPERIMENTS: | 604 case EXPERIMENTS: |
599 return "google_chrome_experiments"; | 605 return "google_chrome_experiments"; |
600 case PRIORITY_PREFERENCES: | 606 case PRIORITY_PREFERENCES: |
601 return "google_chrome_priority_preferences"; | 607 return "google_chrome_priority_preferences"; |
602 case DICTIONARY: | 608 case DICTIONARY: |
603 return "google_chrome_dictionary"; | 609 return "google_chrome_dictionary"; |
604 case FAVICON_IMAGES: | 610 case FAVICON_IMAGES: |
605 return "google_chrome_favicon_images"; | 611 return "google_chrome_favicon_images"; |
606 case FAVICON_TRACKING: | 612 case FAVICON_TRACKING: |
607 return "google_chrome_favicon_tracking"; | 613 return "google_chrome_favicon_tracking"; |
| 614 case PROXY_TABS: |
| 615 return std::string(); |
608 default: | 616 default: |
609 break; | 617 break; |
610 } | 618 } |
611 NOTREACHED() << "No known extension for model type."; | 619 NOTREACHED() << "No known extension for model type."; |
612 return "INVALID"; | 620 return "INVALID"; |
613 } | 621 } |
614 | 622 |
615 // TODO(akalin): Figure out a better way to do these mappings. | 623 // TODO(akalin): Figure out a better way to do these mappings. |
616 // Note: Do not include proxy types in this list. They should never receive | 624 // Note: Do not include proxy types in this list. They should never receive |
617 // or trigger notifications. | 625 // or trigger notifications. |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 | 807 |
800 bool IsRealDataType(ModelType model_type) { | 808 bool IsRealDataType(ModelType model_type) { |
801 return model_type >= FIRST_REAL_MODEL_TYPE && model_type < MODEL_TYPE_COUNT; | 809 return model_type >= FIRST_REAL_MODEL_TYPE && model_type < MODEL_TYPE_COUNT; |
802 } | 810 } |
803 | 811 |
804 bool IsActOnceDataType(ModelType model_type) { | 812 bool IsActOnceDataType(ModelType model_type) { |
805 return model_type == HISTORY_DELETE_DIRECTIVES; | 813 return model_type == HISTORY_DELETE_DIRECTIVES; |
806 } | 814 } |
807 | 815 |
808 } // namespace syncer | 816 } // namespace syncer |
OLD | NEW |