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

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

Issue 11819007: Changed DefaultAdapter to RunCallbackOnAdapterReady function. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created IsBluetoothSupported in BluetoothEventRouter to fix browser_tests. Created 7 years, 11 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/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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 base::Unretained(this))); 176 base::Unretained(this)));
177 web_ui()->RegisterMessageCallback("stopBluetoothDeviceDiscovery", 177 web_ui()->RegisterMessageCallback("stopBluetoothDeviceDiscovery",
178 base::Bind(&BluetoothOptionsHandler::StopDiscoveryCallback, 178 base::Bind(&BluetoothOptionsHandler::StopDiscoveryCallback,
179 base::Unretained(this))); 179 base::Unretained(this)));
180 web_ui()->RegisterMessageCallback("getPairedBluetoothDevices", 180 web_ui()->RegisterMessageCallback("getPairedBluetoothDevices",
181 base::Bind(&BluetoothOptionsHandler::GetPairedDevicesCallback, 181 base::Bind(&BluetoothOptionsHandler::GetPairedDevicesCallback,
182 base::Unretained(this))); 182 base::Unretained(this)));
183 } 183 }
184 184
185 void BluetoothOptionsHandler::InitializeHandler() { 185 void BluetoothOptionsHandler::InitializeHandler() {
186 adapter_ = device::BluetoothAdapterFactory::DefaultAdapter(); 186 device::BluetoothAdapterFactory::RunCallbackOnAdapterReady(
187 DCHECK(adapter_.get()); 187 base::Bind(&BluetoothOptionsHandler::InitializeAdapter,
188 adapter_->AddObserver(this); 188 weak_ptr_factory_.GetWeakPtr()));
189 } 189 }
190 190
191 void BluetoothOptionsHandler::InitializePage() { 191 void BluetoothOptionsHandler::InitializePage() {
192 // Show or hide the bluetooth settings and update the checkbox based 192 // Show or hide the bluetooth settings and update the checkbox based
193 // on the current present/powered state. 193 // on the current present/powered state.
194 AdapterPresentChanged(adapter_.get(), adapter_->IsPresent()); 194 AdapterPresentChanged(adapter_.get(), adapter_->IsPresent());
195 // Automatically start device discovery if the "Add Bluetooth Device" 195 // Automatically start device discovery if the "Add Bluetooth Device"
196 // overlay is visible. 196 // overlay is visible.
197 web_ui()->CallJavascriptFunction( 197 web_ui()->CallJavascriptFunction(
198 "options.BluetoothOptions.updateDiscovery"); 198 "options.BluetoothOptions.updateDiscovery");
199 } 199 }
200 200
201 void BluetoothOptionsHandler::InitializeAdapter(
202 scoped_refptr<device::BluetoothAdapter> adapter) {
203 adapter_ = adapter;
204 CHECK(adapter_);
205 adapter_->AddObserver(this);
206 }
207
201 void BluetoothOptionsHandler::EnableChangeCallback( 208 void BluetoothOptionsHandler::EnableChangeCallback(
202 const ListValue* args) { 209 const ListValue* args) {
203 bool bluetooth_enabled; 210 bool bluetooth_enabled;
204 args->GetBoolean(0, &bluetooth_enabled); 211 args->GetBoolean(0, &bluetooth_enabled);
205 212
206 adapter_->SetPowered(bluetooth_enabled, 213 adapter_->SetPowered(bluetooth_enabled,
207 base::Bind(&base::DoNothing), 214 base::Bind(&base::DoNothing),
208 base::Bind(&BluetoothOptionsHandler::EnableChangeError, 215 base::Bind(&BluetoothOptionsHandler::EnableChangeError,
209 weak_ptr_factory_.GetWeakPtr())); 216 weak_ptr_factory_.GetWeakPtr()));
210 } 217 }
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 DCHECK(device); 476 DCHECK(device);
470 477
471 base::StringValue address(device->address()); 478 base::StringValue address(device->address());
472 web_ui()->CallJavascriptFunction( 479 web_ui()->CallJavascriptFunction(
473 "options.BrowserOptions.removeBluetoothDevice", 480 "options.BrowserOptions.removeBluetoothDevice",
474 address); 481 address);
475 } 482 }
476 483
477 } // namespace options 484 } // namespace options
478 } // namespace chromeos 485 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698