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

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

Issue 2249333002: Prevent peripheral mode operation from outside of Kiosk. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 4 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_chromeos.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 122f6a106839c5fcc0baa0d384135b50992d8a6d..a34580f671f39955f109f5fffe9825a8e96ab18a 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
@@ -324,6 +324,21 @@ device::BluetoothGattCharacteristic::Permissions GetBluetoothPermissions(
return permissions;
}
+bool IsAutoLaunchedKioskApp(const ExtensionId& id) {
+#if defined(OS_CHROMEOS)
+ chromeos::KioskAppManager::App app_info;
+ return chromeos::KioskAppManager::Get()->GetApp(id, &app_info) &&
+ app_info.was_auto_launched_with_zero_delay;
+#else
+ return false;
+#endif
+}
+
+bool IsPeripheralFlagEnabled() {
+ return base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableBLEAdvertising);
+}
+
} // namespace
@@ -440,6 +455,11 @@ BLEPeripheralExtensionFunction<Params>::Run() {
if (!BluetoothManifestData::CheckPeripheralPermitted(extension()))
return RespondNow(Error(kErrorPermissionDenied));
+ if (!(IsAutoLaunchedKioskApp(extension()->id()) ||
+ IsPeripheralFlagEnabled())) {
+ return RespondNow(Error(kErrorPermissionDenied));
+ }
+
// Causes link error on Windows. API will never be on Windows, so #ifdefing.
#if !defined(OS_WIN)
params_ = Params::Create(*args_);
@@ -1110,21 +1130,6 @@ void BluetoothLowEnergyAdvertisementFunction::Initialize() {
ApiResourceManager<BluetoothApiAdvertisement>::Get(browser_context());
}
-static bool IsAutoLaunchedKioskApp(const ExtensionId& id) {
-#if defined(OS_CHROMEOS)
- chromeos::KioskAppManager::App app_info;
- return chromeos::KioskAppManager::Get()->GetApp(id, &app_info) &&
- app_info.was_auto_launched_with_zero_delay;
-#else
- return false;
-#endif
-}
-
-static bool IsPeripheralFlagEnabled() {
- return base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableBLEAdvertising);
-}
-
// RegisterAdvertisement:
bool BluetoothLowEnergyRegisterAdvertisementFunction::DoWork() {
« no previous file with comments | « no previous file | chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_apitest_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698