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 // Support utilities for the JSON automation interface used by PyAuto. | 5 // Support utilities for the JSON automation interface used by PyAuto. |
6 | 6 |
7 #ifndef CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_JSON_H_ | 7 #ifndef CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_JSON_H_ |
8 #define CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_JSON_H_ | 8 #define CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_JSON_H_ |
9 #pragma once | 9 #pragma once |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "chrome/browser/automation/automation_provider.h" | |
14 | |
15 class Value; | 13 class Value; |
| 14 class AutomationProvider; |
16 | 15 |
17 namespace IPC { | 16 namespace IPC { |
18 class Message; | 17 class Message; |
19 } | 18 } |
20 | 19 |
21 // Helper to ensure we always send a reply message for JSON automation requests. | 20 // Helper to ensure we always send a reply message for JSON automation requests. |
22 class AutomationJSONReply { | 21 class AutomationJSONReply { |
23 public: | 22 public: |
24 // Creates a new reply object for the IPC message |reply_message| for | 23 // Creates a new reply object for the IPC message |reply_message| for |
25 // |provider|. The caller is expected to call SendSuccess() or SendError() | 24 // |provider|. The caller is expected to call SendSuccess() or SendError() |
26 // before destroying this object. | 25 // before destroying this object. |
27 AutomationJSONReply(AutomationProvider* provider, | 26 AutomationJSONReply(AutomationProvider* provider, |
28 IPC::Message* reply_message); | 27 IPC::Message* reply_message); |
29 | 28 |
30 ~AutomationJSONReply(); | 29 ~AutomationJSONReply(); |
31 | 30 |
32 // Send a success reply along with data contained in |value|. | 31 // Send a success reply along with data contained in |value|. |
33 // An empty message will be sent if |value| is NULL. | 32 // An empty message will be sent if |value| is NULL. |
34 void SendSuccess(const Value* value); | 33 void SendSuccess(const Value* value); |
35 | 34 |
36 // Send an error reply along with error message |error_message|. | 35 // Send an error reply along with error message |error_message|. |
37 void SendError(const std::string& error_message); | 36 void SendError(const std::string& error_message); |
38 | 37 |
39 private: | 38 private: |
40 AutomationProvider* provider_; | 39 AutomationProvider* provider_; |
41 IPC::Message* message_; | 40 IPC::Message* message_; |
42 }; | 41 }; |
43 | 42 |
44 #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_JSON_H_ | 43 #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_JSON_H_ |
OLD | NEW |