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

Side by Side Diff: components/wifi/wifi_service_win.cc

Issue 2809933003: Remove ListValue::Append(raw ptr) on Win (Closed)
Patch Set: More Win Created 3 years, 8 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
OLDNEW
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>
11 #include <wlanapi.h> 11 #include <wlanapi.h>
12 12
13 #include <set> 13 #include <set>
14 #include <utility>
jdoerrie 2017/04/13 13:49:49 #include <memory>
vabr (Chromium) 2017/04/13 16:06:48 Done.
14 15
15 #include "base/base_paths_win.h" 16 #include "base/base_paths_win.h"
16 #include "base/bind.h" 17 #include "base/bind.h"
17 #include "base/files/file_path.h" 18 #include "base/files/file_path.h"
18 #include "base/macros.h" 19 #include "base/macros.h"
19 #include "base/memory/ref_counted.h" 20 #include "base/memory/ref_counted.h"
20 #include "base/message_loop/message_loop.h" 21 #include "base/message_loop/message_loop.h"
21 #include "base/path_service.h" 22 #include "base/path_service.h"
22 #include "base/strings/string16.h" 23 #include "base/strings/string16.h"
23 #include "base/strings/string_util.h" 24 #include "base/strings/string_util.h"
24 #include "base/strings/utf_string_conversions.h" 25 #include "base/strings/utf_string_conversions.h"
25 #include "base/win/registry.h" 26 #include "base/win/registry.h"
jdoerrie 2017/04/13 13:49:49 #include "base/values.h"
vabr (Chromium) 2017/04/13 16:06:48 Done.
26 #include "components/onc/onc_constants.h" 27 #include "components/onc/onc_constants.h"
27 #include "components/wifi/network_properties.h" 28 #include "components/wifi/network_properties.h"
28 #include "third_party/libxml/chromium/libxml_utils.h" 29 #include "third_party/libxml/chromium/libxml_utils.h"
29 30
30 namespace { 31 namespace {
31 const wchar_t kNwCategoryWizardRegKey[] = 32 const wchar_t kNwCategoryWizardRegKey[] =
32 L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Network\\" 33 L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Network\\"
33 L"NwCategoryWizard"; 34 L"NwCategoryWizard";
34 const wchar_t kNwCategoryWizardRegValue[] = L"Show"; 35 const wchar_t kNwCategoryWizardRegValue[] = L"Show";
35 const wchar_t kNwCategoryWizardSavedRegValue[] = L"ShowSaved"; 36 const wchar_t kNwCategoryWizardSavedRegValue[] = L"ShowSaved";
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 } 575 }
575 576
576 base::DictionaryValue* existing_properties; 577 base::DictionaryValue* existing_properties;
577 // If the network properties already exist, don't override previously set 578 // If the network properties already exist, don't override previously set
578 // properties, unless they are set in |properties|. 579 // properties, unless they are set in |properties|.
579 if (connect_properties_.GetDictionaryWithoutPathExpansion( 580 if (connect_properties_.GetDictionaryWithoutPathExpansion(
580 network_guid, &existing_properties)) { 581 network_guid, &existing_properties)) {
581 existing_properties->MergeDictionary(properties.get()); 582 existing_properties->MergeDictionary(properties.get());
582 } else { 583 } else {
583 connect_properties_.SetWithoutPathExpansion(network_guid, 584 connect_properties_.SetWithoutPathExpansion(network_guid,
584 properties.release()); 585 std::move(properties));
585 } 586 }
586 } 587 }
587 588
588 void WiFiServiceImpl::CreateNetwork( 589 void WiFiServiceImpl::CreateNetwork(
589 bool shared, 590 bool shared,
590 std::unique_ptr<base::DictionaryValue> properties, 591 std::unique_ptr<base::DictionaryValue> properties,
591 std::string* network_guid, 592 std::string* network_guid,
592 std::string* error) { 593 std::string* error) {
593 DWORD error_code = EnsureInitialized(); 594 DWORD error_code = EnsureInitialized();
594 if (CheckError(error_code, kErrorWiFiService, error)) 595 if (CheckError(error_code, kErrorWiFiService, error))
(...skipping 28 matching lines...) Expand all
623 CheckError(ERROR_INVALID_DATA, kErrorWiFiService, error); 624 CheckError(ERROR_INVALID_DATA, kErrorWiFiService, error);
624 return; 625 return;
625 } 626 }
626 627
627 if (tkip_profile_xml != profile_xml) { 628 if (tkip_profile_xml != profile_xml) {
628 std::unique_ptr<base::DictionaryValue> tkip_profile( 629 std::unique_ptr<base::DictionaryValue> tkip_profile(
629 new base::DictionaryValue()); 630 new base::DictionaryValue());
630 tkip_profile->SetString(kProfileXmlKey, tkip_profile_xml); 631 tkip_profile->SetString(kProfileXmlKey, tkip_profile_xml);
631 tkip_profile->SetBoolean(kProfileSharedKey, shared); 632 tkip_profile->SetBoolean(kProfileSharedKey, shared);
632 created_profiles_.SetWithoutPathExpansion(network_properties.guid, 633 created_profiles_.SetWithoutPathExpansion(network_properties.guid,
633 tkip_profile.release()); 634 std::move(tkip_profile));
634 } 635 }
635 636
636 *network_guid = network_properties.guid; 637 *network_guid = network_properties.guid;
637 } 638 }
638 639
639 void WiFiServiceImpl::GetVisibleNetworks(const std::string& network_type, 640 void WiFiServiceImpl::GetVisibleNetworks(const std::string& network_type,
640 base::ListValue* network_list, 641 base::ListValue* network_list,
641 bool include_details) { 642 bool include_details) {
642 if (!network_type.empty() && 643 if (!network_type.empty() &&
643 network_type != onc::network_type::kAllTypes && 644 network_type != onc::network_type::kAllTypes &&
644 network_type != onc::network_type::kWiFi) { 645 network_type != onc::network_type::kWiFi) {
645 return; 646 return;
646 } 647 }
647 648
648 DWORD error = EnsureInitialized(); 649 DWORD error = EnsureInitialized();
649 if (error == ERROR_SUCCESS) { 650 if (error == ERROR_SUCCESS) {
650 NetworkList networks; 651 NetworkList networks;
651 error = GetVisibleNetworkList(&networks); 652 error = GetVisibleNetworkList(&networks);
652 if (error == ERROR_SUCCESS && !networks.empty()) { 653 if (error == ERROR_SUCCESS && !networks.empty()) {
653 SortNetworks(&networks); 654 SortNetworks(&networks);
654 for (NetworkList::const_iterator it = networks.begin(); 655 for (NetworkList::const_iterator it = networks.begin();
655 it != networks.end(); 656 it != networks.end();
656 ++it) { 657 ++it) {
657 std::unique_ptr<base::DictionaryValue> network( 658 std::unique_ptr<base::DictionaryValue> network(
658 it->ToValue(!include_details)); 659 it->ToValue(!include_details));
659 network_list->Append(network.release()); 660 network_list->Append(std::move(network));
660 } 661 }
661 } 662 }
662 } 663 }
663 } 664 }
664 665
665 void WiFiServiceImpl::RequestNetworkScan() { 666 void WiFiServiceImpl::RequestNetworkScan() {
666 DWORD error = EnsureInitialized(); 667 DWORD error = EnsureInitialized();
667 if (error == ERROR_SUCCESS) { 668 if (error == ERROR_SUCCESS) {
668 WlanScan_function_(client_, &interface_guid_, NULL, NULL, NULL); 669 WlanScan_function_(client_, &interface_guid_, NULL, NULL, NULL);
669 } 670 }
(...skipping 1224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1894 DVLOG(1) << "NotifyNetworkChanged: " << network_guid; 1895 DVLOG(1) << "NotifyNetworkChanged: " << network_guid;
1895 NetworkGuidList changed_networks(1, network_guid); 1896 NetworkGuidList changed_networks(1, network_guid);
1896 event_task_runner_->PostTask( 1897 event_task_runner_->PostTask(
1897 FROM_HERE, base::Bind(networks_changed_observer_, changed_networks)); 1898 FROM_HERE, base::Bind(networks_changed_observer_, changed_networks));
1898 } 1899 }
1899 } 1900 }
1900 1901
1901 WiFiService* WiFiService::Create() { return new WiFiServiceImpl(); } 1902 WiFiService* WiFiService::Create() { return new WiFiServiceImpl(); }
1902 1903
1903 } // namespace wifi 1904 } // namespace wifi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698