| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 } | 795 } |
| 796 } | 796 } |
| 797 | 797 |
| 798 SetActivationButtonVisibility(cellular, dictionary); | 798 SetActivationButtonVisibility(cellular, dictionary); |
| 799 } | 799 } |
| 800 | 800 |
| 801 void InternetOptionsHandler::PopulateVPNDetails( | 801 void InternetOptionsHandler::PopulateVPNDetails( |
| 802 const chromeos::VirtualNetwork* vpn, | 802 const chromeos::VirtualNetwork* vpn, |
| 803 DictionaryValue* dictionary) { | 803 DictionaryValue* dictionary) { |
| 804 dictionary->SetString("service_name", vpn->name()); | 804 dictionary->SetString("service_name", vpn->name()); |
| 805 bool remembered = (vpn->profile_type() != chromeos::PROFILE_NONE); |
| 806 dictionary->SetBoolean("remembered", remembered); |
| 805 dictionary->SetString("server_hostname", vpn->server_hostname()); | 807 dictionary->SetString("server_hostname", vpn->server_hostname()); |
| 806 dictionary->SetString("provider_type", vpn->GetProviderTypeString()); | 808 dictionary->SetString("provider_type", vpn->GetProviderTypeString()); |
| 807 dictionary->SetString("username", vpn->username()); | 809 dictionary->SetString("username", vpn->username()); |
| 808 } | 810 } |
| 809 | 811 |
| 810 void InternetOptionsHandler::SetActivationButtonVisibility( | 812 void InternetOptionsHandler::SetActivationButtonVisibility( |
| 811 const chromeos::CellularNetwork* cellular, | 813 const chromeos::CellularNetwork* cellular, |
| 812 DictionaryValue* dictionary) { | 814 DictionaryValue* dictionary) { |
| 813 if (cellular->needs_new_plan()) { | 815 if (cellular->needs_new_plan()) { |
| 814 dictionary->SetBoolean("showBuyButton", true); | 816 dictionary->SetBoolean("showBuyButton", true); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 } else { | 862 } else { |
| 861 NOTREACHED(); | 863 NOTREACHED(); |
| 862 } | 864 } |
| 863 } | 865 } |
| 864 | 866 |
| 865 void InternetOptionsHandler::HandleWifiButtonClick( | 867 void InternetOptionsHandler::HandleWifiButtonClick( |
| 866 const std::string& service_path, | 868 const std::string& service_path, |
| 867 const std::string& command) { | 869 const std::string& command) { |
| 868 chromeos::WifiNetwork* wifi = NULL; | 870 chromeos::WifiNetwork* wifi = NULL; |
| 869 if (command == "forget") { | 871 if (command == "forget") { |
| 870 cros_->ForgetWifiNetwork(service_path); | 872 cros_->ForgetNetwork(service_path); |
| 871 } else if (service_path == kOtherNetworksFakePath) { | 873 } else if (service_path == kOtherNetworksFakePath) { |
| 872 // Other wifi networks. | 874 // Other wifi networks. |
| 873 CreateModalPopup(new chromeos::NetworkConfigView(chromeos::TYPE_WIFI)); | 875 CreateModalPopup(new chromeos::NetworkConfigView(chromeos::TYPE_WIFI)); |
| 874 } else if ((wifi = cros_->FindWifiNetworkByPath(service_path))) { | 876 } else if ((wifi = cros_->FindWifiNetworkByPath(service_path))) { |
| 875 if (command == "connect") { | 877 if (command == "connect") { |
| 876 // Connect to wifi here. Open password page if appropriate. | 878 // Connect to wifi here. Open password page if appropriate. |
| 877 if (wifi->IsPassphraseRequired()) { | 879 if (wifi->IsPassphraseRequired()) { |
| 878 CreateModalPopup(new chromeos::NetworkConfigView(wifi)); | 880 CreateModalPopup(new chromeos::NetworkConfigView(wifi)); |
| 879 } else { | 881 } else { |
| 880 cros_->ConnectToWifiNetwork(wifi); | 882 cros_->ConnectToWifiNetwork(wifi); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 905 } else if (command == "options") { | 907 } else if (command == "options") { |
| 906 PopulateDictionaryDetails(cellular); | 908 PopulateDictionaryDetails(cellular); |
| 907 } | 909 } |
| 908 } | 910 } |
| 909 } | 911 } |
| 910 | 912 |
| 911 void InternetOptionsHandler::HandleVPNButtonClick( | 913 void InternetOptionsHandler::HandleVPNButtonClick( |
| 912 const std::string& service_path, | 914 const std::string& service_path, |
| 913 const std::string& command) { | 915 const std::string& command) { |
| 914 chromeos::VirtualNetwork* network = NULL; | 916 chromeos::VirtualNetwork* network = NULL; |
| 915 // TODO(altimofeev): verify if service_path in condition is correct. | 917 if (command == "forget") { |
| 916 if (service_path == kOtherNetworksFakePath) { | 918 cros_->ForgetNetwork(service_path); |
| 919 } else if (service_path == kOtherNetworksFakePath) { |
| 920 // TODO(altimofeev): verify if service_path in condition is correct. |
| 917 // Other VPN networks. | 921 // Other VPN networks. |
| 918 CreateModalPopup(new chromeos::NetworkConfigView(chromeos::TYPE_VPN)); | 922 CreateModalPopup(new chromeos::NetworkConfigView(chromeos::TYPE_VPN)); |
| 919 } else if ((network = cros_->FindVirtualNetworkByPath(service_path))) { | 923 } else if ((network = cros_->FindVirtualNetworkByPath(service_path))) { |
| 920 if (command == "connect") { | 924 if (command == "connect") { |
| 921 // Connect to VPN here. Open password page if appropriate. | 925 // Connect to VPN here. Open password page if appropriate. |
| 922 if (network->NeedMoreInfoToConnect()) { | 926 if (network->NeedMoreInfoToConnect()) { |
| 923 CreateModalPopup(new chromeos::NetworkConfigView(network)); | 927 CreateModalPopup(new chromeos::NetworkConfigView(network)); |
| 924 } else { | 928 } else { |
| 925 cros_->ConnectToVirtualNetwork(network); | 929 cros_->ConnectToVirtualNetwork(network); |
| 926 } | 930 } |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1135 false, | 1139 false, |
| 1136 false, | 1140 false, |
| 1137 chromeos::ACTIVATION_STATE_UNKNOWN, | 1141 chromeos::ACTIVATION_STATE_UNKNOWN, |
| 1138 false)); | 1142 false)); |
| 1139 } | 1143 } |
| 1140 | 1144 |
| 1141 return list; | 1145 return list; |
| 1142 } | 1146 } |
| 1143 | 1147 |
| 1144 ListValue* InternetOptionsHandler::GetRememberedList() { | 1148 ListValue* InternetOptionsHandler::GetRememberedList() { |
| 1145 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | |
| 1146 ListValue* list = new ListValue(); | 1149 ListValue* list = new ListValue(); |
| 1147 | 1150 |
| 1148 const chromeos::WifiNetworkVector& remembered_wifi_networks = | |
| 1149 cros_->remembered_wifi_networks(); | |
| 1150 | |
| 1151 for (chromeos::WifiNetworkVector::const_iterator rit = | 1151 for (chromeos::WifiNetworkVector::const_iterator rit = |
| 1152 remembered_wifi_networks.begin(); | 1152 cros_->remembered_wifi_networks().begin(); |
| 1153 rit != remembered_wifi_networks.end(); ++rit) { | 1153 rit != cros_->remembered_wifi_networks().end(); ++rit) { |
| 1154 chromeos::WifiNetwork* remembered = *rit; | 1154 chromeos::WifiNetwork* remembered = *rit; |
| 1155 chromeos::WifiNetwork* wifi = static_cast<chromeos::WifiNetwork*>( | 1155 chromeos::WifiNetwork* wifi = static_cast<chromeos::WifiNetwork*>( |
| 1156 cros_->FindNetworkFromRemembered(remembered)); | 1156 cros_->FindNetworkFromRemembered(remembered)); |
| 1157 | 1157 |
| 1158 const SkBitmap* icon = wifi ? | |
| 1159 chromeos::NetworkMenu::IconForNetworkStrength(wifi) : | |
| 1160 rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0); | |
| 1161 // Place the secure badge on the icon if the remembered network is | |
| 1162 // encrypted (the matching detected network, if any, will have the same | |
| 1163 // encrypted property by definition). | |
| 1164 const SkBitmap* bottom_right_badge = remembered->encrypted() ? | |
| 1165 rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_SECURE) : NULL; | |
| 1166 // Set in_active_profile. | 1158 // Set in_active_profile. |
| 1167 bool shared = | 1159 bool shared = |
| 1168 cros_->HasMultipleProfiles() && | 1160 cros_->HasMultipleProfiles() && |
| 1169 remembered->profile_type() == chromeos::PROFILE_SHARED; | 1161 remembered->profile_type() == chromeos::PROFILE_SHARED; |
| 1170 list->Append(GetNetwork( | 1162 list->Append(GetNetwork( |
| 1171 remembered->service_path(), | 1163 remembered->service_path(), |
| 1172 chromeos::NetworkMenu::IconForDisplay( | 1164 chromeos::NetworkMenu::IconForNetwork(wifi ? wifi : remembered), |
| 1173 icon, bottom_right_badge, NULL, NULL), | |
| 1174 remembered->name(), | 1165 remembered->name(), |
| 1175 wifi ? wifi->connecting() : false, | 1166 wifi ? wifi->connecting() : false, |
| 1176 wifi ? wifi->connected() : false, | 1167 wifi ? wifi->connected() : false, |
| 1177 true, | 1168 true, |
| 1178 chromeos::TYPE_WIFI, | 1169 chromeos::TYPE_WIFI, |
| 1179 true, | 1170 true, |
| 1180 shared, | 1171 shared, |
| 1181 chromeos::ACTIVATION_STATE_UNKNOWN, | 1172 chromeos::ACTIVATION_STATE_UNKNOWN, |
| 1182 false)); | 1173 false)); |
| 1183 } | 1174 } |
| 1175 |
| 1176 for (chromeos::VirtualNetworkVector::const_iterator rit = |
| 1177 cros_->remembered_virtual_networks().begin(); |
| 1178 rit != cros_->remembered_virtual_networks().end(); ++rit) { |
| 1179 chromeos::VirtualNetwork* remembered = *rit; |
| 1180 chromeos::VirtualNetwork* vpn = static_cast<chromeos::VirtualNetwork*>( |
| 1181 cros_->FindNetworkFromRemembered(remembered)); |
| 1182 |
| 1183 // Set in_active_profile. |
| 1184 bool shared = |
| 1185 cros_->HasMultipleProfiles() && |
| 1186 remembered->profile_type() == chromeos::PROFILE_SHARED; |
| 1187 list->Append(GetNetwork( |
| 1188 remembered->service_path(), |
| 1189 chromeos::NetworkMenu::IconForNetwork(vpn ? vpn : remembered), |
| 1190 remembered->name(), |
| 1191 vpn ? vpn->connecting() : false, |
| 1192 vpn ? vpn->connected() : false, |
| 1193 true, |
| 1194 chromeos::TYPE_WIFI, |
| 1195 true, |
| 1196 shared, |
| 1197 chromeos::ACTIVATION_STATE_UNKNOWN, |
| 1198 false)); |
| 1199 } |
| 1200 |
| 1184 return list; | 1201 return list; |
| 1185 } | 1202 } |
| 1186 | 1203 |
| 1187 void InternetOptionsHandler::FillNetworkInfo(DictionaryValue* dictionary) { | 1204 void InternetOptionsHandler::FillNetworkInfo(DictionaryValue* dictionary) { |
| 1188 dictionary->SetBoolean("accessLocked", cros_->IsLocked()); | 1205 dictionary->SetBoolean("accessLocked", cros_->IsLocked()); |
| 1189 dictionary->Set("wiredList", GetWiredList()); | 1206 dictionary->Set("wiredList", GetWiredList()); |
| 1190 dictionary->Set("wirelessList", GetWirelessList()); | 1207 dictionary->Set("wirelessList", GetWirelessList()); |
| 1191 dictionary->Set("vpnList", GetVPNList()); | 1208 dictionary->Set("vpnList", GetVPNList()); |
| 1192 dictionary->Set("rememberedList", GetRememberedList()); | 1209 dictionary->Set("rememberedList", GetRememberedList()); |
| 1193 dictionary->SetBoolean("wifiAvailable", cros_->wifi_available()); | 1210 dictionary->SetBoolean("wifiAvailable", cros_->wifi_available()); |
| 1194 dictionary->SetBoolean("wifiEnabled", cros_->wifi_enabled()); | 1211 dictionary->SetBoolean("wifiEnabled", cros_->wifi_enabled()); |
| 1195 dictionary->SetBoolean("cellularAvailable", cros_->cellular_available()); | 1212 dictionary->SetBoolean("cellularAvailable", cros_->cellular_available()); |
| 1196 dictionary->SetBoolean("cellularEnabled", cros_->cellular_enabled()); | 1213 dictionary->SetBoolean("cellularEnabled", cros_->cellular_enabled()); |
| 1197 } | 1214 } |
| OLD | NEW |