File: bluetooth_detailed_view_controller.h

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (97 lines) | stat: -rw-r--r-- 3,747 bytes parent folder | download | duplicates (6)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// 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_BLUETOOTH_BLUETOOTH_DETAILED_VIEW_CONTROLLER_H_
#define ASH_SYSTEM_BLUETOOTH_BLUETOOTH_DETAILED_VIEW_CONTROLLER_H_

#include <memory>
#include <string>
#include <vector>

#include "ash/ash_export.h"
#include "ash/public/mojom/hid_preserving_bluetooth_state_controller.mojom.h"
#include "ash/system/bluetooth/bluetooth_detailed_view.h"
#include "ash/system/bluetooth/bluetooth_device_list_controller.h"
#include "ash/system/tray/detailed_view_delegate.h"
#include "ash/system/unified/detailed_view_controller.h"
#include "base/memory/raw_ptr.h"
#include "chromeos/ash/services/bluetooth_config/public/mojom/cros_bluetooth_config.mojom.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"

namespace views {
class View;
}  // namespace views

namespace ash {

class UnifiedSystemTrayController;

// This class encapsulates the logic to update the detailed Bluetooth device
// page within the quick settings and translate user interaction with the
// detailed view into Bluetooth state changes.
class ASH_EXPORT BluetoothDetailedViewController
    : public DetailedViewController,
      public bluetooth_config::mojom::SystemPropertiesObserver,
      public BluetoothDetailedView::Delegate {
 public:
  explicit BluetoothDetailedViewController(
      UnifiedSystemTrayController* tray_controller);
  BluetoothDetailedViewController(const BluetoothDetailedViewController&) =
      delete;
  BluetoothDetailedViewController& operator=(
      const BluetoothDetailedViewController&) = delete;
  ~BluetoothDetailedViewController() override;

 protected:
  using PairedBluetoothDevicePropertiesPtrs =
      std::vector<bluetooth_config::mojom::PairedBluetoothDevicePropertiesPtr>;

 private:
  // DetailedViewController:
  std::unique_ptr<views::View> CreateView() override;
  std::u16string GetAccessibleName() const override;
  void ShutDown() override;

  // bluetooth_config::mojom::SystemPropertiesObserver:
  void OnPropertiesUpdated(bluetooth_config::mojom::BluetoothSystemPropertiesPtr
                               properties) override;

  // BluetoothDetailedView::Delegate:
  void OnToggleClicked(bool new_state) override;
  void OnPairNewDeviceRequested() override;
  void OnDeviceListItemSelected(
      const bluetooth_config::mojom::PairedBluetoothDevicePropertiesPtr& device)
      override;

  // Used to update |view_| and |device_list_controller_| when the cached
  // Bluetooth state has changed.
  void BluetoothEnabledStateChanged();

  // Adds fake devices for manual testing to `previously_connected_devices_`
  // and `connected_devices_`.
  void AddFakeBluetoothDevices();

  const std::unique_ptr<DetailedViewDelegate> detailed_view_delegate_;

  mojo::Remote<bluetooth_config::mojom::CrosBluetoothConfig>
      remote_cros_bluetooth_config_;
  mojo::Receiver<bluetooth_config::mojom::SystemPropertiesObserver>
      cros_system_properties_observer_receiver_{this};

  mojo::Remote<mojom::HidPreservingBluetoothStateController>
      remote_hid_preserving_bluetooth_;

  bluetooth_config::mojom::BluetoothSystemState system_state_ =
      bluetooth_config::mojom::BluetoothSystemState::kUnavailable;
  raw_ptr<BluetoothDetailedView, DanglingUntriaged> view_ = nullptr;
  std::unique_ptr<BluetoothDeviceListController> device_list_controller_;
  PairedBluetoothDevicePropertiesPtrs connected_devices_;
  PairedBluetoothDevicePropertiesPtrs previously_connected_devices_;
  raw_ptr<UnifiedSystemTrayController> tray_controller_;
};

}  // namespace ash

#endif  // ASH_SYSTEM_BLUETOOTH_BLUETOOTH_DETAILED_VIEW_CONTROLLER_H_