| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chromeos/network/network_connect.h" | 5 #include "chromeos/network/network_connect.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 if (enabled_state == enabled) { | 428 if (enabled_state == enabled) { |
| 429 NET_LOG_USER("Technology already in target state.", log_string); | 429 NET_LOG_USER("Technology already in target state.", log_string); |
| 430 return; | 430 return; |
| 431 } | 431 } |
| 432 if (enabled) { | 432 if (enabled) { |
| 433 // User requested to disable the technology. | 433 // User requested to disable the technology. |
| 434 handler->SetTechnologyEnabled(technology, false, | 434 handler->SetTechnologyEnabled(technology, false, |
| 435 network_handler::ErrorCallback()); | 435 network_handler::ErrorCallback()); |
| 436 return; | 436 return; |
| 437 } | 437 } |
| 438 // If we're dealing with a mobile network, then handle SIM lock here. | 438 // If we're dealing with a cellular network, then handle SIM lock here. |
| 439 // SIM locking only applies to cellular, so the code below won't execute | 439 // SIM locking only applies to cellular. |
| 440 // if |technology| has been explicitly set to WiMAX. | 440 if (technology.MatchesPattern(NetworkTypePattern::Cellular())) { |
| 441 if (technology.MatchesPattern(NetworkTypePattern::Mobile())) { | |
| 442 const DeviceState* mobile = handler->GetDeviceStateByType(technology); | 441 const DeviceState* mobile = handler->GetDeviceStateByType(technology); |
| 443 if (!mobile) { | 442 if (!mobile) { |
| 444 NET_LOG_ERROR("SetTechnologyEnabled with no device", log_string); | 443 NET_LOG_ERROR("SetTechnologyEnabled with no device", log_string); |
| 445 return; | 444 return; |
| 446 } | 445 } |
| 447 // The following only applies to cellular. | 446 if (mobile->IsSimAbsent()) { |
| 448 if (mobile->type() == shill::kTypeCellular) { | 447 // If this is true, then we have a cellular device with no SIM |
| 449 if (mobile->IsSimAbsent()) { | 448 // inserted. TODO(armansito): Chrome should display a notification here, |
| 450 // If this is true, then we have a cellular device with no SIM | 449 // prompting the user to insert a SIM card and restart the device to |
| 451 // inserted. TODO(armansito): Chrome should display a notification here, | 450 // enable cellular. See crbug.com/125171. |
| 452 // prompting the user to insert a SIM card and restart the device to | 451 NET_LOG_USER("Cannot enable cellular device without SIM.", log_string); |
| 453 // enable cellular. See crbug.com/125171. | 452 return; |
| 454 NET_LOG_USER("Cannot enable cellular device without SIM.", log_string); | 453 } |
| 455 return; | 454 if (!mobile->sim_lock_type().empty()) { |
| 456 } | 455 // A SIM has been inserted, but it is locked. Let the user unlock it |
| 457 if (!mobile->sim_lock_type().empty()) { | 456 // via the dialog. |
| 458 // A SIM has been inserted, but it is locked. Let the user unlock it | 457 delegate_->ShowMobileSimDialog(); |
| 459 // via the dialog. | 458 return; |
| 460 delegate_->ShowMobileSimDialog(); | |
| 461 return; | |
| 462 } | |
| 463 } | 459 } |
| 464 } | 460 } |
| 465 handler->SetTechnologyEnabled(technology, true, | 461 handler->SetTechnologyEnabled(technology, true, |
| 466 network_handler::ErrorCallback()); | 462 network_handler::ErrorCallback()); |
| 467 } | 463 } |
| 468 | 464 |
| 469 void NetworkConnectImpl::ActivateCellular(const std::string& network_id) { | 465 void NetworkConnectImpl::ActivateCellular(const std::string& network_id) { |
| 470 NET_LOG_USER("ActivateCellular", network_id); | 466 NET_LOG_USER("ActivateCellular", network_id); |
| 471 const NetworkState* cellular = GetNetworkStateFromId(network_id); | 467 const NetworkState* cellular = GetNetworkStateFromId(network_id); |
| 472 if (!cellular || cellular->type() != shill::kTypeCellular) { | 468 if (!cellular || cellular->type() != shill::kTypeCellular) { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 NetworkConnect* NetworkConnect::Get() { | 577 NetworkConnect* NetworkConnect::Get() { |
| 582 CHECK(g_network_connect); | 578 CHECK(g_network_connect); |
| 583 return g_network_connect; | 579 return g_network_connect; |
| 584 } | 580 } |
| 585 | 581 |
| 586 NetworkConnect::NetworkConnect() {} | 582 NetworkConnect::NetworkConnect() {} |
| 587 | 583 |
| 588 NetworkConnect::~NetworkConnect() {} | 584 NetworkConnect::~NetworkConnect() {} |
| 589 | 585 |
| 590 } // namespace chromeos | 586 } // namespace chromeos |
| OLD | NEW |