Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(492)

Side by Side Diff: chrome/browser/chromeos/cros/network_library.h

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

Powered by Google App Engine
This is Rietveld 408576698