OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_api.h" | 5 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api_factory.h" | 10 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api_factory.h" |
11 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api_utils.h" | 11 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api_utils.h" |
12 #include "chrome/browser/extensions/api/bluetooth/bluetooth_event_router.h" | 12 #include "chrome/browser/extensions/api/bluetooth/bluetooth_event_router.h" |
13 #include "chrome/browser/extensions/event_names.h" | 13 #include "chrome/browser/extensions/event_names.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/common/extensions/api/bluetooth.h" | 15 #include "chrome/common/extensions/api/bluetooth.h" |
16 #include "chrome/common/extensions/permissions/bluetooth_permission.h" | 16 #include "chrome/common/extensions/api/bluetooth/bluetooth_manifest_data.h" |
17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
18 #include "device/bluetooth/bluetooth_adapter.h" | 18 #include "device/bluetooth/bluetooth_adapter.h" |
19 #include "device/bluetooth/bluetooth_device.h" | 19 #include "device/bluetooth/bluetooth_device.h" |
20 #include "device/bluetooth/bluetooth_out_of_band_pairing_data.h" | 20 #include "device/bluetooth/bluetooth_out_of_band_pairing_data.h" |
21 #include "device/bluetooth/bluetooth_profile.h" | 21 #include "device/bluetooth/bluetooth_profile.h" |
22 #include "device/bluetooth/bluetooth_service_record.h" | 22 #include "device/bluetooth/bluetooth_service_record.h" |
23 #include "device/bluetooth/bluetooth_socket.h" | 23 #include "device/bluetooth/bluetooth_socket.h" |
24 #include "device/bluetooth/bluetooth_utils.h" | 24 #include "device/bluetooth/bluetooth_utils.h" |
25 #include "extensions/browser/event_router.h" | 25 #include "extensions/browser/event_router.h" |
26 #include "extensions/browser/extension_system.h" | 26 #include "extensions/browser/extension_system.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 | 118 |
119 bool BluetoothAddProfileFunction::RunImpl() { | 119 bool BluetoothAddProfileFunction::RunImpl() { |
120 scoped_ptr<AddProfile::Params> params(AddProfile::Params::Create(*args_)); | 120 scoped_ptr<AddProfile::Params> params(AddProfile::Params::Create(*args_)); |
121 EXTENSION_FUNCTION_VALIDATE(params.get() != NULL); | 121 EXTENSION_FUNCTION_VALIDATE(params.get() != NULL); |
122 | 122 |
123 if (!BluetoothDevice::IsUUIDValid(params->profile.uuid)) { | 123 if (!BluetoothDevice::IsUUIDValid(params->profile.uuid)) { |
124 SetError(kInvalidUuid); | 124 SetError(kInvalidUuid); |
125 return false; | 125 return false; |
126 } | 126 } |
127 | 127 |
128 BluetoothPermission::CheckParam param(params->profile.uuid); | 128 BluetoothPermissionRequest param(params->profile.uuid); |
129 if (!PermissionsData::CheckAPIPermissionWithParam( | 129 if (!BluetoothManifestData::CheckRequest(GetExtension(), param)) { |
130 GetExtension(), APIPermission::kBluetooth, ¶m)) { | 130 error_ = kPermissionDenied; |
131 SetError(kPermissionDenied); | |
132 return false; | 131 return false; |
133 } | 132 } |
134 | 133 |
135 uuid_ = device::bluetooth_utils::CanonicalUuid(params->profile.uuid); | 134 uuid_ = device::bluetooth_utils::CanonicalUuid(params->profile.uuid); |
136 | 135 |
137 if (GetEventRouter(GetProfile())->HasProfile(uuid_)) { | 136 if (GetEventRouter(GetProfile())->HasProfile(uuid_)) { |
138 SetError(kProfileAlreadyRegistered); | 137 SetError(kProfileAlreadyRegistered); |
139 return false; | 138 return false; |
140 } | 139 } |
141 | 140 |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 adapter->StopDiscovering( | 664 adapter->StopDiscovering( |
666 base::Bind(&BluetoothStopDiscoveryFunction::OnSuccessCallback, this), | 665 base::Bind(&BluetoothStopDiscoveryFunction::OnSuccessCallback, this), |
667 base::Bind(&BluetoothStopDiscoveryFunction::OnErrorCallback, this)); | 666 base::Bind(&BluetoothStopDiscoveryFunction::OnErrorCallback, this)); |
668 } | 667 } |
669 | 668 |
670 return true; | 669 return true; |
671 } | 670 } |
672 | 671 |
673 } // namespace api | 672 } // namespace api |
674 } // namespace extensions | 673 } // namespace extensions |
OLD | NEW |