1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
ash / system / pcie_peripheral / pcie_peripheral_notification_controller.h [blame]
// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_SYSTEM_PCIE_PERIPHERAL_PCIE_PERIPHERAL_NOTIFICATION_CONTROLLER_H_
#define ASH_SYSTEM_PCIE_PERIPHERAL_PCIE_PERIPHERAL_NOTIFICATION_CONTROLLER_H_
#include "ash/ash_export.h"
#include "base/memory/raw_ptr.h"
#include "chromeos/ash/components/peripheral_notification/peripheral_notification_manager.h"
class PrefRegistrySimple;
namespace message_center {
class MessageCenter;
} // namespace message_center
namespace ash {
// Manages showing notifications for Pciguard and TypeC daemon events.
// We display a CRITICAL notification if a guest user is attempting to use a
// Thunderbolt-only peripheral, which we prevent due to security risks with
// direct memory accessing. Other WARNING notifications are used to inform users
// that their peripherals may not be working due to data access protection
// enabled in OS Settings.
class ASH_EXPORT PciePeripheralNotificationController
: public PeripheralNotificationManager::Observer {
public:
explicit PciePeripheralNotificationController(
message_center::MessageCenter* message_center);
PciePeripheralNotificationController(
const PciePeripheralNotificationController&) = delete;
PciePeripheralNotificationController& operator=(
const PciePeripheralNotificationController&) = delete;
~PciePeripheralNotificationController() override;
static void RegisterProfilePrefs(PrefRegistrySimple* registry);
// Call when PeripheralNotificationManager is initialized so that this
// class can start observering requests for notifications.
void OnPeripheralNotificationManagerInitialized();
// chromeos::PciePeripheral::Observer
void OnLimitedPerformancePeripheralReceived() override;
void OnGuestModeNotificationReceived(bool is_thunderbolt_only) override;
void OnPeripheralBlockedReceived() override;
void OnBillboardDeviceConnected() override;
// Call to show a notification to indicate that the recently plugged in
// Thunderbolt/USB4 peripheral performance is limited.
void NotifyLimitedPerformance();
// Call to show a notification to indicate to the Guest user of the current
// state of their Thunderbolt/USB4 peripheral.
void NotifyGuestModeNotification(bool is_thunderbolt_only);
// Call to show a notification to indicate to the user that their
// Thunderbolt/USB4 peripheral is not allowed due to security reasons.
void NotifyPeripheralBlockedNotification();
// Call to show a notification that a billboard device that was connected
// is not supported by the board.
void NotifyBillboardDevice();
// Stubs from usb peripheral notification controller
void OnInvalidDpCableWarning() override {}
void OnInvalidUSB4ValidTBTCableWarning() override {}
void OnInvalidUSB4CableWarning() override {}
void OnInvalidTBTCableWarning() override {}
void OnSpeedLimitingCableWarning() override {}
private:
friend class PciePeripheralNotificationControllerTest;
// MessageCenter for adding notifications.
const raw_ptr<message_center::MessageCenter> message_center_;
};
} // namespace ash
#endif // ASH_SYSTEM_PCIE_PERIPHERAL_PCIE_PERIPHERAL_NOTIFICATION_CONTROLLER_H_