| 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" |
| 11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "chrome/browser/chromeos/bluetooth/bluetooth_adapter.h" | 14 #include "chrome/browser/chromeos/bluetooth/bluetooth_adapter.h" |
| 15 #include "chrome/browser/chromeos/bluetooth/bluetooth_adapter_factory.h" |
| 15 #include "chrome/browser/chromeos/bluetooth/bluetooth_device.h" | 16 #include "chrome/browser/chromeos/bluetooth/bluetooth_device.h" |
| 16 #include "content/public/browser/web_ui.h" | 17 #include "content/public/browser/web_ui.h" |
| 17 #include "grit/chromium_strings.h" | 18 #include "grit/chromium_strings.h" |
| 18 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
| 19 #include "third_party/cros_system_api/dbus/service_constants.h" | 20 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 20 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| 24 // |UpdateDeviceCallback| takes a variable length list as an argument. The | 25 // |UpdateDeviceCallback| takes a variable length list as an argument. The |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 base::Unretained(this))); | 160 base::Unretained(this))); |
| 160 web_ui()->RegisterMessageCallback("stopBluetoothDeviceDiscovery", | 161 web_ui()->RegisterMessageCallback("stopBluetoothDeviceDiscovery", |
| 161 base::Bind(&BluetoothOptionsHandler::StopDiscoveryCallback, | 162 base::Bind(&BluetoothOptionsHandler::StopDiscoveryCallback, |
| 162 base::Unretained(this))); | 163 base::Unretained(this))); |
| 163 web_ui()->RegisterMessageCallback("getPairedBluetoothDevices", | 164 web_ui()->RegisterMessageCallback("getPairedBluetoothDevices", |
| 164 base::Bind(&BluetoothOptionsHandler::GetPairedDevicesCallback, | 165 base::Bind(&BluetoothOptionsHandler::GetPairedDevicesCallback, |
| 165 base::Unretained(this))); | 166 base::Unretained(this))); |
| 166 } | 167 } |
| 167 | 168 |
| 168 void BluetoothOptionsHandler::InitializeHandler() { | 169 void BluetoothOptionsHandler::InitializeHandler() { |
| 169 adapter_ = BluetoothAdapter::DefaultAdapter(); | 170 adapter_ = BluetoothAdapterFactory::DefaultAdapter(); |
| 170 adapter_->AddObserver(this); | 171 adapter_->AddObserver(this); |
| 171 } | 172 } |
| 172 | 173 |
| 173 void BluetoothOptionsHandler::InitializePage() { | 174 void BluetoothOptionsHandler::InitializePage() { |
| 174 // Show or hide the bluetooth settings and update the checkbox based | 175 // Show or hide the bluetooth settings and update the checkbox based |
| 175 // on the current present/powered state. | 176 // on the current present/powered state. |
| 176 AdapterPresentChanged(adapter_.get(), adapter_->IsPresent()); | 177 AdapterPresentChanged(adapter_.get(), adapter_->IsPresent()); |
| 177 // Automatically start device discovery if the "Add Bluetooth Device" | 178 // Automatically start device discovery if the "Add Bluetooth Device" |
| 178 // overlay is visible. | 179 // overlay is visible. |
| 179 web_ui()->CallJavascriptFunction( | 180 web_ui()->CallJavascriptFunction( |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 DCHECK(device); | 420 DCHECK(device); |
| 420 | 421 |
| 421 base::StringValue address(device->address()); | 422 base::StringValue address(device->address()); |
| 422 web_ui()->CallJavascriptFunction( | 423 web_ui()->CallJavascriptFunction( |
| 423 "options.BrowserOptions.removeBluetoothDevice", | 424 "options.BrowserOptions.removeBluetoothDevice", |
| 424 address); | 425 address); |
| 425 } | 426 } |
| 426 | 427 |
| 427 } // namespace options | 428 } // namespace options |
| 428 } // namespace chromeos | 429 } // namespace chromeos |
| OLD | NEW |