OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/chromeos/tether/tether_service.h" | 5 #include "chrome/browser/chromeos/tether/tether_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 profile_->GetPrefs()->SetBoolean(prefs::kInstantTetheringEnabled, | 169 profile_->GetPrefs()->SetBoolean(prefs::kInstantTetheringEnabled, |
170 is_enabled); | 170 is_enabled); |
171 UpdateTetherTechnologyState(); | 171 UpdateTetherTechnologyState(); |
172 } | 172 } |
173 } | 173 } |
174 | 174 |
175 void TetherService::OnPrefsChanged() { | 175 void TetherService::OnPrefsChanged() { |
176 UpdateTetherTechnologyState(); | 176 UpdateTetherTechnologyState(); |
177 } | 177 } |
178 | 178 |
| 179 bool TetherService::HasSyncedTetherHosts() const { |
| 180 return !cryptauth_service_->GetCryptAuthDeviceManager() |
| 181 ->GetTetherHosts() |
| 182 .empty(); |
| 183 } |
| 184 |
179 void TetherService::UpdateTetherTechnologyState() { | 185 void TetherService::UpdateTetherTechnologyState() { |
180 chromeos::NetworkStateHandler::TechnologyState tether_technology_state = | 186 chromeos::NetworkStateHandler::TechnologyState tether_technology_state = |
181 GetTetherTechnologyState(); | 187 GetTetherTechnologyState(); |
182 | 188 |
183 network_state_handler_->SetTetherTechnologyState(tether_technology_state); | 189 network_state_handler_->SetTetherTechnologyState(tether_technology_state); |
184 | 190 |
185 if (tether_technology_state == | 191 if (tether_technology_state == |
186 chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_ENABLED) { | 192 chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_ENABLED) { |
187 StartTetherIfEnabled(); | 193 StartTetherIfEnabled(); |
188 } else { | 194 } else { |
(...skipping 24 matching lines...) Expand all Loading... |
213 return chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_ENABLED; | 219 return chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_ENABLED; |
214 } | 220 } |
215 | 221 |
216 void TetherService::OnBluetoothAdapterFetched( | 222 void TetherService::OnBluetoothAdapterFetched( |
217 scoped_refptr<device::BluetoothAdapter> adapter) { | 223 scoped_refptr<device::BluetoothAdapter> adapter) { |
218 adapter_ = adapter; | 224 adapter_ = adapter; |
219 adapter_->AddObserver(this); | 225 adapter_->AddObserver(this); |
220 UpdateTetherTechnologyState(); | 226 UpdateTetherTechnologyState(); |
221 } | 227 } |
222 | 228 |
223 bool TetherService::HasSyncedTetherHosts() const { | |
224 return !cryptauth_service_->GetCryptAuthDeviceManager() | |
225 ->GetTetherHosts() | |
226 .empty(); | |
227 } | |
228 | |
229 bool TetherService::IsFeatureFlagEnabled() const { | 229 bool TetherService::IsFeatureFlagEnabled() const { |
230 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 230 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
231 chromeos::switches::kEnableTether); | 231 chromeos::switches::kEnableTether); |
232 } | 232 } |
233 | 233 |
234 bool TetherService::IsBluetoothAvailable() const { | 234 bool TetherService::IsBluetoothAvailable() const { |
235 return adapter_.get() && adapter_->IsPresent() && adapter_->IsPowered(); | 235 return adapter_.get() && adapter_->IsPresent() && adapter_->IsPowered(); |
236 } | 236 } |
237 | 237 |
238 bool TetherService::IsAllowedByPolicy() const { | 238 bool TetherService::IsAllowedByPolicy() const { |
239 return profile_->GetPrefs()->GetBoolean(prefs::kInstantTetheringAllowed); | 239 return profile_->GetPrefs()->GetBoolean(prefs::kInstantTetheringAllowed); |
240 } | 240 } |
241 | 241 |
242 bool TetherService::IsEnabledbyPreference() const { | 242 bool TetherService::IsEnabledbyPreference() const { |
243 return profile_->GetPrefs()->GetBoolean(prefs::kInstantTetheringEnabled); | 243 return profile_->GetPrefs()->GetBoolean(prefs::kInstantTetheringEnabled); |
244 } | 244 } |
OLD | NEW |