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 "content/public/common/service_registry.h" |
| 8 #include "content/public/renderer/render_frame.h" |
| 9 #include "content/renderer/mojo/service_registry_js_wrapper.h" |
7 #include "gin/modules/module_registry.h" | 10 #include "gin/modules/module_registry.h" |
8 #include "gin/per_context_data.h" | 11 #include "gin/per_context_data.h" |
9 #include "gin/public/context_holder.h" | 12 #include "gin/public/context_holder.h" |
10 #include "mojo/bindings/js/core.h" | 13 #include "mojo/bindings/js/core.h" |
11 #include "mojo/bindings/js/support.h" | 14 #include "mojo/bindings/js/support.h" |
12 #include "third_party/WebKit/public/web/WebFrame.h" | 15 #include "third_party/WebKit/public/web/WebFrame.h" |
13 #include "third_party/WebKit/public/web/WebScriptSource.h" | 16 #include "third_party/WebKit/public/web/WebScriptSource.h" |
14 | 17 |
15 using v8::Context; | 18 using v8::Context; |
16 using v8::HandleScope; | 19 using v8::HandleScope; |
(...skipping 23 matching lines...) Expand all Loading... |
40 gin::ModuleRegistry* registry = | 43 gin::ModuleRegistry* registry = |
41 gin::ModuleRegistry::From(context_holder_->context()); | 44 gin::ModuleRegistry::From(context_holder_->context()); |
42 registry->AddBuiltinModule(context_holder_->isolate(), | 45 registry->AddBuiltinModule(context_holder_->isolate(), |
43 mojo::js::Core::kModuleName, | 46 mojo::js::Core::kModuleName, |
44 mojo::js::Core::GetModule( | 47 mojo::js::Core::GetModule( |
45 context_holder_->isolate())); | 48 context_holder_->isolate())); |
46 registry->AddBuiltinModule(context_holder_->isolate(), | 49 registry->AddBuiltinModule(context_holder_->isolate(), |
47 mojo::js::Support::kModuleName, | 50 mojo::js::Support::kModuleName, |
48 mojo::js::Support::GetModule( | 51 mojo::js::Support::GetModule( |
49 context_holder_->isolate())); | 52 context_holder_->isolate())); |
| 53 registry->AddBuiltinModule( |
| 54 context_holder_->isolate(), |
| 55 ServiceRegistryJsWrapper::kModuleName, |
| 56 ServiceRegistryJsWrapper::Create( |
| 57 context_holder_->isolate(), |
| 58 RenderFrame::FromWebFrame(frame_)->GetServiceRegistry()).ToV8()); |
50 } | 59 } |
51 | 60 |
52 void WebUIRunner::Run(const std::string& source, | 61 void WebUIRunner::Run(const std::string& source, |
53 const std::string& resource_name) { | 62 const std::string& resource_name) { |
54 frame_->executeScript( | 63 frame_->executeScript( |
55 blink::WebScriptSource(blink::WebString::fromUTF8(source))); | 64 blink::WebScriptSource(blink::WebString::fromUTF8(source))); |
56 } | 65 } |
57 | 66 |
58 v8::Handle<v8::Value> WebUIRunner::Call(v8::Handle<v8::Function> function, | 67 v8::Handle<v8::Value> WebUIRunner::Call(v8::Handle<v8::Function> function, |
59 v8::Handle<v8::Value> receiver, | 68 v8::Handle<v8::Value> receiver, |
60 int argc, | 69 int argc, |
61 v8::Handle<v8::Value> argv[]) { | 70 v8::Handle<v8::Value> argv[]) { |
62 return frame_->callFunctionEvenIfScriptDisabled(function, receiver, argc, | 71 return frame_->callFunctionEvenIfScriptDisabled(function, receiver, argc, |
63 argv); | 72 argv); |
64 } | 73 } |
65 | 74 |
66 gin::ContextHolder* WebUIRunner::GetContextHolder() { | 75 gin::ContextHolder* WebUIRunner::GetContextHolder() { |
67 return context_holder_; | 76 return context_holder_; |
68 } | 77 } |
69 | 78 |
70 } // namespace content | 79 } // namespace content |
OLD | NEW |