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 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 | 544 |
545 if (network->type() != chromeos::TYPE_CELLULAR) | 545 if (network->type() != chromeos::TYPE_CELLULAR) |
546 return; | 546 return; |
547 | 547 |
548 chromeos::CellularNetwork* cellular = | 548 chromeos::CellularNetwork* cellular = |
549 static_cast<chromeos::CellularNetwork*>(network); | 549 static_cast<chromeos::CellularNetwork*>(network); |
550 if (cellular->activation_state() != chromeos::ACTIVATION_STATE_ACTIVATED) | 550 if (cellular->activation_state() != chromeos::ACTIVATION_STATE_ACTIVATED) |
551 cellular->StartActivation(); | 551 cellular->StartActivation(); |
552 } | 552 } |
553 | 553 |
554 // Check if the current cellular device can be activated by directly calling | |
555 // it's activate function instead of going through the activation process. | |
556 // Note: Currently Sprint is the only carrier that uses this. | |
557 bool UseDirectActivation() { | |
558 const chromeos::NetworkDevice* device = | |
559 chromeos::CrosLibrary::Get()->GetNetworkLibrary()->FindCellularDevice(); | |
560 return device && (device->carrier() == shill::kCarrierSprint); | |
561 } | |
562 | |
563 // Given a list of supported carrier's by the device, return the index of | 554 // Given a list of supported carrier's by the device, return the index of |
564 // the carrier the device is currently using. | 555 // the carrier the device is currently using. |
565 int FindCurrentCarrierIndex(const base::ListValue* carriers, | 556 int FindCurrentCarrierIndex(const base::ListValue* carriers, |
566 const chromeos::NetworkDevice* device) { | 557 const chromeos::NetworkDevice* device) { |
567 DCHECK(carriers); | 558 DCHECK(carriers); |
568 DCHECK(device); | 559 DCHECK(device); |
569 | 560 |
570 bool gsm = (device->technology_family() == chromeos::TECHNOLOGY_FAMILY_GSM); | 561 bool gsm = (device->technology_family() == chromeos::TECHNOLOGY_FAMILY_GSM); |
571 int index = 0; | 562 int index = 0; |
572 for (base::ListValue::const_iterator it = carriers->begin(); | 563 for (base::ListValue::const_iterator it = carriers->begin(); |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 network->SetApn(chromeos::CellularApn( | 961 network->SetApn(chromeos::CellularApn( |
971 apn, network->apn().network_id, username, password)); | 962 apn, network->apn().network_id, username, password)); |
972 } | 963 } |
973 } | 964 } |
974 | 965 |
975 void InternetOptionsHandler::CarrierStatusCallback( | 966 void InternetOptionsHandler::CarrierStatusCallback( |
976 const std::string& service_path, | 967 const std::string& service_path, |
977 chromeos::NetworkMethodErrorType error, | 968 chromeos::NetworkMethodErrorType error, |
978 const std::string& error_message) { | 969 const std::string& error_message) { |
979 if ((error == chromeos::NETWORK_METHOD_ERROR_NONE) && | 970 if ((error == chromeos::NETWORK_METHOD_ERROR_NONE) && |
980 UseDirectActivation()) { | 971 cros_->CellularDeviceUsesDirectActivation()) { |
981 Activate(service_path); | 972 Activate(service_path); |
982 UpdateConnectionData(cros_->FindNetworkByPath(service_path)); | 973 UpdateConnectionData(cros_->FindNetworkByPath(service_path)); |
983 } | 974 } |
984 | 975 |
985 UpdateCarrier(); | 976 UpdateCarrier(); |
986 } | 977 } |
987 | 978 |
988 | 979 |
989 void InternetOptionsHandler::SetCarrierCallback(const ListValue* args) { | 980 void InternetOptionsHandler::SetCarrierCallback(const ListValue* args) { |
990 std::string service_path; | 981 std::string service_path; |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1666 if (command == kTagOptions) { | 1657 if (command == kTagOptions) { |
1667 cros_->RequestNetworkServiceProperties( | 1658 cros_->RequestNetworkServiceProperties( |
1668 service_path, | 1659 service_path, |
1669 base::Bind(&InternetOptionsHandler::PopulateDictionaryDetailsCallback, | 1660 base::Bind(&InternetOptionsHandler::PopulateDictionaryDetailsCallback, |
1670 weak_factory_.GetWeakPtr())); | 1661 weak_factory_.GetWeakPtr())); |
1671 } else if (command == kTagConnect) { | 1662 } else if (command == kTagConnect) { |
1672 ConnectToNetwork(network); | 1663 ConnectToNetwork(network); |
1673 } else if (command == kTagDisconnect && type != chromeos::TYPE_ETHERNET) { | 1664 } else if (command == kTagDisconnect && type != chromeos::TYPE_ETHERNET) { |
1674 cros_->DisconnectFromNetwork(network); | 1665 cros_->DisconnectFromNetwork(network); |
1675 } else if (command == kTagActivate && type == chromeos::TYPE_CELLULAR) { | 1666 } else if (command == kTagActivate && type == chromeos::TYPE_CELLULAR) { |
1676 if (!UseDirectActivation()) { | 1667 if (!cros_->CellularDeviceUsesDirectActivation()) { |
1677 ash::Shell::GetInstance()->delegate()->OpenMobileSetup( | 1668 ash::Shell::GetInstance()->delegate()->OpenMobileSetup( |
1678 network->service_path()); | 1669 network->service_path()); |
1679 } else { | 1670 } else { |
1680 Activate(service_path); | 1671 Activate(service_path); |
1681 // Update network properties after we start activation. The Activate | 1672 // Update network properties after we start activation. The Activate |
1682 // call is a blocking call, which blocks on finishing the "start" of | 1673 // call is a blocking call, which blocks on finishing the "start" of |
1683 // the activation, hence when we query for network properties after | 1674 // the activation, hence when we query for network properties after |
1684 // this call is done, we will have the "activating" activation state. | 1675 // this call is done, we will have the "activating" activation state. |
1685 UpdateConnectionData(network); | 1676 UpdateConnectionData(network); |
1686 } | 1677 } |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1880 | 1871 |
1881 dictionary->SetBoolean(kTagWimaxEnabled, cros_->wimax_enabled()); | 1872 dictionary->SetBoolean(kTagWimaxEnabled, cros_->wimax_enabled()); |
1882 dictionary->SetBoolean(kTagWimaxAvailable, cros_->wimax_available()); | 1873 dictionary->SetBoolean(kTagWimaxAvailable, cros_->wimax_available()); |
1883 dictionary->SetBoolean(kTagWimaxBusy, cros_->wimax_busy()); | 1874 dictionary->SetBoolean(kTagWimaxBusy, cros_->wimax_busy()); |
1884 // TODO(kevers): The use of 'offline_mode' is not quite correct. Update once | 1875 // TODO(kevers): The use of 'offline_mode' is not quite correct. Update once |
1885 // we have proper back-end support. | 1876 // we have proper back-end support. |
1886 dictionary->SetBoolean(kTagAirplaneMode, cros_->offline_mode()); | 1877 dictionary->SetBoolean(kTagAirplaneMode, cros_->offline_mode()); |
1887 } | 1878 } |
1888 | 1879 |
1889 } // namespace options | 1880 } // namespace options |
OLD | NEW |