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

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
« no previous file with comments | « chromecast/renderer/cast_content_renderer_client.cc ('k') | chromecast/renderer/cast_gin_runner.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..0f7af0dd2857e643e4ea8d23f146dc3292502bb9
--- /dev/null
+++ b/chromecast/renderer/cast_gin_runner.h
@@ -0,0 +1,63 @@
+// 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 {
+const char kCastContextData[] = "CastContextData";
+}
+
+namespace blink {
+class WebFrame;
+}
+
+namespace chromecast {
+namespace shell {
+
+// 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);
+ ~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:
+ void RemoveUserData(v8::Local<v8::Context> context);
+
+ // 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_
« no previous file with comments | « chromecast/renderer/cast_content_renderer_client.cc ('k') | chromecast/renderer/cast_gin_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698