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> |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 bool notify_failure() const { return notify_failure_; } | 320 bool notify_failure() const { return notify_failure_; } |
321 const std::string& profile_path() const { return profile_path_; } | 321 const std::string& profile_path() const { return profile_path_; } |
322 NetworkProfileType profile_type() const { return profile_type_; } | 322 NetworkProfileType profile_type() const { return profile_type_; } |
323 | 323 |
324 const std::string& unique_id() const { return unique_id_; } | 324 const std::string& unique_id() const { return unique_id_; } |
325 | 325 |
326 void set_notify_failure(bool state) { notify_failure_ = state; } | 326 void set_notify_failure(bool state) { notify_failure_ = state; } |
327 | 327 |
328 // We don't have a setter for |favorite_| because to unfavorite a network is | 328 // We don't have a setter for |favorite_| because to unfavorite a network is |
329 // equivalent to forget a network, so we call forget network on cros for | 329 // equivalent to forget a network, so we call forget network on cros for |
330 // that. See ForgetWifiNetwork(). | 330 // that. See ForgetNetwork(). |
331 | 331 |
332 void SetAutoConnect(bool auto_connect); | 332 void SetAutoConnect(bool auto_connect); |
333 | 333 |
334 void SetName(const std::string& name); | 334 void SetName(const std::string& name); |
335 | 335 |
336 void SetSaveCredentials(bool save_credentials); | 336 void SetSaveCredentials(bool save_credentials); |
337 | 337 |
338 // Return a string representation of the state code. | 338 // Return a string representation of the state code. |
339 std::string GetStateString() const; | 339 std::string GetStateString() const; |
340 | 340 |
341 // Return a string representation of the error code. | 341 // Return a string representation of the error code. |
342 std::string GetErrorString() const; | 342 std::string GetErrorString() const; |
343 | 343 |
344 // Return true if the network must be in the user profile (e.g. has certs). | 344 // Return true if the network must be in the user profile (e.g. has certs). |
345 virtual bool RequiresUserProfile() const; | 345 virtual bool RequiresUserProfile() const; |
346 | 346 |
| 347 // Copy any credentials from a remembered network that are unset in |this|. |
| 348 virtual void CopyCredentialsFromRemembered(Network* remembered); |
| 349 |
347 // Static helper function. | 350 // Static helper function. |
348 static bool IsConnectingState(ConnectionState state) { | 351 static bool IsConnectingState(ConnectionState state) { |
349 return (state == STATE_ASSOCIATION || | 352 return (state == STATE_ASSOCIATION || |
350 state == STATE_CONFIGURATION || | 353 state == STATE_CONFIGURATION || |
351 state == STATE_CARRIER); | 354 state == STATE_CARRIER); |
352 } | 355 } |
353 | 356 |
354 // Sends the well-known TPM PIN to flimflam via D-Bus, because flimflam may | 357 // Sends the well-known TPM PIN to flimflam via D-Bus, because flimflam may |
355 // need it to access client certificates in the TPM for 802.1X, VPN, etc. | 358 // need it to access client certificates in the TPM for 802.1X, VPN, etc. |
356 void SendTpmPin(const std::string& tpm_pin); | 359 void SendTpmPin(const std::string& tpm_pin); |
357 | 360 |
358 protected: | 361 protected: |
359 Network(const std::string& service_path, ConnectionType type); | 362 Network(const std::string& service_path, ConnectionType type); |
360 | 363 |
361 // Parse name/value pairs from libcros. | 364 // Parse name/value pairs from libcros. |
362 virtual bool ParseValue(int index, const Value* value); | 365 virtual bool ParseValue(int index, const Value* value); |
363 virtual void ParseInfo(const DictionaryValue* info); | 366 virtual void ParseInfo(const DictionaryValue* info); |
364 | 367 |
365 // Erase cached credentials, used when "Save password" is unchecked. | 368 // Erase cached credentials, used when "Save password" is unchecked. |
366 virtual void EraseCredentials(); | 369 virtual void EraseCredentials(); |
367 | 370 |
| 371 // Calculate a unique identifier for the network. |
| 372 virtual void CalculateUniqueId(); |
| 373 |
368 // Methods to asynchronously set network service properties | 374 // Methods to asynchronously set network service properties |
369 virtual void SetStringProperty(const char* prop, const std::string& str, | 375 virtual void SetStringProperty(const char* prop, const std::string& str, |
370 std::string* dest); | 376 std::string* dest); |
371 virtual void SetBooleanProperty(const char* prop, bool b, bool* dest); | 377 virtual void SetBooleanProperty(const char* prop, bool b, bool* dest); |
372 virtual void SetIntegerProperty(const char* prop, int i, int* dest); | 378 virtual void SetIntegerProperty(const char* prop, int i, int* dest); |
373 virtual void SetValueProperty(const char* prop, Value* val); | 379 virtual void SetValueProperty(const char* prop, Value* val); |
374 virtual void ClearProperty(const char* prop); | 380 virtual void ClearProperty(const char* prop); |
375 | 381 |
376 // This will clear the property if string is empty. Otherwise, it will set it. | 382 // This will clear the property if string is empty. Otherwise, it will set it. |
377 virtual void SetOrClearStringProperty(const char* prop, | 383 virtual void SetOrClearStringProperty(const char* prop, |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 const std::string& server_hostname() const { return server_hostname_; } | 478 const std::string& server_hostname() const { return server_hostname_; } |
473 ProviderType provider_type() const { return provider_type_; } | 479 ProviderType provider_type() const { return provider_type_; } |
474 const std::string& ca_cert_nss() const { return ca_cert_nss_; } | 480 const std::string& ca_cert_nss() const { return ca_cert_nss_; } |
475 const std::string& psk_passphrase() const { return psk_passphrase_; } | 481 const std::string& psk_passphrase() const { return psk_passphrase_; } |
476 const std::string& client_cert_id() const { return client_cert_id_; } | 482 const std::string& client_cert_id() const { return client_cert_id_; } |
477 const std::string& username() const { return username_; } | 483 const std::string& username() const { return username_; } |
478 const std::string& user_passphrase() const { return user_passphrase_; } | 484 const std::string& user_passphrase() const { return user_passphrase_; } |
479 | 485 |
480 // Network overrides. | 486 // Network overrides. |
481 virtual bool RequiresUserProfile() const; | 487 virtual bool RequiresUserProfile() const; |
| 488 virtual void CopyCredentialsFromRemembered(Network* remembered); |
482 | 489 |
483 // Public getters. | 490 // Public getters. |
484 bool NeedMoreInfoToConnect() const; | 491 bool NeedMoreInfoToConnect() const; |
485 std::string GetProviderTypeString() const; | 492 std::string GetProviderTypeString() const; |
486 | 493 |
487 // Public setters. | 494 // Public setters. |
488 void SetCACertNSS(const std::string& ca_cert_nss); | 495 void SetCACertNSS(const std::string& ca_cert_nss); |
489 void SetPSKPassphrase(const std::string& psk_passphrase); | 496 void SetPSKPassphrase(const std::string& psk_passphrase); |
490 void SetClientCertID(const std::string& cert_id); | 497 void SetClientCertID(const std::string& cert_id); |
491 void SetUsername(const std::string& username); | 498 void SetUsername(const std::string& username); |
492 void SetUserPassphrase(const std::string& user_passphrase); | 499 void SetUserPassphrase(const std::string& user_passphrase); |
493 | 500 |
494 private: | 501 private: |
495 // Network overrides. | 502 // Network overrides. |
496 virtual bool ParseValue(int index, const Value* value); | 503 virtual bool ParseValue(int index, const Value* value); |
497 virtual void ParseInfo(const DictionaryValue* info); | 504 virtual void ParseInfo(const DictionaryValue* info); |
498 virtual void EraseCredentials(); | 505 virtual void EraseCredentials(); |
| 506 virtual void CalculateUniqueId(); |
499 | 507 |
500 // VirtualNetwork private methods. | 508 // VirtualNetwork private methods. |
501 bool ParseProviderValue(int index, const Value* value); | 509 bool ParseProviderValue(int index, const Value* value); |
502 | 510 |
503 void set_server_hostname(const std::string& server_hostname) { | 511 void set_server_hostname(const std::string& server_hostname) { |
504 server_hostname_ = server_hostname; | 512 server_hostname_ = server_hostname; |
505 } | 513 } |
506 void set_provider_type(ProviderType provider_type) { | 514 void set_provider_type(ProviderType provider_type) { |
507 provider_type_ = provider_type; | 515 provider_type_ = provider_type; |
508 } | 516 } |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 // Return a string representation of the encryption code. | 731 // Return a string representation of the encryption code. |
724 // This not translated and should be only used for debugging purposes. | 732 // This not translated and should be only used for debugging purposes. |
725 std::string GetEncryptionString() const; | 733 std::string GetEncryptionString() const; |
726 | 734 |
727 // Return true if a passphrase or other input is required to connect. | 735 // Return true if a passphrase or other input is required to connect. |
728 bool IsPassphraseRequired() const; | 736 bool IsPassphraseRequired() const; |
729 | 737 |
730 private: | 738 private: |
731 // Network overrides. | 739 // Network overrides. |
732 virtual void EraseCredentials(); | 740 virtual void EraseCredentials(); |
| 741 virtual void CalculateUniqueId(); |
733 | 742 |
734 // WirelessNetwork overrides. | 743 // WirelessNetwork overrides. |
735 virtual bool ParseValue(int index, const Value* value); | 744 virtual bool ParseValue(int index, const Value* value); |
736 virtual void ParseInfo(const DictionaryValue* info); | |
737 | |
738 void CalculateUniqueId(); | |
739 | 745 |
740 void set_encryption(ConnectionSecurity encryption) { | 746 void set_encryption(ConnectionSecurity encryption) { |
741 encryption_ = encryption; | 747 encryption_ = encryption; |
742 } | 748 } |
743 void set_passphrase(const std::string& passphrase) { | 749 void set_passphrase(const std::string& passphrase) { |
744 passphrase_ = passphrase; | 750 passphrase_ = passphrase; |
745 } | 751 } |
746 void set_passphrase_required(bool passphrase_required) { | 752 void set_passphrase_required(bool passphrase_required) { |
747 passphrase_required_ = passphrase_required; | 753 passphrase_required_ = passphrase_required; |
748 } | 754 } |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1005 | 1011 |
1006 // Returns the list of remembered wifi networks. | 1012 // Returns the list of remembered wifi networks. |
1007 virtual const WifiNetworkVector& remembered_wifi_networks() const = 0; | 1013 virtual const WifiNetworkVector& remembered_wifi_networks() const = 0; |
1008 | 1014 |
1009 // Returns the current list of cellular networks. | 1015 // Returns the current list of cellular networks. |
1010 virtual const CellularNetworkVector& cellular_networks() const = 0; | 1016 virtual const CellularNetworkVector& cellular_networks() const = 0; |
1011 | 1017 |
1012 // Returns the current list of virtual networks. | 1018 // Returns the current list of virtual networks. |
1013 virtual const VirtualNetworkVector& virtual_networks() const = 0; | 1019 virtual const VirtualNetworkVector& virtual_networks() const = 0; |
1014 | 1020 |
| 1021 // Returns the current list of virtual networks. |
| 1022 virtual const VirtualNetworkVector& remembered_virtual_networks() const = 0; |
| 1023 |
1015 // Return a pointer to the device, if it exists, or NULL. | 1024 // Return a pointer to the device, if it exists, or NULL. |
1016 virtual const NetworkDevice* FindNetworkDeviceByPath( | 1025 virtual const NetworkDevice* FindNetworkDeviceByPath( |
1017 const std::string& path) const = 0; | 1026 const std::string& path) const = 0; |
1018 | 1027 |
1019 // Returns device with TYPE_CELLULAR. Returns NULL if none exists. | 1028 // Returns device with TYPE_CELLULAR. Returns NULL if none exists. |
1020 virtual const NetworkDevice* FindCellularDevice() const = 0; | 1029 virtual const NetworkDevice* FindCellularDevice() const = 0; |
1021 | 1030 |
1022 // Returns device with TYPE_ETHERNET. Returns NULL if none exists. | 1031 // Returns device with TYPE_ETHERNET. Returns NULL if none exists. |
1023 virtual const NetworkDevice* FindEthernetDevice() const = 0; | 1032 virtual const NetworkDevice* FindEthernetDevice() const = 0; |
1024 | 1033 |
1025 // Returns device with TYPE_WIFI. Returns NULL if none exists. | 1034 // Returns device with TYPE_WIFI. Returns NULL if none exists. |
1026 virtual const NetworkDevice* FindWifiDevice() const = 0; | 1035 virtual const NetworkDevice* FindWifiDevice() const = 0; |
1027 | 1036 |
1028 // Return a pointer to the network, if it exists, or NULL. | 1037 // Return a pointer to the network, if it exists, or NULL. |
1029 // NOTE: Never store these results, store service paths instead. | 1038 // NOTE: Never store these results, store service paths instead. |
1030 // The pattern for doing an operation on a Network is: | 1039 // The pattern for doing an operation on a Network is: |
1031 // Network* network = cros->FindNetworkByPath(service_path); | 1040 // Network* network = cros->FindNetworkByPath(service_path); |
1032 // network->SetFoo(); | 1041 // network->SetFoo(); |
1033 // network->Connect(); | 1042 // network->Connect(); |
1034 // As long as this is done in sequence on the UI thread it will be safe; | 1043 // As long as this is done in sequence on the UI thread it will be safe; |
1035 // the network list only gets updated on the UI thread. | 1044 // the network list only gets updated on the UI thread. |
1036 virtual Network* FindNetworkByPath(const std::string& path) const = 0; | 1045 virtual Network* FindNetworkByPath(const std::string& path) const = 0; |
1037 virtual WifiNetwork* FindWifiNetworkByPath(const std::string& path) const = 0; | 1046 virtual WifiNetwork* FindWifiNetworkByPath(const std::string& path) const = 0; |
1038 virtual CellularNetwork* FindCellularNetworkByPath( | 1047 virtual CellularNetwork* FindCellularNetworkByPath( |
1039 const std::string& path) const = 0; | 1048 const std::string& path) const = 0; |
1040 virtual VirtualNetwork* FindVirtualNetworkByPath( | 1049 virtual VirtualNetwork* FindVirtualNetworkByPath( |
1041 const std::string& path) const = 0; | 1050 const std::string& path) const = 0; |
1042 | 1051 |
1043 // Returns the visible wifi network corresponding to the remembered | 1052 // Returns the visible network corresponding to the remembered network, |
1044 // wifi network, or NULL if the remembered network is not visible. | 1053 // or NULL if the remembered network is not visible. |
1045 virtual Network* FindNetworkFromRemembered( | 1054 virtual Network* FindNetworkFromRemembered( |
1046 const Network* remembered) const = 0; | 1055 const Network* remembered) const = 0; |
1047 | 1056 |
1048 // Return a pointer to the remembered network, if it exists, or NULL. | 1057 // Return a pointer to the remembered network, if it exists, or NULL. |
1049 virtual Network* FindRememberedNetworkByPath( | 1058 virtual Network* FindRememberedNetworkByPath( |
1050 const std::string& path) const = 0; | 1059 const std::string& path) const = 0; |
1051 | 1060 |
1052 // Retrieves the data plans associated with |path|, NULL if there are no | 1061 // Retrieves the data plans associated with |path|, NULL if there are no |
1053 // associated plans. | 1062 // associated plans. |
1054 virtual const CellularDataPlanVector* GetDataPlans( | 1063 virtual const CellularDataPlanVector* GetDataPlans( |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1155 const std::string& service_name, | 1164 const std::string& service_name, |
1156 const std::string& server_hostname, | 1165 const std::string& server_hostname, |
1157 const std::string& server_ca_cert_nss_nickname, | 1166 const std::string& server_ca_cert_nss_nickname, |
1158 const std::string& client_cert_pkcs11_id, | 1167 const std::string& client_cert_pkcs11_id, |
1159 const std::string& username, | 1168 const std::string& username, |
1160 const std::string& user_passphrase) = 0; | 1169 const std::string& user_passphrase) = 0; |
1161 | 1170 |
1162 // Disconnect from the specified network. | 1171 // Disconnect from the specified network. |
1163 virtual void DisconnectFromNetwork(const Network* network) = 0; | 1172 virtual void DisconnectFromNetwork(const Network* network) = 0; |
1164 | 1173 |
1165 // Forget the wifi network corresponding to service_path. | 1174 // Forget the network corresponding to service_path. |
1166 virtual void ForgetWifiNetwork(const std::string& service_path) = 0; | 1175 virtual void ForgetNetwork(const std::string& service_path) = 0; |
1167 | 1176 |
1168 // Move the network to the shared/global profile. | 1177 // Move the network to the shared/global profile. |
1169 virtual void SetNetworkProfile(const std::string& service_path, | 1178 virtual void SetNetworkProfile(const std::string& service_path, |
1170 NetworkProfileType type) = 0; | 1179 NetworkProfileType type) = 0; |
1171 | 1180 |
1172 // Returns home carrier ID if available, otherwise empty string is returned. | 1181 // Returns home carrier ID if available, otherwise empty string is returned. |
1173 // Carrier ID format: <carrier name> (country). Ex.: "Verizon (us)". | 1182 // Carrier ID format: <carrier name> (country). Ex.: "Verizon (us)". |
1174 virtual std::string GetCellularHomeCarrierId() const = 0; | 1183 virtual std::string GetCellularHomeCarrierId() const = 0; |
1175 | 1184 |
1176 virtual bool ethernet_available() const = 0; | 1185 virtual bool ethernet_available() const = 0; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1215 virtual void SetIPConfig(const NetworkIPConfig& ipconfig) = 0; | 1224 virtual void SetIPConfig(const NetworkIPConfig& ipconfig) = 0; |
1216 | 1225 |
1217 // Factory function, creates a new instance and returns ownership. | 1226 // Factory function, creates a new instance and returns ownership. |
1218 // For normal usage, access the singleton via CrosLibrary::Get(). | 1227 // For normal usage, access the singleton via CrosLibrary::Get(). |
1219 static NetworkLibrary* GetImpl(bool stub); | 1228 static NetworkLibrary* GetImpl(bool stub); |
1220 }; | 1229 }; |
1221 | 1230 |
1222 } // namespace chromeos | 1231 } // namespace chromeos |
1223 | 1232 |
1224 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ | 1233 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ |
OLD | NEW |