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

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: RunCallbackOnAdapterReady runs callback regardless of Bluetooth Adapter availability. 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 base::Unretained(this)));
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 bool BluetoothOptionsHandler::InitializeAdapter(
202 scoped_refptr<device::BluetoothAdapter> adapter) {
203 adapter_ = adapter;
204 DCHECK(adapter_.get());
bryeung 2013/01/09 15:28:02 This should either be a CHECK, or we should let it
youngki 2013/01/09 19:32:24 Done.
205 adapter_->AddObserver(this);
206 return true;
207 }
208
201 void BluetoothOptionsHandler::EnableChangeCallback( 209 void BluetoothOptionsHandler::EnableChangeCallback(
202 const ListValue* args) { 210 const ListValue* args) {
203 bool bluetooth_enabled; 211 bool bluetooth_enabled;
204 args->GetBoolean(0, &bluetooth_enabled); 212 args->GetBoolean(0, &bluetooth_enabled);
205 213
206 adapter_->SetPowered(bluetooth_enabled, 214 adapter_->SetPowered(bluetooth_enabled,
207 base::Bind(&base::DoNothing), 215 base::Bind(&base::DoNothing),
208 base::Bind(&BluetoothOptionsHandler::EnableChangeError, 216 base::Bind(&BluetoothOptionsHandler::EnableChangeError,
209 weak_ptr_factory_.GetWeakPtr())); 217 weak_ptr_factory_.GetWeakPtr()));
210 } 218 }
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 DCHECK(device); 477 DCHECK(device);
470 478
471 base::StringValue address(device->address()); 479 base::StringValue address(device->address());
472 web_ui()->CallJavascriptFunction( 480 web_ui()->CallJavascriptFunction(
473 "options.BrowserOptions.removeBluetoothDevice", 481 "options.BrowserOptions.removeBluetoothDevice",
474 address); 482 address);
475 } 483 }
476 484
477 } // namespace options 485 } // namespace options
478 } // namespace chromeos 486 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698