1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "chrome/browser/ui/webui/options/chromeos/internet_options_handler_strings.h" 6 7 #include "base/macros.h" 8 #include "base/values.h" 9 #include "grit/ash_strings.h" 10 #include "grit/chromium_strings.h" 11 #include "grit/generated_resources.h" 12 #include "third_party/cros_system_api/dbus/service_constants.h" 13 #include "ui/base/l10n/l10n_util.h" 14 15 namespace chromeos { 16 namespace internet_options_strings { 17 18 namespace { 19 20 struct StringResource { 21 const char* name; 22 int id; 23 }; 24 25 StringResource kStringResources[] = { 26 // Main settings page. 27 {"ethernetTitle", IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET}, 28 {"wifiTitle", IDS_OPTIONS_SETTINGS_SECTION_TITLE_WIFI_NETWORK}, 29 {"wimaxTitle", IDS_OPTIONS_SETTINGS_SECTION_TITLE_WIMAX_NETWORK}, 30 {"cellularTitle", IDS_OPTIONS_SETTINGS_SECTION_TITLE_CELLULAR_NETWORK}, 31 {"vpnTitle", IDS_OPTIONS_SETTINGS_SECTION_TITLE_PRIVATE_NETWORK}, 32 {"networkNotConnected", IDS_OPTIONS_SETTINGS_NETWORK_NOT_CONNECTED}, 33 {"networkConnected", IDS_CHROMEOS_NETWORK_STATE_READY}, 34 {"joinOtherNetwork", IDS_OPTIONS_SETTINGS_NETWORK_OTHER}, 35 {"networkOffline", IDS_OPTIONS_SETTINGS_NETWORK_OFFLINE}, 36 {"networkDisabled", IDS_OPTIONS_SETTINGS_NETWORK_DISABLED}, 37 {"turnOffWifi", IDS_OPTIONS_SETTINGS_NETWORK_DISABLE_WIFI}, 38 {"turnOffWimax", IDS_OPTIONS_SETTINGS_NETWORK_DISABLE_WIMAX}, 39 {"turnOffCellular", IDS_OPTIONS_SETTINGS_NETWORK_DISABLE_CELLULAR}, 40 {"disconnectNetwork", IDS_OPTIONS_SETTINGS_DISCONNECT}, 41 {"preferredNetworks", IDS_OPTIONS_SETTINGS_PREFERRED_NETWORKS_LABEL}, 42 {"preferredNetworksPage", IDS_OPTIONS_SETTINGS_PREFERRED_NETWORKS_TITLE}, 43 {"useSharedProxies", IDS_OPTIONS_SETTINGS_USE_SHARED_PROXIES}, 44 { "addConnectionTitle", 45 IDS_OPTIONS_SETTINGS_SECTION_TITLE_ADD_CONNECTION }, 46 {"addConnectionWifi", IDS_OPTIONS_SETTINGS_ADD_CONNECTION_WIFI}, 47 {"addConnectionVPN", IDS_STATUSBAR_NETWORK_ADD_VPN}, 48 {"otherCellularNetworks", IDS_OPTIONS_SETTINGS_OTHER_CELLULAR_NETWORKS}, 49 {"enableDataRoaming", IDS_OPTIONS_SETTINGS_ENABLE_DATA_ROAMING}, 50 {"disableDataRoaming", IDS_OPTIONS_SETTINGS_DISABLE_DATA_ROAMING}, 51 {"dataRoamingDisableToggleTooltip", 52 IDS_OPTIONS_SETTINGS_TOGGLE_DATA_ROAMING_RESTRICTION}, 53 54 // Internet details dialog. 55 {"managedNetwork", IDS_OPTIONS_SETTINGS_MANAGED_NETWORK}, 56 {"wifiNetworkTabLabel", IDS_OPTIONS_SETTINGS_INTERNET_TAB_CONNECTION}, 57 {"vpnTabLabel", IDS_OPTIONS_SETTINGS_INTERNET_TAB_VPN}, 58 {"cellularConnTabLabel", IDS_OPTIONS_SETTINGS_INTERNET_TAB_CONNECTION}, 59 {"cellularDeviceTabLabel", IDS_OPTIONS_SETTINGS_INTERNET_TAB_DEVICE}, 60 {"networkTabLabel", IDS_OPTIONS_SETTINGS_INTERNET_TAB_NETWORK}, 61 {"securityTabLabel", IDS_OPTIONS_SETTINGS_INTERNET_TAB_SECURITY}, 62 {"proxyTabLabel", IDS_OPTIONS_SETTINGS_INTERNET_TAB_PROXY}, 63 {"connectionState", IDS_OPTIONS_SETTINGS_INTERNET_CONNECTION_STATE}, 64 {"inetAddress", IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_ADDRESS}, 65 {"inetNetmask", IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SUBNETMASK}, 66 {"inetGateway", IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_GATEWAY}, 67 {"inetNameServers", IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_DNSSERVER}, 68 {"ipAutomaticConfiguration", 69 IDS_OPTIONS_SETTINGS_INTERNET_IP_AUTOMATIC_CONFIGURATION}, 70 {"automaticNameServers", 71 IDS_OPTIONS_SETTINGS_INTERNET_AUTOMATIC_NAME_SERVERS}, 72 {"userNameServer1", IDS_OPTIONS_SETTINGS_INTERNET_USER_NAME_SERVER_1}, 73 {"userNameServer2", IDS_OPTIONS_SETTINGS_INTERNET_USER_NAME_SERVER_2}, 74 {"userNameServer3", IDS_OPTIONS_SETTINGS_INTERNET_USER_NAME_SERVER_3}, 75 {"userNameServer4", IDS_OPTIONS_SETTINGS_INTERNET_USER_NAME_SERVER_4}, 76 {"googleNameServers", IDS_OPTIONS_SETTINGS_INTERNET_GOOGLE_NAME_SERVERS}, 77 {"userNameServers", IDS_OPTIONS_SETTINGS_INTERNET_USER_NAME_SERVERS}, 78 {"hardwareAddress", IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_HARDWARE_ADDRESS}, 79 {"detailsInternetDismiss", IDS_CLOSE}, 80 {"activateButton", IDS_OPTIONS_SETTINGS_ACTIVATE}, 81 {"buyplanButton", IDS_OPTIONS_SETTINGS_BUY_PLAN}, 82 {"connectButton", IDS_OPTIONS_SETTINGS_CONNECT}, 83 {"configureButton", IDS_OPTIONS_SETTINGS_CONFIGURE}, 84 {"disconnectButton", IDS_OPTIONS_SETTINGS_DISCONNECT}, 85 {"viewAccountButton", IDS_STATUSBAR_NETWORK_VIEW_ACCOUNT}, 86 {"wimaxConnTabLabel", IDS_OPTIONS_SETTINGS_INTERNET_TAB_WIMAX}, 87 88 // Wifi Tab. 89 {"inetSsid", IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_NETWORK_ID}, 90 {"inetBssid", IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_NETWORK_BSSID}, 91 {"inetEncryption", 92 IDS_OPTIONS_SETTIGNS_INTERNET_OPTIONS_NETWORK_ENCRYPTION}, 93 {"inetFrequency", IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_NETWORK_FREQUENCY}, 94 {"inetFrequencyFormat", 95 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_NETWORK_FREQUENCY_MHZ}, 96 {"inetSignalStrength", 97 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_NETWORK_STRENGTH}, 98 {"inetSignalStrengthFormat", 99 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_NETWORK_STRENGTH_PERCENTAGE}, 100 {"inetPassProtected", IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_NET_PROTECTED}, 101 {"inetNetworkShared", IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_NETWORK_SHARED}, 102 {"inetPreferredNetwork", 103 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PREFER_NETWORK}, 104 {"inetAutoConnectNetwork", 105 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_AUTO_CONNECT}, 106 107 // VPN Tab. 108 {"inetServiceName", IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_SERVICE_NAME}, 109 {"inetServerHostname", 110 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_SERVER_HOSTNAME}, 111 {"inetProviderType", 112 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_PROVIDER_TYPE}, 113 {"inetUsername", IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_USERNAME}, 114 115 // Cellular Tab. 116 {"serviceName", IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_SERVICE_NAME}, 117 {"networkTechnology", 118 IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_NETWORK_TECHNOLOGY}, 119 {"operatorName", IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_OPERATOR}, 120 {"operatorCode", IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_OPERATOR_CODE}, 121 {"activationState", 122 IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_ACTIVATION_STATE}, 123 {"roamingState", IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_ROAMING_STATE}, 124 {"restrictedPool", IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_RESTRICTED_POOL}, 125 {"errorState", IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_ERROR_STATE}, 126 {"cellularManufacturer", 127 IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_MANUFACTURER}, 128 {"modelId", IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_MODEL_ID}, 129 {"firmwareRevision", 130 IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_FIRMWARE_REVISION}, 131 {"hardwareRevision", 132 IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_HARDWARE_REVISION}, 133 {"prlVersion", IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_PRL_VERSION}, 134 {"cellularApnLabel", IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_APN}, 135 {"cellularApnOther", IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_APN_OTHER}, 136 {"cellularApnUsername", 137 IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_APN_USERNAME}, 138 {"cellularApnPassword", 139 IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_APN_PASSWORD}, 140 {"cellularApnUseDefault", IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_APN_CLEAR}, 141 {"cellularApnSet", IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_APN_SET}, 142 {"cellularApnCancel", IDS_CANCEL}, 143 144 // Security Tab. 145 {"lockSimCard", IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_LOCK_SIM_CARD}, 146 {"changePinButton", 147 IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_CHANGE_PIN_BUTTON}, 148 149 // Proxy Tab. 150 {"webProxyAutoDiscoveryUrl", IDS_PROXY_WEB_PROXY_AUTO_DISCOVERY}, 151 }; 152 153 const size_t kStringResourcesLength = arraysize(kStringResources); 154 155 } // namespace 156 157 void RegisterLocalizedStrings(base::DictionaryValue* localized_strings) { 158 for (size_t i = 0; i < kStringResourcesLength; ++i) { 159 localized_strings->SetString( 160 kStringResources[i].name, 161 l10n_util::GetStringUTF16(kStringResources[i].id)); 162 } 163 } 164 165 std::string ActivationStateString(const std::string& activation_state) { 166 int id; 167 if (activation_state == shill::kActivationStateActivated) 168 id = IDS_CHROMEOS_NETWORK_ACTIVATION_STATE_ACTIVATED; 169 else if (activation_state == shill::kActivationStateActivating) 170 id = IDS_CHROMEOS_NETWORK_ACTIVATION_STATE_ACTIVATING; 171 else if (activation_state == shill::kActivationStateNotActivated) 172 id = IDS_CHROMEOS_NETWORK_ACTIVATION_STATE_NOT_ACTIVATED; 173 else if (activation_state == shill::kActivationStatePartiallyActivated) 174 id = IDS_CHROMEOS_NETWORK_ACTIVATION_STATE_PARTIALLY_ACTIVATED; 175 else 176 id = IDS_CHROMEOS_NETWORK_ACTIVATION_STATE_UNKNOWN; 177 return l10n_util::GetStringUTF8(id); 178 } 179 180 std::string RoamingStateString(const std::string& roaming_state) { 181 int id; 182 if (roaming_state == shill::kRoamingStateHome) 183 id = IDS_CHROMEOS_NETWORK_ROAMING_STATE_HOME; 184 else if (roaming_state == shill::kRoamingStateRoaming) 185 id = IDS_CHROMEOS_NETWORK_ROAMING_STATE_ROAMING; 186 else 187 id = IDS_CHROMEOS_NETWORK_ROAMING_STATE_UNKNOWN; 188 return l10n_util::GetStringUTF8(id); 189 } 190 191 std::string ConnectionStateString(const std::string& state) { 192 int id; 193 if (state == shill::kUnknownString) 194 id = IDS_CHROMEOS_NETWORK_STATE_UNKNOWN; 195 else if (state == shill::kStateIdle) 196 id = IDS_CHROMEOS_NETWORK_STATE_IDLE; 197 else if (state == shill::kStateCarrier) 198 id = IDS_CHROMEOS_NETWORK_STATE_CARRIER; 199 else if (state == shill::kStateAssociation) 200 id = IDS_CHROMEOS_NETWORK_STATE_ASSOCIATION; 201 else if (state == shill::kStateConfiguration) 202 id = IDS_CHROMEOS_NETWORK_STATE_CONFIGURATION; 203 else if (state == shill::kStateReady) 204 id = IDS_CHROMEOS_NETWORK_STATE_READY; 205 else if (state == shill::kStateDisconnect) 206 id = IDS_CHROMEOS_NETWORK_STATE_DISCONNECT; 207 else if (state == shill::kStateFailure) 208 id = IDS_CHROMEOS_NETWORK_STATE_FAILURE; 209 else if (state == shill::kStateActivationFailure) 210 id = IDS_CHROMEOS_NETWORK_STATE_ACTIVATION_FAILURE; 211 else if (state == shill::kStatePortal) 212 id = IDS_CHROMEOS_NETWORK_STATE_PORTAL; 213 else if (state == shill::kStateOnline) 214 id = IDS_CHROMEOS_NETWORK_STATE_ONLINE; 215 else 216 id = IDS_CHROMEOS_NETWORK_STATE_UNRECOGNIZED; 217 return l10n_util::GetStringUTF8(id); 218 } 219 220 // Note: these strings are user visible but not localized. 221 std::string EncryptionString(const std::string& security, 222 const std::string& eap_method) { 223 if (security == shill::kSecurityNone) 224 return ""; 225 if (security == shill::kSecurityWpa) 226 return "WPA"; 227 if (security == shill::kSecurityWep) 228 return "WEP"; 229 if (security == shill::kSecurityRsn) 230 return "RSN"; 231 if (security == shill::kSecurityPsk) 232 return "PSK"; 233 if (security == shill::kSecurity8021x) { 234 std::string result = "8021X"; 235 if (eap_method == shill::kEapMethodPEAP) 236 result += "PEAP"; 237 else if (eap_method == shill::kEapMethodTLS) 238 result += "TLS"; 239 else if (eap_method == shill::kEapMethodTTLS) 240 result += "TTLS"; 241 else if (eap_method == shill::kEapMethodLEAP) 242 result += "LEAP"; 243 return result; 244 } 245 return "Unknown"; 246 } 247 248 std::string ProviderTypeString( 249 const std::string& provider_type, 250 const base::DictionaryValue& provider_properties) { 251 int id; 252 if (provider_type == shill::kProviderL2tpIpsec) { 253 std::string client_cert_id; 254 provider_properties.GetStringWithoutPathExpansion( 255 shill::kL2tpIpsecClientCertIdProperty, &client_cert_id); 256 if (client_cert_id.empty()) 257 id = IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_L2TP_IPSEC_PSK; 258 else 259 id = IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_L2TP_IPSEC_USER_CERT; 260 } else if (provider_type == shill::kProviderOpenVpn) { 261 id = IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_OPEN_VPN; 262 } else { 263 id = IDS_CHROMEOS_NETWORK_ERROR_UNKNOWN; 264 } 265 return l10n_util::GetStringUTF8(id); 266 } 267 268 std::string RestrictedStateString(const std::string& connection_state) { 269 int id; 270 if (connection_state == shill::kStatePortal) 271 id = IDS_CONFIRM_MESSAGEBOX_YES_BUTTON_LABEL; 272 else 273 id = IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL; 274 return l10n_util::GetStringUTF8(id); 275 } 276 277 std::string NetworkDeviceTypeString(const std::string& network_type) { 278 int id; 279 if (network_type == shill::kTypeEthernet) 280 id = IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET; 281 else if (network_type == shill::kTypeWifi) 282 id = IDS_STATUSBAR_NETWORK_DEVICE_WIFI; 283 else if (network_type == shill::kTypeCellular) 284 id = IDS_STATUSBAR_NETWORK_DEVICE_CELLULAR; 285 else 286 id = IDS_STATUSBAR_NETWORK_DEVICE_UNKNOWN; 287 return l10n_util::GetStringUTF8(id); 288 } 289 290 } // namespace internet_options_strings 291 } // namespace chromeos 292