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..95ebe7f51155a2b8c00aaf276c4db708224760c3 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/05 19:27:53
delete setting, not setting dict, since that's the
dtu
2011/04/05 21:29:10
Done.
|
| + 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::SetProxySettings(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)) { |
|
Nirnimesh
2011/04/05 19:27:53
this might fit on previous line
dtu
2011/04/05 21:29:10
Done.
|
| + 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()); |
|
Nirnimesh
2011/04/05 19:27:53
who deallocs the DeepCopy()?
xiyuan
2011/04/05 19:44:32
cros settings provider will own the value passed i
Nirnimesh
2011/04/05 19:49:13
Ah, I now see the comment in cros_settings_provide
dtu
2011/04/05 21:29:10
Added a comment here, just in case.
|
| + reply.SendSuccess(NULL); |
| +} |
| + |
| void TestingAutomationProvider::ConnectToWifiNetwork( |
| DictionaryValue* args, IPC::Message* reply_message) { |
| AutomationJSONReply reply(this, reply_message); |