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/object_backed_native_handler.h" | 5 #include "extensions/renderer/object_backed_native_handler.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/linked_ptr.h" | 10 #include "base/memory/linked_ptr.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 v8::Local<v8::Object> data = v8::Object::New(isolate); | 118 v8::Local<v8::Object> data = v8::Object::New(isolate); |
119 SetPrivate(data, kHandlerFunction, | 119 SetPrivate(data, kHandlerFunction, |
120 v8::External::New(isolate, new HandlerFunction(handler_function))); | 120 v8::External::New(isolate, new HandlerFunction(handler_function))); |
121 DCHECK(feature_name.empty() || | 121 DCHECK(feature_name.empty() || |
122 ExtensionAPI::GetSharedInstance()->GetFeatureDependency(feature_name)) | 122 ExtensionAPI::GetSharedInstance()->GetFeatureDependency(feature_name)) |
123 << feature_name; | 123 << feature_name; |
124 SetPrivate(data, kFeatureName, | 124 SetPrivate(data, kFeatureName, |
125 v8_helpers::ToV8StringUnsafe(isolate, feature_name)); | 125 v8_helpers::ToV8StringUnsafe(isolate, feature_name)); |
126 v8::Local<v8::FunctionTemplate> function_template = | 126 v8::Local<v8::FunctionTemplate> function_template = |
127 v8::FunctionTemplate::New(isolate, Router, data); | 127 v8::FunctionTemplate::New(isolate, Router, data); |
| 128 function_template->RemovePrototype(); |
128 v8::Local<v8::ObjectTemplate>::New(isolate, object_template_) | 129 v8::Local<v8::ObjectTemplate>::New(isolate, object_template_) |
129 ->Set(isolate, name.c_str(), function_template); | 130 ->Set(isolate, name.c_str(), function_template); |
130 router_data_.Append(data); | 131 router_data_.Append(data); |
131 } | 132 } |
132 | 133 |
133 v8::Isolate* ObjectBackedNativeHandler::GetIsolate() const { | 134 v8::Isolate* ObjectBackedNativeHandler::GetIsolate() const { |
134 return context_->isolate(); | 135 return context_->isolate(); |
135 } | 136 } |
136 | 137 |
137 void ObjectBackedNativeHandler::Invalidate() { | 138 void ObjectBackedNativeHandler::Invalidate() { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 v8::Local<v8::Object> obj, | 222 v8::Local<v8::Object> obj, |
222 const char* key) { | 223 const char* key) { |
223 obj->DeletePrivate(context, | 224 obj->DeletePrivate(context, |
224 v8::Private::ForApi( | 225 v8::Private::ForApi( |
225 context->GetIsolate(), | 226 context->GetIsolate(), |
226 v8::String::NewFromUtf8(context->GetIsolate(), key))) | 227 v8::String::NewFromUtf8(context->GetIsolate(), key))) |
227 .FromJust(); | 228 .FromJust(); |
228 } | 229 } |
229 | 230 |
230 } // namespace extensions | 231 } // namespace extensions |
OLD | NEW |