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
3 // found in the LICENSE file.
5 #include "mojo/apps/js/bindings/gl/module.h"
7 #include "base/logging.h"
8 #include "gin/arguments.h"
9 #include "gin/object_template_builder.h"
10 #include "gin/per_isolate_data.h"
11 #include "gin/wrappable.h"
12 #include "mojo/apps/js/bindings/gl/context.h"
13 #include "mojo/apps/js/bindings/handle.h"
19 const char* kModuleName = "mojo/apps/js/bindings/gl";
23 gin::WrapperInfo kWrapperInfo = { gin::kEmbedderNativeGin };
25 gin::Handle<Context> CreateContext(
26 const gin::Arguments& args,
28 v8::Handle<v8::Function> did_create_callback) {
29 return Context::Create(args.isolate(), handle, did_create_callback);
34 v8::Local<v8::Value> GetModule(v8::Isolate* isolate) {
35 gin::PerIsolateData* data = gin::PerIsolateData::From(isolate);
36 v8::Local<v8::ObjectTemplate> templ = data->GetObjectTemplate(&kWrapperInfo);
38 if (templ.IsEmpty()) {
39 templ = gin::ObjectTemplateBuilder(isolate)
40 .SetMethod("Context", CreateContext)
42 data->SetObjectTemplate(&kWrapperInfo, templ);
45 return templ->NewInstance();