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/string16.h" | 16 #include "base/string16.h" |
17 #include "base/timer.h" | 17 #include "base/timer.h" |
18 #include "third_party/cros/chromeos_network.h" | 18 #include "third_party/cros/chromeos_network.h" |
19 | 19 |
| 20 namespace base { |
20 class DictionaryValue; | 21 class DictionaryValue; |
21 class Value; | 22 class Value; |
| 23 } |
22 | 24 |
23 namespace chromeos { | 25 namespace chromeos { |
24 | 26 |
25 // Connection enums (see flimflam/include/service.h) | 27 // Connection enums (see flimflam/include/service.h) |
26 enum ConnectionType { | 28 enum ConnectionType { |
27 TYPE_UNKNOWN = 0, | 29 TYPE_UNKNOWN = 0, |
28 TYPE_ETHERNET = 1, | 30 TYPE_ETHERNET = 1, |
29 TYPE_WIFI = 2, | 31 TYPE_WIFI = 2, |
30 TYPE_WIMAX = 3, | 32 TYPE_WIMAX = 3, |
31 TYPE_BLUETOOTH = 4, | 33 TYPE_BLUETOOTH = 4, |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 const std::string& selected_cellular_network() const { | 237 const std::string& selected_cellular_network() const { |
236 return selected_cellular_network_; | 238 return selected_cellular_network_; |
237 } | 239 } |
238 const CellularNetworkList& found_cellular_networks() const { | 240 const CellularNetworkList& found_cellular_networks() const { |
239 return found_cellular_networks_; | 241 return found_cellular_networks_; |
240 } | 242 } |
241 bool data_roaming_allowed() const { return data_roaming_allowed_; } | 243 bool data_roaming_allowed() const { return data_roaming_allowed_; } |
242 bool support_network_scan() const { return support_network_scan_; } | 244 bool support_network_scan() const { return support_network_scan_; } |
243 | 245 |
244 private: | 246 private: |
245 bool ParseValue(int index, const Value* value); | 247 bool ParseValue(int index, const base::Value* value); |
246 void ParseInfo(const DictionaryValue* info); | 248 void ParseInfo(const base::DictionaryValue* info); |
247 | 249 |
248 // General device info. | 250 // General device info. |
249 std::string device_path_; | 251 std::string device_path_; |
250 std::string name_; | 252 std::string name_; |
251 ConnectionType type_; | 253 ConnectionType type_; |
252 bool scanning_; | 254 bool scanning_; |
253 // Cellular specific device info. | 255 // Cellular specific device info. |
254 std::string carrier_; | 256 std::string carrier_; |
255 std::string home_provider_; | 257 std::string home_provider_; |
256 std::string home_provider_code_; | 258 std::string home_provider_code_; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 } | 359 } |
358 | 360 |
359 // Sends the well-known TPM PIN to flimflam via D-Bus, because flimflam may | 361 // Sends the well-known TPM PIN to flimflam via D-Bus, because flimflam may |
360 // need it to access client certificates in the TPM for 802.1X, VPN, etc. | 362 // need it to access client certificates in the TPM for 802.1X, VPN, etc. |
361 void SendTpmPin(const std::string& tpm_pin); | 363 void SendTpmPin(const std::string& tpm_pin); |
362 | 364 |
363 protected: | 365 protected: |
364 Network(const std::string& service_path, ConnectionType type); | 366 Network(const std::string& service_path, ConnectionType type); |
365 | 367 |
366 // Parse name/value pairs from libcros. | 368 // Parse name/value pairs from libcros. |
367 virtual bool ParseValue(int index, const Value* value); | 369 virtual bool ParseValue(int index, const base::Value* value); |
368 virtual void ParseInfo(const DictionaryValue* info); | 370 virtual void ParseInfo(const base::DictionaryValue* info); |
369 | 371 |
370 // Erase cached credentials, used when "Save password" is unchecked. | 372 // Erase cached credentials, used when "Save password" is unchecked. |
371 virtual void EraseCredentials(); | 373 virtual void EraseCredentials(); |
372 | 374 |
373 // Calculate a unique identifier for the network. | 375 // Calculate a unique identifier for the network. |
374 virtual void CalculateUniqueId(); | 376 virtual void CalculateUniqueId(); |
375 | 377 |
376 // Methods to asynchronously set network service properties | 378 // Methods to asynchronously set network service properties |
377 virtual void SetStringProperty(const char* prop, const std::string& str, | 379 virtual void SetStringProperty(const char* prop, const std::string& str, |
378 std::string* dest); | 380 std::string* dest); |
379 virtual void SetBooleanProperty(const char* prop, bool b, bool* dest); | 381 virtual void SetBooleanProperty(const char* prop, bool b, bool* dest); |
380 virtual void SetIntegerProperty(const char* prop, int i, int* dest); | 382 virtual void SetIntegerProperty(const char* prop, int i, int* dest); |
381 virtual void SetValueProperty(const char* prop, Value* val); | 383 virtual void SetValueProperty(const char* prop, base::Value* val); |
382 virtual void ClearProperty(const char* prop); | 384 virtual void ClearProperty(const char* prop); |
383 | 385 |
384 // This will clear the property if string is empty. Otherwise, it will set it. | 386 // This will clear the property if string is empty. Otherwise, it will set it. |
385 virtual void SetOrClearStringProperty(const char* prop, | 387 virtual void SetOrClearStringProperty(const char* prop, |
386 const std::string& str, | 388 const std::string& str, |
387 std::string* dest); | 389 std::string* dest); |
388 | 390 |
389 std::string device_path_; | 391 std::string device_path_; |
390 std::string name_; | 392 std::string name_; |
391 std::string ip_address_; | 393 std::string ip_address_; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 | 497 |
496 // Public setters. | 498 // Public setters. |
497 void SetCACertNSS(const std::string& ca_cert_nss); | 499 void SetCACertNSS(const std::string& ca_cert_nss); |
498 void SetPSKPassphrase(const std::string& psk_passphrase); | 500 void SetPSKPassphrase(const std::string& psk_passphrase); |
499 void SetClientCertID(const std::string& cert_id); | 501 void SetClientCertID(const std::string& cert_id); |
500 void SetUsername(const std::string& username); | 502 void SetUsername(const std::string& username); |
501 void SetUserPassphrase(const std::string& user_passphrase); | 503 void SetUserPassphrase(const std::string& user_passphrase); |
502 | 504 |
503 private: | 505 private: |
504 // Network overrides. | 506 // Network overrides. |
505 virtual bool ParseValue(int index, const Value* value); | 507 virtual bool ParseValue(int index, const base::Value* value); |
506 virtual void ParseInfo(const DictionaryValue* info); | 508 virtual void ParseInfo(const base::DictionaryValue* info); |
507 virtual void EraseCredentials(); | 509 virtual void EraseCredentials(); |
508 virtual void CalculateUniqueId(); | 510 virtual void CalculateUniqueId(); |
509 | 511 |
510 // VirtualNetwork private methods. | 512 // VirtualNetwork private methods. |
511 bool ParseProviderValue(int index, const Value* value); | 513 bool ParseProviderValue(int index, const base::Value* value); |
512 | 514 |
513 void set_server_hostname(const std::string& server_hostname) { | 515 void set_server_hostname(const std::string& server_hostname) { |
514 server_hostname_ = server_hostname; | 516 server_hostname_ = server_hostname; |
515 } | 517 } |
516 void set_provider_type(ProviderType provider_type) { | 518 void set_provider_type(ProviderType provider_type) { |
517 provider_type_ = provider_type; | 519 provider_type_ = provider_type; |
518 } | 520 } |
519 void set_ca_cert_nss(const std::string& ca_cert_nss) { | 521 void set_ca_cert_nss(const std::string& ca_cert_nss) { |
520 ca_cert_nss_ = ca_cert_nss; | 522 ca_cert_nss_ = ca_cert_nss; |
521 } | 523 } |
(...skipping 30 matching lines...) Expand all Loading... |
552 public: | 554 public: |
553 int strength() const { return strength_; } | 555 int strength() const { return strength_; } |
554 | 556 |
555 protected: | 557 protected: |
556 WirelessNetwork(const std::string& service_path, ConnectionType type) | 558 WirelessNetwork(const std::string& service_path, ConnectionType type) |
557 : Network(service_path, type), | 559 : Network(service_path, type), |
558 strength_(0) {} | 560 strength_(0) {} |
559 int strength_; | 561 int strength_; |
560 | 562 |
561 // Network overrides. | 563 // Network overrides. |
562 virtual bool ParseValue(int index, const Value* value); | 564 virtual bool ParseValue(int index, const base::Value* value); |
563 | 565 |
564 private: | 566 private: |
565 void set_strength(int strength) { strength_ = strength; } | 567 void set_strength(int strength) { strength_ = strength; } |
566 | 568 |
567 friend class NetworkLibraryImpl; | 569 friend class NetworkLibraryImpl; |
568 friend class NetworkLibraryStubImpl; | 570 friend class NetworkLibraryStubImpl; |
569 DISALLOW_COPY_AND_ASSIGN(WirelessNetwork); | 571 DISALLOW_COPY_AND_ASSIGN(WirelessNetwork); |
570 }; | 572 }; |
571 | 573 |
572 // Class for networks of TYPE_CELLULAR. | 574 // Class for networks of TYPE_CELLULAR. |
(...skipping 12 matching lines...) Expand all Loading... |
585 struct Apn { | 587 struct Apn { |
586 std::string apn; | 588 std::string apn; |
587 std::string network_id; | 589 std::string network_id; |
588 std::string username; | 590 std::string username; |
589 std::string password; | 591 std::string password; |
590 | 592 |
591 Apn(); | 593 Apn(); |
592 Apn(const std::string& apn, const std::string& network_id, | 594 Apn(const std::string& apn, const std::string& network_id, |
593 const std::string& username, const std::string& password); | 595 const std::string& username, const std::string& password); |
594 ~Apn(); | 596 ~Apn(); |
595 void Set(const DictionaryValue& dict); | 597 void Set(const base::DictionaryValue& dict); |
596 }; | 598 }; |
597 | 599 |
598 explicit CellularNetwork(const std::string& service_path); | 600 explicit CellularNetwork(const std::string& service_path); |
599 virtual ~CellularNetwork(); | 601 virtual ~CellularNetwork(); |
600 | 602 |
601 // Starts device activation process. Returns false if the device state does | 603 // Starts device activation process. Returns false if the device state does |
602 // not permit activation. | 604 // not permit activation. |
603 bool StartActivation() const; | 605 bool StartActivation() const; |
604 // Requests data plans if the network is conencted and activated. | 606 // Requests data plans if the network is conencted and activated. |
605 // Plan data will be passed through Network::Observer::CellularDataPlanChanged | 607 // Plan data will be passed through Network::Observer::CellularDataPlanChanged |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 // Return a string representation of activation state. | 649 // Return a string representation of activation state. |
648 std::string GetActivationStateString() const; | 650 std::string GetActivationStateString() const; |
649 // Return a string representation of roaming state. | 651 // Return a string representation of roaming state. |
650 std::string GetRoamingStateString() const; | 652 std::string GetRoamingStateString() const; |
651 | 653 |
652 // Return a string representation of |activation_state|. | 654 // Return a string representation of |activation_state|. |
653 static std::string ActivationStateToString(ActivationState activation_state); | 655 static std::string ActivationStateToString(ActivationState activation_state); |
654 | 656 |
655 protected: | 657 protected: |
656 // WirelessNetwork overrides. | 658 // WirelessNetwork overrides. |
657 virtual bool ParseValue(int index, const Value* value); | 659 virtual bool ParseValue(int index, const base::Value* value); |
658 | 660 |
659 ActivationState activation_state_; | 661 ActivationState activation_state_; |
660 NetworkTechnology network_technology_; | 662 NetworkTechnology network_technology_; |
661 NetworkRoamingState roaming_state_; | 663 NetworkRoamingState roaming_state_; |
662 // Carrier Info | 664 // Carrier Info |
663 std::string operator_name_; | 665 std::string operator_name_; |
664 std::string operator_code_; | 666 std::string operator_code_; |
665 std::string operator_country_; | 667 std::string operator_country_; |
666 std::string payment_url_; | 668 std::string payment_url_; |
667 std::string usage_url_; | 669 std::string usage_url_; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 | 742 |
741 // Return true if a passphrase or other input is required to connect. | 743 // Return true if a passphrase or other input is required to connect. |
742 bool IsPassphraseRequired() const; | 744 bool IsPassphraseRequired() const; |
743 | 745 |
744 private: | 746 private: |
745 // Network overrides. | 747 // Network overrides. |
746 virtual void EraseCredentials(); | 748 virtual void EraseCredentials(); |
747 virtual void CalculateUniqueId(); | 749 virtual void CalculateUniqueId(); |
748 | 750 |
749 // WirelessNetwork overrides. | 751 // WirelessNetwork overrides. |
750 virtual bool ParseValue(int index, const Value* value); | 752 virtual bool ParseValue(int index, const base::Value* value); |
751 | 753 |
752 void set_encryption(ConnectionSecurity encryption) { | 754 void set_encryption(ConnectionSecurity encryption) { |
753 encryption_ = encryption; | 755 encryption_ = encryption; |
754 } | 756 } |
755 void set_passphrase(const std::string& passphrase) { | 757 void set_passphrase(const std::string& passphrase) { |
756 passphrase_ = passphrase; | 758 passphrase_ = passphrase; |
757 } | 759 } |
758 void set_passphrase_required(bool passphrase_required) { | 760 void set_passphrase_required(bool passphrase_required) { |
759 passphrase_required_ = passphrase_required; | 761 passphrase_required_ = passphrase_required; |
760 } | 762 } |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1234 virtual void SetIPConfig(const NetworkIPConfig& ipconfig) = 0; | 1236 virtual void SetIPConfig(const NetworkIPConfig& ipconfig) = 0; |
1235 | 1237 |
1236 // Factory function, creates a new instance and returns ownership. | 1238 // Factory function, creates a new instance and returns ownership. |
1237 // For normal usage, access the singleton via CrosLibrary::Get(). | 1239 // For normal usage, access the singleton via CrosLibrary::Get(). |
1238 static NetworkLibrary* GetImpl(bool stub); | 1240 static NetworkLibrary* GetImpl(bool stub); |
1239 }; | 1241 }; |
1240 | 1242 |
1241 } // namespace chromeos | 1243 } // namespace chromeos |
1242 | 1244 |
1243 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ | 1245 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ |
OLD | NEW |