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