[email protected] | 766a708 | 2012-02-03 23:39:15 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
[email protected] | 766a708 | 2012-02-03 23:39:15 | [diff] [blame] | 5 | #ifndef CONTENT_RENDERER_DOM_AUTOMATION_CONTROLLER_H_ |
6 | #define CONTENT_RENDERER_DOM_AUTOMATION_CONTROLLER_H_ | ||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 7 | |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame] | 8 | #include <stdint.h> |
9 | |||||
10 | #include "base/macros.h" | ||||
[email protected] | cfa856d6 | 2014-02-22 07:58:40 | [diff] [blame] | 11 | #include "content/public/renderer/render_frame_observer.h" |
[email protected] | caa8dc04 | 2014-01-13 12:07:58 | [diff] [blame] | 12 | #include "gin/wrappable.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 13 | |
[email protected] | caa8dc04 | 2014-01-13 12:07:58 | [diff] [blame] | 14 | namespace blink { |
lukasza | df18ba76 | 2017-06-09 22:24:30 | [diff] [blame] | 15 | class WebLocalFrame; |
[email protected] | caa8dc04 | 2014-01-13 12:07:58 | [diff] [blame] | 16 | } |
17 | |||||
18 | namespace gin { | ||||
19 | class Arguments; | ||||
20 | } | ||||
21 | |||||
[email protected] | 9a292e2 | 2012-10-22 15:19:31 | [diff] [blame] | 22 | namespace content { |
23 | |||||
[email protected] | cfa856d6 | 2014-02-22 07:58:40 | [diff] [blame] | 24 | class RenderFrame; |
[email protected] | 480116e7c | 2014-01-13 12:10:04 | [diff] [blame] | 25 | |
Lukasz Anforowicz | d2daf02a | 2017-09-05 20:20:54 | [diff] [blame] | 26 | // Provides implementation of window.domAutomationController javascript object. |
27 | // Javascript can call domAutomationController.send(...) to send arbitrary data | ||||
28 | // to the browser. On the browser side, the data is received via one of the | ||||
29 | // following: | ||||
30 | // - Product code: | ||||
31 | // - Explicit handlers of FrameHostMsg_DomOperationResponse IPC | ||||
32 | // - Test code: | ||||
33 | // - DOMMessageQueue class | ||||
34 | // - ExecuteScriptAndExtractInt/Bool/String functions | ||||
[email protected] | 480116e7c | 2014-01-13 12:10:04 | [diff] [blame] | 35 | class DomAutomationController : public gin::Wrappable<DomAutomationController>, |
[email protected] | cfa856d6 | 2014-02-22 07:58:40 | [diff] [blame] | 36 | public RenderFrameObserver { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 37 | public: |
[email protected] | caa8dc04 | 2014-01-13 12:07:58 | [diff] [blame] | 38 | static gin::WrapperInfo kWrapperInfo; |
39 | |||||
lukasza | df18ba76 | 2017-06-09 22:24:30 | [diff] [blame] | 40 | static void Install(RenderFrame* render_frame, blink::WebLocalFrame* frame); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 41 | |
42 | // Makes the renderer send a javascript value to the app. | ||||
[email protected] | caa8dc04 | 2014-01-13 12:07:58 | [diff] [blame] | 43 | // The value to be sent can be either of type String, |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame] | 44 | // Number (double casted to int32_t) or Boolean. Any other type or no |
[email protected] | caa8dc04 | 2014-01-13 12:07:58 | [diff] [blame] | 45 | // argument at all is ignored. |
[email protected] | 480116e7c | 2014-01-13 12:10:04 | [diff] [blame] | 46 | bool SendMsg(const gin::Arguments& args); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 47 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 48 | private: |
[email protected] | cfa856d6 | 2014-02-22 07:58:40 | [diff] [blame] | 49 | explicit DomAutomationController(RenderFrame* render_view); |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame] | 50 | ~DomAutomationController() override; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 51 | |
[email protected] | caa8dc04 | 2014-01-13 12:07:58 | [diff] [blame] | 52 | // gin::WrappableBase |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame] | 53 | gin::ObjectTemplateBuilder GetObjectTemplateBuilder( |
mohan.reddy | ee0b42a | 2014-10-08 04:53:14 | [diff] [blame] | 54 | v8::Isolate* isolate) override; |
[email protected] | caa8dc04 | 2014-01-13 12:07:58 | [diff] [blame] | 55 | |
xing.xu | c5c7ef89 | 2016-09-01 01:19:30 | [diff] [blame] | 56 | // RenderFrameObserver |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame] | 57 | void OnDestruct() override; |
mdjones | 28f3694 | 2015-09-24 00:48:22 | [diff] [blame] | 58 | void DidCreateScriptContext(v8::Local<v8::Context> context, |
mdjones | 28f3694 | 2015-09-24 00:48:22 | [diff] [blame] | 59 | int world_id) override; |
[email protected] | caa8dc04 | 2014-01-13 12:07:58 | [diff] [blame] | 60 | |
[email protected] | caa8dc04 | 2014-01-13 12:07:58 | [diff] [blame] | 61 | DISALLOW_COPY_AND_ASSIGN(DomAutomationController); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 62 | }; |
63 | |||||
[email protected] | 9a292e2 | 2012-10-22 15:19:31 | [diff] [blame] | 64 | } // namespace content |
65 | |||||
[email protected] | 766a708 | 2012-02-03 23:39:15 | [diff] [blame] | 66 | #endif // CONTENT_RENDERER_DOM_AUTOMATION_CONTROLLER_H_ |