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

Side by Side Diff: extensions/renderer/resources/runtime_custom_bindings.js

Issue 482603002: Unify logic of stack trace generation for extension errors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add $Error and $String.indexOf to safe builtins Created 6 years, 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 runtime API. 5 // Custom binding for the runtime API.
6 6
7 var binding = require('binding').Binding.create('runtime'); 7 var binding = require('binding').Binding.create('runtime');
8 8
9 var messaging = require('messaging'); 9 var messaging = require('messaging');
10 var runtimeNatives = requireNative('runtime'); 10 var runtimeNatives = requireNative('runtime');
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 var targetId = null; 132 var targetId = null;
133 if (typeof(arguments[nextArg]) == 'string') 133 if (typeof(arguments[nextArg]) == 'string')
134 targetId = arguments[nextArg++]; 134 targetId = arguments[nextArg++];
135 135
136 // connectInfo (second argument) is optional. 136 // connectInfo (second argument) is optional.
137 var connectInfo = null; 137 var connectInfo = null;
138 if (typeof(arguments[nextArg]) == 'object') 138 if (typeof(arguments[nextArg]) == 'object')
139 connectInfo = arguments[nextArg++]; 139 connectInfo = arguments[nextArg++];
140 140
141 if (nextArg != arguments.length) 141 if (nextArg != arguments.length)
142 throw new Error('Invalid arguments to connect.'); 142 throw new $Error.self('Invalid arguments to connect.');
not at google - send to devlin 2014/08/19 16:45:56 new Error()
143 return [targetId, connectInfo]; 143 return [targetId, connectInfo];
144 }); 144 });
145 145
146 apiFunctions.setUpdateArgumentsPreValidate('connectNative', 146 apiFunctions.setUpdateArgumentsPreValidate('connectNative',
147 function(appName) { 147 function(appName) {
148 if (typeof(appName) !== 'string') { 148 if (typeof(appName) !== 'string') {
149 throw new Error('Invalid arguments to connectNative.'); 149 throw new $Error.self('Invalid arguments to connectNative.');
not at google - send to devlin 2014/08/19 16:45:56 new Error()
150 } 150 }
151 return [appName]; 151 return [appName];
152 }); 152 });
153 153
154 apiFunctions.setHandleRequest('connect', function(targetId, connectInfo) { 154 apiFunctions.setHandleRequest('connect', function(targetId, connectInfo) {
155 // Don't let orphaned content scripts communicate with their extension. 155 // Don't let orphaned content scripts communicate with their extension.
156 // http://crbug.com/168263 156 // http://crbug.com/168263
157 if (unloadEvent.wasDispatched) 157 if (unloadEvent.wasDispatched)
158 throw new Error('Error connecting to extension ' + targetId); 158 throw new $Error.self('Error connecting to extension ' + targetId);
not at google - send to devlin 2014/08/19 16:45:56 new Error()
159 159
160 if (!targetId) 160 if (!targetId)
161 targetId = runtime.id; 161 targetId = runtime.id;
162 162
163 var name = ''; 163 var name = '';
164 if (connectInfo && connectInfo.name) 164 if (connectInfo && connectInfo.name)
165 name = connectInfo.name; 165 name = connectInfo.name;
166 166
167 var includeTlsChannelId = 167 var includeTlsChannelId =
168 !!(connectInfo && connectInfo.includeTlsChannelId); 168 !!(connectInfo && connectInfo.includeTlsChannelId);
(...skipping 11 matching lines...) Expand all
180 return; 180 return;
181 181
182 apiFunctions.setHandleRequest('connectNative', 182 apiFunctions.setHandleRequest('connectNative',
183 function(nativeAppName) { 183 function(nativeAppName) {
184 if (!unloadEvent.wasDispatched) { 184 if (!unloadEvent.wasDispatched) {
185 var portId = runtimeNatives.OpenChannelToNativeApp(runtime.id, 185 var portId = runtimeNatives.OpenChannelToNativeApp(runtime.id,
186 nativeAppName); 186 nativeAppName);
187 if (portId >= 0) 187 if (portId >= 0)
188 return messaging.createPort(portId, ''); 188 return messaging.createPort(portId, '');
189 } 189 }
190 throw new Error('Error connecting to native app: ' + nativeAppName); 190 throw new $Error.self('Error connecting to native app: ' + nativeAppName);
not at google - send to devlin 2014/08/19 16:45:56 new Error() ... I think.
191 }); 191 });
192 192
193 apiFunctions.setCustomCallback('getBackgroundPage', 193 apiFunctions.setCustomCallback('getBackgroundPage',
194 function(name, request, response) { 194 function(name, request, response) {
195 if (request.callback) { 195 if (request.callback) {
196 var bg = runtimeNatives.GetExtensionViews(-1, 'BACKGROUND')[0] || null; 196 var bg = runtimeNatives.GetExtensionViews(-1, 'BACKGROUND')[0] || null;
197 request.callback(bg); 197 request.callback(bg);
198 } 198 }
199 request.callback = null; 199 request.callback = null;
200 }); 200 });
201 201
202 bindDirectoryEntryCallback('getPackageDirectoryEntry', apiFunctions); 202 bindDirectoryEntryCallback('getPackageDirectoryEntry', apiFunctions);
203 }); 203 });
204 204
205 exports.bindDirectoryEntryCallback = bindDirectoryEntryCallback; 205 exports.bindDirectoryEntryCallback = bindDirectoryEntryCallback;
206 exports.binding = binding.generate(); 206 exports.binding = binding.generate();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698