Commit c6d26c96 authored by Kyle Horimoto's avatar Kyle Horimoto Committed by Commit Bot

[CrOS MultiDevice] Create shared multidevice_types.mojom.

This CL moves RemoteDevice, BeaconSeed, SoftwareFeature, and
SoftwareFeatureState to a shared multidevice_types.mojom file, cleanly
separating them from the DeviceSync service. Previously, these Mojo
definitions were part of that service even though they are shared among
several services, so including them as part of DeviceSync created an
unnecessary dependency on that service which shouldn't exist.

Change-Id: Ie20cd22f63bd35441c1a5879d71bb5fd3c473bf4
Bug: 912743
Reviewed-on: https://chromium-review.googlesource.com/c/1363905Reviewed-by: default avatarRyan Hansberry <hansberry@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Commit-Queue: Kyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#614828}
parent 49226d7b
...@@ -26,12 +26,14 @@ js_library("post_oobe_delegate") { ...@@ -26,12 +26,14 @@ js_library("post_oobe_delegate") {
] ]
extra_deps = [ extra_deps = [
"//chromeos/components/multidevice/mojom:mojom_js",
"//chromeos/services/device_sync/public/mojom:mojom_js", "//chromeos/services/device_sync/public/mojom:mojom_js",
"//chromeos/services/multidevice_setup/public/mojom:mojom_js", "//chromeos/services/multidevice_setup/public/mojom:mojom_js",
"//mojo/public/mojom/base:base_js", "//mojo/public/mojom/base:base_js",
] ]
externs_list = [ externs_list = [
"$root_gen_dir/chromeos/components/multidevice/mojom/multidevice_types.mojom.externs.js",
"$root_gen_dir/chromeos/services/device_sync/public/mojom/device_sync.mojom.externs.js", "$root_gen_dir/chromeos/services/device_sync/public/mojom/device_sync.mojom.externs.js",
"$root_gen_dir/chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.externs.js", "$root_gen_dir/chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.externs.js",
"$root_gen_dir/mojo/public/mojom/base/time.mojom.externs.js", "$root_gen_dir/mojo/public/mojom/base/time.mojom.externs.js",
......
...@@ -63,6 +63,7 @@ source_set("unit_tests") { ...@@ -63,6 +63,7 @@ source_set("unit_tests") {
":multidevice", ":multidevice",
":test_support", ":test_support",
"//base/test:test_support", "//base/test:test_support",
"//chromeos/components/multidevice/mojom:unit_tests",
"//components/cryptauth/proto", "//components/cryptauth/proto",
"//testing/gtest", "//testing/gtest",
] ]
......
include_rules = [ include_rules = [
"+components/cryptauth", "+components/cryptauth",
"+mojo/public/cpp",
] ]
# Copyright 2018 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.
import("//mojo/public/tools/bindings/mojom.gni")
mojom("mojom") {
sources = [
"multidevice_types.mojom",
]
public_deps = [
"//mojo/public/mojom/base",
]
}
source_set("unit_tests") {
testonly = true
sources = [
"multidevice_mojom_traits_unittest.cc",
]
deps = [
":mojom",
"//base",
"//base/test:test_support",
"//chromeos/components/multidevice",
"//mojo/public/cpp/test_support:test_utils",
"//testing/gtest",
]
}
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
per-file *_mojom_traits*.*=set noparent
per-file *_mojom_traits*.*=file://ipc/SECURITY_OWNERS
per-file *.typemap=set noparent
per-file *.typemap=file://ipc/SECURITY_OWNERS
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
mojom = "//chromeos/services/device_sync/public/mojom/device_sync.mojom" mojom = "//chromeos/components/multidevice/mojom/multidevice_types.mojom"
public_headers = [ public_headers = [
"//chromeos/components/multidevice/beacon_seed.h", "//chromeos/components/multidevice/beacon_seed.h",
...@@ -10,13 +10,12 @@ public_headers = [ ...@@ -10,13 +10,12 @@ public_headers = [
"//chromeos/components/multidevice/software_feature.h", "//chromeos/components/multidevice/software_feature.h",
] ]
traits_headers = [ traits_headers =
"//chromeos/services/device_sync/public/mojom/device_sync_mojom_traits.h", [ "//chromeos/components/multidevice/mojom/multidevice_mojom_traits.h" ]
]
sources = [ sources = [
"//chromeos/services/device_sync/public/mojom/device_sync_mojom_traits.cc", "//chromeos/components/multidevice/mojom/multidevice_mojom_traits.cc",
"//chromeos/services/device_sync/public/mojom/device_sync_mojom_traits.h", "//chromeos/components/multidevice/mojom/multidevice_mojom_traits.h",
] ]
public_deps = [ public_deps = [
...@@ -25,7 +24,7 @@ public_deps = [ ...@@ -25,7 +24,7 @@ public_deps = [
] ]
type_mappings = [ type_mappings = [
"chromeos.device_sync.mojom.BeaconSeed=chromeos::multidevice::BeaconSeed", "chromeos.multidevice.mojom.BeaconSeed=chromeos::multidevice::BeaconSeed",
"chromeos.device_sync.mojom.RemoteDevice=chromeos::multidevice::RemoteDevice", "chromeos.multidevice.mojom.RemoteDevice=chromeos::multidevice::RemoteDevice",
"chromeos.device_sync.mojom.SoftwareFeature=chromeos::multidevice::SoftwareFeature", "chromeos.multidevice.mojom.SoftwareFeature=chromeos::multidevice::SoftwareFeature",
] ]
...@@ -2,25 +2,25 @@ ...@@ -2,25 +2,25 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROMEOS_SERVICES_DEVICE_SYNC_PUBLIC_MOJOM_DEVICE_SYNC_MOJOM_TRAITS_H_ #ifndef CHROMEOS_COMPONENTS_MULTIDEVICE_MOJOM_MULTIDEVICE_MOJOM_TRAITS_H_
#define CHROMEOS_SERVICES_DEVICE_SYNC_PUBLIC_MOJOM_DEVICE_SYNC_MOJOM_TRAITS_H_ #define CHROMEOS_COMPONENTS_MULTIDEVICE_MOJOM_MULTIDEVICE_MOJOM_TRAITS_H_
#include <string> #include <string>
#include <vector> #include <vector>
#include "base/time/time.h" #include "base/time/time.h"
#include "chromeos/components/multidevice/beacon_seed.h" #include "chromeos/components/multidevice/beacon_seed.h"
#include "chromeos/components/multidevice/mojom/multidevice_types.mojom.h"
#include "chromeos/components/multidevice/remote_device.h" #include "chromeos/components/multidevice/remote_device.h"
#include "chromeos/components/multidevice/software_feature.h" #include "chromeos/components/multidevice/software_feature.h"
#include "chromeos/components/multidevice/software_feature_state.h" #include "chromeos/components/multidevice/software_feature_state.h"
#include "chromeos/services/device_sync/public/mojom/device_sync.mojom.h"
#include "mojo/public/cpp/bindings/enum_traits.h" #include "mojo/public/cpp/bindings/enum_traits.h"
#include "mojo/public/cpp/bindings/struct_traits.h" #include "mojo/public/cpp/bindings/struct_traits.h"
namespace mojo { namespace mojo {
template <> template <>
class StructTraits<chromeos::device_sync::mojom::BeaconSeedDataView, class StructTraits<chromeos::multidevice::mojom::BeaconSeedDataView,
chromeos::multidevice::BeaconSeed> { chromeos::multidevice::BeaconSeed> {
public: public:
static const std::string& data( static const std::string& data(
...@@ -30,12 +30,12 @@ class StructTraits<chromeos::device_sync::mojom::BeaconSeedDataView, ...@@ -30,12 +30,12 @@ class StructTraits<chromeos::device_sync::mojom::BeaconSeedDataView,
static base::Time end_time( static base::Time end_time(
const chromeos::multidevice::BeaconSeed& beacon_seed); const chromeos::multidevice::BeaconSeed& beacon_seed);
static bool Read(chromeos::device_sync::mojom::BeaconSeedDataView in, static bool Read(chromeos::multidevice::mojom::BeaconSeedDataView in,
chromeos::multidevice::BeaconSeed* out); chromeos::multidevice::BeaconSeed* out);
}; };
template <> template <>
class StructTraits<chromeos::device_sync::mojom::RemoteDeviceDataView, class StructTraits<chromeos::multidevice::mojom::RemoteDeviceDataView,
chromeos::multidevice::RemoteDevice> { chromeos::multidevice::RemoteDevice> {
public: public:
static std::string device_id( static std::string device_id(
...@@ -54,31 +54,31 @@ class StructTraits<chromeos::device_sync::mojom::RemoteDeviceDataView, ...@@ -54,31 +54,31 @@ class StructTraits<chromeos::device_sync::mojom::RemoteDeviceDataView,
static const std::vector<chromeos::multidevice::BeaconSeed>& beacon_seeds( static const std::vector<chromeos::multidevice::BeaconSeed>& beacon_seeds(
const chromeos::multidevice::RemoteDevice& remote_device); const chromeos::multidevice::RemoteDevice& remote_device);
static bool Read(chromeos::device_sync::mojom::RemoteDeviceDataView in, static bool Read(chromeos::multidevice::mojom::RemoteDeviceDataView in,
chromeos::multidevice::RemoteDevice* out); chromeos::multidevice::RemoteDevice* out);
}; };
template <> template <>
class EnumTraits<chromeos::device_sync::mojom::SoftwareFeature, class EnumTraits<chromeos::multidevice::mojom::SoftwareFeature,
chromeos::multidevice::SoftwareFeature> { chromeos::multidevice::SoftwareFeature> {
public: public:
static chromeos::device_sync::mojom::SoftwareFeature ToMojom( static chromeos::multidevice::mojom::SoftwareFeature ToMojom(
chromeos::multidevice::SoftwareFeature input); chromeos::multidevice::SoftwareFeature input);
static bool FromMojom(chromeos::device_sync::mojom::SoftwareFeature input, static bool FromMojom(chromeos::multidevice::mojom::SoftwareFeature input,
chromeos::multidevice::SoftwareFeature* out); chromeos::multidevice::SoftwareFeature* out);
}; };
template <> template <>
class EnumTraits<chromeos::device_sync::mojom::SoftwareFeatureState, class EnumTraits<chromeos::multidevice::mojom::SoftwareFeatureState,
chromeos::multidevice::SoftwareFeatureState> { chromeos::multidevice::SoftwareFeatureState> {
public: public:
static chromeos::device_sync::mojom::SoftwareFeatureState ToMojom( static chromeos::multidevice::mojom::SoftwareFeatureState ToMojom(
chromeos::multidevice::SoftwareFeatureState input); chromeos::multidevice::SoftwareFeatureState input);
static bool FromMojom( static bool FromMojom(
chromeos::device_sync::mojom::SoftwareFeatureState input, chromeos::multidevice::mojom::SoftwareFeatureState input,
chromeos::multidevice::SoftwareFeatureState* out); chromeos::multidevice::SoftwareFeatureState* out);
}; };
} // namespace mojo } // namespace mojo
#endif // CHROMEOS_SERVICES_DEVICE_SYNC_PUBLIC_MOJOM_DEVICE_SYNC_MOJOM_TRAITS_H_ #endif // CHROMEOS_COMPONENTS_MULTIDEVICE_MOJOM_MULTIDEVICE_MOJOM_TRAITS_H_
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chromeos/services/device_sync/public/mojom/device_sync_mojom_traits.h" #include "chromeos/components/multidevice/mojom/multidevice_mojom_traits.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chromeos/components/multidevice/beacon_seed.h" #include "chromeos/components/multidevice/beacon_seed.h"
#include "chromeos/components/multidevice/mojom/multidevice_types.mojom.h"
#include "chromeos/components/multidevice/remote_device.h" #include "chromeos/components/multidevice/remote_device.h"
#include "chromeos/services/device_sync/public/mojom/device_sync.mojom.h"
#include "mojo/public/cpp/base/time_mojom_traits.h" #include "mojo/public/cpp/base/time_mojom_traits.h"
#include "mojo/public/cpp/test_support/test_utils.h" #include "mojo/public/cpp/test_support/test_utils.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -27,19 +27,19 @@ chromeos::multidevice::BeaconSeed CreateTestBeaconSeed() { ...@@ -27,19 +27,19 @@ chromeos::multidevice::BeaconSeed CreateTestBeaconSeed() {
} // namespace } // namespace
TEST(DeviceSyncMojomStructTraitsTest, BeaconSeed) { TEST(MultiDeviceMojomStructTraitsTest, BeaconSeed) {
chromeos::multidevice::BeaconSeed input = CreateTestBeaconSeed(); chromeos::multidevice::BeaconSeed input = CreateTestBeaconSeed();
chromeos::multidevice::BeaconSeed output; chromeos::multidevice::BeaconSeed output;
EXPECT_TRUE(mojo::test::SerializeAndDeserialize< EXPECT_TRUE(mojo::test::SerializeAndDeserialize<
chromeos::device_sync::mojom::BeaconSeed>(&input, &output)); chromeos::multidevice::mojom::BeaconSeed>(&input, &output));
EXPECT_EQ(kTestBeaconSeedData, output.data()); EXPECT_EQ(kTestBeaconSeedData, output.data());
EXPECT_EQ(kTestBeaconSeedStartTimeMillis, output.start_time().ToJavaTime()); EXPECT_EQ(kTestBeaconSeedStartTimeMillis, output.start_time().ToJavaTime());
EXPECT_EQ(kTestBeaconSeedEndTimeMillis, output.end_time().ToJavaTime()); EXPECT_EQ(kTestBeaconSeedEndTimeMillis, output.end_time().ToJavaTime());
} }
TEST(DeviceSyncMojomStructTraitsTest, RemoteDevice) { TEST(MultiDeviceMojomStructTraitsTest, RemoteDevice) {
std::map<chromeos::multidevice::SoftwareFeature, std::map<chromeos::multidevice::SoftwareFeature,
chromeos::multidevice::SoftwareFeatureState> chromeos::multidevice::SoftwareFeatureState>
software_features = software_features =
...@@ -63,7 +63,7 @@ TEST(DeviceSyncMojomStructTraitsTest, RemoteDevice) { ...@@ -63,7 +63,7 @@ TEST(DeviceSyncMojomStructTraitsTest, RemoteDevice) {
chromeos::multidevice::RemoteDevice output; chromeos::multidevice::RemoteDevice output;
EXPECT_TRUE(mojo::test::SerializeAndDeserialize< EXPECT_TRUE(mojo::test::SerializeAndDeserialize<
chromeos::device_sync::mojom::RemoteDevice>(&input, &output)); chromeos::multidevice::mojom::RemoteDevice>(&input, &output));
EXPECT_EQ("userId", output.user_id); EXPECT_EQ("userId", output.user_id);
EXPECT_EQ("name", output.name); EXPECT_EQ("name", output.name);
...@@ -94,11 +94,11 @@ TEST(DeviceSyncMojomEnumTraitsTest, SoftwareFeature) { ...@@ -94,11 +94,11 @@ TEST(DeviceSyncMojomEnumTraitsTest, SoftwareFeature) {
for (auto feature_in : kTestSoftwareFeatures) { for (auto feature_in : kTestSoftwareFeatures) {
chromeos::multidevice::SoftwareFeature feature_out; chromeos::multidevice::SoftwareFeature feature_out;
chromeos::device_sync::mojom::SoftwareFeature serialized_feature = chromeos::multidevice::mojom::SoftwareFeature serialized_feature =
mojo::EnumTraits< mojo::EnumTraits<
chromeos::device_sync::mojom::SoftwareFeature, chromeos::multidevice::mojom::SoftwareFeature,
chromeos::multidevice::SoftwareFeature>::ToMojom(feature_in); chromeos::multidevice::SoftwareFeature>::ToMojom(feature_in);
ASSERT_TRUE((mojo::EnumTraits<chromeos::device_sync::mojom::SoftwareFeature, ASSERT_TRUE((mojo::EnumTraits<chromeos::multidevice::mojom::SoftwareFeature,
chromeos::multidevice::SoftwareFeature>:: chromeos::multidevice::SoftwareFeature>::
FromMojom(serialized_feature, &feature_out))); FromMojom(serialized_feature, &feature_out)));
EXPECT_EQ(feature_in, feature_out); EXPECT_EQ(feature_in, feature_out);
......
// Copyright 2018 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.
module chromeos.multidevice.mojom;
import "mojo/public/mojom/base/time.mojom";
// Enumeration of software features which can be enabled/disabled for a given
// device. Each feature has a host and client portion; here, "host" refers to
// the associated phone which provides the feature (at most one host per
// account), and "client" refers to the Chromebook which consumes the feature
// (multiple clients allowed per account).
enum SoftwareFeature {
// The Better Together (MultiDevice) setup flow feature allows users to go
// through a unified setup flow which enrolls the device for all multi-device
// features.
BETTER_TOGETHER_HOST = 1,
BETTER_TOGETHER_CLIENT = 2,
// EasyUnlock gives users the ability to unlock their Chromebooks with their
// phone instead of by typing a password.
EASY_UNLOCK_HOST = 3,
EASY_UNLOCK_CLIENT = 4,
// Magic Tether (Instant Tethering) gives users the ability to use their
// phone's Internet connectivity on their Chromebooks via an automated flow
// which does not require any phone-side interaction.
MAGIC_TETHER_HOST = 5,
MAGIC_TETHER_CLIENT = 6,
// SMS Connect gives users the ability to read and reply to their text
// messages from their Chromebooks.
SMS_CONNECT_HOST = 7,
SMS_CONNECT_CLIENT = 8
};
// Enumeration of what value a SoftwareFeature can be.
enum SoftwareFeatureState {
kNotSupported,
kSupported,
kEnabled
};
// Used to generate rotating BLE advertisement data, which is necessary to
// establish a BLE communication channel between two devices. To
// create the BLE channel, both devices must possess the other's BeaconSeeds.
struct BeaconSeed {
string data;
mojo_base.mojom.Time start_time;
mojo_base.mojom.Time end_time;
};
// Metadata describing a remote device with which the current device can
// communicate.
struct RemoteDevice {
// Unique identifier of the device. This field is guaranteed to be
// human-readable (i.e., it does not contain non-ASCII characters).
string device_id;
// Identifier for the user to whom this device is registered.
string user_id;
// Human-readable device name; by default, this is the name of the device
// model, but this value is editable.
string device_name;
// Encryption key used for communication with this device.
string persistent_symmetric_key;
// The time at which this device's metadata was last updated on the CryptAuth
// back-end.
mojo_base.mojom.Time last_update_time;
// The features which this device either does not support, supports, or has
// enabled.
map<SoftwareFeature, SoftwareFeatureState> software_features;
// Seeds belonging to the device. Each seed has start and end timestamps which
// indicate how long the seed is valid, and each device has enough associated
// seeds to keep the device connectable for over 30 days. If no new device
// metadata synced for over 30 days, it is possible that a connection will not
// be able to be established over BLE.
array<BeaconSeed> beacon_seeds;
};
...@@ -2,5 +2,4 @@ ...@@ -2,5 +2,4 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
typemaps = typemaps = [ "//chromeos/components/multidevice/mojom/multidevice.typemap" ]
[ "//chromeos/services/device_sync/public/mojom/device_sync.typemap" ]
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
<script src="proximity_auth.js"></script> <script src="proximity_auth.js"></script>
<script src="chrome://resources/js/mojo_bindings.js"></script> <script src="chrome://resources/js/mojo_bindings.js"></script>
<script src="chrome://resources/js/time.mojom.js"></script> <script src="chrome://resources/js/time.mojom.js"></script>
<script src="chrome://resources/js/chromeos/multidevice_types.mojom.js">
</script>
<script src="chrome://resources/js/chromeos/device_sync.mojom.js"></script> <script src="chrome://resources/js/chromeos/device_sync.mojom.js"></script>
<script src="chrome://resources/js/chromeos/multidevice_setup.mojom.js"> <script src="chrome://resources/js/chromeos/multidevice_setup.mojom.js">
</script> </script>
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
import("//tools/grit/grit_rule.gni")
import("//chromeos/assistant/assistant.gni") import("//chromeos/assistant/assistant.gni")
import("//tools/grit/grit_rule.gni")
assert(is_chromeos, "Non-ChromeOS builds cannot depend on //chromeos") assert(is_chromeos, "Non-ChromeOS builds cannot depend on //chromeos")
...@@ -28,6 +28,7 @@ grit("resources") { ...@@ -28,6 +28,7 @@ grit("resources") {
] ]
deps = [ deps = [
"//chromeos/components/multidevice/mojom:mojom_js",
"//chromeos/services/device_sync/public/mojom:mojom_js", "//chromeos/services/device_sync/public/mojom:mojom_js",
"//chromeos/services/multidevice_setup/public/mojom:mojom_js", "//chromeos/services/multidevice_setup/public/mojom:mojom_js",
] ]
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<grit-part> <grit-part>
<include name="IDR_MULTIDEVICE_MULTIDEVICE_TYPES_MOJOM_JS"
file="${mojom_root}/chromeos/components/multidevice/mojom/multidevice_types.mojom.js"
use_base_dir="false"
type="BINDATA"
compress="gzip" />
<include name="IDR_MULTIDEVICE_DEVICE_SYNC_MOJOM_JS" <include name="IDR_MULTIDEVICE_DEVICE_SYNC_MOJOM_JS"
file="${mojom_root}/chromeos/services/device_sync/public/mojom/device_sync.mojom.js" file="${mojom_root}/chromeos/services/device_sync/public/mojom/device_sync.mojom.js"
use_base_dir="false" use_base_dir="false"
......
...@@ -86,7 +86,6 @@ source_set("unit_tests") { ...@@ -86,7 +86,6 @@ source_set("unit_tests") {
"//chromeos/components/multidevice:test_support", "//chromeos/components/multidevice:test_support",
"//chromeos/services/device_sync/public/cpp:unit_tests", "//chromeos/services/device_sync/public/cpp:unit_tests",
"//chromeos/services/device_sync/public/mojom", "//chromeos/services/device_sync/public/mojom",
"//chromeos/services/device_sync/public/mojom:unit_tests",
"//components/cryptauth", "//components/cryptauth",
"//components/cryptauth:test_support", "//components/cryptauth:test_support",
"//components/gcm_driver:test_support", "//components/gcm_driver:test_support",
......
...@@ -11,23 +11,7 @@ mojom("mojom") { ...@@ -11,23 +11,7 @@ mojom("mojom") {
] ]
public_deps = [ public_deps = [
"//chromeos/components/multidevice/mojom",
"//mojo/public/mojom/base", "//mojo/public/mojom/base",
] ]
} }
source_set("unit_tests") {
testonly = true
sources = [
"device_sync_mojom_traits_unittest.cc",
]
deps = [
":mojom",
"//base",
"//base/test:test_support",
"//components/cryptauth",
"//mojo/public/cpp/test_support:test_utils",
"//testing/gtest",
]
}
per-file *.mojom=set noparent per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS per-file *.mojom=file://ipc/SECURITY_OWNERS
per-file *_mojom_traits*.*=set noparent
per-file *_mojom_traits*.*=file://ipc/SECURITY_OWNERS
per-file *.typemap=set noparent
per-file *.typemap=file://ipc/SECURITY_OWNERS
...@@ -4,44 +4,9 @@ ...@@ -4,44 +4,9 @@
module chromeos.device_sync.mojom; module chromeos.device_sync.mojom;
import "chromeos/components/multidevice/mojom/multidevice_types.mojom";
import "mojo/public/mojom/base/time.mojom"; import "mojo/public/mojom/base/time.mojom";
// Enumeration of software features which can be enabled/disabled for a given
// device. Each feature has a host and client portion; here, "host" refers to
// the associated phone which provides the feature (at most one host per
// account), and "client" refers to the Chromebook which consumes the feature
// (multiple clients allowed per account).
enum SoftwareFeature {
// The Better Together (MultiDevice) setup flow feature allows users to go
// through a unified setup flow which enrolls the device for all multi-device
// features.
BETTER_TOGETHER_HOST = 1,
BETTER_TOGETHER_CLIENT = 2,
// EasyUnlock gives users the ability to unlock their Chromebooks with their
// phone instead of by typing a password.
EASY_UNLOCK_HOST = 3,
EASY_UNLOCK_CLIENT = 4,
// Magic Tether (Instant Tethering) gives users the ability to use their
// phone's Internet connectivity on their Chromebooks via an automated flow
// which does not require any phone-side interaction.
MAGIC_TETHER_HOST = 5,
MAGIC_TETHER_CLIENT = 6,
// SMS Connect gives users the ability to read and reply to their text
// messages from their Chromebooks.
SMS_CONNECT_HOST = 7,
SMS_CONNECT_CLIENT = 8
};
// Enumeration of what value a SoftwareFeature can be.
enum SoftwareFeatureState {
kNotSupported,
kSupported,
kEnabled
};
enum NetworkRequestResult { enum NetworkRequestResult {
// Successful network request. // Successful network request.
kSuccess, kSuccess,
...@@ -77,52 +42,9 @@ enum NetworkRequestResult { ...@@ -77,52 +42,9 @@ enum NetworkRequestResult {
kUnknown kUnknown
}; };
// Used to generate rotating BLE advertisement data, which is necessary to
// establish a BLE communication channel between two devices. To
// create the BLE channel, both devices must possess the other's BeaconSeeds.
struct BeaconSeed {
string data;
mojo_base.mojom.Time start_time;
mojo_base.mojom.Time end_time;
};
// Metadata describing a remote device with which the current device can
// communicate.
struct RemoteDevice {
// Unique identifier of the device. Unlike |public_key|, this field is
// guaranteed to be human-readable (i.e., it does not contain non-ASCII
// characters).
string device_id;
// Identifier for the user to whom this device is registered.
string user_id;
// Human-readable device name; by default, this is the name of the device
// model, but this value is editable.
string device_name;
// Encryption key used for communication with this device.
string persistent_symmetric_key;
// The time at which this device's metadata was last updated on the CryptAuth
// back-end.
mojo_base.mojom.Time last_update_time;
// The features which this device either does not support, supports, or has
// enabled.
map<SoftwareFeature, SoftwareFeatureState> software_features;
// Seeds belonging to the device. Each seed has start and end timestamps which
// indicate how long the seed is valid, and each device has enough associated
// seeds to keep the device connectable for over 30 days. If no new device
// metadata synced for over 30 days, it is possible that a connection will not
// be able to be established over BLE.
array<BeaconSeed> beacon_seeds;
};
struct FindEligibleDevicesResponse { struct FindEligibleDevicesResponse {
array<RemoteDevice> eligible_devices; array<chromeos.multidevice.mojom.RemoteDevice> eligible_devices;
array<RemoteDevice> ineligible_devices; array<chromeos.multidevice.mojom.RemoteDevice> ineligible_devices;
}; };
struct DebugInfo { struct DebugInfo {
...@@ -177,11 +99,13 @@ interface DeviceSync { ...@@ -177,11 +99,13 @@ interface DeviceSync {
// Returns all synced devices associated with the primary account. If this // Returns all synced devices associated with the primary account. If this
// device has not yet registered with the back-end, no list is provided. // device has not yet registered with the back-end, no list is provided.
GetSyncedDevices() => (array<RemoteDevice>? devices); GetSyncedDevices() =>
(array<chromeos.multidevice.mojom.RemoteDevice>? devices);
// Returns the RemoteDevice object associated with this device. If this device // Returns the RemoteDevice object associated with this device. If this device
// has not yet registered with the back-end, no device is provided. // has not yet registered with the back-end, no device is provided.
GetLocalDeviceMetadata() => (RemoteDevice? local_device); GetLocalDeviceMetadata() =>
(chromeos.multidevice.mojom.RemoteDevice? local_device);
// Enables or disables the given software feature for the device with the // Enables or disables the given software feature for the device with the
// given public key. If |enabled| and |is_exclusive| are both true, this // given public key. If |enabled| and |is_exclusive| are both true, this
...@@ -199,7 +123,7 @@ interface DeviceSync { ...@@ -199,7 +123,7 @@ interface DeviceSync {
// all of the user's devices. // all of the user's devices.
SetSoftwareFeatureState( SetSoftwareFeatureState(
string device_public_key, string device_public_key,
SoftwareFeature software_feature, chromeos.multidevice.mojom.SoftwareFeature software_feature,
bool enabled, bool enabled,
bool is_exclusive) => (NetworkRequestResult result_code); bool is_exclusive) => (NetworkRequestResult result_code);
...@@ -211,8 +135,10 @@ interface DeviceSync { ...@@ -211,8 +135,10 @@ interface DeviceSync {
// On success, this function returns a null error_code with a valid response // On success, this function returns a null error_code with a valid response
// to the callback; on error, it returns a valid error_code string indicating // to the callback; on error, it returns a valid error_code string indicating
// the reason for failure along with a null response. // the reason for failure along with a null response.
FindEligibleDevices(SoftwareFeature software_feature) => FindEligibleDevices(
(NetworkRequestResult result_code, FindEligibleDevicesResponse? response); chromeos.multidevice.mojom.SoftwareFeature software_feature) =>
(NetworkRequestResult result_code,
FindEligibleDevicesResponse? response);
// Functions below are implemented for chrome://proximity-auth page, which is // Functions below are implemented for chrome://proximity-auth page, which is
// intended for debugging purposes only. // intended for debugging purposes only.
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
module chromeos.multidevice_setup.mojom; module chromeos.multidevice_setup.mojom;
import "chromeos/services/device_sync/public/mojom/device_sync.mojom"; import "chromeos/components/multidevice/mojom/multidevice_types.mojom";
// Enumeration of event types which can be dispatched. Only used for debugging // Enumeration of event types which can be dispatched. Only used for debugging
// purposes. // purposes.
...@@ -122,7 +122,7 @@ interface HostStatusObserver { ...@@ -122,7 +122,7 @@ interface HostStatusObserver {
// HostStatus::kNoEligibleHosts or // HostStatus::kNoEligibleHosts or
// HostStatus::kEligibleHostExistsButNoHostSet, |host_device| is null. // HostStatus::kEligibleHostExistsButNoHostSet, |host_device| is null.
OnHostStatusChanged(HostStatus host_status, OnHostStatusChanged(HostStatus host_status,
chromeos.device_sync.mojom.RemoteDevice? host_device); chromeos.multidevice.mojom.RemoteDevice? host_device);
}; };
interface FeatureStateObserver { interface FeatureStateObserver {
...@@ -151,7 +151,7 @@ interface MultiDeviceSetup { ...@@ -151,7 +151,7 @@ interface MultiDeviceSetup {
// Provides a list of all eligible host devices (i.e., those which can be // Provides a list of all eligible host devices (i.e., those which can be
// passed to SetHostDevice()). // passed to SetHostDevice()).
GetEligibleHostDevices() => GetEligibleHostDevices() =>
(array<chromeos.device_sync.mojom.RemoteDevice> eligible_host_devices); (array<chromeos.multidevice.mojom.RemoteDevice> eligible_host_devices);
// Sets the host associated with the provided device ID as the host device // Sets the host associated with the provided device ID as the host device
// for this account. The provided auth token must be valid in order to prove // for this account. The provided auth token must be valid in order to prove
...@@ -172,7 +172,7 @@ interface MultiDeviceSetup { ...@@ -172,7 +172,7 @@ interface MultiDeviceSetup {
// HostStatus::kNoEligibleHosts or // HostStatus::kNoEligibleHosts or
// HostStatus::kEligibleHostExistsButNoHostSet, |host_device| is null. // HostStatus::kEligibleHostExistsButNoHostSet, |host_device| is null.
GetHostStatus() => (HostStatus host_status, GetHostStatus() => (HostStatus host_status,
chromeos.device_sync.mojom.RemoteDevice? host_device); chromeos.multidevice.mojom.RemoteDevice? host_device);
// Attempts to enable or disable |feature|. This function succeeds only if // Attempts to enable or disable |feature|. This function succeeds only if
// |feature|'s current state is FeatureState::kEnabledByUser or // |feature|'s current state is FeatureState::kEnabledByUser or
......
...@@ -11,7 +11,7 @@ mojom("mojom") { ...@@ -11,7 +11,7 @@ mojom("mojom") {
] ]
public_deps = [ public_deps = [
"//chromeos/services/device_sync/public/mojom", "//chromeos/components/multidevice/mojom",
"//mojo/public/mojom/base", "//mojo/public/mojom/base",
] ]
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
module chromeos.secure_channel.mojom; module chromeos.secure_channel.mojom;
import "chromeos/services/device_sync/public/mojom/device_sync.mojom"; import "chromeos/components/multidevice/mojom/multidevice_types.mojom";
enum ConnectionAttemptFailureReason { enum ConnectionAttemptFailureReason {
// The local device could not authenticate with the remote device. This likely // The local device could not authenticate with the remote device. This likely
...@@ -169,8 +169,8 @@ interface SecureChannel { ...@@ -169,8 +169,8 @@ interface SecureChannel {
// cancel a connection attempt (i.e., to stop listening for incoming // cancel a connection attempt (i.e., to stop listening for incoming
// connections), disconnect |delegate|. // connections), disconnect |delegate|.
ListenForConnectionFromDevice( ListenForConnectionFromDevice(
chromeos.device_sync.mojom.RemoteDevice device_to_connect, chromeos.multidevice.mojom.RemoteDevice device_to_connect,
chromeos.device_sync.mojom.RemoteDevice local_device, chromeos.multidevice.mojom.RemoteDevice local_device,
string feature, string feature,
ConnectionPriority connection_priority, ConnectionPriority connection_priority,
ConnectionDelegate delegate); ConnectionDelegate delegate);
...@@ -183,8 +183,8 @@ interface SecureChannel { ...@@ -183,8 +183,8 @@ interface SecureChannel {
// if a connection was attempted and failed several retry attempts. To cancel // if a connection was attempted and failed several retry attempts. To cancel
// the connection attempt, disconnect |delegate|. // the connection attempt, disconnect |delegate|.
InitiateConnectionToDevice( InitiateConnectionToDevice(
chromeos.device_sync.mojom.RemoteDevice device_to_connect, chromeos.multidevice.mojom.RemoteDevice device_to_connect,
chromeos.device_sync.mojom.RemoteDevice local_device, chromeos.multidevice.mojom.RemoteDevice local_device,
string feature, string feature,
ConnectionPriority connection_priority, ConnectionPriority connection_priority,
ConnectionDelegate delegate); ConnectionDelegate delegate);
......
...@@ -88,6 +88,8 @@ const std::map<int, std::string> CreateChromeosMojoResourceIdToAliasMap() { ...@@ -88,6 +88,8 @@ const std::map<int, std::string> CreateChromeosMojoResourceIdToAliasMap() {
"js/chromeos/multidevice_setup.mojom.js"}, "js/chromeos/multidevice_setup.mojom.js"},
{IDR_MULTIDEVICE_MULTIDEVICE_SETUP_CONSTANTS_MOJOM_JS, {IDR_MULTIDEVICE_MULTIDEVICE_SETUP_CONSTANTS_MOJOM_JS,
"js/chromeos/multidevice_setup_constants.mojom.js"}, "js/chromeos/multidevice_setup_constants.mojom.js"},
{IDR_MULTIDEVICE_MULTIDEVICE_TYPES_MOJOM_JS,
"js/chromeos/multidevice_types.mojom.js"},
}; };
} }
#endif // !defined(OS_CHROMEOS) #endif // !defined(OS_CHROMEOS)
......
...@@ -10,7 +10,7 @@ _typemap_imports = [ ...@@ -10,7 +10,7 @@ _typemap_imports = [
"//chrome/typemaps.gni", "//chrome/typemaps.gni",
"//chromecast/common/mojom/typemaps.gni", "//chromecast/common/mojom/typemaps.gni",
"//chromeos/typemaps.gni", "//chromeos/typemaps.gni",
"//chromeos/services/device_sync/public/mojom/typemaps.gni", "//chromeos/components/multidevice/mojom/typemaps.gni",
"//chromeos/services/secure_channel/public/mojom/typemaps.gni", "//chromeos/services/secure_channel/public/mojom/typemaps.gni",
"//components/arc/common/typemaps.gni", "//components/arc/common/typemaps.gni",
"//components/sync/mojo/typemaps.gni", "//components/sync/mojo/typemaps.gni",
......
...@@ -31,12 +31,14 @@ js_library("fake_mojo_service") { ...@@ -31,12 +31,14 @@ js_library("fake_mojo_service") {
] ]
extra_deps = [ extra_deps = [
"//chromeos/components/multidevice/mojom:mojom_js",
"//chromeos/services/device_sync/public/mojom:mojom_js", "//chromeos/services/device_sync/public/mojom:mojom_js",
"//chromeos/services/multidevice_setup/public/mojom:mojom_js", "//chromeos/services/multidevice_setup/public/mojom:mojom_js",
"//mojo/public/mojom/base:base_js", "//mojo/public/mojom/base:base_js",
] ]
externs_list = [ externs_list = [
"$root_gen_dir/chromeos/components/multidevice/mojom/multidevice_types.mojom.externs.js",
"$root_gen_dir/chromeos/services/device_sync/public/mojom/device_sync.mojom.externs.js", "$root_gen_dir/chromeos/services/device_sync/public/mojom/device_sync.mojom.externs.js",
"$root_gen_dir/chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.externs.js", "$root_gen_dir/chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.externs.js",
"$root_gen_dir/mojo/public/mojom/base/time.mojom.externs.js", "$root_gen_dir/mojo/public/mojom/base/time.mojom.externs.js",
...@@ -65,12 +67,14 @@ js_library("multidevice_setup") { ...@@ -65,12 +67,14 @@ js_library("multidevice_setup") {
] ]
extra_deps = [ extra_deps = [
"//chromeos/components/multidevice/mojom:mojom_js",
"//chromeos/services/device_sync/public/mojom:mojom_js", "//chromeos/services/device_sync/public/mojom:mojom_js",
"//chromeos/services/multidevice_setup/public/mojom:mojom_js", "//chromeos/services/multidevice_setup/public/mojom:mojom_js",
"//mojo/public/mojom/base:base_js", "//mojo/public/mojom/base:base_js",
] ]
externs_list = [ externs_list = [
"$root_gen_dir/chromeos/components/multidevice/mojom/multidevice_types.mojom.externs.js",
"$root_gen_dir/chromeos/services/device_sync/public/mojom/device_sync.mojom.externs.js", "$root_gen_dir/chromeos/services/device_sync/public/mojom/device_sync.mojom.externs.js",
"$root_gen_dir/chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.externs.js", "$root_gen_dir/chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.externs.js",
"$root_gen_dir/mojo/public/mojom/base/time.mojom.externs.js", "$root_gen_dir/mojo/public/mojom/base/time.mojom.externs.js",
......
<link rel="import" href="chrome://resources/html/cr.html"> <link rel="import" href="chrome://resources/html/cr.html">
<script src="chrome://resources/js/mojo_bindings.js"></script> <script src="chrome://resources/js/mojo_bindings.js"></script>
<script src="chrome://resources/js/time.mojom.js"></script> <script src="chrome://resources/js/time.mojom.js"></script>
<script src="chrome://resources/js/chromeos/multidevice_types.mojom.js">
</script>
<script src="chrome://resources/js/chromeos/device_sync.mojom.js"></script> <script src="chrome://resources/js/chromeos/device_sync.mojom.js"></script>
<script src="chrome://resources/js/chromeos/multidevice_setup.mojom.js"> <script src="chrome://resources/js/chromeos/multidevice_setup.mojom.js">
</script> </script>
......
...@@ -95,7 +95,7 @@ cr.define('multidevice_setup', function() { ...@@ -95,7 +95,7 @@ cr.define('multidevice_setup', function() {
/** /**
* Array of objects representing all potential MultiDevice hosts. * Array of objects representing all potential MultiDevice hosts.
* *
* @private {!Array<!chromeos.deviceSync.mojom.RemoteDevice>} * @private {!Array<!chromeos.multidevice.mojom.RemoteDevice>}
*/ */
devices_: Array, devices_: Array,
......
...@@ -33,7 +33,7 @@ Polymer({ ...@@ -33,7 +33,7 @@ Polymer({
/** /**
* Array of objects representing all potential MultiDevice hosts. * Array of objects representing all potential MultiDevice hosts.
* *
* @type {!Array<!chromeos.deviceSync.mojom.RemoteDevice>} * @type {!Array<!chromeos.multidevice.mojom.RemoteDevice>}
*/ */
devices: { devices: {
type: Array, type: Array,
...@@ -99,7 +99,7 @@ Polymer({ ...@@ -99,7 +99,7 @@ Polymer({
}, },
/** /**
* @param {!Array<!chromeos.deviceSync.mojom.RemoteDevice>} devices * @param {!Array<!chromeos.multidevice.mojom.RemoteDevice>} devices
* @return {string} Label for devices selection content. * @return {string} Label for devices selection content.
* @private * @private
*/ */
...@@ -115,7 +115,7 @@ Polymer({ ...@@ -115,7 +115,7 @@ Polymer({
}, },
/** /**
* @param {!Array<!chromeos.deviceSync.mojom.RemoteDevice>} devices * @param {!Array<!chromeos.multidevice.mojom.RemoteDevice>} devices
* @return {boolean} True if there are more than one potential host devices. * @return {boolean} True if there are more than one potential host devices.
* @private * @private
*/ */
...@@ -124,7 +124,7 @@ Polymer({ ...@@ -124,7 +124,7 @@ Polymer({
}, },
/** /**
* @param {!Array<!chromeos.deviceSync.mojom.RemoteDevice>} devices * @param {!Array<!chromeos.multidevice.mojom.RemoteDevice>} devices
* @return {boolean} True if there is exactly one potential host device. * @return {boolean} True if there is exactly one potential host device.
* @private * @private
*/ */
...@@ -133,7 +133,7 @@ Polymer({ ...@@ -133,7 +133,7 @@ Polymer({
}, },
/** /**
* @param {!Array<!chromeos.deviceSync.mojom.RemoteDevice>} devices * @param {!Array<!chromeos.multidevice.mojom.RemoteDevice>} devices
* @return {string} Name of the first device in device list if there are any. * @return {string} Name of the first device in device list if there are any.
* Returns an empty string otherwise. * Returns an empty string otherwise.
* @private * @private
......
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