bluetooth_detailed_view_controller.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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_BLUETOOTH_BLUETOOTH_DETAILED_VIEW_CONTROLLER_H_
  5. #define ASH_SYSTEM_BLUETOOTH_BLUETOOTH_DETAILED_VIEW_CONTROLLER_H_
  6. #include <memory>
  7. #include <string>
  8. #include <vector>
  9. #include "ash/ash_export.h"
  10. #include "ash/system/bluetooth/bluetooth_detailed_view.h"
  11. #include "ash/system/bluetooth/bluetooth_device_list_controller.h"
  12. #include "ash/system/tray/detailed_view_delegate.h"
  13. #include "ash/system/unified/detailed_view_controller.h"
  14. #include "chromeos/services/bluetooth_config/public/mojom/cros_bluetooth_config.mojom.h"
  15. #include "mojo/public/cpp/bindings/receiver.h"
  16. #include "mojo/public/cpp/bindings/remote.h"
  17. namespace views {
  18. class View;
  19. } // namespace views
  20. namespace ash {
  21. class UnifiedSystemTrayController;
  22. // This class encapsulates the logic to update the detailed Bluetooth device
  23. // page within the quick settings and translate user interaction with the
  24. // detailed view into Bluetooth state changes.
  25. class ASH_EXPORT BluetoothDetailedViewController
  26. : public DetailedViewController,
  27. public chromeos::bluetooth_config::mojom::SystemPropertiesObserver,
  28. public BluetoothDetailedView::Delegate {
  29. public:
  30. explicit BluetoothDetailedViewController(
  31. UnifiedSystemTrayController* tray_controller);
  32. BluetoothDetailedViewController(const BluetoothDetailedViewController&) =
  33. delete;
  34. BluetoothDetailedViewController& operator=(
  35. const BluetoothDetailedViewController&) = delete;
  36. ~BluetoothDetailedViewController() override;
  37. protected:
  38. using PairedBluetoothDevicePropertiesPtrs = std::vector<
  39. chromeos::bluetooth_config::mojom::PairedBluetoothDevicePropertiesPtr>;
  40. private:
  41. // DetailedViewControllerBase:
  42. views::View* CreateView() override;
  43. std::u16string GetAccessibleName() const override;
  44. // chromeos::bluetooth_config::mojom::SystemPropertiesObserver:
  45. void OnPropertiesUpdated(
  46. chromeos::bluetooth_config::mojom::BluetoothSystemPropertiesPtr
  47. properties) override;
  48. // BluetoothDetailedView::Delegate:
  49. void OnToggleClicked(bool new_state) override;
  50. void OnPairNewDeviceRequested() override;
  51. void OnDeviceListItemSelected(
  52. const chromeos::bluetooth_config::mojom::
  53. PairedBluetoothDevicePropertiesPtr& device) override;
  54. // Used to update |view_| and |device_list_controller_| when the cached
  55. // Bluetooth state has changed.
  56. void BluetoothEnabledStateChanged();
  57. const std::unique_ptr<DetailedViewDelegate> detailed_view_delegate_;
  58. mojo::Remote<chromeos::bluetooth_config::mojom::CrosBluetoothConfig>
  59. remote_cros_bluetooth_config_;
  60. mojo::Receiver<chromeos::bluetooth_config::mojom::SystemPropertiesObserver>
  61. cros_system_properties_observer_receiver_{this};
  62. chromeos::bluetooth_config::mojom::BluetoothSystemState system_state_ =
  63. chromeos::bluetooth_config::mojom::BluetoothSystemState::kUnavailable;
  64. BluetoothDetailedView* view_ = nullptr;
  65. std::unique_ptr<BluetoothDeviceListController> device_list_controller_;
  66. PairedBluetoothDevicePropertiesPtrs connected_devices_;
  67. PairedBluetoothDevicePropertiesPtrs previously_connected_devices_;
  68. UnifiedSystemTrayController* tray_controller_;
  69. };
  70. } // namespace ash
  71. #endif // ASH_SYSTEM_BLUETOOTH_BLUETOOTH_DETAILED_VIEW_CONTROLLER_H_