| 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 "services/js/js_app_bridge_module.h" | 5 #include "services/js/js_app_bridge_module.h" |
| 6 | 6 |
| 7 #include "gin/arguments.h" | 7 #include "gin/arguments.h" |
| 8 #include "gin/converter.h" | 8 #include "gin/converter.h" |
| 9 #include "gin/object_template_builder.h" | 9 #include "gin/object_template_builder.h" |
| 10 #include "gin/per_isolate_data.h" | 10 #include "gin/per_isolate_data.h" |
| 11 #include "mojo/edk/js/handle.h" | 11 #include "mojo/edk/js/handle.h" |
| 12 #include "services/js/js_app.h" | 12 #include "services/js/js_app.h" |
| 13 | 13 |
| 14 namespace mojo { | |
| 15 namespace js { | 14 namespace js { |
| 16 | 15 |
| 17 namespace { | 16 namespace { |
| 18 | 17 |
| 19 gin::WrapperInfo g_wrapper_info = {gin::kEmbedderNativeGin}; | 18 gin::WrapperInfo g_wrapper_info = {gin::kEmbedderNativeGin}; |
| 20 | 19 |
| 21 } // namespace | 20 } // namespace |
| 22 | 21 |
| 23 const char AppBridge::kModuleName[] = "services/js/app_bridge"; | 22 const char AppBridge::kModuleName[] = "services/js/app_bridge"; |
| 24 | 23 |
| 25 v8::Local<v8::Value> AppBridge::GetModule(JSApp* js_app, v8::Isolate* isolate) { | 24 v8::Local<v8::Value> AppBridge::GetModule(JSApp* js_app, v8::Isolate* isolate) { |
| 26 gin::PerIsolateData* data = gin::PerIsolateData::From(isolate); | 25 gin::PerIsolateData* data = gin::PerIsolateData::From(isolate); |
| 27 v8::Local<v8::ObjectTemplate> templ = | 26 v8::Local<v8::ObjectTemplate> templ = |
| 28 data->GetObjectTemplate(&g_wrapper_info); | 27 data->GetObjectTemplate(&g_wrapper_info); |
| 29 | 28 |
| 30 if (templ.IsEmpty()) { | 29 if (templ.IsEmpty()) { |
| 31 templ = gin::ObjectTemplateBuilder(isolate) | 30 templ = gin::ObjectTemplateBuilder(isolate) |
| 32 .SetMethod("quit", | 31 .SetMethod("quit", |
| 33 base::Bind(&JSApp::Quit, base::Unretained(js_app))) | 32 base::Bind(&JSApp::Quit, base::Unretained(js_app))) |
| 34 .Build(); | 33 .Build(); |
| 35 data->SetObjectTemplate(&g_wrapper_info, templ); | 34 data->SetObjectTemplate(&g_wrapper_info, templ); |
| 36 } | 35 } |
| 37 | 36 |
| 38 return templ->NewInstance(); | 37 return templ->NewInstance(); |
| 39 } | 38 } |
| 40 | 39 |
| 41 } // namespace js | 40 } // namespace js |
| 42 } // namespace mojo | |
| OLD | NEW |