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 "gin/modules/console.h" | 5 #include "gin/modules/console.h" |
6 | 6 |
7 #include <iostream> | 7 #include <iostream> |
8 | 8 |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "gin/arguments.h" | 10 #include "gin/arguments.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 void Log(const std::vector<std::string>& messages) { | 22 void Log(const std::vector<std::string>& messages) { |
23 std::cout << JoinString(messages, ' ') << std::endl; | 23 std::cout << JoinString(messages, ' ') << std::endl; |
24 } | 24 } |
25 | 25 |
26 WrapperInfo g_wrapper_info = { kEmbedderNativeGin }; | 26 WrapperInfo g_wrapper_info = { kEmbedderNativeGin }; |
27 | 27 |
28 } // namespace | 28 } // namespace |
29 | 29 |
30 const char Console::kModuleName[] = "console"; | 30 const char Console::kModuleName[] = "console"; |
31 | 31 |
32 v8::Local<ObjectTemplate> Console::GetTemplate(v8::Isolate* isolate) { | 32 v8::Local<v8::Value> Console::GetModule(v8::Isolate* isolate) { |
33 PerIsolateData* data = PerIsolateData::From(isolate); | 33 PerIsolateData* data = PerIsolateData::From(isolate); |
34 v8::Local<ObjectTemplate> templ = data->GetObjectTemplate(&g_wrapper_info); | 34 v8::Local<ObjectTemplate> templ = data->GetObjectTemplate(&g_wrapper_info); |
35 if (templ.IsEmpty()) { | 35 if (templ.IsEmpty()) { |
36 templ = ObjectTemplateBuilder(isolate) | 36 templ = ObjectTemplateBuilder(isolate) |
37 .SetMethod("log", Log) | 37 .SetMethod("log", Log) |
38 .Build(); | 38 .Build(); |
39 data->SetObjectTemplate(&g_wrapper_info, templ); | 39 data->SetObjectTemplate(&g_wrapper_info, templ); |
40 } | 40 } |
41 return templ; | 41 return templ->NewInstance(); |
42 } | 42 } |
43 | 43 |
44 } // namespace gin | 44 } // namespace gin |
OLD | NEW |