user_selectable_type.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. #ifndef COMPONENTS_SYNC_BASE_USER_SELECTABLE_TYPE_H_
  5. #define COMPONENTS_SYNC_BASE_USER_SELECTABLE_TYPE_H_
  6. #include <string>
  7. #include "base/containers/enum_set.h"
  8. #include "build/chromeos_buildflags.h"
  9. #include "components/sync/base/model_type.h"
  10. #include "third_party/abseil-cpp/absl/types/optional.h"
  11. namespace syncer {
  12. // TODO(crbug.com/1286405): once it's impossible to launch Ash-browser only
  13. // UserSelectableOsType will be relevant for Ash, guard UserSelectableType with
  14. // #if !BUILDFLAG(IS_CHROMEOS_ASH) and remove lower level Ash-specific code.
  15. enum class UserSelectableType {
  16. kBookmarks,
  17. kFirstType = kBookmarks,
  18. kPreferences,
  19. kPasswords,
  20. kAutofill,
  21. kThemes,
  22. kHistory,
  23. kExtensions,
  24. kApps,
  25. kReadingList,
  26. kTabs,
  27. kWifiConfigurations,
  28. kLastType = kWifiConfigurations
  29. };
  30. using UserSelectableTypeSet = base::EnumSet<UserSelectableType,
  31. UserSelectableType::kFirstType,
  32. UserSelectableType::kLastType>;
  33. const char* GetUserSelectableTypeName(UserSelectableType type);
  34. // Returns the type if the string matches a known type.
  35. absl::optional<UserSelectableType> GetUserSelectableTypeFromString(
  36. const std::string& type);
  37. std::string UserSelectableTypeSetToString(UserSelectableTypeSet types);
  38. ModelTypeSet UserSelectableTypeToAllModelTypes(UserSelectableType type);
  39. ModelType UserSelectableTypeToCanonicalModelType(UserSelectableType type);
  40. #if BUILDFLAG(IS_CHROMEOS_ASH)
  41. // Chrome OS provides a separate UI with sync controls for OS data types. Note
  42. // that wallpaper is a special case due to its reliance on apps, so while it
  43. // appears in the UI, it is not included in this enum.
  44. // TODO(https://crbug.com/967987): Break this dependency.
  45. enum class UserSelectableOsType {
  46. kOsApps,
  47. kFirstType = kOsApps,
  48. kOsPreferences,
  49. kOsWifiConfigurations,
  50. kLastType = kOsWifiConfigurations
  51. };
  52. using UserSelectableOsTypeSet = base::EnumSet<UserSelectableOsType,
  53. UserSelectableOsType::kFirstType,
  54. UserSelectableOsType::kLastType>;
  55. const char* GetUserSelectableOsTypeName(UserSelectableOsType type);
  56. std::string UserSelectableOsTypeSetToString(UserSelectableOsTypeSet types);
  57. ModelTypeSet UserSelectableOsTypeToAllModelTypes(UserSelectableOsType type);
  58. ModelType UserSelectableOsTypeToCanonicalModelType(UserSelectableOsType type);
  59. // Returns the type if the string matches a known OS type.
  60. absl::optional<UserSelectableOsType> GetUserSelectableOsTypeFromString(
  61. const std::string& type);
  62. #endif // BUILDFLAG(IS_CHROMEOS_ASH)
  63. } // namespace syncer
  64. #endif // COMPONENTS_SYNC_BASE_USER_SELECTABLE_TYPE_H_