0
Files
src/content/renderer/dom_automation_controller.h
Chris Fredrickson 96c62db028 Remove ExecuteScriptAndExtractBool
Bug: 1157718
Change-Id: I0c90d67ed41298b73c6850b24a0ee6d6b6af8b4b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4504096
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: Chris Fredrickson <cfredric@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1139227}
2023-05-03 22:12:53 +00:00

70 lines
2.2 KiB
C++

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_RENDERER_DOM_AUTOMATION_CONTROLLER_H_
#define CONTENT_RENDERER_DOM_AUTOMATION_CONTROLLER_H_
#include <stdint.h>
#include "content/common/dom_automation_controller.mojom.h"
#include "content/public/renderer/render_frame_observer.h"
#include "gin/wrappable.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
namespace blink {
class WebLocalFrame;
}
namespace gin {
class Arguments;
}
namespace content {
class RenderFrame;
// Provides implementation of window.domAutomationController javascript object.
// Javascript can call domAutomationController.send(...) to send arbitrary data
// to the browser. On the browser side, the data is received via the
// DOMMessageQueue class.
class DomAutomationController : public gin::Wrappable<DomAutomationController>,
public RenderFrameObserver {
public:
static gin::WrapperInfo kWrapperInfo;
DomAutomationController(const DomAutomationController&) = delete;
DomAutomationController& operator=(const DomAutomationController&) = delete;
static void Install(RenderFrame* render_frame, blink::WebLocalFrame* frame);
// Makes the renderer send a javascript value to the app.
// The value to be sent can be either of type String,
// Number (double casted to int32_t) or Boolean. Any other type or no
// argument at all is ignored.
bool SendMsg(const gin::Arguments& args);
private:
explicit DomAutomationController(RenderFrame* render_view);
~DomAutomationController() override;
// gin::WrappableBase
gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
v8::Isolate* isolate) override;
// RenderFrameObserver
void OnDestruct() override;
void DidCreateScriptContext(v8::Local<v8::Context> context,
int32_t world_id) override;
const mojo::AssociatedRemote<mojom::DomAutomationControllerHost>&
GetDomAutomationControllerHost();
mojo::AssociatedRemote<mojom::DomAutomationControllerHost>
dom_automation_controller_host_;
};
} // namespace content
#endif // CONTENT_RENDERER_DOM_AUTOMATION_CONTROLLER_H_