| 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/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/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 AdapterPresentChanged(adapter_.get(), adapter_->IsPresent()); | 206 AdapterPresentChanged(adapter_.get(), adapter_->IsPresent()); |
| 207 // Automatically start device discovery if the "Add Bluetooth Device" | 207 // Automatically start device discovery if the "Add Bluetooth Device" |
| 208 // overlay is visible. | 208 // overlay is visible. |
| 209 web_ui()->CallJavascriptFunction( | 209 web_ui()->CallJavascriptFunction( |
| 210 "options.BluetoothOptions.updateDiscovery"); | 210 "options.BluetoothOptions.updateDiscovery"); |
| 211 } | 211 } |
| 212 | 212 |
| 213 void BluetoothOptionsHandler::InitializeAdapter( | 213 void BluetoothOptionsHandler::InitializeAdapter( |
| 214 scoped_refptr<device::BluetoothAdapter> adapter) { | 214 scoped_refptr<device::BluetoothAdapter> adapter) { |
| 215 adapter_ = adapter; | 215 adapter_ = adapter; |
| 216 CHECK(adapter_); | 216 CHECK(adapter_.get()); |
| 217 adapter_->AddObserver(this); | 217 adapter_->AddObserver(this); |
| 218 } | 218 } |
| 219 | 219 |
| 220 void BluetoothOptionsHandler::EnableChangeCallback( | 220 void BluetoothOptionsHandler::EnableChangeCallback( |
| 221 const ListValue* args) { | 221 const ListValue* args) { |
| 222 bool bluetooth_enabled; | 222 bool bluetooth_enabled; |
| 223 args->GetBoolean(0, &bluetooth_enabled); | 223 args->GetBoolean(0, &bluetooth_enabled); |
| 224 | 224 |
| 225 adapter_->SetPowered(bluetooth_enabled, | 225 adapter_->SetPowered(bluetooth_enabled, |
| 226 base::Bind(&base::DoNothing), | 226 base::Bind(&base::DoNothing), |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 | 507 |
| 508 void BluetoothOptionsHandler::ConfirmPasskey(device::BluetoothDevice* device, | 508 void BluetoothOptionsHandler::ConfirmPasskey(device::BluetoothDevice* device, |
| 509 uint32 passkey) { | 509 uint32 passkey) { |
| 510 DictionaryValue params; | 510 DictionaryValue params; |
| 511 params.SetString("pairing", kConfirmPasskey); | 511 params.SetString("pairing", kConfirmPasskey); |
| 512 params.SetInteger("passkey", passkey); | 512 params.SetInteger("passkey", passkey); |
| 513 SendDeviceNotification(device, ¶ms); | 513 SendDeviceNotification(device, ¶ms); |
| 514 } | 514 } |
| 515 | 515 |
| 516 void BluetoothOptionsHandler::DismissDisplayOrConfirm() { | 516 void BluetoothOptionsHandler::DismissDisplayOrConfirm() { |
| 517 DCHECK(adapter_); | 517 DCHECK(adapter_.get()); |
| 518 | 518 |
| 519 // We can receive this delegate call when we haven't been asked to display or | 519 // We can receive this delegate call when we haven't been asked to display or |
| 520 // confirm anything; we can determine that by checking whether we've saved | 520 // confirm anything; we can determine that by checking whether we've saved |
| 521 // pairing information for the device. This is also a handy way to get the | 521 // pairing information for the device. This is also a handy way to get the |
| 522 // BluetoothDevice object we need. | 522 // BluetoothDevice object we need. |
| 523 if (!pairing_device_address_.empty()) { | 523 if (!pairing_device_address_.empty()) { |
| 524 device::BluetoothDevice* device = | 524 device::BluetoothDevice* device = |
| 525 adapter_->GetDevice(pairing_device_address_); | 525 adapter_->GetDevice(pairing_device_address_); |
| 526 DCHECK(device); | 526 DCHECK(device); |
| 527 DeviceConnecting(device); | 527 DeviceConnecting(device); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 void BluetoothOptionsHandler::DeviceConnecting( | 573 void BluetoothOptionsHandler::DeviceConnecting( |
| 574 device::BluetoothDevice* device) { | 574 device::BluetoothDevice* device) { |
| 575 DCHECK(device); | 575 DCHECK(device); |
| 576 DictionaryValue params; | 576 DictionaryValue params; |
| 577 params.SetString("pairing", kStartConnecting); | 577 params.SetString("pairing", kStartConnecting); |
| 578 SendDeviceNotification(device, ¶ms); | 578 SendDeviceNotification(device, ¶ms); |
| 579 } | 579 } |
| 580 | 580 |
| 581 } // namespace options | 581 } // namespace options |
| 582 } // namespace chromeos | 582 } // namespace chromeos |
| OLD | NEW |