Chromium Code Reviews| 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/chromeos/cros/network_library.h" | 5 #include "chrome/browser/chromeos/cros/network_library.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| 11 #include "base/i18n/icu_encoding_detection.h" | 11 #include "base/i18n/icu_encoding_detection.h" |
| 12 #include "base/i18n/icu_string_conversions.h" | 12 #include "base/i18n/icu_string_conversions.h" |
| 13 #include "base/i18n/time_formatting.h" | 13 #include "base/i18n/time_formatting.h" |
| 14 #include "base/json/json_writer.h" // for debug output only. | |
| 14 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 15 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
| 16 #include "base/string_number_conversions.h" | 17 #include "base/string_number_conversions.h" |
| 17 #include "base/string_tokenizer.h" | 18 #include "base/string_tokenizer.h" |
| 18 #include "base/string_util.h" | 19 #include "base/string_util.h" |
| 19 #include "base/stringprintf.h" | 20 #include "base/stringprintf.h" |
| 20 #include "base/utf_string_conversions.h" | 21 #include "base/utf_string_conversions.h" |
| 21 #include "base/utf_string_conversion_utils.h" | 22 #include "base/utf_string_conversion_utils.h" |
| 22 #include "base/values.h" | 23 #include "base/values.h" |
| 23 #include "chrome/browser/chromeos/cros/cros_library.h" | 24 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 25 #include "chrome/browser/chromeos/cros/native_network_constants.h" | |
| 26 #include "chrome/browser/chromeos/cros/native_network_parser.h" | |
| 24 #include "chrome/browser/chromeos/login/user_manager.h" | 27 #include "chrome/browser/chromeos/login/user_manager.h" |
| 25 #include "chrome/browser/chromeos/network_login_observer.h" | 28 #include "chrome/browser/chromeos/network_login_observer.h" |
| 26 #include "chrome/browser/chromeos/user_cros_settings_provider.h" | 29 #include "chrome/browser/chromeos/user_cros_settings_provider.h" |
| 27 #include "chrome/common/time_format.h" | 30 #include "chrome/common/time_format.h" |
| 28 #include "content/browser/browser_thread.h" | 31 #include "content/browser/browser_thread.h" |
| 29 #include "crypto/nss_util.h" // crypto::GetTPMTokenInfo() for 802.1X and VPN. | 32 #include "crypto/nss_util.h" // crypto::GetTPMTokenInfo() for 802.1X and VPN. |
| 30 #include "grit/generated_resources.h" | 33 #include "grit/generated_resources.h" |
| 31 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
| 32 #include "ui/base/text/bytes_formatting.h" | 35 #include "ui/base/text/bytes_formatting.h" |
| 33 | 36 |
| 34 //////////////////////////////////////////////////////////////////////////////// | 37 //////////////////////////////////////////////////////////////////////////////// |
| 35 // Implementation notes. | 38 // Implementation notes. |
| 36 // NetworkLibraryImpl manages a series of classes that describe network devices | 39 // NetworkLibraryImpl manages a series of classes that describe network devices |
| 37 // and services: | 40 // and services: |
| 38 // | 41 // |
| 39 // NetworkDevice: e.g. ethernet, wifi modem, cellular modem | 42 // NetworkDevice: e.g. ethernet, wifi modem, cellular modem |
| 40 // device_map_: canonical map<path,NetworkDevice*> for devices | 43 // device_map_: canonical map<path, NetworkDevice*> for devices |
| 41 // | 44 // |
| 42 // Network: a network service ("network"). | 45 // Network: a network service ("network"). |
| 43 // network_map_: canonical map<path,Network*> for all visible networks. | 46 // network_map_: canonical map<path, Network*> for all visible networks. |
| 44 // EthernetNetwork | 47 // EthernetNetwork |
| 45 // ethernet_: EthernetNetwork* to the active ethernet network in network_map_. | 48 // ethernet_: EthernetNetwork* to the active ethernet network in network_map_. |
| 46 // WirelessNetwork: a WiFi or Cellular Network. | 49 // WirelessNetwork: a WiFi or Cellular Network. |
| 47 // WifiNetwork | 50 // WifiNetwork |
| 48 // active_wifi_: WifiNetwork* to the active wifi network in network_map_. | 51 // active_wifi_: WifiNetwork* to the active wifi network in network_map_. |
| 49 // wifi_networks_: ordered vector of WifiNetwork* entries in network_map_, | 52 // wifi_networks_: ordered vector of WifiNetwork* entries in network_map_, |
| 50 // in descending order of importance. | 53 // in descending order of importance. |
| 51 // CellularNetwork | 54 // CellularNetwork |
| 52 // active_cellular_: Cellular version of wifi_. | 55 // active_cellular_: Cellular version of wifi_. |
| 53 // cellular_networks_: Cellular version of wifi_. | 56 // cellular_networks_: Cellular version of wifi_. |
| 54 // network_unique_id_map_: map<unique_id,Network*> for visible networks. | 57 // network_unique_id_map_: map<unique_id, Network*> for visible networks. |
| 55 // remembered_network_map_: a canonical map<path,Network*> for all networks | 58 // remembered_network_map_: a canonical map<path, Network*> for all networks |
| 56 // remembered in the active Profile ("favorites"). | 59 // remembered in the active Profile ("favorites"). |
| 57 // remembered_wifi_networks_: ordered vector of WifiNetwork* entries in | 60 // remembered_wifi_networks_: ordered vector of WifiNetwork* entries in |
| 58 // remembered_network_map_, in descending order of preference. | 61 // remembered_network_map_, in descending order of preference. |
| 59 // remembered_virtual_networks_: ordered vector of VirtualNetwork* entries in | 62 // remembered_virtual_networks_: ordered vector of VirtualNetwork* entries in |
| 60 // remembered_network_map_, in descending order of preference. | 63 // remembered_network_map_, in descending order of preference. |
| 61 // | 64 // |
| 62 // network_manager_monitor_: a handle to the libcros network Manager handler. | 65 // network_manager_monitor_: a handle to the libcros network Manager handler. |
| 63 // NetworkManagerStatusChanged: This handles all messages from the Manager. | 66 // NetworkManagerStatusChanged: This handles all messages from the Manager. |
| 64 // Messages are parsed here and the appropriate updates are then requested. | 67 // Messages are parsed here and the appropriate updates are then requested. |
| 65 // | 68 // |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 94 const int kNetworkNotifyDelayMs = 50; | 97 const int kNetworkNotifyDelayMs = 50; |
| 95 | 98 |
| 96 // How long we should remember that cellular plan payment was received. | 99 // How long we should remember that cellular plan payment was received. |
| 97 const int kRecentPlanPaymentHours = 6; | 100 const int kRecentPlanPaymentHours = 6; |
| 98 | 101 |
| 99 // Default value of the SIM unlock retries count. It is updated to the real | 102 // Default value of the SIM unlock retries count. It is updated to the real |
| 100 // retries count once cellular device with SIM card is initialized. | 103 // retries count once cellular device with SIM card is initialized. |
| 101 // If cellular device doesn't have SIM card, then retries are never used. | 104 // If cellular device doesn't have SIM card, then retries are never used. |
| 102 const int kDefaultSimUnlockRetriesCount = 999; | 105 const int kDefaultSimUnlockRetriesCount = 999; |
| 103 | 106 |
| 104 // Format of the Carrier ID: <carrier name> (<carrier country>). | |
| 105 const char kCarrierIdFormat[] = "%s (%s)"; | |
| 106 | |
| 107 // Path of the default (shared) flimflam profile. | |
| 108 const char kSharedProfilePath[] = "/profile/default"; | |
| 109 | |
| 110 // Type of a pending SIM operation. | |
| 111 enum SimOperationType { | |
| 112 SIM_OPERATION_NONE = 0, | |
| 113 SIM_OPERATION_CHANGE_PIN = 1, | |
| 114 SIM_OPERATION_CHANGE_REQUIRE_PIN = 2, | |
| 115 SIM_OPERATION_ENTER_PIN = 3, | |
| 116 SIM_OPERATION_UNBLOCK_PIN = 4, | |
| 117 }; | |
| 118 | |
| 119 // D-Bus interface string constants. | |
| 120 | |
| 121 // Flimflam manager properties. | |
| 122 const char kAvailableTechnologiesProperty[] = "AvailableTechnologies"; | |
| 123 const char kEnabledTechnologiesProperty[] = "EnabledTechnologies"; | |
| 124 const char kConnectedTechnologiesProperty[] = "ConnectedTechnologies"; | |
| 125 const char kDefaultTechnologyProperty[] = "DefaultTechnology"; | |
| 126 const char kOfflineModeProperty[] = "OfflineMode"; | |
| 127 const char kActiveProfileProperty[] = "ActiveProfile"; | |
| 128 const char kProfilesProperty[] = "Profiles"; | |
| 129 const char kServicesProperty[] = "Services"; | |
| 130 const char kServiceWatchListProperty[] = "ServiceWatchList"; | |
| 131 const char kDevicesProperty[] = "Devices"; | |
| 132 const char kPortalURLProperty[] = "PortalURL"; | |
| 133 const char kCheckPortalListProperty[] = "CheckPortalList"; | |
| 134 | |
| 135 // Flimflam service properties. | |
| 136 const char kSecurityProperty[] = "Security"; | |
| 137 const char kPassphraseProperty[] = "Passphrase"; | |
| 138 const char kIdentityProperty[] = "Identity"; | |
| 139 const char kPassphraseRequiredProperty[] = "PassphraseRequired"; | |
| 140 const char kSaveCredentialsProperty[] = "SaveCredentials"; | |
| 141 const char kSignalStrengthProperty[] = "Strength"; | |
| 142 const char kNameProperty[] = "Name"; | |
| 143 const char kStateProperty[] = "State"; | |
| 144 const char kTypeProperty[] = "Type"; | |
| 145 const char kDeviceProperty[] = "Device"; | |
| 146 const char kProfileProperty[] = "Profile"; | |
| 147 const char kTechnologyFamilyProperty[] = "Cellular.Family"; | |
| 148 const char kActivationStateProperty[] = "Cellular.ActivationState"; | |
| 149 const char kNetworkTechnologyProperty[] = "Cellular.NetworkTechnology"; | |
| 150 const char kRoamingStateProperty[] = "Cellular.RoamingState"; | |
| 151 const char kOperatorNameProperty[] = "Cellular.OperatorName"; | |
| 152 const char kOperatorCodeProperty[] = "Cellular.OperatorCode"; | |
| 153 const char kServingOperatorProperty[] = "Cellular.ServingOperator"; | |
| 154 const char kPaymentURLProperty[] = "Cellular.OlpUrl"; | |
| 155 const char kUsageURLProperty[] = "Cellular.UsageUrl"; | |
| 156 const char kCellularApnProperty[] = "Cellular.APN"; | |
| 157 const char kCellularLastGoodApnProperty[] = "Cellular.LastGoodAPN"; | |
| 158 const char kCellularApnListProperty[] = "Cellular.APNList"; | |
| 159 const char kWifiHexSsid[] = "WiFi.HexSSID"; | |
| 160 const char kWifiFrequency[] = "WiFi.Frequency"; | |
| 161 const char kWifiHiddenSsid[] = "WiFi.HiddenSSID"; | |
| 162 const char kWifiPhyMode[] = "WiFi.PhyMode"; | |
| 163 const char kWifiAuthMode[] = "WiFi.AuthMode"; | |
| 164 const char kFavoriteProperty[] = "Favorite"; | |
| 165 const char kConnectableProperty[] = "Connectable"; | |
| 166 const char kPriorityProperty[] = "Priority"; | |
| 167 const char kAutoConnectProperty[] = "AutoConnect"; | |
| 168 const char kIsActiveProperty[] = "IsActive"; | |
| 169 const char kModeProperty[] = "Mode"; | |
| 170 const char kErrorProperty[] = "Error"; | |
| 171 const char kEntriesProperty[] = "Entries"; | |
| 172 const char kProviderProperty[] = "Provider"; | |
| 173 const char kHostProperty[] = "Host"; | |
| 174 const char kProxyConfigProperty[] = "ProxyConfig"; | |
| 175 | |
| 176 // Flimflam property names for SIMLock status. | |
| 177 const char kSIMLockStatusProperty[] = "Cellular.SIMLockStatus"; | |
| 178 const char kSIMLockTypeProperty[] = "LockType"; | |
| 179 const char kSIMLockRetriesLeftProperty[] = "RetriesLeft"; | |
| 180 | |
| 181 // Flimflam property names for Cellular.FoundNetworks. | |
| 182 const char kLongNameProperty[] = "long_name"; | |
| 183 const char kStatusProperty[] = "status"; | |
| 184 const char kShortNameProperty[] = "short_name"; | |
| 185 const char kTechnologyProperty[] = "technology"; | |
| 186 const char kNetworkIdProperty[] = "network_id"; | |
| 187 | |
| 188 // Flimflam SIMLock status types. | |
| 189 const char kSIMLockPin[] = "sim-pin"; | |
| 190 const char kSIMLockPuk[] = "sim-puk"; | |
| 191 | |
| 192 // APN info property names. | |
| 193 const char kApnProperty[] = "apn"; | |
| 194 const char kApnNetworkIdProperty[] = "network_id"; | |
| 195 const char kApnUsernameProperty[] = "username"; | |
| 196 const char kApnPasswordProperty[] = "password"; | |
| 197 const char kApnNameProperty[] = "name"; | |
| 198 const char kApnLocalizedNameProperty[] = "localized_name"; | |
| 199 const char kApnLanguageProperty[] = "language"; | |
| 200 | |
| 201 // Operator info property names. | |
| 202 const char kOperatorNameKey[] = "name"; | |
| 203 const char kOperatorCodeKey[] = "code"; | |
| 204 const char kOperatorCountryKey[] = "country"; | |
| 205 | |
| 206 // Flimflam device info property names. | |
| 207 const char kScanningProperty[] = "Scanning"; | |
| 208 const char kPoweredProperty[] = "Powered"; | |
| 209 const char kNetworksProperty[] = "Networks"; | |
| 210 const char kCarrierProperty[] = "Cellular.Carrier"; | |
| 211 const char kCellularAllowRoamingProperty[] = "Cellular.AllowRoaming"; | |
| 212 const char kHomeProviderProperty[] = "Cellular.HomeProvider"; | |
| 213 const char kMeidProperty[] = "Cellular.MEID"; | |
| 214 const char kImeiProperty[] = "Cellular.IMEI"; | |
| 215 const char kImsiProperty[] = "Cellular.IMSI"; | |
| 216 const char kEsnProperty[] = "Cellular.ESN"; | |
| 217 const char kMdnProperty[] = "Cellular.MDN"; | |
| 218 const char kMinProperty[] = "Cellular.MIN"; | |
| 219 const char kModelIDProperty[] = "Cellular.ModelID"; | |
| 220 const char kManufacturerProperty[] = "Cellular.Manufacturer"; | |
| 221 const char kFirmwareRevisionProperty[] = "Cellular.FirmwareRevision"; | |
| 222 const char kHardwareRevisionProperty[] = "Cellular.HardwareRevision"; | |
| 223 const char kPRLVersionProperty[] = "Cellular.PRLVersion"; // (INT16) | |
| 224 const char kSelectedNetworkProperty[] = "Cellular.SelectedNetwork"; | |
| 225 const char kSupportNetworkScanProperty[] = "Cellular.SupportNetworkScan"; | |
| 226 const char kFoundNetworksProperty[] = "Cellular.FoundNetworks"; | |
| 227 | |
| 228 // Flimflam ip config property names. | |
| 229 const char kAddressProperty[] = "Address"; | |
| 230 const char kPrefixlenProperty[] = "Prefixlen"; | |
| 231 const char kGatewayProperty[] = "Gateway"; | |
| 232 const char kNameServersProperty[] = "NameServers"; | |
| 233 | |
| 234 // Flimflam type options. | |
| 235 const char kTypeEthernet[] = "ethernet"; | |
| 236 const char kTypeWifi[] = "wifi"; | |
| 237 const char kTypeWimax[] = "wimax"; | |
| 238 const char kTypeBluetooth[] = "bluetooth"; | |
| 239 const char kTypeCellular[] = "cellular"; | |
| 240 const char kTypeVPN[] = "vpn"; | |
| 241 | |
| 242 // Flimflam mode options. | |
| 243 const char kModeManaged[] = "managed"; | |
| 244 const char kModeAdhoc[] = "adhoc"; | |
| 245 | |
| 246 // Flimflam security options. | |
| 247 const char kSecurityWpa[] = "wpa"; | |
| 248 const char kSecurityWep[] = "wep"; | |
| 249 const char kSecurityRsn[] = "rsn"; | |
| 250 const char kSecurity8021x[] = "802_1x"; | |
| 251 const char kSecurityPsk[] = "psk"; | |
| 252 const char kSecurityNone[] = "none"; | |
| 253 | |
| 254 // Flimflam L2TPIPsec property names. | |
| 255 const char kL2TPIPSecCACertNSSProperty[] = "L2TPIPsec.CACertNSS"; | |
| 256 const char kL2TPIPSecClientCertIDProperty[] = "L2TPIPsec.ClientCertID"; | |
| 257 const char kL2TPIPSecClientCertSlotProp[] = "L2TPIPsec.ClientCertSlot"; | |
| 258 const char kL2TPIPSecPINProperty[] = "L2TPIPsec.PIN"; | |
| 259 const char kL2TPIPSecPSKProperty[] = "L2TPIPsec.PSK"; | |
| 260 const char kL2TPIPSecUserProperty[] = "L2TPIPsec.User"; | |
| 261 const char kL2TPIPSecPasswordProperty[] = "L2TPIPsec.Password"; | |
| 262 | |
| 263 // Flimflam EAP property names. | |
| 264 // See src/third_party/flimflam/doc/service-api.txt. | |
| 265 const char kEapIdentityProperty[] = "EAP.Identity"; | |
| 266 const char kEapMethodProperty[] = "EAP.EAP"; | |
| 267 const char kEapPhase2AuthProperty[] = "EAP.InnerEAP"; | |
| 268 const char kEapAnonymousIdentityProperty[] = "EAP.AnonymousIdentity"; | |
| 269 const char kEapClientCertProperty[] = "EAP.ClientCert"; // path | |
| 270 const char kEapCertIDProperty[] = "EAP.CertID"; // PKCS#11 ID | |
| 271 const char kEapClientCertNssProperty[] = "EAP.ClientCertNSS"; // NSS nickname | |
| 272 const char kEapPrivateKeyProperty[] = "EAP.PrivateKey"; | |
| 273 const char kEapPrivateKeyPasswordProperty[] = "EAP.PrivateKeyPassword"; | |
| 274 const char kEapKeyIDProperty[] = "EAP.KeyID"; | |
| 275 const char kEapCaCertProperty[] = "EAP.CACert"; // server CA cert path | |
| 276 const char kEapCaCertIDProperty[] = "EAP.CACertID"; // server CA PKCS#11 ID | |
| 277 const char kEapCaCertNssProperty[] = "EAP.CACertNSS"; // server CA NSS nickname | |
| 278 const char kEapUseSystemCAsProperty[] = "EAP.UseSystemCAs"; | |
| 279 const char kEapPinProperty[] = "EAP.PIN"; | |
| 280 const char kEapPasswordProperty[] = "EAP.Password"; | |
| 281 const char kEapKeyMgmtProperty[] = "EAP.KeyMgmt"; | |
| 282 | |
| 283 // Flimflam EAP method options. | |
| 284 const char kEapMethodPEAP[] = "PEAP"; | |
| 285 const char kEapMethodTLS[] = "TLS"; | |
| 286 const char kEapMethodTTLS[] = "TTLS"; | |
| 287 const char kEapMethodLEAP[] = "LEAP"; | |
| 288 | |
| 289 // Flimflam EAP phase 2 auth options. | |
| 290 const char kEapPhase2AuthPEAPMD5[] = "auth=MD5"; | |
| 291 const char kEapPhase2AuthPEAPMSCHAPV2[] = "auth=MSCHAPV2"; | |
| 292 const char kEapPhase2AuthTTLSMD5[] = "autheap=MD5"; | |
| 293 const char kEapPhase2AuthTTLSMSCHAPV2[] = "autheap=MSCHAPV2"; | |
| 294 const char kEapPhase2AuthTTLSMSCHAP[] = "autheap=MSCHAP"; | |
| 295 const char kEapPhase2AuthTTLSPAP[] = "autheap=PAP"; | |
| 296 const char kEapPhase2AuthTTLSCHAP[] = "autheap=CHAP"; | |
| 297 | |
| 298 // Flimflam VPN provider types. | |
| 299 const char kProviderL2tpIpsec[] = "l2tpipsec"; | |
| 300 const char kProviderOpenVpn[] = "openvpn"; | |
| 301 | |
| 302 | |
| 303 // Flimflam state options. | |
| 304 const char kStateIdle[] = "idle"; | |
| 305 const char kStateCarrier[] = "carrier"; | |
| 306 const char kStateAssociation[] = "association"; | |
| 307 const char kStateConfiguration[] = "configuration"; | |
| 308 const char kStateReady[] = "ready"; | |
| 309 const char kStatePortal[] = "portal"; | |
| 310 const char kStateOnline[] = "online"; | |
| 311 const char kStateDisconnect[] = "disconnect"; | |
| 312 const char kStateFailure[] = "failure"; | |
| 313 const char kStateActivationFailure[] = "activation-failure"; | |
| 314 | |
| 315 // Flimflam network technology options. | |
| 316 const char kNetworkTechnology1Xrtt[] = "1xRTT"; | |
| 317 const char kNetworkTechnologyEvdo[] = "EVDO"; | |
| 318 const char kNetworkTechnologyGprs[] = "GPRS"; | |
| 319 const char kNetworkTechnologyEdge[] = "EDGE"; | |
| 320 const char kNetworkTechnologyUmts[] = "UMTS"; | |
| 321 const char kNetworkTechnologyHspa[] = "HSPA"; | |
| 322 const char kNetworkTechnologyHspaPlus[] = "HSPA+"; | |
| 323 const char kNetworkTechnologyLte[] = "LTE"; | |
| 324 const char kNetworkTechnologyLteAdvanced[] = "LTE Advanced"; | |
| 325 const char kNetworkTechnologyGsm[] = "GSM"; | |
| 326 | |
| 327 // Flimflam roaming state options | |
| 328 const char kRoamingStateHome[] = "home"; | |
| 329 const char kRoamingStateRoaming[] = "roaming"; | |
| 330 const char kRoamingStateUnknown[] = "unknown"; | |
| 331 | |
| 332 // Flimflam activation state options | |
| 333 const char kActivationStateActivated[] = "activated"; | |
| 334 const char kActivationStateActivating[] = "activating"; | |
| 335 const char kActivationStateNotActivated[] = "not-activated"; | |
| 336 const char kActivationStatePartiallyActivated[] = "partially-activated"; | |
| 337 const char kActivationStateUnknown[] = "unknown"; | |
| 338 | |
| 339 // FlimFlam technology family options | |
| 340 const char kTechnologyFamilyCdma[] = "CDMA"; | |
| 341 const char kTechnologyFamilyGsm[] = "GSM"; | |
| 342 | |
| 343 // Flimflam error options. | |
| 344 const char kErrorOutOfRange[] = "out-of-range"; | |
| 345 const char kErrorPinMissing[] = "pin-missing"; | |
| 346 const char kErrorDhcpFailed[] = "dhcp-failed"; | |
| 347 const char kErrorConnectFailed[] = "connect-failed"; | |
| 348 const char kErrorBadPassphrase[] = "bad-passphrase"; | |
| 349 const char kErrorBadWEPKey[] = "bad-wepkey"; | |
| 350 const char kErrorActivationFailed[] = "activation-failed"; | |
| 351 const char kErrorNeedEvdo[] = "need-evdo"; | |
| 352 const char kErrorNeedHomeNetwork[] = "need-home-network"; | |
| 353 const char kErrorOtaspFailed[] = "otasp-failed"; | |
| 354 const char kErrorAaaFailed[] = "aaa-failed"; | |
| 355 const char kErrorInternal[] = "internal-error"; | |
| 356 const char kErrorDNSLookupFailed[] = "dns-lookup-failed"; | |
| 357 const char kErrorHTTPGetFailed[] = "http-get-failed"; | |
| 358 | |
| 359 // Flimflam error messages. | |
| 360 const char kErrorPassphraseRequiredMsg[] = "Passphrase required"; | |
| 361 const char kErrorIncorrectPinMsg[] = "org.chromium.flimflam.Error.IncorrectPin"; | |
| 362 const char kErrorPinBlockedMsg[] = "org.chromium.flimflam.Error.PinBlocked"; | |
| 363 const char kErrorPinRequiredMsg[] = "org.chromium.flimflam.Error.PinRequired"; | |
| 364 | |
| 365 const char kUnknownString[] = "UNKNOWN"; | |
| 366 | |
| 367 //////////////////////////////////////////////////////////////////////////// | |
| 368 | |
| 369 static const char* ConnectionTypeToString(ConnectionType type) { | |
| 370 switch (type) { | |
| 371 case TYPE_UNKNOWN: | |
| 372 break; | |
| 373 case TYPE_ETHERNET: | |
| 374 return kTypeEthernet; | |
| 375 case TYPE_WIFI: | |
| 376 return kTypeWifi; | |
| 377 case TYPE_WIMAX: | |
| 378 return kTypeWimax; | |
| 379 case TYPE_BLUETOOTH: | |
| 380 return kTypeBluetooth; | |
| 381 case TYPE_CELLULAR: | |
| 382 return kTypeCellular; | |
| 383 case TYPE_VPN: | |
| 384 return kTypeVPN; | |
| 385 } | |
| 386 LOG(ERROR) << "ConnectionTypeToString called with unknown type: " << type; | |
| 387 return kUnknownString; | |
| 388 } | |
| 389 | |
| 390 static const char* SecurityToString(ConnectionSecurity security) { | |
| 391 switch (security) { | |
| 392 case SECURITY_NONE: | |
| 393 return kSecurityNone; | |
| 394 case SECURITY_WEP: | |
| 395 return kSecurityWep; | |
| 396 case SECURITY_WPA: | |
| 397 return kSecurityWpa; | |
| 398 case SECURITY_RSN: | |
| 399 return kSecurityRsn; | |
| 400 case SECURITY_8021X: | |
| 401 return kSecurity8021x; | |
| 402 case SECURITY_PSK: | |
| 403 return kSecurityPsk; | |
| 404 case SECURITY_UNKNOWN: | |
| 405 break; | |
| 406 } | |
| 407 LOG(ERROR) << "SecurityToString called with unknown type: " << security; | |
| 408 return kUnknownString; | |
| 409 } | |
| 410 | |
| 411 static const char* ProviderTypeToString(VirtualNetwork::ProviderType type) { | |
| 412 switch (type) { | |
| 413 case VirtualNetwork::PROVIDER_TYPE_L2TP_IPSEC_PSK: | |
| 414 case VirtualNetwork::PROVIDER_TYPE_L2TP_IPSEC_USER_CERT: | |
| 415 return kProviderL2tpIpsec; | |
| 416 case VirtualNetwork::PROVIDER_TYPE_OPEN_VPN: | |
| 417 return kProviderOpenVpn; | |
| 418 case VirtualNetwork::PROVIDER_TYPE_MAX: | |
| 419 break; | |
| 420 } | |
| 421 LOG(ERROR) << "ProviderTypeToString called with unknown type: " << type; | |
| 422 return kUnknownString; | |
| 423 } | |
| 424 | |
| 425 //////////////////////////////////////////////////////////////////////////// | |
| 426 | |
| 427 // Helper class to cache maps of strings to enums. | |
| 428 template <typename Type> | |
| 429 class StringToEnum { | |
| 430 public: | |
| 431 struct Pair { | |
| 432 const char* key; | |
| 433 const Type value; | |
| 434 }; | |
| 435 | |
| 436 StringToEnum(const Pair* list, size_t num_entries, Type unknown) | |
| 437 : unknown_value_(unknown) { | |
| 438 for (size_t i = 0; i < num_entries; ++i, ++list) | |
| 439 enum_map_[list->key] = list->value; | |
| 440 } | |
| 441 | |
| 442 Type Get(const std::string& type) const { | |
| 443 EnumMapConstIter iter = enum_map_.find(type); | |
| 444 if (iter != enum_map_.end()) | |
| 445 return iter->second; | |
| 446 return unknown_value_; | |
| 447 } | |
| 448 | |
| 449 private: | |
| 450 typedef typename std::map<std::string, Type> EnumMap; | |
| 451 typedef typename std::map<std::string, Type>::const_iterator EnumMapConstIter; | |
| 452 EnumMap enum_map_; | |
| 453 Type unknown_value_; | |
| 454 DISALLOW_COPY_AND_ASSIGN(StringToEnum); | |
| 455 }; | |
| 456 | |
| 457 //////////////////////////////////////////////////////////////////////////// | |
| 458 | |
| 459 enum PropertyIndex { | |
| 460 PROPERTY_INDEX_ACTIVATION_STATE, | |
| 461 PROPERTY_INDEX_ACTIVE_PROFILE, | |
| 462 PROPERTY_INDEX_AUTO_CONNECT, | |
| 463 PROPERTY_INDEX_AVAILABLE_TECHNOLOGIES, | |
| 464 PROPERTY_INDEX_CARRIER, | |
| 465 PROPERTY_INDEX_CELLULAR_ALLOW_ROAMING, | |
| 466 PROPERTY_INDEX_CELLULAR_APN, | |
| 467 PROPERTY_INDEX_CELLULAR_APN_LIST, | |
| 468 PROPERTY_INDEX_CELLULAR_LAST_GOOD_APN, | |
| 469 PROPERTY_INDEX_CHECK_PORTAL_LIST, | |
| 470 PROPERTY_INDEX_CONNECTABLE, | |
| 471 PROPERTY_INDEX_CONNECTED_TECHNOLOGIES, | |
| 472 PROPERTY_INDEX_CONNECTIVITY_STATE, | |
| 473 PROPERTY_INDEX_DEFAULT_TECHNOLOGY, | |
| 474 PROPERTY_INDEX_DEVICE, | |
| 475 PROPERTY_INDEX_DEVICES, | |
| 476 PROPERTY_INDEX_EAP_ANONYMOUS_IDENTITY, | |
| 477 PROPERTY_INDEX_EAP_CA_CERT, | |
| 478 PROPERTY_INDEX_EAP_CA_CERT_ID, | |
| 479 PROPERTY_INDEX_EAP_CA_CERT_NSS, | |
| 480 PROPERTY_INDEX_EAP_CERT_ID, | |
| 481 PROPERTY_INDEX_EAP_CLIENT_CERT, | |
| 482 PROPERTY_INDEX_EAP_CLIENT_CERT_NSS, | |
| 483 PROPERTY_INDEX_EAP_IDENTITY, | |
| 484 PROPERTY_INDEX_EAP_KEY_ID, | |
| 485 PROPERTY_INDEX_EAP_KEY_MGMT, | |
| 486 PROPERTY_INDEX_EAP_METHOD, | |
| 487 PROPERTY_INDEX_EAP_PASSWORD, | |
| 488 PROPERTY_INDEX_EAP_PHASE_2_AUTH, | |
| 489 PROPERTY_INDEX_EAP_PIN, | |
| 490 PROPERTY_INDEX_EAP_PRIVATE_KEY, | |
| 491 PROPERTY_INDEX_EAP_PRIVATE_KEY_PASSWORD, | |
| 492 PROPERTY_INDEX_EAP_USE_SYSTEM_CAS, | |
| 493 PROPERTY_INDEX_ENABLED_TECHNOLOGIES, | |
| 494 PROPERTY_INDEX_ERROR, | |
| 495 PROPERTY_INDEX_ESN, | |
| 496 PROPERTY_INDEX_FAVORITE, | |
| 497 PROPERTY_INDEX_FIRMWARE_REVISION, | |
| 498 PROPERTY_INDEX_FOUND_NETWORKS, | |
| 499 PROPERTY_INDEX_HARDWARE_REVISION, | |
| 500 PROPERTY_INDEX_HOME_PROVIDER, | |
| 501 PROPERTY_INDEX_HOST, | |
| 502 PROPERTY_INDEX_IDENTITY, | |
| 503 PROPERTY_INDEX_IMEI, | |
| 504 PROPERTY_INDEX_IMSI, | |
| 505 PROPERTY_INDEX_IS_ACTIVE, | |
| 506 PROPERTY_INDEX_L2TPIPSEC_CA_CERT_NSS, | |
| 507 PROPERTY_INDEX_L2TPIPSEC_CLIENT_CERT_ID, | |
| 508 PROPERTY_INDEX_L2TPIPSEC_CLIENT_CERT_SLOT, | |
| 509 PROPERTY_INDEX_L2TPIPSEC_PASSWORD, | |
| 510 PROPERTY_INDEX_L2TPIPSEC_PIN, | |
| 511 PROPERTY_INDEX_L2TPIPSEC_PSK, | |
| 512 PROPERTY_INDEX_L2TPIPSEC_USER, | |
| 513 PROPERTY_INDEX_MANUFACTURER, | |
| 514 PROPERTY_INDEX_MDN, | |
| 515 PROPERTY_INDEX_MEID, | |
| 516 PROPERTY_INDEX_MIN, | |
| 517 PROPERTY_INDEX_MODE, | |
| 518 PROPERTY_INDEX_MODEL_ID, | |
| 519 PROPERTY_INDEX_NAME, | |
| 520 PROPERTY_INDEX_NETWORKS, | |
| 521 PROPERTY_INDEX_NETWORK_TECHNOLOGY, | |
| 522 PROPERTY_INDEX_OFFLINE_MODE, | |
| 523 PROPERTY_INDEX_OPERATOR_CODE, | |
| 524 PROPERTY_INDEX_OPERATOR_NAME, | |
| 525 PROPERTY_INDEX_PASSPHRASE, | |
| 526 PROPERTY_INDEX_PASSPHRASE_REQUIRED, | |
| 527 PROPERTY_INDEX_PAYMENT_URL, | |
| 528 PROPERTY_INDEX_PORTAL_URL, | |
| 529 PROPERTY_INDEX_POWERED, | |
| 530 PROPERTY_INDEX_PRIORITY, | |
| 531 PROPERTY_INDEX_PRL_VERSION, | |
| 532 PROPERTY_INDEX_PROFILE, | |
| 533 PROPERTY_INDEX_PROFILES, | |
| 534 PROPERTY_INDEX_PROVIDER, | |
| 535 PROPERTY_INDEX_PROXY_CONFIG, | |
| 536 PROPERTY_INDEX_ROAMING_STATE, | |
| 537 PROPERTY_INDEX_SAVE_CREDENTIALS, | |
| 538 PROPERTY_INDEX_SCANNING, | |
| 539 PROPERTY_INDEX_SECURITY, | |
| 540 PROPERTY_INDEX_SELECTED_NETWORK, | |
| 541 PROPERTY_INDEX_SERVICES, | |
| 542 PROPERTY_INDEX_SERVICE_WATCH_LIST, | |
| 543 PROPERTY_INDEX_SERVING_OPERATOR, | |
| 544 PROPERTY_INDEX_SIGNAL_STRENGTH, | |
| 545 PROPERTY_INDEX_SIM_LOCK, | |
| 546 PROPERTY_INDEX_STATE, | |
| 547 PROPERTY_INDEX_SUPPORT_NETWORK_SCAN, | |
| 548 PROPERTY_INDEX_TECHNOLOGY_FAMILY, | |
| 549 PROPERTY_INDEX_TYPE, | |
| 550 PROPERTY_INDEX_UNKNOWN, | |
| 551 PROPERTY_INDEX_USAGE_URL, | |
| 552 PROPERTY_INDEX_WIFI_AUTH_MODE, | |
| 553 PROPERTY_INDEX_WIFI_FREQUENCY, | |
| 554 PROPERTY_INDEX_WIFI_HEX_SSID, | |
| 555 PROPERTY_INDEX_WIFI_HIDDEN_SSID, | |
| 556 PROPERTY_INDEX_WIFI_PHY_MODE, | |
| 557 }; | |
| 558 | |
| 559 StringToEnum<PropertyIndex>::Pair property_index_table[] = { | |
| 560 { kActivationStateProperty, PROPERTY_INDEX_ACTIVATION_STATE }, | |
| 561 { kActiveProfileProperty, PROPERTY_INDEX_ACTIVE_PROFILE }, | |
| 562 { kAutoConnectProperty, PROPERTY_INDEX_AUTO_CONNECT }, | |
| 563 { kAvailableTechnologiesProperty, PROPERTY_INDEX_AVAILABLE_TECHNOLOGIES }, | |
| 564 { kCarrierProperty, PROPERTY_INDEX_CARRIER }, | |
| 565 { kCellularAllowRoamingProperty, PROPERTY_INDEX_CELLULAR_ALLOW_ROAMING }, | |
| 566 { kCellularApnListProperty, PROPERTY_INDEX_CELLULAR_APN_LIST }, | |
| 567 { kCellularApnProperty, PROPERTY_INDEX_CELLULAR_APN }, | |
| 568 { kCellularLastGoodApnProperty, PROPERTY_INDEX_CELLULAR_LAST_GOOD_APN }, | |
| 569 { kCheckPortalListProperty, PROPERTY_INDEX_CHECK_PORTAL_LIST }, | |
| 570 { kConnectableProperty, PROPERTY_INDEX_CONNECTABLE }, | |
| 571 { kConnectedTechnologiesProperty, PROPERTY_INDEX_CONNECTED_TECHNOLOGIES }, | |
| 572 { kDefaultTechnologyProperty, PROPERTY_INDEX_DEFAULT_TECHNOLOGY }, | |
| 573 { kDeviceProperty, PROPERTY_INDEX_DEVICE }, | |
| 574 { kDevicesProperty, PROPERTY_INDEX_DEVICES }, | |
| 575 { kEapAnonymousIdentityProperty, PROPERTY_INDEX_EAP_ANONYMOUS_IDENTITY }, | |
| 576 { kEapCaCertIDProperty, PROPERTY_INDEX_EAP_CA_CERT_ID }, | |
| 577 { kEapCaCertNssProperty, PROPERTY_INDEX_EAP_CA_CERT_NSS }, | |
| 578 { kEapCaCertProperty, PROPERTY_INDEX_EAP_CA_CERT }, | |
| 579 { kEapCertIDProperty, PROPERTY_INDEX_EAP_CERT_ID }, | |
| 580 { kEapClientCertNssProperty, PROPERTY_INDEX_EAP_CLIENT_CERT_NSS }, | |
| 581 { kEapClientCertProperty, PROPERTY_INDEX_EAP_CLIENT_CERT }, | |
| 582 { kEapIdentityProperty, PROPERTY_INDEX_EAP_IDENTITY }, | |
| 583 { kEapKeyIDProperty, PROPERTY_INDEX_EAP_KEY_ID }, | |
| 584 { kEapKeyMgmtProperty, PROPERTY_INDEX_EAP_KEY_MGMT }, | |
| 585 { kEapMethodProperty, PROPERTY_INDEX_EAP_METHOD }, | |
| 586 { kEapPasswordProperty, PROPERTY_INDEX_EAP_PASSWORD }, | |
| 587 { kEapPhase2AuthProperty, PROPERTY_INDEX_EAP_PHASE_2_AUTH }, | |
| 588 { kEapPinProperty, PROPERTY_INDEX_EAP_PIN }, | |
| 589 { kEapPrivateKeyPasswordProperty, PROPERTY_INDEX_EAP_PRIVATE_KEY_PASSWORD }, | |
| 590 { kEapPrivateKeyProperty, PROPERTY_INDEX_EAP_PRIVATE_KEY }, | |
| 591 { kEapUseSystemCAsProperty, PROPERTY_INDEX_EAP_USE_SYSTEM_CAS }, | |
| 592 { kEnabledTechnologiesProperty, PROPERTY_INDEX_ENABLED_TECHNOLOGIES }, | |
| 593 { kErrorProperty, PROPERTY_INDEX_ERROR }, | |
| 594 { kEsnProperty, PROPERTY_INDEX_ESN }, | |
| 595 { kFavoriteProperty, PROPERTY_INDEX_FAVORITE }, | |
| 596 { kFirmwareRevisionProperty, PROPERTY_INDEX_FIRMWARE_REVISION }, | |
| 597 { kFoundNetworksProperty, PROPERTY_INDEX_FOUND_NETWORKS }, | |
| 598 { kHardwareRevisionProperty, PROPERTY_INDEX_HARDWARE_REVISION }, | |
| 599 { kHomeProviderProperty, PROPERTY_INDEX_HOME_PROVIDER }, | |
| 600 { kHostProperty, PROPERTY_INDEX_HOST }, | |
| 601 { kIdentityProperty, PROPERTY_INDEX_IDENTITY }, | |
| 602 { kImeiProperty, PROPERTY_INDEX_IMEI }, | |
| 603 { kImsiProperty, PROPERTY_INDEX_IMSI }, | |
| 604 { kIsActiveProperty, PROPERTY_INDEX_IS_ACTIVE }, | |
| 605 { kL2TPIPSecCACertNSSProperty, PROPERTY_INDEX_L2TPIPSEC_CA_CERT_NSS }, | |
| 606 { kL2TPIPSecClientCertIDProperty, PROPERTY_INDEX_L2TPIPSEC_CLIENT_CERT_ID }, | |
| 607 { kL2TPIPSecClientCertSlotProp, PROPERTY_INDEX_L2TPIPSEC_CLIENT_CERT_SLOT }, | |
| 608 { kL2TPIPSecPasswordProperty, PROPERTY_INDEX_L2TPIPSEC_PASSWORD }, | |
| 609 { kL2TPIPSecPINProperty, PROPERTY_INDEX_L2TPIPSEC_PIN }, | |
| 610 { kL2TPIPSecPSKProperty, PROPERTY_INDEX_L2TPIPSEC_PSK }, | |
| 611 { kL2TPIPSecUserProperty, PROPERTY_INDEX_L2TPIPSEC_USER }, | |
| 612 { kManufacturerProperty, PROPERTY_INDEX_MANUFACTURER }, | |
| 613 { kMdnProperty, PROPERTY_INDEX_MDN }, | |
| 614 { kMeidProperty, PROPERTY_INDEX_MEID }, | |
| 615 { kMinProperty, PROPERTY_INDEX_MIN }, | |
| 616 { kModeProperty, PROPERTY_INDEX_MODE }, | |
| 617 { kModelIDProperty, PROPERTY_INDEX_MODEL_ID }, | |
| 618 { kNameProperty, PROPERTY_INDEX_NAME }, | |
| 619 { kNetworkTechnologyProperty, PROPERTY_INDEX_NETWORK_TECHNOLOGY }, | |
| 620 { kNetworksProperty, PROPERTY_INDEX_NETWORKS }, | |
| 621 { kOfflineModeProperty, PROPERTY_INDEX_OFFLINE_MODE }, | |
| 622 { kOperatorCodeProperty, PROPERTY_INDEX_OPERATOR_CODE }, | |
| 623 { kOperatorNameProperty, PROPERTY_INDEX_OPERATOR_NAME }, | |
| 624 { kPRLVersionProperty, PROPERTY_INDEX_PRL_VERSION }, | |
| 625 { kPassphraseProperty, PROPERTY_INDEX_PASSPHRASE }, | |
| 626 { kPassphraseRequiredProperty, PROPERTY_INDEX_PASSPHRASE_REQUIRED }, | |
| 627 { kPaymentURLProperty, PROPERTY_INDEX_PAYMENT_URL }, | |
| 628 { kPortalURLProperty, PROPERTY_INDEX_PORTAL_URL }, | |
| 629 { kPoweredProperty, PROPERTY_INDEX_POWERED }, | |
| 630 { kPriorityProperty, PROPERTY_INDEX_PRIORITY }, | |
| 631 { kProfileProperty, PROPERTY_INDEX_PROFILE }, | |
| 632 { kProfilesProperty, PROPERTY_INDEX_PROFILES }, | |
| 633 { kProviderProperty, PROPERTY_INDEX_PROVIDER }, | |
| 634 { kProxyConfigProperty, PROPERTY_INDEX_PROXY_CONFIG }, | |
| 635 { kRoamingStateProperty, PROPERTY_INDEX_ROAMING_STATE }, | |
| 636 { kSIMLockStatusProperty, PROPERTY_INDEX_SIM_LOCK }, | |
| 637 { kSaveCredentialsProperty, PROPERTY_INDEX_SAVE_CREDENTIALS }, | |
| 638 { kScanningProperty, PROPERTY_INDEX_SCANNING }, | |
| 639 { kSecurityProperty, PROPERTY_INDEX_SECURITY }, | |
| 640 { kSelectedNetworkProperty, PROPERTY_INDEX_SELECTED_NETWORK }, | |
| 641 { kServiceWatchListProperty, PROPERTY_INDEX_SERVICE_WATCH_LIST }, | |
| 642 { kServicesProperty, PROPERTY_INDEX_SERVICES }, | |
| 643 { kServingOperatorProperty, PROPERTY_INDEX_SERVING_OPERATOR }, | |
| 644 { kSignalStrengthProperty, PROPERTY_INDEX_SIGNAL_STRENGTH }, | |
| 645 { kStateProperty, PROPERTY_INDEX_STATE }, | |
| 646 { kSupportNetworkScanProperty, PROPERTY_INDEX_SUPPORT_NETWORK_SCAN }, | |
| 647 { kTechnologyFamilyProperty, PROPERTY_INDEX_TECHNOLOGY_FAMILY }, | |
| 648 { kTypeProperty, PROPERTY_INDEX_TYPE }, | |
| 649 { kUsageURLProperty, PROPERTY_INDEX_USAGE_URL }, | |
| 650 { kWifiAuthMode, PROPERTY_INDEX_WIFI_AUTH_MODE }, | |
| 651 { kWifiFrequency, PROPERTY_INDEX_WIFI_FREQUENCY }, | |
| 652 { kWifiHexSsid, PROPERTY_INDEX_WIFI_HEX_SSID }, | |
| 653 { kWifiHiddenSsid, PROPERTY_INDEX_WIFI_HIDDEN_SSID }, | |
| 654 { kWifiPhyMode, PROPERTY_INDEX_WIFI_PHY_MODE }, | |
| 655 }; | |
| 656 | |
| 657 StringToEnum<PropertyIndex>& property_index_parser() { | |
| 658 static StringToEnum<PropertyIndex> parser(property_index_table, | |
| 659 arraysize(property_index_table), | |
| 660 PROPERTY_INDEX_UNKNOWN); | |
| 661 return parser; | |
| 662 } | |
| 663 | |
| 664 //////////////////////////////////////////////////////////////////////////// | |
| 665 // Parse strings from libcros. | |
| 666 | |
| 667 // Network. | |
| 668 static ConnectionType ParseType(const std::string& type) { | |
| 669 static StringToEnum<ConnectionType>::Pair table[] = { | |
| 670 { kTypeEthernet, TYPE_ETHERNET }, | |
| 671 { kTypeWifi, TYPE_WIFI }, | |
| 672 { kTypeWimax, TYPE_WIMAX }, | |
| 673 { kTypeBluetooth, TYPE_BLUETOOTH }, | |
| 674 { kTypeCellular, TYPE_CELLULAR }, | |
| 675 { kTypeVPN, TYPE_VPN }, | |
| 676 }; | |
| 677 static StringToEnum<ConnectionType> parser( | |
| 678 table, arraysize(table), TYPE_UNKNOWN); | |
| 679 return parser.Get(type); | |
| 680 } | |
| 681 | |
| 682 ConnectionType ParseTypeFromDictionary(const DictionaryValue* info) { | |
| 683 std::string type_string; | |
| 684 info->GetString(kTypeProperty, &type_string); | |
| 685 return ParseType(type_string); | |
| 686 } | |
| 687 | |
| 688 static ConnectionMode ParseMode(const std::string& mode) { | |
| 689 static StringToEnum<ConnectionMode>::Pair table[] = { | |
| 690 { kModeManaged, MODE_MANAGED }, | |
| 691 { kModeAdhoc, MODE_ADHOC }, | |
| 692 }; | |
| 693 static StringToEnum<ConnectionMode> parser( | |
| 694 table, arraysize(table), MODE_UNKNOWN); | |
| 695 return parser.Get(mode); | |
| 696 } | |
| 697 | |
| 698 static ConnectionState ParseState(const std::string& state) { | |
| 699 static StringToEnum<ConnectionState>::Pair table[] = { | |
| 700 { kStateIdle, STATE_IDLE }, | |
| 701 { kStateCarrier, STATE_CARRIER }, | |
| 702 { kStateAssociation, STATE_ASSOCIATION }, | |
| 703 { kStateConfiguration, STATE_CONFIGURATION }, | |
| 704 { kStateReady, STATE_READY }, | |
| 705 { kStateDisconnect, STATE_DISCONNECT }, | |
| 706 { kStateFailure, STATE_FAILURE }, | |
| 707 { kStateActivationFailure, STATE_ACTIVATION_FAILURE }, | |
| 708 { kStatePortal, STATE_PORTAL }, | |
| 709 { kStateOnline, STATE_ONLINE }, | |
| 710 }; | |
| 711 static StringToEnum<ConnectionState> parser( | |
| 712 table, arraysize(table), STATE_UNKNOWN); | |
| 713 return parser.Get(state); | |
| 714 } | |
| 715 | |
| 716 static ConnectionError ParseError(const std::string& error) { | |
| 717 static StringToEnum<ConnectionError>::Pair table[] = { | |
| 718 { kErrorOutOfRange, ERROR_OUT_OF_RANGE }, | |
| 719 { kErrorPinMissing, ERROR_PIN_MISSING }, | |
| 720 { kErrorDhcpFailed, ERROR_DHCP_FAILED }, | |
| 721 { kErrorConnectFailed, ERROR_CONNECT_FAILED }, | |
| 722 { kErrorBadPassphrase, ERROR_BAD_PASSPHRASE }, | |
| 723 { kErrorBadWEPKey, ERROR_BAD_WEPKEY }, | |
| 724 { kErrorActivationFailed, ERROR_ACTIVATION_FAILED }, | |
| 725 { kErrorNeedEvdo, ERROR_NEED_EVDO }, | |
| 726 { kErrorNeedHomeNetwork, ERROR_NEED_HOME_NETWORK }, | |
| 727 { kErrorOtaspFailed, ERROR_OTASP_FAILED }, | |
| 728 { kErrorAaaFailed, ERROR_AAA_FAILED }, | |
| 729 { kErrorInternal, ERROR_INTERNAL }, | |
| 730 { kErrorDNSLookupFailed, ERROR_DNS_LOOKUP_FAILED }, | |
| 731 { kErrorHTTPGetFailed, ERROR_HTTP_GET_FAILED }, | |
| 732 }; | |
| 733 static StringToEnum<ConnectionError> parser( | |
| 734 table, arraysize(table), ERROR_NO_ERROR); | |
| 735 return parser.Get(error); | |
| 736 } | |
| 737 | |
| 738 // VirtualNetwork | |
| 739 static VirtualNetwork::ProviderType ParseProviderType(const std::string& mode) { | |
| 740 static StringToEnum<VirtualNetwork::ProviderType>::Pair table[] = { | |
| 741 { kProviderL2tpIpsec, VirtualNetwork::PROVIDER_TYPE_L2TP_IPSEC_PSK }, | |
| 742 { kProviderOpenVpn, VirtualNetwork::PROVIDER_TYPE_OPEN_VPN }, | |
| 743 }; | |
| 744 static StringToEnum<VirtualNetwork::ProviderType> parser( | |
| 745 table, arraysize(table), VirtualNetwork::PROVIDER_TYPE_MAX); | |
| 746 return parser.Get(mode); | |
| 747 } | |
| 748 | |
| 749 // CellularNetwork. | |
| 750 static ActivationState ParseActivationState(const std::string& state) { | |
| 751 static StringToEnum<ActivationState>::Pair table[] = { | |
| 752 { kActivationStateActivated, ACTIVATION_STATE_ACTIVATED }, | |
| 753 { kActivationStateActivating, ACTIVATION_STATE_ACTIVATING }, | |
| 754 { kActivationStateNotActivated, ACTIVATION_STATE_NOT_ACTIVATED }, | |
| 755 { kActivationStatePartiallyActivated, ACTIVATION_STATE_PARTIALLY_ACTIVATED}, | |
| 756 { kActivationStateUnknown, ACTIVATION_STATE_UNKNOWN}, | |
| 757 }; | |
| 758 static StringToEnum<ActivationState> parser( | |
| 759 table, arraysize(table), ACTIVATION_STATE_UNKNOWN); | |
| 760 return parser.Get(state); | |
| 761 } | |
| 762 | |
| 763 static NetworkTechnology ParseNetworkTechnology(const std::string& technology) { | |
| 764 static StringToEnum<NetworkTechnology>::Pair table[] = { | |
| 765 { kNetworkTechnology1Xrtt, NETWORK_TECHNOLOGY_1XRTT }, | |
| 766 { kNetworkTechnologyEvdo, NETWORK_TECHNOLOGY_EVDO }, | |
| 767 { kNetworkTechnologyGprs, NETWORK_TECHNOLOGY_GPRS }, | |
| 768 { kNetworkTechnologyEdge, NETWORK_TECHNOLOGY_EDGE }, | |
| 769 { kNetworkTechnologyUmts, NETWORK_TECHNOLOGY_UMTS }, | |
| 770 { kNetworkTechnologyHspa, NETWORK_TECHNOLOGY_HSPA }, | |
| 771 { kNetworkTechnologyHspaPlus, NETWORK_TECHNOLOGY_HSPA_PLUS }, | |
| 772 { kNetworkTechnologyLte, NETWORK_TECHNOLOGY_LTE }, | |
| 773 { kNetworkTechnologyLteAdvanced, NETWORK_TECHNOLOGY_LTE_ADVANCED }, | |
| 774 { kNetworkTechnologyGsm, NETWORK_TECHNOLOGY_GSM }, | |
| 775 }; | |
| 776 static StringToEnum<NetworkTechnology> parser( | |
| 777 table, arraysize(table), NETWORK_TECHNOLOGY_UNKNOWN); | |
| 778 return parser.Get(technology); | |
| 779 } | |
| 780 | |
| 781 static SIMLockState ParseSimLockState(const std::string& state) { | |
| 782 static StringToEnum<SIMLockState>::Pair table[] = { | |
| 783 { "", SIM_UNLOCKED }, | |
| 784 { kSIMLockPin, SIM_LOCKED_PIN }, | |
| 785 { kSIMLockPuk, SIM_LOCKED_PUK }, | |
| 786 }; | |
| 787 static StringToEnum<SIMLockState> parser( | |
| 788 table, arraysize(table), SIM_UNKNOWN); | |
| 789 SIMLockState parsed_state = parser.Get(state); | |
| 790 DCHECK_NE(parsed_state, SIM_UNKNOWN) << "Unknown SIMLock state encountered"; | |
| 791 return parsed_state; | |
| 792 } | |
| 793 | |
| 794 static bool ParseSimLockStateFromDictionary(const DictionaryValue* info, | |
| 795 SIMLockState* out_state, | |
| 796 int* out_retries) { | |
| 797 std::string state_string; | |
| 798 if (!info->GetString(kSIMLockTypeProperty, &state_string) || | |
| 799 !info->GetInteger(kSIMLockRetriesLeftProperty, out_retries)) { | |
| 800 LOG(ERROR) << "Error parsing SIMLock state"; | |
| 801 return false; | |
| 802 } | |
| 803 *out_state = ParseSimLockState(state_string); | |
| 804 return true; | |
| 805 } | |
| 806 | |
| 807 static bool ParseFoundNetworksFromList(const ListValue* list, | |
| 808 CellularNetworkList* found_networks_) { | |
| 809 found_networks_->clear(); | |
| 810 found_networks_->reserve(list->GetSize()); | |
| 811 for (ListValue::const_iterator it = list->begin(); it != list->end(); ++it) { | |
| 812 if ((*it)->IsType(Value::TYPE_DICTIONARY)) { | |
| 813 found_networks_->resize(found_networks_->size() + 1); | |
| 814 const DictionaryValue* dict = static_cast<const DictionaryValue*>(*it); | |
| 815 dict->GetStringWithoutPathExpansion( | |
| 816 kStatusProperty, &found_networks_->back().status); | |
| 817 dict->GetStringWithoutPathExpansion( | |
| 818 kNetworkIdProperty, &found_networks_->back().network_id); | |
| 819 dict->GetStringWithoutPathExpansion( | |
| 820 kShortNameProperty, &found_networks_->back().short_name); | |
| 821 dict->GetStringWithoutPathExpansion( | |
| 822 kLongNameProperty, &found_networks_->back().long_name); | |
| 823 dict->GetStringWithoutPathExpansion( | |
| 824 kTechnologyProperty, &found_networks_->back().technology); | |
| 825 } else { | |
| 826 return false; | |
| 827 } | |
| 828 } | |
| 829 return true; | |
| 830 } | |
| 831 | |
| 832 static bool ParseApnList(const ListValue* list, | |
| 833 CellularApnList* apn_list) { | |
| 834 apn_list->clear(); | |
| 835 apn_list->reserve(list->GetSize()); | |
| 836 for (ListValue::const_iterator it = list->begin(); it != list->end(); ++it) { | |
| 837 if ((*it)->IsType(Value::TYPE_DICTIONARY)) { | |
| 838 apn_list->resize(apn_list->size() + 1); | |
| 839 apn_list->back().Set(*static_cast<const DictionaryValue*>(*it)); | |
| 840 } else { | |
| 841 return false; | |
| 842 } | |
| 843 } | |
| 844 return true; | |
| 845 } | |
| 846 | |
| 847 static NetworkRoamingState ParseRoamingState(const std::string& roaming_state) { | |
| 848 static StringToEnum<NetworkRoamingState>::Pair table[] = { | |
| 849 { kRoamingStateHome, ROAMING_STATE_HOME }, | |
| 850 { kRoamingStateRoaming, ROAMING_STATE_ROAMING }, | |
| 851 { kRoamingStateUnknown, ROAMING_STATE_UNKNOWN }, | |
| 852 }; | |
| 853 static StringToEnum<NetworkRoamingState> parser( | |
| 854 table, arraysize(table), ROAMING_STATE_UNKNOWN); | |
| 855 return parser.Get(roaming_state); | |
| 856 } | |
| 857 | |
| 858 // WifiNetwork | |
| 859 static ConnectionSecurity ParseSecurity(const std::string& security) { | |
| 860 static StringToEnum<ConnectionSecurity>::Pair table[] = { | |
| 861 { kSecurityNone, SECURITY_NONE }, | |
| 862 { kSecurityWep, SECURITY_WEP }, | |
| 863 { kSecurityWpa, SECURITY_WPA }, | |
| 864 { kSecurityRsn, SECURITY_RSN }, | |
| 865 { kSecurityPsk, SECURITY_PSK }, | |
| 866 { kSecurity8021x, SECURITY_8021X }, | |
| 867 }; | |
| 868 static StringToEnum<ConnectionSecurity> parser( | |
| 869 table, arraysize(table), SECURITY_UNKNOWN); | |
| 870 return parser.Get(security); | |
| 871 } | |
| 872 | |
| 873 static EAPMethod ParseEAPMethod(const std::string& method) { | |
| 874 static StringToEnum<EAPMethod>::Pair table[] = { | |
| 875 { kEapMethodPEAP, EAP_METHOD_PEAP }, | |
| 876 { kEapMethodTLS, EAP_METHOD_TLS }, | |
| 877 { kEapMethodTTLS, EAP_METHOD_TTLS }, | |
| 878 { kEapMethodLEAP, EAP_METHOD_LEAP }, | |
| 879 }; | |
| 880 static StringToEnum<EAPMethod> parser( | |
| 881 table, arraysize(table), EAP_METHOD_UNKNOWN); | |
| 882 return parser.Get(method); | |
| 883 } | |
| 884 | |
| 885 static EAPPhase2Auth ParseEAPPhase2Auth(const std::string& auth) { | |
| 886 static StringToEnum<EAPPhase2Auth>::Pair table[] = { | |
| 887 { kEapPhase2AuthPEAPMD5, EAP_PHASE_2_AUTH_MD5 }, | |
| 888 { kEapPhase2AuthPEAPMSCHAPV2, EAP_PHASE_2_AUTH_MSCHAPV2 }, | |
| 889 { kEapPhase2AuthTTLSMD5, EAP_PHASE_2_AUTH_MD5 }, | |
| 890 { kEapPhase2AuthTTLSMSCHAPV2, EAP_PHASE_2_AUTH_MSCHAPV2 }, | |
| 891 { kEapPhase2AuthTTLSMSCHAP, EAP_PHASE_2_AUTH_MSCHAP }, | |
| 892 { kEapPhase2AuthTTLSPAP, EAP_PHASE_2_AUTH_PAP }, | |
| 893 { kEapPhase2AuthTTLSCHAP, EAP_PHASE_2_AUTH_CHAP }, | |
| 894 }; | |
| 895 static StringToEnum<EAPPhase2Auth> parser( | |
| 896 table, arraysize(table), EAP_PHASE_2_AUTH_AUTO); | |
| 897 return parser.Get(auth); | |
| 898 } | |
| 899 | |
| 900 // NetworkDevice | |
| 901 static TechnologyFamily ParseTechnologyFamily(const std::string& family) { | |
| 902 static StringToEnum<TechnologyFamily>::Pair table[] = { | |
| 903 { kTechnologyFamilyCdma, TECHNOLOGY_FAMILY_CDMA }, | |
| 904 { kTechnologyFamilyGsm, TECHNOLOGY_FAMILY_GSM }, | |
| 905 }; | |
| 906 static StringToEnum<TechnologyFamily> parser( | |
| 907 table, arraysize(table), TECHNOLOGY_FAMILY_UNKNOWN); | |
| 908 return parser.Get(family); | |
| 909 } | |
| 910 | |
| 911 //////////////////////////////////////////////////////////////////////////////// | 107 //////////////////////////////////////////////////////////////////////////////// |
| 912 // Misc. | 108 // Misc. |
| 913 | 109 |
| 914 // Safe string constructor since we can't rely on non NULL pointers | 110 // Safe string constructor since we can't rely on non NULL pointers |
| 915 // for string values from libcros. | 111 // for string values from libcros. |
| 916 static std::string SafeString(const char* s) { | 112 static std::string SafeString(const char* s) { |
| 917 return s ? std::string(s) : std::string(); | 113 return s ? std::string(s) : std::string(); |
| 918 } | 114 } |
| 919 | 115 |
| 920 // Erase the memory used by a string, then clear it. | 116 // Erase the memory used by a string, then clear it. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 961 //////////////////////////////////////////////////////////////////////////////// | 157 //////////////////////////////////////////////////////////////////////////////// |
| 962 // NetworkDevice | 158 // NetworkDevice |
| 963 | 159 |
| 964 NetworkDevice::NetworkDevice(const std::string& device_path) | 160 NetworkDevice::NetworkDevice(const std::string& device_path) |
| 965 : device_path_(device_path), | 161 : device_path_(device_path), |
| 966 type_(TYPE_UNKNOWN), | 162 type_(TYPE_UNKNOWN), |
| 967 scanning_(false), | 163 scanning_(false), |
| 968 sim_lock_state_(SIM_UNKNOWN), | 164 sim_lock_state_(SIM_UNKNOWN), |
| 969 sim_retries_left_(kDefaultSimUnlockRetriesCount), | 165 sim_retries_left_(kDefaultSimUnlockRetriesCount), |
| 970 sim_pin_required_(SIM_PIN_REQUIRE_UNKNOWN), | 166 sim_pin_required_(SIM_PIN_REQUIRE_UNKNOWN), |
| 971 PRL_version_(0), | 167 prl_version_(0), |
| 972 data_roaming_allowed_(false), | 168 data_roaming_allowed_(false), |
| 973 support_network_scan_(false) { | 169 support_network_scan_(false), |
| 170 device_parser_(new NativeNetworkDeviceParser) { | |
| 974 } | 171 } |
| 975 | 172 |
| 976 NetworkDevice::~NetworkDevice() {} | 173 NetworkDevice::~NetworkDevice() {} |
| 977 | 174 |
| 978 bool NetworkDevice::ParseValue(int index, const Value* value) { | 175 void NetworkDevice::ParseInfo(const DictionaryValue& info) { |
| 979 switch (index) { | 176 if (device_parser_.get()) |
| 980 case PROPERTY_INDEX_TYPE: { | 177 device_parser_->UpdateDeviceFromInfo(info, this); |
| 981 std::string type_string; | |
| 982 if (value->GetAsString(&type_string)) { | |
| 983 type_ = ParseType(type_string); | |
| 984 return true; | |
| 985 } | |
| 986 break; | |
| 987 } | |
| 988 case PROPERTY_INDEX_NAME: | |
| 989 return value->GetAsString(&name_); | |
| 990 case PROPERTY_INDEX_CARRIER: | |
| 991 return value->GetAsString(&carrier_); | |
| 992 case PROPERTY_INDEX_SCANNING: | |
| 993 return value->GetAsBoolean(&scanning_); | |
| 994 case PROPERTY_INDEX_CELLULAR_ALLOW_ROAMING: | |
| 995 return value->GetAsBoolean(&data_roaming_allowed_); | |
| 996 case PROPERTY_INDEX_CELLULAR_APN_LIST: | |
| 997 if (value->IsType(Value::TYPE_LIST)) { | |
| 998 return ParseApnList(static_cast<const ListValue*>(value), | |
| 999 &provider_apn_list_); | |
| 1000 } | |
| 1001 break; | |
| 1002 case PROPERTY_INDEX_NETWORKS: | |
| 1003 if (value->IsType(Value::TYPE_LIST)) { | |
| 1004 // Ignored. | |
| 1005 return true; | |
| 1006 } | |
| 1007 break; | |
| 1008 case PROPERTY_INDEX_FOUND_NETWORKS: | |
| 1009 if (value->IsType(Value::TYPE_LIST)) { | |
| 1010 return ParseFoundNetworksFromList( | |
| 1011 static_cast<const ListValue*>(value), | |
| 1012 &found_cellular_networks_); | |
| 1013 } | |
| 1014 break; | |
| 1015 case PROPERTY_INDEX_HOME_PROVIDER: { | |
| 1016 if (value->IsType(Value::TYPE_DICTIONARY)) { | |
| 1017 const DictionaryValue* dict = | |
| 1018 static_cast<const DictionaryValue*>(value); | |
| 1019 home_provider_code_.clear(); | |
| 1020 home_provider_country_.clear(); | |
| 1021 home_provider_name_.clear(); | |
| 1022 dict->GetStringWithoutPathExpansion(kOperatorCodeKey, | |
| 1023 &home_provider_code_); | |
| 1024 dict->GetStringWithoutPathExpansion(kOperatorCountryKey, | |
| 1025 &home_provider_country_); | |
| 1026 dict->GetStringWithoutPathExpansion(kOperatorNameKey, | |
| 1027 &home_provider_name_); | |
| 1028 if (!home_provider_name_.empty() && !home_provider_country_.empty()) { | |
| 1029 home_provider_id_ = base::StringPrintf( | |
| 1030 kCarrierIdFormat, | |
| 1031 home_provider_name_.c_str(), | |
| 1032 home_provider_country_.c_str()); | |
| 1033 } else { | |
| 1034 home_provider_id_ = home_provider_code_; | |
| 1035 LOG(WARNING) << "Carrier ID not defined, using code instead: " | |
| 1036 << home_provider_id_; | |
| 1037 } | |
| 1038 return true; | |
| 1039 } | |
| 1040 break; | |
| 1041 } | |
| 1042 case PROPERTY_INDEX_MEID: | |
| 1043 return value->GetAsString(&MEID_); | |
| 1044 case PROPERTY_INDEX_IMEI: | |
| 1045 return value->GetAsString(&IMEI_); | |
| 1046 case PROPERTY_INDEX_IMSI: | |
| 1047 return value->GetAsString(&IMSI_); | |
| 1048 case PROPERTY_INDEX_ESN: | |
| 1049 return value->GetAsString(&ESN_); | |
| 1050 case PROPERTY_INDEX_MDN: | |
| 1051 return value->GetAsString(&MDN_); | |
| 1052 case PROPERTY_INDEX_MIN: | |
| 1053 return value->GetAsString(&MIN_); | |
| 1054 case PROPERTY_INDEX_MODEL_ID: | |
| 1055 return value->GetAsString(&model_id_); | |
| 1056 case PROPERTY_INDEX_MANUFACTURER: | |
| 1057 return value->GetAsString(&manufacturer_); | |
| 1058 case PROPERTY_INDEX_SIM_LOCK: | |
| 1059 if (value->IsType(Value::TYPE_DICTIONARY)) { | |
| 1060 bool result = ParseSimLockStateFromDictionary( | |
| 1061 static_cast<const DictionaryValue*>(value), | |
| 1062 &sim_lock_state_, | |
| 1063 &sim_retries_left_); | |
| 1064 // Initialize PinRequired value only once. | |
| 1065 // See SIMPinRequire enum comments. | |
| 1066 if (sim_pin_required_ == SIM_PIN_REQUIRE_UNKNOWN) { | |
| 1067 if (sim_lock_state_ == SIM_UNLOCKED) { | |
| 1068 sim_pin_required_ = SIM_PIN_NOT_REQUIRED; | |
| 1069 } else if (sim_lock_state_ == SIM_LOCKED_PIN || | |
| 1070 sim_lock_state_ == SIM_LOCKED_PUK) { | |
| 1071 sim_pin_required_ = SIM_PIN_REQUIRED; | |
| 1072 } | |
| 1073 } | |
| 1074 return result; | |
| 1075 } | |
| 1076 break; | |
| 1077 case PROPERTY_INDEX_FIRMWARE_REVISION: | |
| 1078 return value->GetAsString(&firmware_revision_); | |
| 1079 case PROPERTY_INDEX_HARDWARE_REVISION: | |
| 1080 return value->GetAsString(&hardware_revision_); | |
| 1081 case PROPERTY_INDEX_POWERED: | |
| 1082 // we don't care about the value, just the fact that it changed | |
| 1083 return true; | |
| 1084 case PROPERTY_INDEX_PRL_VERSION: | |
| 1085 return value->GetAsInteger(&PRL_version_); | |
| 1086 case PROPERTY_INDEX_SELECTED_NETWORK: | |
| 1087 return value->GetAsString(&selected_cellular_network_); | |
| 1088 case PROPERTY_INDEX_SUPPORT_NETWORK_SCAN: | |
| 1089 return value->GetAsBoolean(&support_network_scan_); | |
| 1090 case PROPERTY_INDEX_TECHNOLOGY_FAMILY: { | |
| 1091 std::string technology_family_string; | |
| 1092 if (value->GetAsString(&technology_family_string)) { | |
| 1093 technology_family_ = ParseTechnologyFamily(technology_family_string); | |
| 1094 return true; | |
| 1095 } | |
| 1096 break; | |
| 1097 } | |
| 1098 default: | |
| 1099 break; | |
| 1100 } | |
| 1101 return false; | |
| 1102 } | 178 } |
| 1103 | 179 |
| 1104 void NetworkDevice::ParseInfo(const DictionaryValue* info) { | 180 bool NetworkDevice::UpdateStatus(const std::string& key, |
| 1105 for (DictionaryValue::key_iterator iter = info->begin_keys(); | 181 const Value& value, |
| 1106 iter != info->end_keys(); ++iter) { | 182 PropertyIndex* index) { |
| 1107 const std::string& key = *iter; | 183 if (device_parser_.get()) |
| 1108 Value* value; | 184 return device_parser_->UpdateStatus(key, value, this, index); |
| 1109 bool res = info->GetWithoutPathExpansion(key, &value); | 185 return false; |
| 1110 DCHECK(res); | |
| 1111 if (res) { | |
| 1112 int index = property_index_parser().Get(key); | |
| 1113 if (!ParseValue(index, value)) | |
| 1114 VLOG(1) << "NetworkDevice: Unhandled key: " << key; | |
| 1115 } | |
| 1116 } | |
| 1117 } | 186 } |
| 1118 | 187 |
| 1119 //////////////////////////////////////////////////////////////////////////////// | 188 //////////////////////////////////////////////////////////////////////////////// |
| 1120 // Network | 189 // Network |
| 1121 | 190 |
| 1122 Network::Network(const std::string& service_path, ConnectionType type) | 191 Network::Network(const std::string& service_path, |
| 192 ConnectionType type, | |
| 193 NativeNetworkParser* parser) | |
| 1123 : state_(STATE_UNKNOWN), | 194 : state_(STATE_UNKNOWN), |
| 1124 error_(ERROR_NO_ERROR), | 195 error_(ERROR_NO_ERROR), |
| 1125 connectable_(true), | 196 connectable_(true), |
| 1126 is_active_(false), | 197 is_active_(false), |
| 1127 priority_(kPriorityNotSet), | 198 priority_(kPriorityNotSet), |
| 1128 auto_connect_(false), | 199 auto_connect_(false), |
| 1129 save_credentials_(false), | 200 save_credentials_(false), |
| 1130 priority_order_(0), | 201 priority_order_(0), |
| 1131 added_(false), | 202 added_(false), |
| 1132 notify_failure_(false), | 203 notify_failure_(false), |
| 1133 profile_type_(PROFILE_NONE), | 204 profile_type_(PROFILE_NONE), |
| 1134 service_path_(service_path), | 205 service_path_(service_path), |
| 1135 type_(type) { | 206 type_(type), |
| 207 network_parser_(parser) { | |
| 1136 } | 208 } |
| 1137 | 209 |
| 1138 Network::~Network() {} | 210 Network::~Network() {} |
| 1139 | 211 |
| 1140 void Network::SetState(ConnectionState new_state) { | 212 void Network::SetState(ConnectionState new_state) { |
| 1141 if (new_state == state_) | 213 if (new_state == state_) |
| 1142 return; | 214 return; |
| 1143 ConnectionState old_state = state_; | 215 ConnectionState old_state = state_; |
| 1144 state_ = new_state; | 216 state_ = new_state; |
| 1145 if (new_state == STATE_FAILURE) { | 217 if (new_state == STATE_FAILURE) { |
| 1146 if (old_state != STATE_UNKNOWN) { | 218 if (old_state != STATE_UNKNOWN) { |
| 1147 // New failure, the user needs to be notified. | 219 // New failure, the user needs to be notified. |
| 1148 notify_failure_ = true; | 220 notify_failure_ = true; |
| 1149 } | 221 } |
| 1150 } else { | 222 } else { |
| 1151 // State changed, so refresh IP address. | 223 // State changed, so refresh IP address. |
| 1152 // Note: blocking DBus call. TODO(stevenjb): refactor this. | 224 // Note: blocking DBus call. TODO(stevenjb): refactor this. |
| 1153 InitIPAddress(); | 225 InitIPAddress(); |
| 1154 } | 226 } |
| 1155 VLOG(1) << name() << ".State = " << GetStateString(); | 227 VLOG(1) << name() << ".State = " << GetStateString(); |
| 1156 } | 228 } |
| 1157 | 229 |
| 1158 void Network::SetName(const std::string& name) { | 230 void Network::SetName(const std::string& name) { |
| 1159 std::string name_utf8; | 231 std::string name_utf8; |
| 1160 ValidateUTF8(name, &name_utf8); | 232 ValidateUTF8(name, &name_utf8); |
| 1161 set_name(name_utf8); | 233 set_name(name_utf8); |
| 1162 } | 234 } |
| 1163 | 235 |
| 1164 bool Network::ParseValue(int index, const Value* value) { | 236 void Network::ParseInfo(const DictionaryValue& info) { |
| 1165 switch (index) { | 237 if (network_parser_.get()) |
| 1166 case PROPERTY_INDEX_TYPE: { | 238 network_parser_->UpdateNetworkFromInfo(info, this); |
| 1167 std::string type_string; | |
| 1168 if (value->GetAsString(&type_string)) { | |
| 1169 ConnectionType type = ParseType(type_string); | |
| 1170 LOG_IF(ERROR, type != type_) | |
| 1171 << "Network with mismatched type: " << service_path_ | |
| 1172 << " " << type << " != " << type_; | |
| 1173 return true; | |
| 1174 } | |
| 1175 break; | |
| 1176 } | |
| 1177 case PROPERTY_INDEX_DEVICE: | |
| 1178 return value->GetAsString(&device_path_); | |
| 1179 case PROPERTY_INDEX_NAME: { | |
| 1180 std::string name; | |
| 1181 if (value->GetAsString(&name)) { | |
| 1182 SetName(name); | |
| 1183 return true; | |
| 1184 } | |
| 1185 break; | |
| 1186 } | |
| 1187 case PROPERTY_INDEX_PROFILE: | |
| 1188 // Note: currently this is only provided for non remembered networks. | |
| 1189 return value->GetAsString(&profile_path_); | |
| 1190 case PROPERTY_INDEX_STATE: { | |
| 1191 std::string state_string; | |
| 1192 if (value->GetAsString(&state_string)) { | |
| 1193 SetState(ParseState(state_string)); | |
| 1194 return true; | |
| 1195 } | |
| 1196 break; | |
| 1197 } | |
| 1198 case PROPERTY_INDEX_MODE: { | |
| 1199 std::string mode_string; | |
| 1200 if (value->GetAsString(&mode_string)) { | |
| 1201 mode_ = ParseMode(mode_string); | |
| 1202 return true; | |
| 1203 } | |
| 1204 break; | |
| 1205 } | |
| 1206 case PROPERTY_INDEX_ERROR: { | |
| 1207 std::string error_string; | |
| 1208 if (value->GetAsString(&error_string)) { | |
| 1209 error_ = ParseError(error_string); | |
| 1210 return true; | |
| 1211 } | |
| 1212 break; | |
| 1213 } | |
| 1214 case PROPERTY_INDEX_CONNECTABLE: | |
| 1215 return value->GetAsBoolean(&connectable_); | |
| 1216 case PROPERTY_INDEX_IS_ACTIVE: | |
| 1217 return value->GetAsBoolean(&is_active_); | |
| 1218 case PROPERTY_INDEX_FAVORITE: | |
| 1219 // Not used currently. | |
| 1220 return true; | |
| 1221 case PROPERTY_INDEX_PRIORITY: | |
| 1222 return value->GetAsInteger(&priority_); | |
| 1223 case PROPERTY_INDEX_AUTO_CONNECT: | |
| 1224 return value->GetAsBoolean(&auto_connect_); | |
| 1225 case PROPERTY_INDEX_SAVE_CREDENTIALS: | |
| 1226 return value->GetAsBoolean(&save_credentials_); | |
| 1227 case PROPERTY_INDEX_PROXY_CONFIG: | |
| 1228 return value->GetAsString(&proxy_config_); | |
| 1229 default: | |
| 1230 break; | |
| 1231 } | |
| 1232 return false; | |
| 1233 } | |
| 1234 | |
| 1235 void Network::ParseInfo(const DictionaryValue* info) { | |
| 1236 // Set default values for properties that may not exist in the dictionary. | |
| 1237 priority_ = kPriorityNotSet; | |
| 1238 | |
| 1239 for (DictionaryValue::key_iterator iter = info->begin_keys(); | |
| 1240 iter != info->end_keys(); ++iter) { | |
| 1241 const std::string& key = *iter; | |
| 1242 Value* value; | |
| 1243 bool res = info->GetWithoutPathExpansion(key, &value); | |
| 1244 DCHECK(res); | |
| 1245 if (res) { | |
| 1246 int index = property_index_parser().Get(key); | |
| 1247 if (!ParseValue(index, value)) // virtual. | |
| 1248 VLOG(1) << "Network: " << name() | |
| 1249 << " Type: " << ConnectionTypeToString(type()) | |
| 1250 << " Unhandled key: " << key; | |
| 1251 } | |
| 1252 } | |
| 1253 CalculateUniqueId(); | |
| 1254 } | 239 } |
| 1255 | 240 |
| 1256 void Network::EraseCredentials() { | 241 void Network::EraseCredentials() { |
| 1257 } | 242 } |
| 1258 | 243 |
| 1259 void Network::CalculateUniqueId() { | 244 void Network::CalculateUniqueId() { |
| 1260 unique_id_ = name_; | 245 unique_id_ = name_; |
| 1261 } | 246 } |
| 1262 | 247 |
| 1263 bool Network::RequiresUserProfile() const { | 248 bool Network::RequiresUserProfile() const { |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1429 if (strlen(ipconfig.address) > 0) { | 414 if (strlen(ipconfig.address) > 0) { |
| 1430 ip_address_ = ipconfig.address; | 415 ip_address_ = ipconfig.address; |
| 1431 break; | 416 break; |
| 1432 } | 417 } |
| 1433 } | 418 } |
| 1434 chromeos::FreeIPConfigStatus(ipconfig_status); | 419 chromeos::FreeIPConfigStatus(ipconfig_status); |
| 1435 } | 420 } |
| 1436 } | 421 } |
| 1437 } | 422 } |
| 1438 | 423 |
| 424 bool Network::UpdateStatus(const std::string& key, | |
| 425 const Value& value, | |
| 426 PropertyIndex* index) { | |
| 427 if (network_parser_.get()) | |
| 428 return network_parser_->UpdateStatus(key, value, this, index); | |
| 429 return false; | |
| 430 } | |
| 431 | |
| 432 //////////////////////////////////////////////////////////////////////////////// | |
| 433 // EthernetNetwork | |
| 434 | |
| 435 EthernetNetwork::EthernetNetwork(const std::string& service_path) | |
|
Greg Spencer (Chromium)
2011/08/04 23:02:14
When we want to support a new parser, we can add a
| |
| 436 : Network(service_path, TYPE_ETHERNET, new NativeEthernetNetworkParser) { | |
| 437 } | |
| 438 | |
| 1439 //////////////////////////////////////////////////////////////////////////////// | 439 //////////////////////////////////////////////////////////////////////////////// |
| 1440 // VirtualNetwork | 440 // VirtualNetwork |
| 1441 | 441 |
| 1442 VirtualNetwork::VirtualNetwork(const std::string& service_path) | 442 VirtualNetwork::VirtualNetwork(const std::string& service_path) |
| 1443 : Network(service_path, TYPE_VPN), | 443 : Network(service_path, TYPE_VPN, new NativeVirtualNetworkParser), |
| 1444 provider_type_(PROVIDER_TYPE_L2TP_IPSEC_PSK) { | 444 provider_type_(PROVIDER_TYPE_L2TP_IPSEC_PSK) { |
| 1445 } | 445 } |
| 1446 | 446 |
| 1447 VirtualNetwork::~VirtualNetwork() {} | 447 VirtualNetwork::~VirtualNetwork() {} |
| 1448 | 448 |
| 1449 bool VirtualNetwork::ParseProviderValue(int index, const Value* value) { | |
| 1450 switch (index) { | |
| 1451 case PROPERTY_INDEX_HOST: | |
| 1452 return value->GetAsString(&server_hostname_); | |
| 1453 case PROPERTY_INDEX_NAME: | |
| 1454 // Note: shadows Network::name_ property. | |
| 1455 return value->GetAsString(&name_); | |
| 1456 case PROPERTY_INDEX_TYPE: { | |
| 1457 std::string provider_type_string; | |
| 1458 if (value->GetAsString(&provider_type_string)) { | |
| 1459 provider_type_ = ParseProviderType(provider_type_string); | |
| 1460 return true; | |
| 1461 } | |
| 1462 break; | |
| 1463 } | |
| 1464 case PROPERTY_INDEX_L2TPIPSEC_CA_CERT_NSS: | |
| 1465 return value->GetAsString(&ca_cert_nss_); | |
| 1466 case PROPERTY_INDEX_L2TPIPSEC_PIN: | |
| 1467 // Ignore PIN property. | |
| 1468 return true; | |
| 1469 case PROPERTY_INDEX_L2TPIPSEC_PSK: | |
| 1470 return value->GetAsString(&psk_passphrase_); | |
| 1471 case PROPERTY_INDEX_L2TPIPSEC_CLIENT_CERT_ID: | |
| 1472 return value->GetAsString(&client_cert_id_); | |
| 1473 case PROPERTY_INDEX_L2TPIPSEC_CLIENT_CERT_SLOT: | |
| 1474 // Ignore ClientCertSlot property. | |
| 1475 return true; | |
| 1476 case PROPERTY_INDEX_L2TPIPSEC_USER: | |
| 1477 return value->GetAsString(&username_); | |
| 1478 case PROPERTY_INDEX_L2TPIPSEC_PASSWORD: | |
| 1479 return value->GetAsString(&user_passphrase_); | |
| 1480 default: | |
| 1481 break; | |
| 1482 } | |
| 1483 return false; | |
| 1484 } | |
| 1485 | |
| 1486 bool VirtualNetwork::ParseValue(int index, const Value* value) { | |
| 1487 switch (index) { | |
| 1488 case PROPERTY_INDEX_PROVIDER: { | |
| 1489 DCHECK_EQ(value->GetType(), Value::TYPE_DICTIONARY); | |
| 1490 const DictionaryValue* dict = static_cast<const DictionaryValue*>(value); | |
| 1491 for (DictionaryValue::key_iterator iter = dict->begin_keys(); | |
| 1492 iter != dict->end_keys(); ++iter) { | |
| 1493 const std::string& key = *iter; | |
| 1494 Value* v; | |
| 1495 bool res = dict->GetWithoutPathExpansion(key, &v); | |
| 1496 DCHECK(res); | |
| 1497 if (res) { | |
| 1498 int index = property_index_parser().Get(key); | |
| 1499 if (!ParseProviderValue(index, v)) | |
| 1500 VLOG(1) << name() << ": Provider unhandled key: " << key | |
| 1501 << " Type: " << v->GetType(); | |
| 1502 } | |
| 1503 } | |
| 1504 return true; | |
| 1505 } | |
| 1506 default: | |
| 1507 return Network::ParseValue(index, value); | |
| 1508 break; | |
| 1509 } | |
| 1510 return false; | |
| 1511 } | |
| 1512 | |
| 1513 void VirtualNetwork::ParseInfo(const DictionaryValue* info) { | |
| 1514 Network::ParseInfo(info); | |
| 1515 VLOG(1) << "VPN: " << name() | |
| 1516 << " Server: " << server_hostname() | |
| 1517 << " Type: " << ProviderTypeToString(provider_type()); | |
| 1518 if (provider_type_ == PROVIDER_TYPE_L2TP_IPSEC_PSK) { | |
| 1519 if (!client_cert_id_.empty()) | |
| 1520 provider_type_ = PROVIDER_TYPE_L2TP_IPSEC_USER_CERT; | |
| 1521 } | |
| 1522 } | |
| 1523 | |
| 1524 void VirtualNetwork::EraseCredentials() { | 449 void VirtualNetwork::EraseCredentials() { |
| 1525 WipeString(&ca_cert_nss_); | 450 WipeString(&ca_cert_nss_); |
| 1526 WipeString(&psk_passphrase_); | 451 WipeString(&psk_passphrase_); |
| 1527 WipeString(&client_cert_id_); | 452 WipeString(&client_cert_id_); |
| 1528 WipeString(&user_passphrase_); | 453 WipeString(&user_passphrase_); |
| 1529 } | 454 } |
| 1530 | 455 |
| 1531 void VirtualNetwork::CalculateUniqueId() { | 456 void VirtualNetwork::CalculateUniqueId() { |
| 1532 std::string provider_type(ProviderTypeToString(provider_type_)); | 457 std::string provider_type(ProviderTypeToString(provider_type_)); |
| 1533 unique_id_ = provider_type + "|" + server_hostname_; | 458 set_unique_id(provider_type + "|" + server_hostname_); |
| 1534 } | 459 } |
| 1535 | 460 |
| 1536 bool VirtualNetwork::RequiresUserProfile() const { | 461 bool VirtualNetwork::RequiresUserProfile() const { |
| 1537 return true; | 462 return true; |
| 1538 } | 463 } |
| 1539 | 464 |
| 1540 void VirtualNetwork::CopyCredentialsFromRemembered(Network* remembered) { | 465 void VirtualNetwork::CopyCredentialsFromRemembered(Network* remembered) { |
| 1541 DCHECK_EQ(remembered->type(), TYPE_VPN); | 466 DCHECK_EQ(remembered->type(), TYPE_VPN); |
| 1542 VirtualNetwork* remembered_vpn = static_cast<VirtualNetwork*>(remembered); | 467 VirtualNetwork* remembered_vpn = static_cast<VirtualNetwork*>(remembered); |
| 1543 VLOG(1) << "Copy VPN credentials: " << name() | 468 VLOG(1) << "Copy VPN credentials: " << name() |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1618 | 543 |
| 1619 void VirtualNetwork::SetCertificateSlotAndPin( | 544 void VirtualNetwork::SetCertificateSlotAndPin( |
| 1620 const std::string& slot, const std::string& pin) { | 545 const std::string& slot, const std::string& pin) { |
| 1621 SetOrClearStringProperty(kL2TPIPSecClientCertSlotProp, slot, NULL); | 546 SetOrClearStringProperty(kL2TPIPSecClientCertSlotProp, slot, NULL); |
| 1622 SetOrClearStringProperty(kL2TPIPSecPINProperty, pin, NULL); | 547 SetOrClearStringProperty(kL2TPIPSecPINProperty, pin, NULL); |
| 1623 } | 548 } |
| 1624 | 549 |
| 1625 //////////////////////////////////////////////////////////////////////////////// | 550 //////////////////////////////////////////////////////////////////////////////// |
| 1626 // WirelessNetwork | 551 // WirelessNetwork |
| 1627 | 552 |
| 1628 bool WirelessNetwork::ParseValue(int index, const Value* value) { | |
| 1629 switch (index) { | |
| 1630 case PROPERTY_INDEX_SIGNAL_STRENGTH: | |
| 1631 return value->GetAsInteger(&strength_); | |
| 1632 default: | |
| 1633 return Network::ParseValue(index, value); | |
| 1634 break; | |
| 1635 } | |
| 1636 return false; | |
| 1637 } | |
| 1638 | |
| 1639 //////////////////////////////////////////////////////////////////////////////// | 553 //////////////////////////////////////////////////////////////////////////////// |
| 1640 // CellularDataPlan | 554 // CellularDataPlan |
| 1641 | 555 |
| 1642 CellularDataPlan::CellularDataPlan() | 556 CellularDataPlan::CellularDataPlan() |
| 1643 : plan_name("Unknown"), | 557 : plan_name("Unknown"), |
| 1644 plan_type(CELLULAR_DATA_PLAN_UNLIMITED), | 558 plan_type(CELLULAR_DATA_PLAN_UNLIMITED), |
| 1645 plan_data_bytes(0), | 559 plan_data_bytes(0), |
| 1646 data_bytes_used(0) { | 560 data_bytes_used(0) { |
| 1647 } | 561 } |
| 1648 | 562 |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1876 &localized_name)) | 790 &localized_name)) |
| 1877 localized_name.clear(); | 791 localized_name.clear(); |
| 1878 if (!dict.GetStringWithoutPathExpansion(kApnLanguageProperty, &language)) | 792 if (!dict.GetStringWithoutPathExpansion(kApnLanguageProperty, &language)) |
| 1879 language.clear(); | 793 language.clear(); |
| 1880 } | 794 } |
| 1881 | 795 |
| 1882 //////////////////////////////////////////////////////////////////////////////// | 796 //////////////////////////////////////////////////////////////////////////////// |
| 1883 // CellularNetwork | 797 // CellularNetwork |
| 1884 | 798 |
| 1885 CellularNetwork::CellularNetwork(const std::string& service_path) | 799 CellularNetwork::CellularNetwork(const std::string& service_path) |
| 1886 : WirelessNetwork(service_path, TYPE_CELLULAR), | 800 : WirelessNetwork(service_path, TYPE_CELLULAR, |
| 801 new NativeCellularNetworkParser), | |
| 1887 activation_state_(ACTIVATION_STATE_UNKNOWN), | 802 activation_state_(ACTIVATION_STATE_UNKNOWN), |
| 1888 network_technology_(NETWORK_TECHNOLOGY_UNKNOWN), | 803 network_technology_(NETWORK_TECHNOLOGY_UNKNOWN), |
| 1889 roaming_state_(ROAMING_STATE_UNKNOWN), | 804 roaming_state_(ROAMING_STATE_UNKNOWN), |
| 1890 data_left_(DATA_UNKNOWN) { | 805 data_left_(DATA_UNKNOWN) { |
| 1891 } | 806 } |
| 1892 | 807 |
| 1893 CellularNetwork::~CellularNetwork() { | 808 CellularNetwork::~CellularNetwork() { |
| 1894 } | 809 } |
| 1895 | 810 |
| 1896 bool CellularNetwork::ParseValue(int index, const Value* value) { | |
| 1897 switch (index) { | |
| 1898 case PROPERTY_INDEX_ACTIVATION_STATE: { | |
| 1899 std::string activation_state_string; | |
| 1900 if (value->GetAsString(&activation_state_string)) { | |
| 1901 ActivationState prev_state = activation_state_; | |
| 1902 activation_state_ = ParseActivationState(activation_state_string); | |
| 1903 if (activation_state_ != prev_state) | |
| 1904 RefreshDataPlansIfNeeded(); | |
| 1905 return true; | |
| 1906 } | |
| 1907 break; | |
| 1908 } | |
| 1909 case PROPERTY_INDEX_CELLULAR_APN: { | |
| 1910 if (value->IsType(Value::TYPE_DICTIONARY)) { | |
| 1911 apn_.Set(*static_cast<const DictionaryValue*>(value)); | |
| 1912 return true; | |
| 1913 } | |
| 1914 break; | |
| 1915 } | |
| 1916 case PROPERTY_INDEX_CELLULAR_LAST_GOOD_APN: { | |
| 1917 if (value->IsType(Value::TYPE_DICTIONARY)) { | |
| 1918 last_good_apn_.Set(*static_cast<const DictionaryValue*>(value)); | |
| 1919 return true; | |
| 1920 } | |
| 1921 break; | |
| 1922 } | |
| 1923 case PROPERTY_INDEX_NETWORK_TECHNOLOGY: { | |
| 1924 std::string network_technology_string; | |
| 1925 if (value->GetAsString(&network_technology_string)) { | |
| 1926 network_technology_ = ParseNetworkTechnology(network_technology_string); | |
| 1927 return true; | |
| 1928 } | |
| 1929 break; | |
| 1930 } | |
| 1931 case PROPERTY_INDEX_ROAMING_STATE: { | |
| 1932 std::string roaming_state_string; | |
| 1933 if (value->GetAsString(&roaming_state_string)) { | |
| 1934 roaming_state_ = ParseRoamingState(roaming_state_string); | |
| 1935 return true; | |
| 1936 } | |
| 1937 break; | |
| 1938 } | |
| 1939 case PROPERTY_INDEX_OPERATOR_NAME: | |
| 1940 return value->GetAsString(&operator_name_); | |
| 1941 case PROPERTY_INDEX_OPERATOR_CODE: | |
| 1942 return value->GetAsString(&operator_code_); | |
| 1943 case PROPERTY_INDEX_SERVING_OPERATOR: { | |
| 1944 if (value->IsType(Value::TYPE_DICTIONARY)) { | |
| 1945 const DictionaryValue* dict = | |
| 1946 static_cast<const DictionaryValue*>(value); | |
| 1947 operator_code_.clear(); | |
| 1948 operator_country_.clear(); | |
| 1949 operator_name_.clear(); | |
| 1950 dict->GetStringWithoutPathExpansion(kOperatorNameKey, | |
| 1951 &operator_name_); | |
| 1952 dict->GetStringWithoutPathExpansion(kOperatorCodeKey, | |
| 1953 &operator_code_); | |
| 1954 dict->GetStringWithoutPathExpansion(kOperatorCountryKey, | |
| 1955 &operator_country_); | |
| 1956 return true; | |
| 1957 } | |
| 1958 break; | |
| 1959 } | |
| 1960 case PROPERTY_INDEX_PAYMENT_URL: | |
| 1961 return value->GetAsString(&payment_url_); | |
| 1962 case PROPERTY_INDEX_USAGE_URL: | |
| 1963 return value->GetAsString(&usage_url_); | |
| 1964 case PROPERTY_INDEX_STATE: { | |
| 1965 // Save previous state before calling WirelessNetwork::ParseValue. | |
| 1966 ConnectionState prev_state = state_; | |
| 1967 if (WirelessNetwork::ParseValue(index, value)) { | |
| 1968 if (state_ != prev_state) | |
| 1969 RefreshDataPlansIfNeeded(); | |
| 1970 return true; | |
| 1971 } | |
| 1972 break; | |
| 1973 } | |
| 1974 default: | |
| 1975 return WirelessNetwork::ParseValue(index, value); | |
| 1976 } | |
| 1977 return false; | |
| 1978 } | |
| 1979 | |
| 1980 bool CellularNetwork::StartActivation() const { | 811 bool CellularNetwork::StartActivation() const { |
| 1981 if (!EnsureCrosLoaded()) | 812 if (!EnsureCrosLoaded()) |
| 1982 return false; | 813 return false; |
| 1983 return chromeos::ActivateCellularModem(service_path().c_str(), NULL); | 814 return chromeos::ActivateCellularModem(service_path().c_str(), NULL); |
| 1984 } | 815 } |
| 1985 | 816 |
| 1986 void CellularNetwork::RefreshDataPlansIfNeeded() const { | 817 void CellularNetwork::RefreshDataPlansIfNeeded() const { |
| 1987 if (!EnsureCrosLoaded()) | 818 if (!EnsureCrosLoaded()) |
| 1988 return; | 819 return; |
| 1989 if (connected() && activated()) | 820 if (connected() && activated()) |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2098 return l10n_util::GetStringUTF8( | 929 return l10n_util::GetStringUTF8( |
| 2099 IDS_CHROMEOS_NETWORK_ROAMING_STATE_UNKNOWN); | 930 IDS_CHROMEOS_NETWORK_ROAMING_STATE_UNKNOWN); |
| 2100 break; | 931 break; |
| 2101 } | 932 } |
| 2102 } | 933 } |
| 2103 | 934 |
| 2104 //////////////////////////////////////////////////////////////////////////////// | 935 //////////////////////////////////////////////////////////////////////////////// |
| 2105 // WifiNetwork | 936 // WifiNetwork |
| 2106 | 937 |
| 2107 WifiNetwork::WifiNetwork(const std::string& service_path) | 938 WifiNetwork::WifiNetwork(const std::string& service_path) |
| 2108 : WirelessNetwork(service_path, TYPE_WIFI), | 939 : WirelessNetwork(service_path, TYPE_WIFI, new NativeWifiNetworkParser), |
| 2109 encryption_(SECURITY_NONE), | 940 encryption_(SECURITY_NONE), |
| 2110 passphrase_required_(false), | 941 passphrase_required_(false), |
| 2111 eap_method_(EAP_METHOD_UNKNOWN), | 942 eap_method_(EAP_METHOD_UNKNOWN), |
| 2112 eap_phase_2_auth_(EAP_PHASE_2_AUTH_AUTO), | 943 eap_phase_2_auth_(EAP_PHASE_2_AUTH_AUTO), |
| 2113 eap_use_system_cas_(true) { | 944 eap_use_system_cas_(true) { |
| 2114 } | 945 } |
| 2115 | 946 |
| 2116 WifiNetwork::~WifiNetwork() {} | 947 WifiNetwork::~WifiNetwork() {} |
| 2117 | 948 |
| 2118 void WifiNetwork::CalculateUniqueId() { | 949 void WifiNetwork::CalculateUniqueId() { |
| 2119 ConnectionSecurity encryption = encryption_; | 950 ConnectionSecurity encryption = encryption_; |
| 2120 // Flimflam treats wpa and rsn as psk internally, so convert those types | 951 // Flimflam treats wpa and rsn as psk internally, so convert those types |
| 2121 // to psk for unique naming. | 952 // to psk for unique naming. |
| 2122 if (encryption == SECURITY_WPA || encryption == SECURITY_RSN) | 953 if (encryption == SECURITY_WPA || encryption == SECURITY_RSN) |
| 2123 encryption = SECURITY_PSK; | 954 encryption = SECURITY_PSK; |
| 2124 std::string security = std::string(SecurityToString(encryption)); | 955 std::string security = std::string(SecurityToString(encryption)); |
| 2125 unique_id_ = security + "|" + name_; | 956 set_unique_id(security + "|" + name()); |
| 2126 } | 957 } |
| 2127 | 958 |
| 2128 bool WifiNetwork::SetSsid(const std::string& ssid) { | 959 bool WifiNetwork::SetSsid(const std::string& ssid) { |
| 2129 // Detects encoding and convert to UTF-8. | 960 // Detects encoding and convert to UTF-8. |
| 2130 std::string ssid_utf8; | 961 std::string ssid_utf8; |
| 2131 if (!IsStringUTF8(ssid)) { | 962 if (!IsStringUTF8(ssid)) { |
| 2132 std::string encoding; | 963 std::string encoding; |
| 2133 if (base::DetectEncoding(ssid, &encoding)) { | 964 if (base::DetectEncoding(ssid, &encoding)) { |
| 2134 if (!base::ConvertToUtf8AndNormalize(ssid, encoding, &ssid_utf8)) { | 965 if (!base::ConvertToUtf8AndNormalize(ssid, encoding, &ssid_utf8)) { |
| 2135 ssid_utf8.clear(); | 966 ssid_utf8.clear(); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 2150 std::vector<uint8> ssid_raw; | 981 std::vector<uint8> ssid_raw; |
| 2151 if (!base::HexStringToBytes(ssid_hex, &ssid_raw)) { | 982 if (!base::HexStringToBytes(ssid_hex, &ssid_raw)) { |
| 2152 LOG(ERROR) << "Illegal hex char is found in WiFi.HexSSID."; | 983 LOG(ERROR) << "Illegal hex char is found in WiFi.HexSSID."; |
| 2153 ssid_raw.clear(); | 984 ssid_raw.clear(); |
| 2154 return false; | 985 return false; |
| 2155 } | 986 } |
| 2156 | 987 |
| 2157 return SetSsid(std::string(ssid_raw.begin(), ssid_raw.end())); | 988 return SetSsid(std::string(ssid_raw.begin(), ssid_raw.end())); |
| 2158 } | 989 } |
| 2159 | 990 |
| 2160 bool WifiNetwork::ParseValue(int index, const Value* value) { | |
| 2161 switch (index) { | |
| 2162 case PROPERTY_INDEX_WIFI_HEX_SSID: { | |
| 2163 std::string ssid_hex; | |
| 2164 if (!value->GetAsString(&ssid_hex)) | |
| 2165 return false; | |
| 2166 | |
| 2167 SetHexSsid(ssid_hex); | |
| 2168 return true; | |
| 2169 } | |
| 2170 case PROPERTY_INDEX_WIFI_AUTH_MODE: | |
| 2171 case PROPERTY_INDEX_WIFI_PHY_MODE: | |
| 2172 case PROPERTY_INDEX_WIFI_HIDDEN_SSID: | |
| 2173 case PROPERTY_INDEX_WIFI_FREQUENCY: | |
| 2174 // These properties are currently not used in the UI. | |
| 2175 return true; | |
| 2176 case PROPERTY_INDEX_NAME: { | |
| 2177 // Does not change network name when it was already set by WiFi.HexSSID. | |
| 2178 if (!name().empty()) | |
| 2179 return true; | |
| 2180 else | |
| 2181 return WirelessNetwork::ParseValue(index, value); | |
| 2182 } | |
| 2183 case PROPERTY_INDEX_SECURITY: { | |
| 2184 std::string security_string; | |
| 2185 if (value->GetAsString(&security_string)) { | |
| 2186 encryption_ = ParseSecurity(security_string); | |
| 2187 return true; | |
| 2188 } | |
| 2189 break; | |
| 2190 } | |
| 2191 case PROPERTY_INDEX_PASSPHRASE: { | |
| 2192 std::string passphrase; | |
| 2193 if (value->GetAsString(&passphrase)) { | |
| 2194 // Only store the passphrase if we are the owner. | |
| 2195 // TODO(stevenjb): Remove this when chromium-os:12948 is resolved. | |
| 2196 if (chromeos::UserManager::Get()->current_user_is_owner()) | |
| 2197 passphrase_ = passphrase; | |
| 2198 return true; | |
| 2199 } | |
| 2200 break; | |
| 2201 } | |
| 2202 case PROPERTY_INDEX_PASSPHRASE_REQUIRED: | |
| 2203 return value->GetAsBoolean(&passphrase_required_); | |
| 2204 case PROPERTY_INDEX_IDENTITY: | |
| 2205 return value->GetAsString(&identity_); | |
| 2206 case PROPERTY_INDEX_EAP_IDENTITY: | |
| 2207 return value->GetAsString(&eap_identity_); | |
| 2208 case PROPERTY_INDEX_EAP_METHOD: { | |
| 2209 std::string method; | |
| 2210 if (value->GetAsString(&method)) { | |
| 2211 eap_method_ = ParseEAPMethod(method); | |
| 2212 return true; | |
| 2213 } | |
| 2214 break; | |
| 2215 } | |
| 2216 case PROPERTY_INDEX_EAP_PHASE_2_AUTH: { | |
| 2217 std::string auth; | |
| 2218 if (value->GetAsString(&auth)) { | |
| 2219 eap_phase_2_auth_ = ParseEAPPhase2Auth(auth); | |
| 2220 return true; | |
| 2221 } | |
| 2222 break; | |
| 2223 } | |
| 2224 case PROPERTY_INDEX_EAP_ANONYMOUS_IDENTITY: | |
| 2225 return value->GetAsString(&eap_anonymous_identity_); | |
| 2226 case PROPERTY_INDEX_EAP_CERT_ID: | |
| 2227 return value->GetAsString(&eap_client_cert_pkcs11_id_); | |
| 2228 case PROPERTY_INDEX_EAP_CA_CERT_NSS: | |
| 2229 return value->GetAsString(&eap_server_ca_cert_nss_nickname_); | |
| 2230 case PROPERTY_INDEX_EAP_USE_SYSTEM_CAS: | |
| 2231 return value->GetAsBoolean(&eap_use_system_cas_); | |
| 2232 case PROPERTY_INDEX_EAP_PASSWORD: | |
| 2233 return value->GetAsString(&eap_passphrase_); | |
| 2234 case PROPERTY_INDEX_EAP_CLIENT_CERT: | |
| 2235 case PROPERTY_INDEX_EAP_CLIENT_CERT_NSS: | |
| 2236 case PROPERTY_INDEX_EAP_PRIVATE_KEY: | |
| 2237 case PROPERTY_INDEX_EAP_PRIVATE_KEY_PASSWORD: | |
| 2238 case PROPERTY_INDEX_EAP_KEY_ID: | |
| 2239 case PROPERTY_INDEX_EAP_CA_CERT: | |
| 2240 case PROPERTY_INDEX_EAP_CA_CERT_ID: | |
| 2241 case PROPERTY_INDEX_EAP_PIN: | |
| 2242 case PROPERTY_INDEX_EAP_KEY_MGMT: | |
| 2243 // These properties are currently not used in the UI. | |
| 2244 return true; | |
| 2245 default: | |
| 2246 return WirelessNetwork::ParseValue(index, value); | |
| 2247 } | |
| 2248 return false; | |
| 2249 } | |
| 2250 | |
| 2251 const std::string& WifiNetwork::GetPassphrase() const { | 991 const std::string& WifiNetwork::GetPassphrase() const { |
| 2252 if (!user_passphrase_.empty()) | 992 if (!user_passphrase_.empty()) |
| 2253 return user_passphrase_; | 993 return user_passphrase_; |
| 2254 return passphrase_; | 994 return passphrase_; |
| 2255 } | 995 } |
| 2256 | 996 |
| 2257 void WifiNetwork::SetPassphrase(const std::string& passphrase) { | 997 void WifiNetwork::SetPassphrase(const std::string& passphrase) { |
| 2258 // Set the user_passphrase_ only; passphrase_ stores the flimflam value. | 998 // Set the user_passphrase_ only; passphrase_ stores the flimflam value. |
| 2259 // If the user sets an empty passphrase, restore it to the passphrase | 999 // If the user sets an empty passphrase, restore it to the passphrase |
| 2260 // remembered by flimflam. | 1000 // remembered by flimflam. |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2404 } | 1144 } |
| 2405 case SECURITY_PSK: | 1145 case SECURITY_PSK: |
| 2406 return "PSK"; | 1146 return "PSK"; |
| 2407 } | 1147 } |
| 2408 return "Unknown"; | 1148 return "Unknown"; |
| 2409 } | 1149 } |
| 2410 | 1150 |
| 2411 bool WifiNetwork::IsPassphraseRequired() const { | 1151 bool WifiNetwork::IsPassphraseRequired() const { |
| 2412 // TODO(stevenjb): Remove error_ tests when fixed in flimflam | 1152 // TODO(stevenjb): Remove error_ tests when fixed in flimflam |
| 2413 // (http://crosbug.com/10135). | 1153 // (http://crosbug.com/10135). |
| 2414 if (error_ == ERROR_BAD_PASSPHRASE || error_ == ERROR_BAD_WEPKEY) | 1154 if (error() == ERROR_BAD_PASSPHRASE || error() == ERROR_BAD_WEPKEY) |
| 2415 return true; | 1155 return true; |
| 2416 // For 802.1x networks, configuration is required if connectable is false. | 1156 // For 802.1x networks, configuration is required if connectable is false. |
| 2417 if (encryption_ == SECURITY_8021X) | 1157 if (encryption_ == SECURITY_8021X) |
| 2418 return !connectable_; | 1158 return !connectable(); |
| 2419 return passphrase_required_; | 1159 return passphrase_required_; |
| 2420 } | 1160 } |
| 2421 | 1161 |
| 2422 bool WifiNetwork::RequiresUserProfile() const { | 1162 bool WifiNetwork::RequiresUserProfile() const { |
| 2423 // 8021X requires certificates which are only stored for individual users. | 1163 // 8021X requires certificates which are only stored for individual users. |
| 2424 if (encryption_ == SECURITY_8021X && | 1164 if (encryption_ == SECURITY_8021X && |
| 2425 (eap_method_ == EAP_METHOD_TLS || | 1165 (eap_method_ == EAP_METHOD_TLS || |
| 2426 !eap_client_cert_pkcs11_id().empty())) | 1166 !eap_client_cert_pkcs11_id().empty())) |
| 2427 return true; | 1167 return true; |
| 2428 return false; | 1168 return false; |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 2451 | 1191 |
| 2452 // Called from ConnectToWifiNetwork. | 1192 // Called from ConnectToWifiNetwork. |
| 2453 // Calls ConnectToWifiNetworkUsingConnectData if network request succeeds. | 1193 // Calls ConnectToWifiNetworkUsingConnectData if network request succeeds. |
| 2454 virtual void CallRequestWifiNetworkAndConnect( | 1194 virtual void CallRequestWifiNetworkAndConnect( |
| 2455 const std::string& ssid, ConnectionSecurity security) = 0; | 1195 const std::string& ssid, ConnectionSecurity security) = 0; |
| 2456 // Called from ConnectToVirtualNetwork*. | 1196 // Called from ConnectToVirtualNetwork*. |
| 2457 // Calls ConnectToVirtualNetworkUsingConnectData if network request succeeds. | 1197 // Calls ConnectToVirtualNetworkUsingConnectData if network request succeeds. |
| 2458 virtual void CallRequestVirtualNetworkAndConnect( | 1198 virtual void CallRequestVirtualNetworkAndConnect( |
| 2459 const std::string& service_name, | 1199 const std::string& service_name, |
| 2460 const std::string& server_hostname, | 1200 const std::string& server_hostname, |
| 2461 VirtualNetwork::ProviderType provider_type) = 0; | 1201 ProviderType provider_type) = 0; |
| 2462 // Called from NetworkConnectStart. | 1202 // Called from NetworkConnectStart. |
| 2463 // Calls NetworkConnectCompleted when the connection attept completes. | 1203 // Calls NetworkConnectCompleted when the connection attept completes. |
| 2464 virtual void CallConnectToNetwork(Network* network) = 0; | 1204 virtual void CallConnectToNetwork(Network* network) = 0; |
| 2465 // Called from DeleteRememberedNetwork. | 1205 // Called from DeleteRememberedNetwork. |
| 2466 virtual void CallDeleteRememberedNetwork( | 1206 virtual void CallDeleteRememberedNetwork( |
| 2467 const std::string& profile_path, const std::string& service_path) = 0; | 1207 const std::string& profile_path, const std::string& service_path) = 0; |
| 2468 | 1208 |
| 2469 // Called from Enable*NetworkDevice. | 1209 // Called from Enable*NetworkDevice. |
| 2470 // Asynchronously enables or disables the specified device type. | 1210 // Asynchronously enables or disables the specified device type. |
| 2471 virtual void CallEnableNetworkDeviceType( | 1211 virtual void CallEnableNetworkDeviceType( |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3158 NetworkDeviceMap::iterator iter = device_map_.find(path); | 1898 NetworkDeviceMap::iterator iter = device_map_.find(path); |
| 3159 if (iter != device_map_.end()) | 1899 if (iter != device_map_.end()) |
| 3160 return iter->second; | 1900 return iter->second; |
| 3161 LOG(WARNING) << "Device path not found: " << path; | 1901 LOG(WARNING) << "Device path not found: " << path; |
| 3162 return NULL; | 1902 return NULL; |
| 3163 } | 1903 } |
| 3164 | 1904 |
| 3165 const NetworkDevice* NetworkLibraryImplBase::FindCellularDevice() const { | 1905 const NetworkDevice* NetworkLibraryImplBase::FindCellularDevice() const { |
| 3166 for (NetworkDeviceMap::const_iterator iter = device_map_.begin(); | 1906 for (NetworkDeviceMap::const_iterator iter = device_map_.begin(); |
| 3167 iter != device_map_.end(); ++iter) { | 1907 iter != device_map_.end(); ++iter) { |
| 3168 if (iter->second->type() == TYPE_CELLULAR) | 1908 if (iter->second && iter->second->type() == TYPE_CELLULAR) |
| 3169 return iter->second; | 1909 return iter->second; |
| 3170 } | 1910 } |
| 3171 return NULL; | 1911 return NULL; |
| 3172 } | 1912 } |
| 3173 | 1913 |
| 3174 const NetworkDevice* NetworkLibraryImplBase::FindEthernetDevice() const { | 1914 const NetworkDevice* NetworkLibraryImplBase::FindEthernetDevice() const { |
| 3175 for (NetworkDeviceMap::const_iterator iter = device_map_.begin(); | 1915 for (NetworkDeviceMap::const_iterator iter = device_map_.begin(); |
| 3176 iter != device_map_.end(); ++iter) { | 1916 iter != device_map_.end(); ++iter) { |
| 3177 if (iter->second->type() == TYPE_ETHERNET) | 1917 if (iter->second->type() == TYPE_ETHERNET) |
| 3178 return iter->second; | 1918 return iter->second; |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3604 const std::string& username, | 2344 const std::string& username, |
| 3605 const std::string& user_passphrase) { | 2345 const std::string& user_passphrase) { |
| 3606 // Store the connection data to be used by the callback. | 2346 // Store the connection data to be used by the callback. |
| 3607 connect_data_.service_name = service_name; | 2347 connect_data_.service_name = service_name; |
| 3608 connect_data_.psk_key = psk; | 2348 connect_data_.psk_key = psk; |
| 3609 connect_data_.server_hostname = server_hostname; | 2349 connect_data_.server_hostname = server_hostname; |
| 3610 connect_data_.psk_username = username; | 2350 connect_data_.psk_username = username; |
| 3611 connect_data_.passphrase = user_passphrase; | 2351 connect_data_.passphrase = user_passphrase; |
| 3612 CallRequestVirtualNetworkAndConnect( | 2352 CallRequestVirtualNetworkAndConnect( |
| 3613 service_name, server_hostname, | 2353 service_name, server_hostname, |
| 3614 VirtualNetwork::PROVIDER_TYPE_L2TP_IPSEC_PSK); | 2354 PROVIDER_TYPE_L2TP_IPSEC_PSK); |
| 3615 } | 2355 } |
| 3616 | 2356 |
| 3617 // 1. Connect to a virtual network with a user cert. | 2357 // 1. Connect to a virtual network with a user cert. |
| 3618 void NetworkLibraryImplBase::ConnectToVirtualNetworkCert( | 2358 void NetworkLibraryImplBase::ConnectToVirtualNetworkCert( |
| 3619 const std::string& service_name, | 2359 const std::string& service_name, |
| 3620 const std::string& server_hostname, | 2360 const std::string& server_hostname, |
| 3621 const std::string& server_ca_cert_nss_nickname, | 2361 const std::string& server_ca_cert_nss_nickname, |
| 3622 const std::string& client_cert_pkcs11_id, | 2362 const std::string& client_cert_pkcs11_id, |
| 3623 const std::string& username, | 2363 const std::string& username, |
| 3624 const std::string& user_passphrase) { | 2364 const std::string& user_passphrase) { |
| 3625 // Store the connection data to be used by the callback. | 2365 // Store the connection data to be used by the callback. |
| 3626 connect_data_.service_name = service_name; | 2366 connect_data_.service_name = service_name; |
| 3627 connect_data_.server_hostname = server_hostname; | 2367 connect_data_.server_hostname = server_hostname; |
| 3628 connect_data_.server_ca_cert_nss_nickname = server_ca_cert_nss_nickname; | 2368 connect_data_.server_ca_cert_nss_nickname = server_ca_cert_nss_nickname; |
| 3629 connect_data_.client_cert_pkcs11_id = client_cert_pkcs11_id; | 2369 connect_data_.client_cert_pkcs11_id = client_cert_pkcs11_id; |
| 3630 connect_data_.psk_username = username; | 2370 connect_data_.psk_username = username; |
| 3631 connect_data_.passphrase = user_passphrase; | 2371 connect_data_.passphrase = user_passphrase; |
| 3632 CallRequestVirtualNetworkAndConnect( | 2372 CallRequestVirtualNetworkAndConnect( |
| 3633 service_name, server_hostname, | 2373 service_name, server_hostname, |
| 3634 VirtualNetwork::PROVIDER_TYPE_L2TP_IPSEC_USER_CERT); | 2374 PROVIDER_TYPE_L2TP_IPSEC_USER_CERT); |
| 3635 } | 2375 } |
| 3636 | 2376 |
| 3637 // 2. Requests a WiFi Network by SSID and security. | 2377 // 2. Requests a WiFi Network by SSID and security. |
| 3638 // Calls ConnectToWifiNetworkUsingConnectData if network request succeeds. | 2378 // Calls ConnectToWifiNetworkUsingConnectData if network request succeeds. |
| 3639 // virtual void CallRequestWifiNetworkAndConnect( | 2379 // virtual void CallRequestWifiNetworkAndConnect( |
| 3640 // const std::string& ssid, ConnectionSecurity security) = 0; | 2380 // const std::string& ssid, ConnectionSecurity security) = 0; |
| 3641 | 2381 |
| 3642 // 2. Requests a Virtual Network by service name, etc. | 2382 // 2. Requests a Virtual Network by service name, etc. |
| 3643 // Calls ConnectToVirtualNetworkUsingConnectData if network request succeeds. | 2383 // Calls ConnectToVirtualNetworkUsingConnectData if network request succeeds. |
| 3644 // virtual void CallRequestVirtualNetworkAndConnect( | 2384 // virtual void CallRequestVirtualNetworkAndConnect( |
| 3645 // const std::string& service_name, | 2385 // const std::string& service_name, |
| 3646 // const std::string& server_hostname, | 2386 // const std::string& server_hostname, |
| 3647 // VirtualNetwork::ProviderType provider_type) = 0; | 2387 // ProviderType provider_type) = 0; |
| 3648 | 2388 |
| 3649 // 3. Sets network properties stored in ConnectData and calls | 2389 // 3. Sets network properties stored in ConnectData and calls |
| 3650 // NetworkConnectStart. | 2390 // NetworkConnectStart. |
| 3651 void NetworkLibraryImplBase::ConnectToWifiNetworkUsingConnectData( | 2391 void NetworkLibraryImplBase::ConnectToWifiNetworkUsingConnectData( |
| 3652 WifiNetwork* wifi) { | 2392 WifiNetwork* wifi) { |
| 3653 ConnectData& data = connect_data_; | 2393 ConnectData& data = connect_data_; |
| 3654 if (wifi->name() != data.service_name) { | 2394 if (wifi->name() != data.service_name) { |
| 3655 LOG(WARNING) << "WiFi network name does not match ConnectData: " | 2395 LOG(WARNING) << "WiFi network name does not match ConnectData: " |
| 3656 << wifi->name() << " != " << data.service_name; | 2396 << wifi->name() << " != " << data.service_name; |
| 3657 return; | 2397 return; |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3846 } | 2586 } |
| 3847 } | 2587 } |
| 3848 DCHECK(!network->profile_path().empty()) | 2588 DCHECK(!network->profile_path().empty()) |
| 3849 << "Service path not in any profile: " << network->service_path(); | 2589 << "Service path not in any profile: " << network->service_path(); |
| 3850 } | 2590 } |
| 3851 | 2591 |
| 3852 void NetworkLibraryImplBase::DeleteRememberedNetwork( | 2592 void NetworkLibraryImplBase::DeleteRememberedNetwork( |
| 3853 const std::string& service_path) { | 2593 const std::string& service_path) { |
| 3854 NetworkMap::iterator found = remembered_network_map_.find(service_path); | 2594 NetworkMap::iterator found = remembered_network_map_.find(service_path); |
| 3855 if (found == remembered_network_map_.end()) { | 2595 if (found == remembered_network_map_.end()) { |
| 3856 LOG(WARNING) << "Attempt to delete non-existant remembered network: " | 2596 LOG(WARNING) << "Attempt to delete non-existent remembered network: " |
| 3857 << service_path; | 2597 << service_path; |
| 3858 return; | 2598 return; |
| 3859 } | 2599 } |
| 3860 | 2600 |
| 3861 // Delete remembered network from lists. | 2601 // Delete remembered network from lists. |
| 3862 Network* remembered_network = found->second; | 2602 Network* remembered_network = found->second; |
| 3863 remembered_network_map_.erase(found); | 2603 remembered_network_map_.erase(found); |
| 3864 | 2604 |
| 3865 if (remembered_network->type() == TYPE_WIFI) { | 2605 if (remembered_network->type() == TYPE_WIFI) { |
| 3866 WifiNetworkVector::iterator iter = std::find( | 2606 WifiNetworkVector::iterator iter = std::find( |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3921 case TYPE_CELLULAR: { | 2661 case TYPE_CELLULAR: { |
| 3922 CellularNetwork* cellular = new CellularNetwork(service_path); | 2662 CellularNetwork* cellular = new CellularNetwork(service_path); |
| 3923 return cellular; | 2663 return cellular; |
| 3924 } | 2664 } |
| 3925 case TYPE_VPN: { | 2665 case TYPE_VPN: { |
| 3926 VirtualNetwork* vpn = new VirtualNetwork(service_path); | 2666 VirtualNetwork* vpn = new VirtualNetwork(service_path); |
| 3927 return vpn; | 2667 return vpn; |
| 3928 } | 2668 } |
| 3929 default: { | 2669 default: { |
| 3930 LOG(WARNING) << "Unknown service type: " << type; | 2670 LOG(WARNING) << "Unknown service type: " << type; |
| 3931 return new Network(service_path, type); | 2671 return new Network(service_path, type, NULL); |
| 3932 } | 2672 } |
| 3933 } | 2673 } |
| 3934 } | 2674 } |
| 3935 | 2675 |
| 3936 //////////////////////////////////////////////////////////////////////////// | 2676 //////////////////////////////////////////////////////////////////////////// |
| 3937 | 2677 |
| 3938 void NetworkLibraryImplBase::ClearNetworks() { | 2678 void NetworkLibraryImplBase::ClearNetworks() { |
| 3939 network_map_.clear(); | 2679 network_map_.clear(); |
| 3940 network_unique_id_map_.clear(); | 2680 network_unique_id_map_.clear(); |
| 3941 ethernet_ = NULL; | 2681 ethernet_ = NULL; |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 3959 } | 2699 } |
| 3960 | 2700 |
| 3961 void NetworkLibraryImplBase::DeleteRememberedNetworks() { | 2701 void NetworkLibraryImplBase::DeleteRememberedNetworks() { |
| 3962 STLDeleteValues(&remembered_network_map_); | 2702 STLDeleteValues(&remembered_network_map_); |
| 3963 ClearRememberedNetworks(); | 2703 ClearRememberedNetworks(); |
| 3964 } | 2704 } |
| 3965 | 2705 |
| 3966 void NetworkLibraryImplBase::DeleteDevice(const std::string& device_path) { | 2706 void NetworkLibraryImplBase::DeleteDevice(const std::string& device_path) { |
| 3967 NetworkDeviceMap::iterator found = device_map_.find(device_path); | 2707 NetworkDeviceMap::iterator found = device_map_.find(device_path); |
| 3968 if (found == device_map_.end()) { | 2708 if (found == device_map_.end()) { |
| 3969 LOG(WARNING) << "Attempt to delete non-existant device: " | 2709 LOG(WARNING) << "Attempt to delete non-existent device: " |
| 3970 << device_path; | 2710 << device_path; |
| 3971 return; | 2711 return; |
| 3972 } | 2712 } |
| 3973 VLOG(2) << " Deleting device: " << device_path; | 2713 VLOG(2) << " Deleting device: " << device_path; |
| 3974 NetworkDevice* device = found->second; | 2714 NetworkDevice* device = found->second; |
| 3975 device_map_.erase(found); | 2715 device_map_.erase(found); |
| 3976 delete device; | 2716 delete device; |
| 3977 DeleteDeviceFromDeviceObserversMap(device_path); | 2717 DeleteDeviceFromDeviceObserversMap(device_path); |
| 3978 } | 2718 } |
| 3979 | 2719 |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4184 const std::string& device_path) OVERRIDE; | 2924 const std::string& device_path) OVERRIDE; |
| 4185 virtual void MonitorNetworkDeviceStop( | 2925 virtual void MonitorNetworkDeviceStop( |
| 4186 const std::string& device_path) OVERRIDE; | 2926 const std::string& device_path) OVERRIDE; |
| 4187 | 2927 |
| 4188 virtual void CallConnectToNetwork(Network* network) OVERRIDE; | 2928 virtual void CallConnectToNetwork(Network* network) OVERRIDE; |
| 4189 virtual void CallRequestWifiNetworkAndConnect( | 2929 virtual void CallRequestWifiNetworkAndConnect( |
| 4190 const std::string& ssid, ConnectionSecurity security) OVERRIDE; | 2930 const std::string& ssid, ConnectionSecurity security) OVERRIDE; |
| 4191 virtual void CallRequestVirtualNetworkAndConnect( | 2931 virtual void CallRequestVirtualNetworkAndConnect( |
| 4192 const std::string& service_name, | 2932 const std::string& service_name, |
| 4193 const std::string& server_hostname, | 2933 const std::string& server_hostname, |
| 4194 VirtualNetwork::ProviderType provider_type) OVERRIDE; | 2934 ProviderType provider_type) OVERRIDE; |
| 4195 virtual void CallDeleteRememberedNetwork( | 2935 virtual void CallDeleteRememberedNetwork( |
| 4196 const std::string& profile_path, | 2936 const std::string& profile_path, |
| 4197 const std::string& service_path) OVERRIDE; | 2937 const std::string& service_path) OVERRIDE; |
| 4198 | 2938 |
| 4199 ////////////////////////////////////////////////////////////////////////////// | 2939 ////////////////////////////////////////////////////////////////////////////// |
| 4200 // NetworkLibrary implementation. | 2940 // NetworkLibrary implementation. |
| 4201 | 2941 |
| 4202 virtual void ChangePin(const std::string& old_pin, | 2942 virtual void ChangePin(const std::string& old_pin, |
| 4203 const std::string& new_pin) OVERRIDE; | 2943 const std::string& new_pin) OVERRIDE; |
| 4204 virtual void ChangeRequirePin(bool require_pin, | 2944 virtual void ChangeRequirePin(bool require_pin, |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 4221 const std::string& device_path, | 2961 const std::string& device_path, |
| 4222 std::string* hardware_address, | 2962 std::string* hardware_address, |
| 4223 HardwareAddressFormat format) OVERRIDE; | 2963 HardwareAddressFormat format) OVERRIDE; |
| 4224 virtual void SetIPConfig(const NetworkIPConfig& ipconfig) OVERRIDE; | 2964 virtual void SetIPConfig(const NetworkIPConfig& ipconfig) OVERRIDE; |
| 4225 | 2965 |
| 4226 ////////////////////////////////////////////////////////////////////////////// | 2966 ////////////////////////////////////////////////////////////////////////////// |
| 4227 // Calbacks. | 2967 // Calbacks. |
| 4228 static void NetworkStatusChangedHandler( | 2968 static void NetworkStatusChangedHandler( |
| 4229 void* object, const char* path, const char* key, const Value* value); | 2969 void* object, const char* path, const char* key, const Value* value); |
| 4230 void UpdateNetworkStatus( | 2970 void UpdateNetworkStatus( |
| 4231 const char* path, const char* key, const Value* value); | 2971 const std::string& path, const std::string& key, const Value& value); |
| 4232 | 2972 |
| 4233 static void NetworkDevicePropertyChangedHandler( | 2973 static void NetworkDevicePropertyChangedHandler( |
| 4234 void* object, const char* path, const char* key, const Value* value); | 2974 void* object, const char* path, const char* key, const Value* value); |
| 4235 void UpdateNetworkDeviceStatus( | 2975 void UpdateNetworkDeviceStatus( |
| 4236 const char* path, const char* key, const Value* value); | 2976 const std::string& path, const std::string& key, const Value& value); |
| 4237 | 2977 |
| 4238 static void PinOperationCallback(void* object, | 2978 static void PinOperationCallback(void* object, |
| 4239 const char* path, | 2979 const char* path, |
| 4240 NetworkMethodErrorType error, | 2980 NetworkMethodErrorType error, |
| 4241 const char* error_message); | 2981 const char* error_message); |
| 4242 | 2982 |
| 4243 static void CellularRegisterCallback(void* object, | 2983 static void CellularRegisterCallback(void* object, |
| 4244 const char* path, | 2984 const char* path, |
| 4245 NetworkMethodErrorType error, | 2985 NetworkMethodErrorType error, |
| 4246 const char* error_message); | 2986 const char* error_message); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 4269 static void RememberedNetworkServiceUpdate( | 3009 static void RememberedNetworkServiceUpdate( |
| 4270 void* object, const char* service_path, const Value* info); | 3010 void* object, const char* service_path, const Value* info); |
| 4271 static void ProfileUpdate( | 3011 static void ProfileUpdate( |
| 4272 void* object, const char* profile_path, const Value* info); | 3012 void* object, const char* profile_path, const Value* info); |
| 4273 static void NetworkDeviceUpdate( | 3013 static void NetworkDeviceUpdate( |
| 4274 void* object, const char* device_path, const Value* info); | 3014 void* object, const char* device_path, const Value* info); |
| 4275 | 3015 |
| 4276 private: | 3016 private: |
| 4277 // This processes all Manager update messages. | 3017 // This processes all Manager update messages. |
| 4278 void NetworkManagerStatusChanged(const char* key, const Value* value); | 3018 void NetworkManagerStatusChanged(const char* key, const Value* value); |
| 4279 void ParseNetworkManager(const DictionaryValue* dict); | 3019 void ParseNetworkManager(const DictionaryValue& dict); |
| 4280 void UpdateTechnologies(const ListValue* technologies, int* bitfieldp); | 3020 void UpdateTechnologies(const ListValue* technologies, int* bitfieldp); |
| 4281 void UpdateAvailableTechnologies(const ListValue* technologies); | 3021 void UpdateAvailableTechnologies(const ListValue* technologies); |
| 4282 void UpdateEnabledTechnologies(const ListValue* technologies); | 3022 void UpdateEnabledTechnologies(const ListValue* technologies); |
| 4283 void UpdateConnectedTechnologies(const ListValue* technologies); | 3023 void UpdateConnectedTechnologies(const ListValue* technologies); |
| 4284 | 3024 |
| 4285 // Update network lists. | 3025 // Update network lists. |
| 4286 void UpdateNetworkServiceList(const ListValue* services); | 3026 void UpdateNetworkServiceList(const ListValue* services); |
| 4287 void UpdateWatchedNetworkServiceList(const ListValue* services); | 3027 void UpdateWatchedNetworkServiceList(const ListValue* services); |
| 4288 Network* ParseNetwork(const std::string& service_path, | 3028 Network* ParseNetwork(const std::string& service_path, |
| 4289 const DictionaryValue* info); | 3029 const DictionaryValue& info); |
| 4290 | 3030 |
| 4291 void UpdateRememberedNetworks(const ListValue* profiles); | 3031 void UpdateRememberedNetworks(const ListValue* profiles); |
| 4292 void RequestRememberedNetworksUpdate(); | 3032 void RequestRememberedNetworksUpdate(); |
| 4293 void UpdateRememberedServiceList(const char* profile_path, | 3033 void UpdateRememberedServiceList(const char* profile_path, |
| 4294 const ListValue* profile_entries); | 3034 const ListValue* profile_entries); |
| 4295 Network* ParseRememberedNetwork(const std::string& service_path, | 3035 Network* ParseRememberedNetwork(const std::string& service_path, |
| 4296 const DictionaryValue* info); | 3036 const DictionaryValue& info); |
| 4297 | 3037 |
| 4298 // NetworkDevice list management functions. | 3038 // NetworkDevice list management functions. |
| 4299 void UpdateNetworkDeviceList(const ListValue* devices); | 3039 void UpdateNetworkDeviceList(const ListValue* devices); |
| 4300 void ParseNetworkDevice(const std::string& device_path, | 3040 void ParseNetworkDevice(const std::string& device_path, |
| 4301 const DictionaryValue* info); | 3041 const DictionaryValue& info); |
| 4302 | 3042 |
| 4303 // Empty device observer to ensure that device property updates are received. | 3043 // Empty device observer to ensure that device property updates are received. |
| 4304 class NetworkLibraryDeviceObserver : public NetworkDeviceObserver { | 3044 class NetworkLibraryDeviceObserver : public NetworkDeviceObserver { |
| 4305 public: | 3045 public: |
| 4306 virtual ~NetworkLibraryDeviceObserver() {} | 3046 virtual ~NetworkLibraryDeviceObserver() {} |
| 4307 virtual void OnNetworkDeviceChanged( | 3047 virtual void OnNetworkDeviceChanged( |
| 4308 NetworkLibrary* cros, const NetworkDevice* device) OVERRIDE {} | 3048 NetworkLibrary* cros, const NetworkDevice* device) OVERRIDE {} |
| 4309 }; | 3049 }; |
| 4310 | 3050 |
| 4311 typedef std::map<std::string, chromeos::PropertyChangeMonitor> | 3051 typedef std::map<std::string, chromeos::PropertyChangeMonitor> |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4411 montitored_devices_.erase(iter); | 3151 montitored_devices_.erase(iter); |
| 4412 } | 3152 } |
| 4413 } | 3153 } |
| 4414 | 3154 |
| 4415 // static callback | 3155 // static callback |
| 4416 void NetworkLibraryImplCros::NetworkStatusChangedHandler( | 3156 void NetworkLibraryImplCros::NetworkStatusChangedHandler( |
| 4417 void* object, const char* path, const char* key, const Value* value) { | 3157 void* object, const char* path, const char* key, const Value* value) { |
| 4418 NetworkLibraryImplCros* networklib = | 3158 NetworkLibraryImplCros* networklib = |
| 4419 static_cast<NetworkLibraryImplCros*>(object); | 3159 static_cast<NetworkLibraryImplCros*>(object); |
| 4420 DCHECK(networklib); | 3160 DCHECK(networklib); |
| 4421 networklib->UpdateNetworkStatus(path, key, value); | 3161 if (key == NULL || value == NULL) |
|
stevenjb
2011/08/05 18:46:58
Add a NULL check for path since string conversion
| |
| 3162 return; | |
| 3163 networklib->UpdateNetworkStatus(path, key, *value); | |
|
stevenjb
2011/08/05 18:46:58
nit: Even though we do a NULL check here, we shoul
Greg Spencer (Chromium)
2011/08/11 22:19:32
You mean implicit, right?
OK, I've added these in
stevenjb
2011/08/12 21:32:37
Right, yes. Cool.
| |
| 4422 } | 3164 } |
| 4423 | 3165 |
| 4424 void NetworkLibraryImplCros::UpdateNetworkStatus( | 3166 void NetworkLibraryImplCros::UpdateNetworkStatus( |
| 4425 const char* path, const char* key, const Value* value) { | 3167 const std::string& path, const std::string& key, const Value& value) { |
| 4426 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 3168 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 4427 if (key == NULL || value == NULL) | |
| 4428 return; | |
| 4429 Network* network = FindNetworkByPath(path); | 3169 Network* network = FindNetworkByPath(path); |
| 4430 if (network) { | 3170 if (network) { |
| 4431 VLOG(2) << "UpdateNetworkStatus: " << network->name() << "." << key; | 3171 VLOG(2) << "UpdateNetworkStatus: " << network->name() << "." << key; |
| 4432 bool prev_connected = network->connected(); | 3172 bool prev_connected = network->connected(); |
| 4433 // Note: ParseValue is virtual. | 3173 if (!network->UpdateStatus(key, value, NULL)) { |
| 4434 int index = property_index_parser().Get(std::string(key)); | 3174 LOG(WARNING) << "UpdateNetworkStatus: Error updating: " |
| 4435 if (!network->ParseValue(index, value)) { | |
| 4436 LOG(WARNING) << "UpdateNetworkStatus: Error parsing: " | |
| 4437 << path << "." << key; | 3175 << path << "." << key; |
| 4438 } | 3176 } |
| 4439 // If we just connected, this may have been added to remembered list. | 3177 // If we just connected, this may have been added to remembered list. |
| 4440 if (!prev_connected && network->connected()) | 3178 if (!prev_connected && network->connected()) |
| 4441 RequestRememberedNetworksUpdate(); | 3179 RequestRememberedNetworksUpdate(); |
| 4442 NotifyNetworkChanged(network); | 3180 NotifyNetworkChanged(network); |
| 4443 // Anything observing the manager needs to know about any service change. | 3181 // Anything observing the manager needs to know about any service change. |
| 4444 NotifyNetworkManagerChanged(false); // Not forced. | 3182 NotifyNetworkManagerChanged(false); // Not forced. |
| 4445 } | 3183 } |
| 4446 } | 3184 } |
| 4447 | 3185 |
| 4448 // static callback | 3186 // static callback |
| 4449 void NetworkLibraryImplCros::NetworkDevicePropertyChangedHandler( | 3187 void NetworkLibraryImplCros::NetworkDevicePropertyChangedHandler( |
| 4450 void* object, const char* path, const char* key, const Value* value) { | 3188 void* object, const char* path, const char* key, const Value* value) { |
| 4451 NetworkLibraryImplCros* networklib = | 3189 NetworkLibraryImplCros* networklib = |
| 4452 static_cast<NetworkLibraryImplCros*>(object); | 3190 static_cast<NetworkLibraryImplCros*>(object); |
| 4453 DCHECK(networklib); | 3191 DCHECK(networklib); |
| 4454 networklib->UpdateNetworkDeviceStatus(path, key, value); | 3192 if (key == NULL || value == NULL) |
| 3193 return; | |
| 3194 networklib->UpdateNetworkDeviceStatus(path, key, *value); | |
| 4455 } | 3195 } |
| 4456 | 3196 |
| 4457 void NetworkLibraryImplCros::UpdateNetworkDeviceStatus( | 3197 void NetworkLibraryImplCros::UpdateNetworkDeviceStatus( |
| 4458 const char* path, const char* key, const Value* value) { | 3198 const std::string& path, const std::string& key, const Value& value) { |
| 4459 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 3199 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 4460 if (key == NULL || value == NULL) | |
| 4461 return; | |
| 4462 NetworkDevice* device = FindNetworkDeviceByPath(path); | 3200 NetworkDevice* device = FindNetworkDeviceByPath(path); |
| 4463 if (device) { | 3201 if (device) { |
| 4464 VLOG(2) << "UpdateNetworkDeviceStatus: " << device->name() << "." << key; | 3202 VLOG(2) << "UpdateNetworkDeviceStatus: " << device->name() << "." << key; |
| 4465 PropertyIndex index = property_index_parser().Get(std::string(key)); | 3203 PropertyIndex index = PROPERTY_INDEX_UNKNOWN; |
| 4466 if (!device->ParseValue(index, value)) { | 3204 if (!device->UpdateStatus(key, value, &index)) { |
|
stevenjb
2011/08/05 18:46:58
This logic is a little hard to follow now - index,
Greg Spencer (Chromium)
2011/08/11 22:19:32
OK, I've switched it, it should be more clear now.
| |
| 4467 VLOG(1) << "UpdateNetworkDeviceStatus: Failed to parse: " | 3205 VLOG(1) << "UpdateNetworkDeviceStatus: Failed to update: " |
| 4468 << path << "." << key; | 3206 << path << "." << key; |
| 4469 } else if (index == PROPERTY_INDEX_CELLULAR_ALLOW_ROAMING) { | 3207 } else if (index == PROPERTY_INDEX_CELLULAR_ALLOW_ROAMING) { |
| 4470 bool settings_value = | 3208 bool settings_value = |
| 4471 UserCrosSettingsProvider::cached_data_roaming_enabled(); | 3209 UserCrosSettingsProvider::cached_data_roaming_enabled(); |
| 4472 if (device->data_roaming_allowed() != settings_value) { | 3210 if (device->data_roaming_allowed() != settings_value) { |
| 4473 // Switch back to signed settings value. | 3211 // Switch back to signed settings value. |
| 4474 SetCellularDataRoamingAllowed(settings_value); | 3212 SetCellularDataRoamingAllowed(settings_value); |
| 4475 return; | 3213 return; |
| 4476 } | 3214 } |
| 4477 } | 3215 } |
| 4478 // Notify only observers on device property change. | 3216 // Notify only observers on device property change. |
| 4479 NotifyNetworkDeviceChanged(device, index); | 3217 NotifyNetworkDeviceChanged(device, index); |
| 4480 // If a device's power state changes, new properties may become defined. | 3218 // If a device's power state changes, new properties may become defined. |
| 4481 if (index == PROPERTY_INDEX_POWERED) | 3219 if (index == PROPERTY_INDEX_POWERED) |
| 4482 chromeos::RequestNetworkDeviceInfo(path, &NetworkDeviceUpdate, this); | 3220 chromeos::RequestNetworkDeviceInfo(path.c_str(), |
| 3221 &NetworkDeviceUpdate, | |
| 3222 this); | |
| 4483 } | 3223 } |
| 4484 } | 3224 } |
| 4485 | 3225 |
| 4486 ///////////////////////////////////////////////////////////////////////////// | 3226 ///////////////////////////////////////////////////////////////////////////// |
| 4487 // NetworkLibraryImplBase connect implementation. | 3227 // NetworkLibraryImplBase connect implementation. |
| 4488 | 3228 |
| 4489 // static callback | 3229 // static callback |
| 4490 void NetworkLibraryImplCros::NetworkConnectCallback( | 3230 void NetworkLibraryImplCros::NetworkConnectCallback( |
| 4491 void* object, | 3231 void* object, |
| 4492 const char* service_path, | 3232 const char* service_path, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4525 // static callback | 3265 // static callback |
| 4526 void NetworkLibraryImplCros::WifiServiceUpdateAndConnect( | 3266 void NetworkLibraryImplCros::WifiServiceUpdateAndConnect( |
| 4527 void* object, const char* service_path, const Value* info) { | 3267 void* object, const char* service_path, const Value* info) { |
| 4528 NetworkLibraryImplCros* networklib = | 3268 NetworkLibraryImplCros* networklib = |
| 4529 static_cast<NetworkLibraryImplCros*>(object); | 3269 static_cast<NetworkLibraryImplCros*>(object); |
| 4530 DCHECK(networklib); | 3270 DCHECK(networklib); |
| 4531 if (service_path && info) { | 3271 if (service_path && info) { |
| 4532 DCHECK_EQ(info->GetType(), Value::TYPE_DICTIONARY); | 3272 DCHECK_EQ(info->GetType(), Value::TYPE_DICTIONARY); |
| 4533 const DictionaryValue* dict = static_cast<const DictionaryValue*>(info); | 3273 const DictionaryValue* dict = static_cast<const DictionaryValue*>(info); |
| 4534 Network* network = | 3274 Network* network = |
| 4535 networklib->ParseNetwork(std::string(service_path), dict); | 3275 networklib->ParseNetwork(std::string(service_path), *dict); |
| 4536 DCHECK_EQ(network->type(), TYPE_WIFI); | 3276 DCHECK_EQ(network->type(), TYPE_WIFI); |
| 4537 networklib->ConnectToWifiNetworkUsingConnectData( | 3277 networklib->ConnectToWifiNetworkUsingConnectData( |
| 4538 static_cast<WifiNetwork*>(network)); | 3278 static_cast<WifiNetwork*>(network)); |
| 4539 } | 3279 } |
| 4540 } | 3280 } |
| 4541 | 3281 |
| 4542 void NetworkLibraryImplCros::CallRequestWifiNetworkAndConnect( | 3282 void NetworkLibraryImplCros::CallRequestWifiNetworkAndConnect( |
| 4543 const std::string& ssid, ConnectionSecurity security) { | 3283 const std::string& ssid, ConnectionSecurity security) { |
| 4544 // Asynchronously request service properties and call | 3284 // Asynchronously request service properties and call |
| 4545 // WifiServiceUpdateAndConnect. | 3285 // WifiServiceUpdateAndConnect. |
| 4546 chromeos::RequestHiddenWifiNetwork(ssid.c_str(), | 3286 chromeos::RequestHiddenWifiNetwork(ssid.c_str(), |
| 4547 SecurityToString(security), | 3287 SecurityToString(security), |
| 4548 WifiServiceUpdateAndConnect, | 3288 WifiServiceUpdateAndConnect, |
| 4549 this); | 3289 this); |
| 4550 } | 3290 } |
| 4551 | 3291 |
| 4552 // static callback | 3292 // static callback |
| 4553 void NetworkLibraryImplCros::VPNServiceUpdateAndConnect( | 3293 void NetworkLibraryImplCros::VPNServiceUpdateAndConnect( |
| 4554 void* object, const char* service_path, const Value* info) { | 3294 void* object, const char* service_path, const Value* info) { |
| 4555 NetworkLibraryImplCros* networklib = | 3295 NetworkLibraryImplCros* networklib = |
| 4556 static_cast<NetworkLibraryImplCros*>(object); | 3296 static_cast<NetworkLibraryImplCros*>(object); |
| 4557 DCHECK(networklib); | 3297 DCHECK(networklib); |
| 4558 if (service_path && info) { | 3298 if (service_path && info) { |
| 4559 VLOG(1) << "Connecting to new VPN Service: " << service_path; | 3299 VLOG(1) << "Connecting to new VPN Service: " << service_path; |
| 4560 DCHECK_EQ(info->GetType(), Value::TYPE_DICTIONARY); | 3300 DCHECK_EQ(info->GetType(), Value::TYPE_DICTIONARY); |
| 4561 const DictionaryValue* dict = static_cast<const DictionaryValue*>(info); | 3301 const DictionaryValue* dict = static_cast<const DictionaryValue*>(info); |
| 4562 Network* network = | 3302 Network* network = |
| 4563 networklib->ParseNetwork(std::string(service_path), dict); | 3303 networklib->ParseNetwork(std::string(service_path), *dict); |
| 4564 DCHECK_EQ(network->type(), TYPE_VPN); | 3304 DCHECK_EQ(network->type(), TYPE_VPN); |
| 4565 networklib->ConnectToVirtualNetworkUsingConnectData( | 3305 networklib->ConnectToVirtualNetworkUsingConnectData( |
| 4566 static_cast<VirtualNetwork*>(network)); | 3306 static_cast<VirtualNetwork*>(network)); |
| 4567 } else { | 3307 } else { |
| 4568 LOG(WARNING) << "Unable to create VPN Service: " << service_path; | 3308 LOG(WARNING) << "Unable to create VPN Service: " << service_path; |
| 4569 } | 3309 } |
| 4570 } | 3310 } |
| 4571 | 3311 |
| 4572 void NetworkLibraryImplCros::CallRequestVirtualNetworkAndConnect( | 3312 void NetworkLibraryImplCros::CallRequestVirtualNetworkAndConnect( |
| 4573 const std::string& service_name, | 3313 const std::string& service_name, |
| 4574 const std::string& server_hostname, | 3314 const std::string& server_hostname, |
| 4575 VirtualNetwork::ProviderType provider_type) { | 3315 ProviderType provider_type) { |
| 4576 chromeos::RequestVirtualNetwork(service_name.c_str(), | 3316 chromeos::RequestVirtualNetwork(service_name.c_str(), |
| 4577 server_hostname.c_str(), | 3317 server_hostname.c_str(), |
| 4578 ProviderTypeToString(provider_type), | 3318 ProviderTypeToString(provider_type), |
| 4579 VPNServiceUpdateAndConnect, | 3319 VPNServiceUpdateAndConnect, |
| 4580 this); | 3320 this); |
| 4581 } | 3321 } |
| 4582 | 3322 |
| 4583 void NetworkLibraryImplCros::CallDeleteRememberedNetwork( | 3323 void NetworkLibraryImplCros::CallDeleteRememberedNetwork( |
| 4584 const std::string& profile_path, | 3324 const std::string& profile_path, |
| 4585 const std::string& service_path) { | 3325 const std::string& service_path) { |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4921 } | 3661 } |
| 4922 | 3662 |
| 4923 // This processes all Manager update messages. | 3663 // This processes all Manager update messages. |
| 4924 void NetworkLibraryImplCros::NetworkManagerStatusChanged( | 3664 void NetworkLibraryImplCros::NetworkManagerStatusChanged( |
| 4925 const char* key, const Value* value) { | 3665 const char* key, const Value* value) { |
| 4926 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 3666 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 4927 base::TimeTicks start = base::TimeTicks::Now(); | 3667 base::TimeTicks start = base::TimeTicks::Now(); |
| 4928 if (!key) | 3668 if (!key) |
| 4929 return; | 3669 return; |
| 4930 VLOG(1) << "NetworkManagerStatusChanged: KEY=" << key; | 3670 VLOG(1) << "NetworkManagerStatusChanged: KEY=" << key; |
| 4931 int index = property_index_parser().Get(std::string(key)); | 3671 int index = NativeNetworkParser::property_mapper()->Get(key); |
| 4932 switch (index) { | 3672 switch (index) { |
| 4933 case PROPERTY_INDEX_STATE: | 3673 case PROPERTY_INDEX_STATE: |
| 4934 // Currently we ignore the network manager state. | 3674 // Currently we ignore the network manager state. |
| 4935 break; | 3675 break; |
| 4936 case PROPERTY_INDEX_AVAILABLE_TECHNOLOGIES: { | 3676 case PROPERTY_INDEX_AVAILABLE_TECHNOLOGIES: { |
| 4937 DCHECK_EQ(value->GetType(), Value::TYPE_LIST); | 3677 DCHECK_EQ(value->GetType(), Value::TYPE_LIST); |
| 4938 const ListValue* vlist = static_cast<const ListValue*>(value); | 3678 const ListValue* vlist = static_cast<const ListValue*>(value); |
| 4939 UpdateAvailableTechnologies(vlist); | 3679 UpdateAvailableTechnologies(vlist); |
| 4940 break; | 3680 break; |
| 4941 } | 3681 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4987 } | 3727 } |
| 4988 case PROPERTY_INDEX_DEVICE: | 3728 case PROPERTY_INDEX_DEVICE: |
| 4989 case PROPERTY_INDEX_DEVICES: { | 3729 case PROPERTY_INDEX_DEVICES: { |
| 4990 DCHECK_EQ(value->GetType(), Value::TYPE_LIST); | 3730 DCHECK_EQ(value->GetType(), Value::TYPE_LIST); |
| 4991 const ListValue* vlist = static_cast<const ListValue*>(value); | 3731 const ListValue* vlist = static_cast<const ListValue*>(value); |
| 4992 UpdateNetworkDeviceList(vlist); | 3732 UpdateNetworkDeviceList(vlist); |
| 4993 break; | 3733 break; |
| 4994 } | 3734 } |
| 4995 case PROPERTY_INDEX_PORTAL_URL: | 3735 case PROPERTY_INDEX_PORTAL_URL: |
| 4996 case PROPERTY_INDEX_CHECK_PORTAL_LIST: | 3736 case PROPERTY_INDEX_CHECK_PORTAL_LIST: |
| 4997 // Currently we ignore PortalURL and CheckPortalList. | 3737 case PROPERTY_INDEX_ARP_GATEWAY: |
|
Greg Spencer (Chromium)
2011/08/04 23:02:14
I added this to stop the "unhandled key" warning b
stevenjb
2011/08/05 18:46:58
Thanks, that's why there is a warning here, so we
| |
| 3738 // Currently we ignore PortalURL, CheckPortalList and ArpGateway. | |
| 4998 break; | 3739 break; |
| 4999 default: | 3740 default: |
| 5000 LOG(WARNING) << "Manager: Unhandled key: " << key; | 3741 LOG(WARNING) << "Manager: Unhandled key: " << key; |
| 5001 break; | 3742 break; |
| 5002 } | 3743 } |
| 5003 base::TimeDelta delta = base::TimeTicks::Now() - start; | 3744 base::TimeDelta delta = base::TimeTicks::Now() - start; |
| 5004 VLOG(2) << "NetworkManagerStatusChanged: time: " | 3745 VLOG(2) << "NetworkManagerStatusChanged: time: " |
| 5005 << delta.InMilliseconds() << " ms."; | 3746 << delta.InMilliseconds() << " ms."; |
| 5006 HISTOGRAM_TIMES("CROS_NETWORK_UPDATE", delta); | 3747 HISTOGRAM_TIMES("CROS_NETWORK_UPDATE", delta); |
| 5007 } | 3748 } |
| 5008 | 3749 |
| 5009 // static | 3750 // static |
| 5010 void NetworkLibraryImplCros::NetworkManagerUpdate( | 3751 void NetworkLibraryImplCros::NetworkManagerUpdate( |
| 5011 void* object, const char* manager_path, const Value* info) { | 3752 void* object, const char* manager_path, const Value* info) { |
| 5012 NetworkLibraryImplCros* networklib = | 3753 NetworkLibraryImplCros* networklib = |
| 5013 static_cast<NetworkLibraryImplCros*>(object); | 3754 static_cast<NetworkLibraryImplCros*>(object); |
| 5014 DCHECK(networklib); | 3755 DCHECK(networklib); |
| 5015 if (!info) { | 3756 if (!info) { |
| 5016 LOG(ERROR) << "Error retrieving manager properties: " << manager_path; | 3757 LOG(ERROR) << "Error retrieving manager properties: " << manager_path; |
| 5017 return; | 3758 return; |
| 5018 } | 3759 } |
| 5019 VLOG(1) << "Received NetworkManagerUpdate."; | 3760 VLOG(1) << "Received NetworkManagerUpdate."; |
| 5020 DCHECK_EQ(info->GetType(), Value::TYPE_DICTIONARY); | 3761 DCHECK_EQ(info->GetType(), Value::TYPE_DICTIONARY); |
| 5021 const DictionaryValue* dict = static_cast<const DictionaryValue*>(info); | 3762 const DictionaryValue* dict = static_cast<const DictionaryValue*>(info); |
| 5022 networklib->ParseNetworkManager(dict); | 3763 networklib->ParseNetworkManager(*dict); |
| 5023 } | 3764 } |
| 5024 | 3765 |
| 5025 void NetworkLibraryImplCros::ParseNetworkManager(const DictionaryValue* dict) { | 3766 void NetworkLibraryImplCros::ParseNetworkManager(const DictionaryValue& dict) { |
| 5026 for (DictionaryValue::key_iterator iter = dict->begin_keys(); | 3767 for (DictionaryValue::key_iterator iter = dict.begin_keys(); |
| 5027 iter != dict->end_keys(); ++iter) { | 3768 iter != dict.end_keys(); ++iter) { |
| 5028 const std::string& key = *iter; | 3769 const std::string& key = *iter; |
| 5029 Value* value; | 3770 Value* value; |
| 5030 bool res = dict->GetWithoutPathExpansion(key, &value); | 3771 bool res = dict.GetWithoutPathExpansion(key, &value); |
| 5031 CHECK(res); | 3772 CHECK(res); |
| 5032 NetworkManagerStatusChanged(key.c_str(), value); | 3773 NetworkManagerStatusChanged(key.c_str(), value); |
| 5033 } | 3774 } |
| 5034 // If there is no Profiles entry, request remembered networks here. | 3775 // If there is no Profiles entry, request remembered networks here. |
| 5035 if (!dict->HasKey(kProfilesProperty)) | 3776 if (!dict.HasKey(kProfilesProperty)) |
| 5036 RequestRememberedNetworksUpdate(); | 3777 RequestRememberedNetworksUpdate(); |
| 5037 } | 3778 } |
| 5038 | 3779 |
| 5039 // static | 3780 // static |
| 5040 void NetworkLibraryImplCros::DataPlanUpdateHandler( | 3781 void NetworkLibraryImplCros::DataPlanUpdateHandler( |
| 5041 void* object, | 3782 void* object, |
| 5042 const char* modem_service_path, | 3783 const char* modem_service_path, |
| 5043 const CellularDataPlanList* dataplan) { | 3784 const CellularDataPlanList* dataplan) { |
| 5044 NetworkLibraryImplCros* networklib = | 3785 NetworkLibraryImplCros* networklib = |
| 5045 static_cast<NetworkLibraryImplCros*>(object); | 3786 static_cast<NetworkLibraryImplCros*>(object); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 5056 const ListValue* technologies, int* bitfieldp) { | 3797 const ListValue* technologies, int* bitfieldp) { |
| 5057 DCHECK(bitfieldp); | 3798 DCHECK(bitfieldp); |
| 5058 if (!technologies) | 3799 if (!technologies) |
| 5059 return; | 3800 return; |
| 5060 int bitfield = 0; | 3801 int bitfield = 0; |
| 5061 for (ListValue::const_iterator iter = technologies->begin(); | 3802 for (ListValue::const_iterator iter = technologies->begin(); |
| 5062 iter != technologies->end(); ++iter) { | 3803 iter != technologies->end(); ++iter) { |
| 5063 std::string technology; | 3804 std::string technology; |
| 5064 (*iter)->GetAsString(&technology); | 3805 (*iter)->GetAsString(&technology); |
| 5065 if (!technology.empty()) { | 3806 if (!technology.empty()) { |
| 5066 ConnectionType type = ParseType(technology); | 3807 ConnectionType type = |
| 3808 NativeNetworkParser::ParseConnectionType(technology); | |
|
Greg Spencer (Chromium)
2011/08/04 23:02:14
I think this call to the native parser is unfortun
stevenjb
2011/08/05 18:46:58
Just a thought, but the 'Native' has been botherin
Greg Spencer (Chromium)
2011/08/11 22:19:32
Well, but we're already in the chromeos/cros direc
| |
| 5067 bitfield |= 1 << type; | 3809 bitfield |= 1 << type; |
| 5068 } | 3810 } |
| 5069 } | 3811 } |
| 5070 *bitfieldp = bitfield; | 3812 *bitfieldp = bitfield; |
| 5071 NotifyNetworkManagerChanged(false); // Not forced. | 3813 NotifyNetworkManagerChanged(false); // Not forced. |
| 5072 } | 3814 } |
| 5073 | 3815 |
| 5074 void NetworkLibraryImplCros::UpdateAvailableTechnologies( | 3816 void NetworkLibraryImplCros::UpdateAvailableTechnologies( |
| 5075 const ListValue* technologies) { | 3817 const ListValue* technologies) { |
| 5076 UpdateTechnologies(technologies, &available_devices_); | 3818 UpdateTechnologies(technologies, &available_devices_); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5142 iter != old_network_map.end(); ++iter) { | 3884 iter != old_network_map.end(); ++iter) { |
| 5143 Network* network = iter->second; | 3885 Network* network = iter->second; |
| 5144 if (network->failed() && network->notify_failure()) { | 3886 if (network->failed() && network->notify_failure()) { |
| 5145 // We have not notified observers of a connection failure yet. | 3887 // We have not notified observers of a connection failure yet. |
| 5146 AddNetwork(network); | 3888 AddNetwork(network); |
| 5147 } else if (network->connecting()) { | 3889 } else if (network->connecting()) { |
| 5148 // Network was in connecting state; set state to failed. | 3890 // Network was in connecting state; set state to failed. |
| 5149 network->SetState(STATE_FAILURE); | 3891 network->SetState(STATE_FAILURE); |
| 5150 AddNetwork(network); | 3892 AddNetwork(network); |
| 5151 } else { | 3893 } else { |
| 5152 VLOG(2) << "Deleting non-existant Network: " << network->name() | 3894 VLOG(2) << "Deleting non-existent Network: " << network->name() |
| 5153 << " State = " << network->GetStateString(); | 3895 << " State = " << network->GetStateString(); |
| 5154 DeleteNetwork(network); | 3896 DeleteNetwork(network); |
| 5155 } | 3897 } |
| 5156 } | 3898 } |
| 5157 // If the last network has disappeared, nothing else will | 3899 // If the last network has disappeared, nothing else will |
| 5158 // have notified observers, so do it now. | 3900 // have notified observers, so do it now. |
| 5159 if (services->empty()) | 3901 if (services->empty()) |
| 5160 NotifyNetworkManagerChanged(true); // Forced update | 3902 NotifyNetworkManagerChanged(true); // Forced update |
| 5161 } | 3903 } |
| 5162 | 3904 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 5182 void NetworkLibraryImplCros::NetworkServiceUpdate( | 3924 void NetworkLibraryImplCros::NetworkServiceUpdate( |
| 5183 void* object, const char* service_path, const Value* info) { | 3925 void* object, const char* service_path, const Value* info) { |
| 5184 NetworkLibraryImplCros* networklib = | 3926 NetworkLibraryImplCros* networklib = |
| 5185 static_cast<NetworkLibraryImplCros*>(object); | 3927 static_cast<NetworkLibraryImplCros*>(object); |
| 5186 DCHECK(networklib); | 3928 DCHECK(networklib); |
| 5187 if (service_path) { | 3929 if (service_path) { |
| 5188 if (!info) | 3930 if (!info) |
| 5189 return; // Network no longer in visible list, ignore. | 3931 return; // Network no longer in visible list, ignore. |
| 5190 DCHECK_EQ(info->GetType(), Value::TYPE_DICTIONARY); | 3932 DCHECK_EQ(info->GetType(), Value::TYPE_DICTIONARY); |
| 5191 const DictionaryValue* dict = static_cast<const DictionaryValue*>(info); | 3933 const DictionaryValue* dict = static_cast<const DictionaryValue*>(info); |
| 5192 networklib->ParseNetwork(std::string(service_path), dict); | 3934 networklib->ParseNetwork(std::string(service_path), *dict); |
| 5193 } | 3935 } |
| 5194 } | 3936 } |
| 5195 | 3937 |
| 5196 // Called from NetworkServiceUpdate and WifiServiceUpdateAndConnect. | 3938 // Called from NetworkServiceUpdate and WifiServiceUpdateAndConnect. |
| 5197 Network* NetworkLibraryImplCros::ParseNetwork( | 3939 Network* NetworkLibraryImplCros::ParseNetwork( |
| 5198 const std::string& service_path, const DictionaryValue* info) { | 3940 const std::string& service_path, const DictionaryValue& info) { |
| 5199 Network* network = FindNetworkByPath(service_path); | 3941 Network* network = FindNetworkByPath(service_path); |
| 5200 if (!network) { | 3942 if (!network) { |
| 5201 ConnectionType type = ParseTypeFromDictionary(info); | 3943 NativeNetworkParser parser; |
| 5202 network = CreateNewNetwork(type, service_path); | 3944 network = parser.CreateNetworkFromInfo(service_path, info); |
| 5203 AddNetwork(network); | 3945 AddNetwork(network); |
| 3946 } else { | |
| 3947 // Erase entry from network_unique_id_map_ in case unique id changes. | |
| 3948 if (!network->unique_id().empty()) | |
| 3949 network_unique_id_map_.erase(network->unique_id()); | |
| 3950 network->network_parser()->UpdateNetworkFromInfo(info, network); | |
| 5204 } | 3951 } |
| 5205 | 3952 |
| 5206 // Erase entry from network_unique_id_map_ in case unique id changes. | |
| 5207 if (!network->unique_id().empty()) | |
| 5208 network_unique_id_map_.erase(network->unique_id()); | |
| 5209 | |
| 5210 network->ParseInfo(info); // virtual. | |
| 5211 | |
| 5212 if (!network->unique_id().empty()) | 3953 if (!network->unique_id().empty()) |
| 5213 network_unique_id_map_[network->unique_id()] = network; | 3954 network_unique_id_map_[network->unique_id()] = network; |
| 5214 | 3955 |
| 5215 SetProfileTypeFromPath(network); | 3956 SetProfileTypeFromPath(network); |
| 5216 | 3957 |
| 5217 UpdateActiveNetwork(network); | 3958 UpdateActiveNetwork(network); |
| 5218 | 3959 |
| 5219 // Copy remembered credentials if required. | 3960 // Copy remembered credentials if required. |
| 5220 Network* remembered = FindRememberedFromNetwork(network); | 3961 Network* remembered = FindRememberedFromNetwork(network); |
| 5221 if (remembered) | 3962 if (remembered) |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5360 NetworkLibraryImplCros* networklib = | 4101 NetworkLibraryImplCros* networklib = |
| 5361 static_cast<NetworkLibraryImplCros*>(object); | 4102 static_cast<NetworkLibraryImplCros*>(object); |
| 5362 DCHECK(networklib); | 4103 DCHECK(networklib); |
| 5363 if (service_path) { | 4104 if (service_path) { |
| 5364 if (!info) { | 4105 if (!info) { |
| 5365 // Remembered network no longer exists. | 4106 // Remembered network no longer exists. |
| 5366 networklib->DeleteRememberedNetwork(std::string(service_path)); | 4107 networklib->DeleteRememberedNetwork(std::string(service_path)); |
| 5367 } else { | 4108 } else { |
| 5368 DCHECK_EQ(info->GetType(), Value::TYPE_DICTIONARY); | 4109 DCHECK_EQ(info->GetType(), Value::TYPE_DICTIONARY); |
| 5369 const DictionaryValue* dict = static_cast<const DictionaryValue*>(info); | 4110 const DictionaryValue* dict = static_cast<const DictionaryValue*>(info); |
| 5370 networklib->ParseRememberedNetwork(std::string(service_path), dict); | 4111 networklib->ParseRememberedNetwork(std::string(service_path), *dict); |
| 5371 } | 4112 } |
| 5372 } | 4113 } |
| 5373 } | 4114 } |
| 5374 | 4115 |
| 5375 // Returns NULL if |service_path| refers to a network that is not a | 4116 // Returns NULL if |service_path| refers to a network that is not a |
| 5376 // remembered type. Called from RememberedNetworkServiceUpdate. | 4117 // remembered type. Called from RememberedNetworkServiceUpdate. |
| 5377 Network* NetworkLibraryImplCros::ParseRememberedNetwork( | 4118 Network* NetworkLibraryImplCros::ParseRememberedNetwork( |
| 5378 const std::string& service_path, const DictionaryValue* info) { | 4119 const std::string& service_path, const DictionaryValue& info) { |
| 5379 Network* remembered; | 4120 Network* remembered; |
| 5380 NetworkMap::iterator found = remembered_network_map_.find(service_path); | 4121 NetworkMap::iterator found = remembered_network_map_.find(service_path); |
| 5381 if (found != remembered_network_map_.end()) { | 4122 if (found != remembered_network_map_.end()) { |
| 5382 remembered = found->second; | 4123 remembered = found->second; |
| 4124 remembered->network_parser()->UpdateNetworkFromInfo(info, remembered); | |
| 5383 } else { | 4125 } else { |
| 5384 ConnectionType type = ParseTypeFromDictionary(info); | 4126 NativeNetworkParser parser; |
| 5385 if (type == TYPE_WIFI || type == TYPE_VPN) { | 4127 remembered = parser.CreateNetworkFromInfo(service_path, info); |
| 5386 remembered = CreateNewNetwork(type, service_path); | 4128 if (remembered->type() == TYPE_WIFI || remembered->type() == TYPE_VPN) { |
| 5387 AddRememberedNetwork(remembered); | 4129 AddRememberedNetwork(remembered); |
| 5388 } else { | 4130 } else { |
| 5389 VLOG(1) << "Ignoring remembered network: " << service_path | 4131 LOG(WARNING) << "Ignoring remembered network: " << service_path |
| 5390 << " Type: " << ConnectionTypeToString(type); | 4132 << " Type: " << ConnectionTypeToString(remembered->type()); |
|
stevenjb
2011/08/05 18:46:58
nit: align <<
Greg Spencer (Chromium)
2011/08/11 22:19:32
Done.
| |
| 4133 delete remembered; | |
| 5391 return NULL; | 4134 return NULL; |
| 5392 } | 4135 } |
| 5393 } | 4136 } |
| 5394 remembered->ParseInfo(info); // virtual. | |
| 5395 | 4137 |
| 5396 SetProfileTypeFromPath(remembered); | 4138 SetProfileTypeFromPath(remembered); |
| 5397 | 4139 |
| 5398 VLOG(1) << "ParseRememberedNetwork: " << remembered->name() | 4140 VLOG(1) << "ParseRememberedNetwork: " << remembered->name() |
| 5399 << " path: " << remembered->service_path() | 4141 << " path: " << remembered->service_path() |
| 5400 << " profile: " << remembered->profile_path_; | 4142 << " profile: " << remembered->profile_path_; |
| 5401 NotifyNetworkManagerChanged(false); // Not forced. | 4143 NotifyNetworkManagerChanged(false); // Not forced. |
| 5402 | 4144 |
| 5403 if (remembered->type() == TYPE_VPN) { | 4145 if (remembered->type() == TYPE_VPN) { |
| 5404 // VPNs are only stored in profiles. If we don't have a network for it, | 4146 // VPNs are only stored in profiles. If we don't have a network for it, |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 5430 device_map_.clear(); | 4172 device_map_.clear(); |
| 5431 VLOG(2) << "Updating Device List."; | 4173 VLOG(2) << "Updating Device List."; |
| 5432 for (ListValue::const_iterator iter = devices->begin(); | 4174 for (ListValue::const_iterator iter = devices->begin(); |
| 5433 iter != devices->end(); ++iter) { | 4175 iter != devices->end(); ++iter) { |
| 5434 std::string device_path; | 4176 std::string device_path; |
| 5435 (*iter)->GetAsString(&device_path); | 4177 (*iter)->GetAsString(&device_path); |
| 5436 if (!device_path.empty()) { | 4178 if (!device_path.empty()) { |
| 5437 NetworkDeviceMap::iterator found = old_device_map.find(device_path); | 4179 NetworkDeviceMap::iterator found = old_device_map.find(device_path); |
| 5438 if (found != old_device_map.end()) { | 4180 if (found != old_device_map.end()) { |
| 5439 VLOG(2) << " Adding existing device: " << device_path; | 4181 VLOG(2) << " Adding existing device: " << device_path; |
| 4182 CHECK(found->second) << "Attempted to add NULL device pointer"; | |
| 5440 device_map_[device_path] = found->second; | 4183 device_map_[device_path] = found->second; |
| 5441 old_device_map.erase(found); | 4184 old_device_map.erase(found); |
| 5442 } | 4185 } |
| 5443 chromeos::RequestNetworkDeviceInfo(device_path.c_str(), | 4186 chromeos::RequestNetworkDeviceInfo(device_path.c_str(), |
| 5444 &NetworkDeviceUpdate, | 4187 &NetworkDeviceUpdate, |
| 5445 this); | 4188 this); |
| 5446 } | 4189 } |
| 5447 } | 4190 } |
| 5448 // Delete any old devices that no longer exist. | 4191 // Delete any old devices that no longer exist. |
| 5449 for (NetworkDeviceMap::iterator iter = old_device_map.begin(); | 4192 for (NetworkDeviceMap::iterator iter = old_device_map.begin(); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 5460 NetworkLibraryImplCros* networklib = | 4203 NetworkLibraryImplCros* networklib = |
| 5461 static_cast<NetworkLibraryImplCros*>(object); | 4204 static_cast<NetworkLibraryImplCros*>(object); |
| 5462 DCHECK(networklib); | 4205 DCHECK(networklib); |
| 5463 if (device_path) { | 4206 if (device_path) { |
| 5464 if (!info) { | 4207 if (!info) { |
| 5465 // device no longer exists. | 4208 // device no longer exists. |
| 5466 networklib->DeleteDevice(std::string(device_path)); | 4209 networklib->DeleteDevice(std::string(device_path)); |
| 5467 } else { | 4210 } else { |
| 5468 DCHECK_EQ(info->GetType(), Value::TYPE_DICTIONARY); | 4211 DCHECK_EQ(info->GetType(), Value::TYPE_DICTIONARY); |
| 5469 const DictionaryValue* dict = static_cast<const DictionaryValue*>(info); | 4212 const DictionaryValue* dict = static_cast<const DictionaryValue*>(info); |
| 5470 networklib->ParseNetworkDevice(std::string(device_path), dict); | 4213 networklib->ParseNetworkDevice(std::string(device_path), *dict); |
| 5471 } | 4214 } |
| 5472 } | 4215 } |
| 5473 } | 4216 } |
| 5474 | 4217 |
| 5475 void NetworkLibraryImplCros::ParseNetworkDevice( | 4218 void NetworkLibraryImplCros::ParseNetworkDevice(const std::string& device_path, |
| 5476 const std::string& device_path, const DictionaryValue* info) { | 4219 const DictionaryValue& info) { |
| 5477 NetworkDeviceMap::iterator found = device_map_.find(device_path); | 4220 NetworkDeviceMap::iterator found = device_map_.find(device_path); |
| 5478 NetworkDevice* device; | 4221 NetworkDevice* device; |
| 5479 if (found != device_map_.end()) { | 4222 if (found != device_map_.end()) { |
| 5480 device = found->second; | 4223 device = found->second; |
| 4224 device->device_parser()->UpdateDeviceFromInfo(info, device); | |
| 5481 } else { | 4225 } else { |
| 5482 device = new NetworkDevice(device_path); | 4226 NativeNetworkDeviceParser parser; |
| 4227 device = parser.CreateDeviceFromInfo(device_path, info); | |
| 5483 VLOG(2) << " Adding device: " << device_path; | 4228 VLOG(2) << " Adding device: " << device_path; |
| 5484 device_map_[device_path] = device; | 4229 if (device) { |
| 4230 device_map_[device_path] = device; | |
| 4231 } else { | |
| 4232 std::string json; | |
| 4233 base::JSONWriter::Write(&info, true, &json); | |
| 4234 LOG(WARNING) << " NULL Device Dictionary: " << json; | |
|
stevenjb
2011/08/05 18:46:58
I think we should move the detailed output to the
Greg Spencer (Chromium)
2011/08/11 22:19:32
Sorry, that was some debugging code I accidentally
| |
| 4235 } | |
| 4236 CHECK(device) << "Attempted to add NULL device for path: " << device_path; | |
| 5485 } | 4237 } |
| 5486 device->ParseInfo(info); | |
| 5487 VLOG(1) << "ParseNetworkDevice:" << device->name(); | 4238 VLOG(1) << "ParseNetworkDevice:" << device->name(); |
| 5488 NotifyNetworkManagerChanged(false); // Not forced. | 4239 NotifyNetworkManagerChanged(false); // Not forced. |
| 5489 AddNetworkDeviceObserver(device_path, network_device_observer_.get()); | 4240 AddNetworkDeviceObserver(device_path, network_device_observer_.get()); |
| 5490 } | 4241 } |
| 5491 | 4242 |
| 5492 //////////////////////////////////////////////////////////////////////////// | 4243 //////////////////////////////////////////////////////////////////////////// |
| 5493 | 4244 |
| 5494 class NetworkLibraryImplStub : public NetworkLibraryImplBase { | 4245 class NetworkLibraryImplStub : public NetworkLibraryImplBase { |
| 5495 public: | 4246 public: |
| 5496 NetworkLibraryImplStub(); | 4247 NetworkLibraryImplStub(); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 5507 const std::string& device_path) OVERRIDE {} | 4258 const std::string& device_path) OVERRIDE {} |
| 5508 virtual void MonitorNetworkDeviceStop( | 4259 virtual void MonitorNetworkDeviceStop( |
| 5509 const std::string& device_path) OVERRIDE {} | 4260 const std::string& device_path) OVERRIDE {} |
| 5510 | 4261 |
| 5511 virtual void CallConnectToNetwork(Network* network) OVERRIDE; | 4262 virtual void CallConnectToNetwork(Network* network) OVERRIDE; |
| 5512 virtual void CallRequestWifiNetworkAndConnect( | 4263 virtual void CallRequestWifiNetworkAndConnect( |
| 5513 const std::string& ssid, ConnectionSecurity security) OVERRIDE; | 4264 const std::string& ssid, ConnectionSecurity security) OVERRIDE; |
| 5514 virtual void CallRequestVirtualNetworkAndConnect( | 4265 virtual void CallRequestVirtualNetworkAndConnect( |
| 5515 const std::string& service_name, | 4266 const std::string& service_name, |
| 5516 const std::string& server_hostname, | 4267 const std::string& server_hostname, |
| 5517 VirtualNetwork::ProviderType provider_type) OVERRIDE; | 4268 ProviderType provider_type) OVERRIDE; |
| 5518 | 4269 |
| 5519 virtual void CallDeleteRememberedNetwork( | 4270 virtual void CallDeleteRememberedNetwork( |
| 5520 const std::string& profile_path, | 4271 const std::string& profile_path, |
| 5521 const std::string& service_path) OVERRIDE {} | 4272 const std::string& service_path) OVERRIDE {} |
| 5522 | 4273 |
| 5523 // NetworkLibrary implementation. | 4274 // NetworkLibrary implementation. |
| 5524 | 4275 |
| 5525 virtual void ChangePin(const std::string& old_pin, | 4276 virtual void ChangePin(const std::string& old_pin, |
| 5526 const std::string& new_pin) OVERRIDE; | 4277 const std::string& new_pin) OVERRIDE; |
| 5527 virtual void ChangeRequirePin(bool require_pin, | 4278 virtual void ChangeRequirePin(bool require_pin, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5580 is_locked_ = false; | 4331 is_locked_ = false; |
| 5581 | 4332 |
| 5582 // Devices | 4333 // Devices |
| 5583 int devices = | 4334 int devices = |
| 5584 (1 << TYPE_ETHERNET) | (1 << TYPE_WIFI) | (1 << TYPE_CELLULAR); | 4335 (1 << TYPE_ETHERNET) | (1 << TYPE_WIFI) | (1 << TYPE_CELLULAR); |
| 5585 available_devices_ = devices; | 4336 available_devices_ = devices; |
| 5586 enabled_devices_ = devices; | 4337 enabled_devices_ = devices; |
| 5587 connected_devices_ = devices; | 4338 connected_devices_ = devices; |
| 5588 | 4339 |
| 5589 NetworkDevice* cellular = new NetworkDevice("cellular"); | 4340 NetworkDevice* cellular = new NetworkDevice("cellular"); |
| 5590 scoped_ptr<Value> cellular_type(Value::CreateStringValue(kTypeCellular)); | 4341 cellular->type_ = TYPE_CELLULAR; |
| 5591 cellular->ParseValue(PROPERTY_INDEX_TYPE, cellular_type.get()); | 4342 cellular->imsi_ = "123456789012345"; |
| 5592 cellular->IMSI_ = "123456789012345"; | |
| 5593 device_map_["cellular"] = cellular; | 4343 device_map_["cellular"] = cellular; |
| 5594 | 4344 |
| 5595 // Networks | 4345 // Networks |
| 5596 DeleteNetworks(); | 4346 DeleteNetworks(); |
| 5597 | 4347 |
| 5598 ethernet_ = new EthernetNetwork("eth1"); | 4348 ethernet_ = new EthernetNetwork("eth1"); |
| 5599 ethernet_->set_connected(true); | 4349 ethernet_->set_connected(true); |
| 5600 AddNetwork(ethernet_); | 4350 AddNetwork(ethernet_); |
| 5601 | 4351 |
| 5602 WifiNetwork* wifi1 = new WifiNetwork("fw1"); | 4352 WifiNetwork* wifi1 = new WifiNetwork("fw1"); |
| 5603 wifi1->set_name("Fake WiFi Connected"); | 4353 wifi1->set_name("Fake WiFi Connected"); |
| 5604 wifi1->set_strength(90); | 4354 wifi1->set_strength(90); |
| 5605 wifi1->set_connected(false); | 4355 wifi1->set_connected(false); |
| 5606 wifi1->set_connecting(true); | 4356 wifi1->set_connecting(true); |
| 5607 wifi1->set_active(true); | 4357 wifi1->set_is_active(true); |
| 5608 wifi1->set_encryption(SECURITY_NONE); | 4358 wifi1->set_encryption(SECURITY_NONE); |
| 5609 wifi1->set_profile_type(PROFILE_SHARED); | 4359 wifi1->set_profile_type(PROFILE_SHARED); |
| 5610 AddNetwork(wifi1); | 4360 AddNetwork(wifi1); |
| 5611 | 4361 |
| 5612 WifiNetwork* wifi2 = new WifiNetwork("fw2"); | 4362 WifiNetwork* wifi2 = new WifiNetwork("fw2"); |
| 5613 wifi2->set_name("Fake WiFi"); | 4363 wifi2->set_name("Fake WiFi"); |
| 5614 wifi2->set_strength(70); | 4364 wifi2->set_strength(70); |
| 5615 wifi2->set_connected(false); | 4365 wifi2->set_connected(false); |
| 5616 wifi2->set_encryption(SECURITY_NONE); | 4366 wifi2->set_encryption(SECURITY_NONE); |
| 5617 wifi2->set_profile_type(PROFILE_SHARED); | 4367 wifi2->set_profile_type(PROFILE_SHARED); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5651 wifi6->set_connected(false); | 4401 wifi6->set_connected(false); |
| 5652 AddNetwork(wifi6); | 4402 AddNetwork(wifi6); |
| 5653 | 4403 |
| 5654 active_wifi_ = wifi1; | 4404 active_wifi_ = wifi1; |
| 5655 | 4405 |
| 5656 CellularNetwork* cellular1 = new CellularNetwork("fc1"); | 4406 CellularNetwork* cellular1 = new CellularNetwork("fc1"); |
| 5657 cellular1->set_name("Fake Cellular"); | 4407 cellular1->set_name("Fake Cellular"); |
| 5658 cellular1->set_strength(70); | 4408 cellular1->set_strength(70); |
| 5659 cellular1->set_connected(false); | 4409 cellular1->set_connected(false); |
| 5660 cellular1->set_connecting(true); | 4410 cellular1->set_connecting(true); |
| 5661 cellular1->set_active(true); | 4411 cellular1->set_is_active(true); |
| 5662 cellular1->set_activation_state(ACTIVATION_STATE_ACTIVATED); | 4412 cellular1->set_activation_state(ACTIVATION_STATE_ACTIVATED); |
| 5663 cellular1->set_payment_url(std::string("http://www.google.com")); | 4413 cellular1->set_payment_url(std::string("http://www.google.com")); |
| 5664 cellular1->set_usage_url(std::string("http://www.google.com")); | 4414 cellular1->set_usage_url(std::string("http://www.google.com")); |
| 5665 cellular1->set_network_technology(NETWORK_TECHNOLOGY_EVDO); | 4415 cellular1->set_network_technology(NETWORK_TECHNOLOGY_EVDO); |
| 5666 cellular1->set_roaming_state(ROAMING_STATE_ROAMING); | 4416 cellular1->set_roaming_state(ROAMING_STATE_ROAMING); |
| 5667 | 4417 |
| 5668 CellularDataPlan* base_plan = new CellularDataPlan(); | 4418 CellularDataPlan* base_plan = new CellularDataPlan(); |
| 5669 base_plan->plan_name = "Base plan"; | 4419 base_plan->plan_name = "Base plan"; |
| 5670 base_plan->plan_type = CELLULAR_DATA_PLAN_METERED_BASE; | 4420 base_plan->plan_type = CELLULAR_DATA_PLAN_METERED_BASE; |
| 5671 base_plan->plan_data_bytes = 100ll * 1024 * 1024; | 4421 base_plan->plan_data_bytes = 100ll * 1024 * 1024; |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 5689 cellular2->set_strength(70); | 4439 cellular2->set_strength(70); |
| 5690 cellular2->set_connected(true); | 4440 cellular2->set_connected(true); |
| 5691 cellular2->set_activation_state(ACTIVATION_STATE_ACTIVATED); | 4441 cellular2->set_activation_state(ACTIVATION_STATE_ACTIVATED); |
| 5692 cellular2->set_network_technology(NETWORK_TECHNOLOGY_UMTS); | 4442 cellular2->set_network_technology(NETWORK_TECHNOLOGY_UMTS); |
| 5693 AddNetwork(cellular2); | 4443 AddNetwork(cellular2); |
| 5694 | 4444 |
| 5695 // VPNs | 4445 // VPNs |
| 5696 VirtualNetwork* vpn1 = new VirtualNetwork("fv1"); | 4446 VirtualNetwork* vpn1 = new VirtualNetwork("fv1"); |
| 5697 vpn1->set_name("Fake VPN Provider 1"); | 4447 vpn1->set_name("Fake VPN Provider 1"); |
| 5698 vpn1->set_server_hostname("vpn1server.fake.com"); | 4448 vpn1->set_server_hostname("vpn1server.fake.com"); |
| 5699 vpn1->set_provider_type(VirtualNetwork::PROVIDER_TYPE_L2TP_IPSEC_PSK); | 4449 vpn1->set_provider_type(PROVIDER_TYPE_L2TP_IPSEC_PSK); |
| 5700 vpn1->set_username("VPN User 1"); | 4450 vpn1->set_username("VPN User 1"); |
| 5701 vpn1->set_connected(false); | 4451 vpn1->set_connected(false); |
| 5702 AddNetwork(vpn1); | 4452 AddNetwork(vpn1); |
| 5703 | 4453 |
| 5704 VirtualNetwork* vpn2 = new VirtualNetwork("fv2"); | 4454 VirtualNetwork* vpn2 = new VirtualNetwork("fv2"); |
| 5705 vpn2->set_name("Fake VPN Provider 2"); | 4455 vpn2->set_name("Fake VPN Provider 2"); |
| 5706 vpn2->set_server_hostname("vpn2server.fake.com"); | 4456 vpn2->set_server_hostname("vpn2server.fake.com"); |
| 5707 vpn2->set_provider_type(VirtualNetwork::PROVIDER_TYPE_L2TP_IPSEC_USER_CERT); | 4457 vpn2->set_provider_type(PROVIDER_TYPE_L2TP_IPSEC_USER_CERT); |
| 5708 vpn2->set_username("VPN User 2"); | 4458 vpn2->set_username("VPN User 2"); |
| 5709 vpn2->set_connected(true); | 4459 vpn2->set_connected(true); |
| 5710 AddNetwork(vpn2); | 4460 AddNetwork(vpn2); |
| 5711 | 4461 |
| 5712 VirtualNetwork* vpn3 = new VirtualNetwork("fv3"); | 4462 VirtualNetwork* vpn3 = new VirtualNetwork("fv3"); |
| 5713 vpn3->set_name("Fake VPN Provider 3"); | 4463 vpn3->set_name("Fake VPN Provider 3"); |
| 5714 vpn3->set_server_hostname("vpn3server.fake.com"); | 4464 vpn3->set_server_hostname("vpn3server.fake.com"); |
| 5715 vpn3->set_provider_type(VirtualNetwork::PROVIDER_TYPE_OPEN_VPN); | 4465 vpn3->set_provider_type(PROVIDER_TYPE_OPEN_VPN); |
| 5716 vpn3->set_connected(false); | 4466 vpn3->set_connected(false); |
| 5717 AddNetwork(vpn3); | 4467 AddNetwork(vpn3); |
| 5718 | 4468 |
| 5719 active_virtual_ = vpn2; | 4469 active_virtual_ = vpn2; |
| 5720 | 4470 |
| 5721 // Remembered Networks | 4471 // Remembered Networks |
| 5722 DeleteRememberedNetworks(); | 4472 DeleteRememberedNetworks(); |
| 5723 NetworkProfile profile("default", PROFILE_SHARED); | 4473 NetworkProfile profile("default", PROFILE_SHARED); |
| 5724 profile.services.insert("fw2"); | 4474 profile.services.insert("fw2"); |
| 5725 profile.services.insert("fv2"); | 4475 profile.services.insert("fv2"); |
| 5726 profile_list_.push_back(profile); | 4476 profile_list_.push_back(profile); |
| 5727 WifiNetwork* remembered_wifi2 = new WifiNetwork("fw2"); | 4477 WifiNetwork* remembered_wifi2 = new WifiNetwork("fw2"); |
| 5728 remembered_wifi2->set_name("Fake WiFi 2"); | 4478 remembered_wifi2->set_name("Fake WiFi 2"); |
| 5729 remembered_wifi2->set_encryption(SECURITY_WEP); | 4479 remembered_wifi2->set_encryption(SECURITY_WEP); |
| 5730 AddRememberedNetwork(remembered_wifi2); | 4480 AddRememberedNetwork(remembered_wifi2); |
| 5731 VirtualNetwork* remembered_vpn2 = new VirtualNetwork("fv2"); | 4481 VirtualNetwork* remembered_vpn2 = new VirtualNetwork("fv2"); |
| 5732 remembered_vpn2->set_name("Fake VPN Provider 2"); | 4482 remembered_vpn2->set_name("Fake VPN Provider 2"); |
| 5733 remembered_vpn2->set_server_hostname("vpn2server.fake.com"); | 4483 remembered_vpn2->set_server_hostname("vpn2server.fake.com"); |
| 5734 remembered_vpn2->set_provider_type( | 4484 remembered_vpn2->set_provider_type( |
| 5735 VirtualNetwork::PROVIDER_TYPE_L2TP_IPSEC_USER_CERT); | 4485 PROVIDER_TYPE_L2TP_IPSEC_USER_CERT); |
| 5736 remembered_vpn2->set_connected(true); | 4486 remembered_vpn2->set_connected(true); |
| 5737 AddRememberedNetwork(remembered_vpn2); | 4487 AddRememberedNetwork(remembered_vpn2); |
| 5738 | 4488 |
| 5739 wifi_scanning_ = false; | 4489 wifi_scanning_ = false; |
| 5740 offline_mode_ = false; | 4490 offline_mode_ = false; |
| 5741 } | 4491 } |
| 5742 | 4492 |
| 5743 ////////////////////////////////////////////////////////////////////////////// | 4493 ////////////////////////////////////////////////////////////////////////////// |
| 5744 // NetworkLibraryImplBase implementation. | 4494 // NetworkLibraryImplBase implementation. |
| 5745 | 4495 |
| 5746 void NetworkLibraryImplStub::CallConnectToNetwork(Network* network) { | 4496 void NetworkLibraryImplStub::CallConnectToNetwork(Network* network) { |
| 5747 NetworkConnectCompleted(network, CONNECT_SUCCESS); | 4497 NetworkConnectCompleted(network, CONNECT_SUCCESS); |
| 5748 } | 4498 } |
| 5749 | 4499 |
| 5750 void NetworkLibraryImplStub::CallRequestWifiNetworkAndConnect( | 4500 void NetworkLibraryImplStub::CallRequestWifiNetworkAndConnect( |
| 5751 const std::string& ssid, ConnectionSecurity security) { | 4501 const std::string& ssid, ConnectionSecurity security) { |
| 5752 WifiNetwork* wifi = new WifiNetwork(ssid); | 4502 WifiNetwork* wifi = new WifiNetwork(ssid); |
| 5753 wifi->set_encryption(security); | 4503 wifi->set_encryption(security); |
| 5754 AddNetwork(wifi); | 4504 AddNetwork(wifi); |
| 5755 ConnectToWifiNetworkUsingConnectData(wifi); | 4505 ConnectToWifiNetworkUsingConnectData(wifi); |
| 5756 } | 4506 } |
| 5757 | 4507 |
| 5758 void NetworkLibraryImplStub::CallRequestVirtualNetworkAndConnect( | 4508 void NetworkLibraryImplStub::CallRequestVirtualNetworkAndConnect( |
| 5759 const std::string& service_name, | 4509 const std::string& service_name, |
| 5760 const std::string& server_hostname, | 4510 const std::string& server_hostname, |
| 5761 VirtualNetwork::ProviderType provider_type) { | 4511 ProviderType provider_type) { |
| 5762 VirtualNetwork* vpn = new VirtualNetwork(service_name); | 4512 VirtualNetwork* vpn = new VirtualNetwork(service_name); |
| 5763 vpn->set_server_hostname(server_hostname); | 4513 vpn->set_server_hostname(server_hostname); |
| 5764 vpn->set_provider_type(provider_type); | 4514 vpn->set_provider_type(provider_type); |
| 5765 AddNetwork(vpn); | 4515 AddNetwork(vpn); |
| 5766 ConnectToVirtualNetworkUsingConnectData(vpn); | 4516 ConnectToVirtualNetworkUsingConnectData(vpn); |
| 5767 } | 4517 } |
| 5768 | 4518 |
| 5769 ///////////////////////////////////////////////////////////////////////////// | 4519 ///////////////////////////////////////////////////////////////////////////// |
| 5770 // NetworkLibrary implementation. | 4520 // NetworkLibrary implementation. |
| 5771 | 4521 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5847 return network_library; | 4597 return network_library; |
| 5848 } | 4598 } |
| 5849 | 4599 |
| 5850 ///////////////////////////////////////////////////////////////////////////// | 4600 ///////////////////////////////////////////////////////////////////////////// |
| 5851 | 4601 |
| 5852 } // namespace chromeos | 4602 } // namespace chromeos |
| 5853 | 4603 |
| 5854 // Allows InvokeLater without adding refcounting. This class is a Singleton and | 4604 // Allows InvokeLater without adding refcounting. This class is a Singleton and |
| 5855 // won't be deleted until it's last InvokeLater is run. | 4605 // won't be deleted until it's last InvokeLater is run. |
| 5856 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::NetworkLibraryImplBase); | 4606 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::NetworkLibraryImplBase); |
| OLD | NEW |