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

Side by Side Diff: chrome/browser/ui/webui/options/chromeos/bluetooth_options_handler.cc

Issue 9702028: bluetooth: remove command-line flag, enabling by default (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
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/ui/webui/options/chromeos/bluetooth_options_handler.h" 5 #include "chrome/browser/ui/webui/options/chromeos/bluetooth_options_handler.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/options/chromeos/system_settings_provider.h" 14 #include "chrome/browser/ui/webui/options/chromeos/system_settings_provider.h"
15 #include "chrome/common/chrome_switches.h"
16 #include "content/public/browser/web_ui.h" 15 #include "content/public/browser/web_ui.h"
17 #include "grit/chromium_strings.h" 16 #include "grit/chromium_strings.h"
18 #include "grit/generated_resources.h" 17 #include "grit/generated_resources.h"
19 #include "third_party/cros_system_api/dbus/service_constants.h" 18 #include "third_party/cros_system_api/dbus/service_constants.h"
20 #include "ui/base/l10n/l10n_util.h" 19 #include "ui/base/l10n/l10n_util.h"
21 20
22 namespace { 21 namespace {
23 22
24 // |UpdateDeviceCallback| takes a variable length list as an argument. The 23 // |UpdateDeviceCallback| takes a variable length list as an argument. The
25 // value stored in each list element is indicated by the following constants. 24 // value stored in each list element is indicated by the following constants.
26 const int kUpdateDeviceAddressIndex = 0; 25 const int kUpdateDeviceAddressIndex = 0;
27 const int kUpdateDeviceCommandIndex = 1; 26 const int kUpdateDeviceCommandIndex = 1;
28 const int kUpdateDevicePasskeyIndex = 2; 27 const int kUpdateDevicePasskeyIndex = 2;
29 28
30 } // namespace 29 } // namespace
31 30
32 namespace chromeos { 31 namespace chromeos {
33 32
34 BluetoothOptionsHandler::BluetoothOptionsHandler() { 33 BluetoothOptionsHandler::BluetoothOptionsHandler() {
35 } 34 }
36 35
37 BluetoothOptionsHandler::~BluetoothOptionsHandler() { 36 BluetoothOptionsHandler::~BluetoothOptionsHandler() {
38 if (!CommandLine::ForCurrentProcess()
39 ->HasSwitch(switches::kEnableBluetooth)) {
40 return;
41 }
42
43 adapter_->RemoveObserver(this); 37 adapter_->RemoveObserver(this);
44 } 38 }
45 39
46 void BluetoothOptionsHandler::GetLocalizedValues( 40 void BluetoothOptionsHandler::GetLocalizedValues(
47 DictionaryValue* localized_strings) { 41 DictionaryValue* localized_strings) {
48 DCHECK(localized_strings); 42 DCHECK(localized_strings);
49 43
50 localized_strings->SetString("bluetooth", 44 localized_strings->SetString("bluetooth",
51 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_SECTION_TITLE_BLUETOOTH)); 45 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_SECTION_TITLE_BLUETOOTH));
52 localized_strings->SetString("disableBluetooth", 46 localized_strings->SetString("disableBluetooth",
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 IDS_OPTIONS_SETTINGS_BLUETOOTH_CONNECTION_FAILED_INCORRECT_PIN)); 105 IDS_OPTIONS_SETTINGS_BLUETOOTH_CONNECTION_FAILED_INCORRECT_PIN));
112 localized_strings->SetString("bluetoothErrorTimeout", 106 localized_strings->SetString("bluetoothErrorTimeout",
113 l10n_util::GetStringUTF16( 107 l10n_util::GetStringUTF16(
114 IDS_OPTIONS_SETTINGS_BLUETOOTH_CONNECTION_FAILED_TIMEOUT)); 108 IDS_OPTIONS_SETTINGS_BLUETOOTH_CONNECTION_FAILED_TIMEOUT));
115 localized_strings->SetString("bluetoothErrorConnectionFailed", 109 localized_strings->SetString("bluetoothErrorConnectionFailed",
116 l10n_util::GetStringUTF16( 110 l10n_util::GetStringUTF16(
117 IDS_OPTIONS_SETTINGS_BLUETOOTH_CONNECTION_FAILED)); 111 IDS_OPTIONS_SETTINGS_BLUETOOTH_CONNECTION_FAILED));
118 } 112 }
119 113
120 void BluetoothOptionsHandler::Initialize() { 114 void BluetoothOptionsHandler::Initialize() {
121 // Bluetooth support is a work in progress. Supress the feature unless
122 // explicitly enabled via a command line flag.
123 if (!CommandLine::ForCurrentProcess()
124 ->HasSwitch(switches::kEnableBluetooth)) {
125 return;
126 }
127
128 adapter_.reset(BluetoothAdapter::CreateDefaultAdapter()); 115 adapter_.reset(BluetoothAdapter::CreateDefaultAdapter());
129 adapter_->AddObserver(this); 116 adapter_->AddObserver(this);
130 117
131 // Show or hide the bluetooth settings and update the checkbox based 118 // Show or hide the bluetooth settings and update the checkbox based
132 // on the current present/powered state. 119 // on the current present/powered state.
133 AdapterPresentChanged(adapter_.get(), adapter_->IsPresent()); 120 AdapterPresentChanged(adapter_.get(), adapter_->IsPresent());
134 } 121 }
135 122
136 void BluetoothOptionsHandler::AdapterPresentChanged(BluetoothAdapter* adapter, 123 void BluetoothOptionsHandler::AdapterPresentChanged(BluetoothAdapter* adapter,
137 bool present) { 124 bool present) {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 291
305 void BluetoothOptionsHandler::ErrorCallback() { 292 void BluetoothOptionsHandler::ErrorCallback() {
306 // TODO(keybuk): we don't get any form of error response from dbus:: 293 // TODO(keybuk): we don't get any form of error response from dbus::
307 // yet, other than an error occurred. I'm going to fix that, then this 294 // yet, other than an error occurred. I'm going to fix that, then this
308 // gets replaced by genuine error information from the method which we 295 // gets replaced by genuine error information from the method which we
309 // can act on, rather than a debug log statement. 296 // can act on, rather than a debug log statement.
310 DVLOG(1) << "Failed."; 297 DVLOG(1) << "Failed.";
311 } 298 }
312 299
313 } // namespace chromeos 300 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | chrome/browser/ui/webui/options2/chromeos/bluetooth_options_handler2.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698