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" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 | 129 |
130 void BluetoothOptionsHandler::Initialize() { | 130 void BluetoothOptionsHandler::Initialize() { |
131 // Bluetooth support is a work in progress. Supress the feature unless | 131 // Bluetooth support is a work in progress. Supress the feature unless |
132 // explicitly enabled via a command line flag. | 132 // explicitly enabled via a command line flag. |
133 if (!CommandLine::ForCurrentProcess() | 133 if (!CommandLine::ForCurrentProcess() |
134 ->HasSwitch(switches::kEnableBluetooth)) { | 134 ->HasSwitch(switches::kEnableBluetooth)) { |
135 return; | 135 return; |
136 } | 136 } |
137 | 137 |
138 web_ui()->CallJavascriptFunction( | 138 web_ui()->CallJavascriptFunction( |
139 "options.AdvancedOptions.showBluetoothSettings"); | 139 "options.BrowserOptions.showBluetoothSettings"); |
140 | 140 |
141 // TODO(kevers): Determine whether bluetooth adapter is powered. | 141 // TODO(kevers): Determine whether bluetooth adapter is powered. |
142 bool bluetooth_on = false; | 142 bool bluetooth_on = false; |
143 base::FundamentalValue checked(bluetooth_on); | 143 base::FundamentalValue checked(bluetooth_on); |
144 web_ui()->CallJavascriptFunction( | 144 web_ui()->CallJavascriptFunction( |
145 "options.AdvancedOptions.setBluetoothState", checked); | 145 "options.BrowserOptions.setBluetoothState", checked); |
146 | 146 |
147 chromeos::BluetoothManager* bluetooth_manager = | 147 chromeos::BluetoothManager* bluetooth_manager = |
148 chromeos::BluetoothManager::GetInstance(); | 148 chromeos::BluetoothManager::GetInstance(); |
149 DCHECK(bluetooth_manager); | 149 DCHECK(bluetooth_manager); |
150 bluetooth_manager->AddObserver(this); | 150 bluetooth_manager->AddObserver(this); |
151 | 151 |
152 chromeos::BluetoothAdapter* default_adapter = | 152 chromeos::BluetoothAdapter* default_adapter = |
153 bluetooth_manager->DefaultAdapter(); | 153 bluetooth_manager->DefaultAdapter(); |
154 DefaultAdapterChanged(default_adapter); | 154 DefaultAdapterChanged(default_adapter); |
155 } | 155 } |
(...skipping 17 matching lines...) Expand all Loading... |
173 | 173 |
174 } | 174 } |
175 | 175 |
176 void BluetoothOptionsHandler::EnableChangeCallback( | 176 void BluetoothOptionsHandler::EnableChangeCallback( |
177 const ListValue* args) { | 177 const ListValue* args) { |
178 bool bluetooth_enabled; | 178 bool bluetooth_enabled; |
179 args->GetBoolean(0, &bluetooth_enabled); | 179 args->GetBoolean(0, &bluetooth_enabled); |
180 // TODO(kevers): Call Bluetooth API to enable or disable. | 180 // TODO(kevers): Call Bluetooth API to enable or disable. |
181 base::FundamentalValue checked(bluetooth_enabled); | 181 base::FundamentalValue checked(bluetooth_enabled); |
182 web_ui()->CallJavascriptFunction( | 182 web_ui()->CallJavascriptFunction( |
183 "options.AdvancedOptions.setBluetoothState", checked); | 183 "options.BrowserOptions.setBluetoothState", checked); |
184 } | 184 } |
185 | 185 |
186 void BluetoothOptionsHandler::FindDevicesCallback( | 186 void BluetoothOptionsHandler::FindDevicesCallback( |
187 const ListValue* args) { | 187 const ListValue* args) { |
188 // We only initiate a scan if we're running on Chrome OS. Otherwise, we | 188 // We only initiate a scan if we're running on Chrome OS. Otherwise, we |
189 // generate a fake device list. | 189 // generate a fake device list. |
190 if (!chromeos::system::runtime_environment::IsRunningOnChromeOS()) { | 190 if (!chromeos::system::runtime_environment::IsRunningOnChromeOS()) { |
191 GenerateFakeDeviceList(); | 191 GenerateFakeDeviceList(); |
192 return; | 192 return; |
193 } | 193 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 base::DictionaryValue js_properties; | 260 base::DictionaryValue js_properties; |
261 js_properties.SetString("name", device->GetName()); | 261 js_properties.SetString("name", device->GetName()); |
262 js_properties.SetString("address", device->GetAddress()); | 262 js_properties.SetString("address", device->GetAddress()); |
263 js_properties.SetString("icon", device->GetIcon()); | 263 js_properties.SetString("icon", device->GetIcon()); |
264 js_properties.SetBoolean("paired", device->IsPaired()); | 264 js_properties.SetBoolean("paired", device->IsPaired()); |
265 js_properties.SetBoolean("connected", device->IsConnected()); | 265 js_properties.SetBoolean("connected", device->IsConnected()); |
266 if (params) { | 266 if (params) { |
267 js_properties.MergeDictionary(params); | 267 js_properties.MergeDictionary(params); |
268 } | 268 } |
269 web_ui()->CallJavascriptFunction( | 269 web_ui()->CallJavascriptFunction( |
270 "options.AdvancedOptions.addBluetoothDevice", | 270 "options.BrowserOptions.addBluetoothDevice", |
271 js_properties); | 271 js_properties); |
272 } | 272 } |
273 | 273 |
274 void BluetoothOptionsHandler::RequestConfirmation( | 274 void BluetoothOptionsHandler::RequestConfirmation( |
275 chromeos::BluetoothDevice* device, | 275 chromeos::BluetoothDevice* device, |
276 int passkey) { | 276 int passkey) { |
277 DictionaryValue params; | 277 DictionaryValue params; |
278 params.SetString("pairing", "bluetoothConfirmPasskey"); | 278 params.SetString("pairing", "bluetoothConfirmPasskey"); |
279 params.SetInteger("passkey", passkey); | 279 params.SetInteger("passkey", passkey); |
280 SendDeviceNotification(device, ¶ms); | 280 SendDeviceNotification(device, ¶ms); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 // Sending an error notification. | 414 // Sending an error notification. |
415 DictionaryValue params; | 415 DictionaryValue params; |
416 params.SetString("pairing", pairing); | 416 params.SetString("pairing", pairing); |
417 SendDeviceNotification(device, ¶ms); | 417 SendDeviceNotification(device, ¶ms); |
418 } | 418 } |
419 delete device; | 419 delete device; |
420 } | 420 } |
421 | 421 |
422 } // namespace options2 | 422 } // namespace options2 |
423 } // namespace chromeos | 423 } // namespace chromeos |
OLD | NEW |