| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/webui/options/chromeos/internet_options_handler.h" | 5 #include "chrome/browser/ui/webui/options/chromeos/internet_options_handler.h" |
| 6 | 6 |
| 7 #include <ctype.h> | 7 #include <ctype.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 | 543 |
| 544 if (network->type() != chromeos::TYPE_CELLULAR) | 544 if (network->type() != chromeos::TYPE_CELLULAR) |
| 545 return; | 545 return; |
| 546 | 546 |
| 547 chromeos::CellularNetwork* cellular = | 547 chromeos::CellularNetwork* cellular = |
| 548 static_cast<chromeos::CellularNetwork*>(network); | 548 static_cast<chromeos::CellularNetwork*>(network); |
| 549 if (cellular->activation_state() != chromeos::ACTIVATION_STATE_ACTIVATED) | 549 if (cellular->activation_state() != chromeos::ACTIVATION_STATE_ACTIVATED) |
| 550 cellular->StartActivation(); | 550 cellular->StartActivation(); |
| 551 } | 551 } |
| 552 | 552 |
| 553 // Check if the current cellular device can be activated by directly calling | |
| 554 // it's activate function instead of going through the activation process. | |
| 555 // Note: Currently Sprint is the only carrier that uses this. | |
| 556 bool UseDirectActivation() { | |
| 557 const chromeos::NetworkDevice* device = | |
| 558 chromeos::CrosLibrary::Get()->GetNetworkLibrary()->FindCellularDevice(); | |
| 559 return device && (device->carrier() == shill::kCarrierSprint); | |
| 560 } | |
| 561 | |
| 562 // Given a list of supported carrier's by the device, return the index of | 553 // Given a list of supported carrier's by the device, return the index of |
| 563 // the carrier the device is currently using. | 554 // the carrier the device is currently using. |
| 564 int FindCurrentCarrierIndex(const base::ListValue* carriers, | 555 int FindCurrentCarrierIndex(const base::ListValue* carriers, |
| 565 const chromeos::NetworkDevice* device) { | 556 const chromeos::NetworkDevice* device) { |
| 566 DCHECK(carriers); | 557 DCHECK(carriers); |
| 567 DCHECK(device); | 558 DCHECK(device); |
| 568 | 559 |
| 569 bool gsm = (device->technology_family() == chromeos::TECHNOLOGY_FAMILY_GSM); | 560 bool gsm = (device->technology_family() == chromeos::TECHNOLOGY_FAMILY_GSM); |
| 570 int index = 0; | 561 int index = 0; |
| 571 for (base::ListValue::const_iterator it = carriers->begin(); | 562 for (base::ListValue::const_iterator it = carriers->begin(); |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 954 if (network) { | 945 if (network) { |
| 955 network->SetApn(chromeos::CellularApn( | 946 network->SetApn(chromeos::CellularApn( |
| 956 apn, network->apn().network_id, username, password)); | 947 apn, network->apn().network_id, username, password)); |
| 957 } | 948 } |
| 958 } | 949 } |
| 959 | 950 |
| 960 void InternetOptionsHandler::CarrierStatusCallback( | 951 void InternetOptionsHandler::CarrierStatusCallback( |
| 961 const std::string& service_path, | 952 const std::string& service_path, |
| 962 chromeos::NetworkMethodErrorType error, | 953 chromeos::NetworkMethodErrorType error, |
| 963 const std::string& error_message) { | 954 const std::string& error_message) { |
| 964 if ((error == chromeos::NETWORK_METHOD_ERROR_NONE) && | 955 if ((error == chromeos::NETWORK_METHOD_ERROR_NONE)) { |
| 965 UseDirectActivation()) { | 956 chromeos::CellularNetwork* network = |
| 966 Activate(service_path); | 957 cros_->FindCellularNetworkByPath(service_path); |
| 967 UpdateConnectionData(cros_->FindNetworkByPath(service_path)); | 958 if (network && network->UsesDirectActivation()) { |
| 959 Activate(service_path); |
| 960 UpdateConnectionData(network); |
| 961 } |
| 968 } | 962 } |
| 969 | 963 |
| 970 UpdateCarrier(); | 964 UpdateCarrier(); |
| 971 } | 965 } |
| 972 | 966 |
| 973 | 967 |
| 974 void InternetOptionsHandler::SetCarrierCallback(const ListValue* args) { | 968 void InternetOptionsHandler::SetCarrierCallback(const ListValue* args) { |
| 975 std::string service_path; | 969 std::string service_path; |
| 976 std::string carrier; | 970 std::string carrier; |
| 977 if (args->GetSize() != 2 || | 971 if (args->GetSize() != 2 || |
| (...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1647 if (command == kTagOptions) { | 1641 if (command == kTagOptions) { |
| 1648 cros_->RequestNetworkServiceProperties( | 1642 cros_->RequestNetworkServiceProperties( |
| 1649 service_path, | 1643 service_path, |
| 1650 base::Bind(&InternetOptionsHandler::PopulateDictionaryDetailsCallback, | 1644 base::Bind(&InternetOptionsHandler::PopulateDictionaryDetailsCallback, |
| 1651 weak_factory_.GetWeakPtr())); | 1645 weak_factory_.GetWeakPtr())); |
| 1652 } else if (command == kTagConnect) { | 1646 } else if (command == kTagConnect) { |
| 1653 ConnectToNetwork(network); | 1647 ConnectToNetwork(network); |
| 1654 } else if (command == kTagDisconnect && type != chromeos::TYPE_ETHERNET) { | 1648 } else if (command == kTagDisconnect && type != chromeos::TYPE_ETHERNET) { |
| 1655 cros_->DisconnectFromNetwork(network); | 1649 cros_->DisconnectFromNetwork(network); |
| 1656 } else if (command == kTagActivate && type == chromeos::TYPE_CELLULAR) { | 1650 } else if (command == kTagActivate && type == chromeos::TYPE_CELLULAR) { |
| 1657 if (!UseDirectActivation()) { | 1651 chromeos::CellularNetwork* cellular = |
| 1652 static_cast<chromeos::CellularNetwork*>(network); |
| 1653 if (!cellular->UsesDirectActivation()) { |
| 1658 ash::Shell::GetInstance()->delegate()->OpenMobileSetup( | 1654 ash::Shell::GetInstance()->delegate()->OpenMobileSetup( |
| 1659 network->service_path()); | 1655 cellular->service_path()); |
| 1660 } else { | 1656 } else { |
| 1661 Activate(service_path); | 1657 Activate(service_path); |
| 1662 // Update network properties after we start activation. The Activate | 1658 // Update network properties after we start activation. The Activate |
| 1663 // call is a blocking call, which blocks on finishing the "start" of | 1659 // call is a blocking call, which blocks on finishing the "start" of |
| 1664 // the activation, hence when we query for network properties after | 1660 // the activation, hence when we query for network properties after |
| 1665 // this call is done, we will have the "activating" activation state. | 1661 // this call is done, we will have the "activating" activation state. |
| 1666 UpdateConnectionData(network); | 1662 UpdateConnectionData(cellular); |
| 1667 } | 1663 } |
| 1668 } else { | 1664 } else { |
| 1669 VLOG(1) << "Unknown command: " << command; | 1665 VLOG(1) << "Unknown command: " << command; |
| 1670 NOTREACHED(); | 1666 NOTREACHED(); |
| 1671 } | 1667 } |
| 1672 } | 1668 } |
| 1673 | 1669 |
| 1674 void InternetOptionsHandler::ToggleAirplaneModeCallback(const ListValue* args) { | 1670 void InternetOptionsHandler::ToggleAirplaneModeCallback(const ListValue* args) { |
| 1675 // TODO(kevers): The use of 'offline_mode' is not quite correct. Update once | 1671 // TODO(kevers): The use of 'offline_mode' is not quite correct. Update once |
| 1676 // we have proper back-end support. | 1672 // we have proper back-end support. |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1861 | 1857 |
| 1862 dictionary->SetBoolean(kTagWimaxEnabled, cros_->wimax_enabled()); | 1858 dictionary->SetBoolean(kTagWimaxEnabled, cros_->wimax_enabled()); |
| 1863 dictionary->SetBoolean(kTagWimaxAvailable, cros_->wimax_available()); | 1859 dictionary->SetBoolean(kTagWimaxAvailable, cros_->wimax_available()); |
| 1864 dictionary->SetBoolean(kTagWimaxBusy, cros_->wimax_busy()); | 1860 dictionary->SetBoolean(kTagWimaxBusy, cros_->wimax_busy()); |
| 1865 // TODO(kevers): The use of 'offline_mode' is not quite correct. Update once | 1861 // TODO(kevers): The use of 'offline_mode' is not quite correct. Update once |
| 1866 // we have proper back-end support. | 1862 // we have proper back-end support. |
| 1867 dictionary->SetBoolean(kTagAirplaneMode, cros_->offline_mode()); | 1863 dictionary->SetBoolean(kTagAirplaneMode, cros_->offline_mode()); |
| 1868 } | 1864 } |
| 1869 | 1865 |
| 1870 } // namespace options | 1866 } // namespace options |
| OLD | NEW |