Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Unified Diff: content/renderer/dom_automation_controller.h

Issue 131573003: Convert DomAutomationController from CppBoundClass to gin::Wrappable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/dom_automation_controller.h
diff --git a/content/renderer/dom_automation_controller.h b/content/renderer/dom_automation_controller.h
index 0f6a74a30cb0aaff200227a9035861d082efbc3d..8098b29b93d7180a842a7e84ea347bb0fdc0d425 100644
--- a/content/renderer/dom_automation_controller.h
+++ b/content/renderer/dom_automation_controller.h
@@ -5,8 +5,8 @@
#ifndef CONTENT_RENDERER_DOM_AUTOMATION_CONTROLLER_H_
#define CONTENT_RENDERER_DOM_AUTOMATION_CONTROLLER_H_
-#include "ipc/ipc_sender.h"
-#include "webkit/renderer/cpp_bound_class.h"
+#include "base/basictypes.h"
+#include "gin/wrappable.h"
/* DomAutomationController class:
Bound to Javascript window.domAutomationController object.
@@ -50,7 +50,7 @@
(0) Initialization step where DAController is bound to the renderer
and the view_id of the renderer is supplied to the DAController for
- routing message in (5). (routing_id_)
+ routing message in (5).
(1) A 'javascript:' url is sent from the test process to master as an IPC
message. A unique routing id is generated at this stage (automation_id_)
(2) The automation_id_ of step (1) is supplied to DAController by calling
@@ -61,8 +61,8 @@
(4) A callback is generated as a result of domAutomationController.send()
into Cpp. The supplied value is received as a result of this callback.
(5) The value received in (4) is sent to the master along with the
- stored automation_id_ as an IPC message. routing_id_ is used to route
- the message. (IPC messages, ViewHostMsg_*DomAutomation* )
+ stored automation_id_ as an IPC message. The frame_'s RenderFrameImpl is
+ used to route the message. (IPC messages, ViewHostMsg_*DomAutomation* )
(6) The value and the automation_id_ is extracted out of the message received
in (5). This value is relayed to AProxy using another IPC message.
automation_id_ is used to route the message.
@@ -70,57 +70,50 @@
*/
+namespace blink {
+class WebFrame;
+}
+
+namespace gin {
+class Arguments;
+}
+
namespace content {
-// TODO(vibhor): Add another method-pair like sendLater() and sendNow()
-// sendLater() should keep building a json serializer
-// sendNow() should send the above serializer as a string.
-class DomAutomationController : public webkit_glue::CppBoundClass {
+class DomAutomationController : public gin::Wrappable<DomAutomationController> {
public:
- DomAutomationController();
+ static gin::WrapperInfo kWrapperInfo;
+
+ static void Install(blink::WebFrame* frame);
// Makes the renderer send a javascript value to the app.
- // The value to be sent can be either of type NPString,
- // Number (double casted to int32) or boolean.
- // The function returns true/false based on the result of actual send over
- // IPC. It sets the return value to null on unexpected errors or arguments.
- void Send(const webkit_glue::CppArgumentList& args,
- webkit_glue::CppVariant* result);
+ // The value to be sent can be either of type String,
+ // Number (double casted to int32) or Boolean. Any other type or no
+ // argument at all is ignored.
+ bool Send(const gin::Arguments& args);
// Makes the renderer send a javascript value to the app.
- // The value must be a NPString and should be properly formed JSON.
- // This function does not modify/escape the returned string in any way.
- void SendJSON(const webkit_glue::CppArgumentList& args,
- webkit_glue::CppVariant* result);
+ // The value should be properly formed JSON.
+ bool SendJSON(const std::string& json);
// Sends a string with a provided Automation Id.
- // Expects two javascript values; the first must be a number type and will be
- // used as the Automation Id, the second must be of type NPString.
- // The function returns true/false to the javascript based on the success
- // of the send over IPC. It sets the javascript return value to null on
- // unexpected errors or arguments.
- void SendWithId(const webkit_glue::CppArgumentList& args,
- webkit_glue::CppVariant* result);
-
- void SetAutomationId(const webkit_glue::CppArgumentList& args,
- webkit_glue::CppVariant* result);
+ bool SendWithId(int automation_id, const std::string& str);
- // TODO(vibhor): Implement later
- // static CppBindingObjectMethod sendLater;
- // static CppBindingObjectMethod sendNow;
+ bool SetAutomationId(int automation_id);
- void set_routing_id(int routing_id) { routing_id_ = routing_id; }
+ private:
+ explicit DomAutomationController(blink::WebFrame* frame);
+ virtual ~DomAutomationController();
- void set_message_sender(IPC::Sender* sender) {
- sender_ = sender;
- }
+ // gin::WrappableBase
+ virtual gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
+ v8::Isolate* isolate) OVERRIDE;
- private:
- IPC::Sender* sender_;
+ blink::WebFrame* frame_;
abarth-chromium 2014/01/12 01:51:56 What keeps this pointer from becoming stale?
- // Refer to the comments at the top of the file for more details.
- int routing_id_; // routing id to be used by first channel.
int automation_id_; // routing id to be used by the next channel.
+
+ DISALLOW_COPY_AND_ASSIGN(DomAutomationController);
};
} // namespace content
« no previous file with comments | « chrome/browser/extensions/extension_keybinding_apitest.cc ('k') | content/renderer/dom_automation_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698