OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/javascript_execution_controller.h" | 5 #include "chrome/test/automation/javascript_execution_controller.h" |
6 | 6 |
7 #include "base/json/string_escape.h" | 7 #include "base/json/string_escape.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/common/json_value_serializer.h" | 10 #include "chrome/common/json_value_serializer.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 "domAutomation.evaluateJavaScript("; | 65 "domAutomation.evaluateJavaScript("; |
66 script.append(GetDoubleQuotedJson(UTF8ToUTF16(original_script))); | 66 script.append(GetDoubleQuotedJson(UTF8ToUTF16(original_script))); |
67 script.append(");"); | 67 script.append(");"); |
68 return ExecuteJavaScriptAndGetJSON(script, json); | 68 return ExecuteJavaScriptAndGetJSON(script, json); |
69 } | 69 } |
70 | 70 |
71 bool JavaScriptExecutionController::ParseJSON(const std::string& json, | 71 bool JavaScriptExecutionController::ParseJSON(const std::string& json, |
72 scoped_ptr<Value>* result) { | 72 scoped_ptr<Value>* result) { |
73 JSONStringValueSerializer parse(json); | 73 JSONStringValueSerializer parse(json); |
74 std::string parsing_error; | 74 std::string parsing_error; |
75 scoped_ptr<Value> root_value(parse.Deserialize(&parsing_error)); | 75 scoped_ptr<Value> root_value(parse.Deserialize(NULL, &parsing_error)); |
76 | 76 |
77 if (!root_value.get()) { | 77 if (!root_value.get()) { |
78 if (parsing_error.length()) | 78 if (parsing_error.length()) |
79 LOG(ERROR) << "Cannot parse JSON response: " << parsing_error; | 79 LOG(ERROR) << "Cannot parse JSON response: " << parsing_error; |
80 else | 80 else |
81 LOG(ERROR) << "JSON response is empty"; | 81 LOG(ERROR) << "JSON response is empty"; |
82 return false; | 82 return false; |
83 } | 83 } |
84 | 84 |
85 // The response must be a list of 3 components: | 85 // The response must be a list of 3 components: |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 | 118 |
119 bool JavaScriptExecutionController::ConvertResponse(Value* value, | 119 bool JavaScriptExecutionController::ConvertResponse(Value* value, |
120 int* result) { | 120 int* result) { |
121 return value->GetAsInteger(result); | 121 return value->GetAsInteger(result); |
122 } | 122 } |
123 | 123 |
124 bool JavaScriptExecutionController::ConvertResponse(Value* value, | 124 bool JavaScriptExecutionController::ConvertResponse(Value* value, |
125 std::string* result) { | 125 std::string* result) { |
126 return value->GetAsString(result); | 126 return value->GetAsString(result); |
127 } | 127 } |
OLD | NEW |