summaryrefslogtreecommitdiffstats
path: root/chrome/browser/automation
diff options
context:
space:
mode:
authorbeeps@chromium.org <beeps@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-18 04:35:38 +0000
committerbeeps@chromium.org <beeps@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-18 04:35:38 +0000
commit7f1ed2450574b02ebb955f18e834436dced65f4e (patch)
tree1f99394e6cac3830ec7ef784c56c6452af27ca0b /chrome/browser/automation
parent11feec32b991ffac983d2a9781c70df4b987b67f (diff)
downloadchromium_src-7f1ed2450574b02ebb955f18e834436dced65f4e.zip
chromium_src-7f1ed2450574b02ebb955f18e834436dced65f4e.tar.gz
chromium_src-7f1ed2450574b02ebb955f18e834436dced65f4e.tar.bz2
Enables us to setproxysettings through the chromeos options UI and have it propogate to the system.
TestingAutomationProvider Get/SetProxySettings: 1. uses profile on shell 2. handles shared proxy settings through internetoptionshandler 3. changed setproxysettings from a browserhandler call to handler call Pyauto.py: 1. Gets servicepath and network type for sharedproxysettings call 2. uses network_type parameter (used to be windex) to get network information, since setproxysettings is now a handler call. Chromeos_proxy.py: 1. changed to check value in result dictionary instead of presence of key 2. navigate to url and perform setup needed to setproxysettings TEST=functional/chromeos_proxy.py BUG=27040 Review URL: https://chromiumcodereview.appspot.com/10829388 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157295 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/automation')
-rw-r--r--chrome/browser/automation/automation_util.cc53
-rw-r--r--chrome/browser/automation/automation_util.h5
-rw-r--r--chrome/browser/automation/testing_automation_provider.cc23
-rw-r--r--chrome/browser/automation/testing_automation_provider.h12
-rw-r--r--chrome/browser/automation/testing_automation_provider_chromeos.cc96
5 files changed, 159 insertions, 30 deletions
diff --git a/chrome/browser/automation/automation_util.cc b/chrome/browser/automation/automation_util.cc
index 5a35aef..82b67c2 100644
--- a/chrome/browser/automation/automation_util.cc
+++ b/chrome/browser/automation/automation_util.cc
@@ -6,6 +6,8 @@
#include <string>
+#include "ash/shell.h"
+#include "ash/shell_delegate.h"
#include "base/bind.h"
#include "base/memory/scoped_ptr.h"
#include "base/string_number_conversions.h"
@@ -39,10 +41,25 @@
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
+#if defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/login/existing_user_controller.h"
+#include "chrome/browser/chromeos/login/login_display.h"
+#include "chrome/browser/chromeos/login/login_display_host.h"
+#include "chrome/browser/chromeos/login/webui_login_display.h"
+#include "chrome/browser/chromeos/login/webui_login_display_host.h"
+#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
+#endif
+
using content::BrowserThread;
using content::RenderViewHost;
using content::WebContents;
+#if defined(OS_CHROMEOS)
+using chromeos::ExistingUserController;
+using chromeos::User;
+using chromeos::UserManager;
+#endif
+
namespace {
void GetCookiesCallback(base::WaitableEvent* event,
@@ -150,6 +167,42 @@ WebContents* GetWebContentsAt(int browser_index, int tab_index) {
return chrome::GetWebContentsAt(browser, tab_index);
}
+#if defined(OS_CHROMEOS)
+Profile* GetCurrentProfileOnChromeOS(std::string* error_message) {
+ const UserManager* user_manager = UserManager::Get();
+ if (!user_manager) {
+ *error_message = "No user manager.";
+ return NULL;
+ }
+ if (!user_manager->IsUserLoggedIn()) {
+ ExistingUserController* controller =
+ ExistingUserController::current_controller();
+ if (!controller) {
+ *error_message = "Cannot get controller though user is not logged in.";
+ return NULL;
+ }
+ chromeos::WebUILoginDisplayHost* webui_login_display_host =
+ static_cast<chromeos::WebUILoginDisplayHost*>(
+ controller->login_display_host());
+ content::WebUI* web_ui = webui_login_display_host->GetOobeUI()->web_ui();
+ if (!web_ui) {
+ *error_message = "Unable to get webui from login display host.";
+ return NULL;
+ }
+ return Profile::FromWebUI(web_ui);
+ } else {
+ ash::Shell* shell = ash::Shell::GetInstance();
+ if (!shell || !shell->delegate()) {
+ *error_message = "Unable to get shell delegate.";
+ return NULL;
+ }
+ return Profile::FromBrowserContext(
+ shell->delegate()->GetCurrentBrowserContext());
+ }
+ return NULL;
+}
+#endif // defined(OS_CHROMEOS)
+
Browser* GetBrowserForTab(WebContents* tab) {
BrowserList::const_iterator browser_iter = BrowserList::begin();
for (; browser_iter != BrowserList::end(); ++browser_iter) {
diff --git a/chrome/browser/automation/automation_util.h b/chrome/browser/automation/automation_util.h
index 9ccd971..e895108 100644
--- a/chrome/browser/automation/automation_util.h
+++ b/chrome/browser/automation/automation_util.h
@@ -45,6 +45,11 @@ Browser* GetBrowserAt(int index);
// |BrowserList|. If any of these indices are invalid, NULL will be returned.
content::WebContents* GetWebContentsAt(int browser_index, int tab_index);
+#if defined(OS_CHROMEOS)
+// Returns the appropriate profile depending on signed in state of user.
+Profile* GetCurrentProfileOnChromeOS(std::string* error_message);
+#endif
+
// Returns the browser that contains the given tab, or NULL if none exists.
Browser* GetBrowserForTab(content::WebContents* tab);
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index 50bef18..21454cc 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -1875,7 +1875,19 @@ void TestingAutomationProvider::BuildJSONHandlerMaps() {
handler_map_["SetMute"] = &TestingAutomationProvider::SetMute;
handler_map_["OpenCrosh"] = &TestingAutomationProvider::OpenCrosh;
+ handler_map_["SetProxySettings"] =
+ &TestingAutomationProvider::SetProxySettings;
+ handler_map_["GetProxySettings"] =
+ &TestingAutomationProvider::GetProxySettings;
+ handler_map_["SetSharedProxies"] =
+ &TestingAutomationProvider::SetSharedProxies;
+ handler_map_["RefreshInternetDetails"] =
+ &TestingAutomationProvider::RefreshInternetDetails;
+ browser_handler_map_["CaptureProfilePhoto"] =
+ &TestingAutomationProvider::CaptureProfilePhoto;
+ browser_handler_map_["GetTimeInfo"] =
+ &TestingAutomationProvider::GetTimeInfo;
#endif // defined(OS_CHROMEOS)
browser_handler_map_["DisablePlugin"] =
@@ -2014,17 +2026,6 @@ void TestingAutomationProvider::BuildJSONHandlerMaps() {
&TestingAutomationProvider::AcceptCurrentFullscreenOrMouseLockRequest;
browser_handler_map_["DenyCurrentFullscreenOrMouseLockRequest"] =
&TestingAutomationProvider::DenyCurrentFullscreenOrMouseLockRequest;
-
-#if defined(OS_CHROMEOS)
- browser_handler_map_["CaptureProfilePhoto"] =
- &TestingAutomationProvider::CaptureProfilePhoto;
- browser_handler_map_["GetTimeInfo"] =
- &TestingAutomationProvider::GetTimeInfo;
- browser_handler_map_["GetProxySettings"] =
- &TestingAutomationProvider::GetProxySettings;
- browser_handler_map_["SetProxySettings"] =
- &TestingAutomationProvider::SetProxySettings;
-#endif // defined(OS_CHROMEOS)
}
scoped_ptr<DictionaryValue> TestingAutomationProvider::ParseJSONRequestCommand(
diff --git a/chrome/browser/automation/testing_automation_provider.h b/chrome/browser/automation/testing_automation_provider.h
index 33e1633..426ec83 100644
--- a/chrome/browser/automation/testing_automation_provider.h
+++ b/chrome/browser/automation/testing_automation_provider.h
@@ -1496,14 +1496,18 @@ class TestingAutomationProvider : public AutomationProvider,
void ToggleNetworkDevice(base::DictionaryValue* args,
IPC::Message* reply_message);
- void GetProxySettings(Browser* browser,
- base::DictionaryValue* args,
+ void GetProxySettings(base::DictionaryValue* args,
IPC::Message* reply_message);
- void SetProxySettings(Browser* browser,
- base::DictionaryValue* args,
+ void SetProxySettings(base::DictionaryValue* args,
+ IPC::Message* reply_message);
+
+ void SetSharedProxies(base::DictionaryValue* args,
IPC::Message* reply_message);
+ void RefreshInternetDetails(base::DictionaryValue* args,
+ IPC::Message* reply_message);
+
void ConnectToCellularNetwork(base::DictionaryValue* args,
IPC::Message* reply_message);
diff --git a/chrome/browser/automation/testing_automation_provider_chromeos.cc b/chrome/browser/automation/testing_automation_provider_chromeos.cc
index b8115b53..f256a03 100644
--- a/chrome/browser/automation/testing_automation_provider_chromeos.cc
+++ b/chrome/browser/automation/testing_automation_provider_chromeos.cc
@@ -14,6 +14,7 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/automation/automation_provider_json.h"
#include "chrome/browser/automation/automation_provider_observers.h"
+#include "chrome/browser/automation/automation_util.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/accessibility/accessibility_util.h"
#include "chrome/browser/chromeos/audio/audio_handler.h"
@@ -34,6 +35,7 @@
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/chromeos/options/take_photo_dialog.h"
#include "chrome/browser/chromeos/proxy_cros_settings_parser.h"
+#include "chrome/browser/chromeos/proxy_config_service_impl.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/chromeos/settings/cros_settings_names.h"
#include "chrome/browser/chromeos/system/timezone_settings.h"
@@ -84,14 +86,13 @@ DictionaryValue* GetWifiInfoDict(const chromeos::WifiNetwork* wifi) {
return item;
}
-base::Value* GetProxySetting(Browser* browser,
- const std::string& setting_name) {
+base::Value* GetProxySetting(const std::string& setting_name,
+ Profile* profile) {
std::string setting_path = "cros.session.proxy.";
setting_path.append(setting_name);
-
base::Value* setting;
if (chromeos::proxy_cros_settings_parser::GetProxyPrefValue(
- browser->profile(), setting_path, &setting)) {
+ profile, setting_path, &setting)) {
scoped_ptr<DictionaryValue> setting_dict(
static_cast<DictionaryValue*>(setting));
base::Value* value;
@@ -619,6 +620,7 @@ void TestingAutomationProvider::GetNetworkInfo(DictionaryValue* args,
DictionaryValue* items = new DictionaryValue;
DictionaryValue* item = GetNetworkInfoDict(ethernet_network);
items->Set(ethernet_network->service_path(), item);
+ items->SetInteger("network_type", chromeos::TYPE_ETHERNET);
return_value->Set("ethernet_networks", items);
}
}
@@ -638,6 +640,7 @@ void TestingAutomationProvider::GetNetworkInfo(DictionaryValue* args,
DictionaryValue* item = GetWifiInfoDict(wifi);
items->Set(wifi->service_path(), item);
}
+ items->SetInteger("network_type", chromeos::TYPE_WIFI);
return_value->Set("wifi_networks", items);
}
@@ -665,6 +668,7 @@ void TestingAutomationProvider::GetNetworkInfo(DictionaryValue* args,
cellular_networks[i]->GetRoamingStateString());
items->Set(cellular_networks[i]->service_path(), item);
}
+ items->SetInteger("network_type", chromeos::TYPE_CELLULAR);
return_value->Set("cellular_networks", items);
}
@@ -679,6 +683,7 @@ void TestingAutomationProvider::GetNetworkInfo(DictionaryValue* args,
DictionaryValue* item = GetWifiInfoDict(wifi);
remembered_wifi_items->Set(wifi->service_path(), item);
}
+ remembered_wifi_items->SetInteger("network_type", chromeos::TYPE_WIFI);
return_value->Set("remembered_wifi", remembered_wifi_items);
AutomationJSONReply(this, reply_message).SendSuccess(return_value.get());
@@ -721,27 +726,83 @@ void TestingAutomationProvider::ToggleNetworkDevice(
}
}
-void TestingAutomationProvider::GetProxySettings(Browser* browser,
- DictionaryValue* args,
+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" };
-
+ AutomationJSONReply reply(this, reply_message);
scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
+ std::string error_message;
+ Profile* profile =
+ automation_util::GetCurrentProfileOnChromeOS(&error_message);
+ if (!profile) {
+ reply.SendError(error_message);
+ return;
+ }
for (size_t i = 0; i < arraysize(settings); ++i) {
- base::Value* setting = GetProxySetting(browser, settings[i]);
+ base::Value* setting =
+ GetProxySetting(settings[i], profile);
if (setting)
return_value->Set(settings[i], setting);
}
+ reply.SendSuccess(return_value.get());
+}
- AutomationJSONReply(this, reply_message).SendSuccess(return_value.get());
+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 proxy_setting_type;
+ std::string setting_path = prefs::kUseSharedProxies;
+ 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(setting_path.c_str(), *value);
+ reply.SendSuccess(NULL);
+}
+
+void TestingAutomationProvider::RefreshInternetDetails(
+ DictionaryValue* args,
+ IPC::Message* reply_message) {
+
+ AutomationJSONReply reply(this, reply_message);
+ std::string service_path;
+ if (!args->GetString("service path", &service_path)) {
+ reply.SendError("missing service path.");
+ return;
+ }
+ std::string error_message;
+ Profile* profile =
+ automation_util::GetCurrentProfileOnChromeOS(&error_message);
+ if (!profile) {
+ reply.SendError(error_message);
+ return;
+ }
+ chromeos::ProxyConfigServiceImpl* config_service =
+ profile->GetProxyConfigTracker();
+ if (!config_service) {
+ reply.SendError("Unable to get proxy configuration.");
+ return;
+ }
+ config_service->UISetCurrentNetwork(service_path);
+ reply.SendSuccess(NULL);
}
-void TestingAutomationProvider::SetProxySettings(Browser* browser,
- DictionaryValue* args,
+void TestingAutomationProvider::SetProxySettings(DictionaryValue* args,
IPC::Message* reply_message) {
AutomationJSONReply reply(this, reply_message);
std::string key;
@@ -750,13 +811,18 @@ void TestingAutomationProvider::SetProxySettings(Browser* browser,
reply.SendError("Invalid or missing args.");
return;
}
-
+ std::string error_message;
+ Profile* profile =
+ automation_util::GetCurrentProfileOnChromeOS(&error_message);
+ if (!profile) {
+ reply.SendError(error_message);
+ return;
+ }
+ // ProxyCrosSettingsProvider will own the Value* passed to Set().
std::string setting_path = "cros.session.proxy.";
setting_path.append(key);
-
- // ProxyCrosSettingsProvider will own the Value* passed to Set().
chromeos::proxy_cros_settings_parser::SetProxyPrefValue(
- browser->profile(), setting_path, value);
+ profile, setting_path, value);
reply.SendSuccess(NULL);
}