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

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

Issue 9701056: Revert 126809 - 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"
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.
25 const int kUpdateDeviceAddressIndex = 0; 26 const int kUpdateDeviceAddressIndex = 0;
26 const int kUpdateDeviceCommandIndex = 1; 27 const int kUpdateDeviceCommandIndex = 1;
27 const int kUpdateDevicePasskeyIndex = 2; 28 const int kUpdateDevicePasskeyIndex = 2;
28 29
29 } // namespace 30 } // namespace
30 31
31 namespace chromeos { 32 namespace chromeos {
32 33
33 BluetoothOptionsHandler::BluetoothOptionsHandler() { 34 BluetoothOptionsHandler::BluetoothOptionsHandler() {
34 } 35 }
35 36
36 BluetoothOptionsHandler::~BluetoothOptionsHandler() { 37 BluetoothOptionsHandler::~BluetoothOptionsHandler() {
38 if (!CommandLine::ForCurrentProcess()
39 ->HasSwitch(switches::kEnableBluetooth)) {
40 return;
41 }
42
37 adapter_->RemoveObserver(this); 43 adapter_->RemoveObserver(this);
38 } 44 }
39 45
40 void BluetoothOptionsHandler::GetLocalizedValues( 46 void BluetoothOptionsHandler::GetLocalizedValues(
41 DictionaryValue* localized_strings) { 47 DictionaryValue* localized_strings) {
42 DCHECK(localized_strings); 48 DCHECK(localized_strings);
43 49
44 localized_strings->SetString("bluetooth", 50 localized_strings->SetString("bluetooth",
45 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_SECTION_TITLE_BLUETOOTH)); 51 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_SECTION_TITLE_BLUETOOTH));
46 localized_strings->SetString("disableBluetooth", 52 localized_strings->SetString("disableBluetooth",
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 IDS_OPTIONS_SETTINGS_BLUETOOTH_CONNECTION_FAILED_INCORRECT_PIN)); 111 IDS_OPTIONS_SETTINGS_BLUETOOTH_CONNECTION_FAILED_INCORRECT_PIN));
106 localized_strings->SetString("bluetoothErrorTimeout", 112 localized_strings->SetString("bluetoothErrorTimeout",
107 l10n_util::GetStringUTF16( 113 l10n_util::GetStringUTF16(
108 IDS_OPTIONS_SETTINGS_BLUETOOTH_CONNECTION_FAILED_TIMEOUT)); 114 IDS_OPTIONS_SETTINGS_BLUETOOTH_CONNECTION_FAILED_TIMEOUT));
109 localized_strings->SetString("bluetoothErrorConnectionFailed", 115 localized_strings->SetString("bluetoothErrorConnectionFailed",
110 l10n_util::GetStringUTF16( 116 l10n_util::GetStringUTF16(
111 IDS_OPTIONS_SETTINGS_BLUETOOTH_CONNECTION_FAILED)); 117 IDS_OPTIONS_SETTINGS_BLUETOOTH_CONNECTION_FAILED));
112 } 118 }
113 119
114 void BluetoothOptionsHandler::Initialize() { 120 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
115 adapter_.reset(BluetoothAdapter::CreateDefaultAdapter()); 128 adapter_.reset(BluetoothAdapter::CreateDefaultAdapter());
116 adapter_->AddObserver(this); 129 adapter_->AddObserver(this);
117 130
118 // Show or hide the bluetooth settings and update the checkbox based 131 // Show or hide the bluetooth settings and update the checkbox based
119 // on the current present/powered state. 132 // on the current present/powered state.
120 AdapterPresentChanged(adapter_.get(), adapter_->IsPresent()); 133 AdapterPresentChanged(adapter_.get(), adapter_->IsPresent());
121 } 134 }
122 135
123 void BluetoothOptionsHandler::AdapterPresentChanged(BluetoothAdapter* adapter, 136 void BluetoothOptionsHandler::AdapterPresentChanged(BluetoothAdapter* adapter,
124 bool present) { 137 bool present) {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 304
292 void BluetoothOptionsHandler::ErrorCallback() { 305 void BluetoothOptionsHandler::ErrorCallback() {
293 // TODO(keybuk): we don't get any form of error response from dbus:: 306 // TODO(keybuk): we don't get any form of error response from dbus::
294 // yet, other than an error occurred. I'm going to fix that, then this 307 // yet, other than an error occurred. I'm going to fix that, then this
295 // gets replaced by genuine error information from the method which we 308 // gets replaced by genuine error information from the method which we
296 // can act on, rather than a debug log statement. 309 // can act on, rather than a debug log statement.
297 DVLOG(1) << "Failed."; 310 DVLOG(1) << "Failed.";
298 } 311 }
299 312
300 } // namespace chromeos 313 } // 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