Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Side by Side Diff: chrome/renderer/resources/extensions/extension_custom_bindings.js

Issue 15855010: Make ExtensionMsg_MessageInvoke run a module system function rather than a (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test compile Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 forEach = require('utils').forEach;
11 var GetExtensionViews = extensionNatives.GetExtensionViews; 11 var GetExtensionViews = extensionNatives.GetExtensionViews;
12 var miscBindings = require('miscellaneous_bindings');
12 var runtimeNatives = requireNative('runtime'); 13 var runtimeNatives = requireNative('runtime');
13 var OpenChannelToExtension = runtimeNatives.OpenChannelToExtension; 14 var OpenChannelToExtension = runtimeNatives.OpenChannelToExtension;
14 var OpenChannelToNativeApp = runtimeNatives.OpenChannelToNativeApp; 15 var OpenChannelToNativeApp = runtimeNatives.OpenChannelToNativeApp;
15 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
16 var chrome = requireNative('chrome').GetChrome(); 16 var chrome = requireNative('chrome').GetChrome();
17 var sendMessageUpdateArguments =
18 require('miscellaneous_bindings').sendMessageUpdateArguments;
19 17
20 var inIncognitoContext = requireNative('process').InIncognitoContext(); 18 var inIncognitoContext = requireNative('process').InIncognitoContext();
21 var sendRequestIsDisabled = requireNative('process').IsSendRequestDisabled(); 19 var sendRequestIsDisabled = requireNative('process').IsSendRequestDisabled();
22 var contextType = requireNative('process').GetContextType(); 20 var contextType = requireNative('process').GetContextType();
23 var manifestVersion = requireNative('process').GetManifestVersion(); 21 var manifestVersion = requireNative('process').GetManifestVersion();
24 22
25 // This should match chrome.windows.WINDOW_ID_NONE. 23 // This should match chrome.windows.WINDOW_ID_NONE.
26 // 24 //
27 // We can't use chrome.windows.WINDOW_ID_NONE directly because the 25 // We can't use chrome.windows.WINDOW_ID_NONE directly because the
28 // chrome.windows API won't exist unless this extension has permission for it; 26 // chrome.windows API won't exist unless this extension has permission for it;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 forEach(mayNeedAlias, function(i, alias) { 80 forEach(mayNeedAlias, function(i, alias) {
83 // Checking existence isn't enough since some functions are disabled via 81 // Checking existence isn't enough since some functions are disabled via
84 // getters that throw exceptions. Assume that any getter is such a function. 82 // getters that throw exceptions. Assume that any getter is such a function.
85 if (chrome.runtime.hasOwnProperty(alias) && 83 if (chrome.runtime.hasOwnProperty(alias) &&
86 chrome.runtime.__lookupGetter__(alias) === undefined) { 84 chrome.runtime.__lookupGetter__(alias) === undefined) {
87 extension[alias] = chrome.runtime[alias]; 85 extension[alias] = chrome.runtime[alias];
88 } 86 }
89 }); 87 });
90 88
91 apiFunctions.setUpdateArgumentsPreValidate('sendRequest', 89 apiFunctions.setUpdateArgumentsPreValidate('sendRequest',
92 sendMessageUpdateArguments.bind(null, 'sendRequest')); 90 miscBindings.sendMessageUpdateArguments.bind(null, 'sendRequest'));
93 91
94 apiFunctions.setHandleRequest('sendRequest', 92 apiFunctions.setHandleRequest('sendRequest',
95 function(targetId, request, responseCallback) { 93 function(targetId, request, responseCallback) {
96 if (sendRequestIsDisabled) 94 if (sendRequestIsDisabled)
97 throw new Error(sendRequestIsDisabled); 95 throw new Error(sendRequestIsDisabled);
98 var port = chrome.runtime.connect(targetId || extensionId, 96 var port = chrome.runtime.connect(targetId || extensionId,
99 {name: chromeHidden.kRequestChannel}); 97 {name: miscBindings.kRequestChannel});
100 chromeHidden.Port.sendMessageImpl(port, request, responseCallback); 98 miscBindings.sendMessageImpl(port, request, responseCallback);
101 }); 99 });
102 100
103 if (sendRequestIsDisabled) { 101 if (sendRequestIsDisabled) {
104 extension.onRequest.addListener = function() { 102 extension.onRequest.addListener = function() {
105 throw new Error(sendRequestIsDisabled); 103 throw new Error(sendRequestIsDisabled);
106 }; 104 };
107 if (contextType == 'BLESSED_EXTENSION') { 105 if (contextType == 'BLESSED_EXTENSION') {
108 extension.onRequestExternal.addListener = function() { 106 extension.onRequestExternal.addListener = function() {
109 throw new Error(sendRequestIsDisabled); 107 throw new Error(sendRequestIsDisabled);
110 }; 108 };
111 } 109 }
112 } 110 }
113 }); 111 });
114 112
115 exports.binding = binding.generate(); 113 exports.binding = binding.generate();
OLDNEW
« no previous file with comments | « chrome/renderer/resources/extensions/event.js ('k') | chrome/renderer/resources/extensions/miscellaneous_bindings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698