| 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 extension API. | 5 // Custom binding for the extension API. |
| 6 | 6 |
| 7 var binding = require('binding').Binding.create('extension'); | 7 var binding = require('binding').Binding.create('extension'); |
| 8 | 8 |
| 9 var extensionNatives = requireNative('extension'); | 9 var extensionNatives = requireNative('extension'); |
| 10 var forEach = require('utils').forEach; |
| 10 var GetExtensionViews = extensionNatives.GetExtensionViews; | 11 var GetExtensionViews = extensionNatives.GetExtensionViews; |
| 11 var runtimeNatives = requireNative('runtime'); | 12 var runtimeNatives = requireNative('runtime'); |
| 12 var OpenChannelToExtension = runtimeNatives.OpenChannelToExtension; | 13 var OpenChannelToExtension = runtimeNatives.OpenChannelToExtension; |
| 13 var OpenChannelToNativeApp = runtimeNatives.OpenChannelToNativeApp; | 14 var OpenChannelToNativeApp = runtimeNatives.OpenChannelToNativeApp; |
| 14 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); | 15 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); |
| 15 var chrome = requireNative('chrome').GetChrome(); | 16 var chrome = requireNative('chrome').GetChrome(); |
| 16 var sendMessageUpdateArguments = | 17 var sendMessageUpdateArguments = |
| 17 require('miscellaneous_bindings').sendMessageUpdateArguments; | 18 require('miscellaneous_bindings').sendMessageUpdateArguments; |
| 18 | 19 |
| 19 var inIncognitoContext = requireNative('process').InIncognitoContext(); | 20 var inIncognitoContext = requireNative('process').InIncognitoContext(); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 72 |
| 72 // Alias several messaging deprecated APIs to their runtime counterparts. | 73 // Alias several messaging deprecated APIs to their runtime counterparts. |
| 73 var mayNeedAlias = [ | 74 var mayNeedAlias = [ |
| 74 // Types | 75 // Types |
| 75 'Port', | 76 'Port', |
| 76 // Functions | 77 // Functions |
| 77 'connect', 'sendMessage', 'connectNative', 'sendNativeMessage', | 78 'connect', 'sendMessage', 'connectNative', 'sendNativeMessage', |
| 78 // Events | 79 // Events |
| 79 'onConnect', 'onConnectExternal', 'onMessage', 'onMessageExternal' | 80 'onConnect', 'onConnectExternal', 'onMessage', 'onMessageExternal' |
| 80 ]; | 81 ]; |
| 81 mayNeedAlias.forEach(function(alias) { | 82 forEach(mayNeedAlias, function(i, alias) { |
| 82 // Checking existence isn't enough since some functions are disabled via | 83 // Checking existence isn't enough since some functions are disabled via |
| 83 // getters that throw exceptions. Assume that any getter is such a function. | 84 // getters that throw exceptions. Assume that any getter is such a function. |
| 84 if (chrome.runtime.hasOwnProperty(alias) && | 85 if (chrome.runtime.hasOwnProperty(alias) && |
| 85 chrome.runtime.__lookupGetter__(alias) === undefined) { | 86 chrome.runtime.__lookupGetter__(alias) === undefined) { |
| 86 extension[alias] = chrome.runtime[alias]; | 87 extension[alias] = chrome.runtime[alias]; |
| 87 } | 88 } |
| 88 }); | 89 }); |
| 89 | 90 |
| 90 apiFunctions.setUpdateArgumentsPreValidate('sendRequest', | 91 apiFunctions.setUpdateArgumentsPreValidate('sendRequest', |
| 91 sendMessageUpdateArguments.bind(null, 'sendRequest')); | 92 sendMessageUpdateArguments.bind(null, 'sendRequest')); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 105 }; | 106 }; |
| 106 if (contextType == 'BLESSED_EXTENSION') { | 107 if (contextType == 'BLESSED_EXTENSION') { |
| 107 extension.onRequestExternal.addListener = function() { | 108 extension.onRequestExternal.addListener = function() { |
| 108 throw new Error(sendRequestIsDisabled); | 109 throw new Error(sendRequestIsDisabled); |
| 109 }; | 110 }; |
| 110 } | 111 } |
| 111 } | 112 } |
| 112 }); | 113 }); |
| 113 | 114 |
| 114 exports.binding = binding.generate(); | 115 exports.binding = binding.generate(); |
| OLD | NEW |