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/browser/automation/automation_provider_json.h" | 5 #include "chrome/browser/automation/automation_provider_json.h" |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/json/string_escape.h" | 8 #include "base/json/string_escape.h" |
9 #include "chrome/browser/autocomplete/autocomplete_match.h" | 9 #include "chrome/browser/autocomplete/autocomplete_match.h" |
10 #include "chrome/browser/automation/automation_provider.h" | 10 #include "chrome/browser/automation/automation_provider.h" |
11 #include "chrome/common/automation_messages.h" | 11 #include "chrome/test/automation/automation_messages.h" |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 // Util for creating a JSON error return string (dict with key | 15 // Util for creating a JSON error return string (dict with key |
16 // 'error' and error string value). No need to quote input. | 16 // 'error' and error string value). No need to quote input. |
17 std::string JSONErrorString(const std::string& err) { | 17 std::string JSONErrorString(const std::string& err) { |
18 std::string prefix = "{\"error\": \""; | 18 std::string prefix = "{\"error\": \""; |
19 std::string no_quote_err; | 19 std::string no_quote_err; |
20 std::string suffix = "\"}"; | 20 std::string suffix = "\"}"; |
21 | 21 |
(...skipping 25 matching lines...) Expand all Loading... |
47 } | 47 } |
48 | 48 |
49 void AutomationJSONReply::SendError(const std::string& error_message) { | 49 void AutomationJSONReply::SendError(const std::string& error_message) { |
50 DCHECK(message_) << "Resending reply for JSON automation request"; | 50 DCHECK(message_) << "Resending reply for JSON automation request"; |
51 std::string json_string = JSONErrorString(error_message); | 51 std::string json_string = JSONErrorString(error_message); |
52 AutomationMsg_SendJSONRequest::WriteReplyParams( | 52 AutomationMsg_SendJSONRequest::WriteReplyParams( |
53 message_, json_string, false); | 53 message_, json_string, false); |
54 provider_->Send(message_); | 54 provider_->Send(message_); |
55 message_ = NULL; | 55 message_ = NULL; |
56 } | 56 } |
OLD | NEW |