OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "extensions/browser/api/bluetooth/bluetooth_api_pairing_delegate.h" | 5 #include "extensions/browser/api/bluetooth/bluetooth_api_pairing_delegate.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 const std::string& pincode) { | 57 const std::string& pincode) { |
58 bt_private::PairingEvent event; | 58 bt_private::PairingEvent event; |
59 PopulatePairingEvent( | 59 PopulatePairingEvent( |
60 device, bt_private::PAIRING_EVENT_TYPE_DISPLAYPINCODE, &event); | 60 device, bt_private::PAIRING_EVENT_TYPE_DISPLAYPINCODE, &event); |
61 event.pincode.reset(new std::string(pincode)); | 61 event.pincode.reset(new std::string(pincode)); |
62 DispatchPairingEvent(event); | 62 DispatchPairingEvent(event); |
63 } | 63 } |
64 | 64 |
65 void BluetoothApiPairingDelegate::DisplayPasskey( | 65 void BluetoothApiPairingDelegate::DisplayPasskey( |
66 device::BluetoothDevice* device, | 66 device::BluetoothDevice* device, |
67 uint32 passkey) { | 67 uint32_t passkey) { |
68 bt_private::PairingEvent event; | 68 bt_private::PairingEvent event; |
69 PopulatePairingEvent( | 69 PopulatePairingEvent( |
70 device, bt_private::PAIRING_EVENT_TYPE_DISPLAYPASSKEY, &event); | 70 device, bt_private::PAIRING_EVENT_TYPE_DISPLAYPASSKEY, &event); |
71 event.passkey.reset(new int(passkey)); | 71 event.passkey.reset(new int(passkey)); |
72 DispatchPairingEvent(event); | 72 DispatchPairingEvent(event); |
73 } | 73 } |
74 | 74 |
75 void BluetoothApiPairingDelegate::KeysEntered(device::BluetoothDevice* device, | 75 void BluetoothApiPairingDelegate::KeysEntered(device::BluetoothDevice* device, |
76 uint32 entered) { | 76 uint32_t entered) { |
77 bt_private::PairingEvent event; | 77 bt_private::PairingEvent event; |
78 PopulatePairingEvent( | 78 PopulatePairingEvent( |
79 device, bt_private::PAIRING_EVENT_TYPE_KEYSENTERED, &event); | 79 device, bt_private::PAIRING_EVENT_TYPE_KEYSENTERED, &event); |
80 event.entered_key.reset(new int(entered)); | 80 event.entered_key.reset(new int(entered)); |
81 DispatchPairingEvent(event); | 81 DispatchPairingEvent(event); |
82 } | 82 } |
83 | 83 |
84 void BluetoothApiPairingDelegate::ConfirmPasskey( | 84 void BluetoothApiPairingDelegate::ConfirmPasskey( |
85 device::BluetoothDevice* device, | 85 device::BluetoothDevice* device, |
86 uint32 passkey) { | 86 uint32_t passkey) { |
87 bt_private::PairingEvent event; | 87 bt_private::PairingEvent event; |
88 PopulatePairingEvent( | 88 PopulatePairingEvent( |
89 device, bt_private::PAIRING_EVENT_TYPE_CONFIRMPASSKEY, &event); | 89 device, bt_private::PAIRING_EVENT_TYPE_CONFIRMPASSKEY, &event); |
90 event.passkey.reset(new int(passkey)); | 90 event.passkey.reset(new int(passkey)); |
91 DispatchPairingEvent(event); | 91 DispatchPairingEvent(event); |
92 } | 92 } |
93 | 93 |
94 void BluetoothApiPairingDelegate::AuthorizePairing( | 94 void BluetoothApiPairingDelegate::AuthorizePairing( |
95 device::BluetoothDevice* device) { | 95 device::BluetoothDevice* device) { |
96 bt_private::PairingEvent event; | 96 bt_private::PairingEvent event; |
97 PopulatePairingEvent( | 97 PopulatePairingEvent( |
98 device, bt_private::PAIRING_EVENT_TYPE_REQUESTAUTHORIZATION, &event); | 98 device, bt_private::PAIRING_EVENT_TYPE_REQUESTAUTHORIZATION, &event); |
99 DispatchPairingEvent(event); | 99 DispatchPairingEvent(event); |
100 } | 100 } |
101 | 101 |
102 void BluetoothApiPairingDelegate::DispatchPairingEvent( | 102 void BluetoothApiPairingDelegate::DispatchPairingEvent( |
103 const bt_private::PairingEvent& pairing_event) { | 103 const bt_private::PairingEvent& pairing_event) { |
104 scoped_ptr<base::ListValue> args = | 104 scoped_ptr<base::ListValue> args = |
105 bt_private::OnPairing::Create(pairing_event); | 105 bt_private::OnPairing::Create(pairing_event); |
106 scoped_ptr<Event> event(new Event(events::BLUETOOTH_PRIVATE_ON_PAIRING, | 106 scoped_ptr<Event> event(new Event(events::BLUETOOTH_PRIVATE_ON_PAIRING, |
107 bt_private::OnPairing::kEventName, | 107 bt_private::OnPairing::kEventName, |
108 std::move(args))); | 108 std::move(args))); |
109 EventRouter::Get(browser_context_)->BroadcastEvent(std::move(event)); | 109 EventRouter::Get(browser_context_)->BroadcastEvent(std::move(event)); |
110 } | 110 } |
111 | 111 |
112 } // namespace extensions | 112 } // namespace extensions |
OLD | NEW |