| 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 #ifndef CONTENT_RENDERER_DOM_AUTOMATION_CONTROLLER_H_ | 5 #ifndef CONTENT_RENDERER_DOM_AUTOMATION_CONTROLLER_H_ |
| 6 #define CONTENT_RENDERER_DOM_AUTOMATION_CONTROLLER_H_ | 6 #define CONTENT_RENDERER_DOM_AUTOMATION_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "content/renderer/cpp_bound_class.h" |
| 8 #include "ipc/ipc_sender.h" | 9 #include "ipc/ipc_sender.h" |
| 9 #include "webkit/renderer/cpp_bound_class.h" | |
| 10 | 10 |
| 11 /* DomAutomationController class: | 11 /* DomAutomationController class: |
| 12 Bound to Javascript window.domAutomationController object. | 12 Bound to Javascript window.domAutomationController object. |
| 13 At the very basic, this object makes any native value (string, numbers, | 13 At the very basic, this object makes any native value (string, numbers, |
| 14 boolean) from javascript available to the automation host in Cpp. | 14 boolean) from javascript available to the automation host in Cpp. |
| 15 Any renderer implementation that is built with this binding will allow the | 15 Any renderer implementation that is built with this binding will allow the |
| 16 above facility. | 16 above facility. |
| 17 The intended use of this object is to expose the DOM Objects and their | 17 The intended use of this object is to expose the DOM Objects and their |
| 18 attributes to the automation host. | 18 attributes to the automation host. |
| 19 | 19 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 automation_id_ is used to route the message. | 68 automation_id_ is used to route the message. |
| 69 (IPC messages, AutomationMsg_Dom*Response) | 69 (IPC messages, AutomationMsg_Dom*Response) |
| 70 | 70 |
| 71 */ | 71 */ |
| 72 | 72 |
| 73 namespace content { | 73 namespace content { |
| 74 | 74 |
| 75 // TODO(vibhor): Add another method-pair like sendLater() and sendNow() | 75 // TODO(vibhor): Add another method-pair like sendLater() and sendNow() |
| 76 // sendLater() should keep building a json serializer | 76 // sendLater() should keep building a json serializer |
| 77 // sendNow() should send the above serializer as a string. | 77 // sendNow() should send the above serializer as a string. |
| 78 class DomAutomationController : public webkit_glue::CppBoundClass { | 78 class DomAutomationController : public CppBoundClass { |
| 79 public: | 79 public: |
| 80 DomAutomationController(); | 80 DomAutomationController(); |
| 81 | 81 |
| 82 // Makes the renderer send a javascript value to the app. | 82 // Makes the renderer send a javascript value to the app. |
| 83 // The value to be sent can be either of type NPString, | 83 // The value to be sent can be either of type NPString, |
| 84 // Number (double casted to int32) or boolean. | 84 // Number (double casted to int32) or boolean. |
| 85 // The function returns true/false based on the result of actual send over | 85 // The function returns true/false based on the result of actual send over |
| 86 // IPC. It sets the return value to null on unexpected errors or arguments. | 86 // IPC. It sets the return value to null on unexpected errors or arguments. |
| 87 void Send(const webkit_glue::CppArgumentList& args, | 87 void Send(const CppArgumentList& args, CppVariant* result); |
| 88 webkit_glue::CppVariant* result); | |
| 89 | 88 |
| 90 // Makes the renderer send a javascript value to the app. | 89 // Makes the renderer send a javascript value to the app. |
| 91 // The value must be a NPString and should be properly formed JSON. | 90 // The value must be a NPString and should be properly formed JSON. |
| 92 // This function does not modify/escape the returned string in any way. | 91 // This function does not modify/escape the returned string in any way. |
| 93 void SendJSON(const webkit_glue::CppArgumentList& args, | 92 void SendJSON(const CppArgumentList& args, CppVariant* result); |
| 94 webkit_glue::CppVariant* result); | |
| 95 | 93 |
| 96 // Sends a string with a provided Automation Id. | 94 // Sends a string with a provided Automation Id. |
| 97 // Expects two javascript values; the first must be a number type and will be | 95 // Expects two javascript values; the first must be a number type and will be |
| 98 // used as the Automation Id, the second must be of type NPString. | 96 // used as the Automation Id, the second must be of type NPString. |
| 99 // The function returns true/false to the javascript based on the success | 97 // The function returns true/false to the javascript based on the success |
| 100 // of the send over IPC. It sets the javascript return value to null on | 98 // of the send over IPC. It sets the javascript return value to null on |
| 101 // unexpected errors or arguments. | 99 // unexpected errors or arguments. |
| 102 void SendWithId(const webkit_glue::CppArgumentList& args, | 100 void SendWithId(const CppArgumentList& args, CppVariant* result); |
| 103 webkit_glue::CppVariant* result); | |
| 104 | 101 |
| 105 void SetAutomationId(const webkit_glue::CppArgumentList& args, | 102 void SetAutomationId(const CppArgumentList& args, CppVariant* result); |
| 106 webkit_glue::CppVariant* result); | |
| 107 | 103 |
| 108 // TODO(vibhor): Implement later | 104 // TODO(vibhor): Implement later |
| 109 // static CppBindingObjectMethod sendLater; | 105 // static CppBindingObjectMethod sendLater; |
| 110 // static CppBindingObjectMethod sendNow; | 106 // static CppBindingObjectMethod sendNow; |
| 111 | 107 |
| 112 void set_routing_id(int routing_id) { routing_id_ = routing_id; } | 108 void set_routing_id(int routing_id) { routing_id_ = routing_id; } |
| 113 | 109 |
| 114 void set_message_sender(IPC::Sender* sender) { | 110 void set_message_sender(IPC::Sender* sender) { |
| 115 sender_ = sender; | 111 sender_ = sender; |
| 116 } | 112 } |
| 117 | 113 |
| 118 private: | 114 private: |
| 119 IPC::Sender* sender_; | 115 IPC::Sender* sender_; |
| 120 | 116 |
| 121 // Refer to the comments at the top of the file for more details. | 117 // Refer to the comments at the top of the file for more details. |
| 122 int routing_id_; // routing id to be used by first channel. | 118 int routing_id_; // routing id to be used by first channel. |
| 123 int automation_id_; // routing id to be used by the next channel. | 119 int automation_id_; // routing id to be used by the next channel. |
| 124 }; | 120 }; |
| 125 | 121 |
| 126 } // namespace content | 122 } // namespace content |
| 127 | 123 |
| 128 #endif // CONTENT_RENDERER_DOM_AUTOMATION_CONTROLLER_H_ | 124 #endif // CONTENT_RENDERER_DOM_AUTOMATION_CONTROLLER_H_ |
| OLD | NEW |