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

Side by Side Diff: chrome/browser/chromeos/tether/tether_service.cc

Issue 2883283004: Merged Tether and cellular network types in System Tray. (Closed)
Patch Set: Merged Tether and cellular network types in System Tray. Created 3 years, 7 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 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 192
193 chromeos::NetworkStateHandler::TechnologyState 193 chromeos::NetworkStateHandler::TechnologyState
194 TetherService::GetTetherTechnologyState() { 194 TetherService::GetTetherTechnologyState() {
195 if (shut_down_ || suspended_ || session_manager_client_->IsScreenLocked() || 195 if (shut_down_ || suspended_ || session_manager_client_->IsScreenLocked() ||
196 !IsFeatureFlagEnabled() || !HasSyncedTetherHosts()) { 196 !IsFeatureFlagEnabled() || !HasSyncedTetherHosts()) {
197 return chromeos::NetworkStateHandler::TechnologyState:: 197 return chromeos::NetworkStateHandler::TechnologyState::
198 TECHNOLOGY_UNAVAILABLE; 198 TECHNOLOGY_UNAVAILABLE;
199 } else if (!IsAllowedByPolicy()) { 199 } else if (!IsAllowedByPolicy()) {
200 return chromeos::NetworkStateHandler::TechnologyState:: 200 return chromeos::NetworkStateHandler::TechnologyState::
201 TECHNOLOGY_PROHIBITED; 201 TECHNOLOGY_PROHIBITED;
202 } else if (!IsBluetoothAvailable()) { 202 } else if (!IsBluetoothAvailable() || IsCellularAvailableButNotEnabled()) {
203 // TODO (hansberry): This unfortunately results in a weird UI state for 203 // TODO (hansberry): This unfortunately results in a weird UI state for
204 // Settings where the toggle is clickable but immediately becomes disabled 204 // Settings where the toggle is clickable but immediately becomes disabled
205 // after enabling it. Possible solution: grey out the toggle and tell the 205 // after enabling it. Possible solution: grey out the toggle and tell the
206 // user to turn Bluetooth on? 206 // user to turn Bluetooth on?
207 return chromeos::NetworkStateHandler::TechnologyState:: 207 return chromeos::NetworkStateHandler::TechnologyState::
208 TECHNOLOGY_UNINITIALIZED; 208 TECHNOLOGY_UNINITIALIZED;
209 } else if (!IsEnabledbyPreference()) { 209 } else if (!IsEnabledbyPreference()) {
210 return chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_AVAILABLE; 210 return chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_AVAILABLE;
211 } 211 }
212 212
(...skipping 15 matching lines...) Expand all
228 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::IsCellularAvailableButNotEnabled() const {
239 return (network_state_handler_->IsTechnologyAvailable(
240 chromeos::NetworkTypePattern::Cellular()) &&
241 !network_state_handler_->IsTechnologyEnabled(
242 chromeos::NetworkTypePattern::Cellular()));
243 }
244
238 bool TetherService::IsAllowedByPolicy() const { 245 bool TetherService::IsAllowedByPolicy() const {
239 return profile_->GetPrefs()->GetBoolean(prefs::kInstantTetheringAllowed); 246 return profile_->GetPrefs()->GetBoolean(prefs::kInstantTetheringAllowed);
240 } 247 }
241 248
242 bool TetherService::IsEnabledbyPreference() const { 249 bool TetherService::IsEnabledbyPreference() const {
243 return profile_->GetPrefs()->GetBoolean(prefs::kInstantTetheringEnabled); 250 return profile_->GetPrefs()->GetBoolean(prefs::kInstantTetheringEnabled);
244 } 251 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698