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

Unified Diff: chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_api.cc

Issue 325893002: Bluetooth: add socket & low_energy manifest check (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add permission denied tests Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_apitest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_api.cc
diff --git a/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_api.cc b/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_api.cc
index 4c29506d6e8808f5cee710d3632a16a4ae216043..e938f3e442e75f6544f360f3ad367733bc07268f 100644
--- a/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_api.cc
+++ b/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_api.cc
@@ -9,9 +9,11 @@
#include "base/strings/stringprintf.h"
#include "chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_event_router.h"
#include "chrome/browser/extensions/api/bluetooth_low_energy/utils.h"
+#include "chrome/common/extensions/api/bluetooth/bluetooth_manifest_data.h"
#include "chrome/common/extensions/api/bluetooth_low_energy.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/browser/event_router.h"
+#include "extensions/common/permissions/permissions_data.h"
using content::BrowserContext;
using content::BrowserThread;
@@ -39,6 +41,7 @@ const char kErrorWriteCharacteristicValueFailedFormat[] =
"Failed to write value of characteristic with ID \"%s\".";
const char kErrorWriteDescriptorValueFailedFormat[] =
"Failed to write value of descriptor with ID \"%s\".";
+const char kErrorPermissionDenied[] = "Permission denied";
extensions::BluetoothLowEnergyEventRouter* GetEventRouter(
BrowserContext* context) {
@@ -94,6 +97,11 @@ BluetoothLowEnergyExtensionFunction::~BluetoothLowEnergyExtensionFunction() {
bool BluetoothLowEnergyExtensionFunction::RunAsync() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ if (!BluetoothManifestData::CheckLowEnergyPermitted(GetExtension())) {
+ error_ = kErrorPermissionDenied;
+ return false;
+ }
+
BluetoothLowEnergyEventRouter* event_router =
GetEventRouter(browser_context());
if (!event_router->IsBluetoothSupported()) {
« no previous file with comments | « no previous file | chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698