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