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 // Custom bindings for the contextMenus API. | 5 // Custom bindings for the contextMenus API. |
6 | 6 |
| 7 var Bindings = require('schema_binding_generator').Bindings; |
| 8 var bindings = new Bindings('contextMenus'); |
| 9 |
7 var contextMenus = requireNative('context_menus'); | 10 var contextMenus = requireNative('context_menus'); |
8 var GetNextContextMenuId = contextMenus.GetNextContextMenuId; | 11 var GetNextContextMenuId = contextMenus.GetNextContextMenuId; |
9 var sendRequest = require('sendRequest').sendRequest; | 12 var sendRequest = require('sendRequest').sendRequest; |
10 | 13 |
11 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); | 14 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); |
12 | 15 |
13 chromeHidden.registerCustomHook('contextMenus', function(bindingsAPI) { | 16 bindings.registerCustomHook(function(bindingsAPI) { |
14 var apiFunctions = bindingsAPI.apiFunctions; | 17 var apiFunctions = bindingsAPI.apiFunctions; |
15 | 18 |
16 chromeHidden.contextMenus = {}; | 19 chromeHidden.contextMenus = {}; |
17 chromeHidden.contextMenus.generatedIdHandlers = {}; | 20 chromeHidden.contextMenus.generatedIdHandlers = {}; |
18 chromeHidden.contextMenus.stringIdHandlers = {}; | 21 chromeHidden.contextMenus.stringIdHandlers = {}; |
19 var eventName = 'contextMenus'; | 22 var eventName = 'contextMenus'; |
20 chromeHidden.contextMenus.event = new chrome.Event(eventName); | 23 chromeHidden.contextMenus.event = new chrome.Event(eventName); |
21 chromeHidden.contextMenus.getIdFromCreateProperties = function(prop) { | 24 chromeHidden.contextMenus.getIdFromCreateProperties = function(prop) { |
22 if (typeof(prop.id) !== 'undefined') | 25 if (typeof(prop.id) !== 'undefined') |
23 return prop.id; | 26 return prop.id; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 94 |
92 apiFunctions.setCustomCallback('removeAll', | 95 apiFunctions.setCustomCallback('removeAll', |
93 function(name, request, response) { | 96 function(name, request, response) { |
94 if (chrome.runtime.lastError) { | 97 if (chrome.runtime.lastError) { |
95 return; | 98 return; |
96 } | 99 } |
97 chromeHidden.contextMenus.generatedIdHandlers = {}; | 100 chromeHidden.contextMenus.generatedIdHandlers = {}; |
98 chromeHidden.contextMenus.stringIdHandlers = {}; | 101 chromeHidden.contextMenus.stringIdHandlers = {}; |
99 }); | 102 }); |
100 }); | 103 }); |
| 104 |
| 105 exports.bindings = bindings.generate(); |
OLD | NEW |