Index: chrome/browser/automation/testing_automation_provider_chromeos.cc |
diff --git a/chrome/browser/automation/testing_automation_provider_chromeos.cc b/chrome/browser/automation/testing_automation_provider_chromeos.cc |
index f1b91d550194e6d5bbaaa2f73a9ee26101ff0040..f98c4e80f95268701537a280783a683e68dc5671 100644 |
--- a/chrome/browser/automation/testing_automation_provider_chromeos.cc |
+++ b/chrome/browser/automation/testing_automation_provider_chromeos.cc |
@@ -632,128 +632,6 @@ void TestingAutomationProvider::ToggleNetworkDevice( |
} |
} |
-void TestingAutomationProvider::SetSharedProxies( |
- DictionaryValue* args, |
- IPC::Message* reply_message) { |
- |
- AutomationJSONReply reply(this, reply_message); |
- base::Value* value; |
- if (!args->Get("value", &value)) { |
- reply.SendError("Invalid or missing value argument."); |
- return; |
- } |
- std::string error_message; |
- Profile* profile = |
- automation_util::GetCurrentProfileOnChromeOS(&error_message); |
- if (!profile) { |
- reply.SendError(error_message); |
- return; |
- } |
- PrefService* pref_service = profile->GetPrefs(); |
- pref_service->Set(prefs::kUseSharedProxies, *value); |
- reply.SendSuccess(NULL); |
-} |
- |
-void TestingAutomationProvider::SetProxySettings(DictionaryValue* args, |
- IPC::Message* reply_message) { |
- AutomationJSONReply reply(this, reply_message); |
- std::string proxy_config_str; |
- if (!args->GetString("proxy_config", &proxy_config_str)) { |
- reply.SendError("Invalid or missing args."); |
- return; |
- } |
- |
- const chromeos::NetworkState* network = chromeos::NetworkHandler::Get()-> |
- network_state_handler()->DefaultNetwork(); |
- if (!network) { |
- reply.SendError("No network connected."); |
- return; |
- } |
- |
- scoped_ptr<base::DictionaryValue> proxy_config_dict( |
- chromeos::onc::ReadDictionaryFromJson(proxy_config_str)); |
- ProxyConfigDictionary proxy_config(proxy_config_dict.get()); |
- chromeos::proxy_config::SetProxyConfigForNetwork(proxy_config, *network); |
- |
- reply.SendSuccess(NULL); |
-} |
- |
-void TestingAutomationProvider::ConnectToCellularNetwork( |
- DictionaryValue* args, IPC::Message* reply_message) { |
- std::string service_path; |
- if (!args->GetString("service_path", &service_path)) { |
- AutomationJSONReply(this, reply_message).SendError( |
- "Invalid or missing args."); |
- return; |
- } |
- |
- NetworkLibrary* network_library = NetworkLibrary::Get(); |
- chromeos::CellularNetwork* cellular = |
- network_library->FindCellularNetworkByPath(service_path); |
- if (!cellular) { |
- AutomationJSONReply(this, reply_message).SendError( |
- "No network found with specified service path."); |
- return; |
- } |
- |
- // Set up an observer (it will delete itself). |
- new ServicePathConnectObserver(this, reply_message, service_path); |
- |
- network_library->ConnectToCellularNetwork(cellular); |
- network_library->RequestNetworkScan(); |
-} |
- |
-void TestingAutomationProvider::DisconnectFromCellularNetwork( |
- DictionaryValue* args, IPC::Message* reply_message) { |
- NetworkLibrary* network_library = NetworkLibrary::Get(); |
- const chromeos::CellularNetwork* cellular = |
- network_library->cellular_network(); |
- if (!cellular) { |
- AutomationJSONReply(this, reply_message).SendError( |
- "Not connected to any cellular network."); |
- return; |
- } |
- |
- // Set up an observer (it will delete itself). |
- new NetworkDisconnectObserver(this, reply_message, cellular->service_path()); |
- |
- network_library->DisconnectFromNetwork(cellular); |
-} |
- |
-void TestingAutomationProvider::ConnectToWifiNetwork( |
- DictionaryValue* args, IPC::Message* reply_message) { |
- AutomationJSONReply reply(this, reply_message); |
- std::string service_path, password; |
- bool shared; |
- if (!args->GetString("service_path", &service_path) || |
- !args->GetString("password", &password) || |
- !args->GetBoolean("shared", &shared)) { |
- reply.SendError("Invalid or missing args."); |
- return; |
- } |
- |
- NetworkLibrary* network_library = NetworkLibrary::Get(); |
- chromeos::WifiNetwork* wifi = |
- network_library->FindWifiNetworkByPath(service_path); |
- if (!wifi) { |
- reply.SendError("No network found with specified service path."); |
- return; |
- } |
- if (!password.empty()) |
- wifi->SetPassphrase(password); |
- |
- // Regardless of what was passed, if the network is open and visible, |
- // the network must be shared because of a UI restriction. |
- if (wifi->encryption() == chromeos::SECURITY_NONE) |
- shared = true; |
- |
- // Set up an observer (it will delete itself). |
- new ServicePathConnectObserver(this, reply_message, service_path); |
- |
- network_library->ConnectToWifiNetwork(wifi, shared); |
- network_library->RequestNetworkScan(); |
-} |
- |
void TestingAutomationProvider::ForgetWifiNetwork( |
DictionaryValue* args, IPC::Message* reply_message) { |
std::string service_path; |
@@ -767,260 +645,6 @@ void TestingAutomationProvider::ForgetWifiNetwork( |
AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
} |
-void TestingAutomationProvider::ConnectToHiddenWifiNetwork( |
- DictionaryValue* args, IPC::Message* reply_message) { |
- std::string ssid, security, password; |
- bool shared; |
- if (!args->GetString("ssid", &ssid) || |
- !args->GetString("security", &security) || |
- !args->GetString("password", &password) || |
- !args->GetBoolean("shared", &shared)) { |
- AutomationJSONReply(this, reply_message).SendError( |
- "Invalid or missing args."); |
- return; |
- } |
- |
- std::map<std::string, chromeos::ConnectionSecurity> connection_security_map; |
- connection_security_map["SECURITY_NONE"] = chromeos::SECURITY_NONE; |
- connection_security_map["SECURITY_WEP"] = chromeos::SECURITY_WEP; |
- connection_security_map["SECURITY_WPA"] = chromeos::SECURITY_WPA; |
- connection_security_map["SECURITY_RSN"] = chromeos::SECURITY_RSN; |
- connection_security_map["SECURITY_8021X"] = chromeos::SECURITY_8021X; |
- |
- if (connection_security_map.find(security) == connection_security_map.end()) { |
- AutomationJSONReply(this, reply_message).SendError( |
- "Unknown security type."); |
- return; |
- } |
- chromeos::ConnectionSecurity connection_security = |
- connection_security_map[security]; |
- |
- NetworkLibrary* network_library = NetworkLibrary::Get(); |
- |
- // Set up an observer (it will delete itself). |
- new SSIDConnectObserver(this, reply_message, ssid); |
- |
- bool save_credentials = false; |
- |
- if (connection_security == chromeos::SECURITY_8021X) { |
- chromeos::NetworkLibrary::EAPConfigData config_data; |
- std::string eap_method, eap_auth, eap_identity; |
- if (!args->GetString("eap_method", &eap_method) || |
- !args->GetString("eap_auth", &eap_auth) || |
- !args->GetString("eap_identity", &eap_identity) || |
- !args->GetBoolean("save_credentials", &save_credentials)) { |
- AutomationJSONReply(this, reply_message).SendError( |
- "Invalid or missing EAP args."); |
- return; |
- } |
- |
- std::map<std::string, chromeos::EAPMethod> eap_method_map; |
- eap_method_map["EAP_METHOD_NONE"] = chromeos::EAP_METHOD_UNKNOWN; |
- eap_method_map["EAP_METHOD_PEAP"] = chromeos::EAP_METHOD_PEAP; |
- eap_method_map["EAP_METHOD_TLS"] = chromeos::EAP_METHOD_TLS; |
- eap_method_map["EAP_METHOD_TTLS"] = chromeos::EAP_METHOD_TTLS; |
- eap_method_map["EAP_METHOD_LEAP"] = chromeos::EAP_METHOD_LEAP; |
- if (eap_method_map.find(eap_method) == eap_method_map.end()) { |
- AutomationJSONReply(this, reply_message).SendError( |
- "Unknown EAP Method type."); |
- return; |
- } |
- config_data.method = eap_method_map[eap_method]; |
- |
- std::map<std::string, chromeos::EAPPhase2Auth> eap_auth_map; |
- eap_auth_map["EAP_PHASE_2_AUTH_AUTO"] = chromeos::EAP_PHASE_2_AUTH_AUTO; |
- eap_auth_map["EAP_PHASE_2_AUTH_MD5"] = chromeos::EAP_PHASE_2_AUTH_MD5; |
- eap_auth_map["EAP_PHASE_2_AUTH_MSCHAP"] = |
- chromeos::EAP_PHASE_2_AUTH_MSCHAP; |
- eap_auth_map["EAP_PHASE_2_AUTH_MSCHAPV2"] = |
- chromeos::EAP_PHASE_2_AUTH_MSCHAPV2; |
- eap_auth_map["EAP_PHASE_2_AUTH_PAP"] = chromeos::EAP_PHASE_2_AUTH_PAP; |
- eap_auth_map["EAP_PHASE_2_AUTH_CHAP"] = chromeos::EAP_PHASE_2_AUTH_CHAP; |
- if (eap_auth_map.find(eap_auth) == eap_auth_map.end()) { |
- AutomationJSONReply(this, reply_message).SendError( |
- "Unknown EAP Phase2 Auth type."); |
- return; |
- } |
- config_data.auth = eap_auth_map[eap_auth]; |
- |
- config_data.identity = eap_identity; |
- |
- // TODO(stevenjb): Parse cert values? |
- config_data.use_system_cas = false; |
- config_data.client_cert_pkcs11_id = ""; |
- |
- network_library->ConnectToUnconfiguredWifiNetwork( |
- ssid, chromeos::SECURITY_8021X, password, &config_data, |
- save_credentials, shared); |
- } else { |
- network_library->ConnectToUnconfiguredWifiNetwork( |
- ssid, connection_security, password, NULL, |
- save_credentials, shared); |
- } |
-} |
- |
-void TestingAutomationProvider::DisconnectFromWifiNetwork( |
- DictionaryValue* args, IPC::Message* reply_message) { |
- AutomationJSONReply reply(this, reply_message); |
- NetworkLibrary* network_library = NetworkLibrary::Get(); |
- const chromeos::WifiNetwork* wifi = network_library->wifi_network(); |
- if (!wifi) { |
- reply.SendError("Not connected to any wifi network."); |
- return; |
- } |
- |
- network_library->DisconnectFromNetwork(wifi); |
- reply.SendSuccess(NULL); |
-} |
- |
-void TestingAutomationProvider::AddPrivateNetwork( |
- DictionaryValue* args, IPC::Message* reply_message) { |
- std::string hostname, service_name, provider_type, key, cert_id, username, |
- password; |
- if (!args->GetString("hostname", &hostname) || |
- !args->GetString("service_name", &service_name) || |
- !args->GetString("provider_type", &provider_type) || |
- !args->GetString("username", &username) || |
- !args->GetString("password", &password)) { |
- AutomationJSONReply(this, reply_message) |
- .SendError("Invalid or missing args."); |
- return; |
- } |
- |
- NetworkLibrary* network_library = NetworkLibrary::Get(); |
- |
- // Attempt to connect to the VPN based on the provider type. |
- if (provider_type == VPNProviderTypeToString( |
- chromeos::PROVIDER_TYPE_L2TP_IPSEC_PSK)) { |
- if (!args->GetString("key", &key)) { |
- AutomationJSONReply(this, reply_message) |
- .SendError("Missing key arg."); |
- return; |
- } |
- new VirtualConnectObserver(this, reply_message, service_name); |
- // Connect using a pre-shared key. |
- chromeos::NetworkLibrary::VPNConfigData config_data; |
- config_data.psk = key; |
- config_data.username = username; |
- config_data.user_passphrase = password; |
- network_library->ConnectToUnconfiguredVirtualNetwork( |
- service_name, |
- hostname, |
- chromeos::PROVIDER_TYPE_L2TP_IPSEC_PSK, |
- config_data); |
- } else if (provider_type == VPNProviderTypeToString( |
- chromeos::PROVIDER_TYPE_L2TP_IPSEC_USER_CERT)) { |
- if (!args->GetString("cert_id", &cert_id)) { |
- AutomationJSONReply(this, reply_message) |
- .SendError("Missing a certificate arg."); |
- return; |
- } |
- new VirtualConnectObserver(this, reply_message, service_name); |
- // Connect using a user certificate. |
- chromeos::NetworkLibrary::VPNConfigData config_data; |
- config_data.client_cert_pkcs11_id = cert_id; |
- config_data.username = username; |
- config_data.user_passphrase = password; |
- network_library->ConnectToUnconfiguredVirtualNetwork( |
- service_name, |
- hostname, |
- chromeos::PROVIDER_TYPE_L2TP_IPSEC_USER_CERT, |
- config_data); |
- } else if (provider_type == VPNProviderTypeToString( |
- chromeos::PROVIDER_TYPE_OPEN_VPN)) { |
- std::string otp; |
- args->GetString("otp", &otp); |
- // Connect using OPEN_VPN. |
- chromeos::NetworkLibrary::VPNConfigData config_data; |
- config_data.client_cert_pkcs11_id = cert_id; |
- config_data.username = username; |
- config_data.user_passphrase = password; |
- config_data.otp = otp; |
- network_library->ConnectToUnconfiguredVirtualNetwork( |
- service_name, |
- hostname, |
- chromeos::PROVIDER_TYPE_OPEN_VPN, |
- config_data); |
- } else { |
- AutomationJSONReply(this, reply_message) |
- .SendError("Unsupported provider type."); |
- return; |
- } |
-} |
- |
-void TestingAutomationProvider::ConnectToPrivateNetwork( |
- DictionaryValue* args, IPC::Message* reply_message) { |
- AutomationJSONReply reply(this, reply_message); |
- std::string service_path; |
- if (!args->GetString("service_path", &service_path)) { |
- reply.SendError("Invalid or missing args."); |
- return; |
- } |
- |
- // Connect to a remembered VPN by its service_path. Valid service_paths |
- // can be found in the dictionary returned by GetPrivateNetworkInfo. |
- NetworkLibrary* network_library = NetworkLibrary::Get(); |
- chromeos::VirtualNetwork* network = |
- network_library->FindVirtualNetworkByPath(service_path); |
- if (!network) { |
- reply.SendError(base::StringPrintf("No virtual network found: %s", |
- service_path.c_str())); |
- return; |
- } |
- if (network->NeedMoreInfoToConnect()) { |
- reply.SendError("Virtual network is missing info required to connect."); |
- return; |
- }; |
- |
- // Set up an observer (it will delete itself). |
- new VirtualConnectObserver(this, reply_message, network->name()); |
- network_library->ConnectToVirtualNetwork(network); |
-} |
- |
-void TestingAutomationProvider::GetPrivateNetworkInfo( |
- DictionaryValue* args, IPC::Message* reply_message) { |
- scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
- NetworkLibrary* network_library = NetworkLibrary::Get(); |
- const chromeos::VirtualNetworkVector& virtual_networks = |
- network_library->virtual_networks(); |
- |
- // Construct a dictionary of fields describing remembered VPNs. Also list |
- // the currently active VPN, if any. |
- if (network_library->virtual_network()) |
- return_value->SetString("connected", |
- network_library->virtual_network()->service_path()); |
- for (chromeos::VirtualNetworkVector::const_iterator iter = |
- virtual_networks.begin(); iter != virtual_networks.end(); ++iter) { |
- const chromeos::VirtualNetwork* virt = *iter; |
- DictionaryValue* item = new DictionaryValue; |
- item->SetString("name", virt->name()); |
- item->SetString("provider_type", |
- VPNProviderTypeToString(virt->provider_type())); |
- item->SetString("hostname", virt->server_hostname()); |
- item->SetString("key", virt->psk_passphrase()); |
- item->SetString("cert_id", virt->client_cert_id()); |
- item->SetString("username", virt->username()); |
- item->SetString("password", virt->user_passphrase()); |
- return_value->Set(virt->service_path(), item); |
- } |
- |
- AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); |
-} |
- |
-void TestingAutomationProvider::DisconnectFromPrivateNetwork( |
- DictionaryValue* args, IPC::Message* reply_message) { |
- AutomationJSONReply reply(this, reply_message); |
- NetworkLibrary* network_library = NetworkLibrary::Get(); |
- const chromeos::VirtualNetwork* virt = network_library->virtual_network(); |
- if (!virt) { |
- reply.SendError("Not connected to any virtual network."); |
- return; |
- } |
- |
- network_library->DisconnectFromNetwork(virt); |
- reply.SendSuccess(NULL); |
-} |
- |
void TestingAutomationProvider::ExecuteJavascriptInOOBEWebUI( |
DictionaryValue* args, IPC::Message* reply_message) { |
std::string javascript, frame_xpath; |