diff options
19 files changed, 74 insertions, 52 deletions
diff --git a/chrome/browser/chromeos/login/helper.cc b/chrome/browser/chromeos/login/helper.cc index f4345f4..ae74d166 100644 --- a/chrome/browser/chromeos/login/helper.cc +++ b/chrome/browser/chromeos/login/helper.cc @@ -200,7 +200,8 @@ bool NetworkStateHelper::IsConnecting() const { void NetworkStateHelper::OnCreateConfiguration( const base::Closure& success_callback, const base::Closure& error_callback, - const std::string& service_path) const { + const std::string& service_path, + const std::string& guid) const { // Connect to the network. NetworkHandler::Get()->network_connection_handler()->ConnectToNetwork( service_path, success_callback, diff --git a/chrome/browser/chromeos/login/helper.h b/chrome/browser/chromeos/login/helper.h index dd5f2b4..231540f 100644 --- a/chrome/browser/chromeos/login/helper.h +++ b/chrome/browser/chromeos/login/helper.h @@ -86,7 +86,8 @@ class NetworkStateHelper { private: void OnCreateConfiguration(const base::Closure& success_callback, const base::Closure& error_callback, - const std::string& service_path) const; + const std::string& service_path, + const std::string& guid) const; void OnCreateOrConnectNetworkFailed( const base::Closure& error_callback, const std::string& error_name, diff --git a/chrome/browser/chromeos/net/onc_utils.cc b/chrome/browser/chromeos/net/onc_utils.cc index 36c5df8..22bec70 100644 --- a/chrome/browser/chromeos/net/onc_utils.cc +++ b/chrome/browser/chromeos/net/onc_utils.cc @@ -141,7 +141,7 @@ void ImportNetworksForUser(const user_manager::User* user, } else { config_handler->CreateShillConfiguration( *shill_dict, NetworkConfigurationObserver::SOURCE_USER_ACTION, - network_handler::StringResultCallback(), + network_handler::ServiceResultCallback(), network_handler::ErrorCallback()); } } diff --git a/chrome/browser/extensions/api/vpn_provider/vpn_provider_apitest.cc b/chrome/browser/extensions/api/vpn_provider/vpn_provider_apitest.cc index b45809c..3a772db 100644 --- a/chrome/browser/extensions/api/vpn_provider/vpn_provider_apitest.cc +++ b/chrome/browser/extensions/api/vpn_provider/vpn_provider_apitest.cc @@ -61,8 +61,8 @@ void DoNothingFailureCallback(const std::string& error_name, EXPECT_EQ(true, false); } -void DoNothingSuccessCallback(const std::string& service_path) { -} +void DoNothingSuccessCallback(const std::string& service_path, + const std::string& guid) {} } // namespace diff --git a/chrome/browser/sync/test/integration/wifi_credentials_helper_chromeos.cc b/chrome/browser/sync/test/integration/wifi_credentials_helper_chromeos.cc index 7117f19..6f7e3a6 100644 --- a/chrome/browser/sync/test/integration/wifi_credentials_helper_chromeos.cc +++ b/chrome/browser/sync/test/integration/wifi_credentials_helper_chromeos.cc @@ -106,14 +106,12 @@ void AddWifiCredentialToProfileChromeOs( credential.ToOncProperties(); CHECK(onc_properties) << "Failed to generate ONC properties for " << credential.ToString(); - GetManagedNetworkConfigurationHandler() - ->CreateConfiguration( - ChromeOsUserHashForBrowserContext(*browser_context), - *onc_properties, - ::chromeos::network_handler::StringResultCallback(), - base::Bind(LogCreateConfigurationFailure, - base::StringPrintf("Failed to add credential %s", - credential.ToString().c_str()))); + GetManagedNetworkConfigurationHandler()->CreateConfiguration( + ChromeOsUserHashForBrowserContext(*browser_context), *onc_properties, + ::chromeos::network_handler::ServiceResultCallback(), + base::Bind(LogCreateConfigurationFailure, + base::StringPrintf("Failed to add credential %s", + credential.ToString().c_str()))); base::MessageLoop::current()->RunUntilIdle(); } 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, diff --git a/components/wifi_sync/wifi_config_delegate_chromeos.cc b/components/wifi_sync/wifi_config_delegate_chromeos.cc index d8d241f..780dd1e 100644 --- a/components/wifi_sync/wifi_config_delegate_chromeos.cc +++ b/components/wifi_sync/wifi_config_delegate_chromeos.cc @@ -50,12 +50,10 @@ void WifiConfigDelegateChromeOs::AddToLocalNetworks( return; } - managed_network_configuration_handler_ - ->CreateConfiguration( - user_hash_, - *onc_properties, - chromeos::network_handler::StringResultCallback(), - base::Bind(OnCreateConfigurationFailed, network_credential)); + managed_network_configuration_handler_->CreateConfiguration( + user_hash_, *onc_properties, + chromeos::network_handler::ServiceResultCallback(), + base::Bind(OnCreateConfigurationFailed, network_credential)); } } // namespace wifi_sync diff --git a/components/wifi_sync/wifi_config_delegate_chromeos_unittest.cc b/components/wifi_sync/wifi_config_delegate_chromeos_unittest.cc index e1996eb..a9e14cd 100644 --- a/components/wifi_sync/wifi_config_delegate_chromeos_unittest.cc +++ b/components/wifi_sync/wifi_config_delegate_chromeos_unittest.cc @@ -24,7 +24,7 @@ const char kUserHash[] = "fake-user-hash"; using chromeos::network_handler::DictionaryResultCallback; using chromeos::network_handler::ErrorCallback; -using chromeos::network_handler::StringResultCallback; +using chromeos::network_handler::ServiceResultCallback; class FakeManagedNetworkConfigurationHandler : public chromeos::ManagedNetworkConfigurationHandler { @@ -61,11 +61,10 @@ class FakeManagedNetworkConfigurationHandler const ErrorCallback& error_callback) override { NOTIMPLEMENTED(); } - void CreateConfiguration( - const std::string& userhash, - const base::DictionaryValue& properties, - const StringResultCallback& callback, - const ErrorCallback& error_callback) const override { + void CreateConfiguration(const std::string& userhash, + const base::DictionaryValue& properties, + const ServiceResultCallback& callback, + const ErrorCallback& error_callback) const override { EXPECT_FALSE(create_configuration_called_); create_configuration_called_ = true; create_configuration_success_callback_ = callback; @@ -115,7 +114,7 @@ class FakeManagedNetworkConfigurationHandler bool create_configuration_called() const { return create_configuration_called_; } - const StringResultCallback& create_configuration_success_callback() const { + const ServiceResultCallback& create_configuration_success_callback() const { return create_configuration_success_callback_; } const ErrorCallback& create_configuration_error_callback() const { @@ -126,7 +125,7 @@ class FakeManagedNetworkConfigurationHandler // Whether or not CreateConfiguration has been called on this fake. mutable bool create_configuration_called_; // The last |callback| passed to CreateConfiguration. - mutable StringResultCallback create_configuration_success_callback_; + mutable ServiceResultCallback create_configuration_success_callback_; // The last |error_callback| passed to CreateConfiguration. mutable ErrorCallback create_configuration_error_callback_; }; @@ -164,11 +163,11 @@ class WifiConfigDelegateChromeOsTest : public testing::Test { // that |callback| is null. void RunCreateConfigurationSuccessCallback() { const char new_service_path[] = "/service/0"; - const StringResultCallback callback = + const ServiceResultCallback callback = fake_managed_network_configuration_handler_ - ->create_configuration_success_callback(); + ->create_configuration_success_callback(); if (!callback.is_null()) - callback.Run(new_service_path); + callback.Run(new_service_path, nullptr); } // Returns whether or not CreateConfiguration has been called diff --git a/extensions/browser/api/networking_private/networking_private_chromeos.cc b/extensions/browser/api/networking_private/networking_private_chromeos.cc index 5754f37..a710848 100644 --- a/extensions/browser/api/networking_private/networking_private_chromeos.cc +++ b/extensions/browser/api/networking_private/networking_private_chromeos.cc @@ -302,6 +302,13 @@ void NetworkingPrivateChromeOS::SetProperties( base::Bind(&NetworkHandlerFailureCallback, failure_callback)); } +void NetworkHandlerCreateCallback( + const NetworkingPrivateDelegate::StringCallback& callback, + const std::string& service_path, + const std::string& guid) { + callback.Run(guid); +} + void NetworkingPrivateChromeOS::CreateNetwork( bool shared, scoped_ptr<base::DictionaryValue> properties, @@ -316,7 +323,8 @@ void NetworkingPrivateChromeOS::CreateNetwork( } GetManagedConfigurationHandler()->CreateConfiguration( - user_id_hash, *properties, success_callback, + user_id_hash, *properties, + base::Bind(&NetworkHandlerCreateCallback, success_callback), base::Bind(&NetworkHandlerFailureCallback, failure_callback)); } diff --git a/extensions/browser/api/vpn_provider/vpn_service.cc b/extensions/browser/api/vpn_provider/vpn_service.cc index 1214a3b..7293f70 100644 --- a/extensions/browser/api/vpn_provider/vpn_service.cc +++ b/extensions/browser/api/vpn_provider/vpn_service.cc @@ -494,7 +494,8 @@ void VpnService::OnExtensionUnloaded( void VpnService::OnCreateConfigurationSuccess( const VpnService::SuccessCallback& callback, VpnConfiguration* configuration, - const std::string& service_path) { + const std::string& service_path, + const std::string& guid) { configuration->set_service_path(service_path); service_path_to_configuration_map_[service_path] = configuration; shill_client_->AddShillThirdPartyVpnObserver(configuration->object_path(), diff --git a/extensions/browser/api/vpn_provider/vpn_service.h b/extensions/browser/api/vpn_provider/vpn_service.h index 7aa1dc2..6e515c9 100644 --- a/extensions/browser/api/vpn_provider/vpn_service.h +++ b/extensions/browser/api/vpn_provider/vpn_service.h @@ -170,7 +170,8 @@ class VpnService : public KeyedService, // Callback used to indicate that configuration was successfully created. void OnCreateConfigurationSuccess(const SuccessCallback& callback, VpnConfiguration* configuration, - const std::string& service_path); + const std::string& service_path, + const std::string& guid); // Callback used to indicate that configuration creation failed. void OnCreateConfigurationFailure( diff --git a/ui/chromeos/network/network_connect.cc b/ui/chromeos/network/network_connect.cc index 6fa57bc..f00b9f8 100644 --- a/ui/chromeos/network/network_connect.cc +++ b/ui/chromeos/network/network_connect.cc @@ -99,7 +99,8 @@ class NetworkConnectImpl : public NetworkConnect { void OnConfigureFailed(const std::string& error_name, scoped_ptr<base::DictionaryValue> error_data); void OnConfigureSucceeded(bool connect_on_configure, - const std::string& service_path); + const std::string& service_path, + const std::string& guid); void CallCreateConfiguration(base::DictionaryValue* properties, bool shared, bool connect_on_configure); @@ -284,7 +285,8 @@ void NetworkConnectImpl::OnConfigureFailed( } void NetworkConnectImpl::OnConfigureSucceeded(bool connect_on_configure, - const std::string& service_path) { + const std::string& service_path, + const std::string& guid) { NET_LOG_USER("Configure Succeeded", service_path); if (!connect_on_configure) return; |