#include "components/sync/base/user_selectable_type.h"
#include <optional>
#include <ostream>
#include "base/notreached.h"
#include "build/chromeos_buildflags.h"
#include "components/sync/base/data_type.h"
namespace syncer {
namespace {
struct UserSelectableTypeInfo { … };
constexpr char kBookmarksTypeName[] = …;
constexpr char kPreferencesTypeName[] = …;
constexpr char kPasswordsTypeName[] = …;
constexpr char kAutofillTypeName[] = …;
constexpr char kThemesTypeName[] = …;
constexpr char kHistoryTypeName[] = …;
constexpr char kExtensionsTypeName[] = …;
constexpr char kAppsTypeName[] = …;
constexpr char kReadingListTypeName[] = …;
constexpr char kTabsTypeName[] = …;
constexpr char kSavedTabGroupsTypeName[] = …;
constexpr char kSharedTabGroupDataTypeName[] = …;
constexpr char kPaymentsTypeName[] = …;
constexpr char kProductComparisonTypeName[] = …;
constexpr char kCookiesTypeName[] = …;
UserSelectableTypeInfo GetUserSelectableTypeInfo(UserSelectableType type) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
constexpr char kOsAppsTypeName[] = "osApps";
constexpr char kOsPreferencesTypeName[] = "osPreferences";
constexpr char kOsWifiConfigurationsTypeName[] = "osWifiConfigurations";
constexpr char kWifiConfigurationsTypeName[] = "wifiConfigurations";
UserSelectableTypeInfo GetUserSelectableOsTypeInfo(UserSelectableOsType type) {
switch (type) {
case UserSelectableOsType::kOsApps:
return {kOsAppsTypeName,
APPS,
{APP_LIST, APPS, APP_SETTINGS, ARC_PACKAGE, WEB_APPS}};
case UserSelectableOsType::kOsPreferences:
return {kOsPreferencesTypeName,
OS_PREFERENCES,
{OS_PREFERENCES, OS_PRIORITY_PREFERENCES, PRINTERS,
PRINTERS_AUTHORIZATION_SERVERS, WORKSPACE_DESK}};
case UserSelectableOsType::kOsWifiConfigurations:
return {kOsWifiConfigurationsTypeName,
WIFI_CONFIGURATIONS,
{WIFI_CONFIGURATIONS}};
}
}
#endif
}
const char* GetUserSelectableTypeName(UserSelectableType type) { … }
std::optional<UserSelectableType> GetUserSelectableTypeFromString(
const std::string& type) { … }
std::string UserSelectableTypeSetToString(UserSelectableTypeSet types) { … }
DataTypeSet UserSelectableTypeToAllDataTypes(UserSelectableType type) { … }
DataType UserSelectableTypeToCanonicalDataType(UserSelectableType type) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
const char* GetUserSelectableOsTypeName(UserSelectableOsType type) {
return GetUserSelectableOsTypeInfo(type).type_name;
}
std::string UserSelectableOsTypeSetToString(UserSelectableOsTypeSet types) {
std::string result;
for (UserSelectableOsType type : types) {
if (!result.empty()) {
result += ", ";
}
result += GetUserSelectableOsTypeName(type);
}
return result;
}
std::optional<UserSelectableOsType> GetUserSelectableOsTypeFromString(
const std::string& type) {
if (type == kOsAppsTypeName) {
return UserSelectableOsType::kOsApps;
}
if (type == kOsPreferencesTypeName) {
return UserSelectableOsType::kOsPreferences;
}
if (type == kOsWifiConfigurationsTypeName) {
return UserSelectableOsType::kOsWifiConfigurations;
}
if (type == kAppsTypeName) {
return UserSelectableOsType::kOsApps;
}
if (type == kWifiConfigurationsTypeName) {
return UserSelectableOsType::kOsWifiConfigurations;
}
if (type == kPreferencesTypeName) {
return UserSelectableOsType::kOsPreferences;
}
return std::nullopt;
}
DataTypeSet UserSelectableOsTypeToAllDataTypes(UserSelectableOsType type) {
return GetUserSelectableOsTypeInfo(type).data_type_group;
}
DataType UserSelectableOsTypeToCanonicalDataType(UserSelectableOsType type) {
return GetUserSelectableOsTypeInfo(type).canonical_data_type;
}
#endif
std::ostream& operator<<(std::ostream& stream, const UserSelectableType& type) { … }
std::ostream& operator<<(std::ostream& stream,
const UserSelectableTypeSet& types) { … }
}