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

Side by Side Diff: components/pairing/bluetooth_host_pairing_controller.cc

Issue 1551433002: Switch to standard integer types in components/, part 3 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more Created 4 years, 12 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
OLDNEW
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_host_pairing_controller.h" 5 #include "components/pairing/bluetooth_host_pairing_controller.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/hash.h" 8 #include "base/hash.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 SetName(); 180 SetName();
181 } else { 181 } else {
182 // Set the name once the adapter is present. 182 // Set the name once the adapter is present.
183 adapter_->AddObserver(this); 183 adapter_->AddObserver(this);
184 } 184 }
185 } 185 }
186 186
187 void BluetoothHostPairingController::SetName() { 187 void BluetoothHostPairingController::SetName() {
188 // Hash the bluetooth address and take the lower 2 bytes to create a human 188 // Hash the bluetooth address and take the lower 2 bytes to create a human
189 // readable device name. 189 // readable device name.
190 const uint32 device_id = base::Hash(adapter_->GetAddress()) & 0xFFFF; 190 const uint32_t device_id = base::Hash(adapter_->GetAddress()) & 0xFFFF;
191 device_name_ = base::StringPrintf("%s%04X", kDeviceNamePrefix, device_id); 191 device_name_ = base::StringPrintf("%s%04X", kDeviceNamePrefix, device_id);
192 192
193 adapter_->SetName( 193 adapter_->SetName(
194 device_name_, 194 device_name_,
195 base::Bind(&BluetoothHostPairingController::OnSetName, 195 base::Bind(&BluetoothHostPairingController::OnSetName,
196 ptr_factory_.GetWeakPtr()), 196 ptr_factory_.GetWeakPtr()),
197 base::Bind(&BluetoothHostPairingController::OnSetError, 197 base::Bind(&BluetoothHostPairingController::OnSetError,
198 ptr_factory_.GetWeakPtr())); 198 ptr_factory_.GetWeakPtr()));
199 } 199 }
200 200
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 479
480 void BluetoothHostPairingController::DisplayPinCode( 480 void BluetoothHostPairingController::DisplayPinCode(
481 device::BluetoothDevice* device, 481 device::BluetoothDevice* device,
482 const std::string& pincode) { 482 const std::string& pincode) {
483 // Disallow unknown device. 483 // Disallow unknown device.
484 device->RejectPairing(); 484 device->RejectPairing();
485 } 485 }
486 486
487 void BluetoothHostPairingController::DisplayPasskey( 487 void BluetoothHostPairingController::DisplayPasskey(
488 device::BluetoothDevice* device, 488 device::BluetoothDevice* device,
489 uint32 passkey) { 489 uint32_t passkey) {
490 // Disallow unknown device. 490 // Disallow unknown device.
491 device->RejectPairing(); 491 device->RejectPairing();
492 } 492 }
493 493
494 void BluetoothHostPairingController::KeysEntered( 494 void BluetoothHostPairingController::KeysEntered(
495 device::BluetoothDevice* device, 495 device::BluetoothDevice* device,
496 uint32 entered) { 496 uint32_t entered) {
497 // Disallow unknown device. 497 // Disallow unknown device.
498 device->RejectPairing(); 498 device->RejectPairing();
499 } 499 }
500 500
501 void BluetoothHostPairingController::ConfirmPasskey( 501 void BluetoothHostPairingController::ConfirmPasskey(
502 device::BluetoothDevice* device, 502 device::BluetoothDevice* device,
503 uint32 passkey) { 503 uint32_t passkey) {
504 // If a new connection is occurring, reset the stage. This can occur if the 504 // If a new connection is occurring, reset the stage. This can occur if the
505 // pairing times out, or a new controller connects. 505 // pairing times out, or a new controller connects.
506 if (current_stage_ == STAGE_WAITING_FOR_CODE_CONFIRMATION) 506 if (current_stage_ == STAGE_WAITING_FOR_CODE_CONFIRMATION)
507 ChangeStage(STAGE_WAITING_FOR_CONTROLLER); 507 ChangeStage(STAGE_WAITING_FOR_CONTROLLER);
508 508
509 confirmation_code_ = base::StringPrintf("%06d", passkey); 509 confirmation_code_ = base::StringPrintf("%06d", passkey);
510 device->ConfirmPairing(); 510 device->ConfirmPairing();
511 ChangeStage(STAGE_WAITING_FOR_CODE_CONFIRMATION); 511 ChangeStage(STAGE_WAITING_FOR_CODE_CONFIRMATION);
512 } 512 }
513 513
514 void BluetoothHostPairingController::AuthorizePairing( 514 void BluetoothHostPairingController::AuthorizePairing(
515 device::BluetoothDevice* device) { 515 device::BluetoothDevice* device) {
516 // Disallow unknown device. 516 // Disallow unknown device.
517 device->RejectPairing(); 517 device->RejectPairing();
518 } 518 }
519 519
520 } // namespace pairing_chromeos 520 } // namespace pairing_chromeos
OLDNEW
« no previous file with comments | « components/pairing/bluetooth_host_pairing_controller.h ('k') | components/pairing/fake_controller_pairing_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698