Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: ash/common/system/chromeos/bluetooth/bluetooth_notification_controller.h

Issue 2734653002: chromeos: Move files in //ash/common to //ash (Closed)
Patch Set: fix a11y tests, fix docs Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 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
5 #ifndef ASH_COMMON_SYSTEM_CHROMEOS_BLUETOOTH_BLUETOOTH_NOTIFICATION_CONTROLLER_H _
6 #define ASH_COMMON_SYSTEM_CHROMEOS_BLUETOOTH_BLUETOOTH_NOTIFICATION_CONTROLLER_H _
7
8 #include <stdint.h>
9
10 #include <set>
11 #include <string>
12
13 #include "ash/ash_export.h"
14 #include "base/macros.h"
15 #include "base/memory/ref_counted.h"
16 #include "base/memory/weak_ptr.h"
17 #include "base/strings/string16.h"
18 #include "device/bluetooth/bluetooth_adapter.h"
19 #include "device/bluetooth/bluetooth_device.h"
20
21 namespace ash {
22
23 // The BluetoothNotificationController receives incoming pairing requests from
24 // the BluetoothAdapter, and notifications of changes to the adapter state and
25 // set of paired devices. It presents incoming pairing requests in the form of
26 // rich notifications that the user can interact with to approve the request.
27 class ASH_EXPORT BluetoothNotificationController
28 : public device::BluetoothAdapter::Observer,
29 public device::BluetoothDevice::PairingDelegate {
30 public:
31 BluetoothNotificationController();
32 ~BluetoothNotificationController() override;
33
34 // device::BluetoothAdapter::Observer override.
35 void AdapterDiscoverableChanged(device::BluetoothAdapter* adapter,
36 bool discoverable) override;
37 void DeviceAdded(device::BluetoothAdapter* adapter,
38 device::BluetoothDevice* device) override;
39 void DeviceChanged(device::BluetoothAdapter* adapter,
40 device::BluetoothDevice* device) override;
41 void DeviceRemoved(device::BluetoothAdapter* adapter,
42 device::BluetoothDevice* device) override;
43
44 // device::BluetoothDevice::PairingDelegate override.
45 void RequestPinCode(device::BluetoothDevice* device) override;
46 void RequestPasskey(device::BluetoothDevice* device) override;
47 void DisplayPinCode(device::BluetoothDevice* device,
48 const std::string& pincode) override;
49 void DisplayPasskey(device::BluetoothDevice* device,
50 uint32_t passkey) override;
51 void KeysEntered(device::BluetoothDevice* device, uint32_t entered) override;
52 void ConfirmPasskey(device::BluetoothDevice* device,
53 uint32_t passkey) override;
54 void AuthorizePairing(device::BluetoothDevice* device) override;
55
56 private:
57 // Internal method called by BluetoothAdapterFactory to provide the adapter
58 // object.
59 void OnGetAdapter(scoped_refptr<device::BluetoothAdapter> adapter);
60
61 // Presents a notification to the user when the adapter becomes discoverable
62 // to other nearby devices.
63 void NotifyAdapterDiscoverable();
64
65 // Presents a notification to the user that a device |device| is making a
66 // pairing request. The exact message to display is given in |message| and
67 // should include all relevant instructions, if |with_buttons| is true then
68 // the notification will have Accept and Reject buttons, if false only the
69 // usual cancel/dismiss button will be present on the notification.
70 void NotifyPairing(device::BluetoothDevice* device,
71 const base::string16& message,
72 bool with_buttons);
73
74 // Clears any shown pairing notification now that the device has been paired.
75 void NotifyPairedDevice(device::BluetoothDevice* device);
76
77 // Reference to the underlying BluetoothAdapter object, holding this reference
78 // ensures we stay around as the pairing delegate for that adapter.
79 scoped_refptr<device::BluetoothAdapter> adapter_;
80
81 // Set of currently paired devices, stored by Bluetooth address, used to
82 // filter out property changes for devices that were previously paired.
83 std::set<std::string> paired_devices_;
84
85 // Note: This should remain the last member so it'll be destroyed and
86 // invalidate its weak pointers before any other members are destroyed.
87 base::WeakPtrFactory<BluetoothNotificationController> weak_ptr_factory_;
88
89 DISALLOW_COPY_AND_ASSIGN(BluetoothNotificationController);
90 };
91
92 } // namespace ash
93
94 #endif // ASH_COMMON_SYSTEM_CHROMEOS_BLUETOOTH_BLUETOOTH_NOTIFICATION_CONTROLLE R_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698