Skip to content

Commit

Permalink
[NewEV] Create New device_signals Component
Browse files Browse the repository at this point in the history
Moved all device signals related code out from
components/enterprise into a new components/device_signals directory.

Code under components/enterprise should be limited to enterprise
management use cases. While device signals collection and aggregation
may happen in enterprise use cases, it is also intended for this
component to hold classes and utility functions that will be reused in
non-enterprise use cases where some signals need to be collected (e.g.
AntiVirus information collected for metrics reporting purposes).

The intended directory layout is:
device_signals/
  core/
    browser/
      win/
      ... other platforms
    common/
      mojom/
      win/
      ... other platforms
  content/
  ios/

Bug: b:229737384
Change-Id: I019eb2104e2151f55c98788d1e6c86005c63107d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3632205
Reviewed-by: Roger Tawa <rogerta@chromium.org>
Reviewed-by: Colin Blundell <blundell@chromium.org>
Commit-Queue: Sebastien Lalancette <seblalancette@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1001022}
  • Loading branch information
Sebastien Lalancette authored and Chromium LUCI CQ committed May 9, 2022
1 parent 9c222f8 commit e4158ec
Show file tree
Hide file tree
Showing 17 changed files with 70 additions and 48 deletions.
1 change: 1 addition & 0 deletions components/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ test("components_unittests") {
"//components/crash/core/common:unit_tests",
"//components/crx_file:unit_tests",
"//components/device_event_log:unit_tests",
"//components/device_signals/core:unit_tests",
"//components/dom_distiller/core:unit_tests",
"//components/download:unit_tests",
"//components/encrypted_messages:unit_tests",
Expand Down
2 changes: 2 additions & 0 deletions components/device_signals/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
seblalancette@chromium.org
rogerta@chromium.org
12 changes: 12 additions & 0 deletions components/device_signals/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Device Signals

This component contains the implementation of device signals (aka context-aware
signals) collection. It contains definition for services used to aggregate such
signals, along with utility functions that can be reused in various contexts.

A set of device signals can be used by Zero Trust access providers to assess a
device's security posture. That posture can then be used to calculate the risk
factor around granting access to restricted resources to the device (and its
user). This component facilitates the collection of those signals in Enterprise
use cases while also providing symbols for other use cases requiring some of
these signals (e.g. metrics).
8 changes: 8 additions & 0 deletions components/device_signals/core/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright 2022 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.

source_set("unit_tests") {
testonly = true
deps = [ "//components/device_signals/core/browser:unit_tests" ]
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

static_library("signals") {
static_library("browser") {
public = [
"signals_aggregator.h",
"signals_aggregator_impl.h",
Expand All @@ -13,7 +13,7 @@ static_library("signals") {

deps = [
"//base",
"//components/enterprise/common/signals:constants",
"//components/device_signals/core/common",
"//components/keyed_service/core",
]
}
Expand All @@ -26,7 +26,7 @@ static_library("test_support") {
]

deps = [
":signals",
":browser",
"//base",
"//testing/gmock",
]
Expand All @@ -37,10 +37,10 @@ source_set("unit_tests") {
sources = [ "signals_aggregator_impl_unittest.cc" ]

deps = [
":signals",
":browser",
":test_support",
"//base/test:test_support",
"//components/enterprise/common/signals:constants",
"//components/device_signals/core/common",
"//testing/gtest",
]
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/enterprise/browser/signals/mock_signals_collector.h"
#include "components/device_signals/core/browser/mock_signals_collector.h"

namespace enterprise_signals {
namespace device_signals {

MockSignalsCollector::MockSignalsCollector() = default;
MockSignalsCollector::~MockSignalsCollector() = default;

} // namespace enterprise_signals
} // namespace device_signals
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_ENTERPRISE_BROWSER_SIGNALS_MOCK_SIGNALS_COLLECTOR_H_
#define COMPONENTS_ENTERPRISE_BROWSER_SIGNALS_MOCK_SIGNALS_COLLECTOR_H_
#ifndef COMPONENTS_DEVICE_SIGNALS_CORE_BROWSER_MOCK_SIGNALS_COLLECTOR_H_
#define COMPONENTS_DEVICE_SIGNALS_CORE_BROWSER_MOCK_SIGNALS_COLLECTOR_H_

#include "base/callback.h"
#include "base/values.h"
#include "components/enterprise/browser/signals/signals_collector.h"
#include "components/device_signals/core/browser/signals_collector.h"
#include "testing/gmock/include/gmock/gmock.h"

namespace enterprise_signals {
namespace device_signals {

class MockSignalsCollector : public SignalsCollector {
public:
Expand All @@ -29,6 +29,6 @@ class MockSignalsCollector : public SignalsCollector {
(override));
};

} // namespace enterprise_signals
} // namespace device_signals

#endif // COMPONENTS_ENTERPRISE_BROWSER_SIGNALS_MOCK_SIGNALS_COLLECTOR_H_
#endif // COMPONENTS_DEVICE_SIGNALS_CORE_BROWSER_MOCK_SIGNALS_COLLECTOR_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_ENTERPRISE_BROWSER_SIGNALS_SIGNALS_AGGREGATOR_H_
#define COMPONENTS_ENTERPRISE_BROWSER_SIGNALS_SIGNALS_AGGREGATOR_H_
#ifndef COMPONENTS_DEVICE_SIGNALS_CORE_BROWSER_SIGNALS_AGGREGATOR_H_
#define COMPONENTS_DEVICE_SIGNALS_CORE_BROWSER_SIGNALS_AGGREGATOR_H_

#include "base/callback_forward.h"
#include "base/values.h"
#include "components/keyed_service/core/keyed_service.h"

namespace enterprise_signals {
namespace device_signals {

class SignalsAggregator : public KeyedService {
public:
Expand All @@ -28,6 +28,6 @@ class SignalsAggregator : public KeyedService {
GetSignalsCallback callback) = 0;
};

} // namespace enterprise_signals
} // namespace device_signals

#endif // COMPONENTS_ENTERPRISE_BROWSER_SIGNALS_SIGNALS_AGGREGATOR_H_
#endif // COMPONENTS_DEVICE_SIGNALS_CORE_BROWSER_SIGNALS_AGGREGATOR_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/enterprise/browser/signals/signals_aggregator_impl.h"
#include "components/device_signals/core/browser/signals_aggregator_impl.h"

#include "base/bind.h"
#include "base/callback.h"
#include "base/logging.h"
#include "base/strings/string_util.h"
#include "base/values.h"
#include "components/enterprise/browser/signals/signals_collector.h"
#include "components/device_signals/core/browser/signals_collector.h"

namespace enterprise_signals {
namespace device_signals {

SignalsAggregatorImpl::SignalsAggregatorImpl(
std::vector<std::unique_ptr<SignalsCollector>> collectors)
Expand Down Expand Up @@ -61,4 +61,4 @@ void SignalsAggregatorImpl::OnSignalCollected(const std::string signal_name,
std::move(callback).Run(std::move(return_value));
}

} // namespace enterprise_signals
} // namespace device_signals
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_ENTERPRISE_BROWSER_SIGNALS_SIGNALS_AGGREGATOR_IMPL_H_
#define COMPONENTS_ENTERPRISE_BROWSER_SIGNALS_SIGNALS_AGGREGATOR_IMPL_H_
#ifndef COMPONENTS_DEVICE_SIGNALS_CORE_BROWSER_SIGNALS_AGGREGATOR_IMPL_H_
#define COMPONENTS_DEVICE_SIGNALS_CORE_BROWSER_SIGNALS_AGGREGATOR_IMPL_H_

#include <memory>
#include <vector>

#include "base/memory/weak_ptr.h"
#include "components/enterprise/browser/signals/signals_aggregator.h"
#include "components/device_signals/core/browser/signals_aggregator.h"

namespace enterprise_signals {
namespace device_signals {

class SignalsCollector;

Expand Down Expand Up @@ -39,6 +39,6 @@ class SignalsAggregatorImpl : public SignalsAggregator {
base::WeakPtrFactory<SignalsAggregatorImpl> weak_factory_{this};
};

} // namespace enterprise_signals
} // namespace device_signals

#endif // COMPONENTS_ENTERPRISE_BROWSER_SIGNALS_SIGNALS_AGGREGATOR_IMPL_H_
#endif // COMPONENTS_DEVICE_SIGNALS_CORE_BROWSER_SIGNALS_AGGREGATOR_IMPL_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/enterprise/browser/signals/signals_aggregator_impl.h"
#include "components/device_signals/core/browser/signals_aggregator_impl.h"

#include <memory>
#include <vector>

#include "base/test/task_environment.h"
#include "base/test/test_future.h"
#include "components/enterprise/browser/signals/mock_signals_collector.h"
#include "components/device_signals/core/browser/mock_signals_collector.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

Expand All @@ -19,7 +19,7 @@ using testing::Pointee;
using testing::Ref;
using testing::Return;

namespace enterprise_signals {
namespace device_signals {

namespace {

Expand Down Expand Up @@ -166,4 +166,4 @@ TEST_F(SignalsAggregatorImplTest, GetSignals_SingleSignal_Unsupported) {
EXPECT_EQ(future.Get(), base::Value::Dict());
}

} // namespace enterprise_signals
} // namespace device_signals
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_ENTERPRISE_BROWSER_SIGNALS_SIGNALS_COLLECTOR_H_
#define COMPONENTS_ENTERPRISE_BROWSER_SIGNALS_SIGNALS_COLLECTOR_H_
#ifndef COMPONENTS_DEVICE_SIGNALS_CORE_BROWSER_SIGNALS_COLLECTOR_H_
#define COMPONENTS_DEVICE_SIGNALS_CORE_BROWSER_SIGNALS_COLLECTOR_H_

#include <string>
#include <vector>
Expand All @@ -14,7 +14,7 @@ namespace base {
class Value;
} // namespace base

namespace enterprise_signals {
namespace device_signals {

class SignalsCollector {
public:
Expand All @@ -32,6 +32,6 @@ class SignalsCollector {
GetSignalCallback callback) = 0;
};

} // namespace enterprise_signals
} // namespace device_signals

#endif // COMPONENTS_ENTERPRISE_BROWSER_SIGNALS_SIGNALS_COLLECTOR_H_
#endif // COMPONENTS_DEVICE_SIGNALS_CORE_BROWSER_SIGNALS_COLLECTOR_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

static_library("constants") {
static_library("common") {
public = [ "signals_constants.h" ]

sources = [ "signals_constants.cc" ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/enterprise/common/signals/signals_constants.h"
#include "components/device_signals/core/common/signals_constants.h"

namespace enterprise_signals {
namespace device_signals {
namespace names {

// Name of the signal for getting information of the AllowScreenLock
Expand Down Expand Up @@ -136,4 +136,4 @@ const char kTpmHash[] = "tpmHash";
const char kWindowsDomain[] = "windowsDomain";

} // namespace names
} // namespace enterprise_signals
} // namespace device_signals
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_ENTERPRISE_COMMON_SIGNALS_SIGNALS_CONSTANTS_H_
#define COMPONENTS_ENTERPRISE_COMMON_SIGNALS_SIGNALS_CONSTANTS_H_
#ifndef COMPONENTS_DEVICE_SIGNALS_CORE_COMMON_SIGNALS_CONSTANTS_H_
#define COMPONENTS_DEVICE_SIGNALS_CORE_COMMON_SIGNALS_CONSTANTS_H_

namespace enterprise_signals {
namespace device_signals {

// Signal names can be used as keys to store/retrieve signal values from
// dictionaries.
Expand Down Expand Up @@ -46,6 +46,6 @@ extern const char kWindowsDomain[];

} // namespace names

} // namespace enterprise_signals
} // namespace device_signals

#endif // COMPONENTS_ENTERPRISE_COMMON_SIGNALS_SIGNALS_CONSTANTS_H_
#endif // COMPONENTS_DEVICE_SIGNALS_CORE_COMMON_SIGNALS_CONSTANTS_H_
1 change: 0 additions & 1 deletion components/enterprise/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ source_set("unit_tests") {
":reporting_test_support",
"//base/test:test_support",
"//build:chromeos_buildflags",
"//components/enterprise/browser/signals:unit_tests",
"//components/policy/core/common:test_support",
"//components/version_info",
"//testing/gmock",
Expand Down

0 comments on commit e4158ec

Please sign in to comment.