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/extensions/context_menus_custom_bindings.h" | 5 #include "chrome/renderer/extensions/context_menus_custom_bindings.h" |
6 | 6 |
7 #include "grit/renderer_resources.h" | 7 #include "grit/renderer_resources.h" |
8 #include "v8/include/v8.h" | 8 #include "v8/include/v8.h" |
9 | 9 |
10 namespace extensions { | 10 namespace extensions { |
11 | 11 |
12 ContextMenusCustomBindings::ContextMenusCustomBindings( | 12 ContextMenusCustomBindings::ContextMenusCustomBindings( |
13 int dependency_count, | 13 int dependency_count, |
14 const char** dependencies) | 14 const char** dependencies) |
15 : ChromeV8Extension( | 15 : ChromeV8Extension( |
16 "extensions/context_menus_custom_bindings.js", | 16 "extensions/context_menus_custom_bindings.js", |
17 IDR_CONTEXT_MENUS_CUSTOM_BINDINGS_JS, | 17 IDR_CONTEXT_MENUS_CUSTOM_BINDINGS_JS, |
18 dependency_count, | 18 dependency_count, |
19 dependencies, | 19 dependencies, |
20 NULL) {} | 20 NULL) {} |
21 | 21 |
22 static v8::Handle<v8::Value> GetNextContextMenuId(const v8::Arguments& args) { | 22 static v8::Handle<v8::Value> GetNextContextMenuId(const v8::Arguments& args) { |
23 // Note: this works because contextMenus.create() only works in the | 23 // Note: this works because contextMenus.create() only works in the |
24 // extension process. If that API is opened up to content scripts, this | 24 // extension process. If that API is opened up to content scripts, this |
25 // will need to change. See crbug.com/77023 | 25 // will need to change. See crbug.com/77023 |
26 static int next_context_menu_id = 1; | 26 static int next_context_menu_id = 1; |
27 return v8::Integer::New(next_context_menu_id++); | 27 return v8::Integer::New(next_context_menu_id++); |
28 } | 28 } |
29 | 29 |
30 v8::Handle<v8::FunctionTemplate> ContextMenusCustomBindings::GetNativeFunction( | 30 void ContextMenusCustomBindings::SetNativeFunctions( |
31 v8::Handle<v8::String> name) { | 31 v8::Handle<v8::Object> object) { |
32 if (name->Equals(v8::String::New("GetNextContextMenuId"))) | 32 RouteFunctionToStatic("GetNextContextMenuId", GetNextContextMenuId, object); |
33 return v8::FunctionTemplate::New(GetNextContextMenuId); | |
34 | |
35 return ChromeV8Extension::GetNativeFunction(name); | |
36 } | 33 } |
37 | 34 |
38 } // extensions | 35 } // extensions |
OLD | NEW |