| 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 <stddef.h> | 9 #include <stddef.h> |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 | 191 |
| 192 void GetManagedProperties(const std::string& network_guid, | 192 void GetManagedProperties(const std::string& network_guid, |
| 193 base::DictionaryValue* managed_properties, | 193 base::DictionaryValue* managed_properties, |
| 194 std::string* error) override; | 194 std::string* error) override; |
| 195 | 195 |
| 196 void GetState(const std::string& network_guid, | 196 void GetState(const std::string& network_guid, |
| 197 base::DictionaryValue* properties, | 197 base::DictionaryValue* properties, |
| 198 std::string* error) override; | 198 std::string* error) override; |
| 199 | 199 |
| 200 void SetProperties(const std::string& network_guid, | 200 void SetProperties(const std::string& network_guid, |
| 201 scoped_ptr<base::DictionaryValue> properties, | 201 std::unique_ptr<base::DictionaryValue> properties, |
| 202 std::string* error) override; | 202 std::string* error) override; |
| 203 | 203 |
| 204 void CreateNetwork(bool shared, | 204 void CreateNetwork(bool shared, |
| 205 scoped_ptr<base::DictionaryValue> properties, | 205 std::unique_ptr<base::DictionaryValue> properties, |
| 206 std::string* network_guid, | 206 std::string* network_guid, |
| 207 std::string* error) override; | 207 std::string* error) override; |
| 208 | 208 |
| 209 void GetVisibleNetworks(const std::string& network_type, | 209 void GetVisibleNetworks(const std::string& network_type, |
| 210 base::ListValue* network_list, | 210 base::ListValue* network_list, |
| 211 bool include_details) override; | 211 bool include_details) override; |
| 212 | 212 |
| 213 void RequestNetworkScan() override; | 213 void RequestNetworkScan() override; |
| 214 | 214 |
| 215 void StartConnect(const std::string& network_guid, | 215 void StartConnect(const std::string& network_guid, |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 DWORD Disconnect(); | 377 DWORD Disconnect(); |
| 378 | 378 |
| 379 // Get desired connection freqency if it was set using |SetProperties|. | 379 // Get desired connection freqency if it was set using |SetProperties|. |
| 380 // Default to |kFrequencyAny|. | 380 // Default to |kFrequencyAny|. |
| 381 Frequency GetFrequencyToConnect(const std::string& network_guid) const; | 381 Frequency GetFrequencyToConnect(const std::string& network_guid) const; |
| 382 | 382 |
| 383 // Get DOT11_BSSID_LIST of desired BSSIDs to connect to |ssid| network on | 383 // Get DOT11_BSSID_LIST of desired BSSIDs to connect to |ssid| network on |
| 384 // given |frequency|. | 384 // given |frequency|. |
| 385 DWORD GetDesiredBssList(DOT11_SSID& ssid, | 385 DWORD GetDesiredBssList(DOT11_SSID& ssid, |
| 386 Frequency frequency, | 386 Frequency frequency, |
| 387 scoped_ptr<DOT11_BSSID_LIST>* desired_list); | 387 std::unique_ptr<DOT11_BSSID_LIST>* desired_list); |
| 388 | 388 |
| 389 // Normalizes |frequency_in_mhz| into one of |Frequency| values. | 389 // Normalizes |frequency_in_mhz| into one of |Frequency| values. |
| 390 Frequency GetNormalizedFrequency(int frequency_in_mhz) const; | 390 Frequency GetNormalizedFrequency(int frequency_in_mhz) const; |
| 391 | 391 |
| 392 // Create |profile_xml| based on |network_properties|. If |encryption_type| | 392 // Create |profile_xml| based on |network_properties|. If |encryption_type| |
| 393 // is |kEncryptionTypeAny| applies the type most suitable for parameters in | 393 // is |kEncryptionTypeAny| applies the type most suitable for parameters in |
| 394 // |network_properties|. | 394 // |network_properties|. |
| 395 bool CreateProfile(const NetworkProperties& network_properties, | 395 bool CreateProfile(const NetworkProperties& network_properties, |
| 396 EncryptionType encryption_type, | 396 EncryptionType encryption_type, |
| 397 std::string* profile_xml); | 397 std::string* profile_xml); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 // Created WLAN Profiles, indexed by |network_guid|. Contains xml with TKIP | 460 // Created WLAN Profiles, indexed by |network_guid|. Contains xml with TKIP |
| 461 // encryption type saved by |CreateNetwork| if applicable. Profile has to be | 461 // encryption type saved by |CreateNetwork| if applicable. Profile has to be |
| 462 // deleted if connection fails. Implicitly created profiles have to be deleted | 462 // deleted if connection fails. Implicitly created profiles have to be deleted |
| 463 // if connection succeeds. Persist only in memory. | 463 // if connection succeeds. Persist only in memory. |
| 464 base::DictionaryValue created_profiles_; | 464 base::DictionaryValue created_profiles_; |
| 465 // Observer to get notified when network(s) have changed (e.g. connect). | 465 // Observer to get notified when network(s) have changed (e.g. connect). |
| 466 NetworkGuidListCallback networks_changed_observer_; | 466 NetworkGuidListCallback networks_changed_observer_; |
| 467 // Observer to get notified when network list has changed (scan complete). | 467 // Observer to get notified when network list has changed (scan complete). |
| 468 NetworkGuidListCallback network_list_changed_observer_; | 468 NetworkGuidListCallback network_list_changed_observer_; |
| 469 // Saved value of network location wizard show value. | 469 // Saved value of network location wizard show value. |
| 470 scoped_ptr<DWORD> saved_nw_category_wizard_; | 470 std::unique_ptr<DWORD> saved_nw_category_wizard_; |
| 471 // Task runner to post events on UI thread. | 471 // Task runner to post events on UI thread. |
| 472 scoped_refptr<base::SingleThreadTaskRunner> event_task_runner_; | 472 scoped_refptr<base::SingleThreadTaskRunner> event_task_runner_; |
| 473 // Task runner for worker tasks. | 473 // Task runner for worker tasks. |
| 474 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 474 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| 475 // If |false|, then |networks_changed_observer_| is not notified. | 475 // If |false|, then |networks_changed_observer_| is not notified. |
| 476 bool enable_notify_network_changed_; | 476 bool enable_notify_network_changed_; |
| 477 // Number of attempts to check that network has connected successfully. | 477 // Number of attempts to check that network has connected successfully. |
| 478 static const int kMaxAttempts = 100; | 478 static const int kMaxAttempts = 100; |
| 479 // Delay between attempts to check that network has connected successfully. | 479 // Delay between attempts to check that network has connected successfully. |
| 480 static const int kAttemptDelayMs = 100; | 480 static const int kAttemptDelayMs = 100; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 } | 555 } |
| 556 | 556 |
| 557 void WiFiServiceImpl::GetState(const std::string& network_guid, | 557 void WiFiServiceImpl::GetState(const std::string& network_guid, |
| 558 base::DictionaryValue* properties, | 558 base::DictionaryValue* properties, |
| 559 std::string* error) { | 559 std::string* error) { |
| 560 CheckError(ERROR_CALL_NOT_IMPLEMENTED, kErrorWiFiService, error); | 560 CheckError(ERROR_CALL_NOT_IMPLEMENTED, kErrorWiFiService, error); |
| 561 } | 561 } |
| 562 | 562 |
| 563 void WiFiServiceImpl::SetProperties( | 563 void WiFiServiceImpl::SetProperties( |
| 564 const std::string& network_guid, | 564 const std::string& network_guid, |
| 565 scoped_ptr<base::DictionaryValue> properties, | 565 std::unique_ptr<base::DictionaryValue> properties, |
| 566 std::string* error) { | 566 std::string* error) { |
| 567 // Temporary preserve WiFi properties (desired frequency, wifi password) to | 567 // Temporary preserve WiFi properties (desired frequency, wifi password) to |
| 568 // use in StartConnect. | 568 // use in StartConnect. |
| 569 DCHECK(properties.get()); | 569 DCHECK(properties.get()); |
| 570 if (!properties->HasKey(onc::network_type::kWiFi)) { | 570 if (!properties->HasKey(onc::network_type::kWiFi)) { |
| 571 DVLOG(0) << "Missing WiFi properties:" << *properties; | 571 DVLOG(0) << "Missing WiFi properties:" << *properties; |
| 572 *error = kErrorWiFiService; | 572 *error = kErrorWiFiService; |
| 573 return; | 573 return; |
| 574 } | 574 } |
| 575 | 575 |
| 576 base::DictionaryValue* existing_properties; | 576 base::DictionaryValue* existing_properties; |
| 577 // If the network properties already exist, don't override previously set | 577 // If the network properties already exist, don't override previously set |
| 578 // properties, unless they are set in |properties|. | 578 // properties, unless they are set in |properties|. |
| 579 if (connect_properties_.GetDictionaryWithoutPathExpansion( | 579 if (connect_properties_.GetDictionaryWithoutPathExpansion( |
| 580 network_guid, &existing_properties)) { | 580 network_guid, &existing_properties)) { |
| 581 existing_properties->MergeDictionary(properties.get()); | 581 existing_properties->MergeDictionary(properties.get()); |
| 582 } else { | 582 } else { |
| 583 connect_properties_.SetWithoutPathExpansion(network_guid, | 583 connect_properties_.SetWithoutPathExpansion(network_guid, |
| 584 properties.release()); | 584 properties.release()); |
| 585 } | 585 } |
| 586 } | 586 } |
| 587 | 587 |
| 588 void WiFiServiceImpl::CreateNetwork( | 588 void WiFiServiceImpl::CreateNetwork( |
| 589 bool shared, | 589 bool shared, |
| 590 scoped_ptr<base::DictionaryValue> properties, | 590 std::unique_ptr<base::DictionaryValue> properties, |
| 591 std::string* network_guid, | 591 std::string* network_guid, |
| 592 std::string* error) { | 592 std::string* error) { |
| 593 DWORD error_code = EnsureInitialized(); | 593 DWORD error_code = EnsureInitialized(); |
| 594 if (CheckError(error_code, kErrorWiFiService, error)) | 594 if (CheckError(error_code, kErrorWiFiService, error)) |
| 595 return; | 595 return; |
| 596 | 596 |
| 597 NetworkProperties network_properties; | 597 NetworkProperties network_properties; |
| 598 if (!network_properties.UpdateFromValue(*properties)) { | 598 if (!network_properties.UpdateFromValue(*properties)) { |
| 599 CheckError(ERROR_INVALID_DATA, kErrorWiFiService, error); | 599 CheckError(ERROR_INVALID_DATA, kErrorWiFiService, error); |
| 600 return; | 600 return; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 618 // encryption type fails. | 618 // encryption type fails. |
| 619 std::string tkip_profile_xml; | 619 std::string tkip_profile_xml; |
| 620 if (!CreateProfile(network_properties, | 620 if (!CreateProfile(network_properties, |
| 621 kEncryptionTypeTKIP, | 621 kEncryptionTypeTKIP, |
| 622 &tkip_profile_xml)) { | 622 &tkip_profile_xml)) { |
| 623 CheckError(ERROR_INVALID_DATA, kErrorWiFiService, error); | 623 CheckError(ERROR_INVALID_DATA, kErrorWiFiService, error); |
| 624 return; | 624 return; |
| 625 } | 625 } |
| 626 | 626 |
| 627 if (tkip_profile_xml != profile_xml) { | 627 if (tkip_profile_xml != profile_xml) { |
| 628 scoped_ptr<base::DictionaryValue> tkip_profile(new base::DictionaryValue()); | 628 std::unique_ptr<base::DictionaryValue> tkip_profile( |
| 629 new base::DictionaryValue()); |
| 629 tkip_profile->SetString(kProfileXmlKey, tkip_profile_xml); | 630 tkip_profile->SetString(kProfileXmlKey, tkip_profile_xml); |
| 630 tkip_profile->SetBoolean(kProfileSharedKey, shared); | 631 tkip_profile->SetBoolean(kProfileSharedKey, shared); |
| 631 created_profiles_.SetWithoutPathExpansion(network_properties.guid, | 632 created_profiles_.SetWithoutPathExpansion(network_properties.guid, |
| 632 tkip_profile.release()); | 633 tkip_profile.release()); |
| 633 } | 634 } |
| 634 | 635 |
| 635 *network_guid = network_properties.guid; | 636 *network_guid = network_properties.guid; |
| 636 } | 637 } |
| 637 | 638 |
| 638 void WiFiServiceImpl::GetVisibleNetworks(const std::string& network_type, | 639 void WiFiServiceImpl::GetVisibleNetworks(const std::string& network_type, |
| 639 base::ListValue* network_list, | 640 base::ListValue* network_list, |
| 640 bool include_details) { | 641 bool include_details) { |
| 641 if (!network_type.empty() && | 642 if (!network_type.empty() && |
| 642 network_type != onc::network_type::kAllTypes && | 643 network_type != onc::network_type::kAllTypes && |
| 643 network_type != onc::network_type::kWiFi) { | 644 network_type != onc::network_type::kWiFi) { |
| 644 return; | 645 return; |
| 645 } | 646 } |
| 646 | 647 |
| 647 DWORD error = EnsureInitialized(); | 648 DWORD error = EnsureInitialized(); |
| 648 if (error == ERROR_SUCCESS) { | 649 if (error == ERROR_SUCCESS) { |
| 649 NetworkList networks; | 650 NetworkList networks; |
| 650 error = GetVisibleNetworkList(&networks); | 651 error = GetVisibleNetworkList(&networks); |
| 651 if (error == ERROR_SUCCESS && !networks.empty()) { | 652 if (error == ERROR_SUCCESS && !networks.empty()) { |
| 652 SortNetworks(&networks); | 653 SortNetworks(&networks); |
| 653 for (NetworkList::const_iterator it = networks.begin(); | 654 for (NetworkList::const_iterator it = networks.begin(); |
| 654 it != networks.end(); | 655 it != networks.end(); |
| 655 ++it) { | 656 ++it) { |
| 656 scoped_ptr<base::DictionaryValue> network( | 657 std::unique_ptr<base::DictionaryValue> network( |
| 657 it->ToValue(!include_details)); | 658 it->ToValue(!include_details)); |
| 658 network_list->Append(network.release()); | 659 network_list->Append(network.release()); |
| 659 } | 660 } |
| 660 } | 661 } |
| 661 } | 662 } |
| 662 } | 663 } |
| 663 | 664 |
| 664 void WiFiServiceImpl::RequestNetworkScan() { | 665 void WiFiServiceImpl::RequestNetworkScan() { |
| 665 DWORD error = EnsureInitialized(); | 666 DWORD error = EnsureInitialized(); |
| 666 if (error == ERROR_SUCCESS) { | 667 if (error == ERROR_SUCCESS) { |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1143 const GUID& interface_guid, | 1144 const GUID& interface_guid, |
| 1144 IP_ADAPTER_INDEX_MAP* adapter_index_map) { | 1145 IP_ADAPTER_INDEX_MAP* adapter_index_map) { |
| 1145 base::string16 guid_string; | 1146 base::string16 guid_string; |
| 1146 const int kGUIDSize = 39; | 1147 const int kGUIDSize = 39; |
| 1147 ::StringFromGUID2( | 1148 ::StringFromGUID2( |
| 1148 interface_guid, base::WriteInto(&guid_string, kGUIDSize), kGUIDSize); | 1149 interface_guid, base::WriteInto(&guid_string, kGUIDSize), kGUIDSize); |
| 1149 | 1150 |
| 1150 ULONG buffer_length = 0; | 1151 ULONG buffer_length = 0; |
| 1151 DWORD error = ::GetInterfaceInfo(NULL, &buffer_length); | 1152 DWORD error = ::GetInterfaceInfo(NULL, &buffer_length); |
| 1152 if (error == ERROR_INSUFFICIENT_BUFFER) { | 1153 if (error == ERROR_INSUFFICIENT_BUFFER) { |
| 1153 scoped_ptr<unsigned char[]> buffer(new unsigned char[buffer_length]); | 1154 std::unique_ptr<unsigned char[]> buffer(new unsigned char[buffer_length]); |
| 1154 IP_INTERFACE_INFO* interface_info = | 1155 IP_INTERFACE_INFO* interface_info = |
| 1155 reinterpret_cast<IP_INTERFACE_INFO*>(buffer.get()); | 1156 reinterpret_cast<IP_INTERFACE_INFO*>(buffer.get()); |
| 1156 error = GetInterfaceInfo(interface_info, &buffer_length); | 1157 error = GetInterfaceInfo(interface_info, &buffer_length); |
| 1157 if (error == ERROR_SUCCESS) { | 1158 if (error == ERROR_SUCCESS) { |
| 1158 for (int adapter = 0; adapter < interface_info->NumAdapters; ++adapter) { | 1159 for (int adapter = 0; adapter < interface_info->NumAdapters; ++adapter) { |
| 1159 if (base::EndsWith( | 1160 if (base::EndsWith( |
| 1160 interface_info->Adapter[adapter].Name, guid_string, | 1161 interface_info->Adapter[adapter].Name, guid_string, |
| 1161 base::CompareCase::INSENSITIVE_ASCII)) { | 1162 base::CompareCase::INSENSITIVE_ASCII)) { |
| 1162 *adapter_index_map = interface_info->Adapter[adapter]; | 1163 *adapter_index_map = interface_info->Adapter[adapter]; |
| 1163 break; | 1164 break; |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1528 if (wifi->GetInteger(onc::wifi::kFrequency, &frequency)) | 1529 if (wifi->GetInteger(onc::wifi::kFrequency, &frequency)) |
| 1529 return GetNormalizedFrequency(frequency); | 1530 return GetNormalizedFrequency(frequency); |
| 1530 } | 1531 } |
| 1531 } | 1532 } |
| 1532 return kFrequencyAny; | 1533 return kFrequencyAny; |
| 1533 } | 1534 } |
| 1534 | 1535 |
| 1535 DWORD WiFiServiceImpl::GetDesiredBssList( | 1536 DWORD WiFiServiceImpl::GetDesiredBssList( |
| 1536 DOT11_SSID& ssid, | 1537 DOT11_SSID& ssid, |
| 1537 Frequency frequency, | 1538 Frequency frequency, |
| 1538 scoped_ptr<DOT11_BSSID_LIST>* desired_list) { | 1539 std::unique_ptr<DOT11_BSSID_LIST>* desired_list) { |
| 1539 if (client_ == NULL) { | 1540 if (client_ == NULL) { |
| 1540 NOTREACHED(); | 1541 NOTREACHED(); |
| 1541 return ERROR_NOINTERFACE; | 1542 return ERROR_NOINTERFACE; |
| 1542 } | 1543 } |
| 1543 | 1544 |
| 1544 desired_list->reset(); | 1545 desired_list->reset(); |
| 1545 | 1546 |
| 1546 if (frequency == kFrequencyAny) | 1547 if (frequency == kFrequencyAny) |
| 1547 return ERROR_SUCCESS; | 1548 return ERROR_SUCCESS; |
| 1548 | 1549 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1581 if (bss_frequency == frequency && | 1582 if (bss_frequency == frequency && |
| 1582 bss_entry.uLinkQuality > best_quality) { | 1583 bss_entry.uLinkQuality > best_quality) { |
| 1583 best_quality = bss_entry.uLinkQuality; | 1584 best_quality = bss_entry.uLinkQuality; |
| 1584 best_index = bss; | 1585 best_index = bss; |
| 1585 } | 1586 } |
| 1586 } | 1587 } |
| 1587 | 1588 |
| 1588 // If any matching BSS were found, prepare the header. | 1589 // If any matching BSS were found, prepare the header. |
| 1589 if (best_quality > 0) { | 1590 if (best_quality > 0) { |
| 1590 const WLAN_BSS_ENTRY& bss_entry(bss_list->wlanBssEntries[best_index]); | 1591 const WLAN_BSS_ENTRY& bss_entry(bss_list->wlanBssEntries[best_index]); |
| 1591 scoped_ptr<DOT11_BSSID_LIST> selected_list(new DOT11_BSSID_LIST); | 1592 std::unique_ptr<DOT11_BSSID_LIST> selected_list(new DOT11_BSSID_LIST); |
| 1592 | 1593 |
| 1593 selected_list->Header.Revision = DOT11_BSSID_LIST_REVISION_1; | 1594 selected_list->Header.Revision = DOT11_BSSID_LIST_REVISION_1; |
| 1594 selected_list->Header.Size = sizeof(DOT11_BSSID_LIST); | 1595 selected_list->Header.Size = sizeof(DOT11_BSSID_LIST); |
| 1595 selected_list->Header.Type = NDIS_OBJECT_TYPE_DEFAULT; | 1596 selected_list->Header.Type = NDIS_OBJECT_TYPE_DEFAULT; |
| 1596 selected_list->uNumOfEntries = 1; | 1597 selected_list->uNumOfEntries = 1; |
| 1597 selected_list->uTotalNumOfEntries = 1; | 1598 selected_list->uTotalNumOfEntries = 1; |
| 1598 std::copy(bss_entry.dot11Bssid, | 1599 std::copy(bss_entry.dot11Bssid, |
| 1599 bss_entry.dot11Bssid+sizeof(bss_entry.dot11Bssid), | 1600 bss_entry.dot11Bssid+sizeof(bss_entry.dot11Bssid), |
| 1600 selected_list->BSSIDs[0]); | 1601 selected_list->BSSIDs[0]); |
| 1601 desired_list->swap(selected_list); | 1602 desired_list->swap(selected_list); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1623 | 1624 |
| 1624 DWORD WiFiServiceImpl::Connect(const std::string& network_guid, | 1625 DWORD WiFiServiceImpl::Connect(const std::string& network_guid, |
| 1625 Frequency frequency) { | 1626 Frequency frequency) { |
| 1626 if (client_ == NULL) { | 1627 if (client_ == NULL) { |
| 1627 NOTREACHED(); | 1628 NOTREACHED(); |
| 1628 return ERROR_NOINTERFACE; | 1629 return ERROR_NOINTERFACE; |
| 1629 } | 1630 } |
| 1630 | 1631 |
| 1631 DWORD error = ERROR_SUCCESS; | 1632 DWORD error = ERROR_SUCCESS; |
| 1632 DOT11_SSID ssid = SSIDFromGUID(network_guid); | 1633 DOT11_SSID ssid = SSIDFromGUID(network_guid); |
| 1633 scoped_ptr<DOT11_BSSID_LIST> desired_bss_list; | 1634 std::unique_ptr<DOT11_BSSID_LIST> desired_bss_list; |
| 1634 error = GetDesiredBssList(ssid, frequency, &desired_bss_list); | 1635 error = GetDesiredBssList(ssid, frequency, &desired_bss_list); |
| 1635 if (error == ERROR_SUCCESS) { | 1636 if (error == ERROR_SUCCESS) { |
| 1636 if (HaveProfile(network_guid)) { | 1637 if (HaveProfile(network_guid)) { |
| 1637 base::string16 profile_name = ProfileNameFromGUID(network_guid); | 1638 base::string16 profile_name = ProfileNameFromGUID(network_guid); |
| 1638 WLAN_CONNECTION_PARAMETERS wlan_params = { | 1639 WLAN_CONNECTION_PARAMETERS wlan_params = { |
| 1639 wlan_connection_mode_profile, | 1640 wlan_connection_mode_profile, |
| 1640 profile_name.c_str(), | 1641 profile_name.c_str(), |
| 1641 NULL, | 1642 NULL, |
| 1642 desired_bss_list.get(), | 1643 desired_bss_list.get(), |
| 1643 dot11_BSS_type_any, | 1644 dot11_BSS_type_any, |
| 1644 0}; | 1645 0}; |
| 1645 error = WlanConnect_function_( | 1646 error = WlanConnect_function_( |
| 1646 client_, &interface_guid_, &wlan_params, NULL); | 1647 client_, &interface_guid_, &wlan_params, NULL); |
| 1647 } else { | 1648 } else { |
| 1648 // If network is available, but is not open security, then it cannot be | 1649 // If network is available, but is not open security, then it cannot be |
| 1649 // connected without profile, so return 'access denied' error. | 1650 // connected without profile, so return 'access denied' error. |
| 1650 scoped_ptr<base::DictionaryValue> properties (new base::DictionaryValue); | 1651 std::unique_ptr<base::DictionaryValue> properties( |
| 1652 new base::DictionaryValue); |
| 1651 const base::DictionaryValue* wifi; | 1653 const base::DictionaryValue* wifi; |
| 1652 std::string wifi_security; | 1654 std::string wifi_security; |
| 1653 std::string error_string; | 1655 std::string error_string; |
| 1654 GetProperties(network_guid, properties.get(), &error_string); | 1656 GetProperties(network_guid, properties.get(), &error_string); |
| 1655 if (error_string.empty() && | 1657 if (error_string.empty() && |
| 1656 properties->GetDictionary(onc::network_type::kWiFi, &wifi) && | 1658 properties->GetDictionary(onc::network_type::kWiFi, &wifi) && |
| 1657 wifi->GetString(onc::wifi::kSecurity, &wifi_security) && | 1659 wifi->GetString(onc::wifi::kSecurity, &wifi_security) && |
| 1658 wifi_security != onc::wifi::kSecurityNone) { | 1660 wifi_security != onc::wifi::kSecurityNone) { |
| 1659 error = ERROR_ACCESS_DENIED; | 1661 error = ERROR_ACCESS_DENIED; |
| 1660 LOG(ERROR) << error; | 1662 LOG(ERROR) << error; |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1892 DVLOG(1) << "NotifyNetworkChanged: " << network_guid; | 1894 DVLOG(1) << "NotifyNetworkChanged: " << network_guid; |
| 1893 NetworkGuidList changed_networks(1, network_guid); | 1895 NetworkGuidList changed_networks(1, network_guid); |
| 1894 event_task_runner_->PostTask( | 1896 event_task_runner_->PostTask( |
| 1895 FROM_HERE, base::Bind(networks_changed_observer_, changed_networks)); | 1897 FROM_HERE, base::Bind(networks_changed_observer_, changed_networks)); |
| 1896 } | 1898 } |
| 1897 } | 1899 } |
| 1898 | 1900 |
| 1899 WiFiService* WiFiService::Create() { return new WiFiServiceImpl(); } | 1901 WiFiService* WiFiService::Create() { return new WiFiServiceImpl(); } |
| 1900 | 1902 |
| 1901 } // namespace wifi | 1903 } // namespace wifi |
| OLD | NEW |