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

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

Issue 1829453002: Enable bootstrapping feature by default. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CL format Created 4 years, 8 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
« no previous file with comments | « components/pairing/bluetooth_host_pairing_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 BluetoothHostPairingController::BluetoothHostPairingController() 93 BluetoothHostPairingController::BluetoothHostPairingController()
94 : current_stage_(STAGE_NONE), 94 : current_stage_(STAGE_NONE),
95 connectivity_status_(CONNECTIVITY_UNTESTED), 95 connectivity_status_(CONNECTIVITY_UNTESTED),
96 update_status_(UPDATE_STATUS_UNKNOWN), 96 update_status_(UPDATE_STATUS_UNKNOWN),
97 enrollment_status_(ENROLLMENT_STATUS_UNKNOWN), 97 enrollment_status_(ENROLLMENT_STATUS_UNKNOWN),
98 proto_decoder_(new ProtoDecoder(this)), 98 proto_decoder_(new ProtoDecoder(this)),
99 ptr_factory_(this) {} 99 ptr_factory_(this) {}
100 100
101 BluetoothHostPairingController::~BluetoothHostPairingController() { 101 BluetoothHostPairingController::~BluetoothHostPairingController() {
102 Reset(); 102 Reset();
103 if (adapter_.get()) {
104 if (adapter_->IsDiscoverable()) {
105 adapter_->SetDiscoverable(false, base::Closure(), base::Closure());
106 }
107 adapter_->RemoveObserver(this);
108 adapter_ = NULL;
109 }
110 } 103 }
111 104
112 void BluetoothHostPairingController::ChangeStage(Stage new_stage) { 105 void BluetoothHostPairingController::ChangeStage(Stage new_stage) {
113 if (current_stage_ == new_stage) 106 if (current_stage_ == new_stage)
114 return; 107 return;
115 VLOG(1) << "ChangeStage " << new_stage; 108 VLOG(1) << "ChangeStage " << new_stage;
116 current_stage_ = new_stage; 109 current_stage_ = new_stage;
117 FOR_EACH_OBSERVER(Observer, observers_, PairingStageChanged(new_stage)); 110 FOR_EACH_OBSERVER(Observer, observers_, PairingStageChanged(new_stage));
118 } 111 }
119 112
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 void BluetoothHostPairingController::Reset() { 145 void BluetoothHostPairingController::Reset() {
153 if (controller_socket_.get()) { 146 if (controller_socket_.get()) {
154 controller_socket_->Close(); 147 controller_socket_->Close();
155 controller_socket_ = NULL; 148 controller_socket_ = NULL;
156 } 149 }
157 150
158 if (service_socket_.get()) { 151 if (service_socket_.get()) {
159 service_socket_->Close(); 152 service_socket_->Close();
160 service_socket_ = NULL; 153 service_socket_ = NULL;
161 } 154 }
155
156 if (adapter_.get()) {
157 if (adapter_->IsDiscoverable()) {
158 adapter_->SetDiscoverable(false, base::Bind(&base::DoNothing),
159 base::Bind(&base::DoNothing));
160 }
161 if (!was_powered_) {
162 adapter_->SetPowered(false, base::Bind(&base::DoNothing),
163 base::Bind(&base::DoNothing));
164 }
165 adapter_->RemoveObserver(this);
166 adapter_ = NULL;
167 }
162 ChangeStage(STAGE_NONE); 168 ChangeStage(STAGE_NONE);
163 } 169 }
164 170
165 void BluetoothHostPairingController::OnGetAdapter( 171 void BluetoothHostPairingController::OnGetAdapter(
166 scoped_refptr<device::BluetoothAdapter> adapter) { 172 scoped_refptr<device::BluetoothAdapter> adapter) {
167 DCHECK(thread_checker_.CalledOnValidThread()); 173 DCHECK(thread_checker_.CalledOnValidThread());
168 DCHECK(!adapter_.get()); 174 DCHECK(!adapter_.get());
169 adapter_ = adapter; 175 adapter_ = adapter;
170 176
171 if (adapter_->IsPresent()) { 177 if (adapter_->IsPresent()) {
(...skipping 15 matching lines...) Expand all
187 device_name_, 193 device_name_,
188 base::Bind(&BluetoothHostPairingController::OnSetName, 194 base::Bind(&BluetoothHostPairingController::OnSetName,
189 ptr_factory_.GetWeakPtr()), 195 ptr_factory_.GetWeakPtr()),
190 base::Bind(&BluetoothHostPairingController::OnSetError, 196 base::Bind(&BluetoothHostPairingController::OnSetError,
191 ptr_factory_.GetWeakPtr())); 197 ptr_factory_.GetWeakPtr()));
192 } 198 }
193 199
194 void BluetoothHostPairingController::OnSetName() { 200 void BluetoothHostPairingController::OnSetName() {
195 DCHECK(thread_checker_.CalledOnValidThread()); 201 DCHECK(thread_checker_.CalledOnValidThread());
196 if (adapter_->IsPowered()) { 202 if (adapter_->IsPowered()) {
203 was_powered_ = true;
197 OnSetPowered(); 204 OnSetPowered();
198 } else { 205 } else {
199 adapter_->SetPowered( 206 adapter_->SetPowered(
200 true, 207 true,
201 base::Bind(&BluetoothHostPairingController::OnSetPowered, 208 base::Bind(&BluetoothHostPairingController::OnSetPowered,
202 ptr_factory_.GetWeakPtr()), 209 ptr_factory_.GetWeakPtr()),
203 base::Bind(&BluetoothHostPairingController::OnSetError, 210 base::Bind(&BluetoothHostPairingController::OnSetError,
204 ptr_factory_.GetWeakPtr())); 211 ptr_factory_.GetWeakPtr()));
205 } 212 }
206 } 213 }
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 ChangeStage(STAGE_WAITING_FOR_CODE_CONFIRMATION); 510 ChangeStage(STAGE_WAITING_FOR_CODE_CONFIRMATION);
504 } 511 }
505 512
506 void BluetoothHostPairingController::AuthorizePairing( 513 void BluetoothHostPairingController::AuthorizePairing(
507 device::BluetoothDevice* device) { 514 device::BluetoothDevice* device) {
508 // Disallow unknown device. 515 // Disallow unknown device.
509 device->RejectPairing(); 516 device->RejectPairing();
510 } 517 }
511 518
512 } // namespace pairing_chromeos 519 } // namespace pairing_chromeos
OLDNEW
« no previous file with comments | « components/pairing/bluetooth_host_pairing_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698