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

Side by Side Diff: chrome/browser/chromeos/policy/bluetooth_policy_handler.cc

Issue 1784333002: Add Device Policy Handler for Bluetooth, and allow disabling the Bluetooth adapter on Chrome OS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: code fix Created 4 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
(Empty)
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/policy/bluetooth_policy_handler.h"
6
7 #include "base/bind.h"
8 #include "base/callback.h"
9 #include "chromeos/settings/cros_settings_names.h"
10 #include "chromeos/settings/cros_settings_provider.h"
11 #include "device/bluetooth/bluetooth_adapter_factory.h"
12
13 namespace chromeos {
14
15 BluetoothPolicyHandler::BluetoothPolicyHandler(CrosSettings* cros_settings)
16 : cros_settings_(cros_settings), weak_factory_(this) {
17 bluetooth_policy_subscription_ = cros_settings_->AddSettingsObserver(
18 kAllowBluetooth,
19 base::Bind(&BluetoothPolicyHandler::OnBluetoothPolicyChanged,
20 weak_factory_.GetWeakPtr()));
21 }
22
23 BluetoothPolicyHandler::~BluetoothPolicyHandler() {}
24
25 void BluetoothPolicyHandler::OnBluetoothPolicyChanged() {
ortuno 2016/04/13 21:12:21 You didn't answer atwilson's question: "Are we alw
Ivan Šandrk 2016/04/14 18:08:47 Answered it now. C/P: No guarantee. That's why now
26 CrosSettingsProvider::TrustedStatus status =
27 cros_settings_->PrepareTrustedValues(
28 base::Bind(&BluetoothPolicyHandler::OnBluetoothPolicyChanged,
29 weak_factory_.GetWeakPtr()));
30 if (status != CrosSettingsProvider::TRUSTED)
31 return;
32
33 // Get the updated policy.
34 bool allow_bluetooth = true;
35 cros_settings_->GetBoolean(kAllowBluetooth, &allow_bluetooth);
36
37 // device::BluetoothAdapterFactory::GetAdapter(
scheib 2016/04/13 19:47:44 Don't leave commented out code.
Ivan Šandrk 2016/04/14 18:08:47 Once again sorry for the half-baked code, wanted t
38 // base::Bind(&BluetoothPolicyHandler::SetBluetoothPolicy,
39 // weak_factory_.GetWeakPtr(), allow_bluetooth));
40 device::BluetoothAdapterFactory::GetAdapter(
41 base::Bind(&BluetoothPolicyHandler::SetBluetoothPolicy,
42 nullptr, allow_bluetooth));
43 }
44
45 void BluetoothPolicyHandler::SetBluetoothPolicy(
46 bool allow_bluetooth, scoped_refptr<device::BluetoothAdapter> adapter) {
47 // !allow_bluetooth because we have a switch in logic
48 // (allow bluetooth -> disable bluetooth)
49 adapter->SetDisabled(!allow_bluetooth);
50 }
51
52 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698