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

Unified Diff: chromecast/renderer/cast_gin_runner.h

Issue 2342563003: [chromecast] Enable Mojo javascript bindings for cast_shell (Closed)
Patch Set: Add Mojo JavaScript support for Chromecast Created 4 years, 3 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: chromecast/renderer/cast_gin_runner.h
diff --git a/chromecast/renderer/cast_gin_runner.h b/chromecast/renderer/cast_gin_runner.h
new file mode 100644
index 0000000000000000000000000000000000000000..9865051d1c27685944b39c9286594a990cd029b9
--- /dev/null
+++ b/chromecast/renderer/cast_gin_runner.h
@@ -0,0 +1,61 @@
+// Copyright 2016 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.
+
+#ifndef CHROMECAST_RENDERER_CAST_GIN_RUNNER_H_
+#define CHROMECAST_RENDERER_CAST_GIN_RUNNER_H_
+
+#include "base/macros.h"
+#include "base/supports_user_data.h"
+#include "content/public/renderer/render_frame_observer.h"
+#include "gin/runner.h"
+
+namespace blink {
+class WebFrame;
+}
+
+namespace chromecast {
+namespace shell {
+
+extern const char kCastContextData[];
+
+// Implementation of gin::Runner that forwards Runner functions to WebFrame.
+class CastGinRunner : public gin::Runner,
+ public base::SupportsUserData::Data,
+ public content::RenderFrameObserver {
+ public:
+ // Does not take ownership of ContextHolder.
+ CastGinRunner(content::RenderFrame* render_frame,
+ blink::WebFrame* frame,
+ gin::ContextHolder* context_holder);
+ ~CastGinRunner() override {}
+
+ // gin:Runner implementation:
+ void Run(const std::string& source,
+ const std::string& resource_name) override;
+ v8::Local<v8::Value> Call(v8::Local<v8::Function> function,
+ v8::Local<v8::Value> receiver,
+ int argc,
+ v8::Local<v8::Value> argv[]) override;
+ gin::ContextHolder* GetContextHolder() override;
+
+ // content::RenderFrameObserver implementation:
+ void WillReleaseScriptContext(v8::Local<v8::Context> context,
+ int world_id) override;
+ void DidClearWindowObject() override;
+ void OnDestruct() override;
+
+ private:
+ // Frame to execute script in.
+ blink::WebFrame* const frame_;
+
+ // Created by blink bindings to V8.
+ gin::ContextHolder* const context_holder_;
+
+ DISALLOW_COPY_AND_ASSIGN(CastGinRunner);
+};
+
+} // namespace shell
+} // namespace chromecast
+
+#endif // CHROMECAST_RENDERER_CAST_GIN_RUNNER_H_

Powered by Google App Engine
This is Rietveld 408576698