| 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" |
| 11 #include "sync/protocol/app_specifics.pb.h" | 11 #include "sync/protocol/app_specifics.pb.h" |
| 12 #include "sync/protocol/autofill_specifics.pb.h" | 12 #include "sync/protocol/autofill_specifics.pb.h" |
| 13 #include "sync/protocol/bookmark_specifics.pb.h" | 13 #include "sync/protocol/bookmark_specifics.pb.h" |
| 14 #include "sync/protocol/extension_setting_specifics.pb.h" | 14 #include "sync/protocol/extension_setting_specifics.pb.h" |
| 15 #include "sync/protocol/extension_specifics.pb.h" | 15 #include "sync/protocol/extension_specifics.pb.h" |
| 16 #include "sync/protocol/nigori_specifics.pb.h" | 16 #include "sync/protocol/nigori_specifics.pb.h" |
| 17 #include "sync/protocol/password_specifics.pb.h" | 17 #include "sync/protocol/password_specifics.pb.h" |
| 18 #include "sync/protocol/preference_specifics.pb.h" | 18 #include "sync/protocol/preference_specifics.pb.h" |
| 19 #include "sync/protocol/search_engine_specifics.pb.h" | 19 #include "sync/protocol/search_engine_specifics.pb.h" |
| 20 #include "sync/protocol/session_specifics.pb.h" | 20 #include "sync/protocol/session_specifics.pb.h" |
| 21 #include "sync/protocol/sync.pb.h" | 21 #include "sync/protocol/sync.pb.h" |
| 22 #include "sync/protocol/theme_specifics.pb.h" | 22 #include "sync/protocol/theme_specifics.pb.h" |
| 23 #include "sync/protocol/typed_url_specifics.pb.h" | 23 #include "sync/protocol/typed_url_specifics.pb.h" |
| 24 #include "sync/syncable/syncable_proto_util.h" | 24 #include "sync/syncable/syncable_proto_util.h" |
| 25 | 25 |
| 26 namespace syncer { | 26 namespace syncer { |
| 27 | 27 |
| 28 struct ModelTypeInfo { |
| 29 const ModelType model_type; |
| 30 const char* const notification_type; // Model Type notification string. |
| 31 const char* const root_tag; // Root tag for Model Type |
| 32 const char* const model_type_string; // String value for Model Type |
| 33 const int specifics_field_number; // SpecificsFieldNumber for Model Type |
| 34 // Histogram value should be unique for the Model Type, Existing histogram |
| 35 // values should never be modified without updating "SyncModelTypes" enum in |
| 36 // histograms.xml to maintain backward compatibility. |
| 37 const int model_type_histogram_val; |
| 38 }; |
| 39 |
| 40 // Below struct entries are in the same order as their definition in the |
| 41 // ModelType enum. Don't forget to update the ModelType enum when you make |
| 42 // changes to this list. |
| 43 const ModelTypeInfo kModelTypeInfoMap[] = { |
| 44 {UNSPECIFIED, "", "", "Unspecified", -1, 0}, |
| 45 {TOP_LEVEL_FOLDER, "", "", "Top Level Folder", -1, 1}, |
| 46 {BOOKMARKS, "BOOKMARK", "bookmarks", "Bookmarks", |
| 47 sync_pb::EntitySpecifics::kBookmarkFieldNumber, 2}, |
| 48 {PREFERENCES, "PREFERENCE", "preferences", "Preferences", |
| 49 sync_pb::EntitySpecifics::kPreferenceFieldNumber, 3}, |
| 50 {PASSWORDS, "PASSWORD", "passwords", "Passwords", |
| 51 sync_pb::EntitySpecifics::kPasswordFieldNumber, 4}, |
| 52 {AUTOFILL_PROFILE, "AUTOFILL_PROFILE", "autofill_profiles", |
| 53 "Autofill Profiles", sync_pb::EntitySpecifics::kAutofillProfileFieldNumber, |
| 54 5}, |
| 55 {AUTOFILL, "AUTOFILL", "autofill", "Autofill", |
| 56 sync_pb::EntitySpecifics::kAutofillFieldNumber, 6}, |
| 57 {AUTOFILL_WALLET_DATA, "AUTOFILL_WALLET", "autofill_wallet", |
| 58 "Autofill Wallet", sync_pb::EntitySpecifics::kAutofillWalletFieldNumber, |
| 59 34}, |
| 60 {AUTOFILL_WALLET_METADATA, "AUTOFILL_WALLET_METADATA", |
| 61 "autofill_wallet_metadata", "Autofill Wallet Metadata", |
| 62 sync_pb::EntitySpecifics::kWalletMetadataFieldNumber, 35}, |
| 63 {THEMES, "THEME", "themes", "Themes", |
| 64 sync_pb::EntitySpecifics::kThemeFieldNumber, 7}, |
| 65 {TYPED_URLS, "TYPED_URL", "typed_urls", "Typed URLs", |
| 66 sync_pb::EntitySpecifics::kTypedUrlFieldNumber, 8}, |
| 67 {EXTENSIONS, "EXTENSION", "extensions", "Extensions", |
| 68 sync_pb::EntitySpecifics::kExtensionFieldNumber, 9}, |
| 69 {SEARCH_ENGINES, "SEARCH_ENGINE", "search_engines", "Search Engines", |
| 70 sync_pb::EntitySpecifics::kSearchEngineFieldNumber, 10}, |
| 71 {SESSIONS, "SESSION", "sessions", "Sessions", |
| 72 sync_pb::EntitySpecifics::kSessionFieldNumber, 11}, |
| 73 {APPS, "APP", "apps", "Apps", sync_pb::EntitySpecifics::kAppFieldNumber, |
| 74 12}, |
| 75 {APP_SETTINGS, "APP_SETTING", "app_settings", "App settings", |
| 76 sync_pb::EntitySpecifics::kAppSettingFieldNumber, 13}, |
| 77 {EXTENSION_SETTINGS, "EXTENSION_SETTING", "extension_settings", |
| 78 "Extension settings", |
| 79 sync_pb::EntitySpecifics::kExtensionSettingFieldNumber, 14}, |
| 80 {APP_NOTIFICATIONS, "APP_NOTIFICATION", "app_notifications", |
| 81 "App Notifications", sync_pb::EntitySpecifics::kAppNotificationFieldNumber, |
| 82 15}, |
| 83 {HISTORY_DELETE_DIRECTIVES, "HISTORY_DELETE_DIRECTIVE", |
| 84 "history_delete_directives", "History Delete Directives", |
| 85 sync_pb::EntitySpecifics::kHistoryDeleteDirectiveFieldNumber, 16}, |
| 86 {SYNCED_NOTIFICATIONS, "SYNCED_NOTIFICATION", "synced_notifications", |
| 87 "Synced Notifications", |
| 88 sync_pb::EntitySpecifics::kSyncedNotificationFieldNumber, 20}, |
| 89 {SYNCED_NOTIFICATION_APP_INFO, "SYNCED_NOTIFICATION_APP_INFO", |
| 90 "synced_notification_app_info", "Synced Notification App Info", |
| 91 sync_pb::EntitySpecifics::kSyncedNotificationAppInfoFieldNumber, 31}, |
| 92 {DICTIONARY, "DICTIONARY", "dictionary", "Dictionary", |
| 93 sync_pb::EntitySpecifics::kDictionaryFieldNumber, 22}, |
| 94 {FAVICON_IMAGES, "FAVICON_IMAGE", "favicon_images", "Favicon Images", |
| 95 sync_pb::EntitySpecifics::kFaviconImageFieldNumber, 23}, |
| 96 {FAVICON_TRACKING, "FAVICON_TRACKING", "favicon_tracking", |
| 97 "Favicon Tracking", sync_pb::EntitySpecifics::kFaviconTrackingFieldNumber, |
| 98 24}, |
| 99 {DEVICE_INFO, "DEVICE_INFO", "device_info", "Device Info", |
| 100 sync_pb::EntitySpecifics::kDeviceInfoFieldNumber, 18}, |
| 101 {PRIORITY_PREFERENCES, "PRIORITY_PREFERENCE", "priority_preferences", |
| 102 "Priority Preferences", |
| 103 sync_pb::EntitySpecifics::kPriorityPreferenceFieldNumber, 21}, |
| 104 {SUPERVISED_USER_SETTINGS, "MANAGED_USER_SETTING", "managed_user_settings", |
| 105 "Managed User Settings", |
| 106 sync_pb::EntitySpecifics::kManagedUserSettingFieldNumber, 26}, |
| 107 {SUPERVISED_USERS, "MANAGED_USER", "managed_users", "Managed Users", |
| 108 sync_pb::EntitySpecifics::kManagedUserFieldNumber, 27}, |
| 109 {SUPERVISED_USER_SHARED_SETTINGS, "MANAGED_USER_SHARED_SETTING", |
| 110 "managed_user_shared_settings", "Managed User Shared Settings", |
| 111 sync_pb::EntitySpecifics::kManagedUserSharedSettingFieldNumber, 30}, |
| 112 {ARTICLES, "ARTICLE", "articles", "Articles", |
| 113 sync_pb::EntitySpecifics::kArticleFieldNumber, 28}, |
| 114 {APP_LIST, "APP_LIST", "app_list", "App List", |
| 115 sync_pb::EntitySpecifics::kAppListFieldNumber, 29}, |
| 116 {WIFI_CREDENTIALS, "WIFI_CREDENTIAL", "wifi_credentials", |
| 117 "WiFi Credentials", sync_pb::EntitySpecifics::kWifiCredentialFieldNumber, |
| 118 32}, |
| 119 {SUPERVISED_USER_WHITELISTS, "MANAGED_USER_WHITELIST", |
| 120 "managed_user_whitelists", "Managed User Whitelists", |
| 121 sync_pb::EntitySpecifics::kManagedUserWhitelistFieldNumber, 33}, |
| 122 {PROXY_TABS, "", "", "Tabs", -1, 25}, |
| 123 {NIGORI, "NIGORI", "nigori", "Encryption keys", |
| 124 sync_pb::EntitySpecifics::kNigoriFieldNumber, 17}, |
| 125 {EXPERIMENTS, "EXPERIMENTS", "experiments", "Experiments", |
| 126 sync_pb::EntitySpecifics::kExperimentsFieldNumber, 19}, |
| 127 }; |
| 128 |
| 129 static_assert(arraysize(kModelTypeInfoMap) == MODEL_TYPE_COUNT, |
| 130 "kModelTypeInfoMap should have MODEL_TYPE_COUNT elements"); |
| 131 |
| 28 // Notes: | 132 // Notes: |
| 29 // 1) This list must contain exactly the same elements as the set returned by | 133 // 1) This list must contain exactly the same elements as the set returned by |
| 30 // UserSelectableTypes(). | 134 // UserSelectableTypes(). |
| 31 // 2) This list must be in the same order as the respective values in the | 135 // 2) This list must be in the same order as the respective values in the |
| 32 // ModelType enum. | 136 // ModelType enum. |
| 33 const char* kUserSelectableDataTypeNames[] = { | 137 const char* kUserSelectableDataTypeNames[] = { |
| 34 "bookmarks", | 138 "bookmarks", |
| 35 "preferences", | 139 "preferences", |
| 36 "passwords", | 140 "passwords", |
| 37 "autofill", | 141 "autofill", |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 iter.Inc()) { | 268 iter.Inc()) { |
| 165 if (GetSpecificsFieldNumberFromModelType(iter.Get()) == field_number) | 269 if (GetSpecificsFieldNumberFromModelType(iter.Get()) == field_number) |
| 166 return iter.Get(); | 270 return iter.Get(); |
| 167 } | 271 } |
| 168 return UNSPECIFIED; | 272 return UNSPECIFIED; |
| 169 } | 273 } |
| 170 | 274 |
| 171 int GetSpecificsFieldNumberFromModelType(ModelType model_type) { | 275 int GetSpecificsFieldNumberFromModelType(ModelType model_type) { |
| 172 DCHECK(ProtocolTypes().Has(model_type)) | 276 DCHECK(ProtocolTypes().Has(model_type)) |
| 173 << "Only protocol types have field values."; | 277 << "Only protocol types have field values."; |
| 174 switch (model_type) { | 278 if (ProtocolTypes().Has(model_type)) |
| 175 case BOOKMARKS: | 279 return kModelTypeInfoMap[model_type].specifics_field_number; |
| 176 return sync_pb::EntitySpecifics::kBookmarkFieldNumber; | 280 NOTREACHED() << "No known extension for model type."; |
| 177 case PASSWORDS: | 281 return 0; |
| 178 return sync_pb::EntitySpecifics::kPasswordFieldNumber; | |
| 179 case PREFERENCES: | |
| 180 return sync_pb::EntitySpecifics::kPreferenceFieldNumber; | |
| 181 case AUTOFILL: | |
| 182 return sync_pb::EntitySpecifics::kAutofillFieldNumber; | |
| 183 case AUTOFILL_PROFILE: | |
| 184 return sync_pb::EntitySpecifics::kAutofillProfileFieldNumber; | |
| 185 case AUTOFILL_WALLET_DATA: | |
| 186 return sync_pb::EntitySpecifics::kAutofillWalletFieldNumber; | |
| 187 case AUTOFILL_WALLET_METADATA: | |
| 188 return sync_pb::EntitySpecifics::kWalletMetadataFieldNumber; | |
| 189 case THEMES: | |
| 190 return sync_pb::EntitySpecifics::kThemeFieldNumber; | |
| 191 case TYPED_URLS: | |
| 192 return sync_pb::EntitySpecifics::kTypedUrlFieldNumber; | |
| 193 case EXTENSIONS: | |
| 194 return sync_pb::EntitySpecifics::kExtensionFieldNumber; | |
| 195 case NIGORI: | |
| 196 return sync_pb::EntitySpecifics::kNigoriFieldNumber; | |
| 197 case SEARCH_ENGINES: | |
| 198 return sync_pb::EntitySpecifics::kSearchEngineFieldNumber; | |
| 199 case SESSIONS: | |
| 200 return sync_pb::EntitySpecifics::kSessionFieldNumber; | |
| 201 case APPS: | |
| 202 return sync_pb::EntitySpecifics::kAppFieldNumber; | |
| 203 case APP_LIST: | |
| 204 return sync_pb::EntitySpecifics::kAppListFieldNumber; | |
| 205 case APP_SETTINGS: | |
| 206 return sync_pb::EntitySpecifics::kAppSettingFieldNumber; | |
| 207 case EXTENSION_SETTINGS: | |
| 208 return sync_pb::EntitySpecifics::kExtensionSettingFieldNumber; | |
| 209 case APP_NOTIFICATIONS: | |
| 210 return sync_pb::EntitySpecifics::kAppNotificationFieldNumber; | |
| 211 case HISTORY_DELETE_DIRECTIVES: | |
| 212 return sync_pb::EntitySpecifics::kHistoryDeleteDirectiveFieldNumber; | |
| 213 case SYNCED_NOTIFICATIONS: | |
| 214 return sync_pb::EntitySpecifics::kSyncedNotificationFieldNumber; | |
| 215 case SYNCED_NOTIFICATION_APP_INFO: | |
| 216 return sync_pb::EntitySpecifics::kSyncedNotificationAppInfoFieldNumber; | |
| 217 case DEVICE_INFO: | |
| 218 return sync_pb::EntitySpecifics::kDeviceInfoFieldNumber; | |
| 219 case EXPERIMENTS: | |
| 220 return sync_pb::EntitySpecifics::kExperimentsFieldNumber; | |
| 221 case PRIORITY_PREFERENCES: | |
| 222 return sync_pb::EntitySpecifics::kPriorityPreferenceFieldNumber; | |
| 223 case DICTIONARY: | |
| 224 return sync_pb::EntitySpecifics::kDictionaryFieldNumber; | |
| 225 case FAVICON_IMAGES: | |
| 226 return sync_pb::EntitySpecifics::kFaviconImageFieldNumber; | |
| 227 case FAVICON_TRACKING: | |
| 228 return sync_pb::EntitySpecifics::kFaviconTrackingFieldNumber; | |
| 229 case SUPERVISED_USER_SETTINGS: | |
| 230 return sync_pb::EntitySpecifics::kManagedUserSettingFieldNumber; | |
| 231 case SUPERVISED_USERS: | |
| 232 return sync_pb::EntitySpecifics::kManagedUserFieldNumber; | |
| 233 case SUPERVISED_USER_SHARED_SETTINGS: | |
| 234 return sync_pb::EntitySpecifics::kManagedUserSharedSettingFieldNumber; | |
| 235 case SUPERVISED_USER_WHITELISTS: | |
| 236 return sync_pb::EntitySpecifics::kManagedUserWhitelistFieldNumber; | |
| 237 case ARTICLES: | |
| 238 return sync_pb::EntitySpecifics::kArticleFieldNumber; | |
| 239 case WIFI_CREDENTIALS: | |
| 240 return sync_pb::EntitySpecifics::kWifiCredentialFieldNumber; | |
| 241 default: | |
| 242 NOTREACHED() << "No known extension for model type."; | |
| 243 return 0; | |
| 244 } | |
| 245 } | 282 } |
| 246 | 283 |
| 247 FullModelTypeSet ToFullModelTypeSet(ModelTypeSet in) { | 284 FullModelTypeSet ToFullModelTypeSet(ModelTypeSet in) { |
| 248 FullModelTypeSet out; | 285 FullModelTypeSet out; |
| 249 for (ModelTypeSet::Iterator i = in.First(); i.Good(); i.Inc()) { | 286 for (ModelTypeSet::Iterator i = in.First(); i.Good(); i.Inc()) { |
| 250 out.Put(i.Get()); | 287 out.Put(i.Get()); |
| 251 } | 288 } |
| 252 return out; | 289 return out; |
| 253 } | 290 } |
| 254 | 291 |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 result.Put(APP_SETTINGS); | 564 result.Put(APP_SETTINGS); |
| 528 result.Put(EXTENSION_SETTINGS); | 565 result.Put(EXTENSION_SETTINGS); |
| 529 result.Put(PRIORITY_PREFERENCES); | 566 result.Put(PRIORITY_PREFERENCES); |
| 530 return result; | 567 return result; |
| 531 } | 568 } |
| 532 | 569 |
| 533 const char* ModelTypeToString(ModelType model_type) { | 570 const char* ModelTypeToString(ModelType model_type) { |
| 534 // This is used in serialization routines as well as for displaying debug | 571 // This is used in serialization routines as well as for displaying debug |
| 535 // information. Do not attempt to change these string values unless you know | 572 // information. Do not attempt to change these string values unless you know |
| 536 // what you're doing. | 573 // what you're doing. |
| 537 switch (model_type) { | 574 if (model_type >= UNSPECIFIED && model_type < MODEL_TYPE_COUNT) |
| 538 case TOP_LEVEL_FOLDER: | 575 return kModelTypeInfoMap[model_type].model_type_string; |
| 539 return "Top Level Folder"; | |
| 540 case UNSPECIFIED: | |
| 541 return "Unspecified"; | |
| 542 case BOOKMARKS: | |
| 543 return "Bookmarks"; | |
| 544 case PREFERENCES: | |
| 545 return "Preferences"; | |
| 546 case PASSWORDS: | |
| 547 return "Passwords"; | |
| 548 case AUTOFILL: | |
| 549 return "Autofill"; | |
| 550 case THEMES: | |
| 551 return "Themes"; | |
| 552 case TYPED_URLS: | |
| 553 return "Typed URLs"; | |
| 554 case EXTENSIONS: | |
| 555 return "Extensions"; | |
| 556 case NIGORI: | |
| 557 return "Encryption keys"; | |
| 558 case SEARCH_ENGINES: | |
| 559 return "Search Engines"; | |
| 560 case SESSIONS: | |
| 561 return "Sessions"; | |
| 562 case APPS: | |
| 563 return "Apps"; | |
| 564 case APP_LIST: | |
| 565 return "App List"; | |
| 566 case AUTOFILL_PROFILE: | |
| 567 return "Autofill Profiles"; | |
| 568 case APP_SETTINGS: | |
| 569 return "App settings"; | |
| 570 case EXTENSION_SETTINGS: | |
| 571 return "Extension settings"; | |
| 572 case APP_NOTIFICATIONS: | |
| 573 return "App Notifications"; | |
| 574 case HISTORY_DELETE_DIRECTIVES: | |
| 575 return "History Delete Directives"; | |
| 576 case SYNCED_NOTIFICATIONS: | |
| 577 return "Synced Notifications"; | |
| 578 case SYNCED_NOTIFICATION_APP_INFO: | |
| 579 return "Synced Notification App Info"; | |
| 580 case DEVICE_INFO: | |
| 581 return "Device Info"; | |
| 582 case EXPERIMENTS: | |
| 583 return "Experiments"; | |
| 584 case PRIORITY_PREFERENCES: | |
| 585 return "Priority Preferences"; | |
| 586 case DICTIONARY: | |
| 587 return "Dictionary"; | |
| 588 case FAVICON_IMAGES: | |
| 589 return "Favicon Images"; | |
| 590 case FAVICON_TRACKING: | |
| 591 return "Favicon Tracking"; | |
| 592 case SUPERVISED_USER_SETTINGS: | |
| 593 return "Managed User Settings"; | |
| 594 case SUPERVISED_USERS: | |
| 595 return "Managed Users"; | |
| 596 case SUPERVISED_USER_SHARED_SETTINGS: | |
| 597 return "Managed User Shared Settings"; | |
| 598 case SUPERVISED_USER_WHITELISTS: | |
| 599 return "Managed User Whitelists"; | |
| 600 case ARTICLES: | |
| 601 return "Articles"; | |
| 602 case WIFI_CREDENTIALS: | |
| 603 return "WiFi Credentials"; | |
| 604 case PROXY_TABS: | |
| 605 return "Tabs"; | |
| 606 case AUTOFILL_WALLET_DATA: | |
| 607 return "Autofill Wallet"; | |
| 608 case AUTOFILL_WALLET_METADATA: | |
| 609 return "Autofill Wallet Metadata"; | |
| 610 default: | |
| 611 break; | |
| 612 } | |
| 613 NOTREACHED() << "No known extension for model type."; | 576 NOTREACHED() << "No known extension for model type."; |
| 614 return "INVALID"; | 577 return "INVALID"; |
| 615 } | 578 } |
| 616 | 579 |
| 617 // The normal rules about histograms apply here. Always append to the bottom of | 580 // The normal rules about histograms apply here. Always append to the bottom of |
| 618 // the list, and be careful to not reuse integer values that have already been | 581 // the list, and be careful to not reuse integer values that have already been |
| 619 // assigned. | 582 // assigned. |
| 620 // | 583 // |
| 621 // Don't forget to update the "SyncModelTypes" enum in histograms.xml when you | 584 // Don't forget to update the "SyncModelTypes" enum in histograms.xml when you |
| 622 // make changes to this list. | 585 // make changes to this list. |
| 623 int ModelTypeToHistogramInt(ModelType model_type) { | 586 int ModelTypeToHistogramInt(ModelType model_type) { |
| 624 switch (model_type) { | 587 if (model_type >= UNSPECIFIED && model_type < MODEL_TYPE_COUNT) |
| 625 case UNSPECIFIED: | 588 return kModelTypeInfoMap[model_type].model_type_histogram_val; |
| 626 return 0; | |
| 627 case TOP_LEVEL_FOLDER: | |
| 628 return 1; | |
| 629 case BOOKMARKS: | |
| 630 return 2; | |
| 631 case PREFERENCES: | |
| 632 return 3; | |
| 633 case PASSWORDS: | |
| 634 return 4; | |
| 635 case AUTOFILL_PROFILE: | |
| 636 return 5; | |
| 637 case AUTOFILL: | |
| 638 return 6; | |
| 639 case THEMES: | |
| 640 return 7; | |
| 641 case TYPED_URLS: | |
| 642 return 8; | |
| 643 case EXTENSIONS: | |
| 644 return 9; | |
| 645 case SEARCH_ENGINES: | |
| 646 return 10; | |
| 647 case SESSIONS: | |
| 648 return 11; | |
| 649 case APPS: | |
| 650 return 12; | |
| 651 case APP_SETTINGS: | |
| 652 return 13; | |
| 653 case EXTENSION_SETTINGS: | |
| 654 return 14; | |
| 655 case APP_NOTIFICATIONS: | |
| 656 return 15; | |
| 657 case HISTORY_DELETE_DIRECTIVES: | |
| 658 return 16; | |
| 659 case NIGORI: | |
| 660 return 17; | |
| 661 case DEVICE_INFO: | |
| 662 return 18; | |
| 663 case EXPERIMENTS: | |
| 664 return 19; | |
| 665 case SYNCED_NOTIFICATIONS: | |
| 666 return 20; | |
| 667 case PRIORITY_PREFERENCES: | |
| 668 return 21; | |
| 669 case DICTIONARY: | |
| 670 return 22; | |
| 671 case FAVICON_IMAGES: | |
| 672 return 23; | |
| 673 case FAVICON_TRACKING: | |
| 674 return 24; | |
| 675 case PROXY_TABS: | |
| 676 return 25; | |
| 677 case SUPERVISED_USER_SETTINGS: | |
| 678 return 26; | |
| 679 case SUPERVISED_USERS: | |
| 680 return 27; | |
| 681 case ARTICLES: | |
| 682 return 28; | |
| 683 case APP_LIST: | |
| 684 return 29; | |
| 685 case SUPERVISED_USER_SHARED_SETTINGS: | |
| 686 return 30; | |
| 687 case SYNCED_NOTIFICATION_APP_INFO: | |
| 688 return 31; | |
| 689 case WIFI_CREDENTIALS: | |
| 690 return 32; | |
| 691 case SUPERVISED_USER_WHITELISTS: | |
| 692 return 33; | |
| 693 case AUTOFILL_WALLET_DATA: | |
| 694 return 34; | |
| 695 case AUTOFILL_WALLET_METADATA: | |
| 696 return 35; | |
| 697 // Silence a compiler warning. | |
| 698 case MODEL_TYPE_COUNT: | |
| 699 return 0; | |
| 700 } | |
| 701 return 0; | 589 return 0; |
| 702 } | 590 } |
| 703 | 591 |
| 704 base::StringValue* ModelTypeToValue(ModelType model_type) { | 592 base::StringValue* ModelTypeToValue(ModelType model_type) { |
| 705 if (model_type >= FIRST_REAL_MODEL_TYPE) { | 593 if (model_type >= FIRST_REAL_MODEL_TYPE) { |
| 706 return new base::StringValue(ModelTypeToString(model_type)); | 594 return new base::StringValue(ModelTypeToString(model_type)); |
| 707 } else if (model_type == TOP_LEVEL_FOLDER) { | 595 } else if (model_type == TOP_LEVEL_FOLDER) { |
| 708 return new base::StringValue("Top-level folder"); | 596 return new base::StringValue("Top-level folder"); |
| 709 } else if (model_type == UNSPECIFIED) { | 597 } else if (model_type == UNSPECIFIED) { |
| 710 return new base::StringValue("Unspecified"); | 598 return new base::StringValue("Unspecified"); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 722 int result; | 610 int result; |
| 723 CHECK(value.GetAsInteger(&result)); | 611 CHECK(value.GetAsInteger(&result)); |
| 724 return ModelTypeFromInt(result); | 612 return ModelTypeFromInt(result); |
| 725 } else { | 613 } else { |
| 726 NOTREACHED() << "Unsupported value type: " << value.GetType(); | 614 NOTREACHED() << "Unsupported value type: " << value.GetType(); |
| 727 return UNSPECIFIED; | 615 return UNSPECIFIED; |
| 728 } | 616 } |
| 729 } | 617 } |
| 730 | 618 |
| 731 ModelType ModelTypeFromString(const std::string& model_type_string) { | 619 ModelType ModelTypeFromString(const std::string& model_type_string) { |
| 732 if (model_type_string == "Bookmarks") | 620 if (model_type_string != "Unspecified" && |
| 733 return BOOKMARKS; | 621 model_type_string != "Top Level Folder") { |
| 734 else if (model_type_string == "Preferences") | 622 for (size_t i = 0; i < arraysize(kModelTypeInfoMap); ++i) { |
| 735 return PREFERENCES; | 623 if (kModelTypeInfoMap[i].model_type_string == model_type_string) |
| 736 else if (model_type_string == "Passwords") | 624 return kModelTypeInfoMap[i].model_type; |
| 737 return PASSWORDS; | 625 } |
| 738 else if (model_type_string == "Autofill") | 626 } |
| 739 return AUTOFILL; | 627 NOTREACHED() << "No known model type corresponding to " << model_type_string |
| 740 else if (model_type_string == "Autofill Profiles") | 628 << "."; |
| 741 return AUTOFILL_PROFILE; | |
| 742 else if (model_type_string == "Autofill Wallet") | |
| 743 return AUTOFILL_WALLET_DATA; | |
| 744 else if (model_type_string == "Autofill Wallet Metadata") | |
| 745 return AUTOFILL_WALLET_METADATA; | |
| 746 else if (model_type_string == "Themes") | |
| 747 return THEMES; | |
| 748 else if (model_type_string == "Typed URLs") | |
| 749 return TYPED_URLS; | |
| 750 else if (model_type_string == "Extensions") | |
| 751 return EXTENSIONS; | |
| 752 else if (model_type_string == "Encryption keys") | |
| 753 return NIGORI; | |
| 754 else if (model_type_string == "Search Engines") | |
| 755 return SEARCH_ENGINES; | |
| 756 else if (model_type_string == "Sessions") | |
| 757 return SESSIONS; | |
| 758 else if (model_type_string == "Apps") | |
| 759 return APPS; | |
| 760 else if (model_type_string == "App List") | |
| 761 return APP_LIST; | |
| 762 else if (model_type_string == "App settings") | |
| 763 return APP_SETTINGS; | |
| 764 else if (model_type_string == "Extension settings") | |
| 765 return EXTENSION_SETTINGS; | |
| 766 else if (model_type_string == "App Notifications") | |
| 767 return APP_NOTIFICATIONS; | |
| 768 else if (model_type_string == "History Delete Directives") | |
| 769 return HISTORY_DELETE_DIRECTIVES; | |
| 770 else if (model_type_string == "Synced Notifications") | |
| 771 return SYNCED_NOTIFICATIONS; | |
| 772 else if (model_type_string == "Synced Notification App Info") | |
| 773 return SYNCED_NOTIFICATION_APP_INFO; | |
| 774 else if (model_type_string == "Device Info") | |
| 775 return DEVICE_INFO; | |
| 776 else if (model_type_string == "Experiments") | |
| 777 return EXPERIMENTS; | |
| 778 else if (model_type_string == "Priority Preferences") | |
| 779 return PRIORITY_PREFERENCES; | |
| 780 else if (model_type_string == "Dictionary") | |
| 781 return DICTIONARY; | |
| 782 else if (model_type_string == "Favicon Images") | |
| 783 return FAVICON_IMAGES; | |
| 784 else if (model_type_string == "Favicon Tracking") | |
| 785 return FAVICON_TRACKING; | |
| 786 else if (model_type_string == "Managed User Settings") | |
| 787 return SUPERVISED_USER_SETTINGS; | |
| 788 else if (model_type_string == "Managed Users") | |
| 789 return SUPERVISED_USERS; | |
| 790 else if (model_type_string == "Managed User Shared Settings") | |
| 791 return SUPERVISED_USER_SHARED_SETTINGS; | |
| 792 else if (model_type_string == "Managed User Whitelists") | |
| 793 return SUPERVISED_USER_WHITELISTS; | |
| 794 else if (model_type_string == "Articles") | |
| 795 return ARTICLES; | |
| 796 else if (model_type_string == "WiFi Credentials") | |
| 797 return WIFI_CREDENTIALS; | |
| 798 else if (model_type_string == "Tabs") | |
| 799 return PROXY_TABS; | |
| 800 else | |
| 801 NOTREACHED() << "No known model type corresponding to " | |
| 802 << model_type_string << "."; | |
| 803 return UNSPECIFIED; | 629 return UNSPECIFIED; |
| 804 } | 630 } |
| 805 | 631 |
| 806 std::string ModelTypeSetToString(ModelTypeSet model_types) { | 632 std::string ModelTypeSetToString(ModelTypeSet model_types) { |
| 807 std::string result; | 633 std::string result; |
| 808 for (ModelTypeSet::Iterator it = model_types.First(); it.Good(); it.Inc()) { | 634 for (ModelTypeSet::Iterator it = model_types.First(); it.Good(); it.Inc()) { |
| 809 if (!result.empty()) { | 635 if (!result.empty()) { |
| 810 result += ", "; | 636 result += ", "; |
| 811 } | 637 } |
| 812 result += ModelTypeToString(it.Get()); | 638 result += ModelTypeToString(it.Get()); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 result.Put(ModelTypeFromValue(**i)); | 679 result.Put(ModelTypeFromValue(**i)); |
| 854 } | 680 } |
| 855 return result; | 681 return result; |
| 856 } | 682 } |
| 857 | 683 |
| 858 // TODO(zea): remove all hardcoded tags in model associators and have them use | 684 // TODO(zea): remove all hardcoded tags in model associators and have them use |
| 859 // this instead. | 685 // this instead. |
| 860 // NOTE: Proxy types should return empty strings (so that we don't NOTREACHED | 686 // NOTE: Proxy types should return empty strings (so that we don't NOTREACHED |
| 861 // in tests when we verify they have no root node). | 687 // in tests when we verify they have no root node). |
| 862 std::string ModelTypeToRootTag(ModelType type) { | 688 std::string ModelTypeToRootTag(ModelType type) { |
| 863 switch (type) { | 689 if (IsProxyType(type)) |
| 864 case BOOKMARKS: | 690 return std::string(); |
| 865 return "google_chrome_bookmarks"; | 691 if (IsRealDataType(type)) |
| 866 case PREFERENCES: | 692 return "google_chrome_" + std::string(kModelTypeInfoMap[type].root_tag); |
| 867 return "google_chrome_preferences"; | |
| 868 case PASSWORDS: | |
| 869 return "google_chrome_passwords"; | |
| 870 case AUTOFILL: | |
| 871 return "google_chrome_autofill"; | |
| 872 case THEMES: | |
| 873 return "google_chrome_themes"; | |
| 874 case TYPED_URLS: | |
| 875 return "google_chrome_typed_urls"; | |
| 876 case EXTENSIONS: | |
| 877 return "google_chrome_extensions"; | |
| 878 case NIGORI: | |
| 879 return "google_chrome_nigori"; | |
| 880 case SEARCH_ENGINES: | |
| 881 return "google_chrome_search_engines"; | |
| 882 case SESSIONS: | |
| 883 return "google_chrome_sessions"; | |
| 884 case APPS: | |
| 885 return "google_chrome_apps"; | |
| 886 case APP_LIST: | |
| 887 return "google_chrome_app_list"; | |
| 888 case AUTOFILL_PROFILE: | |
| 889 return "google_chrome_autofill_profiles"; | |
| 890 case AUTOFILL_WALLET_DATA: | |
| 891 return "google_chrome_autofill_wallet"; | |
| 892 case AUTOFILL_WALLET_METADATA: | |
| 893 return "google_chrome_autofill_wallet_metadata"; | |
| 894 case APP_SETTINGS: | |
| 895 return "google_chrome_app_settings"; | |
| 896 case EXTENSION_SETTINGS: | |
| 897 return "google_chrome_extension_settings"; | |
| 898 case APP_NOTIFICATIONS: | |
| 899 return "google_chrome_app_notifications"; | |
| 900 case HISTORY_DELETE_DIRECTIVES: | |
| 901 return "google_chrome_history_delete_directives"; | |
| 902 case SYNCED_NOTIFICATIONS: | |
| 903 return "google_chrome_synced_notifications"; | |
| 904 case SYNCED_NOTIFICATION_APP_INFO: | |
| 905 return "google_chrome_synced_notification_app_info"; | |
| 906 case DEVICE_INFO: | |
| 907 return "google_chrome_device_info"; | |
| 908 case EXPERIMENTS: | |
| 909 return "google_chrome_experiments"; | |
| 910 case PRIORITY_PREFERENCES: | |
| 911 return "google_chrome_priority_preferences"; | |
| 912 case DICTIONARY: | |
| 913 return "google_chrome_dictionary"; | |
| 914 case FAVICON_IMAGES: | |
| 915 return "google_chrome_favicon_images"; | |
| 916 case FAVICON_TRACKING: | |
| 917 return "google_chrome_favicon_tracking"; | |
| 918 case SUPERVISED_USER_SETTINGS: | |
| 919 return "google_chrome_managed_user_settings"; | |
| 920 case SUPERVISED_USERS: | |
| 921 return "google_chrome_managed_users"; | |
| 922 case SUPERVISED_USER_SHARED_SETTINGS: | |
| 923 return "google_chrome_managed_user_shared_settings"; | |
| 924 case SUPERVISED_USER_WHITELISTS: | |
| 925 return "google_chrome_managed_user_whitelists"; | |
| 926 case ARTICLES: | |
| 927 return "google_chrome_articles"; | |
| 928 case WIFI_CREDENTIALS: | |
| 929 return "google_chrome_wifi_credentials"; | |
| 930 case PROXY_TABS: | |
| 931 return std::string(); | |
| 932 default: | |
| 933 break; | |
| 934 } | |
| 935 NOTREACHED() << "No known extension for model type."; | 693 NOTREACHED() << "No known extension for model type."; |
| 936 return "INVALID"; | 694 return "INVALID"; |
| 937 } | 695 } |
| 938 | 696 |
| 939 // TODO(akalin): Figure out a better way to do these mappings. | |
| 940 // Note: Do not include proxy types in this list. They should never receive | |
| 941 // or trigger notifications. | |
| 942 namespace { | |
| 943 const char kBookmarkNotificationType[] = "BOOKMARK"; | |
| 944 const char kPreferenceNotificationType[] = "PREFERENCE"; | |
| 945 const char kPasswordNotificationType[] = "PASSWORD"; | |
| 946 const char kAutofillNotificationType[] = "AUTOFILL"; | |
| 947 const char kThemeNotificationType[] = "THEME"; | |
| 948 const char kTypedUrlNotificationType[] = "TYPED_URL"; | |
| 949 const char kExtensionNotificationType[] = "EXTENSION"; | |
| 950 const char kExtensionSettingNotificationType[] = "EXTENSION_SETTING"; | |
| 951 const char kNigoriNotificationType[] = "NIGORI"; | |
| 952 const char kAppSettingNotificationType[] = "APP_SETTING"; | |
| 953 const char kAppNotificationType[] = "APP"; | |
| 954 const char kAppListNotificationType[] = "APP_LIST"; | |
| 955 const char kSearchEngineNotificationType[] = "SEARCH_ENGINE"; | |
| 956 const char kSessionNotificationType[] = "SESSION"; | |
| 957 const char kAutofillProfileNotificationType[] = "AUTOFILL_PROFILE"; | |
| 958 const char kAutofillWalletMetadataNotificationType[] = | |
| 959 "AUTOFILL_WALLET_METADATA"; | |
| 960 const char kAutofillWalletNotificationType[] = "AUTOFILL_WALLET"; | |
| 961 const char kAppNotificationNotificationType[] = "APP_NOTIFICATION"; | |
| 962 const char kHistoryDeleteDirectiveNotificationType[] = | |
| 963 "HISTORY_DELETE_DIRECTIVE"; | |
| 964 const char kSyncedNotificationType[] = "SYNCED_NOTIFICATION"; | |
| 965 const char kSyncedNotificationAppInfoType[] = "SYNCED_NOTIFICATION_APP_INFO"; | |
| 966 const char kDeviceInfoNotificationType[] = "DEVICE_INFO"; | |
| 967 const char kExperimentsNotificationType[] = "EXPERIMENTS"; | |
| 968 const char kPriorityPreferenceNotificationType[] = "PRIORITY_PREFERENCE"; | |
| 969 const char kDictionaryNotificationType[] = "DICTIONARY"; | |
| 970 const char kFaviconImageNotificationType[] = "FAVICON_IMAGE"; | |
| 971 const char kFaviconTrackingNotificationType[] = "FAVICON_TRACKING"; | |
| 972 const char kSupervisedUserSettingNotificationType[] = "MANAGED_USER_SETTING"; | |
| 973 const char kSupervisedUserNotificationType[] = "MANAGED_USER"; | |
| 974 const char kSupervisedUserSharedSettingNotificationType[] = | |
| 975 "MANAGED_USER_SHARED_SETTING"; | |
| 976 const char kSupervisedUserWhitelistNotificationType[] = | |
| 977 "MANAGED_USER_WHITELIST"; | |
| 978 const char kArticleNotificationType[] = "ARTICLE"; | |
| 979 const char kWifiCredentialNotificationType[] = "WIFI_CREDENTIAL"; | |
| 980 } // namespace | |
| 981 | |
| 982 bool RealModelTypeToNotificationType(ModelType model_type, | 697 bool RealModelTypeToNotificationType(ModelType model_type, |
| 983 std::string* notification_type) { | 698 std::string* notification_type) { |
| 984 switch (model_type) { | 699 if (ProtocolTypes().Has(model_type)) { |
| 985 case BOOKMARKS: | 700 *notification_type = kModelTypeInfoMap[model_type].notification_type; |
| 986 *notification_type = kBookmarkNotificationType; | 701 return true; |
| 987 return true; | |
| 988 case PREFERENCES: | |
| 989 *notification_type = kPreferenceNotificationType; | |
| 990 return true; | |
| 991 case PASSWORDS: | |
| 992 *notification_type = kPasswordNotificationType; | |
| 993 return true; | |
| 994 case AUTOFILL: | |
| 995 *notification_type = kAutofillNotificationType; | |
| 996 return true; | |
| 997 case THEMES: | |
| 998 *notification_type = kThemeNotificationType; | |
| 999 return true; | |
| 1000 case TYPED_URLS: | |
| 1001 *notification_type = kTypedUrlNotificationType; | |
| 1002 return true; | |
| 1003 case EXTENSIONS: | |
| 1004 *notification_type = kExtensionNotificationType; | |
| 1005 return true; | |
| 1006 case NIGORI: | |
| 1007 *notification_type = kNigoriNotificationType; | |
| 1008 return true; | |
| 1009 case APP_SETTINGS: | |
| 1010 *notification_type = kAppSettingNotificationType; | |
| 1011 return true; | |
| 1012 case APPS: | |
| 1013 *notification_type = kAppNotificationType; | |
| 1014 return true; | |
| 1015 case APP_LIST: | |
| 1016 *notification_type = kAppListNotificationType; | |
| 1017 return true; | |
| 1018 case SEARCH_ENGINES: | |
| 1019 *notification_type = kSearchEngineNotificationType; | |
| 1020 return true; | |
| 1021 case SESSIONS: | |
| 1022 *notification_type = kSessionNotificationType; | |
| 1023 return true; | |
| 1024 case AUTOFILL_PROFILE: | |
| 1025 *notification_type = kAutofillProfileNotificationType; | |
| 1026 return true; | |
| 1027 case AUTOFILL_WALLET_DATA: | |
| 1028 *notification_type = kAutofillWalletNotificationType; | |
| 1029 return true; | |
| 1030 case AUTOFILL_WALLET_METADATA: | |
| 1031 *notification_type = kAutofillWalletMetadataNotificationType; | |
| 1032 return true; | |
| 1033 case EXTENSION_SETTINGS: | |
| 1034 *notification_type = kExtensionSettingNotificationType; | |
| 1035 return true; | |
| 1036 case APP_NOTIFICATIONS: | |
| 1037 *notification_type = kAppNotificationNotificationType; | |
| 1038 return true; | |
| 1039 case HISTORY_DELETE_DIRECTIVES: | |
| 1040 *notification_type = kHistoryDeleteDirectiveNotificationType; | |
| 1041 return true; | |
| 1042 case SYNCED_NOTIFICATIONS: | |
| 1043 *notification_type = kSyncedNotificationType; | |
| 1044 return true; | |
| 1045 case SYNCED_NOTIFICATION_APP_INFO: | |
| 1046 *notification_type = kSyncedNotificationAppInfoType; | |
| 1047 return true; | |
| 1048 case DEVICE_INFO: | |
| 1049 *notification_type = kDeviceInfoNotificationType; | |
| 1050 return true; | |
| 1051 case EXPERIMENTS: | |
| 1052 *notification_type = kExperimentsNotificationType; | |
| 1053 return true; | |
| 1054 case PRIORITY_PREFERENCES: | |
| 1055 *notification_type = kPriorityPreferenceNotificationType; | |
| 1056 return true; | |
| 1057 case DICTIONARY: | |
| 1058 *notification_type = kDictionaryNotificationType; | |
| 1059 return true; | |
| 1060 case FAVICON_IMAGES: | |
| 1061 *notification_type = kFaviconImageNotificationType; | |
| 1062 return true; | |
| 1063 case FAVICON_TRACKING: | |
| 1064 *notification_type = kFaviconTrackingNotificationType; | |
| 1065 return true; | |
| 1066 case SUPERVISED_USER_SETTINGS: | |
| 1067 *notification_type = kSupervisedUserSettingNotificationType; | |
| 1068 return true; | |
| 1069 case SUPERVISED_USERS: | |
| 1070 *notification_type = kSupervisedUserNotificationType; | |
| 1071 return true; | |
| 1072 case SUPERVISED_USER_SHARED_SETTINGS: | |
| 1073 *notification_type = kSupervisedUserSharedSettingNotificationType; | |
| 1074 return true; | |
| 1075 case SUPERVISED_USER_WHITELISTS: | |
| 1076 *notification_type = kSupervisedUserWhitelistNotificationType; | |
| 1077 return true; | |
| 1078 case ARTICLES: | |
| 1079 *notification_type = kArticleNotificationType; | |
| 1080 return true; | |
| 1081 case WIFI_CREDENTIALS: | |
| 1082 *notification_type = kWifiCredentialNotificationType; | |
| 1083 return true; | |
| 1084 default: | |
| 1085 break; | |
| 1086 } | 702 } |
| 1087 notification_type->clear(); | 703 notification_type->clear(); |
| 1088 return false; | 704 return false; |
| 1089 } | 705 } |
| 1090 | 706 |
| 1091 bool NotificationTypeToRealModelType(const std::string& notification_type, | 707 bool NotificationTypeToRealModelType(const std::string& notification_type, |
| 1092 ModelType* model_type) { | 708 ModelType* model_type) { |
| 1093 if (notification_type == kBookmarkNotificationType) { | 709 if (notification_type.empty()) { |
| 1094 *model_type = BOOKMARKS; | 710 *model_type = UNSPECIFIED; |
| 1095 return true; | 711 return false; |
| 1096 } else if (notification_type == kPreferenceNotificationType) { | 712 } |
| 1097 *model_type = PREFERENCES; | 713 for (size_t i = 0; i < arraysize(kModelTypeInfoMap); ++i) { |
| 1098 return true; | 714 if (kModelTypeInfoMap[i].notification_type == notification_type) { |
| 1099 } else if (notification_type == kPasswordNotificationType) { | 715 *model_type = kModelTypeInfoMap[i].model_type; |
| 1100 *model_type = PASSWORDS; | 716 return true; |
| 1101 return true; | 717 } |
| 1102 } else if (notification_type == kAutofillNotificationType) { | |
| 1103 *model_type = AUTOFILL; | |
| 1104 return true; | |
| 1105 } else if (notification_type == kThemeNotificationType) { | |
| 1106 *model_type = THEMES; | |
| 1107 return true; | |
| 1108 } else if (notification_type == kTypedUrlNotificationType) { | |
| 1109 *model_type = TYPED_URLS; | |
| 1110 return true; | |
| 1111 } else if (notification_type == kExtensionNotificationType) { | |
| 1112 *model_type = EXTENSIONS; | |
| 1113 return true; | |
| 1114 } else if (notification_type == kNigoriNotificationType) { | |
| 1115 *model_type = NIGORI; | |
| 1116 return true; | |
| 1117 } else if (notification_type == kAppNotificationType) { | |
| 1118 *model_type = APPS; | |
| 1119 return true; | |
| 1120 } else if (notification_type == kAppListNotificationType) { | |
| 1121 *model_type = APP_LIST; | |
| 1122 return true; | |
| 1123 } else if (notification_type == kSearchEngineNotificationType) { | |
| 1124 *model_type = SEARCH_ENGINES; | |
| 1125 return true; | |
| 1126 } else if (notification_type == kSessionNotificationType) { | |
| 1127 *model_type = SESSIONS; | |
| 1128 return true; | |
| 1129 } else if (notification_type == kAutofillProfileNotificationType) { | |
| 1130 *model_type = AUTOFILL_PROFILE; | |
| 1131 return true; | |
| 1132 } else if (notification_type == kAutofillWalletNotificationType) { | |
| 1133 *model_type = AUTOFILL_WALLET_DATA; | |
| 1134 return true; | |
| 1135 } else if (notification_type == kAutofillWalletMetadataNotificationType) { | |
| 1136 *model_type = AUTOFILL_WALLET_METADATA; | |
| 1137 return true; | |
| 1138 } else if (notification_type == kAppSettingNotificationType) { | |
| 1139 *model_type = APP_SETTINGS; | |
| 1140 return true; | |
| 1141 } else if (notification_type == kExtensionSettingNotificationType) { | |
| 1142 *model_type = EXTENSION_SETTINGS; | |
| 1143 return true; | |
| 1144 } else if (notification_type == kAppNotificationNotificationType) { | |
| 1145 *model_type = APP_NOTIFICATIONS; | |
| 1146 return true; | |
| 1147 } else if (notification_type == kHistoryDeleteDirectiveNotificationType) { | |
| 1148 *model_type = HISTORY_DELETE_DIRECTIVES; | |
| 1149 return true; | |
| 1150 } else if (notification_type == kSyncedNotificationType) { | |
| 1151 *model_type = SYNCED_NOTIFICATIONS; | |
| 1152 return true; | |
| 1153 } else if (notification_type == kSyncedNotificationAppInfoType) { | |
| 1154 *model_type = SYNCED_NOTIFICATION_APP_INFO; | |
| 1155 return true; | |
| 1156 } else if (notification_type == kDeviceInfoNotificationType) { | |
| 1157 *model_type = DEVICE_INFO; | |
| 1158 return true; | |
| 1159 } else if (notification_type == kExperimentsNotificationType) { | |
| 1160 *model_type = EXPERIMENTS; | |
| 1161 return true; | |
| 1162 } else if (notification_type == kPriorityPreferenceNotificationType) { | |
| 1163 *model_type = PRIORITY_PREFERENCES; | |
| 1164 return true; | |
| 1165 } else if (notification_type == kDictionaryNotificationType) { | |
| 1166 *model_type = DICTIONARY; | |
| 1167 return true; | |
| 1168 } else if (notification_type == kFaviconImageNotificationType) { | |
| 1169 *model_type = FAVICON_IMAGES; | |
| 1170 return true; | |
| 1171 } else if (notification_type == kFaviconTrackingNotificationType) { | |
| 1172 *model_type = FAVICON_TRACKING; | |
| 1173 return true; | |
| 1174 } else if (notification_type == kSupervisedUserSettingNotificationType) { | |
| 1175 *model_type = SUPERVISED_USER_SETTINGS; | |
| 1176 return true; | |
| 1177 } else if (notification_type == kSupervisedUserNotificationType) { | |
| 1178 *model_type = SUPERVISED_USERS; | |
| 1179 return true; | |
| 1180 } else if (notification_type == | |
| 1181 kSupervisedUserSharedSettingNotificationType) { | |
| 1182 *model_type = SUPERVISED_USER_SHARED_SETTINGS; | |
| 1183 return true; | |
| 1184 } else if (notification_type == kSupervisedUserWhitelistNotificationType) { | |
| 1185 *model_type = SUPERVISED_USER_WHITELISTS; | |
| 1186 return true; | |
| 1187 } else if (notification_type == kArticleNotificationType) { | |
| 1188 *model_type = ARTICLES; | |
| 1189 return true; | |
| 1190 } else if (notification_type == kWifiCredentialNotificationType) { | |
| 1191 *model_type = WIFI_CREDENTIALS; | |
| 1192 return true; | |
| 1193 } | 718 } |
| 1194 *model_type = UNSPECIFIED; | 719 *model_type = UNSPECIFIED; |
| 1195 return false; | 720 return false; |
| 1196 } | 721 } |
| 1197 | 722 |
| 1198 bool IsRealDataType(ModelType model_type) { | 723 bool IsRealDataType(ModelType model_type) { |
| 1199 return model_type >= FIRST_REAL_MODEL_TYPE && model_type < MODEL_TYPE_COUNT; | 724 return model_type >= FIRST_REAL_MODEL_TYPE && model_type < MODEL_TYPE_COUNT; |
| 1200 } | 725 } |
| 1201 | 726 |
| 1202 bool IsProxyType(ModelType model_type) { | 727 bool IsProxyType(ModelType model_type) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1219 bool TypeSupportsHierarchy(ModelType model_type) { | 744 bool TypeSupportsHierarchy(ModelType model_type) { |
| 1220 // TODO(stanisc): crbug/438313: Should this also include TOP_LEVEL_FOLDER? | 745 // TODO(stanisc): crbug/438313: Should this also include TOP_LEVEL_FOLDER? |
| 1221 return model_type == BOOKMARKS; | 746 return model_type == BOOKMARKS; |
| 1222 } | 747 } |
| 1223 | 748 |
| 1224 bool TypeSupportsOrdering(ModelType model_type) { | 749 bool TypeSupportsOrdering(ModelType model_type) { |
| 1225 return model_type == BOOKMARKS; | 750 return model_type == BOOKMARKS; |
| 1226 } | 751 } |
| 1227 | 752 |
| 1228 } // namespace syncer | 753 } // namespace syncer |
| OLD | NEW |