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 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 hostname_ui_data.ParseOncProperty( | 526 hostname_ui_data.ParseOncProperty( |
527 vpn->ui_data().onc_source(), &onc, | 527 vpn->ui_data().onc_source(), &onc, |
528 base::StringPrintf("%s.%s", | 528 base::StringPrintf("%s.%s", |
529 chromeos::onc::network_config::kVPN, | 529 chromeos::onc::network_config::kVPN, |
530 chromeos::onc::vpn::kHost)); | 530 chromeos::onc::vpn::kHost)); |
531 SetValueDictionary(dictionary, kTagServerHostname, | 531 SetValueDictionary(dictionary, kTagServerHostname, |
532 new base::StringValue(vpn->server_hostname()), | 532 new base::StringValue(vpn->server_hostname()), |
533 hostname_ui_data); | 533 hostname_ui_data); |
534 } | 534 } |
535 | 535 |
536 // Activate the cellular device pointed to by the service path. | |
537 void Activate(std::string service_path) { | |
538 chromeos::Network* network = NULL; | |
539 if (!service_path.empty()) { | |
540 network = chromeos::CrosLibrary::Get()->GetNetworkLibrary()-> | |
541 FindNetworkByPath(service_path); | |
542 } else { | |
543 NOTREACHED(); | |
544 return; | |
545 } | |
546 | |
547 if (network->type() != chromeos::TYPE_CELLULAR) | |
548 return; | |
549 | |
550 chromeos::CellularNetwork* cellular = | |
551 static_cast<chromeos::CellularNetwork*>(network); | |
552 if (cellular->activation_state() != chromeos::ACTIVATION_STATE_ACTIVATED) | |
553 cellular->StartActivation(); | |
554 } | |
555 | |
556 // Given a list of supported carrier's by the device, return the index of | 536 // Given a list of supported carrier's by the device, return the index of |
557 // the carrier the device is currently using. | 537 // the carrier the device is currently using. |
558 int FindCurrentCarrierIndex(const base::ListValue* carriers, | 538 int FindCurrentCarrierIndex(const base::ListValue* carriers, |
559 const chromeos::NetworkDevice* device) { | 539 const chromeos::NetworkDevice* device) { |
560 DCHECK(carriers); | 540 DCHECK(carriers); |
561 DCHECK(device); | 541 DCHECK(device); |
562 | 542 |
563 bool gsm = (device->technology_family() == chromeos::TECHNOLOGY_FAMILY_GSM); | 543 bool gsm = (device->technology_family() == chromeos::TECHNOLOGY_FAMILY_GSM); |
564 int index = 0; | 544 int index = 0; |
565 for (base::ListValue::const_iterator it = carriers->begin(); | 545 for (base::ListValue::const_iterator it = carriers->begin(); |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 | 896 |
917 void InternetOptionsHandler::ShowMorePlanInfoCallback(const ListValue* args) { | 897 void InternetOptionsHandler::ShowMorePlanInfoCallback(const ListValue* args) { |
918 if (!web_ui()) | 898 if (!web_ui()) |
919 return; | 899 return; |
920 | 900 |
921 std::string service_path; | 901 std::string service_path; |
922 if (args->GetSize() != 1 || !args->GetString(0, &service_path)) { | 902 if (args->GetSize() != 1 || !args->GetString(0, &service_path)) { |
923 NOTREACHED(); | 903 NOTREACHED(); |
924 return; | 904 return; |
925 } | 905 } |
926 | 906 chromeos::network_connect::ShowMobileSetup(service_path); |
927 const chromeos::CellularNetwork* cellular = | |
928 cros_->FindCellularNetworkByPath(service_path); | |
929 if (!cellular) | |
930 return; | |
931 ash::Shell::GetInstance()->delegate()->OpenMobileSetup(service_path); | |
932 } | 907 } |
933 | 908 |
934 void InternetOptionsHandler::BuyDataPlanCallback(const ListValue* args) { | 909 void InternetOptionsHandler::BuyDataPlanCallback(const ListValue* args) { |
935 if (!web_ui()) | 910 if (!web_ui()) |
936 return; | 911 return; |
937 | 912 |
938 std::string service_path; | 913 std::string service_path; |
939 if (args->GetSize() != 1 || !args->GetString(0, &service_path)) { | 914 if (args->GetSize() != 1 || !args->GetString(0, &service_path)) { |
940 NOTREACHED(); | 915 NOTREACHED(); |
941 return; | 916 return; |
942 } | 917 } |
943 ash::Shell::GetInstance()->delegate()->OpenMobileSetup(service_path); | 918 chromeos::network_connect::ShowMobileSetup(service_path); |
944 } | 919 } |
945 | 920 |
946 void InternetOptionsHandler::SetApnCallback(const ListValue* args) { | 921 void InternetOptionsHandler::SetApnCallback(const ListValue* args) { |
947 std::string service_path; | 922 std::string service_path; |
948 std::string apn; | 923 std::string apn; |
949 std::string username; | 924 std::string username; |
950 std::string password; | 925 std::string password; |
951 if (args->GetSize() != 4 || | 926 if (args->GetSize() != 4 || |
952 !args->GetString(0, &service_path) || | 927 !args->GetString(0, &service_path) || |
953 !args->GetString(1, &apn) || | 928 !args->GetString(1, &apn) || |
(...skipping 10 matching lines...) Expand all Loading... |
964 apn, network->apn().network_id, username, password)); | 939 apn, network->apn().network_id, username, password)); |
965 } | 940 } |
966 } | 941 } |
967 | 942 |
968 void InternetOptionsHandler::CarrierStatusCallback( | 943 void InternetOptionsHandler::CarrierStatusCallback( |
969 const std::string& service_path, | 944 const std::string& service_path, |
970 chromeos::NetworkMethodErrorType error, | 945 chromeos::NetworkMethodErrorType error, |
971 const std::string& error_message) { | 946 const std::string& error_message) { |
972 if ((error == chromeos::NETWORK_METHOD_ERROR_NONE) && | 947 if ((error == chromeos::NETWORK_METHOD_ERROR_NONE) && |
973 cros_->CellularDeviceUsesDirectActivation()) { | 948 cros_->CellularDeviceUsesDirectActivation()) { |
974 Activate(service_path); | 949 chromeos::network_connect::ActivateCellular(service_path); |
975 UpdateConnectionData(cros_->FindNetworkByPath(service_path)); | 950 UpdateConnectionData(cros_->FindNetworkByPath(service_path)); |
976 } | 951 } |
977 | 952 |
978 UpdateCarrier(); | 953 UpdateCarrier(); |
979 } | 954 } |
980 | 955 |
981 | 956 |
982 void InternetOptionsHandler::SetCarrierCallback(const ListValue* args) { | 957 void InternetOptionsHandler::SetCarrierCallback(const ListValue* args) { |
983 std::string service_path; | 958 std::string service_path; |
984 std::string carrier; | 959 std::string carrier; |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1660 cros_->RequestNetworkServiceProperties( | 1635 cros_->RequestNetworkServiceProperties( |
1661 service_path, | 1636 service_path, |
1662 base::Bind(&InternetOptionsHandler::PopulateDictionaryDetailsCallback, | 1637 base::Bind(&InternetOptionsHandler::PopulateDictionaryDetailsCallback, |
1663 weak_factory_.GetWeakPtr())); | 1638 weak_factory_.GetWeakPtr())); |
1664 } else if (command == kTagConnect) { | 1639 } else if (command == kTagConnect) { |
1665 chromeos::network_connect::ConnectToNetwork( | 1640 chromeos::network_connect::ConnectToNetwork( |
1666 service_path, GetNativeWindow()); | 1641 service_path, GetNativeWindow()); |
1667 } else if (command == kTagDisconnect && type != chromeos::TYPE_ETHERNET) { | 1642 } else if (command == kTagDisconnect && type != chromeos::TYPE_ETHERNET) { |
1668 cros_->DisconnectFromNetwork(network); | 1643 cros_->DisconnectFromNetwork(network); |
1669 } else if (command == kTagActivate && type == chromeos::TYPE_CELLULAR) { | 1644 } else if (command == kTagActivate && type == chromeos::TYPE_CELLULAR) { |
1670 if (!cros_->CellularDeviceUsesDirectActivation()) { | 1645 chromeos::network_connect::ActivateCellular(service_path); |
1671 ash::Shell::GetInstance()->delegate()->OpenMobileSetup( | 1646 // Activation may update network properties (e.g. ActivationState), so |
1672 network->service_path()); | 1647 // request them here in case they change. |
1673 } else { | 1648 UpdateConnectionData(network); |
1674 Activate(service_path); | |
1675 // Update network properties after we start activation. The Activate | |
1676 // call is a blocking call, which blocks on finishing the "start" of | |
1677 // the activation, hence when we query for network properties after | |
1678 // this call is done, we will have the "activating" activation state. | |
1679 UpdateConnectionData(network); | |
1680 } | |
1681 } else { | 1649 } else { |
1682 VLOG(1) << "Unknown command: " << command; | 1650 VLOG(1) << "Unknown command: " << command; |
1683 NOTREACHED(); | 1651 NOTREACHED(); |
1684 } | 1652 } |
1685 } | 1653 } |
1686 | 1654 |
1687 void InternetOptionsHandler::ToggleAirplaneModeCallback(const ListValue* args) { | 1655 void InternetOptionsHandler::ToggleAirplaneModeCallback(const ListValue* args) { |
1688 // TODO(kevers): The use of 'offline_mode' is not quite correct. Update once | 1656 // TODO(kevers): The use of 'offline_mode' is not quite correct. Update once |
1689 // we have proper back-end support. | 1657 // we have proper back-end support. |
1690 cros_->EnableOfflineMode(!cros_->offline_mode()); | 1658 cros_->EnableOfflineMode(!cros_->offline_mode()); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1822 | 1790 |
1823 dictionary->SetBoolean(kTagWimaxEnabled, cros_->wimax_enabled()); | 1791 dictionary->SetBoolean(kTagWimaxEnabled, cros_->wimax_enabled()); |
1824 dictionary->SetBoolean(kTagWimaxAvailable, cros_->wimax_available()); | 1792 dictionary->SetBoolean(kTagWimaxAvailable, cros_->wimax_available()); |
1825 dictionary->SetBoolean(kTagWimaxBusy, cros_->wimax_busy()); | 1793 dictionary->SetBoolean(kTagWimaxBusy, cros_->wimax_busy()); |
1826 // TODO(kevers): The use of 'offline_mode' is not quite correct. Update once | 1794 // TODO(kevers): The use of 'offline_mode' is not quite correct. Update once |
1827 // we have proper back-end support. | 1795 // we have proper back-end support. |
1828 dictionary->SetBoolean(kTagAirplaneMode, cros_->offline_mode()); | 1796 dictionary->SetBoolean(kTagAirplaneMode, cros_->offline_mode()); |
1829 } | 1797 } |
1830 | 1798 |
1831 } // namespace options | 1799 } // namespace options |
OLD | NEW |