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

Side by Side Diff: chrome/browser/extensions/api/bluetooth/bluetooth_private_api.cc

Issue 180163009: chrome.bluetooth API improvements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unused code. Created 6 years, 8 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
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 "chrome/browser/extensions/api/bluetooth/bluetooth_private_api.h" 5 #include "chrome/browser/extensions/api/bluetooth/bluetooth_private_api.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api.h" 10 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api.h"
(...skipping 24 matching lines...) Expand all
35 35
36 BluetoothPrivateAPI::~BluetoothPrivateAPI() {} 36 BluetoothPrivateAPI::~BluetoothPrivateAPI() {}
37 37
38 void BluetoothPrivateAPI::Shutdown() { 38 void BluetoothPrivateAPI::Shutdown() {
39 ExtensionSystem::Get(browser_context_)->event_router()->UnregisterObserver( 39 ExtensionSystem::Get(browser_context_)->event_router()->UnregisterObserver(
40 this); 40 this);
41 } 41 }
42 42
43 void BluetoothPrivateAPI::OnListenerAdded(const EventListenerInfo& details) { 43 void BluetoothPrivateAPI::OnListenerAdded(const EventListenerInfo& details) {
44 BluetoothAPI::Get(browser_context_) 44 BluetoothAPI::Get(browser_context_)
45 ->bluetooth_event_router() 45 ->event_router()
46 ->AddPairingDelegate(details.extension_id); 46 ->AddPairingDelegate(details.extension_id);
47 } 47 }
48 48
49 void BluetoothPrivateAPI::OnListenerRemoved(const EventListenerInfo& details) { 49 void BluetoothPrivateAPI::OnListenerRemoved(const EventListenerInfo& details) {
50 BluetoothAPI::Get(browser_context_) 50 BluetoothAPI::Get(browser_context_)
51 ->bluetooth_event_router() 51 ->event_router()
52 ->RemovePairingDelegate(details.extension_id); 52 ->RemovePairingDelegate(details.extension_id);
53 } 53 }
54 54
55 namespace api { 55 namespace api {
56 56
57 namespace { 57 namespace {
58 58
59 const char kNameProperty[] = "name"; 59 const char kNameProperty[] = "name";
60 const char kPoweredProperty[] = "powered"; 60 const char kPoweredProperty[] = "powered";
61 const char kDiscoverableProperty[] = "discoverable"; 61 const char kDiscoverableProperty[] = "discoverable";
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 ~BluetoothPrivateSetPairingResponseFunction() {} 215 ~BluetoothPrivateSetPairingResponseFunction() {}
216 216
217 bool BluetoothPrivateSetPairingResponseFunction::DoWork( 217 bool BluetoothPrivateSetPairingResponseFunction::DoWork(
218 scoped_refptr<device::BluetoothAdapter> adapter) { 218 scoped_refptr<device::BluetoothAdapter> adapter) {
219 scoped_ptr<bt_private::SetPairingResponse::Params> params( 219 scoped_ptr<bt_private::SetPairingResponse::Params> params(
220 bt_private::SetPairingResponse::Params::Create(*args_)); 220 bt_private::SetPairingResponse::Params::Create(*args_));
221 EXTENSION_FUNCTION_VALIDATE(params.get()); 221 EXTENSION_FUNCTION_VALIDATE(params.get());
222 const bt_private::SetPairingResponseOptions& options = params->options; 222 const bt_private::SetPairingResponseOptions& options = params->options;
223 223
224 BluetoothEventRouter* router = 224 BluetoothEventRouter* router =
225 BluetoothAPI::Get(browser_context())->bluetooth_event_router(); 225 BluetoothAPI::Get(browser_context())->event_router();
226 if (!router->GetPairingDelegate(extension_id())) { 226 if (!router->GetPairingDelegate(extension_id())) {
227 SetError(kPairingNotEnabled); 227 SetError(kPairingNotEnabled);
228 SendResponse(false); 228 SendResponse(false);
229 return true; 229 return true;
230 } 230 }
231 231
232 const std::string& device_address = options.device.address; 232 const std::string& device_address = options.device.address;
233 device::BluetoothDevice* device = adapter->GetDevice(device_address); 233 device::BluetoothDevice* device = adapter->GetDevice(device_address);
234 if (!device) { 234 if (!device) {
235 SetError(kDeviceNotFoundError); 235 SetError(kDeviceNotFoundError);
(...skipping 27 matching lines...) Expand all
263 device->SetPasskey(*options.passkey.get()); 263 device->SetPasskey(*options.passkey.get());
264 } 264 }
265 265
266 SendResponse(true); 266 SendResponse(true);
267 return true; 267 return true;
268 } 268 }
269 269
270 } // namespace api 270 } // namespace api
271 271
272 } // namespace extensions 272 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698