OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROMECAST_RENDERER_CAST_GIN_RUNNER_H_ |
| 6 #define CHROMECAST_RENDERER_CAST_GIN_RUNNER_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "base/supports_user_data.h" |
| 10 #include "content/public/renderer/render_frame_observer.h" |
| 11 #include "gin/runner.h" |
| 12 |
| 13 namespace blink { |
| 14 class WebFrame; |
| 15 } |
| 16 |
| 17 namespace chromecast { |
| 18 namespace shell { |
| 19 |
| 20 extern const char kCastContextData[]; |
| 21 |
| 22 // Implementation of gin::Runner that forwards Runner functions to WebFrame. |
| 23 class CastGinRunner : public gin::Runner, |
| 24 public base::SupportsUserData::Data, |
| 25 public content::RenderFrameObserver { |
| 26 public: |
| 27 // Does not take ownership of ContextHolder. |
| 28 CastGinRunner(content::RenderFrame* render_frame, |
| 29 blink::WebFrame* frame, |
| 30 gin::ContextHolder* context_holder); |
| 31 ~CastGinRunner() override {} |
| 32 |
| 33 // gin:Runner implementation: |
| 34 void Run(const std::string& source, |
| 35 const std::string& resource_name) override; |
| 36 v8::Local<v8::Value> Call(v8::Local<v8::Function> function, |
| 37 v8::Local<v8::Value> receiver, |
| 38 int argc, |
| 39 v8::Local<v8::Value> argv[]) override; |
| 40 gin::ContextHolder* GetContextHolder() override; |
| 41 |
| 42 // content::RenderFrameObserver implementation: |
| 43 void WillReleaseScriptContext(v8::Local<v8::Context> context, |
| 44 int world_id) override; |
| 45 void DidClearWindowObject() override; |
| 46 void OnDestruct() override; |
| 47 |
| 48 private: |
| 49 // Frame to execute script in. |
| 50 blink::WebFrame* const frame_; |
| 51 |
| 52 // Created by blink bindings to V8. |
| 53 gin::ContextHolder* const context_holder_; |
| 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(CastGinRunner); |
| 56 }; |
| 57 |
| 58 } // namespace shell |
| 59 } // namespace chromecast |
| 60 |
| 61 #endif // CHROMECAST_RENDERER_CAST_GIN_RUNNER_H_ |
OLD | NEW |