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 "extensions/renderer/console.h" | 5 #include "extensions/renderer/console.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/debug/alias.h" | 8 #include "base/debug/alias.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 } | 66 } |
67 | 67 |
68 void BindLogMethod(v8::Isolate* isolate, | 68 void BindLogMethod(v8::Isolate* isolate, |
69 v8::Local<v8::Object> target, | 69 v8::Local<v8::Object> target, |
70 const std::string& name, | 70 const std::string& name, |
71 LogMethod log_method) { | 71 LogMethod log_method) { |
72 v8::Local<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New( | 72 v8::Local<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New( |
73 isolate, | 73 isolate, |
74 &BoundLogMethodCallback, | 74 &BoundLogMethodCallback, |
75 v8::External::New(isolate, reinterpret_cast<void*>(log_method))); | 75 v8::External::New(isolate, reinterpret_cast<void*>(log_method))); |
| 76 tmpl->RemovePrototype(); |
76 v8::Local<v8::Function> function; | 77 v8::Local<v8::Function> function; |
77 if (!tmpl->GetFunction(isolate->GetCurrentContext()).ToLocal(&function)) { | 78 if (!tmpl->GetFunction(isolate->GetCurrentContext()).ToLocal(&function)) { |
78 LOG(FATAL) << "Could not create log function \"" << name << "\""; | 79 LOG(FATAL) << "Could not create log function \"" << name << "\""; |
79 return; | 80 return; |
80 } | 81 } |
81 v8::Local<v8::String> v8_name = ToV8StringUnsafe(isolate, name); | 82 v8::Local<v8::String> v8_name = ToV8StringUnsafe(isolate, name); |
82 if (!SetProperty(isolate->GetCurrentContext(), target, v8_name, function)) { | 83 if (!SetProperty(isolate->GetCurrentContext(), target, v8_name, function)) { |
83 LOG(WARNING) << "Could not bind log method \"" << name << "\""; | 84 LOG(WARNING) << "Could not bind log method \"" << name << "\""; |
84 } | 85 } |
85 SetProperty(isolate->GetCurrentContext(), target, v8_name, | 86 SetProperty(isolate->GetCurrentContext(), target, v8_name, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 v8::Local<v8::Object> console_object = v8::Object::New(isolate); | 126 v8::Local<v8::Object> console_object = v8::Object::New(isolate); |
126 BindLogMethod(isolate, console_object, "debug", &Debug); | 127 BindLogMethod(isolate, console_object, "debug", &Debug); |
127 BindLogMethod(isolate, console_object, "log", &Log); | 128 BindLogMethod(isolate, console_object, "log", &Log); |
128 BindLogMethod(isolate, console_object, "warn", &Warn); | 129 BindLogMethod(isolate, console_object, "warn", &Warn); |
129 BindLogMethod(isolate, console_object, "error", &Error); | 130 BindLogMethod(isolate, console_object, "error", &Error); |
130 return handle_scope.Escape(console_object); | 131 return handle_scope.Escape(console_object); |
131 } | 132 } |
132 | 133 |
133 } // namespace console | 134 } // namespace console |
134 } // namespace extensions | 135 } // namespace extensions |
OLD | NEW |