blob: b0a3fb6f8e8c9d0cf310e5655bdc4ad85a0f0f94 [file] [log] [blame]
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <string>
#include "base/macros.h"
#include "content/public/renderer/render_frame_observer.h"
#include "content/public/renderer/render_frame_observer_tracker.h"
#include "mojo/public/cpp/system/core.h"
namespace gin {
class PerContextData;
namespace content {
class MojoContextState;
// MojoBindingsController is responsible for enabling the renderer side of mojo
// bindings. It creates (and destroys) a MojoContextState at the appropriate
// times and handles the necessary browser messages. MojoBindingsController
// destroys itself when the RendererFrame it is created with is destroyed.
class MojoBindingsController
: public RenderFrameObserver,
public RenderFrameObserverTracker<MojoBindingsController> {
MojoBindingsController(RenderFrame* render_frame, bool for_layout_tests);
void RunScriptsAtDocumentStart();
void RunScriptsAtDocumentReady();
~MojoBindingsController() override;
void CreateContextState();
void DestroyContextState(v8::Local<v8::Context> context);
MojoContextState* GetContextState();
// RenderFrameObserver overrides:
void WillReleaseScriptContext(v8::Local<v8::Context> context,
int world_id) override;
void DidClearWindowObject() override;
void OnDestruct() override;
const bool for_layout_tests_;
} // namespace content