Chromium Code Reviews| 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 chromeos::NetworkStateHandler:: | 170 chromeos::NetworkStateHandler:: |
| 171 TechnologyState::TECHNOLOGY_ENABLED) { | 171 TechnologyState::TECHNOLOGY_ENABLED) { |
| 172 is_enabled = true; | 172 is_enabled = true; |
| 173 } else { | 173 } else { |
| 174 is_enabled = was_pref_enabled; | 174 is_enabled = was_pref_enabled; |
| 175 } | 175 } |
| 176 | 176 |
| 177 if (is_enabled != was_pref_enabled) { | 177 if (is_enabled != was_pref_enabled) { |
| 178 profile_->GetPrefs()->SetBoolean(prefs::kInstantTetheringEnabled, | 178 profile_->GetPrefs()->SetBoolean(prefs::kInstantTetheringEnabled, |
| 179 is_enabled); | 179 is_enabled); |
| 180 UpdateTetherTechnologyState(); | |
| 181 } | 180 } |
| 181 UpdateTetherTechnologyState(); | |
| 182 } | 182 } |
| 183 | 183 |
| 184 void TetherService::OnPrefsChanged() { | 184 void TetherService::OnPrefsChanged() { |
| 185 UpdateTetherTechnologyState(); | 185 UpdateTetherTechnologyState(); |
| 186 } | 186 } |
| 187 | 187 |
| 188 bool TetherService::HasSyncedTetherHosts() const { | 188 bool TetherService::HasSyncedTetherHosts() const { |
| 189 return !cryptauth_service_->GetCryptAuthDeviceManager() | 189 return !cryptauth_service_->GetCryptAuthDeviceManager() |
| 190 ->GetTetherHosts() | 190 ->GetTetherHosts() |
| 191 .empty(); | 191 .empty(); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 207 | 207 |
| 208 chromeos::NetworkStateHandler::TechnologyState | 208 chromeos::NetworkStateHandler::TechnologyState |
| 209 TetherService::GetTetherTechnologyState() { | 209 TetherService::GetTetherTechnologyState() { |
| 210 if (shut_down_ || suspended_ || session_manager_client_->IsScreenLocked() || | 210 if (shut_down_ || suspended_ || session_manager_client_->IsScreenLocked() || |
| 211 !HasSyncedTetherHosts()) { | 211 !HasSyncedTetherHosts()) { |
| 212 return chromeos::NetworkStateHandler::TechnologyState:: | 212 return chromeos::NetworkStateHandler::TechnologyState:: |
| 213 TECHNOLOGY_UNAVAILABLE; | 213 TECHNOLOGY_UNAVAILABLE; |
| 214 } else if (!IsAllowedByPolicy()) { | 214 } else if (!IsAllowedByPolicy()) { |
| 215 return chromeos::NetworkStateHandler::TechnologyState:: | 215 return chromeos::NetworkStateHandler::TechnologyState:: |
| 216 TECHNOLOGY_PROHIBITED; | 216 TECHNOLOGY_PROHIBITED; |
| 217 } else if (!IsBluetoothAvailable()) { | 217 } else if (!IsBluetoothAvailable() || IsCellularAvailableButNotEnabled()) { |
|
khorimoto
2017/05/30 22:35:16
nit: Please add an explanation for why tether is l
lesliewatkins
2017/05/31 00:43:27
Done.
Kyle Horimoto
2017/05/31 20:13:59
Not actually done.
lesliewatkins
2017/05/31 22:06:28
Done.
Kyle Horimoto
2017/05/31 22:18:48
Can you move the comment into the if() block? It's
lesliewatkins
2017/06/05 19:41:42
Done.
| |
| 218 // TODO (hansberry): This unfortunately results in a weird UI state for | 218 // TODO (hansberry): This unfortunately results in a weird UI state for |
|
khorimoto
2017/05/30 22:35:16
nit: Does this description still apply the same wa
lesliewatkins
2017/05/31 00:43:27
Done.
Kyle Horimoto
2017/05/31 20:13:59
Please explicitly refer to the code in question:
lesliewatkins
2017/05/31 22:06:28
Done.
Kyle Horimoto
2017/05/31 22:18:48
nit: Please change the wording so that the "When !
lesliewatkins
2017/06/05 19:41:42
Done.
| |
| 219 // Settings where the toggle is clickable but immediately becomes disabled | 219 // Settings where the toggle is clickable but immediately becomes disabled |
| 220 // after enabling it. Possible solution: grey out the toggle and tell the | 220 // after enabling it. Possible solution: grey out the toggle and tell the |
| 221 // user to turn Bluetooth on? | 221 // user to turn Bluetooth on? |
| 222 return chromeos::NetworkStateHandler::TechnologyState:: | 222 return chromeos::NetworkStateHandler::TechnologyState:: |
| 223 TECHNOLOGY_UNINITIALIZED; | 223 TECHNOLOGY_UNINITIALIZED; |
| 224 } else if (!IsEnabledbyPreference()) { | 224 } else if (!IsEnabledbyPreference()) { |
| 225 return chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_AVAILABLE; | 225 return chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_AVAILABLE; |
| 226 } | 226 } |
| 227 | 227 |
| 228 return chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_ENABLED; | 228 return chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_ENABLED; |
| 229 } | 229 } |
| 230 | 230 |
| 231 void TetherService::OnBluetoothAdapterFetched( | 231 void TetherService::OnBluetoothAdapterFetched( |
| 232 scoped_refptr<device::BluetoothAdapter> adapter) { | 232 scoped_refptr<device::BluetoothAdapter> adapter) { |
| 233 adapter_ = adapter; | 233 adapter_ = adapter; |
| 234 adapter_->AddObserver(this); | 234 adapter_->AddObserver(this); |
| 235 UpdateTetherTechnologyState(); | 235 UpdateTetherTechnologyState(); |
| 236 } | 236 } |
| 237 | 237 |
| 238 bool TetherService::IsBluetoothAvailable() const { | 238 bool TetherService::IsBluetoothAvailable() const { |
| 239 return adapter_.get() && adapter_->IsPresent() && adapter_->IsPowered(); | 239 return adapter_.get() && adapter_->IsPresent() && adapter_->IsPowered(); |
| 240 } | 240 } |
| 241 | 241 |
| 242 bool TetherService::IsCellularAvailableButNotEnabled() const { | |
| 243 return (network_state_handler_->IsTechnologyAvailable( | |
| 244 chromeos::NetworkTypePattern::Cellular()) && | |
| 245 !network_state_handler_->IsTechnologyEnabled( | |
| 246 chromeos::NetworkTypePattern::Cellular())); | |
| 247 } | |
| 248 | |
| 242 bool TetherService::IsAllowedByPolicy() const { | 249 bool TetherService::IsAllowedByPolicy() const { |
| 243 return profile_->GetPrefs()->GetBoolean(prefs::kInstantTetheringAllowed); | 250 return profile_->GetPrefs()->GetBoolean(prefs::kInstantTetheringAllowed); |
| 244 } | 251 } |
| 245 | 252 |
| 246 bool TetherService::IsEnabledbyPreference() const { | 253 bool TetherService::IsEnabledbyPreference() const { |
| 247 return profile_->GetPrefs()->GetBoolean(prefs::kInstantTetheringEnabled); | 254 return profile_->GetPrefs()->GetBoolean(prefs::kInstantTetheringEnabled); |
| 248 } | 255 } |
| OLD | NEW |