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