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 #include "chromecast/renderer/cast_gin_runner.h" | |
6 | |
7 #include "gin/per_context_data.h" | |
8 #include "third_party/WebKit/public/web/WebFrame.h" | |
9 #include "third_party/WebKit/public/web/WebScriptSource.h" | |
10 | |
11 namespace chromecast { | |
12 namespace shell { | |
13 | |
14 CastGinRunner::CastGinRunner(blink::WebFrame* frame, | |
15 gin::ContextHolder* context_holder) | |
16 : frame_(frame), context_holder_(context_holder) { | |
derekjchow1
2016/09/14 21:20:13
DCHECK(context_holder)?
jarhar
2016/09/15 00:32:42
Done.
| |
17 DCHECK(frame_); | |
18 v8::Isolate::Scope isolate_scope(context_holder->isolate()); | |
19 v8::HandleScope handle_scope(context_holder->isolate()); | |
20 // Note: this installs the runner globally. If we need to support more than | |
21 // one runner at a time we'll have to revisit this. | |
22 gin::PerContextData::From(context_holder->context())->set_runner(this); | |
23 } | |
24 | |
25 void CastGinRunner::Run(const std::string& source, | |
26 const std::string& resource_name) { | |
27 frame_->executeScript( | |
28 blink::WebScriptSource(blink::WebString::fromUTF8(source))); | |
29 } | |
30 | |
31 v8::Local<v8::Value> CastGinRunner::Call(v8::Local<v8::Function> function, | |
32 v8::Local<v8::Value> receiver, | |
33 int argc, | |
34 v8::Local<v8::Value> argv[]) { | |
35 return frame_->callFunctionEvenIfScriptDisabled(function, receiver, argc, | |
36 argv); | |
37 } | |
38 | |
39 gin::ContextHolder* CastGinRunner::GetContextHolder() { | |
40 return context_holder_; | |
41 } | |
42 | |
43 } // namespace shell | |
44 } // namespace chromecast | |
OLD | NEW |