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

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

Issue 12440030: Use utils.forEach everywhere rather than Array.prototype.forEach to guard (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make foreach of an array give numbers Created 7 years, 9 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 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
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
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();
OLDNEW
« no previous file with comments | « chrome/renderer/resources/extensions/event.js ('k') | chrome/renderer/resources/extensions/file_system_custom_bindings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698