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

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

Issue 88653002: Move GetVisibleNetworks network type filtering to WiFiService interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Toni's comments. Created 7 years 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 | Annotate | Revision Log
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "components/onc/onc_constants.h" 9 #include "components/onc/onc_constants.h"
10 10
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 virtual void SetProperties(const std::string& network_guid, 100 virtual void SetProperties(const std::string& network_guid,
101 scoped_ptr<base::DictionaryValue> properties, 101 scoped_ptr<base::DictionaryValue> properties,
102 std::string* error) OVERRIDE { 102 std::string* error) OVERRIDE {
103 NetworkList::iterator network_properties = FindNetwork(network_guid); 103 NetworkList::iterator network_properties = FindNetwork(network_guid);
104 if (network_properties == networks_.end() || 104 if (network_properties == networks_.end() ||
105 !network_properties->UpdateFromValue(*properties)) { 105 !network_properties->UpdateFromValue(*properties)) {
106 *error = "Error.DBusFailed"; 106 *error = "Error.DBusFailed";
107 } 107 }
108 } 108 }
109 109
110 virtual void GetVisibleNetworks(ListValue* network_list) OVERRIDE { 110 virtual void GetVisibleNetworks(const std::string& network_type,
111 ListValue* network_list) OVERRIDE {
111 for (WiFiService::NetworkList::const_iterator it = networks_.begin(); 112 for (WiFiService::NetworkList::const_iterator it = networks_.begin();
112 it != networks_.end(); 113 it != networks_.end();
113 ++it) { 114 ++it) {
114 scoped_ptr<DictionaryValue> network(it->ToValue(true)); 115 if (network_type.empty() ||
115 network_list->Append(network.release()); 116 network_type == onc::network_type::kAllTypes ||
117 it->type == network_type) {
118 scoped_ptr<DictionaryValue> network(it->ToValue(true));
119 network_list->Append(network.release());
120 }
116 } 121 }
117 } 122 }
118 123
119 virtual void RequestNetworkScan() OVERRIDE { 124 virtual void RequestNetworkScan() OVERRIDE {
120 NotifyNetworkListChanged(networks_); 125 NotifyNetworkListChanged(networks_);
121 } 126 }
122 127
123 virtual void StartConnect(const std::string& network_guid, 128 virtual void StartConnect(const std::string& network_guid,
124 std::string* error) OVERRIDE { 129 std::string* error) OVERRIDE {
125 NetworkList::iterator network_properties = FindNetwork(network_guid); 130 NetworkList::iterator network_properties = FindNetwork(network_guid);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 208
204 NetworkList networks_; 209 NetworkList networks_;
205 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; 210 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
206 NetworkGuidListCallback networks_changed_observer_; 211 NetworkGuidListCallback networks_changed_observer_;
207 NetworkGuidListCallback network_list_changed_observer_; 212 NetworkGuidListCallback network_list_changed_observer_;
208 }; 213 };
209 214
210 WiFiService* WiFiService::CreateForTest() { return new FakeWiFiService(); } 215 WiFiService* WiFiService::CreateForTest() { return new FakeWiFiService(); }
211 216
212 } // namespace wifi 217 } // namespace wifi
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/networking_private/networking_private_service_client.cc ('k') | components/wifi/wifi_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698