summaryrefslogtreecommitdiffstats
path: root/chromeos
diff options
context:
space:
mode:
authorcernekee <cernekee@chromium.org>2016-03-15 16:33:03 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-15 23:35:10 +0000
commitf1da84b10359d62c67a73e46da90b0d0510a0768 (patch)
tree26e92834631e010954b80a4cada4a6b6efd4f8bd /chromeos
parenta3a50c140c60eb242df3dd4df06fe55cad117c75 (diff)
downloadchromium_src-f1da84b10359d62c67a73e46da90b0d0510a0768.zip
chromium_src-f1da84b10359d62c67a73e46da90b0d0510a0768.tar.gz
chromium_src-f1da84b10359d62c67a73e46da90b0d0510a0768.tar.bz2
Invoke createNetwork() callback with GUID, not service name
The current implementation doesn't match the API spec. Fix this. BUG=593196 TEST=go to chrome://settings/network , ctrl-shift-i, run in console: chrome.networkingPrivate.createNetwork(false, {"Type":"WiFi","WiFi":{"SSID":"GoogleGuest","AutoConnect":true}}, function(x) { console.log(x); }) Review URL: https://codereview.chromium.org/1779633002 Cr-Commit-Position: refs/heads/master@{#381347}
Diffstat (limited to 'chromeos')
-rw-r--r--chromeos/network/managed_network_configuration_handler.h2
-rw-r--r--chromeos/network/managed_network_configuration_handler_impl.cc5
-rw-r--r--chromeos/network/managed_network_configuration_handler_impl.h5
-rw-r--r--chromeos/network/mock_managed_network_configuration_handler.h2
-rw-r--r--chromeos/network/network_configuration_handler.cc13
-rw-r--r--chromeos/network/network_configuration_handler.h4
-rw-r--r--chromeos/network/network_configuration_handler_unittest.cc12
-rw-r--r--chromeos/network/network_handler_callbacks.h4
8 files changed, 30 insertions, 17 deletions
diff --git a/chromeos/network/managed_network_configuration_handler.h b/chromeos/network/managed_network_configuration_handler.h
index 172dc0b..40ba923 100644
--- a/chromeos/network/managed_network_configuration_handler.h
+++ b/chromeos/network/managed_network_configuration_handler.h
@@ -100,7 +100,7 @@ class CHROMEOS_EXPORT ManagedNetworkConfigurationHandler {
virtual void CreateConfiguration(
const std::string& userhash,
const base::DictionaryValue& properties,
- const network_handler::StringResultCallback& callback,
+ const network_handler::ServiceResultCallback& callback,
const network_handler::ErrorCallback& error_callback) const = 0;
// Removes the user's configuration from the network with |service_path|. The
diff --git a/chromeos/network/managed_network_configuration_handler_impl.cc b/chromeos/network/managed_network_configuration_handler_impl.cc
index cdbc963..4574f77 100644
--- a/chromeos/network/managed_network_configuration_handler_impl.cc
+++ b/chromeos/network/managed_network_configuration_handler_impl.cc
@@ -358,7 +358,7 @@ void ManagedNetworkConfigurationHandlerImpl::SetShillProperties(
void ManagedNetworkConfigurationHandlerImpl::CreateConfiguration(
const std::string& userhash,
const base::DictionaryValue& properties,
- const network_handler::StringResultCallback& callback,
+ const network_handler::ServiceResultCallback& callback,
const network_handler::ErrorCallback& error_callback) const {
const Policies* policies = GetPoliciesForUser(userhash);
if (!policies) {
@@ -735,7 +735,8 @@ void ManagedNetworkConfigurationHandlerImpl::Init(
}
void ManagedNetworkConfigurationHandlerImpl::OnPolicyAppliedToNetwork(
- const std::string& service_path) {
+ const std::string& service_path,
+ const std::string& guid) {
if (service_path.empty())
return;
FOR_EACH_OBSERVER(
diff --git a/chromeos/network/managed_network_configuration_handler_impl.h b/chromeos/network/managed_network_configuration_handler_impl.h
index a6337f3..c94e446 100644
--- a/chromeos/network/managed_network_configuration_handler_impl.h
+++ b/chromeos/network/managed_network_configuration_handler_impl.h
@@ -62,7 +62,7 @@ class CHROMEOS_EXPORT ManagedNetworkConfigurationHandlerImpl
void CreateConfiguration(
const std::string& userhash,
const base::DictionaryValue& properties,
- const network_handler::StringResultCallback& callback,
+ const network_handler::ServiceResultCallback& callback,
const network_handler::ErrorCallback& error_callback) const override;
void RemoveConfiguration(
@@ -152,7 +152,8 @@ class CHROMEOS_EXPORT ManagedNetworkConfigurationHandlerImpl
const Policies* GetPoliciesForUser(const std::string& userhash) const;
const Policies* GetPoliciesForProfile(const NetworkProfile& profile) const;
- void OnPolicyAppliedToNetwork(const std::string& service_path);
+ void OnPolicyAppliedToNetwork(const std::string& service_path,
+ const std::string& guid);
// Helper method to append associated Device properties to |properties|.
void GetDeviceStateProperties(const std::string& service_path,
diff --git a/chromeos/network/mock_managed_network_configuration_handler.h b/chromeos/network/mock_managed_network_configuration_handler.h
index 812dfc3..140f7d8 100644
--- a/chromeos/network/mock_managed_network_configuration_handler.h
+++ b/chromeos/network/mock_managed_network_configuration_handler.h
@@ -43,7 +43,7 @@ class CHROMEOS_EXPORT MockManagedNetworkConfigurationHandler
CreateConfiguration,
void(const std::string& userhash,
const base::DictionaryValue& properties,
- const network_handler::StringResultCallback& callback,
+ const network_handler::ServiceResultCallback& callback,
const network_handler::ErrorCallback& error_callback));
MOCK_CONST_METHOD3(
RemoveConfiguration,
diff --git a/chromeos/network/network_configuration_handler.cc b/chromeos/network/network_configuration_handler.cc
index 4caf50c..0cb32db 100644
--- a/chromeos/network/network_configuration_handler.cc
+++ b/chromeos/network/network_configuration_handler.cc
@@ -279,7 +279,7 @@ void NetworkConfigurationHandler::ClearShillProperties(
void NetworkConfigurationHandler::CreateShillConfiguration(
const base::DictionaryValue& shill_properties,
NetworkConfigurationObserver::Source source,
- const network_handler::StringResultCallback& callback,
+ const network_handler::ServiceResultCallback& callback,
const network_handler::ErrorCallback& error_callback) {
ShillManagerClient* manager =
DBusThreadManager::Get()->GetShillManagerClient();
@@ -393,10 +393,15 @@ void NetworkConfigurationHandler::RunCreateNetworkCallback(
const std::string& profile_path,
NetworkConfigurationObserver::Source source,
scoped_ptr<base::DictionaryValue> configure_properties,
- const network_handler::StringResultCallback& callback,
+ const network_handler::ServiceResultCallback& callback,
const dbus::ObjectPath& service_path) {
- if (!callback.is_null())
- callback.Run(service_path.value());
+ if (!callback.is_null()) {
+ std::string guid;
+ configure_properties->GetStringWithoutPathExpansion(
+ ::onc::network_config::kGUID, &guid);
+ DCHECK(!guid.empty());
+ callback.Run(service_path.value(), guid);
+ }
FOR_EACH_OBSERVER(NetworkConfigurationObserver, observers_,
OnConfigurationCreated(service_path.value(), profile_path,
*configure_properties, source));
diff --git a/chromeos/network/network_configuration_handler.h b/chromeos/network/network_configuration_handler.h
index d76be19..b2e85be 100644
--- a/chromeos/network/network_configuration_handler.h
+++ b/chromeos/network/network_configuration_handler.h
@@ -103,7 +103,7 @@ class CHROMEOS_EXPORT NetworkConfigurationHandler
void CreateShillConfiguration(
const base::DictionaryValue& shill_properties,
NetworkConfigurationObserver::Source source,
- const network_handler::StringResultCallback& callback,
+ const network_handler::ServiceResultCallback& callback,
const network_handler::ErrorCallback& error_callback);
// Removes the network |service_path| from any profiles that include it.
@@ -142,7 +142,7 @@ class CHROMEOS_EXPORT NetworkConfigurationHandler
const std::string& profile_path,
NetworkConfigurationObserver::Source source,
scoped_ptr<base::DictionaryValue> configure_properties,
- const network_handler::StringResultCallback& callback,
+ const network_handler::ServiceResultCallback& callback,
const dbus::ObjectPath& service_path);
// Called from ProfileEntryDeleter instances when they complete causing
diff --git a/chromeos/network/network_configuration_handler_unittest.cc b/chromeos/network/network_configuration_handler_unittest.cc
index a5be195..cc8b3ee 100644
--- a/chromeos/network/network_configuration_handler_unittest.cc
+++ b/chromeos/network/network_configuration_handler_unittest.cc
@@ -73,9 +73,10 @@ void ErrorCallback(bool error_expected,
<< PrettyJson(*error_data);
}
-void StringResultCallback(const std::string& expected_result,
- const std::string& result) {
- EXPECT_EQ(expected_result, result);
+void ServiceResultCallback(const std::string& expected_result,
+ const std::string& service_path,
+ const std::string& guid) {
+ EXPECT_EQ(expected_result, service_path);
}
void DBusErrorCallback(const std::string& error_name,
@@ -286,7 +287,7 @@ class NetworkConfigurationHandlerTest : public testing::Test {
const base::DictionaryValue& properties) {
network_configuration_handler_->CreateShillConfiguration(
properties, NetworkConfigurationObserver::SOURCE_USER_ACTION,
- base::Bind(&StringResultCallback, service_path),
+ base::Bind(&ServiceResultCallback, service_path),
base::Bind(&ErrorCallback, false, std::string()));
}
@@ -525,7 +526,8 @@ class NetworkConfigurationHandlerStubTest : public testing::Test {
get_properties_.reset(dictionary.DeepCopy());
}
- void CreateConfigurationCallback(const std::string& service_path) {
+ void CreateConfigurationCallback(const std::string& service_path,
+ const std::string& guid) {
create_service_path_ = service_path;
}
diff --git a/chromeos/network/network_handler_callbacks.h b/chromeos/network/network_handler_callbacks.h
index 3135bf9..b63a0af 100644
--- a/chromeos/network/network_handler_callbacks.h
+++ b/chromeos/network/network_handler_callbacks.h
@@ -39,6 +39,10 @@ typedef base::Callback<
typedef base::Callback<
void(const std::string& service_path)> StringResultCallback;
+typedef base::Callback<void(const std::string& service_path,
+ const std::string& guid)>
+ ServiceResultCallback;
+
// Create a DictionaryValue for passing to ErrorCallback.
CHROMEOS_EXPORT base::DictionaryValue* CreateErrorData(
const std::string& path,