File: bluetooth_pairing_dialog.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 (105 lines) | stat: -rw-r--r-- 3,833 bytes parent folder | download | duplicates (7)
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
98
99
100
101
102
103
104
105
// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_UI_WEBUI_ASH_BLUETOOTH_BLUETOOTH_PAIRING_DIALOG_H_
#define CHROME_BROWSER_UI_WEBUI_ASH_BLUETOOTH_BLUETOOTH_PAIRING_DIALOG_H_

#include <optional>
#include <string>
#include <string_view>

#include "chrome/browser/ui/webui/ash/system_web_dialog/system_web_dialog_delegate.h"
#include "chrome/common/webui_url_constants.h"
#include "chromeos/ash/services/bluetooth_config/public/mojom/cros_bluetooth_config.mojom-forward.h"
#include "content/public/browser/webui_config.h"
#include "content/public/common/url_constants.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "ui/base/interaction/element_identifier.h"
#include "ui/web_dialogs/web_dialog_ui.h"

namespace color_change_listener::mojom {
class PageHandler;
}  // namespace color_change_listener::mojom

namespace ui {
class ColorChangeHandler;
}  //  namespace ui

namespace ash {

class BluetoothPairingDialog : public SystemWebDialogDelegate {
 public:
  DECLARE_CLASS_ELEMENT_IDENTIFIER_VALUE(kBluetoothPairingDialogElementId);

  BluetoothPairingDialog(const BluetoothPairingDialog&) = delete;
  BluetoothPairingDialog& operator=(const BluetoothPairingDialog&) = delete;

  // Show the Bluetooth pairing dialog. When provided, |device_address| is the
  // unique device address that the dialog should attempt to pair with and
  // should be in the form "XX:XX:XX:XX:XX:XX". When |device_address| is not
  // provided the dialog will show the device list instead. The returned object
  // manages its own lifetime, for more information see
  // chrome/browser/ui/webui/ash/system_web_dialog/system_web_dialog_delegate.h.
  static SystemWebDialogDelegate* ShowDialog(
      std::optional<std::string_view> device_address = std::nullopt);

  ~BluetoothPairingDialog() override;

 protected:
  BluetoothPairingDialog(
      const std::string& dialog_id,
      std::optional<std::string_view> canonical_device_address);

 private:
  // SystemWebDialogDelegate:
  std::string Id() override;
  void AdjustWidgetInitParams(views::Widget::InitParams* params) override;

  // The canonical Bluetooth address of a device when pairing a specific device,
  // otherwise |kChromeUIBluetoothPairingURL|.
  std::string dialog_id_;
};

class BluetoothPairingDialogUI;

// WebUIConfig for chrome://bluetooth-pairing
class BluetoothPairingDialogUIConfig
    : public content::DefaultWebUIConfig<BluetoothPairingDialogUI> {
 public:
  BluetoothPairingDialogUIConfig()
      : DefaultWebUIConfig(content::kChromeUIScheme,
                           chrome::kChromeUIBluetoothPairingHost) {}
};

// A WebUI to host the Bluetooth device pairing web UI.
class BluetoothPairingDialogUI : public ui::MojoWebDialogUI {
 public:
  explicit BluetoothPairingDialogUI(content::WebUI* web_ui);

  BluetoothPairingDialogUI(const BluetoothPairingDialogUI&) = delete;
  BluetoothPairingDialogUI& operator=(const BluetoothPairingDialogUI&) = delete;

  ~BluetoothPairingDialogUI() override;

  // Instantiates implementor of the mojom::CrosBluetoothConfig mojo interface
  // passing the pending receiver that will be internally bound.
  void BindInterface(
      mojo::PendingReceiver<ash::bluetooth_config::mojom::CrosBluetoothConfig>
          receiver);

  // Instantiates the implementor of the mojom::PageHandler mojo interface
  // passing the pending receiver that will be internally bound.
  void BindInterface(
      mojo::PendingReceiver<color_change_listener::mojom::PageHandler>
          receiver);

 private:
  std::unique_ptr<ui::ColorChangeHandler> color_change_handler_;

  WEB_UI_CONTROLLER_TYPE_DECL();
};

}  // namespace ash

#endif  // CHROME_BROWSER_UI_WEBUI_ASH_BLUETOOTH_BLUETOOTH_PAIRING_DIALOG_H_