| Index: chromeos/dbus/shill_manager_client.cc
|
| diff --git a/chromeos/dbus/shill_manager_client.cc b/chromeos/dbus/shill_manager_client.cc
|
| index 1be4bf22b04a1801d286489a89bb41974afb0ec4..c5f05ff1e3e253c4a4de2a6b1d0c742afc5ec6bb 100644
|
| --- a/chromeos/dbus/shill_manager_client.cc
|
| +++ b/chromeos/dbus/shill_manager_client.cc
|
| @@ -6,6 +6,7 @@
|
|
|
| #include "base/bind.h"
|
| #include "base/chromeos/chromeos_version.h"
|
| +#include "base/logging.h"
|
| #include "base/message_loop.h"
|
| #include "base/values.h"
|
| #include "chromeos/dbus/shill_manager_client_stub.h"
|
| @@ -21,13 +22,41 @@ namespace chromeos {
|
|
|
| namespace {
|
|
|
| +const char kIncompleteServiceProperties[] = "Error.IncompleteServiceProperties";
|
| +const char kIncompleteServicePropertiesMessage[] =
|
| + "Service properties are incomplete.";
|
| +
|
| // Returns whether the properties have the required keys or not.
|
| -bool AreServicePropertiesValid(const base::DictionaryValue& properties) {
|
| - if (properties.HasKey(flimflam::kGuidProperty))
|
| +bool AreServicePropertiesValidWithMode(
|
| + const base::DictionaryValue& properties,
|
| + const ShillManagerClient::ErrorCallback& error_callback) {
|
| + if (properties.HasKey(flimflam::kGuidProperty) ||
|
| + (properties.HasKey(flimflam::kTypeProperty) &&
|
| + properties.HasKey(flimflam::kSecurityProperty) &&
|
| + properties.HasKey(flimflam::kModeProperty) &&
|
| + properties.HasKey(flimflam::kSSIDProperty))) {
|
| return true;
|
| - return properties.HasKey(flimflam::kTypeProperty) &&
|
| - properties.HasKey(flimflam::kSecurityProperty) &&
|
| - properties.HasKey(flimflam::kSSIDProperty);
|
| + }
|
| + error_callback.Run(kIncompleteServiceProperties,
|
| + kIncompleteServicePropertiesMessage);
|
| + return false;
|
| +}
|
| +
|
| +// DEPRECATED: Keep this only for backward compatibility with NetworkLibrary.
|
| +// Returns whether the properties have the required keys or not.
|
| +// TODO(pneubeck): remove this once NetworkLibrary is gone (crbug/230799).
|
| +bool AreServicePropertiesValid(
|
| + const base::DictionaryValue& properties,
|
| + const ShillManagerClient::ErrorCallback& error_callback) {
|
| + if (properties.HasKey(flimflam::kGuidProperty) ||
|
| + (properties.HasKey(flimflam::kTypeProperty) &&
|
| + properties.HasKey(flimflam::kSecurityProperty) &&
|
| + properties.HasKey(flimflam::kSSIDProperty))) {
|
| + return true;
|
| + }
|
| + error_callback.Run(kIncompleteServiceProperties,
|
| + kIncompleteServicePropertiesMessage);
|
| + return false;
|
| }
|
|
|
| // Appends a string-to-variant dictionary to the writer.
|
| @@ -146,7 +175,10 @@ class ShillManagerClientImpl : public ShillManagerClient {
|
| const base::DictionaryValue& properties,
|
| const ObjectPathCallback& callback,
|
| const ErrorCallback& error_callback) OVERRIDE {
|
| - DCHECK(AreServicePropertiesValid(properties));
|
| + if (!AreServicePropertiesValid(properties, error_callback)) {
|
| + NOTREACHED() << kIncompleteServicePropertiesMessage;
|
| + return;
|
| + }
|
| dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface,
|
| flimflam::kConfigureServiceFunction);
|
| dbus::MessageWriter writer(&method_call);
|
| @@ -156,6 +188,25 @@ class ShillManagerClientImpl : public ShillManagerClient {
|
| error_callback);
|
| }
|
|
|
| + virtual void ConfigureServiceForProfile(
|
| + const dbus::ObjectPath& profile_path,
|
| + const base::DictionaryValue& properties,
|
| + const ObjectPathCallback& callback,
|
| + const ErrorCallback& error_callback) OVERRIDE {
|
| + if (!AreServicePropertiesValidWithMode(properties, error_callback)) {
|
| + NOTREACHED() << kIncompleteServicePropertiesMessage;
|
| + return;
|
| + }
|
| + dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface,
|
| + shill::kConfigureServiceForProfileFunction);
|
| + dbus::MessageWriter writer(&method_call);
|
| + writer.AppendObjectPath(dbus::ObjectPath(profile_path));
|
| + AppendServicePropertiesDictionary(&writer, properties);
|
| + helper_.CallObjectPathMethodWithErrorCallback(&method_call,
|
| + callback,
|
| + error_callback);
|
| + }
|
| +
|
| virtual void GetService(
|
| const base::DictionaryValue& properties,
|
| const ObjectPathCallback& callback,
|
|
|