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

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

Issue 2548413002: Fix sync for reading list (Closed)
Patch Set: Move histogram Created 4 years 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"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "components/reading_list/core/reading_list_enable_flags.h"
12 #include "components/sync/protocol/app_notification_specifics.pb.h" 13 #include "components/sync/protocol/app_notification_specifics.pb.h"
13 #include "components/sync/protocol/app_setting_specifics.pb.h" 14 #include "components/sync/protocol/app_setting_specifics.pb.h"
14 #include "components/sync/protocol/app_specifics.pb.h" 15 #include "components/sync/protocol/app_specifics.pb.h"
15 #include "components/sync/protocol/autofill_specifics.pb.h" 16 #include "components/sync/protocol/autofill_specifics.pb.h"
16 #include "components/sync/protocol/bookmark_specifics.pb.h" 17 #include "components/sync/protocol/bookmark_specifics.pb.h"
17 #include "components/sync/protocol/extension_setting_specifics.pb.h" 18 #include "components/sync/protocol/extension_setting_specifics.pb.h"
18 #include "components/sync/protocol/extension_specifics.pb.h" 19 #include "components/sync/protocol/extension_specifics.pb.h"
19 #include "components/sync/protocol/nigori_specifics.pb.h" 20 #include "components/sync/protocol/nigori_specifics.pb.h"
20 #include "components/sync/protocol/password_specifics.pb.h" 21 #include "components/sync/protocol/password_specifics.pb.h"
21 #include "components/sync/protocol/preference_specifics.pb.h" 22 #include "components/sync/protocol/preference_specifics.pb.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 148
148 static_assert(arraysize(kModelTypeInfoMap) == MODEL_TYPE_COUNT, 149 static_assert(arraysize(kModelTypeInfoMap) == MODEL_TYPE_COUNT,
149 "kModelTypeInfoMap should have MODEL_TYPE_COUNT elements"); 150 "kModelTypeInfoMap should have MODEL_TYPE_COUNT elements");
150 151
151 // Notes: 152 // Notes:
152 // 1) This list must contain exactly the same elements as the set returned by 153 // 1) This list must contain exactly the same elements as the set returned by
153 // UserSelectableTypes(). 154 // UserSelectableTypes().
154 // 2) This list must be in the same order as the respective values in the 155 // 2) This list must be in the same order as the respective values in the
155 // ModelType enum. 156 // ModelType enum.
156 const char* kUserSelectableDataTypeNames[] = { 157 const char* kUserSelectableDataTypeNames[] = {
157 "bookmarks", "preferences", "passwords", "autofill", "themes", 158 "bookmarks", "preferences", "passwords", "autofill",
158 "typedUrls", "extensions", "apps", "tabs", 159 "themes", "typedUrls", "extensions", "apps",
160 #if BUILDFLAG(ENABLE_READING_LIST)
161 "readingList",
162 #endif
163 "tabs",
159 }; 164 };
160 165
161 static_assert( 166 static_assert(
162 39 == MODEL_TYPE_COUNT, 167 39 == MODEL_TYPE_COUNT,
163 "update kUserSelectableDataTypeName to match UserSelectableTypes"); 168 "update kUserSelectableDataTypeName to match UserSelectableTypes");
164 169
165 void AddDefaultFieldValue(ModelType datatype, 170 void AddDefaultFieldValue(ModelType datatype,
166 sync_pb::EntitySpecifics* specifics) { 171 sync_pb::EntitySpecifics* specifics) {
167 if (!ProtocolTypes().Has(datatype)) { 172 if (!ProtocolTypes().Has(datatype)) {
168 NOTREACHED() << "Only protocol types have field values."; 173 NOTREACHED() << "Only protocol types have field values.";
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 // Although the order doesn't technically matter here, it's clearer to keep 474 // Although the order doesn't technically matter here, it's clearer to keep
470 // these in the same order as their definition in the ModelType enum. 475 // these in the same order as their definition in the ModelType enum.
471 set.Put(BOOKMARKS); 476 set.Put(BOOKMARKS);
472 set.Put(PREFERENCES); 477 set.Put(PREFERENCES);
473 set.Put(PASSWORDS); 478 set.Put(PASSWORDS);
474 set.Put(AUTOFILL); 479 set.Put(AUTOFILL);
475 set.Put(THEMES); 480 set.Put(THEMES);
476 set.Put(TYPED_URLS); 481 set.Put(TYPED_URLS);
477 set.Put(EXTENSIONS); 482 set.Put(EXTENSIONS);
478 set.Put(APPS); 483 set.Put(APPS);
484 #if BUILDFLAG(ENABLE_READING_LIST)
485 set.Put(READING_LIST);
486 #endif
479 set.Put(PROXY_TABS); 487 set.Put(PROXY_TABS);
480 return set; 488 return set;
481 } 489 }
482 490
483 bool IsUserSelectableType(ModelType model_type) { 491 bool IsUserSelectableType(ModelType model_type) {
484 return UserSelectableTypes().Has(model_type); 492 return UserSelectableTypes().Has(model_type);
485 } 493 }
486 494
487 ModelTypeNameMap GetUserSelectableTypeNameMap() { 495 ModelTypeNameMap GetUserSelectableTypeNameMap() {
488 ModelTypeNameMap type_names; 496 ModelTypeNameMap type_names;
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 bool TypeSupportsHierarchy(ModelType model_type) { 773 bool TypeSupportsHierarchy(ModelType model_type) {
766 // TODO(stanisc): crbug/438313: Should this also include TOP_LEVEL_FOLDER? 774 // TODO(stanisc): crbug/438313: Should this also include TOP_LEVEL_FOLDER?
767 return model_type == BOOKMARKS; 775 return model_type == BOOKMARKS;
768 } 776 }
769 777
770 bool TypeSupportsOrdering(ModelType model_type) { 778 bool TypeSupportsOrdering(ModelType model_type) {
771 return model_type == BOOKMARKS; 779 return model_type == BOOKMARKS;
772 } 780 }
773 781
774 } // namespace syncer 782 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698