OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/wifi/wifi_service.h" | 5 #include "components/wifi/wifi_service.h" |
6 | 6 |
7 #include <iphlpapi.h> | 7 #include <iphlpapi.h> |
8 #include <objbase.h> | 8 #include <objbase.h> |
9 #include <wlanapi.h> | 9 #include <wlanapi.h> |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... | |
28 const char kWiFiServiceErrorNotImplemented[] = | 28 const char kWiFiServiceErrorNotImplemented[] = |
29 "Error.WiFiService.NotImplemented"; | 29 "Error.WiFiService.NotImplemented"; |
30 const wchar_t kNwCategoryWizardRegKey[] = | 30 const wchar_t kNwCategoryWizardRegKey[] = |
31 L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Network\\" | 31 L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Network\\" |
32 L"NwCategoryWizard"; | 32 L"NwCategoryWizard"; |
33 const wchar_t kNwCategoryWizardRegValue[] = L"Show"; | 33 const wchar_t kNwCategoryWizardRegValue[] = L"Show"; |
34 const wchar_t kNwCategoryWizardSavedRegValue[] = L"ShowSaved"; | 34 const wchar_t kNwCategoryWizardSavedRegValue[] = L"ShowSaved"; |
35 const wchar_t kNwCategoryWizardDeleteRegValue[] = L"ShowDelete"; | 35 const wchar_t kNwCategoryWizardDeleteRegValue[] = L"ShowDelete"; |
36 const wchar_t kWlanApiDll[] = L"wlanapi.dll"; | 36 const wchar_t kWlanApiDll[] = L"wlanapi.dll"; |
37 | 37 |
38 // TKIP Profile Dictionary keys | |
39 const char kNetworkGuidKey[] = "guid"; | |
40 const char kProfileXmlKey[] = "profile"; | |
41 const char kSharedProfileKey[] = "shared"; | |
42 | |
38 // WlanApi function names | 43 // WlanApi function names |
39 const char kWlanConnect[] = "WlanConnect"; | 44 const char kWlanConnect[] = "WlanConnect"; |
40 const char kWlanCloseHandle[] = "WlanCloseHandle"; | 45 const char kWlanCloseHandle[] = "WlanCloseHandle"; |
41 const char kWlanDisconnect[] = "WlanDisconnect"; | 46 const char kWlanDisconnect[] = "WlanDisconnect"; |
42 const char kWlanEnumInterfaces[] = "WlanEnumInterfaces"; | 47 const char kWlanEnumInterfaces[] = "WlanEnumInterfaces"; |
43 const char kWlanFreeMemory[] = "WlanFreeMemory"; | 48 const char kWlanFreeMemory[] = "WlanFreeMemory"; |
44 const char kWlanGetAvailableNetworkList[] = "WlanGetAvailableNetworkList"; | 49 const char kWlanGetAvailableNetworkList[] = "WlanGetAvailableNetworkList"; |
45 const char kWlanGetNetworkBssList[] = "WlanGetNetworkBssList"; | 50 const char kWlanGetNetworkBssList[] = "WlanGetNetworkBssList"; |
46 const char kWlanGetProfile[] = "WlanGetProfile"; | 51 const char kWlanGetProfile[] = "WlanGetProfile"; |
47 const char kWlanOpenHandle[] = "WlanOpenHandle"; | 52 const char kWlanOpenHandle[] = "WlanOpenHandle"; |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 // Get unique |network_guid| string based on |wlan|. | 313 // Get unique |network_guid| string based on |wlan|. |
309 std::string GUIDFromWLAN(const WLAN_AVAILABLE_NETWORK& wlan) const { | 314 std::string GUIDFromWLAN(const WLAN_AVAILABLE_NETWORK& wlan) const { |
310 return SSIDFromWLAN(wlan); | 315 return SSIDFromWLAN(wlan); |
311 } | 316 } |
312 | 317 |
313 // Deduce |onc::wifi| security from |alg|. | 318 // Deduce |onc::wifi| security from |alg|. |
314 std::string SecurityFromDot11AuthAlg(DOT11_AUTH_ALGORITHM alg) const; | 319 std::string SecurityFromDot11AuthAlg(DOT11_AUTH_ALGORITHM alg) const; |
315 | 320 |
316 // Deduce WLANProfile |authEncryption| values from |onc::wifi| security. | 321 // Deduce WLANProfile |authEncryption| values from |onc::wifi| security. |
317 bool AuthEncryptionFromSecurity(const std::string& security, | 322 bool AuthEncryptionFromSecurity(const std::string& security, |
323 bool use_default_encryption, | |
tbarzic
2014/03/14 22:34:45
can you pass an enum {TKIP, AES} instead of bool
mef
2014/03/15 13:44:32
Done.
| |
318 std::string* authentication, | 324 std::string* authentication, |
319 std::string* encryption, | 325 std::string* encryption, |
320 std::string* key_type) const; | 326 std::string* key_type) const; |
321 | 327 |
322 // Populate |properties| based on |wlan| and its corresponding bss info from | 328 // Populate |properties| based on |wlan| and its corresponding bss info from |
323 // |wlan_bss_list|. | 329 // |wlan_bss_list|. |
324 void NetworkPropertiesFromAvailableNetwork(const WLAN_AVAILABLE_NETWORK& wlan, | 330 void NetworkPropertiesFromAvailableNetwork(const WLAN_AVAILABLE_NETWORK& wlan, |
325 const WLAN_BSS_LIST& wlan_bss_list, | 331 const WLAN_BSS_LIST& wlan_bss_list, |
326 NetworkProperties* properties); | 332 NetworkProperties* properties); |
327 | 333 |
(...skipping 23 matching lines...) Expand all Loading... | |
351 | 357 |
352 // Get DOT11_BSSID_LIST of desired BSSIDs to connect to |ssid| network on | 358 // Get DOT11_BSSID_LIST of desired BSSIDs to connect to |ssid| network on |
353 // given |frequency|. | 359 // given |frequency|. |
354 DWORD GetDesiredBssList(DOT11_SSID& ssid, | 360 DWORD GetDesiredBssList(DOT11_SSID& ssid, |
355 Frequency frequency, | 361 Frequency frequency, |
356 scoped_ptr<DOT11_BSSID_LIST>* desired_list); | 362 scoped_ptr<DOT11_BSSID_LIST>* desired_list); |
357 | 363 |
358 // Normalizes |frequency_in_mhz| into one of |Frequency| values. | 364 // Normalizes |frequency_in_mhz| into one of |Frequency| values. |
359 Frequency GetNormalizedFrequency(int frequency_in_mhz) const; | 365 Frequency GetNormalizedFrequency(int frequency_in_mhz) const; |
360 | 366 |
361 // Create |profile_xml| based on |network_properties|. | 367 // Create |profile_xml| based on |network_properties|. If |
368 // |use_default_encryption| is true, then profile uses default | |
369 // encryption type (AES), otherwise it uses alternative (TKIP). | |
362 bool CreateProfile(const NetworkProperties& network_properties, | 370 bool CreateProfile(const NetworkProperties& network_properties, |
371 bool use_default_encryption, | |
363 std::string* profile_xml); | 372 std::string* profile_xml); |
364 | 373 |
365 // Save temporary wireless profile for |network_guid|. | 374 // Save temporary wireless profile for |network_guid|. |
366 DWORD SaveTempProfile(const std::string& network_guid); | 375 DWORD SaveTempProfile(const std::string& network_guid); |
367 | 376 |
368 // Get previously stored |profile_xml| for |network_guid|. | 377 // Get previously stored |profile_xml| for |network_guid|. |
369 // If |get_plaintext_key| is true, and process has sufficient privileges, then | 378 // If |get_plaintext_key| is true, and process has sufficient privileges, then |
370 // <sharedKey> data in |profile_xml| will be unprotected. | 379 // <sharedKey> data in |profile_xml| will be unprotected. |
371 DWORD GetProfile(const std::string& network_guid, | 380 DWORD GetProfile(const std::string& network_guid, |
372 bool get_plaintext_key, | 381 bool get_plaintext_key, |
373 std::string* profile_xml); | 382 std::string* profile_xml); |
374 | 383 |
384 // Set |profile_xml| to current user or all users depending on |shared| flag. | |
385 // If |overwrite| is false, then returns an error if profile exists. | |
386 DWORD SetProfile(bool shared, const std::string& profile_xml, bool overwrite); | |
387 | |
375 // Return true if there is previously stored profile xml for |network_guid|. | 388 // Return true if there is previously stored profile xml for |network_guid|. |
376 bool HaveProfile(const std::string& network_guid); | 389 bool HaveProfile(const std::string& network_guid); |
377 | 390 |
378 // Notify |network_list_changed_observer_| that list of visible networks has | 391 // Notify |network_list_changed_observer_| that list of visible networks has |
379 // changed to |networks|. | 392 // changed to |networks|. |
380 void NotifyNetworkListChanged(const NetworkList& networks); | 393 void NotifyNetworkListChanged(const NetworkList& networks); |
381 | 394 |
382 // Notify |networks_changed_observer_| that network |network_guid| status has | 395 // Notify |networks_changed_observer_| that network |network_guid| status has |
383 // changed. | 396 // changed. |
384 void NotifyNetworkChanged(const std::string& network_guid); | 397 void NotifyNetworkChanged(const std::string& network_guid); |
(...skipping 23 matching lines...) Expand all Loading... | |
408 // WLAN service handle. | 421 // WLAN service handle. |
409 HANDLE client_; | 422 HANDLE client_; |
410 // GUID of the currently connected interface, if any, otherwise the GUID of | 423 // GUID of the currently connected interface, if any, otherwise the GUID of |
411 // one of the WLAN interfaces. | 424 // one of the WLAN interfaces. |
412 GUID interface_guid_; | 425 GUID interface_guid_; |
413 // Temporary storage of network properties indexed by |network_guid|. Persist | 426 // Temporary storage of network properties indexed by |network_guid|. Persist |
414 // only in memory. | 427 // only in memory. |
415 base::DictionaryValue connect_properties_; | 428 base::DictionaryValue connect_properties_; |
416 // Preserved WLAN profile xml. | 429 // Preserved WLAN profile xml. |
417 std::map<std::string, std::string> saved_profiles_xml_; | 430 std::map<std::string, std::string> saved_profiles_xml_; |
431 // WLAN profile xml with TKIP encryption type saved by |CreateNetwork|. | |
432 base::DictionaryValue tkip_profile_; | |
418 // Observer to get notified when network(s) have changed (e.g. connect). | 433 // Observer to get notified when network(s) have changed (e.g. connect). |
419 NetworkGuidListCallback networks_changed_observer_; | 434 NetworkGuidListCallback networks_changed_observer_; |
420 // Observer to get notified when network list has changed (scan complete). | 435 // Observer to get notified when network list has changed (scan complete). |
421 NetworkGuidListCallback network_list_changed_observer_; | 436 NetworkGuidListCallback network_list_changed_observer_; |
422 // Saved value of network location wizard show value. | 437 // Saved value of network location wizard show value. |
423 scoped_ptr<DWORD> saved_nw_category_wizard_; | 438 scoped_ptr<DWORD> saved_nw_category_wizard_; |
424 // MessageLoopProxy to post events on UI thread. | 439 // MessageLoopProxy to post events on UI thread. |
425 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; | 440 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; |
426 // Task runner for worker tasks. | 441 // Task runner for worker tasks. |
427 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 442 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
512 DCHECK(properties.get()); | 527 DCHECK(properties.get()); |
513 if (!properties->HasKey(onc::network_type::kWiFi)) { | 528 if (!properties->HasKey(onc::network_type::kWiFi)) { |
514 DVLOG(0) << "Missing WiFi properties:" << *properties; | 529 DVLOG(0) << "Missing WiFi properties:" << *properties; |
515 *error = kWiFiServiceError; | 530 *error = kWiFiServiceError; |
516 return; | 531 return; |
517 } | 532 } |
518 connect_properties_.SetWithoutPathExpansion(network_guid, | 533 connect_properties_.SetWithoutPathExpansion(network_guid, |
519 properties.release()); | 534 properties.release()); |
520 } | 535 } |
521 | 536 |
537 DWORD WiFiServiceImpl::SetProfile(bool shared, | |
538 const std::string& profile_xml, | |
539 bool overwrite) { | |
540 DWORD error_code = ERROR_SUCCESS; | |
541 | |
542 base::string16 profile_xml16(base::UTF8ToUTF16(profile_xml)); | |
543 DWORD reason_code = 0u; | |
544 | |
545 error_code = WlanSetProfile_function_(client_, | |
546 &interface_guid_, | |
547 shared ? 0 : WLAN_PROFILE_USER, | |
548 profile_xml16.c_str(), | |
549 NULL, | |
550 overwrite, | |
551 NULL, | |
552 &reason_code); | |
553 return error_code; | |
554 } | |
555 | |
522 void WiFiServiceImpl::CreateNetwork( | 556 void WiFiServiceImpl::CreateNetwork( |
523 bool shared, | 557 bool shared, |
524 scoped_ptr<base::DictionaryValue> properties, | 558 scoped_ptr<base::DictionaryValue> properties, |
525 std::string* network_guid, | 559 std::string* network_guid, |
526 std::string* error) { | 560 std::string* error) { |
527 DWORD error_code = EnsureInitialized(); | 561 DWORD error_code = EnsureInitialized(); |
528 if (CheckError(error_code, kWiFiServiceError, error)) | 562 if (CheckError(error_code, kWiFiServiceError, error)) |
529 return; | 563 return; |
530 | 564 |
531 WiFiService::NetworkProperties network_properties; | 565 WiFiService::NetworkProperties network_properties; |
532 if (!network_properties.UpdateFromValue(*properties)) { | 566 if (!network_properties.UpdateFromValue(*properties)) { |
533 CheckError(ERROR_INVALID_DATA, kWiFiServiceError, error); | 567 CheckError(ERROR_INVALID_DATA, kWiFiServiceError, error); |
534 return; | 568 return; |
535 } | 569 } |
536 | 570 |
537 network_properties.guid = network_properties.ssid; | 571 network_properties.guid = network_properties.ssid; |
538 std::string profile_xml; | 572 std::string profile_xml; |
539 if (!CreateProfile(network_properties, &profile_xml)) { | 573 if (!CreateProfile(network_properties, true, &profile_xml)) { |
540 CheckError(ERROR_INVALID_DATA, kWiFiServiceError, error); | 574 CheckError(ERROR_INVALID_DATA, kWiFiServiceError, error); |
541 return; | 575 return; |
542 } | 576 } |
543 | 577 |
544 base::string16 profile_xml16(base::UTF8ToUTF16(profile_xml)); | 578 error_code = SetProfile(shared, profile_xml, false); |
545 DWORD reason_code = 0u; | |
546 | |
547 error_code = WlanSetProfile_function_(client_, | |
548 &interface_guid_, | |
549 shared ? 0 : WLAN_PROFILE_USER, | |
550 profile_xml16.c_str(), | |
551 NULL, | |
552 FALSE, | |
553 NULL, | |
554 &reason_code); | |
555 if (CheckError(error_code, kWiFiServiceError, error)) { | 579 if (CheckError(error_code, kWiFiServiceError, error)) { |
556 DVLOG(0) << profile_xml; | 580 DVLOG(0) << profile_xml; |
557 DVLOG(0) << "SetProfile Reason Code:" << reason_code; | |
558 return; | 581 return; |
559 } | 582 } |
560 | 583 |
584 // WAP and WAP2 networks could use either AES or TKIP encryption type. | |
585 // Preserve alternative profile to use in case if connection with default | |
586 // encryption type fails. | |
587 std::string tkip_profile_xml; | |
588 if (!CreateProfile(network_properties, false, &tkip_profile_xml)) { | |
589 CheckError(ERROR_INVALID_DATA, kWiFiServiceError, error); | |
590 return; | |
591 } | |
592 | |
593 if (tkip_profile_xml != profile_xml) { | |
594 tkip_profile_.SetString(kNetworkGuidKey, network_properties.guid); | |
tbarzic
2014/03/14 22:34:45
Should tkip_profile be saved be per network_guid?
mef
2014/03/15 13:44:32
Done.
| |
595 tkip_profile_.SetString(kProfileXmlKey, tkip_profile_xml); | |
596 tkip_profile_.SetBoolean(kSharedProfileKey, shared); | |
597 } | |
598 | |
561 *network_guid = network_properties.guid; | 599 *network_guid = network_properties.guid; |
562 } | 600 } |
563 | 601 |
564 void WiFiServiceImpl::GetVisibleNetworks(const std::string& network_type, | 602 void WiFiServiceImpl::GetVisibleNetworks(const std::string& network_type, |
565 base::ListValue* network_list) { | 603 base::ListValue* network_list) { |
566 if (!network_type.empty() && | 604 if (!network_type.empty() && |
567 network_type != onc::network_type::kAllTypes && | 605 network_type != onc::network_type::kAllTypes && |
568 network_type != onc::network_type::kWiFi) { | 606 network_type != onc::network_type::kWiFi) { |
569 return; | 607 return; |
570 } | 608 } |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
774 NotifyNetworkListChanged(networks); | 812 NotifyNetworkListChanged(networks); |
775 } | 813 } |
776 | 814 |
777 void WiFiServiceImpl::WaitForNetworkConnect(const std::string& network_guid, | 815 void WiFiServiceImpl::WaitForNetworkConnect(const std::string& network_guid, |
778 int attempt) { | 816 int attempt) { |
779 // If network didn't get connected in |kMaxAttempts|, then restore automatic | 817 // If network didn't get connected in |kMaxAttempts|, then restore automatic |
780 // network change notifications and stop waiting. | 818 // network change notifications and stop waiting. |
781 if (attempt > kMaxAttempts) { | 819 if (attempt > kMaxAttempts) { |
782 DLOG(ERROR) << kMaxAttempts << " attempts exceeded waiting for connect to " | 820 DLOG(ERROR) << kMaxAttempts << " attempts exceeded waiting for connect to " |
783 << network_guid; | 821 << network_guid; |
784 enable_notify_network_changed_ = true; | 822 |
785 RestoreNwCategoryWizard(); | 823 // Check, if there is alternative TKIP profile that should be tried. |
824 // If there is, then set it up and try to connect again. | |
825 if (!tkip_profile_.empty()) { | |
826 std::string tkip_network_guid; | |
827 std::string tkip_profile_xml; | |
828 bool shared = false; | |
829 if (tkip_profile_.GetString(kNetworkGuidKey, &tkip_network_guid) && | |
830 tkip_profile_.GetString(kProfileXmlKey, &tkip_profile_xml) && | |
831 tkip_profile_.GetBoolean(kSharedProfileKey, &shared) && | |
832 tkip_network_guid == network_guid) { | |
833 DWORD error_code = SetProfile(shared, tkip_profile_xml, true); | |
834 if (error_code == ERROR_SUCCESS) { | |
835 // Try to connect with new profile. | |
836 error_code = Connect(network_guid, kFrequencyAny); | |
tbarzic
2014/03/14 22:34:45
original connect request may have had the frequenc
mef
2014/03/15 13:44:32
Done.
| |
837 if (error_code == ERROR_SUCCESS) | |
838 WaitForNetworkConnect(network_guid, 0); | |
839 } | |
840 } | |
841 tkip_profile_.Clear(); | |
842 } else { | |
843 enable_notify_network_changed_ = true; | |
844 RestoreNwCategoryWizard(); | |
845 } | |
786 return; | 846 return; |
787 } | 847 } |
788 std::string connected_network_guid; | 848 std::string connected_network_guid; |
789 DWORD error = FindConnectedNetwork(&connected_network_guid); | 849 DWORD error = FindConnectedNetwork(&connected_network_guid); |
790 if (network_guid == connected_network_guid) { | 850 if (network_guid == connected_network_guid) { |
791 DVLOG(1) << "WiFi Connected, Reset DHCP: " << network_guid; | 851 DVLOG(1) << "WiFi Connected, Reset DHCP: " << network_guid; |
792 // Even though wireless network is now connected, it may still be unusable, | 852 // Even though wireless network is now connected, it may still be unusable, |
793 // e.g. after Chromecast device reset. Reset DHCP on wireless network to | 853 // e.g. after Chromecast device reset. Reset DHCP on wireless network to |
794 // work around this issue. | 854 // work around this issue. |
795 error = ResetDHCP(); | 855 error = ResetDHCP(); |
856 // There is no need to keep TKIP profile as network is connected. | |
857 tkip_profile_.Clear(); | |
796 // Restore previously suppressed notifications. | 858 // Restore previously suppressed notifications. |
797 enable_notify_network_changed_ = true; | 859 enable_notify_network_changed_ = true; |
798 RestoreNwCategoryWizard(); | 860 RestoreNwCategoryWizard(); |
799 NotifyNetworkChanged(network_guid); | 861 NotifyNetworkChanged(network_guid); |
800 } else { | 862 } else { |
801 // Continue waiting for network connection state change. | 863 // Continue waiting for network connection state change. |
802 task_runner_->PostDelayedTask( | 864 task_runner_->PostDelayedTask( |
803 FROM_HERE, | 865 FROM_HERE, |
804 base::Bind(&WiFiServiceImpl::WaitForNetworkConnect, | 866 base::Bind(&WiFiServiceImpl::WaitForNetworkConnect, |
805 base::Unretained(this), | 867 base::Unretained(this), |
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1550 } | 1612 } |
1551 | 1613 |
1552 bool WiFiServiceImpl::HaveProfile(const std::string& network_guid) { | 1614 bool WiFiServiceImpl::HaveProfile(const std::string& network_guid) { |
1553 DWORD error = ERROR_SUCCESS; | 1615 DWORD error = ERROR_SUCCESS; |
1554 std::string profile_xml; | 1616 std::string profile_xml; |
1555 return GetProfile(network_guid, false, &profile_xml) == ERROR_SUCCESS; | 1617 return GetProfile(network_guid, false, &profile_xml) == ERROR_SUCCESS; |
1556 } | 1618 } |
1557 | 1619 |
1558 bool WiFiServiceImpl::AuthEncryptionFromSecurity( | 1620 bool WiFiServiceImpl::AuthEncryptionFromSecurity( |
1559 const std::string& security, | 1621 const std::string& security, |
1622 bool use_default_encryption, | |
1560 std::string* authentication, | 1623 std::string* authentication, |
1561 std::string* encryption, | 1624 std::string* encryption, |
1562 std::string* key_type) const { | 1625 std::string* key_type) const { |
1563 if (security == onc::wifi::kNone) { | 1626 if (security == onc::wifi::kNone) { |
1564 *authentication = kAuthenticationOpen; | 1627 *authentication = kAuthenticationOpen; |
1565 *encryption = kEncryptionNone; | 1628 *encryption = kEncryptionNone; |
1566 } else if (security == onc::wifi::kWEP_PSK) { | 1629 } else if (security == onc::wifi::kWEP_PSK) { |
1567 *authentication = kAuthenticationOpen; | 1630 *authentication = kAuthenticationOpen; |
1568 *encryption = kEncryptionWEP; | 1631 *encryption = kEncryptionWEP; |
1569 *key_type = kKeyTypeNetwork; | 1632 *key_type = kKeyTypeNetwork; |
1570 } else if (security == onc::wifi::kWPA_PSK) { | 1633 } else if (security == onc::wifi::kWPA_PSK) { |
1571 *authentication = kAuthenticationWpaPsk; | 1634 *authentication = kAuthenticationWpaPsk; |
1572 // TODO(mef): WAP |encryption| could be either |AES| or |TKIP|. It has to be | 1635 *encryption = use_default_encryption ? kEncryptionAES : kEncryptionTKIP; |
1573 // determined and adjusted properly during |Connect|. | |
1574 *encryption = kEncryptionAES; | |
1575 *key_type = kKeyTypePassphrase; | 1636 *key_type = kKeyTypePassphrase; |
1576 } else if (security == onc::wifi::kWPA2_PSK) { | 1637 } else if (security == onc::wifi::kWPA2_PSK) { |
1577 *authentication = kAuthenticationWpa2Psk; | 1638 *authentication = kAuthenticationWpa2Psk; |
1578 // TODO(mef): WAP |encryption| could be either |AES| or |TKIP|. It has to be | 1639 *encryption = use_default_encryption ? kEncryptionAES : kEncryptionTKIP; |
1579 // determined and adjusted properly during |Connect|. | |
1580 *encryption = kEncryptionAES; | |
1581 *key_type = kKeyTypePassphrase; | 1640 *key_type = kKeyTypePassphrase; |
1582 } else { | 1641 } else { |
1583 return false; | 1642 return false; |
1584 } | 1643 } |
1585 return true; | 1644 return true; |
1586 } | 1645 } |
1587 | 1646 |
1588 bool WiFiServiceImpl::CreateProfile( | 1647 bool WiFiServiceImpl::CreateProfile( |
1589 const NetworkProperties& network_properties, | 1648 const NetworkProperties& network_properties, |
1649 bool use_default_encryption, | |
1590 std::string* profile_xml) { | 1650 std::string* profile_xml) { |
1591 // Get authentication and encryption values from security. | 1651 // Get authentication and encryption values from security. |
1592 std::string authentication; | 1652 std::string authentication; |
1593 std::string encryption; | 1653 std::string encryption; |
1594 std::string key_type; | 1654 std::string key_type; |
1595 bool valid = AuthEncryptionFromSecurity(network_properties.security, | 1655 bool valid = AuthEncryptionFromSecurity(network_properties.security, |
1656 use_default_encryption, | |
1596 &authentication, | 1657 &authentication, |
1597 &encryption, | 1658 &encryption, |
1598 &key_type); | 1659 &key_type); |
1599 if (!valid) | 1660 if (!valid) |
1600 return valid; | 1661 return valid; |
1601 | 1662 |
1602 // Generate profile XML. | 1663 // Generate profile XML. |
1603 XmlWriter xml_writer; | 1664 XmlWriter xml_writer; |
1604 xml_writer.StartWriting(); | 1665 xml_writer.StartWriting(); |
1605 xml_writer.StartElement("WLANProfile"); | 1666 xml_writer.StartElement("WLANProfile"); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1659 NetworkGuidList changed_networks(1, network_guid); | 1720 NetworkGuidList changed_networks(1, network_guid); |
1660 message_loop_proxy_->PostTask( | 1721 message_loop_proxy_->PostTask( |
1661 FROM_HERE, | 1722 FROM_HERE, |
1662 base::Bind(networks_changed_observer_, changed_networks)); | 1723 base::Bind(networks_changed_observer_, changed_networks)); |
1663 } | 1724 } |
1664 } | 1725 } |
1665 | 1726 |
1666 WiFiService* WiFiService::Create() { return new WiFiServiceImpl(); } | 1727 WiFiService* WiFiService::Create() { return new WiFiServiceImpl(); } |
1667 | 1728 |
1668 } // namespace wifi | 1729 } // namespace wifi |
OLD | NEW |