1 // Copyright 2019 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef COMPONENTS_SYNC_BASE_USER_SELECTABLE_TYPE_H_
6 #define COMPONENTS_SYNC_BASE_USER_SELECTABLE_TYPE_H_
7 
8 #include <string>
9 
10 #include "base/optional.h"
11 #include "components/sync/base/enum_set.h"
12 #include "components/sync/base/model_type.h"
13 
14 namespace syncer {
15 
16 enum class UserSelectableType {
17   kBookmarks,
18   kFirstType = kBookmarks,
19 
20   kPreferences,
21   kPasswords,
22   kAutofill,
23   kThemes,
24   kHistory,
25   kExtensions,
26   kApps,
27   kReadingList,
28   kTabs,
29   kWifiConfigurations,
30   kLastType = kWifiConfigurations
31 };
32 
33 using UserSelectableTypeSet = EnumSet<UserSelectableType,
34                                       UserSelectableType::kFirstType,
35                                       UserSelectableType::kLastType>;
36 
37 const char* GetUserSelectableTypeName(UserSelectableType type);
38 // Returns the type if the string matches a known type.
39 base::Optional<UserSelectableType> GetUserSelectableTypeFromString(
40     const std::string& type);
41 std::string UserSelectableTypeSetToString(UserSelectableTypeSet types);
42 ModelTypeSet UserSelectableTypeToAllModelTypes(UserSelectableType type);
43 
44 ModelType UserSelectableTypeToCanonicalModelType(UserSelectableType type);
45 int UserSelectableTypeToHistogramInt(UserSelectableType type);
46 
UserSelectableTypeHistogramNumEntries()47 constexpr int UserSelectableTypeHistogramNumEntries() {
48   return static_cast<int>(ModelType::NUM_ENTRIES);
49 }
50 
51 #if defined(OS_CHROMEOS)
52 // Chrome OS provides a separate UI with sync controls for OS data types. Note
53 // that wallpaper is a special case due to its reliance on apps, so while it
54 // appears in the UI, it is not included in this enum.
55 // TODO(https://crbug.com/967987): Break this dependency.
56 enum class UserSelectableOsType {
57   kOsApps,
58   kFirstType = kOsApps,
59 
60   kOsPreferences,
61   kOsWifiConfigurations,
62   kLastType = kOsWifiConfigurations
63 };
64 
65 using UserSelectableOsTypeSet = EnumSet<UserSelectableOsType,
66                                         UserSelectableOsType::kFirstType,
67                                         UserSelectableOsType::kLastType>;
68 
69 const char* GetUserSelectableOsTypeName(UserSelectableOsType type);
70 ModelTypeSet UserSelectableOsTypeToAllModelTypes(UserSelectableOsType type);
71 ModelType UserSelectableOsTypeToCanonicalModelType(UserSelectableOsType type);
72 
73 // Returns the type if the string matches a known OS type.
74 base::Optional<UserSelectableOsType> GetUserSelectableOsTypeFromString(
75     const std::string& type);
76 #endif  // defined(OS_CHROMEOS)
77 
78 }  // namespace syncer
79 
80 #endif  // COMPONENTS_SYNC_BASE_USER_SELECTABLE_TYPE_H_
81