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

Side by Side Diff: chromeos/dbus/shill_manager_client.cc

Issue 12676017: Adding policy support to the new network configuration stack. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove policy initialized flags and wrap PolicyMaps with scoped_ptr. Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chromeos/dbus/shill_manager_client.h" 5 #include "chromeos/dbus/shill_manager_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/chromeos/chromeos_version.h" 8 #include "base/chromeos/chromeos_version.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chromeos/dbus/shill_manager_client_stub.h" 11 #include "chromeos/dbus/shill_manager_client_stub.h"
12 #include "chromeos/dbus/shill_property_changed_observer.h" 12 #include "chromeos/dbus/shill_property_changed_observer.h"
13 #include "dbus/bus.h" 13 #include "dbus/bus.h"
14 #include "dbus/message.h" 14 #include "dbus/message.h"
15 #include "dbus/object_path.h" 15 #include "dbus/object_path.h"
16 #include "dbus/object_proxy.h" 16 #include "dbus/object_proxy.h"
17 #include "dbus/values_util.h" 17 #include "dbus/values_util.h"
18 #include "third_party/cros_system_api/dbus/service_constants.h" 18 #include "third_party/cros_system_api/dbus/service_constants.h"
19 19
20 namespace chromeos { 20 namespace chromeos {
21 21
22 namespace { 22 namespace {
23 23
24 // Returns whether the properties have the required keys or not. 24 // Returns whether the properties have the required keys or not.
25 bool AreServicePropertiesValid2(const base::DictionaryValue& properties) {
stevenjb 2013/04/11 18:20:08 2 is a poor differentiator. Maybe ForProfile or Wi
pneubeck (no reviews) 2013/04/15 12:16:24 Done.
26 if (properties.HasKey(flimflam::kGuidProperty))
27 return true;
28 return properties.HasKey(flimflam::kTypeProperty) &&
29 properties.HasKey(flimflam::kSecurityProperty) &&
30 properties.HasKey(flimflam::kModeProperty) &&
31 properties.HasKey(flimflam::kSSIDProperty);
32 }
33
34 // DEPRECATED: Keep this only for backward compatibility with NetworkLibrary.
pastarmovj 2013/04/11 14:46:29 Put a todo here to remove that once not needed and
pneubeck (no reviews) 2013/04/15 12:16:24 Done.
35 // Returns whether the properties have the required keys or not.
25 bool AreServicePropertiesValid(const base::DictionaryValue& properties) { 36 bool AreServicePropertiesValid(const base::DictionaryValue& properties) {
26 if (properties.HasKey(flimflam::kGuidProperty)) 37 if (properties.HasKey(flimflam::kGuidProperty))
27 return true; 38 return true;
28 return properties.HasKey(flimflam::kTypeProperty) && 39 return properties.HasKey(flimflam::kTypeProperty) &&
29 properties.HasKey(flimflam::kSecurityProperty) && 40 properties.HasKey(flimflam::kSecurityProperty) &&
30 properties.HasKey(flimflam::kSSIDProperty); 41 properties.HasKey(flimflam::kSSIDProperty);
31 } 42 }
32 43
33 // Appends a string-to-variant dictionary to the writer. 44 // Appends a string-to-variant dictionary to the writer.
34 void AppendServicePropertiesDictionary( 45 void AppendServicePropertiesDictionary(
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 DCHECK(AreServicePropertiesValid(properties)); 160 DCHECK(AreServicePropertiesValid(properties));
150 dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface, 161 dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface,
151 flimflam::kConfigureServiceFunction); 162 flimflam::kConfigureServiceFunction);
152 dbus::MessageWriter writer(&method_call); 163 dbus::MessageWriter writer(&method_call);
153 AppendServicePropertiesDictionary(&writer, properties); 164 AppendServicePropertiesDictionary(&writer, properties);
154 helper_.CallObjectPathMethodWithErrorCallback(&method_call, 165 helper_.CallObjectPathMethodWithErrorCallback(&method_call,
155 callback, 166 callback,
156 error_callback); 167 error_callback);
157 } 168 }
158 169
170 virtual void ConfigureServiceForProfile(
171 const dbus::ObjectPath& profile_path,
172 const base::DictionaryValue& properties,
173 const ObjectPathCallback& callback,
174 const ErrorCallback& error_callback) OVERRIDE {
175 DCHECK(AreServicePropertiesValid2(properties));
pastarmovj 2013/04/11 14:46:29 DCHECK will only verify in debug builds - does you
pneubeck (no reviews) 2013/04/15 12:16:24 Done.
176 dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface,
177 shill::kConfigureServiceForProfileFunction);
178 dbus::MessageWriter writer(&method_call);
179 writer.AppendObjectPath(dbus::ObjectPath(profile_path));
180 AppendServicePropertiesDictionary(&writer, properties);
181 helper_.CallObjectPathMethodWithErrorCallback(&method_call,
182 callback,
183 error_callback);
184 }
185
159 virtual void GetService( 186 virtual void GetService(
160 const base::DictionaryValue& properties, 187 const base::DictionaryValue& properties,
161 const ObjectPathCallback& callback, 188 const ObjectPathCallback& callback,
162 const ErrorCallback& error_callback) OVERRIDE { 189 const ErrorCallback& error_callback) OVERRIDE {
163 dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface, 190 dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface,
164 flimflam::kGetServiceFunction); 191 flimflam::kGetServiceFunction);
165 dbus::MessageWriter writer(&method_call); 192 dbus::MessageWriter writer(&method_call);
166 AppendServicePropertiesDictionary(&writer, properties); 193 AppendServicePropertiesDictionary(&writer, properties);
167 helper_.CallObjectPathMethodWithErrorCallback(&method_call, 194 helper_.CallObjectPathMethodWithErrorCallback(&method_call,
168 callback, 195 callback,
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 ShillManagerClient* ShillManagerClient::Create( 293 ShillManagerClient* ShillManagerClient::Create(
267 DBusClientImplementationType type, 294 DBusClientImplementationType type,
268 dbus::Bus* bus) { 295 dbus::Bus* bus) {
269 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) 296 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION)
270 return new ShillManagerClientImpl(bus); 297 return new ShillManagerClientImpl(bus);
271 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); 298 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type);
272 return new ShillManagerClientStub(); 299 return new ShillManagerClientStub();
273 } 300 }
274 301
275 } // namespace chromeos 302 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698