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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "content/public/renderer/render_view_observer.h" | 9 #include "content/public/renderer/render_frame_observer.h" |
10 #include "gin/wrappable.h" | 10 #include "gin/wrappable.h" |
11 | 11 |
12 /* DomAutomationController class: | 12 /* DomAutomationController class: |
13 Bound to Javascript window.domAutomationController object. | 13 Bound to Javascript window.domAutomationController object. |
14 At the very basic, this object makes any native value (string, numbers, | 14 At the very basic, this object makes any native value (string, numbers, |
15 boolean) from javascript available to the automation host in Cpp. | 15 boolean) from javascript available to the automation host in Cpp. |
16 Any renderer implementation that is built with this binding will allow the | 16 Any renderer implementation that is built with this binding will allow the |
17 above facility. | 17 above facility. |
18 The intended use of this object is to expose the DOM Objects and their | 18 The intended use of this object is to expose the DOM Objects and their |
19 attributes to the automation host. | 19 attributes to the automation host. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 namespace blink { | 74 namespace blink { |
75 class WebFrame; | 75 class WebFrame; |
76 } | 76 } |
77 | 77 |
78 namespace gin { | 78 namespace gin { |
79 class Arguments; | 79 class Arguments; |
80 } | 80 } |
81 | 81 |
82 namespace content { | 82 namespace content { |
83 | 83 |
84 class RenderViewImpl; | 84 class RenderFrame; |
85 | 85 |
86 class DomAutomationController : public gin::Wrappable<DomAutomationController>, | 86 class DomAutomationController : public gin::Wrappable<DomAutomationController>, |
87 public RenderViewObserver { | 87 public RenderFrameObserver { |
88 public: | 88 public: |
89 static gin::WrapperInfo kWrapperInfo; | 89 static gin::WrapperInfo kWrapperInfo; |
90 | 90 |
91 static void Install(RenderViewImpl* render_view, blink::WebFrame* frame); | 91 static void Install(RenderFrame* render_frame, blink::WebFrame* frame); |
92 | 92 |
93 // Makes the renderer send a javascript value to the app. | 93 // Makes the renderer send a javascript value to the app. |
94 // The value to be sent can be either of type String, | 94 // The value to be sent can be either of type String, |
95 // Number (double casted to int32) or Boolean. Any other type or no | 95 // Number (double casted to int32) or Boolean. Any other type or no |
96 // argument at all is ignored. | 96 // argument at all is ignored. |
97 bool SendMsg(const gin::Arguments& args); | 97 bool SendMsg(const gin::Arguments& args); |
98 | 98 |
99 // Makes the renderer send a javascript value to the app. | 99 // Makes the renderer send a javascript value to the app. |
100 // The value should be properly formed JSON. | 100 // The value should be properly formed JSON. |
101 bool SendJSON(const std::string& json); | 101 bool SendJSON(const std::string& json); |
102 | 102 |
103 // Sends a string with a provided Automation Id. | 103 // Sends a string with a provided Automation Id. |
104 bool SendWithId(int automation_id, const std::string& str); | 104 bool SendWithId(int automation_id, const std::string& str); |
105 | 105 |
106 bool SetAutomationId(int automation_id); | 106 bool SetAutomationId(int automation_id); |
107 | 107 |
108 private: | 108 private: |
109 explicit DomAutomationController(RenderViewImpl* render_view); | 109 explicit DomAutomationController(RenderFrame* render_view); |
110 virtual ~DomAutomationController(); | 110 virtual ~DomAutomationController(); |
111 | 111 |
112 // gin::WrappableBase | 112 // gin::WrappableBase |
113 virtual gin::ObjectTemplateBuilder GetObjectTemplateBuilder( | 113 virtual gin::ObjectTemplateBuilder GetObjectTemplateBuilder( |
114 v8::Isolate* isolate) OVERRIDE; | 114 v8::Isolate* isolate) OVERRIDE; |
115 | 115 |
116 // RenderViewObserver | 116 // RenderViewObserver |
117 virtual void OnDestruct() OVERRIDE; | 117 virtual void OnDestruct() OVERRIDE; |
118 | 118 |
119 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. |
120 | 120 |
121 DISALLOW_COPY_AND_ASSIGN(DomAutomationController); | 121 DISALLOW_COPY_AND_ASSIGN(DomAutomationController); |
122 }; | 122 }; |
123 | 123 |
124 } // namespace content | 124 } // namespace content |
125 | 125 |
126 #endif // CONTENT_RENDERER_DOM_AUTOMATION_CONTROLLER_H_ | 126 #endif // CONTENT_RENDERER_DOM_AUTOMATION_CONTROLLER_H_ |
OLD | NEW |