| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "mojo/public/bindings/js/mojo.h" | 5 #include "mojo/public/bindings/js/global.h" |
| 6 | 6 |
| 7 #include "gin/converter.h" | 7 #include "gin/modules/module_registry.h" |
| 8 #include "gin/per_isolate_data.h" | 8 #include "gin/per_isolate_data.h" |
| 9 #include "gin/wrapper_info.h" | 9 #include "gin/wrapper_info.h" |
| 10 #include "mojo/public/bindings/js/core.h" | |
| 11 | 10 |
| 12 namespace mojo { | 11 namespace mojo { |
| 13 namespace js { | 12 namespace js { |
| 14 | 13 |
| 15 namespace { | 14 namespace { |
| 16 | 15 |
| 17 gin::WrapperInfo g_mojo_wrapper_info = {}; | 16 gin::WrapperInfo g_wrapper_info = {}; |
| 18 | 17 |
| 19 } | 18 } |
| 20 | 19 |
| 21 v8::Local<v8::ObjectTemplate> GetMojoTemplate(v8::Isolate* isolate) { | 20 v8::Local<v8::ObjectTemplate> GetGlobalTemplate(v8::Isolate* isolate) { |
| 22 gin::PerIsolateData* data = gin::PerIsolateData::From(isolate); | 21 gin::PerIsolateData* data = gin::PerIsolateData::From(isolate); |
| 23 v8::Local<v8::ObjectTemplate> templ = data->GetObjectTemplate( | 22 v8::Local<v8::ObjectTemplate> templ = data->GetObjectTemplate( |
| 24 &g_mojo_wrapper_info); | 23 &g_wrapper_info); |
| 25 if (templ.IsEmpty()) { | 24 if (templ.IsEmpty()) { |
| 26 templ = v8::ObjectTemplate::New(); | 25 templ = v8::ObjectTemplate::New(); |
| 27 templ->Set(gin::StringToSymbol(isolate, "core"), GetCoreTemplate(isolate)); | 26 gin::ModuleRegistry::RegisterGlobals(isolate, templ); |
| 28 data->SetObjectTemplate(&g_mojo_wrapper_info, templ); | 27 data->SetObjectTemplate(&g_wrapper_info, templ); |
| 29 } | 28 } |
| 30 return templ; | 29 return templ; |
| 31 } | 30 } |
| 32 | 31 |
| 33 } // namespace js | 32 } // namespace js |
| 34 } // namespace mojo | 33 } // namespace mojo |
| OLD | NEW |