OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/dom_ui/internet_options_handler.h" | 5 #include "chrome/browser/chromeos/dom_ui/internet_options_handler.h" |
6 | 6 |
7 #include <ctype.h> | 7 #include <ctype.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_AUTO_CONNECT)); | 151 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_AUTO_CONNECT)); |
152 localized_strings->SetString("inetCertPkcs", | 152 localized_strings->SetString("inetCertPkcs", |
153 l10n_util::GetStringUTF16( | 153 l10n_util::GetStringUTF16( |
154 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_INSTALLED)); | 154 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_INSTALLED)); |
155 localized_strings->SetString("inetLogin", | 155 localized_strings->SetString("inetLogin", |
156 l10n_util::GetStringUTF16( | 156 l10n_util::GetStringUTF16( |
157 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_LOGIN)); | 157 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_LOGIN)); |
158 localized_strings->SetString("inetShowPass", | 158 localized_strings->SetString("inetShowPass", |
159 l10n_util::GetStringUTF16( | 159 l10n_util::GetStringUTF16( |
160 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SHOWPASSWORD)); | 160 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SHOWPASSWORD)); |
| 161 localized_strings->SetString("inetSecurityNone", |
| 162 l10n_util::GetStringFUTF16( |
| 163 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_SELECT, |
| 164 l10n_util::GetStringUTF16( |
| 165 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_NONE))); |
| 166 localized_strings->SetString("inetSecurityWEP", |
| 167 l10n_util::GetStringFUTF16( |
| 168 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_SELECT, |
| 169 l10n_util::GetStringUTF16( |
| 170 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_WEP))); |
| 171 localized_strings->SetString("inetSecurityWPA", |
| 172 l10n_util::GetStringFUTF16( |
| 173 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_SELECT, |
| 174 l10n_util::GetStringUTF16( |
| 175 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_WPA))); |
| 176 localized_strings->SetString("inetSecurityRSN", |
| 177 l10n_util::GetStringFUTF16( |
| 178 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_SELECT, |
| 179 l10n_util::GetStringUTF16( |
| 180 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_RSN))); |
161 localized_strings->SetString("inetPassPrompt", | 181 localized_strings->SetString("inetPassPrompt", |
162 l10n_util::GetStringUTF16( | 182 l10n_util::GetStringUTF16( |
163 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSWORD)); | 183 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSWORD)); |
164 localized_strings->SetString("inetSsidPrompt", | 184 localized_strings->SetString("inetSsidPrompt", |
165 l10n_util::GetStringUTF16( | 185 l10n_util::GetStringUTF16( |
166 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SSID)); | 186 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SSID)); |
167 localized_strings->SetString("inetStatus", | 187 localized_strings->SetString("inetStatus", |
168 l10n_util::GetStringUTF16( | 188 l10n_util::GetStringUTF16( |
169 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_STATUS_TITLE)); | 189 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_STATUS_TITLE)); |
170 localized_strings->SetString("inetConnect", | 190 localized_strings->SetString("inetConnect", |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 return; | 695 return; |
676 } | 696 } |
677 | 697 |
678 chromeos::NetworkLibrary* cros = | 698 chromeos::NetworkLibrary* cros = |
679 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 699 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
680 chromeos::WifiNetwork* network = cros->FindWifiNetworkByPath(service_path); | 700 chromeos::WifiNetwork* network = cros->FindWifiNetworkByPath(service_path); |
681 if (network) { | 701 if (network) { |
682 cros->ConnectToWifiNetwork( | 702 cros->ConnectToWifiNetwork( |
683 network, password, std::string(), std::string()); | 703 network, password, std::string(), std::string()); |
684 } else { | 704 } else { |
685 // Must be an "other" login | 705 // Network disappeared while the user is connecting to it. |
686 cros->ConnectToWifiNetwork( | 706 // TODO(chocobo): Display error message. |
687 service_path, password, std::string(), std::string(), true); | 707 LOG(WARNING) << "Cannot find network to connect " << service_path; |
688 } | 708 } |
689 } | 709 } |
690 | 710 |
691 void InternetOptionsHandler::LoginCertCallback(const ListValue* args) { | 711 void InternetOptionsHandler::LoginCertCallback(const ListValue* args) { |
692 | 712 |
693 std::string service_path; | 713 std::string service_path; |
694 std::string identity; | 714 std::string identity; |
695 std::string certpath; | 715 std::string certpath; |
696 std::string password; | 716 std::string password; |
697 | 717 |
(...skipping 11 matching lines...) Expand all Loading... |
709 cros->FindWifiNetworkByPath(service_path); | 729 cros->FindWifiNetworkByPath(service_path); |
710 if (network) { | 730 if (network) { |
711 cros->ConnectToWifiNetwork( | 731 cros->ConnectToWifiNetwork( |
712 network, password, identity, certpath); | 732 network, password, identity, certpath); |
713 } else { | 733 } else { |
714 // TODO(dhg): Send error back to UI | 734 // TODO(dhg): Send error back to UI |
715 } | 735 } |
716 } | 736 } |
717 | 737 |
718 void InternetOptionsHandler::LoginToOtherCallback(const ListValue* args) { | 738 void InternetOptionsHandler::LoginToOtherCallback(const ListValue* args) { |
| 739 std::string security; |
719 std::string ssid; | 740 std::string ssid; |
720 std::string password; | 741 std::string password; |
721 | 742 |
722 if (args->GetSize() != 2 || | 743 if (args->GetSize() != 3 || |
723 !args->GetString(0, &ssid) || | 744 !args->GetString(0, &security) || |
724 !args->GetString(1, &password)) { | 745 !args->GetString(1, &ssid) || |
| 746 !args->GetString(2, &password)) { |
725 NOTREACHED(); | 747 NOTREACHED(); |
726 return; | 748 return; |
727 } | 749 } |
728 | 750 |
| 751 chromeos::ConnectionSecurity sec = chromeos::SECURITY_UNKNOWN; |
| 752 if (security == "none") { |
| 753 sec = chromeos::SECURITY_NONE; |
| 754 } else if (security == "wep") { |
| 755 sec = chromeos::SECURITY_WEP; |
| 756 } else if (security == "wpa") { |
| 757 sec = chromeos::SECURITY_WPA; |
| 758 } else if (security == "rsn") { |
| 759 sec = chromeos::SECURITY_RSN; |
| 760 } |
| 761 |
729 chromeos::NetworkLibrary* cros = | 762 chromeos::NetworkLibrary* cros = |
730 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 763 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
731 | 764 |
732 cros->ConnectToWifiNetwork( | 765 cros->ConnectToWifiNetwork(sec, ssid, password, std::string(), std::string(), |
733 ssid, password, std::string(), std::string(), true); | 766 true); |
734 } | 767 } |
735 | 768 |
736 void InternetOptionsHandler::ButtonClickCallback(const ListValue* args) { | 769 void InternetOptionsHandler::ButtonClickCallback(const ListValue* args) { |
737 std::string str_type; | 770 std::string str_type; |
738 std::string service_path; | 771 std::string service_path; |
739 std::string command; | 772 std::string command; |
740 if (args->GetSize() != 3 || | 773 if (args->GetSize() != 3 || |
741 !args->GetString(0, &str_type) || | 774 !args->GetString(0, &str_type) || |
742 !args->GetString(1, &service_path) || | 775 !args->GetString(1, &service_path) || |
743 !args->GetString(2, &command)) { | 776 !args->GetString(2, &command)) { |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
927 (*it)->connected(), | 960 (*it)->connected(), |
928 chromeos::TYPE_CELLULAR, | 961 chromeos::TYPE_CELLULAR, |
929 false, | 962 false, |
930 (*it)->activation_state())); | 963 (*it)->activation_state())); |
931 } | 964 } |
932 | 965 |
933 // Add "Other..." if wifi is enabled. | 966 // Add "Other..." if wifi is enabled. |
934 if (cros->wifi_enabled()) { | 967 if (cros->wifi_enabled()) { |
935 list->Append(GetNetwork( | 968 list->Append(GetNetwork( |
936 kOtherNetworksFakePath, | 969 kOtherNetworksFakePath, |
937 SkBitmap(), | 970 *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0_BLACK), |
938 l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_OTHER_NETWORKS), | 971 l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_OTHER_NETWORKS), |
939 false, | 972 false, |
940 false, | 973 false, |
941 chromeos::TYPE_WIFI, | 974 chromeos::TYPE_WIFI, |
942 false, | 975 false, |
943 chromeos::ACTIVATION_STATE_UNKNOWN)); | 976 chromeos::ACTIVATION_STATE_UNKNOWN)); |
944 } | 977 } |
945 | 978 |
946 return list; | 979 return list; |
947 } | 980 } |
(...skipping 18 matching lines...) Expand all Loading... |
966 icon, | 999 icon, |
967 (*it)->name(), | 1000 (*it)->name(), |
968 (*it)->connecting(), | 1001 (*it)->connecting(), |
969 (*it)->connected(), | 1002 (*it)->connected(), |
970 chromeos::TYPE_WIFI, | 1003 chromeos::TYPE_WIFI, |
971 true, | 1004 true, |
972 chromeos::ACTIVATION_STATE_UNKNOWN)); | 1005 chromeos::ACTIVATION_STATE_UNKNOWN)); |
973 } | 1006 } |
974 return list; | 1007 return list; |
975 } | 1008 } |
OLD | NEW |