OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/renderer/native_handler.h" | 5 #include "chrome/renderer/extensions/native_handler.h" |
6 | 6 |
7 #include "base/memory/linked_ptr.h" | 7 #include "base/memory/linked_ptr.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "chrome/renderer/module_system.h" | 9 #include "chrome/renderer/extensions/module_system.h" |
10 #include "v8/include/v8.h" | 10 #include "v8/include/v8.h" |
11 | 11 |
| 12 namespace extensions { |
| 13 |
12 NativeHandler::NativeHandler() | 14 NativeHandler::NativeHandler() |
13 : object_template_( | 15 : object_template_( |
14 v8::Persistent<v8::ObjectTemplate>::New(v8::ObjectTemplate::New())) { | 16 v8::Persistent<v8::ObjectTemplate>::New(v8::ObjectTemplate::New())) { |
15 } | 17 } |
16 | 18 |
17 NativeHandler::~NativeHandler() { | 19 NativeHandler::~NativeHandler() { |
18 object_template_.Dispose(); | 20 object_template_.Dispose(); |
19 } | 21 } |
20 | 22 |
21 v8::Handle<v8::Object> NativeHandler::NewInstance() { | 23 v8::Handle<v8::Object> NativeHandler::NewInstance() { |
(...skipping 25 matching lines...) Expand all Loading... |
47 v8::External::New(function.get())); | 49 v8::External::New(function.get())); |
48 object_template_->Set(name.c_str(), function_template); | 50 object_template_->Set(name.c_str(), function_template); |
49 } | 51 } |
50 | 52 |
51 void NativeHandler::RouteStaticFunction(const std::string& name, | 53 void NativeHandler::RouteStaticFunction(const std::string& name, |
52 const HandlerFunc handler_func) { | 54 const HandlerFunc handler_func) { |
53 v8::Handle<v8::FunctionTemplate> function_template = | 55 v8::Handle<v8::FunctionTemplate> function_template = |
54 v8::FunctionTemplate::New(handler_func, v8::External::New(this)); | 56 v8::FunctionTemplate::New(handler_func, v8::External::New(this)); |
55 object_template_->Set(name.c_str(), function_template); | 57 object_template_->Set(name.c_str(), function_template); |
56 } | 58 } |
| 59 |
| 60 } // extensions |
OLD | NEW |