Index: chrome/browser/sync/test/integration/wifi_credentials_helper_chromeos.cc |
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 8e5400247c21808abee5edcbbdf3b236208d1440..c50fa4af12579e5d9f26fb7edd1e619e62313b8c 100644 |
--- a/chrome/browser/sync/test/integration/wifi_credentials_helper_chromeos.cc |
+++ b/chrome/browser/sync/test/integration/wifi_credentials_helper_chromeos.cc |
@@ -6,14 +6,22 @@ |
#include <string> |
+#include "base/bind.h" |
#include "base/files/file_path.h" |
#include "base/logging.h" |
+#include "base/strings/stringprintf.h" |
+#include "base/values.h" |
#include "chrome/browser/profiles/profile.h" |
+#include "chromeos/dbus/dbus_thread_manager.h" |
+#include "chromeos/dbus/shill_profile_client.h" |
+#include "chromeos/network/managed_network_configuration_handler.h" |
#include "chromeos/network/network_handler.h" |
-#include "chromeos/network/network_state.h" |
#include "chromeos/network/network_state_handler.h" |
+#include "components/onc/onc_constants.h" |
#include "components/wifi_sync/network_state_helper_chromeos.h" |
-#include "components/wifi_sync/wifi_security_class.h" |
+#include "components/wifi_sync/wifi_config_delegate_factory_chromeos.h" |
+ |
+using wifi_sync::WifiCredential; |
using WifiCredentialSet = wifi_sync::WifiCredential::CredentialSet; |
@@ -23,6 +31,15 @@ namespace { |
const char kProfilePrefix[] = "/profile/"; |
+void DoNothingWithString(const std::string&) {} |
+ |
+void LogCreateConfigurationFailure( |
+ const std::string& debug_hint, |
+ const std::string& /* network_config_error_message */, |
+ scoped_ptr<base::DictionaryValue> /* network_config_error_data */) { |
+ LOG(FATAL) << debug_hint; |
+} |
+ |
std::string ChromeOsUserHashForBrowserContext( |
const content::BrowserContext& context) { |
return context.GetPath().BaseName().value(); |
@@ -33,6 +50,23 @@ std::string ShillProfilePathForBrowserContext( |
return kProfilePrefix + ChromeOsUserHashForBrowserContext(context); |
} |
+chromeos::ShillProfileClient::TestInterface* |
+GetShillProfileClientTestInterface() { |
+ DCHECK(chromeos::DBusThreadManager::Get()->GetShillProfileClient()); |
+ DCHECK(chromeos::DBusThreadManager::Get()->GetShillProfileClient() |
+ ->GetTestInterface()); |
+ return chromeos::DBusThreadManager::Get()->GetShillProfileClient() |
+ ->GetTestInterface(); |
+} |
+ |
+chromeos::ManagedNetworkConfigurationHandler* |
+GetManagedNetworkConfigurationHandler() { |
+ DCHECK(chromeos::NetworkHandler::Get() |
+ ->managed_network_configuration_handler()); |
+ return chromeos::NetworkHandler::Get() |
+ ->managed_network_configuration_handler(); |
+} |
+ |
chromeos::NetworkStateHandler* GetNetworkStateHandler() { |
DCHECK(chromeos::NetworkHandler::Get()->network_state_handler()); |
return chromeos::NetworkHandler::Get()->network_state_handler(); |
@@ -40,6 +74,41 @@ chromeos::NetworkStateHandler* GetNetworkStateHandler() { |
} // namespace |
+void SetUpChromeOs() { |
+ wifi_sync::WifiConfigDelegateFactoryChromeOs::GetInstance() |
+ ->SetUseLoginState(false); |
+} |
+ |
+bool SetupClientForProfileChromeOs(const Profile* profile) { |
+ DCHECK(profile); |
+ GetShillProfileClientTestInterface() |
+ ->AddProfile(ShillProfilePathForBrowserContext(*profile), |
+ ChromeOsUserHashForBrowserContext(*profile)); |
+ |
+ const base::ListValue policy_network_configs; |
+ const base::DictionaryValue policy_global_config; |
+ GetManagedNetworkConfigurationHandler() |
+ ->SetPolicy(onc::ONC_SOURCE_UNKNOWN, |
+ ChromeOsUserHashForBrowserContext(*profile), |
+ policy_network_configs, |
+ policy_global_config); |
+ |
+ return true; |
+} |
+ |
+void AddWifiCredentialToProfileChromeOs( |
+ Profile* profile, const WifiCredential& credential) { |
+ DCHECK(profile); |
+ wifi_sync::CreateWifiNetworkInShillUserProfile( |
+ GetManagedNetworkConfigurationHandler(), |
+ ChromeOsUserHashForBrowserContext(*profile), |
+ credential, |
+ base::Bind(DoNothingWithString), // success_callback |
+ base::Bind(LogCreateConfigurationFailure, |
+ base::StringPrintf("Failed to add credential %s", |
+ credential.ToString().c_str()))); |
+} |
+ |
WifiCredentialSet GetWifiCredentialsForProfileChromeOs(const Profile* profile) { |
DCHECK(profile); |
return wifi_sync::GetWifiCredentialsForShillProfile( |