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

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

Issue 145663004: Replace "bluetooth" permission with manifest property. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unused function. Created 6 years, 10 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
« no previous file with comments | « no previous file | chrome/chrome_common.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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, &param)) { 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
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
OLDNEW
« no previous file with comments | « no previous file | chrome/chrome_common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698