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/ui/webui/options2/chromeos/bluetooth_options_handler2.h
" | 5 #include "chrome/browser/ui/webui/options2/chromeos/bluetooth_options_handler2.h
" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "chrome/browser/chromeos/bluetooth/bluetooth_adapter.h" | 11 #include "chrome/browser/chromeos/bluetooth/bluetooth_adapter.h" |
12 #include "chrome/browser/chromeos/bluetooth/bluetooth_device.h" | 12 #include "chrome/browser/chromeos/bluetooth/bluetooth_device.h" |
13 #include "chrome/browser/chromeos/system/runtime_environment.h" | 13 #include "chrome/browser/chromeos/system/runtime_environment.h" |
14 #include "chrome/browser/ui/webui/options2/chromeos/system_settings_provider2.h" | 14 #include "chrome/browser/ui/webui/options2/chromeos/system_settings_provider2.h" |
| 15 #include "chrome/common/chrome_switches.h" |
15 #include "content/public/browser/web_ui.h" | 16 #include "content/public/browser/web_ui.h" |
16 #include "grit/chromium_strings.h" | 17 #include "grit/chromium_strings.h" |
17 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
18 #include "third_party/cros_system_api/dbus/service_constants.h" | 19 #include "third_party/cros_system_api/dbus/service_constants.h" |
19 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
20 | 21 |
21 namespace { | 22 namespace { |
22 | 23 |
23 // |UpdateDeviceCallback| takes a variable length list as an argument. The | 24 // |UpdateDeviceCallback| takes a variable length list as an argument. The |
24 // value stored in each list element is indicated by the following constants. | 25 // value stored in each list element is indicated by the following constants. |
(...skipping 21 matching lines...) Expand all Loading... |
46 | 47 |
47 } // namespace | 48 } // namespace |
48 | 49 |
49 namespace chromeos { | 50 namespace chromeos { |
50 namespace options2 { | 51 namespace options2 { |
51 | 52 |
52 BluetoothOptionsHandler::BluetoothOptionsHandler() : weak_ptr_factory_(this) { | 53 BluetoothOptionsHandler::BluetoothOptionsHandler() : weak_ptr_factory_(this) { |
53 } | 54 } |
54 | 55 |
55 BluetoothOptionsHandler::~BluetoothOptionsHandler() { | 56 BluetoothOptionsHandler::~BluetoothOptionsHandler() { |
| 57 if (!CommandLine::ForCurrentProcess() |
| 58 ->HasSwitch(switches::kEnableBluetooth)) { |
| 59 return; |
| 60 } |
| 61 |
56 adapter_->RemoveObserver(this); | 62 adapter_->RemoveObserver(this); |
57 } | 63 } |
58 | 64 |
59 void BluetoothOptionsHandler::GetLocalizedValues( | 65 void BluetoothOptionsHandler::GetLocalizedValues( |
60 DictionaryValue* localized_strings) { | 66 DictionaryValue* localized_strings) { |
61 DCHECK(localized_strings); | 67 DCHECK(localized_strings); |
62 localized_strings->SetString("bluetooth", | 68 localized_strings->SetString("bluetooth", |
63 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_SECTION_TITLE_BLUETOOTH)); | 69 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_SECTION_TITLE_BLUETOOTH)); |
64 localized_strings->SetString("disableBluetooth", | 70 localized_strings->SetString("disableBluetooth", |
65 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_BLUETOOTH_DISABLE)); | 71 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_BLUETOOTH_DISABLE)); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 web_ui()->RegisterMessageCallback("stopBluetoothDeviceDiscovery", | 183 web_ui()->RegisterMessageCallback("stopBluetoothDeviceDiscovery", |
178 base::Bind(&BluetoothOptionsHandler::StopDiscoveryCallback, | 184 base::Bind(&BluetoothOptionsHandler::StopDiscoveryCallback, |
179 base::Unretained(this))); | 185 base::Unretained(this))); |
180 web_ui()->RegisterMessageCallback("getPairedBluetoothDevices", | 186 web_ui()->RegisterMessageCallback("getPairedBluetoothDevices", |
181 base::Bind(&BluetoothOptionsHandler::GetPairedDevicesCallback, | 187 base::Bind(&BluetoothOptionsHandler::GetPairedDevicesCallback, |
182 base::Unretained(this))); | 188 base::Unretained(this))); |
183 } | 189 } |
184 | 190 |
185 void BluetoothOptionsHandler::InitializeBluetoothStatusCallback( | 191 void BluetoothOptionsHandler::InitializeBluetoothStatusCallback( |
186 const ListValue* args) { | 192 const ListValue* args) { |
| 193 // Bluetooth support is a work in progress. Supress the feature unless |
| 194 // explicitly enabled via a command line flag. |
| 195 if (!CommandLine::ForCurrentProcess() |
| 196 ->HasSwitch(switches::kEnableBluetooth)) { |
| 197 return; |
| 198 } |
187 adapter_.reset(BluetoothAdapter::CreateDefaultAdapter()); | 199 adapter_.reset(BluetoothAdapter::CreateDefaultAdapter()); |
188 adapter_->AddObserver(this); | 200 adapter_->AddObserver(this); |
189 // Show or hide the bluetooth settings and update the checkbox based | 201 // Show or hide the bluetooth settings and update the checkbox based |
190 // on the current present/powered state. | 202 // on the current present/powered state. |
191 AdapterPresentChanged(adapter_.get(), adapter_->IsPresent()); | 203 AdapterPresentChanged(adapter_.get(), adapter_->IsPresent()); |
192 } | 204 } |
193 | 205 |
194 void BluetoothOptionsHandler::EnableChangeCallback( | 206 void BluetoothOptionsHandler::EnableChangeCallback( |
195 const ListValue* args) { | 207 const ListValue* args) { |
196 bool bluetooth_enabled; | 208 bool bluetooth_enabled; |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 void BluetoothOptionsHandler::ErrorCallback() { | 406 void BluetoothOptionsHandler::ErrorCallback() { |
395 // TODO(keybuk): we don't get any form of error response from dbus:: | 407 // TODO(keybuk): we don't get any form of error response from dbus:: |
396 // yet, other than an error occurred. I'm going to fix that, then this | 408 // yet, other than an error occurred. I'm going to fix that, then this |
397 // gets replaced by genuine error information from the method which we | 409 // gets replaced by genuine error information from the method which we |
398 // can act on, rather than a debug log statement. | 410 // can act on, rather than a debug log statement. |
399 DVLOG(1) << "Failed."; | 411 DVLOG(1) << "Failed."; |
400 } | 412 } |
401 | 413 |
402 } // namespace options2 | 414 } // namespace options2 |
403 } // namespace chromeos | 415 } // namespace chromeos |
OLD | NEW |