Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(759)

Unified Diff: chrome/test/webdriver/webdriver_automation.cc

Issue 8890026: Allow chromedriver to set local state preferences. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/webdriver/webdriver_automation.cc
diff --git a/chrome/test/webdriver/webdriver_automation.cc b/chrome/test/webdriver/webdriver_automation.cc
index 72cb45f916828b1c6abc305eb514ee6df83242b8..006cacf5bcb8c365695e6d2fb39d7bd03df0c793 100644
--- a/chrome/test/webdriver/webdriver_automation.cc
+++ b/chrome/test/webdriver/webdriver_automation.cc
@@ -185,7 +185,8 @@ namespace webdriver {
Automation::BrowserOptions::BrowserOptions()
: command(CommandLine::NO_PROGRAM),
- detach_process(false) {}
+ detach_process(false),
+ cert_revocation_checking(true) {}
Automation::BrowserOptions::~BrowserOptions() {}
@@ -743,6 +744,64 @@ void Automation::InstallExtension(
*error = new Error(kUnknownError, error_msg);
}
+void Automation::SetLocalStatePreference(const std::string& pref,
+ base::Value* value,
+ Error** error) {
+ scoped_ptr<Value> scoped_value(value);
+ bool has_new_local_state_api = false;
+ *error = CompareVersion(927, 0, &has_new_local_state_api);
Huyen 2011/12/09 23:56:55 maybe move the version # out into a constant and/o
kkania 2011/12/10 00:37:44 Done.
+ if (*error)
+ return;
+
+ if (has_new_local_state_api) {
+ std::string error_msg;
+ if (!SendSetLocalStatePreferenceJSONRequest(
+ automation(), pref, scoped_value.release(), &error_msg))
+ *error = new Error(kUnknownError, error_msg);
+ } else {
+ std::string request, response;
+ DictionaryValue request_dict;
+ request_dict.SetString("command", "SetLocalStatePrefs");
+ request_dict.SetString("path", pref);
+ request_dict.Set("value", scoped_value.release());
+ base::JSONWriter::Write(&request_dict, false, &request);
+ if (!automation()->GetBrowserWindow(0)->SendJSONRequest(
+ request, -1, &response)) {
+ *error = new Error(kUnknownError, base::StringPrintf(
+ "Failed to set local state pref '%s'", pref.c_str()));
+ }
+ }
+}
+
+void Automation::SetPreference(const std::string& pref,
+ base::Value* value,
+ Error** error) {
+ scoped_ptr<Value> scoped_value(value);
+ bool has_new_pref_api = false;
+ *error = CompareVersion(964, 0, &has_new_pref_api);
Huyen 2011/12/09 23:56:55 same comment as above
kkania 2011/12/10 00:37:44 Done.
+ if (*error)
+ return;
+
+ if (has_new_pref_api) {
+ std::string error_msg;
+ if (!SendSetPreferenceJSONRequest(
+ automation(), pref, scoped_value.release(), &error_msg))
+ *error = new Error(kUnknownError, error_msg);
+ } else {
+ std::string request, response;
+ DictionaryValue request_dict;
+ request_dict.SetString("command", "SetPrefs");
+ request_dict.SetString("path", pref);
+ request_dict.Set("value", scoped_value.release());
+ base::JSONWriter::Write(&request_dict, false, &request);
+ if (!automation()->GetBrowserWindow(0)->SendJSONRequest(
+ request, -1, &response)) {
+ *error = new Error(kUnknownError, base::StringPrintf(
+ "Failed to set pref '%s'", pref.c_str()));
+ }
+ }
+}
+
AutomationProxy* Automation::automation() const {
return launcher_->automation();
}

Powered by Google App Engine
This is Rietveld 408576698