Commit de4987eb authored by Josh Nohle's avatar Josh Nohle Committed by Commit Bot

[DeviceSync v2]: Add CryptAuth BetterTogether feature type strings

These strings identify the supported and enabled states of
BetterTogether features. They are used in DeviceSync v2 RPCs
BatchNotifyGroupDevices, BatchGetFeatureStatuses, and
BatchSetFeatureStatuses.

Bug: 951969
Change-Id: I3f922f7aa0dcbcb0f8656519905d706b21666508
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1684244Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Commit-Queue: Josh Nohle <nohle@chromium.org>
Auto-Submit: Josh Nohle <nohle@chromium.org>
Cr-Commit-Position: refs/heads/master@{#675765}
parent 7dc0f0a2
......@@ -8,6 +8,8 @@ static_library("device_sync") {
sources = [
"cryptauth_api_call_flow.cc",
"cryptauth_api_call_flow.h",
"cryptauth_better_together_feature_types.cc",
"cryptauth_better_together_feature_types.h",
"cryptauth_client.h",
"cryptauth_client_impl.cc",
"cryptauth_client_impl.h",
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromeos/services/device_sync/cryptauth_better_together_feature_types.h"
#include "base/logging.h"
#include "base/no_destructor.h"
namespace chromeos {
namespace device_sync {
const char kCryptAuthFeatureTypeBetterTogetherHostSupported[] =
"BETTER_TOGETHER_HOST_SUPPORTED";
const char kCryptAuthFeatureTypeBetterTogetherClientSupported[] =
"BETTER_TOGETHER_CLIENT_SUPPORTED";
const char kCryptAuthFeatureTypeEasyUnlockHostSupported[] =
"EASY_UNLOCK_HOST_SUPPORTED";
const char kCryptAuthFeatureTypeEasyUnlockClientSupported[] =
"EASY_UNLOCK_CLIENT_SUPPORTED";
const char kCryptAuthFeatureTypeMagicTetherHostSupported[] =
"MAGIC_TETHER_HOST_SUPPORTED";
const char kCryptAuthFeatureTypeMagicTetherClientSupported[] =
"MAGIC_TETHER_CLIENT_SUPPORTED";
const char kCryptAuthFeatureTypeSmsConnectHostSupported[] =
"SMS_CONNECT_HOST_SUPPORTED";
const char kCryptAuthFeatureTypeSmsConnectClientSupported[] =
"SMS_CONNECT_CLIENT_SUPPORTED";
const char kCryptAuthFeatureTypeBetterTogetherHostEnabled[] =
"BETTER_TOGETHER_HOST";
const char kCryptAuthFeatureTypeBetterTogetherClientEnabled[] =
"BETTER_TOGETHER_CLIENT";
const char kCryptAuthFeatureTypeEasyUnlockHostEnabled[] = "EASY_UNLOCK_HOST";
const char kCryptAuthFeatureTypeEasyUnlockClientEnabled[] =
"EASY_UNLOCK_CLIENT";
const char kCryptAuthFeatureTypeMagicTetherHostEnabled[] = "MAGIC_TETHER_HOST";
const char kCryptAuthFeatureTypeMagicTetherClientEnabled[] =
"MAGIC_TETHER_CLIENT";
const char kCryptAuthFeatureTypeSmsConnectHostEnabled[] = "SMS_CONNECT_HOST";
const char kCryptAuthFeatureTypeSmsConnectClientEnabled[] =
"SMS_CONNECT_CLIENT";
const base::flat_set<std::string>& GetBetterTogetherFeatureTypes() {
static const base::NoDestructor<base::flat_set<std::string>> feature_set([] {
return base::flat_set<std::string>{
kCryptAuthFeatureTypeBetterTogetherHostSupported,
kCryptAuthFeatureTypeBetterTogetherClientSupported,
kCryptAuthFeatureTypeEasyUnlockHostSupported,
kCryptAuthFeatureTypeEasyUnlockClientSupported,
kCryptAuthFeatureTypeMagicTetherHostSupported,
kCryptAuthFeatureTypeMagicTetherClientSupported,
kCryptAuthFeatureTypeSmsConnectHostSupported,
kCryptAuthFeatureTypeSmsConnectClientSupported,
kCryptAuthFeatureTypeBetterTogetherHostEnabled,
kCryptAuthFeatureTypeBetterTogetherClientEnabled,
kCryptAuthFeatureTypeEasyUnlockHostEnabled,
kCryptAuthFeatureTypeEasyUnlockClientEnabled,
kCryptAuthFeatureTypeMagicTetherHostEnabled,
kCryptAuthFeatureTypeMagicTetherClientEnabled,
kCryptAuthFeatureTypeSmsConnectHostEnabled,
kCryptAuthFeatureTypeSmsConnectClientEnabled};
}());
return *feature_set;
}
const base::flat_set<std::string>& GetSupportedBetterTogetherFeatureTypes() {
static const base::NoDestructor<base::flat_set<std::string>> supported_set(
[] {
return base::flat_set<std::string>{
kCryptAuthFeatureTypeBetterTogetherHostSupported,
kCryptAuthFeatureTypeBetterTogetherClientSupported,
kCryptAuthFeatureTypeEasyUnlockHostSupported,
kCryptAuthFeatureTypeEasyUnlockClientSupported,
kCryptAuthFeatureTypeMagicTetherHostSupported,
kCryptAuthFeatureTypeMagicTetherClientSupported,
kCryptAuthFeatureTypeSmsConnectHostSupported,
kCryptAuthFeatureTypeSmsConnectClientSupported};
}());
return *supported_set;
}
const base::flat_set<std::string>& GetEnabledBetterTogetherFeatureTypes() {
static const base::NoDestructor<base::flat_set<std::string>> enabled_set([] {
return base::flat_set<std::string>{
kCryptAuthFeatureTypeBetterTogetherHostEnabled,
kCryptAuthFeatureTypeBetterTogetherClientEnabled,
kCryptAuthFeatureTypeEasyUnlockHostEnabled,
kCryptAuthFeatureTypeEasyUnlockClientEnabled,
kCryptAuthFeatureTypeMagicTetherHostEnabled,
kCryptAuthFeatureTypeMagicTetherClientEnabled,
kCryptAuthFeatureTypeSmsConnectHostEnabled,
kCryptAuthFeatureTypeSmsConnectClientEnabled};
}());
return *enabled_set;
}
multidevice::SoftwareFeature BetterTogetherFeatureTypeStringToSoftwareFeature(
const std::string& feature_type_string) {
if (feature_type_string == kCryptAuthFeatureTypeBetterTogetherHostSupported ||
feature_type_string == kCryptAuthFeatureTypeBetterTogetherHostEnabled) {
return multidevice::SoftwareFeature::kBetterTogetherHost;
}
if (feature_type_string ==
kCryptAuthFeatureTypeBetterTogetherClientSupported ||
feature_type_string == kCryptAuthFeatureTypeBetterTogetherClientEnabled) {
return multidevice::SoftwareFeature::kBetterTogetherClient;
}
if (feature_type_string == kCryptAuthFeatureTypeEasyUnlockHostSupported ||
feature_type_string == kCryptAuthFeatureTypeEasyUnlockHostEnabled) {
return multidevice::SoftwareFeature::kSmartLockHost;
}
if (feature_type_string == kCryptAuthFeatureTypeEasyUnlockClientSupported ||
feature_type_string == kCryptAuthFeatureTypeEasyUnlockClientEnabled) {
return multidevice::SoftwareFeature::kSmartLockClient;
}
if (feature_type_string == kCryptAuthFeatureTypeMagicTetherHostSupported ||
feature_type_string == kCryptAuthFeatureTypeMagicTetherHostEnabled) {
return multidevice::SoftwareFeature::kInstantTetheringHost;
}
if (feature_type_string == kCryptAuthFeatureTypeMagicTetherClientSupported ||
feature_type_string == kCryptAuthFeatureTypeMagicTetherClientEnabled) {
return multidevice::SoftwareFeature::kInstantTetheringClient;
}
if (feature_type_string == kCryptAuthFeatureTypeSmsConnectHostSupported ||
feature_type_string == kCryptAuthFeatureTypeSmsConnectHostEnabled) {
return multidevice::SoftwareFeature::kMessagesForWebHost;
}
DCHECK(feature_type_string ==
kCryptAuthFeatureTypeSmsConnectClientSupported ||
feature_type_string == kCryptAuthFeatureTypeSmsConnectClientEnabled);
return multidevice::SoftwareFeature::kMessagesForWebClient;
}
} // namespace device_sync
} // namespace chromeos
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMEOS_SERVICES_DEVICE_SYNC_CRYPTAUTH_BETTER_TOGETHER_FEATURE_TYPES_H_
#define CHROMEOS_SERVICES_DEVICE_SYNC_CRYPTAUTH_BETTER_TOGETHER_FEATURE_TYPES_H_
#include <string>
#include "base/containers/flat_set.h"
#include "chromeos/components/multidevice/software_feature.h"
namespace chromeos {
namespace device_sync {
// Strings used by CryptAuth to identify the supported and enabled states of
// BetterTogether features. They are used in the "feature_type(s)" fields of the
// DeviceSync v2 RPCs BatchNotifyGroupDevices, BatchGetFeatureStatuses, and
// BatchSetFeatureStatuses.
extern const char kCryptAuthFeatureTypeBetterTogetherHostSupported[];
extern const char kCryptAuthFeatureTypeBetterTogetherClientSupported[];
extern const char kCryptAuthFeatureTypeEasyUnlockHostSupported[];
extern const char kCryptAuthFeatureTypeEasyUnlockClientSupported[];
extern const char kCryptAuthFeatureTypeMagicTetherHostSupported[];
extern const char kCryptAuthFeatureTypeMagicTetherClientSupported[];
extern const char kCryptAuthFeatureTypeSmsConnectHostSupported[];
extern const char kCryptAuthFeatureTypeSmsConnectClientSupported[];
extern const char kCryptAuthFeatureTypeBetterTogetherHostEnabled[];
extern const char kCryptAuthFeatureTypeBetterTogetherClientEnabled[];
extern const char kCryptAuthFeatureTypeEasyUnlockHostEnabled[];
extern const char kCryptAuthFeatureTypeEasyUnlockClientEnabled[];
extern const char kCryptAuthFeatureTypeMagicTetherHostEnabled[];
extern const char kCryptAuthFeatureTypeMagicTetherClientEnabled[];
extern const char kCryptAuthFeatureTypeSmsConnectHostEnabled[];
extern const char kCryptAuthFeatureTypeSmsConnectClientEnabled[];
const base::flat_set<std::string>& GetBetterTogetherFeatureTypes();
const base::flat_set<std::string>& GetSupportedBetterTogetherFeatureTypes();
const base::flat_set<std::string>& GetEnabledBetterTogetherFeatureTypes();
multidevice::SoftwareFeature BetterTogetherFeatureTypeStringToSoftwareFeature(
const std::string& feature_type_string);
} // namespace device_sync
} // namespace chromeos
#endif // CHROMEOS_SERVICES_DEVICE_SYNC_CRYPTAUTH_BETTER_TOGETHER_FEATURE_TYPES_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment