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 #ifndef CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ | 6 #define CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 13 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
| 14 #include "base/memory/singleton.h" | 14 #include "base/memory/singleton.h" |
| 15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
| 16 #include "base/scoped_ptr.h" | |
| 16 #include "base/string16.h" | 17 #include "base/string16.h" |
| 17 #include "base/timer.h" | 18 #include "base/timer.h" |
| 18 #include "third_party/cros/chromeos_network.h" | 19 #include "third_party/cros/chromeos_network.h" |
| 19 | 20 |
| 20 namespace base { | 21 namespace base { |
| 21 class DictionaryValue; | 22 class DictionaryValue; |
| 22 class Value; | 23 class Value; |
| 23 } | 24 } |
| 24 | 25 |
| 25 namespace chromeos { | 26 namespace chromeos { |
| 26 | 27 |
| 28 class NativeNetworkParser; | |
| 29 class NativeNetworkDeviceParser; | |
| 30 class NativeEthernetNetworkParser; | |
| 31 | |
| 32 // This is the list of all implementation classes that are allowed | |
| 33 // access to the internals of the network library classes. | |
| 34 #define NETWORK_LIBRARY_IMPL_FRIENDS \ | |
| 35 friend class NetworkLibraryImplBase; \ | |
| 36 friend class NetworkLibraryImplCros; \ | |
| 37 friend class NetworkLibraryImplStub; | |
| 38 | |
| 39 // This is the list of all parsers that are allowed access to the | |
| 40 // internals of the network library classes. All parsers should still | |
| 41 // access the internals through the set_ functions to allow these | |
| 42 // classes to evolve without also having to change all of the parsers. | |
| 43 // If you add a parser subclass, then you'll need to add it to this | |
| 44 // list. | |
| 45 #define NETWORK_LIBRARY_PARSER_FRIENDS \ | |
| 46 friend class NetworkParser; \ | |
| 47 friend class NetworkDeviceParser; \ | |
| 48 friend class NativeNetworkParser; \ | |
| 49 friend class NativeNetworkDeviceParser; \ | |
| 50 friend class NativeEthernetNetworkParser; \ | |
| 51 friend class NativeWirelessNetworkParser; \ | |
| 52 friend class NativeWifiNetworkParser; \ | |
| 53 friend class NativeCellularNetworkParser; \ | |
| 54 friend class NativeVirtualNetworkParser; | |
|
stevenjb
2011/08/05 18:46:58
On the one hand this is convenient, on the other h
Greg Spencer (Chromium)
2011/08/11 22:19:32
Yeah, I guess... The Wireless parser needs interna
stevenjb
2011/08/12 21:32:37
I think this is a good compromise.
| |
| 55 | |
| 56 // This enumerates the various property indices that can be found in a | |
| 57 // dictionary being parsed. | |
| 58 enum PropertyIndex { | |
| 59 PROPERTY_INDEX_ACTIVATION_STATE, | |
| 60 PROPERTY_INDEX_ACTIVE_PROFILE, | |
| 61 PROPERTY_INDEX_ARP_GATEWAY, | |
| 62 PROPERTY_INDEX_AUTO_CONNECT, | |
| 63 PROPERTY_INDEX_AVAILABLE_TECHNOLOGIES, | |
| 64 PROPERTY_INDEX_CARRIER, | |
| 65 PROPERTY_INDEX_CELLULAR_ALLOW_ROAMING, | |
| 66 PROPERTY_INDEX_CELLULAR_APN, | |
| 67 PROPERTY_INDEX_CELLULAR_APN_LIST, | |
| 68 PROPERTY_INDEX_CELLULAR_LAST_GOOD_APN, | |
| 69 PROPERTY_INDEX_CHECK_PORTAL_LIST, | |
| 70 PROPERTY_INDEX_CONNECTABLE, | |
| 71 PROPERTY_INDEX_CONNECTED_TECHNOLOGIES, | |
| 72 PROPERTY_INDEX_CONNECTIVITY_STATE, | |
| 73 PROPERTY_INDEX_DEFAULT_TECHNOLOGY, | |
| 74 PROPERTY_INDEX_DEVICE, | |
| 75 PROPERTY_INDEX_DEVICES, | |
| 76 PROPERTY_INDEX_EAP_ANONYMOUS_IDENTITY, | |
| 77 PROPERTY_INDEX_EAP_CA_CERT, | |
| 78 PROPERTY_INDEX_EAP_CA_CERT_ID, | |
| 79 PROPERTY_INDEX_EAP_CA_CERT_NSS, | |
| 80 PROPERTY_INDEX_EAP_CERT_ID, | |
| 81 PROPERTY_INDEX_EAP_CLIENT_CERT, | |
| 82 PROPERTY_INDEX_EAP_CLIENT_CERT_NSS, | |
| 83 PROPERTY_INDEX_EAP_IDENTITY, | |
| 84 PROPERTY_INDEX_EAP_KEY_ID, | |
| 85 PROPERTY_INDEX_EAP_KEY_MGMT, | |
| 86 PROPERTY_INDEX_EAP_METHOD, | |
| 87 PROPERTY_INDEX_EAP_PASSWORD, | |
| 88 PROPERTY_INDEX_EAP_PHASE_2_AUTH, | |
| 89 PROPERTY_INDEX_EAP_PIN, | |
| 90 PROPERTY_INDEX_EAP_PRIVATE_KEY, | |
| 91 PROPERTY_INDEX_EAP_PRIVATE_KEY_PASSWORD, | |
| 92 PROPERTY_INDEX_EAP_USE_SYSTEM_CAS, | |
| 93 PROPERTY_INDEX_ENABLED_TECHNOLOGIES, | |
| 94 PROPERTY_INDEX_ERROR, | |
| 95 PROPERTY_INDEX_ESN, | |
| 96 PROPERTY_INDEX_FAVORITE, | |
| 97 PROPERTY_INDEX_FIRMWARE_REVISION, | |
| 98 PROPERTY_INDEX_FOUND_NETWORKS, | |
| 99 PROPERTY_INDEX_GUID, | |
| 100 PROPERTY_INDEX_HARDWARE_REVISION, | |
| 101 PROPERTY_INDEX_HOME_PROVIDER, | |
| 102 PROPERTY_INDEX_HOST, | |
| 103 PROPERTY_INDEX_IDENTITY, | |
| 104 PROPERTY_INDEX_IMEI, | |
| 105 PROPERTY_INDEX_IMSI, | |
| 106 PROPERTY_INDEX_IS_ACTIVE, | |
| 107 PROPERTY_INDEX_L2TPIPSEC_CA_CERT_NSS, | |
| 108 PROPERTY_INDEX_L2TPIPSEC_CLIENT_CERT_ID, | |
| 109 PROPERTY_INDEX_L2TPIPSEC_CLIENT_CERT_SLOT, | |
| 110 PROPERTY_INDEX_L2TPIPSEC_PASSWORD, | |
| 111 PROPERTY_INDEX_L2TPIPSEC_PIN, | |
| 112 PROPERTY_INDEX_L2TPIPSEC_PSK, | |
| 113 PROPERTY_INDEX_L2TPIPSEC_USER, | |
| 114 PROPERTY_INDEX_MANUFACTURER, | |
| 115 PROPERTY_INDEX_MDN, | |
| 116 PROPERTY_INDEX_MEID, | |
| 117 PROPERTY_INDEX_MIN, | |
| 118 PROPERTY_INDEX_MODE, | |
| 119 PROPERTY_INDEX_MODEL_ID, | |
| 120 PROPERTY_INDEX_NAME, | |
| 121 PROPERTY_INDEX_NETWORKS, | |
| 122 PROPERTY_INDEX_NETWORK_TECHNOLOGY, | |
| 123 PROPERTY_INDEX_OFFLINE_MODE, | |
| 124 PROPERTY_INDEX_OPERATOR_CODE, | |
| 125 PROPERTY_INDEX_OPERATOR_NAME, | |
| 126 PROPERTY_INDEX_PASSPHRASE, | |
| 127 PROPERTY_INDEX_PASSPHRASE_REQUIRED, | |
| 128 PROPERTY_INDEX_PAYMENT_URL, | |
| 129 PROPERTY_INDEX_PORTAL_URL, | |
| 130 PROPERTY_INDEX_POWERED, | |
| 131 PROPERTY_INDEX_PRIORITY, | |
| 132 PROPERTY_INDEX_PRL_VERSION, | |
| 133 PROPERTY_INDEX_PROFILE, | |
| 134 PROPERTY_INDEX_PROFILES, | |
| 135 PROPERTY_INDEX_PROVIDER, | |
| 136 PROPERTY_INDEX_PROXY_CONFIG, | |
| 137 PROPERTY_INDEX_ROAMING_STATE, | |
| 138 PROPERTY_INDEX_SAVE_CREDENTIALS, | |
| 139 PROPERTY_INDEX_SCANNING, | |
| 140 PROPERTY_INDEX_SECURITY, | |
| 141 PROPERTY_INDEX_SELECTED_NETWORK, | |
| 142 PROPERTY_INDEX_SERVICES, | |
| 143 PROPERTY_INDEX_SERVICE_WATCH_LIST, | |
| 144 PROPERTY_INDEX_SERVING_OPERATOR, | |
| 145 PROPERTY_INDEX_SIGNAL_STRENGTH, | |
| 146 PROPERTY_INDEX_SIM_LOCK, | |
| 147 PROPERTY_INDEX_STATE, | |
| 148 PROPERTY_INDEX_SUPPORT_NETWORK_SCAN, | |
| 149 PROPERTY_INDEX_TECHNOLOGY_FAMILY, | |
| 150 PROPERTY_INDEX_TYPE, | |
| 151 PROPERTY_INDEX_UNKNOWN, | |
| 152 PROPERTY_INDEX_USAGE_URL, | |
| 153 PROPERTY_INDEX_WIFI_AUTH_MODE, | |
| 154 PROPERTY_INDEX_WIFI_FREQUENCY, | |
| 155 PROPERTY_INDEX_WIFI_HEX_SSID, | |
| 156 PROPERTY_INDEX_WIFI_HIDDEN_SSID, | |
| 157 PROPERTY_INDEX_WIFI_PHY_MODE, | |
| 158 }; | |
| 159 | |
| 27 // Connection enums (see flimflam/include/service.h) | 160 // Connection enums (see flimflam/include/service.h) |
| 28 enum ConnectionType { | 161 enum ConnectionType { |
| 29 TYPE_UNKNOWN = 0, | 162 TYPE_UNKNOWN = 0, |
| 30 TYPE_ETHERNET = 1, | 163 TYPE_ETHERNET = 1, |
| 31 TYPE_WIFI = 2, | 164 TYPE_WIFI = 2, |
| 32 TYPE_WIMAX = 3, | 165 TYPE_WIMAX = 3, |
| 33 TYPE_BLUETOOTH = 4, | 166 TYPE_BLUETOOTH = 4, |
| 34 TYPE_CELLULAR = 5, | 167 TYPE_CELLULAR = 5, |
| 35 TYPE_VPN = 6, | 168 TYPE_VPN = 6, |
| 36 }; | 169 }; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 ROAMING_STATE_ROAMING = 2, | 227 ROAMING_STATE_ROAMING = 2, |
| 95 }; | 228 }; |
| 96 | 229 |
| 97 // Device enums (see flimflam/include/device.h) | 230 // Device enums (see flimflam/include/device.h) |
| 98 enum TechnologyFamily { | 231 enum TechnologyFamily { |
| 99 TECHNOLOGY_FAMILY_UNKNOWN = 0, | 232 TECHNOLOGY_FAMILY_UNKNOWN = 0, |
| 100 TECHNOLOGY_FAMILY_CDMA = 1, | 233 TECHNOLOGY_FAMILY_CDMA = 1, |
| 101 TECHNOLOGY_FAMILY_GSM = 2 | 234 TECHNOLOGY_FAMILY_GSM = 2 |
| 102 }; | 235 }; |
| 103 | 236 |
| 237 // Type of a pending SIM operation. | |
| 238 enum SimOperationType { | |
| 239 SIM_OPERATION_NONE = 0, | |
| 240 SIM_OPERATION_CHANGE_PIN = 1, | |
| 241 SIM_OPERATION_CHANGE_REQUIRE_PIN = 2, | |
| 242 SIM_OPERATION_ENTER_PIN = 3, | |
| 243 SIM_OPERATION_UNBLOCK_PIN = 4, | |
| 244 }; | |
| 245 | |
| 104 // SIMLock states (see gobi-cromo-plugin/gobi_gsm_modem.cc) | 246 // SIMLock states (see gobi-cromo-plugin/gobi_gsm_modem.cc) |
| 105 enum SIMLockState { | 247 enum SimLockState { |
| 106 SIM_UNKNOWN = 0, | 248 SIM_UNKNOWN = 0, |
| 107 SIM_UNLOCKED = 1, | 249 SIM_UNLOCKED = 1, |
| 108 SIM_LOCKED_PIN = 2, | 250 SIM_LOCKED_PIN = 2, |
| 109 SIM_LOCKED_PUK = 3, // also when SIM is blocked, then retries = 0. | 251 SIM_LOCKED_PUK = 3, // also when SIM is blocked, then retries = 0. |
| 110 }; | 252 }; |
| 111 | 253 |
| 112 // SIM PinRequire states. Since PinRequire current state is not exposed as a | 254 // SIM PinRequire states. Since PinRequire current state is not exposed as a |
| 113 // cellular property, we initialize it's value based on the SIMLockState | 255 // cellular property, we initialize it's value based on the SimLockState |
| 114 // initial value. | 256 // initial value. |
| 115 // SIM_PIN_REQUIRE_UNKNOWN - SIM card is absent or SIMLockState initial value | 257 // SIM_PIN_REQUIRE_UNKNOWN - SIM card is absent or SimLockState initial value |
| 116 // hasn't been received yet. | 258 // hasn't been received yet. |
| 117 // SIM_PIN_REQUIRED - SIM card is locked when booted/wake from sleep and | 259 // SIM_PIN_REQUIRED - SIM card is locked when booted/wake from sleep and |
| 118 // requires user to enter PIN. | 260 // requires user to enter PIN. |
| 119 // SIM_PIN_NOT_REQUIRED - SIM card is unlocked all the time and requires PIN | 261 // SIM_PIN_NOT_REQUIRED - SIM card is unlocked all the time and requires PIN |
| 120 // only on certain operations, such as ChangeRequirePin, ChangePin, EnterPin. | 262 // only on certain operations, such as ChangeRequirePin, ChangePin, EnterPin. |
| 121 enum SIMPinRequire { | 263 enum SimPinRequire { |
| 122 SIM_PIN_REQUIRE_UNKNOWN = 0, | 264 SIM_PIN_REQUIRE_UNKNOWN = 0, |
| 123 SIM_PIN_NOT_REQUIRED = 1, | 265 SIM_PIN_NOT_REQUIRED = 1, |
| 124 SIM_PIN_REQUIRED = 2, | 266 SIM_PIN_REQUIRED = 2, |
| 125 }; | 267 }; |
| 126 | 268 |
| 127 // Any PIN operation result (EnterPin, UnblockPin etc.). | 269 // Any PIN operation result (EnterPin, UnblockPin etc.). |
| 128 enum PinOperationError { | 270 enum PinOperationError { |
| 129 PIN_ERROR_NONE = 0, | 271 PIN_ERROR_NONE = 0, |
| 130 PIN_ERROR_UNKNOWN = 1, | 272 PIN_ERROR_UNKNOWN = 1, |
| 131 PIN_ERROR_INCORRECT_CODE = 2, // Either PIN/PUK specified is incorrect. | 273 PIN_ERROR_INCORRECT_CODE = 2, // Either PIN/PUK specified is incorrect. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 EAP_PHASE_2_AUTH_CHAP = 5 | 312 EAP_PHASE_2_AUTH_CHAP = 5 |
| 171 }; | 313 }; |
| 172 | 314 |
| 173 // Misc enums | 315 // Misc enums |
| 174 enum NetworkProfileType { | 316 enum NetworkProfileType { |
| 175 PROFILE_NONE, // Not in any profile (not remembered). | 317 PROFILE_NONE, // Not in any profile (not remembered). |
| 176 PROFILE_SHARED, // In the local profile, shared by all users on device. | 318 PROFILE_SHARED, // In the local profile, shared by all users on device. |
| 177 PROFILE_USER // In the user provile, not visible to other users. | 319 PROFILE_USER // In the user provile, not visible to other users. |
| 178 }; | 320 }; |
| 179 | 321 |
| 322 // Virtual Network provider type. | |
| 323 enum ProviderType { | |
|
Greg Spencer (Chromium)
2011/08/04 23:02:14
I moved this out of the VirtualNetwork class becau
| |
| 324 PROVIDER_TYPE_L2TP_IPSEC_PSK, | |
| 325 PROVIDER_TYPE_L2TP_IPSEC_USER_CERT, | |
| 326 PROVIDER_TYPE_OPEN_VPN, | |
| 327 // Add new provider types before PROVIDER_TYPE_MAX. | |
| 328 PROVIDER_TYPE_MAX, | |
| 329 }; | |
| 330 | |
| 180 // Simple wrapper for property Cellular.FoundNetworks. | 331 // Simple wrapper for property Cellular.FoundNetworks. |
| 181 struct FoundCellularNetwork { | 332 struct FoundCellularNetwork { |
| 182 FoundCellularNetwork(); | 333 FoundCellularNetwork(); |
| 183 ~FoundCellularNetwork(); | 334 ~FoundCellularNetwork(); |
| 184 | 335 |
| 185 std::string status; | 336 std::string status; |
| 186 std::string network_id; | 337 std::string network_id; |
| 187 std::string short_name; | 338 std::string short_name; |
| 188 std::string long_name; | 339 std::string long_name; |
| 189 std::string technology; | 340 std::string technology; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 228 // e.g. ethernet, wifi, cellular. | 379 // e.g. ethernet, wifi, cellular. |
| 229 // TODO(dpolukhin): refactor to make base class and device specific derivatives. | 380 // TODO(dpolukhin): refactor to make base class and device specific derivatives. |
| 230 class NetworkDevice { | 381 class NetworkDevice { |
| 231 public: | 382 public: |
| 232 explicit NetworkDevice(const std::string& device_path); | 383 explicit NetworkDevice(const std::string& device_path); |
| 233 ~NetworkDevice(); | 384 ~NetworkDevice(); |
| 234 | 385 |
| 235 // Device info. | 386 // Device info. |
| 236 const std::string& device_path() const { return device_path_; } | 387 const std::string& device_path() const { return device_path_; } |
| 237 const std::string& name() const { return name_; } | 388 const std::string& name() const { return name_; } |
| 389 const std::string& unique_id() const { return unique_id_; } | |
| 238 ConnectionType type() const { return type_; } | 390 ConnectionType type() const { return type_; } |
| 239 bool scanning() const { return scanning_; } | 391 bool scanning() const { return scanning_; } |
| 240 const std::string& meid() const { return MEID_; } | 392 const std::string& meid() const { return meid_; } |
| 241 const std::string& imei() const { return IMEI_; } | 393 const std::string& imei() const { return imei_; } |
| 242 const std::string& imsi() const { return IMSI_; } | 394 const std::string& imsi() const { return imsi_; } |
| 243 const std::string& esn() const { return ESN_; } | 395 const std::string& esn() const { return esn_; } |
| 244 const std::string& mdn() const { return MDN_; } | 396 const std::string& mdn() const { return mdn_; } |
| 245 const std::string& min() const { return MIN_; } | 397 const std::string& min() const { return min_; } |
| 246 const std::string& model_id() const { return model_id_; } | 398 const std::string& model_id() const { return model_id_; } |
| 247 const std::string& manufacturer() const { return manufacturer_; } | 399 const std::string& manufacturer() const { return manufacturer_; } |
| 248 SIMLockState sim_lock_state() const { return sim_lock_state_; } | 400 SimLockState sim_lock_state() const { return sim_lock_state_; } |
| 249 bool is_sim_locked() const { | 401 bool is_sim_locked() const { |
| 250 return sim_lock_state_ == SIM_LOCKED_PIN || | 402 return sim_lock_state_ == SIM_LOCKED_PIN || |
| 251 sim_lock_state_ == SIM_LOCKED_PUK; | 403 sim_lock_state_ == SIM_LOCKED_PUK; |
| 252 } | 404 } |
| 253 const int sim_retries_left() const { return sim_retries_left_; } | 405 const int sim_retries_left() const { return sim_retries_left_; } |
| 254 SIMPinRequire sim_pin_required() const { return sim_pin_required_; } | 406 SimPinRequire sim_pin_required() const { return sim_pin_required_; } |
|
Greg Spencer (Chromium)
2011/08/04 23:02:14
The capitalization of this one was even internally
| |
| 255 const std::string& firmware_revision() const { return firmware_revision_; } | 407 const std::string& firmware_revision() const { return firmware_revision_; } |
| 256 const std::string& hardware_revision() const { return hardware_revision_; } | 408 const std::string& hardware_revision() const { return hardware_revision_; } |
| 257 const unsigned int prl_version() const { return PRL_version_; } | 409 const unsigned int prl_version() const { return prl_version_; } |
| 258 const std::string& home_provider() const { return home_provider_; } | 410 const std::string& home_provider() const { return home_provider_; } |
| 259 const std::string& home_provider_code() const { return home_provider_code_; } | 411 const std::string& home_provider_code() const { return home_provider_code_; } |
| 260 const std::string& home_provider_country() const { | 412 const std::string& home_provider_country() const { |
| 261 return home_provider_country_; | 413 return home_provider_country_; |
| 262 } | 414 } |
| 263 const std::string& home_provider_id() const { return home_provider_id_; } | 415 const std::string& home_provider_id() const { return home_provider_id_; } |
| 264 const std::string& home_provider_name() const { return home_provider_name_; } | 416 const std::string& home_provider_name() const { return home_provider_name_; } |
| 265 const std::string& selected_cellular_network() const { | 417 const std::string& selected_cellular_network() const { |
| 266 return selected_cellular_network_; | 418 return selected_cellular_network_; |
| 267 } | 419 } |
| 268 const CellularNetworkList& found_cellular_networks() const { | 420 const CellularNetworkList& found_cellular_networks() const { |
| 269 return found_cellular_networks_; | 421 return found_cellular_networks_; |
| 270 } | 422 } |
| 271 bool data_roaming_allowed() const { return data_roaming_allowed_; } | 423 bool data_roaming_allowed() const { return data_roaming_allowed_; } |
| 272 bool support_network_scan() const { return support_network_scan_; } | 424 bool support_network_scan() const { return support_network_scan_; } |
| 273 enum TechnologyFamily technology_family() const { return technology_family_; } | 425 enum TechnologyFamily technology_family() const { return technology_family_; } |
| 274 const CellularApnList& provider_apn_list() const { | 426 const CellularApnList& provider_apn_list() const { |
| 275 return provider_apn_list_; | 427 return provider_apn_list_; |
| 276 } | 428 } |
| 277 | 429 |
| 430 // Updates the property specified by |key| with the contents of | |
| 431 // |value|. Returns false on failure. Upon success, returns the | |
| 432 // PropertyIndex that was updated in |index|. |index| may be NULL | |
| 433 // if not needed. | |
| 434 virtual bool UpdateStatus(const std::string& key, | |
| 435 const Value& value, | |
| 436 PropertyIndex *index); | |
| 437 | |
| 438 NativeNetworkDeviceParser* device_parser() { return device_parser_.get(); } | |
| 439 | |
| 440 protected: | |
| 441 void set_unique_id(const std::string& unique_id) { unique_id_ = unique_id; } | |
| 442 | |
| 278 private: | 443 private: |
| 279 bool ParseValue(int index, const base::Value* value); | 444 // This allows NetworkDeviceParser and its subclasses access to |
| 280 void ParseInfo(const base::DictionaryValue* info); | 445 // device privates so that they can be reconstituted during parsing. |
| 446 // The parsers only access things through the private set_ functions | |
| 447 // so that this class can evolve without having to change all the | |
| 448 // parsers. | |
| 449 NETWORK_LIBRARY_PARSER_FRIENDS; | |
| 450 | |
| 451 // This allows the implementation classes access to privates in the | |
| 452 // same fashion. | |
| 453 NETWORK_LIBRARY_IMPL_FRIENDS; | |
| 454 | |
| 455 // Use these functions at your peril. They are used by the various | |
| 456 // parsers to set state, and really shouldn't be used by anyone | |
| 457 // else. | |
| 458 void set_device_path(const std::string& device_path) { | |
| 459 device_path_ = device_path; | |
| 460 } | |
| 461 void set_name(const std::string& name) { name_ = name; } | |
| 462 void set_type(ConnectionType type) { type_ = type; } | |
| 463 void set_scanning(bool scanning) { scanning_ = scanning; } | |
| 464 void set_meid(const std::string& meid) { meid_ = meid; } | |
| 465 void set_imei(const std::string& imei) { imei_ = imei; } | |
| 466 void set_imsi(const std::string& imsi) { imsi_ = imsi; } | |
| 467 void set_esn(const std::string& esn) { esn_ = esn; } | |
| 468 void set_mdn(const std::string& mdn) { mdn_ = mdn; } | |
| 469 void set_min(const std::string& min) { min_ = min; } | |
| 470 void set_technology_family(TechnologyFamily technology_family) { | |
| 471 technology_family_ = technology_family; | |
| 472 } | |
| 473 void set_carrier(const std::string& carrier) { carrier_ = carrier; } | |
| 474 void set_home_provider(const std::string& home_provider) { | |
| 475 home_provider_ = home_provider; | |
| 476 } | |
| 477 void set_home_provider_code(const std::string& home_provider_code) { | |
| 478 home_provider_code_ = home_provider_code; | |
| 479 } | |
| 480 void set_home_provider_country(const std::string& home_provider_country) { | |
| 481 home_provider_country_ = home_provider_country; | |
| 482 } | |
| 483 void set_home_provider_id(const std::string& home_provider_id) { | |
| 484 home_provider_id_ = home_provider_id; | |
| 485 } | |
| 486 void set_home_provider_name(const std::string& home_provider_name) { | |
| 487 home_provider_name_ = home_provider_name; | |
| 488 } | |
| 489 void set_model_id(const std::string& model_id) { model_id_ = model_id; } | |
| 490 void set_manufacturer(const std::string& manufacturer) { | |
| 491 manufacturer_ = manufacturer; | |
| 492 } | |
| 493 void set_prl_version(int prl_version) { | |
| 494 prl_version_ = prl_version; | |
| 495 } | |
| 496 void set_sim_lock_state(SimLockState sim_lock_state) { | |
| 497 sim_lock_state_ = sim_lock_state; | |
| 498 } | |
| 499 void set_sim_retries_left(int sim_retries_left) { | |
| 500 sim_retries_left_ = sim_retries_left; | |
| 501 } | |
| 502 void set_sim_pin_required(SimPinRequire sim_pin_required) { | |
| 503 sim_pin_required_ = sim_pin_required; | |
| 504 } | |
| 505 void set_firmware_revision(const std::string& firmware_revision) { | |
| 506 firmware_revision_ = firmware_revision; | |
| 507 } | |
| 508 void set_hardware_revision(const std::string& hardware_revision) { | |
| 509 hardware_revision_ = hardware_revision; | |
| 510 } | |
| 511 void set_selected_cellular_network( | |
| 512 const std::string& selected_cellular_network) { | |
| 513 selected_cellular_network_ = selected_cellular_network; | |
| 514 } | |
| 515 void set_found_cellular_networks( | |
| 516 const CellularNetworkList& found_cellular_networks) { | |
| 517 found_cellular_networks_ = found_cellular_networks; | |
| 518 } | |
| 519 void set_data_roaming_allowed(bool data_roaming_allowed) { | |
| 520 data_roaming_allowed_ = data_roaming_allowed; | |
| 521 } | |
| 522 void set_support_network_scan(bool support_network_scan) { | |
| 523 support_network_scan_ = support_network_scan; | |
| 524 } | |
| 525 void set_provider_apn_list(const CellularApnList& provider_apn_list) { | |
| 526 provider_apn_list_ = provider_apn_list; | |
| 527 } | |
| 528 | |
| 529 void ParseInfo(const base::DictionaryValue& info); | |
| 281 | 530 |
| 282 // General device info. | 531 // General device info. |
| 283 std::string device_path_; | 532 std::string device_path_; |
| 284 std::string name_; | 533 std::string name_; |
| 534 std::string unique_id_; | |
| 285 ConnectionType type_; | 535 ConnectionType type_; |
| 286 bool scanning_; | 536 bool scanning_; |
| 287 // Cellular specific device info. | 537 // Cellular specific device info. |
| 288 TechnologyFamily technology_family_; | 538 TechnologyFamily technology_family_; |
| 289 std::string carrier_; | 539 std::string carrier_; |
| 290 std::string home_provider_; | 540 std::string home_provider_; |
| 291 std::string home_provider_code_; | 541 std::string home_provider_code_; |
| 292 std::string home_provider_country_; | 542 std::string home_provider_country_; |
| 293 std::string home_provider_id_; | 543 std::string home_provider_id_; |
| 294 std::string home_provider_name_; | 544 std::string home_provider_name_; |
| 295 std::string MEID_; | 545 std::string meid_; |
| 296 std::string IMEI_; | 546 std::string imei_; |
| 297 std::string IMSI_; | 547 std::string imsi_; |
| 298 std::string ESN_; | 548 std::string esn_; |
| 299 std::string MDN_; | 549 std::string mdn_; |
| 300 std::string MIN_; | 550 std::string min_; |
| 301 std::string model_id_; | 551 std::string model_id_; |
| 302 std::string manufacturer_; | 552 std::string manufacturer_; |
| 303 SIMLockState sim_lock_state_; | 553 SimLockState sim_lock_state_; |
| 304 int sim_retries_left_; | 554 int sim_retries_left_; |
| 305 SIMPinRequire sim_pin_required_; | 555 SimPinRequire sim_pin_required_; |
| 306 std::string firmware_revision_; | 556 std::string firmware_revision_; |
| 307 std::string hardware_revision_; | 557 std::string hardware_revision_; |
| 308 int PRL_version_; | 558 int prl_version_; |
| 309 std::string selected_cellular_network_; | 559 std::string selected_cellular_network_; |
| 310 CellularNetworkList found_cellular_networks_; | 560 CellularNetworkList found_cellular_networks_; |
| 311 bool data_roaming_allowed_; | 561 bool data_roaming_allowed_; |
| 312 bool support_network_scan_; | 562 bool support_network_scan_; |
| 313 CellularApnList provider_apn_list_; | 563 CellularApnList provider_apn_list_; |
| 314 | 564 |
| 315 friend class NetworkLibraryImplBase; | 565 // This is the parser we use to parse messages from the native |
| 316 friend class NetworkLibraryImplCros; | 566 // network layer. |
| 317 friend class NetworkLibraryImplStub; | 567 scoped_ptr<NativeNetworkDeviceParser> device_parser_; |
| 568 | |
| 318 DISALLOW_COPY_AND_ASSIGN(NetworkDevice); | 569 DISALLOW_COPY_AND_ASSIGN(NetworkDevice); |
| 319 }; | 570 }; |
| 320 | 571 |
| 321 // Contains data common to all network service types. | 572 // Contains data common to all network service types. |
| 322 class Network { | 573 class Network { |
| 323 public: | 574 public: |
| 324 virtual ~Network(); | 575 virtual ~Network(); |
| 325 | 576 |
| 326 const std::string& service_path() const { return service_path_; } | 577 const std::string& service_path() const { return service_path_; } |
| 327 const std::string& name() const { return name_; } | 578 const std::string& name() const { return name_; } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 397 state == STATE_CARRIER); | 648 state == STATE_CARRIER); |
| 398 } | 649 } |
| 399 static bool IsDisconnectedState(ConnectionState state) { | 650 static bool IsDisconnectedState(ConnectionState state) { |
| 400 return (state == STATE_UNKNOWN || | 651 return (state == STATE_UNKNOWN || |
| 401 state == STATE_IDLE || | 652 state == STATE_IDLE || |
| 402 state == STATE_DISCONNECT || | 653 state == STATE_DISCONNECT || |
| 403 state == STATE_FAILURE || | 654 state == STATE_FAILURE || |
| 404 state == STATE_ACTIVATION_FAILURE); | 655 state == STATE_ACTIVATION_FAILURE); |
| 405 } | 656 } |
| 406 | 657 |
| 658 virtual bool UpdateStatus(const std::string& key, | |
| 659 const Value& value, | |
| 660 PropertyIndex* index); | |
| 661 | |
| 407 protected: | 662 protected: |
| 408 Network(const std::string& service_path, ConnectionType type); | 663 Network(const std::string& service_path, |
| 664 ConnectionType type, | |
| 665 NativeNetworkParser* parser); | |
| 666 | |
| 667 // Set the state and update flags if necessary. | |
| 668 void SetState(ConnectionState state); | |
| 409 | 669 |
| 410 // Parse name/value pairs from libcros. | 670 // Parse name/value pairs from libcros. |
| 411 virtual bool ParseValue(int index, const base::Value* value); | 671 virtual void ParseInfo(const base::DictionaryValue& info); |
| 412 virtual void ParseInfo(const base::DictionaryValue* info); | |
| 413 | 672 |
| 414 // Erase cached credentials, used when "Save password" is unchecked. | 673 // Erase cached credentials, used when "Save password" is unchecked. |
| 415 virtual void EraseCredentials(); | 674 virtual void EraseCredentials(); |
| 416 | 675 |
| 417 // Calculate a unique identifier for the network. | 676 // Calculate a unique identifier for the network. |
| 418 virtual void CalculateUniqueId(); | 677 virtual void CalculateUniqueId(); |
| 419 | 678 |
| 420 // Methods to asynchronously set network service properties | 679 // Methods to asynchronously set network service properties |
| 421 virtual void SetStringProperty(const char* prop, const std::string& str, | 680 virtual void SetStringProperty(const char* prop, const std::string& str, |
| 422 std::string* dest); | 681 std::string* dest); |
| 423 virtual void SetBooleanProperty(const char* prop, bool b, bool* dest); | 682 virtual void SetBooleanProperty(const char* prop, bool b, bool* dest); |
| 424 virtual void SetIntegerProperty(const char* prop, int i, int* dest); | 683 virtual void SetIntegerProperty(const char* prop, int i, int* dest); |
| 425 virtual void SetValueProperty(const char* prop, base::Value* val); | 684 virtual void SetValueProperty(const char* prop, base::Value* val); |
| 426 virtual void ClearProperty(const char* prop); | 685 virtual void ClearProperty(const char* prop); |
| 427 | 686 |
| 428 // This will clear the property if string is empty. Otherwise, it will set it. | 687 // This will clear the property if string is empty. Otherwise, it will set it. |
| 429 virtual void SetOrClearStringProperty(const char* prop, | 688 virtual void SetOrClearStringProperty(const char* prop, |
| 430 const std::string& str, | 689 const std::string& str, |
| 431 std::string* dest); | 690 std::string* dest); |
| 432 | 691 |
| 433 std::string device_path_; | 692 NativeNetworkParser* network_parser() { return network_parser_.get(); } |
| 434 std::string name_; | |
| 435 std::string ip_address_; | |
| 436 ConnectionMode mode_; | |
| 437 ConnectionState state_; | |
| 438 ConnectionError error_; | |
| 439 bool connectable_; | |
| 440 bool is_active_; | |
| 441 int priority_; // determines order in network list. | |
| 442 bool auto_connect_; | |
| 443 bool save_credentials_; // save passphrase and EAP credentials to disk. | |
| 444 std::string proxy_config_; | |
| 445 | 693 |
| 446 // Unique identifier, set the first time the network is parsed. | 694 void set_unique_id(const std::string& unique_id) { unique_id_ = unique_id; } |
| 447 std::string unique_id_; | |
| 448 | 695 |
| 449 private: | 696 private: |
| 697 // This allows NetworkParser and its subclasses access to device | |
| 698 // privates so that they can be reconstituted during parsing. The | |
| 699 // parsers only access things through the private set_ functions so | |
| 700 // that this class can evolve without having to change all the | |
| 701 // parsers. | |
| 702 NETWORK_LIBRARY_PARSER_FRIENDS; | |
| 703 | |
| 704 // This allows the implementation classes access to privates in the | |
| 705 // same fashion. | |
| 706 NETWORK_LIBRARY_IMPL_FRIENDS; | |
| 707 | |
| 708 // Use these functions at your peril. They are used by the various | |
| 709 // parsers to set state, and really shouldn't be used by anything else | |
| 710 // because they don't do the error checking and sending to the | |
| 711 // network layer that the other setters do. | |
| 712 void set_device_path(const std::string& device_path) { | |
| 713 device_path_ = device_path; | |
| 714 } | |
| 450 void set_name(const std::string& name) { name_ = name; } | 715 void set_name(const std::string& name) { name_ = name; } |
| 716 void set_mode(ConnectionMode mode) { mode_ = mode; } | |
| 451 void set_connecting(bool connecting) { | 717 void set_connecting(bool connecting) { |
| 452 state_ = (connecting ? STATE_ASSOCIATION : STATE_IDLE); | 718 state_ = (connecting ? STATE_ASSOCIATION : STATE_IDLE); |
| 453 } | 719 } |
| 454 void set_connected(bool connected) { | 720 void set_connected(bool connected) { |
| 455 state_ = (connected ? STATE_ONLINE : STATE_IDLE); | 721 state_ = (connected ? STATE_ONLINE : STATE_IDLE); |
| 456 } | 722 } |
| 457 void set_connectable(bool connectable) { connectable_ = connectable; } | 723 void set_connectable(bool connectable) { connectable_ = connectable; } |
| 458 void set_active(bool is_active) { is_active_ = is_active; } | 724 void set_is_active(bool is_active) { is_active_ = is_active; } |
| 459 void set_error(ConnectionError error) { error_ = error; } | 725 void set_error(ConnectionError error) { error_ = error; } |
| 460 void set_added(bool added) { added_ = added; } | 726 void set_added(bool added) { added_ = added; } |
| 727 void set_auto_connect(bool auto_connect) { auto_connect_ = auto_connect; } | |
| 728 void set_save_credentials(bool save_credentials) { | |
| 729 save_credentials_ = save_credentials; | |
| 730 } | |
| 461 void set_profile_path(const std::string& path) { profile_path_ = path; } | 731 void set_profile_path(const std::string& path) { profile_path_ = path; } |
| 462 void set_profile_type(NetworkProfileType type) { profile_type_ = type; } | 732 void set_profile_type(NetworkProfileType type) { profile_type_ = type; } |
| 463 | 733 |
| 464 // Set the state and update flags if necessary. | 734 std::string device_path_; |
| 465 void SetState(ConnectionState state); | 735 std::string name_; |
| 736 std::string ip_address_; | |
| 737 ConnectionMode mode_; | |
| 738 ConnectionState state_; | |
| 739 ConnectionError error_; | |
| 740 bool connectable_; | |
| 741 bool is_active_; | |
| 742 int priority_; // determines order in network list. | |
| 743 bool auto_connect_; | |
| 744 bool save_credentials_; // save passphrase and EAP credentials to disk. | |
| 745 std::string proxy_config_; | |
| 746 | |
| 747 // Unique identifier, set the first time the network is parsed. | |
| 748 std::string unique_id_; | |
| 466 | 749 |
| 467 // Set the profile path and update the flimfalm property. | 750 // Set the profile path and update the flimfalm property. |
| 468 void SetProfilePath(const std::string& profile_path); | 751 void SetProfilePath(const std::string& profile_path); |
| 469 | 752 |
| 470 // Initialize the IP address field | 753 // Initialize the IP address field |
| 471 void InitIPAddress(); | 754 void InitIPAddress(); |
| 472 | 755 |
| 473 // Priority value, corresponds to index in list from flimflam (0 = first) | 756 // Priority value, corresponds to index in list from flimflam (0 = first) |
| 474 int priority_order_; | 757 int priority_order_; |
| 475 | 758 |
| 476 // Set to true if the UI requested this as a new network. | 759 // Set to true if the UI requested this as a new network. |
| 477 bool added_; | 760 bool added_; |
| 478 | 761 |
| 479 // Set to true when a new connection failure occurs; cleared when observers | 762 // Set to true when a new connection failure occurs; cleared when observers |
| 480 // are notified. | 763 // are notified. |
| 481 bool notify_failure_; | 764 bool notify_failure_; |
| 482 | 765 |
| 483 // Profile path for networks. | 766 // Profile path for networks. |
| 484 std::string profile_path_; | 767 std::string profile_path_; |
| 485 | 768 |
| 486 // Set to profile type based on profile_path_. | 769 // Set to profile type based on profile_path_. |
| 487 NetworkProfileType profile_type_; | 770 NetworkProfileType profile_type_; |
| 488 | 771 |
| 489 // These must not be modified after construction. | 772 // These must not be modified after construction. |
| 490 std::string service_path_; | 773 std::string service_path_; |
| 491 ConnectionType type_; | 774 ConnectionType type_; |
| 492 | 775 |
| 493 friend class NetworkLibraryImplBase; | 776 // This is the parser we use to parse messages from the native |
| 494 friend class NetworkLibraryImplCros; | 777 // network layer. |
| 495 friend class NetworkLibraryImplStub; | 778 scoped_ptr<NativeNetworkParser> network_parser_; |
| 779 | |
| 496 DISALLOW_COPY_AND_ASSIGN(Network); | 780 DISALLOW_COPY_AND_ASSIGN(Network); |
| 497 }; | 781 }; |
| 498 | 782 |
| 499 // Class for networks of TYPE_ETHERNET. | 783 // Class for networks of TYPE_ETHERNET. |
| 500 class EthernetNetwork : public Network { | 784 class EthernetNetwork : public Network { |
| 501 public: | 785 public: |
| 502 explicit EthernetNetwork(const std::string& service_path) : | 786 explicit EthernetNetwork(const std::string& service_path); |
| 503 Network(service_path, TYPE_ETHERNET) { | |
| 504 } | |
| 505 private: | 787 private: |
| 506 friend class NetworkLibraryImplBase; | 788 // This allows NetworkParser and its subclasses access to device |
| 507 friend class NetworkLibraryImplCros; | 789 // privates so that they can be reconstituted during parsing. The |
| 508 friend class NetworkLibraryImplStub; | 790 // parsers only access things through the private set_ functions so |
| 791 // that this class can evolve without having to change all the | |
| 792 // parsers. | |
| 793 NETWORK_LIBRARY_PARSER_FRIENDS; | |
| 794 | |
| 795 // This allows the implementation classes access to privates in the | |
| 796 // same fashion. | |
| 797 NETWORK_LIBRARY_IMPL_FRIENDS; | |
| 798 | |
| 509 DISALLOW_COPY_AND_ASSIGN(EthernetNetwork); | 799 DISALLOW_COPY_AND_ASSIGN(EthernetNetwork); |
| 510 }; | 800 }; |
| 511 | 801 |
| 512 // Class for networks of TYPE_VPN. | 802 // Class for networks of TYPE_VPN. |
| 513 class VirtualNetwork : public Network { | 803 class VirtualNetwork : public Network { |
| 514 public: | 804 public: |
| 515 enum ProviderType { | |
| 516 PROVIDER_TYPE_L2TP_IPSEC_PSK, | |
| 517 PROVIDER_TYPE_L2TP_IPSEC_USER_CERT, | |
| 518 PROVIDER_TYPE_OPEN_VPN, | |
| 519 // Add new provider types before PROVIDER_TYPE_MAX. | |
| 520 PROVIDER_TYPE_MAX, | |
| 521 }; | |
| 522 | |
| 523 explicit VirtualNetwork(const std::string& service_path); | 805 explicit VirtualNetwork(const std::string& service_path); |
| 524 virtual ~VirtualNetwork(); | 806 virtual ~VirtualNetwork(); |
| 525 | 807 |
| 526 const std::string& server_hostname() const { return server_hostname_; } | 808 const std::string& server_hostname() const { return server_hostname_; } |
| 527 ProviderType provider_type() const { return provider_type_; } | 809 ProviderType provider_type() const { return provider_type_; } |
| 528 const std::string& ca_cert_nss() const { return ca_cert_nss_; } | 810 const std::string& ca_cert_nss() const { return ca_cert_nss_; } |
| 529 const std::string& psk_passphrase() const { return psk_passphrase_; } | 811 const std::string& psk_passphrase() const { return psk_passphrase_; } |
| 530 const std::string& client_cert_id() const { return client_cert_id_; } | 812 const std::string& client_cert_id() const { return client_cert_id_; } |
| 531 const std::string& username() const { return username_; } | 813 const std::string& username() const { return username_; } |
| 532 const std::string& user_passphrase() const { return user_passphrase_; } | 814 const std::string& user_passphrase() const { return user_passphrase_; } |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 544 std::string GetProviderTypeString() const; | 826 std::string GetProviderTypeString() const; |
| 545 | 827 |
| 546 // Public setters. | 828 // Public setters. |
| 547 void SetCACertNSS(const std::string& ca_cert_nss); | 829 void SetCACertNSS(const std::string& ca_cert_nss); |
| 548 void SetPSKPassphrase(const std::string& psk_passphrase); | 830 void SetPSKPassphrase(const std::string& psk_passphrase); |
| 549 void SetClientCertID(const std::string& cert_id); | 831 void SetClientCertID(const std::string& cert_id); |
| 550 void SetUsername(const std::string& username); | 832 void SetUsername(const std::string& username); |
| 551 void SetUserPassphrase(const std::string& user_passphrase); | 833 void SetUserPassphrase(const std::string& user_passphrase); |
| 552 | 834 |
| 553 private: | 835 private: |
| 554 // Network overrides. | 836 // This allows NetworkParser and its subclasses access to device |
| 555 virtual bool ParseValue(int index, const base::Value* value); | 837 // privates so that they can be reconstituted during parsing. The |
| 556 virtual void ParseInfo(const base::DictionaryValue* info); | 838 // parsers only access things through the private set_ functions so |
| 557 virtual void EraseCredentials(); | 839 // that this class can evolve without having to change all the |
| 558 virtual void CalculateUniqueId(); | 840 // parsers. |
| 841 NETWORK_LIBRARY_PARSER_FRIENDS; | |
| 559 | 842 |
| 560 // VirtualNetwork private methods. | 843 // This allows the implementation classes access to privates in the |
| 561 bool ParseProviderValue(int index, const base::Value* value); | 844 // same fashion. |
| 845 NETWORK_LIBRARY_IMPL_FRIENDS; | |
| 562 | 846 |
| 847 // Use these functions at your peril. They are used by the various | |
| 848 // parsers to set state, and really shouldn't be used by anything else | |
| 849 // because they don't do the error checking and sending to the | |
| 850 // network layer that the other setters do. | |
| 563 void set_server_hostname(const std::string& server_hostname) { | 851 void set_server_hostname(const std::string& server_hostname) { |
| 564 server_hostname_ = server_hostname; | 852 server_hostname_ = server_hostname; |
| 565 } | 853 } |
| 566 void set_provider_type(ProviderType provider_type) { | 854 void set_provider_type(ProviderType provider_type) { |
| 567 provider_type_ = provider_type; | 855 provider_type_ = provider_type; |
| 568 } | 856 } |
| 569 void set_ca_cert_nss(const std::string& ca_cert_nss) { | 857 void set_ca_cert_nss(const std::string& ca_cert_nss) { |
| 570 ca_cert_nss_ = ca_cert_nss; | 858 ca_cert_nss_ = ca_cert_nss; |
| 571 } | 859 } |
| 572 void set_psk_passphrase(const std::string& psk_passphrase) { | 860 void set_psk_passphrase(const std::string& psk_passphrase) { |
| 573 psk_passphrase_ = psk_passphrase; | 861 psk_passphrase_ = psk_passphrase; |
| 574 } | 862 } |
| 575 void set_client_cert_id(const std::string& client_cert_id) { | 863 void set_client_cert_id(const std::string& client_cert_id) { |
| 576 client_cert_id_ = client_cert_id; | 864 client_cert_id_ = client_cert_id; |
| 577 } | 865 } |
| 578 void set_username(const std::string& username) { | 866 void set_username(const std::string& username) { username_ = username; } |
| 579 username_ = username; | |
| 580 } | |
| 581 void set_user_passphrase(const std::string& user_passphrase) { | 867 void set_user_passphrase(const std::string& user_passphrase) { |
| 582 user_passphrase_ = user_passphrase; | 868 user_passphrase_ = user_passphrase; |
| 583 } | 869 } |
| 584 | 870 |
| 871 // Network overrides. | |
| 872 virtual void EraseCredentials() OVERRIDE; | |
| 873 virtual void CalculateUniqueId() OVERRIDE; | |
| 874 | |
| 875 // VirtualNetwork private methods. | |
| 876 bool ParseProviderValue(int index, const base::Value* value); | |
| 877 | |
| 585 std::string server_hostname_; | 878 std::string server_hostname_; |
| 586 ProviderType provider_type_; | 879 ProviderType provider_type_; |
| 587 // NSS nickname for server CA certificate. | 880 // NSS nickname for server CA certificate. |
| 588 std::string ca_cert_nss_; | 881 std::string ca_cert_nss_; |
| 589 std::string psk_passphrase_; | 882 std::string psk_passphrase_; |
| 590 // PKCS#11 ID for client certificate. | 883 // PKCS#11 ID for client certificate. |
| 591 std::string client_cert_id_; | 884 std::string client_cert_id_; |
| 592 std::string username_; | 885 std::string username_; |
| 593 std::string user_passphrase_; | 886 std::string user_passphrase_; |
| 594 | |
| 595 friend class NetworkLibraryImplBase; | |
| 596 friend class NetworkLibraryImplCros; | |
| 597 friend class NetworkLibraryImplStub; | |
| 598 DISALLOW_COPY_AND_ASSIGN(VirtualNetwork); | 887 DISALLOW_COPY_AND_ASSIGN(VirtualNetwork); |
| 599 }; | 888 }; |
| 600 typedef std::vector<VirtualNetwork*> VirtualNetworkVector; | 889 typedef std::vector<VirtualNetwork*> VirtualNetworkVector; |
| 601 | 890 |
| 602 // Base class for networks of TYPE_WIFI or TYPE_CELLULAR. | 891 // Base class for networks of TYPE_WIFI or TYPE_CELLULAR. |
| 603 class WirelessNetwork : public Network { | 892 class WirelessNetwork : public Network { |
| 604 public: | 893 public: |
| 605 int strength() const { return strength_; } | 894 int strength() const { return strength_; } |
| 606 | 895 |
| 607 protected: | 896 protected: |
| 608 WirelessNetwork(const std::string& service_path, ConnectionType type) | 897 WirelessNetwork(const std::string& service_path, |
| 609 : Network(service_path, type), | 898 ConnectionType type, |
| 610 strength_(0) {} | 899 NativeNetworkParser* parser) |
| 900 : Network(service_path, type, parser), strength_(0) {} | |
| 901 private: | |
| 902 // This allows NetworkParser and its subclasses access to device | |
| 903 // privates so that they can be reconstituted during parsing. The | |
| 904 // parsers only access things through the private set_ functions so | |
| 905 // that this class can evolve without having to change all the | |
| 906 // parsers. | |
| 907 NETWORK_LIBRARY_PARSER_FRIENDS; | |
| 908 | |
| 909 // This allows the implementation classes access to privates in the | |
| 910 // same fashion. | |
| 911 NETWORK_LIBRARY_IMPL_FRIENDS; | |
| 912 | |
| 913 // The friend parsers use this. | |
| 914 void set_strength(int strength) { strength_ = strength; } | |
| 915 | |
| 611 int strength_; // 0-100 | 916 int strength_; // 0-100 |
| 612 | 917 |
| 613 // Network overrides. | |
| 614 virtual bool ParseValue(int index, const base::Value* value); | |
| 615 | |
| 616 private: | |
| 617 void set_strength(int strength) { strength_ = strength; } | |
| 618 | |
| 619 friend class NetworkLibraryImplBase; | |
| 620 friend class NetworkLibraryImplCros; | |
| 621 friend class NetworkLibraryImplStub; | |
| 622 DISALLOW_COPY_AND_ASSIGN(WirelessNetwork); | 918 DISALLOW_COPY_AND_ASSIGN(WirelessNetwork); |
| 623 }; | 919 }; |
| 624 | 920 |
| 625 // Class for networks of TYPE_CELLULAR. | 921 // Class for networks of TYPE_CELLULAR. |
| 626 class CellularDataPlan; | 922 class CellularDataPlan; |
| 627 | 923 |
| 628 class CellularNetwork : public WirelessNetwork { | 924 class CellularNetwork : public WirelessNetwork { |
| 629 public: | 925 public: |
| 630 enum DataLeft { | 926 enum DataLeft { |
| 631 DATA_UNKNOWN, | 927 DATA_UNKNOWN, |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 659 && connected() && activated(); | 955 && connected() && activated(); |
| 660 } | 956 } |
| 661 const std::string& operator_name() const { return operator_name_; } | 957 const std::string& operator_name() const { return operator_name_; } |
| 662 const std::string& operator_code() const { return operator_code_; } | 958 const std::string& operator_code() const { return operator_code_; } |
| 663 const std::string& operator_country() const { return operator_country_; } | 959 const std::string& operator_country() const { return operator_country_; } |
| 664 const std::string& payment_url() const { return payment_url_; } | 960 const std::string& payment_url() const { return payment_url_; } |
| 665 const std::string& usage_url() const { return usage_url_; } | 961 const std::string& usage_url() const { return usage_url_; } |
| 666 DataLeft data_left() const { return data_left_; } | 962 DataLeft data_left() const { return data_left_; } |
| 667 const CellularApn& apn() const { return apn_; } | 963 const CellularApn& apn() const { return apn_; } |
| 668 const CellularApn& last_good_apn() const { return last_good_apn_; } | 964 const CellularApn& last_good_apn() const { return last_good_apn_; } |
| 965 | |
| 669 // Sets the APN to use in establishing data connections. Only | 966 // Sets the APN to use in establishing data connections. Only |
| 670 // the fields of the APN that are needed for making connections | 967 // the fields of the APN that are needed for making connections |
| 671 // are passed to flimflam. The name, localized_name, and language | 968 // are passed to flimflam. The name, localized_name, and language |
| 672 // fields are ignored. | 969 // fields are ignored. |
| 673 void SetApn(const CellularApn& apn); | 970 void SetApn(const CellularApn& apn); |
| 674 | 971 |
| 675 // Returns true if network supports activation. | 972 // Returns true if network supports activation. |
| 676 // Current implementation returns same as SupportsDataPlan(). | 973 // Current implementation returns same as SupportsDataPlan(). |
| 677 bool SupportsActivation() const; | 974 bool SupportsActivation() const; |
| 678 | 975 |
| 679 // Returns true if one of the usage_url_ / payment_url_ (or both) is defined. | 976 // Returns true if one of the usage_url_ / payment_url_ (or both) is defined. |
| 680 bool SupportsDataPlan() const; | 977 bool SupportsDataPlan() const; |
| 681 | 978 |
| 682 // Return a string representation of network technology. | 979 // Return a string representation of network technology. |
| 683 std::string GetNetworkTechnologyString() const; | 980 std::string GetNetworkTechnologyString() const; |
| 684 // Return a string representation of activation state. | 981 // Return a string representation of activation state. |
| 685 std::string GetActivationStateString() const; | 982 std::string GetActivationStateString() const; |
| 686 // Return a string representation of roaming state. | 983 // Return a string representation of roaming state. |
| 687 std::string GetRoamingStateString() const; | 984 std::string GetRoamingStateString() const; |
| 688 | 985 |
| 689 // Return a string representation of |activation_state|. | 986 // Return a string representation of |activation_state|. |
| 690 static std::string ActivationStateToString(ActivationState activation_state); | 987 static std::string ActivationStateToString(ActivationState activation_state); |
| 691 | 988 |
| 692 protected: | 989 private: |
| 693 // WirelessNetwork overrides. | 990 // This allows NetworkParser and its subclasses access to device |
| 694 virtual bool ParseValue(int index, const base::Value* value); | 991 // privates so that they can be reconstituted during parsing. The |
| 992 // parsers only access things through the private set_ functions so | |
| 993 // that this class can evolve without having to change all the | |
| 994 // parsers. | |
| 995 NETWORK_LIBRARY_PARSER_FRIENDS; | |
| 996 | |
| 997 // This allows the implementation classes access to privates in the | |
| 998 // same fashion. | |
| 999 NETWORK_LIBRARY_IMPL_FRIENDS; | |
| 1000 | |
| 1001 // Use these functions at your peril. They are used by the various | |
| 1002 // parsers to set state, and really shouldn't be used by anything else | |
| 1003 // because they don't do the error checking and sending to the | |
| 1004 // network layer that the other setters do. | |
| 1005 void set_activation_state(ActivationState activation_state) { | |
| 1006 activation_state_ = activation_state; | |
| 1007 } | |
| 1008 void set_network_technology(NetworkTechnology network_technology) { | |
| 1009 network_technology_ = network_technology; | |
| 1010 } | |
| 1011 void set_roaming_state(NetworkRoamingState roaming_state) { | |
| 1012 roaming_state_ = roaming_state; | |
| 1013 } | |
| 1014 void set_operator_name(const std::string& operator_name) { | |
| 1015 operator_name_ = operator_name; | |
| 1016 } | |
| 1017 void set_operator_code(const std::string& operator_code) { | |
| 1018 operator_code_ = operator_code; | |
| 1019 } | |
| 1020 void set_operator_country(const std::string& operator_country) { | |
| 1021 operator_country_ = operator_country; | |
| 1022 } | |
| 1023 void set_payment_url(const std::string& payment_url) { | |
| 1024 payment_url_ = payment_url; | |
| 1025 } | |
| 1026 void set_usage_url(const std::string& usage_url) { usage_url_ = usage_url; } | |
| 1027 void set_data_left(DataLeft data_left) { data_left_ = data_left; } | |
| 1028 void set_apn(const DictionaryValue& apn) { apn_.Set(apn); } | |
| 1029 void set_last_good_apn(const DictionaryValue& last_good_apn) { | |
| 1030 last_good_apn_.Set(last_good_apn); | |
| 1031 } | |
| 695 | 1032 |
| 696 ActivationState activation_state_; | 1033 ActivationState activation_state_; |
| 697 NetworkTechnology network_technology_; | 1034 NetworkTechnology network_technology_; |
| 698 NetworkRoamingState roaming_state_; | 1035 NetworkRoamingState roaming_state_; |
| 699 // Carrier Info | 1036 // Carrier Info |
| 700 std::string operator_name_; | 1037 std::string operator_name_; |
| 701 std::string operator_code_; | 1038 std::string operator_code_; |
| 702 std::string operator_country_; | 1039 std::string operator_country_; |
| 703 std::string payment_url_; | 1040 std::string payment_url_; |
| 704 std::string usage_url_; | 1041 std::string usage_url_; |
| 705 // Cached values | 1042 // Cached values |
| 706 DataLeft data_left_; // Updated when data plans are updated. | 1043 DataLeft data_left_; // Updated when data plans are updated. |
| 707 CellularApn apn_; | 1044 CellularApn apn_; |
| 708 CellularApn last_good_apn_; | 1045 CellularApn last_good_apn_; |
| 709 | 1046 |
| 710 private: | |
| 711 void set_activation_state(ActivationState state) { | |
| 712 activation_state_ = state; | |
| 713 } | |
| 714 void set_payment_url(const std::string& url) { payment_url_ = url; } | |
| 715 void set_usage_url(const std::string& url) { usage_url_ = url; } | |
| 716 void set_network_technology(NetworkTechnology technology) { | |
| 717 network_technology_ = technology; | |
| 718 } | |
| 719 void set_roaming_state(NetworkRoamingState state) { roaming_state_ = state; } | |
| 720 void set_data_left(DataLeft data_left) { data_left_ = data_left; } | |
| 721 void set_apn(const CellularApn& apn) { apn_ = apn; } | |
| 722 void set_last_good_apn(const CellularApn& apn) { last_good_apn_ = apn; } | |
| 723 | |
| 724 friend class NetworkLibraryImplBase; | |
| 725 friend class NetworkLibraryImplCros; | |
| 726 friend class NetworkLibraryImplStub; | |
| 727 DISALLOW_COPY_AND_ASSIGN(CellularNetwork); | 1047 DISALLOW_COPY_AND_ASSIGN(CellularNetwork); |
| 728 }; | 1048 }; |
| 729 typedef std::vector<CellularNetwork*> CellularNetworkVector; | 1049 typedef std::vector<CellularNetwork*> CellularNetworkVector; |
| 730 | 1050 |
| 731 // Class for networks of TYPE_WIFI. | 1051 // Class for networks of TYPE_WIFI. |
| 732 class WifiNetwork : public WirelessNetwork { | 1052 class WifiNetwork : public WirelessNetwork { |
| 733 public: | 1053 public: |
| 734 explicit WifiNetwork(const std::string& service_path); | 1054 explicit WifiNetwork(const std::string& service_path); |
| 735 virtual ~WifiNetwork(); | 1055 virtual ~WifiNetwork(); |
| 736 | 1056 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 776 virtual bool RequiresUserProfile() const; | 1096 virtual bool RequiresUserProfile() const; |
| 777 | 1097 |
| 778 // Return a string representation of the encryption code. | 1098 // Return a string representation of the encryption code. |
| 779 // This not translated and should be only used for debugging purposes. | 1099 // This not translated and should be only used for debugging purposes. |
| 780 std::string GetEncryptionString() const; | 1100 std::string GetEncryptionString() const; |
| 781 | 1101 |
| 782 // Return true if a passphrase or other input is required to connect. | 1102 // Return true if a passphrase or other input is required to connect. |
| 783 bool IsPassphraseRequired() const; | 1103 bool IsPassphraseRequired() const; |
| 784 | 1104 |
| 785 private: | 1105 private: |
| 786 // Network overrides. | 1106 // This allows NetworkParser and its subclasses access to device |
| 787 virtual void EraseCredentials(); | 1107 // privates so that they can be reconstituted during parsing. The |
| 788 virtual void CalculateUniqueId(); | 1108 // parsers only access things through the private set_ functions so |
| 1109 // that this class can evolve without having to change all the | |
| 1110 // parsers. | |
| 1111 NETWORK_LIBRARY_PARSER_FRIENDS; | |
| 789 | 1112 |
| 790 // WirelessNetwork overrides. | 1113 // This allows the implementation classes access to privates in the |
| 791 virtual bool ParseValue(int index, const base::Value* value); | 1114 // same fashion. |
| 1115 NETWORK_LIBRARY_IMPL_FRIENDS; | |
| 792 | 1116 |
| 1117 // Use these functions at your peril. They are used by the various | |
| 1118 // parsers to set state, and really shouldn't be used by anything else | |
| 1119 // because they don't do the error checking and sending to the | |
| 1120 // network layer that the other setters do. | |
| 793 void set_encryption(ConnectionSecurity encryption) { | 1121 void set_encryption(ConnectionSecurity encryption) { |
| 794 encryption_ = encryption; | 1122 encryption_ = encryption; |
| 795 } | 1123 } |
| 796 void set_passphrase(const std::string& passphrase) { | 1124 void set_passphrase(const std::string& passphrase) { |
| 797 passphrase_ = passphrase; | 1125 passphrase_ = passphrase; |
| 1126 user_passphrase_ = passphrase; | |
| 798 } | 1127 } |
| 799 void set_passphrase_required(bool passphrase_required) { | 1128 void set_passphrase_required(bool passphrase_required) { |
| 800 passphrase_required_ = passphrase_required; | 1129 passphrase_required_ = passphrase_required; |
| 801 } | 1130 } |
| 802 void set_identity(const std::string& identity) { | 1131 void set_identity(const std::string& identity) { |
| 803 identity_ = identity; | 1132 identity_ = identity; |
| 804 } | 1133 } |
| 1134 void set_eap_method(EAPMethod eap_method) { eap_method_ = eap_method; } | |
| 1135 void set_eap_phase_2_auth(EAPPhase2Auth eap_phase_2_auth) { | |
| 1136 eap_phase_2_auth_ = eap_phase_2_auth; | |
| 1137 } | |
| 1138 void set_eap_server_ca_cert_nss_nickname( | |
| 1139 const std::string& eap_server_ca_cert_nss_nickname) { | |
| 1140 eap_server_ca_cert_nss_nickname_ = eap_server_ca_cert_nss_nickname; | |
| 1141 } | |
| 1142 void set_eap_client_cert_pkcs11_id( | |
| 1143 const std::string& eap_client_cert_pkcs11_id) { | |
| 1144 eap_client_cert_pkcs11_id_ = eap_client_cert_pkcs11_id; | |
| 1145 } | |
| 1146 void set_eap_use_system_cas(bool eap_use_system_cas) { | |
| 1147 eap_use_system_cas_ = eap_use_system_cas; | |
| 1148 } | |
| 1149 void set_eap_identity(const std::string& eap_identity) { | |
| 1150 eap_identity_ = eap_identity; | |
| 1151 } | |
| 1152 void set_eap_anonymous_identity(const std::string& eap_anonymous_identity) { | |
| 1153 eap_anonymous_identity_ = eap_anonymous_identity; | |
| 1154 } | |
| 1155 void set_eap_passphrase(const std::string& eap_passphrase) { | |
| 1156 eap_passphrase_ = eap_passphrase; | |
| 1157 } | |
| 1158 | |
| 1159 // Network overrides. | |
| 1160 virtual void EraseCredentials() OVERRIDE; | |
| 1161 virtual void CalculateUniqueId() OVERRIDE; | |
| 1162 | |
| 805 ConnectionSecurity encryption_; | 1163 ConnectionSecurity encryption_; |
| 806 std::string passphrase_; | 1164 std::string passphrase_; |
| 807 bool passphrase_required_; | 1165 bool passphrase_required_; |
| 808 std::string identity_; | 1166 std::string identity_; |
| 809 | 1167 |
| 810 EAPMethod eap_method_; | 1168 EAPMethod eap_method_; |
| 811 EAPPhase2Auth eap_phase_2_auth_; | 1169 EAPPhase2Auth eap_phase_2_auth_; |
| 812 std::string eap_server_ca_cert_nss_nickname_; | 1170 std::string eap_server_ca_cert_nss_nickname_; |
| 813 std::string eap_client_cert_pkcs11_id_; | 1171 std::string eap_client_cert_pkcs11_id_; |
| 814 bool eap_use_system_cas_; | 1172 bool eap_use_system_cas_; |
| 815 std::string eap_identity_; | 1173 std::string eap_identity_; |
| 816 std::string eap_anonymous_identity_; | 1174 std::string eap_anonymous_identity_; |
| 817 std::string eap_passphrase_; | 1175 std::string eap_passphrase_; |
| 818 | 1176 |
| 819 // Internal state (not stored in flimflam). | 1177 // Internal state (not stored in flimflam). |
| 820 // Passphrase set by user (stored for UI). | 1178 // Passphrase set by user (stored for UI). |
| 821 std::string user_passphrase_; | 1179 std::string user_passphrase_; |
| 822 | 1180 |
| 823 friend class NetworkLibraryImplBase; | |
| 824 friend class NetworkLibraryImplCros; | |
| 825 friend class NetworkLibraryImplStub; | |
| 826 DISALLOW_COPY_AND_ASSIGN(WifiNetwork); | 1181 DISALLOW_COPY_AND_ASSIGN(WifiNetwork); |
| 827 }; | 1182 }; |
| 828 typedef std::vector<WifiNetwork*> WifiNetworkVector; | 1183 typedef std::vector<WifiNetwork*> WifiNetworkVector; |
| 829 | 1184 |
| 830 // Cellular Data Plan management. | 1185 // Cellular Data Plan management. |
| 831 class CellularDataPlan { | 1186 class CellularDataPlan { |
| 832 public: | 1187 public: |
| 833 CellularDataPlan(); | 1188 CellularDataPlan(); |
| 834 explicit CellularDataPlan(const CellularDataPlanInfo &plan); | 1189 explicit CellularDataPlan(const CellularDataPlanInfo &plan); |
| 835 ~CellularDataPlan(); | 1190 ~CellularDataPlan(); |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1295 virtual void SetIPConfig(const NetworkIPConfig& ipconfig) = 0; | 1650 virtual void SetIPConfig(const NetworkIPConfig& ipconfig) = 0; |
| 1296 | 1651 |
| 1297 // Factory function, creates a new instance and returns ownership. | 1652 // Factory function, creates a new instance and returns ownership. |
| 1298 // For normal usage, access the singleton via CrosLibrary::Get(). | 1653 // For normal usage, access the singleton via CrosLibrary::Get(). |
| 1299 static NetworkLibrary* GetImpl(bool stub); | 1654 static NetworkLibrary* GetImpl(bool stub); |
| 1300 }; | 1655 }; |
| 1301 | 1656 |
| 1302 } // namespace chromeos | 1657 } // namespace chromeos |
| 1303 | 1658 |
| 1304 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ | 1659 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ |
| OLD | NEW |