pcie_peripheral_notification_controller.h 3.2 KB

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