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..12f8024a3c6c4f0d1a7e27aaa97b872414679867 |
--- /dev/null |
+++ b/chromecast/renderer/cast_gin_runner.h |
@@ -0,0 +1,48 @@ |
+// 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 "gin/runner.h" |
+ |
+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: |
+ // Does not take ownership of ContextHolder. |
+ CastGinRunner(blink::WebFrame* frame, gin::ContextHolder* context_holder); |
+ ~CastGinRunner() override {} |
+ |
+ // Runner overrides: |
+ 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; |
+ |
+ 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_ |