Chromium Code Reviews| 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 83b7df0a1bb7ea5fba7c6b00c27629fccce21359..6cc8846f5cf84675eaeea139a5ed9cd049686cdc 100644 |
| --- a/chrome/browser/automation/testing_automation_provider_chromeos.cc |
| +++ b/chrome/browser/automation/testing_automation_provider_chromeos.cc |
| @@ -13,6 +13,7 @@ |
| #include "chrome/browser/chromeos/cros/screen_lock_library.h" |
| #include "chrome/browser/chromeos/login/existing_user_controller.h" |
| #include "chrome/browser/chromeos/login/screen_locker.h" |
| +#include "chrome/browser/chromeos/proxy_cros_settings_provider.h" |
| using chromeos::CrosLibrary; |
| using chromeos::NetworkLibrary; |
| @@ -29,6 +30,29 @@ DictionaryValue* GetNetworkInfoDict(const chromeos::Network* network) { |
| return item; |
| } |
| +Value* GetProxySetting(const std::string& setting_name) { |
| + chromeos::ProxyCrosSettingsProvider settings_provider; |
| + std::string setting_path = "cros.session.proxy."; |
| + setting_path.append(setting_name); |
| + |
| + if (setting_name == "ignorelist") { |
| + Value* value; |
| + if (settings_provider.Get(setting_path, &value)) |
| + return value; |
| + } else { |
| + Value* setting; |
| + if (settings_provider.Get(setting_path, &setting)) { |
| + DictionaryValue* setting_dict = static_cast<DictionaryValue*>(setting); |
| + Value* value; |
| + bool found = setting_dict->Remove("value", &value); |
| + delete setting_dict; |
|
Nirnimesh
2011/04/04 21:38:27
who allocs setting_dict?
dtu
2011/04/04 22:48:57
Good catch, this is a mistake. setting_dict is sti
xiyuan
2011/04/04 23:31:18
emm... Acutally, the comment in cros_settings_prov
dtu
2011/04/05 00:04:11
Done. Thanks for the heads up.
|
| + if (found) |
| + return value; |
| + } |
| + } |
| + return NULL; |
| +} |
| + |
| } // namespace |
| void TestingAutomationProvider::GetLoginInfo(DictionaryValue* args, |
| @@ -262,6 +286,43 @@ void TestingAutomationProvider::NetworkScan(DictionaryValue* args, |
| new NetworkScanObserver(this, reply_message); |
| } |
| +void TestingAutomationProvider::GetProxySettings(DictionaryValue* args, |
| + IPC::Message* reply_message) { |
| + const char* settings[] = { "pacurl", "singlehttp", "singlehttpport", |
| + "httpurl", "httpport", "httpsurl", "httpsport", |
| + "type", "single", "ftpurl", "ftpport", |
| + "socks", "socksport", "ignorelist" }; |
| + |
| + scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
| + chromeos::ProxyCrosSettingsProvider settings_provider; |
| + |
| + for (size_t i = 0; i < arraysize(settings); ++i) { |
| + Value* setting = GetProxySetting(settings[i]); |
| + if (setting) |
| + return_value->Set(settings[i], setting); |
| + } |
| + |
| + AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); |
| +} |
| + |
| +void TestingAutomationProvider::SetProxySetting(DictionaryValue* args, |
| + IPC::Message* reply_message) { |
| + AutomationJSONReply reply(this, reply_message); |
| + std::string key; |
| + Value* value; |
| + if (!args->GetString("key", &key) || |
| + !args->Get("value", &value)) { |
| + reply.SendError("Invalid or missing args."); |
| + return; |
| + } |
| + |
| + std::string setting_path = "cros.session.proxy."; |
| + setting_path.append(key); |
| + |
| + chromeos::ProxyCrosSettingsProvider().Set(setting_path, value->DeepCopy()); |
| + reply.SendSuccess(NULL); |
| +} |
| + |
| void TestingAutomationProvider::ConnectToWifiNetwork( |
| DictionaryValue* args, IPC::Message* reply_message) { |
| AutomationJSONReply reply(this, reply_message); |