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

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

Issue 674633002: sync: add WIFI_CREDENTIALS protobuf, ModelType, and preference (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@local-master
Patch Set: resolve conflicts with https://codereview.chromium.org/673983003 Created 6 years, 1 month 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 "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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 break; 112 break;
113 case SUPERVISED_USERS: 113 case SUPERVISED_USERS:
114 specifics->mutable_managed_user(); 114 specifics->mutable_managed_user();
115 break; 115 break;
116 case SUPERVISED_USER_SHARED_SETTINGS: 116 case SUPERVISED_USER_SHARED_SETTINGS:
117 specifics->mutable_managed_user_shared_setting(); 117 specifics->mutable_managed_user_shared_setting();
118 break; 118 break;
119 case ARTICLES: 119 case ARTICLES:
120 specifics->mutable_article(); 120 specifics->mutable_article();
121 break; 121 break;
122 case WIFI_CREDENTIALS:
123 specifics->mutable_wifi_credential();
124 break;
122 default: 125 default:
123 NOTREACHED() << "No known extension for model type."; 126 NOTREACHED() << "No known extension for model type.";
124 } 127 }
125 } 128 }
126 129
127 ModelType GetModelTypeFromSpecificsFieldNumber(int field_number) { 130 ModelType GetModelTypeFromSpecificsFieldNumber(int field_number) {
128 ModelTypeSet protocol_types = ProtocolTypes(); 131 ModelTypeSet protocol_types = ProtocolTypes();
129 for (ModelTypeSet::Iterator iter = protocol_types.First(); iter.Good(); 132 for (ModelTypeSet::Iterator iter = protocol_types.First(); iter.Good();
130 iter.Inc()) { 133 iter.Inc()) {
131 if (GetSpecificsFieldNumberFromModelType(iter.Get()) == field_number) 134 if (GetSpecificsFieldNumberFromModelType(iter.Get()) == field_number)
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 case FAVICON_TRACKING: 192 case FAVICON_TRACKING:
190 return sync_pb::EntitySpecifics::kFaviconTrackingFieldNumber; 193 return sync_pb::EntitySpecifics::kFaviconTrackingFieldNumber;
191 case SUPERVISED_USER_SETTINGS: 194 case SUPERVISED_USER_SETTINGS:
192 return sync_pb::EntitySpecifics::kManagedUserSettingFieldNumber; 195 return sync_pb::EntitySpecifics::kManagedUserSettingFieldNumber;
193 case SUPERVISED_USERS: 196 case SUPERVISED_USERS:
194 return sync_pb::EntitySpecifics::kManagedUserFieldNumber; 197 return sync_pb::EntitySpecifics::kManagedUserFieldNumber;
195 case SUPERVISED_USER_SHARED_SETTINGS: 198 case SUPERVISED_USER_SHARED_SETTINGS:
196 return sync_pb::EntitySpecifics::kManagedUserSharedSettingFieldNumber; 199 return sync_pb::EntitySpecifics::kManagedUserSharedSettingFieldNumber;
197 case ARTICLES: 200 case ARTICLES:
198 return sync_pb::EntitySpecifics::kArticleFieldNumber; 201 return sync_pb::EntitySpecifics::kArticleFieldNumber;
202 case WIFI_CREDENTIALS:
203 return sync_pb::EntitySpecifics::kWifiCredentialFieldNumber;
199 default: 204 default:
200 NOTREACHED() << "No known extension for model type."; 205 NOTREACHED() << "No known extension for model type.";
201 return 0; 206 return 0;
202 } 207 }
203 } 208 }
204 209
205 FullModelTypeSet ToFullModelTypeSet(ModelTypeSet in) { 210 FullModelTypeSet ToFullModelTypeSet(ModelTypeSet in) {
206 FullModelTypeSet out; 211 FullModelTypeSet out;
207 for (ModelTypeSet::Iterator i = in.First(); i.Good(); i.Inc()) { 212 for (ModelTypeSet::Iterator i = in.First(); i.Good(); i.Inc()) {
208 out.Put(i.Get()); 213 out.Put(i.Get());
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 322
318 if (specifics.has_managed_user()) 323 if (specifics.has_managed_user())
319 return SUPERVISED_USERS; 324 return SUPERVISED_USERS;
320 325
321 if (specifics.has_managed_user_shared_setting()) 326 if (specifics.has_managed_user_shared_setting())
322 return SUPERVISED_USER_SHARED_SETTINGS; 327 return SUPERVISED_USER_SHARED_SETTINGS;
323 328
324 if (specifics.has_article()) 329 if (specifics.has_article())
325 return ARTICLES; 330 return ARTICLES;
326 331
332 if (specifics.has_wifi_credential())
333 return WIFI_CREDENTIALS;
334
327 return UNSPECIFIED; 335 return UNSPECIFIED;
328 } 336 }
329 337
330 ModelTypeSet ProtocolTypes() { 338 ModelTypeSet ProtocolTypes() {
331 ModelTypeSet set = ModelTypeSet::All(); 339 ModelTypeSet set = ModelTypeSet::All();
332 set.RemoveAll(ProxyTypes()); 340 set.RemoveAll(ProxyTypes());
333 return set; 341 return set;
334 } 342 }
335 343
336 ModelTypeSet UserTypes() { 344 ModelTypeSet UserTypes() {
(...skipping 12 matching lines...) Expand all
349 // Although the order doesn't technically matter here, it's clearer to keep 357 // Although the order doesn't technically matter here, it's clearer to keep
350 // these in the same order as their definition in the ModelType enum. 358 // these in the same order as their definition in the ModelType enum.
351 set.Put(BOOKMARKS); 359 set.Put(BOOKMARKS);
352 set.Put(PREFERENCES); 360 set.Put(PREFERENCES);
353 set.Put(PASSWORDS); 361 set.Put(PASSWORDS);
354 set.Put(AUTOFILL); 362 set.Put(AUTOFILL);
355 set.Put(THEMES); 363 set.Put(THEMES);
356 set.Put(TYPED_URLS); 364 set.Put(TYPED_URLS);
357 set.Put(EXTENSIONS); 365 set.Put(EXTENSIONS);
358 set.Put(APPS); 366 set.Put(APPS);
367 set.Put(WIFI_CREDENTIALS);
359 set.Put(PROXY_TABS); 368 set.Put(PROXY_TABS);
360 return set; 369 return set;
361 } 370 }
362 371
363 bool IsUserSelectableType(ModelType model_type) { 372 bool IsUserSelectableType(ModelType model_type) {
364 return UserSelectableTypes().Has(model_type); 373 return UserSelectableTypes().Has(model_type);
365 } 374 }
366 375
367 ModelTypeSet EncryptableUserTypes() { 376 ModelTypeSet EncryptableUserTypes() {
368 ModelTypeSet encryptable_user_types = UserTypes(); 377 ModelTypeSet encryptable_user_types = UserTypes();
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 case FAVICON_TRACKING: 526 case FAVICON_TRACKING:
518 return "Favicon Tracking"; 527 return "Favicon Tracking";
519 case SUPERVISED_USER_SETTINGS: 528 case SUPERVISED_USER_SETTINGS:
520 return "Managed User Settings"; 529 return "Managed User Settings";
521 case SUPERVISED_USERS: 530 case SUPERVISED_USERS:
522 return "Managed Users"; 531 return "Managed Users";
523 case SUPERVISED_USER_SHARED_SETTINGS: 532 case SUPERVISED_USER_SHARED_SETTINGS:
524 return "Managed User Shared Settings"; 533 return "Managed User Shared Settings";
525 case ARTICLES: 534 case ARTICLES:
526 return "Articles"; 535 return "Articles";
536 case WIFI_CREDENTIALS:
537 return "WiFi Credentials";
527 case PROXY_TABS: 538 case PROXY_TABS:
528 return "Tabs"; 539 return "Tabs";
529 default: 540 default:
530 break; 541 break;
531 } 542 }
532 NOTREACHED() << "No known extension for model type."; 543 NOTREACHED() << "No known extension for model type.";
533 return "INVALID"; 544 return "INVALID";
534 } 545 }
535 546
536 // The normal rules about histograms apply here. Always append to the bottom of 547 // The normal rules about histograms apply here. Always append to the bottom of
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 case SUPERVISED_USERS: 607 case SUPERVISED_USERS:
597 return 27; 608 return 27;
598 case ARTICLES: 609 case ARTICLES:
599 return 28; 610 return 28;
600 case APP_LIST: 611 case APP_LIST:
601 return 29; 612 return 29;
602 case SUPERVISED_USER_SHARED_SETTINGS: 613 case SUPERVISED_USER_SHARED_SETTINGS:
603 return 30; 614 return 30;
604 case SYNCED_NOTIFICATION_APP_INFO: 615 case SYNCED_NOTIFICATION_APP_INFO:
605 return 31; 616 return 31;
617 case WIFI_CREDENTIALS:
618 return 32;
606 // Silence a compiler warning. 619 // Silence a compiler warning.
607 case MODEL_TYPE_COUNT: 620 case MODEL_TYPE_COUNT:
608 return 0; 621 return 0;
609 } 622 }
610 return 0; 623 return 0;
611 } 624 }
612 625
613 base::StringValue* ModelTypeToValue(ModelType model_type) { 626 base::StringValue* ModelTypeToValue(ModelType model_type) {
614 if (model_type >= FIRST_REAL_MODEL_TYPE) { 627 if (model_type >= FIRST_REAL_MODEL_TYPE) {
615 return new base::StringValue(ModelTypeToString(model_type)); 628 return new base::StringValue(ModelTypeToString(model_type));
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 else if (model_type_string == "Favicon Tracking") 702 else if (model_type_string == "Favicon Tracking")
690 return FAVICON_TRACKING; 703 return FAVICON_TRACKING;
691 else if (model_type_string == "Managed User Settings") 704 else if (model_type_string == "Managed User Settings")
692 return SUPERVISED_USER_SETTINGS; 705 return SUPERVISED_USER_SETTINGS;
693 else if (model_type_string == "Managed Users") 706 else if (model_type_string == "Managed Users")
694 return SUPERVISED_USERS; 707 return SUPERVISED_USERS;
695 else if (model_type_string == "Managed User Shared Settings") 708 else if (model_type_string == "Managed User Shared Settings")
696 return SUPERVISED_USER_SHARED_SETTINGS; 709 return SUPERVISED_USER_SHARED_SETTINGS;
697 else if (model_type_string == "Articles") 710 else if (model_type_string == "Articles")
698 return ARTICLES; 711 return ARTICLES;
712 else if (model_type_string == "WiFi Credentials")
713 return WIFI_CREDENTIALS;
699 else if (model_type_string == "Tabs") 714 else if (model_type_string == "Tabs")
700 return PROXY_TABS; 715 return PROXY_TABS;
701 else 716 else
702 NOTREACHED() << "No known model type corresponding to " 717 NOTREACHED() << "No known model type corresponding to "
703 << model_type_string << "."; 718 << model_type_string << ".";
704 return UNSPECIFIED; 719 return UNSPECIFIED;
705 } 720 }
706 721
707 std::string ModelTypeSetToString(ModelTypeSet model_types) { 722 std::string ModelTypeSetToString(ModelTypeSet model_types) {
708 std::string result; 723 std::string result;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 case FAVICON_TRACKING: 828 case FAVICON_TRACKING:
814 return "google_chrome_favicon_tracking"; 829 return "google_chrome_favicon_tracking";
815 case SUPERVISED_USER_SETTINGS: 830 case SUPERVISED_USER_SETTINGS:
816 return "google_chrome_managed_user_settings"; 831 return "google_chrome_managed_user_settings";
817 case SUPERVISED_USERS: 832 case SUPERVISED_USERS:
818 return "google_chrome_managed_users"; 833 return "google_chrome_managed_users";
819 case SUPERVISED_USER_SHARED_SETTINGS: 834 case SUPERVISED_USER_SHARED_SETTINGS:
820 return "google_chrome_managed_user_shared_settings"; 835 return "google_chrome_managed_user_shared_settings";
821 case ARTICLES: 836 case ARTICLES:
822 return "google_chrome_articles"; 837 return "google_chrome_articles";
838 case WIFI_CREDENTIALS:
839 return "google_chrome_wifi_credentials";
823 case PROXY_TABS: 840 case PROXY_TABS:
824 return std::string(); 841 return std::string();
825 default: 842 default:
826 break; 843 break;
827 } 844 }
828 NOTREACHED() << "No known extension for model type."; 845 NOTREACHED() << "No known extension for model type.";
829 return "INVALID"; 846 return "INVALID";
830 } 847 }
831 848
832 // TODO(akalin): Figure out a better way to do these mappings. 849 // TODO(akalin): Figure out a better way to do these mappings.
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 1081
1065 bool IsProxyType(ModelType model_type) { 1082 bool IsProxyType(ModelType model_type) {
1066 return model_type >= FIRST_PROXY_TYPE && model_type <= LAST_PROXY_TYPE; 1083 return model_type >= FIRST_PROXY_TYPE && model_type <= LAST_PROXY_TYPE;
1067 } 1084 }
1068 1085
1069 bool IsActOnceDataType(ModelType model_type) { 1086 bool IsActOnceDataType(ModelType model_type) {
1070 return model_type == HISTORY_DELETE_DIRECTIVES; 1087 return model_type == HISTORY_DELETE_DIRECTIVES;
1071 } 1088 }
1072 1089
1073 } // namespace syncer 1090 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698