| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/test/webdriver/webdriver_automation.h" | 5 #include "chrome/test/webdriver/webdriver_automation.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 869 automation::Error auto_error; | 869 automation::Error auto_error; |
| 870 if (!SendSetLocalStatePreferenceJSONRequest( | 870 if (!SendSetLocalStatePreferenceJSONRequest( |
| 871 automation(), pref, scoped_value.release(), &auto_error)) | 871 automation(), pref, scoped_value.release(), &auto_error)) |
| 872 *error = Error::FromAutomationError(auto_error); | 872 *error = Error::FromAutomationError(auto_error); |
| 873 } else { | 873 } else { |
| 874 std::string request, response; | 874 std::string request, response; |
| 875 DictionaryValue request_dict; | 875 DictionaryValue request_dict; |
| 876 request_dict.SetString("command", "SetLocalStatePrefs"); | 876 request_dict.SetString("command", "SetLocalStatePrefs"); |
| 877 request_dict.SetString("path", pref); | 877 request_dict.SetString("path", pref); |
| 878 request_dict.Set("value", scoped_value.release()); | 878 request_dict.Set("value", scoped_value.release()); |
| 879 base::JSONWriter::Write(&request_dict, false, &request); | 879 base::JSONWriter::Write(&request_dict, &request); |
| 880 if (!automation()->GetBrowserWindow(0)->SendJSONRequest( | 880 if (!automation()->GetBrowserWindow(0)->SendJSONRequest( |
| 881 request, -1, &response)) { | 881 request, -1, &response)) { |
| 882 *error = new Error(kUnknownError, base::StringPrintf( | 882 *error = new Error(kUnknownError, base::StringPrintf( |
| 883 "Failed to set local state pref '%s'", pref.c_str())); | 883 "Failed to set local state pref '%s'", pref.c_str())); |
| 884 } | 884 } |
| 885 } | 885 } |
| 886 } | 886 } |
| 887 | 887 |
| 888 void Automation::SetPreference(const std::string& pref, | 888 void Automation::SetPreference(const std::string& pref, |
| 889 base::Value* value, | 889 base::Value* value, |
| 890 Error** error) { | 890 Error** error) { |
| 891 scoped_ptr<Value> scoped_value(value); | 891 scoped_ptr<Value> scoped_value(value); |
| 892 // Chrome 17 is on the 963 branch. The first released 18 build should have | 892 // Chrome 17 is on the 963 branch. The first released 18 build should have |
| 893 // the new SetPrefs method which uses a browser index instead of handle. | 893 // the new SetPrefs method which uses a browser index instead of handle. |
| 894 if (build_no_ >= 964) { | 894 if (build_no_ >= 964) { |
| 895 automation::Error auto_error; | 895 automation::Error auto_error; |
| 896 if (!SendSetPreferenceJSONRequest( | 896 if (!SendSetPreferenceJSONRequest( |
| 897 automation(), pref, scoped_value.release(), &auto_error)) | 897 automation(), pref, scoped_value.release(), &auto_error)) |
| 898 *error = Error::FromAutomationError(auto_error); | 898 *error = Error::FromAutomationError(auto_error); |
| 899 } else { | 899 } else { |
| 900 std::string request, response; | 900 std::string request, response; |
| 901 DictionaryValue request_dict; | 901 DictionaryValue request_dict; |
| 902 request_dict.SetString("command", "SetPrefs"); | 902 request_dict.SetString("command", "SetPrefs"); |
| 903 request_dict.SetInteger("windex", 0); | 903 request_dict.SetInteger("windex", 0); |
| 904 request_dict.SetString("path", pref); | 904 request_dict.SetString("path", pref); |
| 905 request_dict.Set("value", scoped_value.release()); | 905 request_dict.Set("value", scoped_value.release()); |
| 906 base::JSONWriter::Write(&request_dict, false, &request); | 906 base::JSONWriter::Write(&request_dict, &request); |
| 907 if (!automation()->GetBrowserWindow(0)->SendJSONRequest( | 907 if (!automation()->GetBrowserWindow(0)->SendJSONRequest( |
| 908 request, -1, &response)) { | 908 request, -1, &response)) { |
| 909 *error = new Error(kUnknownError, base::StringPrintf( | 909 *error = new Error(kUnknownError, base::StringPrintf( |
| 910 "Failed to set pref '%s'", pref.c_str())); | 910 "Failed to set pref '%s'", pref.c_str())); |
| 911 } | 911 } |
| 912 } | 912 } |
| 913 } | 913 } |
| 914 | 914 |
| 915 AutomationProxy* Automation::automation() const { | 915 AutomationProxy* Automation::automation() const { |
| 916 return launcher_->automation(); | 916 return launcher_->automation(); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 return CheckVersion(750, message); | 965 return CheckVersion(750, message); |
| 966 } | 966 } |
| 967 | 967 |
| 968 Error* Automation::CheckNewExtensionInterfaceSupported() { | 968 Error* Automation::CheckNewExtensionInterfaceSupported() { |
| 969 const char* message = | 969 const char* message = |
| 970 "Extension interface is not supported for this version of Chrome"; | 970 "Extension interface is not supported for this version of Chrome"; |
| 971 return CheckVersion(947, message); | 971 return CheckVersion(947, message); |
| 972 } | 972 } |
| 973 | 973 |
| 974 } // namespace webdriver | 974 } // namespace webdriver |
| OLD | NEW |