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 { |
| 14 const char kCastContextData[] = "CastContextData"; |
| 15 } |
| 16 |
| 17 namespace blink { |
| 18 class WebFrame; |
| 19 } |
| 20 |
| 21 namespace chromecast { |
| 22 namespace shell { |
| 23 |
| 24 // Implementation of gin::Runner that forwards Runner functions to WebFrame. |
| 25 class CastGinRunner : public gin::Runner, |
| 26 public base::SupportsUserData::Data, |
| 27 public content::RenderFrameObserver { |
| 28 public: |
| 29 // Does not take ownership of ContextHolder. |
| 30 CastGinRunner(content::RenderFrame* render_frame); |
| 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 void RemoveUserData(v8::Local<v8::Context> context); |
| 50 |
| 51 // Frame to execute script in. |
| 52 blink::WebFrame* const frame_; |
| 53 |
| 54 // Created by blink bindings to V8. |
| 55 gin::ContextHolder* const context_holder_; |
| 56 |
| 57 DISALLOW_COPY_AND_ASSIGN(CastGinRunner); |
| 58 }; |
| 59 |
| 60 } // namespace shell |
| 61 } // namespace chromecast |
| 62 |
| 63 #endif // CHROMECAST_RENDERER_CAST_GIN_RUNNER_H_ |
OLD | NEW |