| 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/automation/automation_json_requests.h" | 5 #include "chrome/test/automation/automation_json_requests.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 using base::DictionaryValue; | 23 using base::DictionaryValue; |
| 24 using base::ListValue; | 24 using base::ListValue; |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 bool SendAutomationJSONRequest(AutomationMessageSender* sender, | 28 bool SendAutomationJSONRequest(AutomationMessageSender* sender, |
| 29 const DictionaryValue& request_dict, | 29 const DictionaryValue& request_dict, |
| 30 DictionaryValue* reply_dict, | 30 DictionaryValue* reply_dict, |
| 31 Error* error) { | 31 Error* error) { |
| 32 std::string request, reply; | 32 std::string request, reply; |
| 33 base::JSONWriter::Write(&request_dict, false, &request); | 33 base::JSONWriter::Write(&request_dict, &request); |
| 34 std::string command; | 34 std::string command; |
| 35 request_dict.GetString("command", &command); | 35 request_dict.GetString("command", &command); |
| 36 LOG(INFO) << "Sending '" << command << "' command."; | 36 LOG(INFO) << "Sending '" << command << "' command."; |
| 37 | 37 |
| 38 base::Time before_sending = base::Time::Now(); | 38 base::Time before_sending = base::Time::Now(); |
| 39 bool success = false; | 39 bool success = false; |
| 40 if (!SendAutomationJSONRequestWithDefaultTimeout( | 40 if (!SendAutomationJSONRequestWithDefaultTimeout( |
| 41 sender, request, &reply, &success)) { | 41 sender, request, &reply, &success)) { |
| 42 *error = Error(base::StringPrintf( | 42 *error = Error(base::StringPrintf( |
| 43 "Chrome did not respond to '%s'. Elapsed time was %" PRId64 " ms.", | 43 "Chrome did not respond to '%s'. Elapsed time was %" PRId64 " ms.", |
| (...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 base::Value* value, | 881 base::Value* value, |
| 882 Error* error) { | 882 Error* error) { |
| 883 DictionaryValue dict; | 883 DictionaryValue dict; |
| 884 dict.SetString("command", "SetPrefs"); | 884 dict.SetString("command", "SetPrefs"); |
| 885 dict.SetInteger("windex", 0); | 885 dict.SetInteger("windex", 0); |
| 886 dict.SetString("path", pref); | 886 dict.SetString("path", pref); |
| 887 dict.Set("value", value); | 887 dict.Set("value", value); |
| 888 DictionaryValue reply_dict; | 888 DictionaryValue reply_dict; |
| 889 return SendAutomationJSONRequest(sender, dict, &reply_dict, error); | 889 return SendAutomationJSONRequest(sender, dict, &reply_dict, error); |
| 890 } | 890 } |
| OLD | NEW |