OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/web_ui_runner.h" | 5 #include "content/renderer/web_ui_runner.h" |
6 | 6 |
7 #include "gin/modules/module_registry.h" | 7 #include "gin/modules/module_registry.h" |
8 #include "gin/per_context_data.h" | 8 #include "gin/per_context_data.h" |
9 #include "gin/public/context_holder.h" | 9 #include "gin/public/context_holder.h" |
10 #include "mojo/bindings/js/core.h" | 10 #include "mojo/bindings/js/core.h" |
11 #include "mojo/bindings/js/support.h" | 11 #include "mojo/bindings/js/support.h" |
12 #include "mojo/bindings/js/unicode.h" | |
13 #include "third_party/WebKit/public/web/WebFrame.h" | 12 #include "third_party/WebKit/public/web/WebFrame.h" |
14 #include "third_party/WebKit/public/web/WebScriptSource.h" | 13 #include "third_party/WebKit/public/web/WebScriptSource.h" |
15 | 14 |
16 using v8::Context; | 15 using v8::Context; |
17 using v8::HandleScope; | 16 using v8::HandleScope; |
18 using v8::Isolate; | 17 using v8::Isolate; |
19 using v8::Object; | 18 using v8::Object; |
20 using v8::ObjectTemplate; | 19 using v8::ObjectTemplate; |
21 using v8::Script; | 20 using v8::Script; |
22 | 21 |
(...skipping 18 matching lines...) Expand all Loading... |
41 gin::ModuleRegistry* registry = | 40 gin::ModuleRegistry* registry = |
42 gin::ModuleRegistry::From(context_holder_->context()); | 41 gin::ModuleRegistry::From(context_holder_->context()); |
43 registry->AddBuiltinModule(context_holder_->isolate(), | 42 registry->AddBuiltinModule(context_holder_->isolate(), |
44 mojo::js::Core::kModuleName, | 43 mojo::js::Core::kModuleName, |
45 mojo::js::Core::GetModule( | 44 mojo::js::Core::GetModule( |
46 context_holder_->isolate())); | 45 context_holder_->isolate())); |
47 registry->AddBuiltinModule(context_holder_->isolate(), | 46 registry->AddBuiltinModule(context_holder_->isolate(), |
48 mojo::js::Support::kModuleName, | 47 mojo::js::Support::kModuleName, |
49 mojo::js::Support::GetModule( | 48 mojo::js::Support::GetModule( |
50 context_holder_->isolate())); | 49 context_holder_->isolate())); |
51 registry->AddBuiltinModule(context_holder_->isolate(), | |
52 mojo::js::Unicode::kModuleName, | |
53 mojo::js::Unicode::GetModule( | |
54 context_holder_->isolate())); | |
55 } | 50 } |
56 | 51 |
57 void WebUIRunner::Run(const std::string& source, | 52 void WebUIRunner::Run(const std::string& source, |
58 const std::string& resource_name) { | 53 const std::string& resource_name) { |
59 frame_->executeScript( | 54 frame_->executeScript( |
60 blink::WebScriptSource(blink::WebString::fromUTF8(source))); | 55 blink::WebScriptSource(blink::WebString::fromUTF8(source))); |
61 } | 56 } |
62 | 57 |
63 v8::Handle<v8::Value> WebUIRunner::Call(v8::Handle<v8::Function> function, | 58 v8::Handle<v8::Value> WebUIRunner::Call(v8::Handle<v8::Function> function, |
64 v8::Handle<v8::Value> receiver, | 59 v8::Handle<v8::Value> receiver, |
65 int argc, | 60 int argc, |
66 v8::Handle<v8::Value> argv[]) { | 61 v8::Handle<v8::Value> argv[]) { |
67 return frame_->callFunctionEvenIfScriptDisabled(function, receiver, argc, | 62 return frame_->callFunctionEvenIfScriptDisabled(function, receiver, argc, |
68 argv); | 63 argv); |
69 } | 64 } |
70 | 65 |
71 gin::ContextHolder* WebUIRunner::GetContextHolder() { | 66 gin::ContextHolder* WebUIRunner::GetContextHolder() { |
72 return context_holder_; | 67 return context_holder_; |
73 } | 68 } |
74 | 69 |
75 } // namespace content | 70 } // namespace content |
OLD | NEW |