Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/pairing/bluetooth_controller_pairing_controller.h" | 5 #include "components/pairing/bluetooth_controller_pairing_controller.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "components/pairing/bluetooth_pairing_constants.h" | 12 #include "components/pairing/bluetooth_pairing_constants.h" |
| 13 #include "components/pairing/pairing_api.pb.h" | 13 #include "components/pairing/pairing_api.pb.h" |
| 14 #include "device/bluetooth/bluetooth_adapter_factory.h" | 14 #include "device/bluetooth/bluetooth_adapter_factory.h" |
| 15 #include "device/bluetooth/bluetooth_discovery_session.h" | 15 #include "device/bluetooth/bluetooth_discovery_session.h" |
| 16 #include "net/base/io_buffer.h" | 16 #include "net/base/io_buffer.h" |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 const char* kFakeEnrollmentDomain = "http://fake.com"; | 19 const char* kFakeEnrollmentDomain = "http://fake.com"; |
|
achuithb
2014/08/27 21:41:36
Is this used any more?
Zachary Kuznia
2014/08/27 22:01:49
Removed.
| |
| 20 const int kReceiveSize = 16384; | 20 const int kReceiveSize = 16384; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace pairing_chromeos { | 23 namespace pairing_chromeos { |
| 24 | 24 |
| 25 BluetoothControllerPairingController::BluetoothControllerPairingController() | 25 BluetoothControllerPairingController::BluetoothControllerPairingController() |
| 26 : current_stage_(STAGE_NONE), | 26 : current_stage_(STAGE_NONE), |
| 27 got_initial_status_(false), | 27 got_initial_status_(false), |
| 28 proto_decoder_(new ProtoDecoder(this)), | 28 proto_decoder_(new ProtoDecoder(this)), |
| 29 ptr_factory_(this) { | 29 ptr_factory_(this) { |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 297 device->ConfirmPairing(); | 297 device->ConfirmPairing(); |
| 298 // Once pairing is confirmed, the connection will either be successful, or | 298 // Once pairing is confirmed, the connection will either be successful, or |
| 299 // fail. Either case is acceptable as long as the devices are paired. | 299 // fail. Either case is acceptable as long as the devices are paired. |
| 300 } else { | 300 } else { |
| 301 device->RejectPairing(); | 301 device->RejectPairing(); |
| 302 controller_device_id_.clear(); | 302 controller_device_id_.clear(); |
| 303 RepeatDiscovery(); | 303 RepeatDiscovery(); |
| 304 } | 304 } |
| 305 } | 305 } |
| 306 | 306 |
| 307 void BluetoothControllerPairingController::SetHostConfiguration( | |
| 308 bool accepted_eula, | |
| 309 const std::string& lang, | |
| 310 const std::string& timezone, | |
| 311 bool send_reports, | |
| 312 const std::string& keyboard_layout) { | |
| 313 // TODO(zork): Get configuration from UI and send to Host. | |
| 314 // (http://crbug.com/405744) | |
| 315 } | |
| 316 | |
| 307 void BluetoothControllerPairingController::OnAuthenticationDone( | 317 void BluetoothControllerPairingController::OnAuthenticationDone( |
| 308 const chromeos::UserContext& user_context, | 318 const std::string& domain, |
|
achuithb
2014/08/27 21:41:36
Is domain used?
Zachary Kuznia
2014/08/27 22:01:49
Leaving it per the design, as discussed.
| |
| 309 content::BrowserContext* browser_context) { | 319 const std::string& auth_token) { |
| 310 DCHECK_EQ(current_stage_, STAGE_WAITING_FOR_CREDENTIALS); | 320 DCHECK_EQ(current_stage_, STAGE_WAITING_FOR_CREDENTIALS); |
| 311 | 321 |
| 312 // TODO(zork): Get configuration from UI and send to Host. | |
| 313 // (http://crbug.com/405744) | |
| 314 | |
| 315 // TODO(zork): Get proper credentials. (http://crbug.com/405744) | |
| 316 // For now, send a fake domain. | |
| 317 pairing_api::PairDevices pair_devices; | 322 pairing_api::PairDevices pair_devices; |
| 318 pair_devices.set_api_version(kPairingAPIVersion); | 323 pair_devices.set_api_version(kPairingAPIVersion); |
| 319 pair_devices.mutable_parameters()->set_admin_access_token( | 324 pair_devices.mutable_parameters()->set_admin_access_token(auth_token); |
| 320 kFakeEnrollmentDomain); | |
| 321 | 325 |
| 322 int size = 0; | 326 int size = 0; |
| 323 scoped_refptr<net::IOBuffer> io_buffer( | 327 scoped_refptr<net::IOBuffer> io_buffer( |
| 324 ProtoDecoder::SendPairDevices(pair_devices, &size)); | 328 ProtoDecoder::SendPairDevices(pair_devices, &size)); |
| 325 | 329 |
| 326 socket_->Send( | 330 socket_->Send( |
| 327 io_buffer, size, | 331 io_buffer, size, |
| 328 base::Bind(&BluetoothControllerPairingController::OnSendComplete, | 332 base::Bind(&BluetoothControllerPairingController::OnSendComplete, |
| 329 ptr_factory_.GetWeakPtr()), | 333 ptr_factory_.GetWeakPtr()), |
| 330 base::Bind(&BluetoothControllerPairingController::OnErrorWithMessage, | 334 base::Bind(&BluetoothControllerPairingController::OnErrorWithMessage, |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 454 ChangeStage(STAGE_WAITING_FOR_CODE_CONFIRMATION); | 458 ChangeStage(STAGE_WAITING_FOR_CODE_CONFIRMATION); |
| 455 } | 459 } |
| 456 | 460 |
| 457 void BluetoothControllerPairingController::AuthorizePairing( | 461 void BluetoothControllerPairingController::AuthorizePairing( |
| 458 device::BluetoothDevice* device) { | 462 device::BluetoothDevice* device) { |
| 459 // Disallow unknown device. | 463 // Disallow unknown device. |
| 460 device->RejectPairing(); | 464 device->RejectPairing(); |
| 461 } | 465 } |
| 462 | 466 |
| 463 } // namespace pairing_chromeos | 467 } // namespace pairing_chromeos |
| OLD | NEW |