OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2014 The Native Client Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 'use strict'; | 7 'use strict'; |
8 | 8 |
9 // The background page of the debugger extension has a few purposes: | 9 // The background page of the debugger extension has a few purposes: |
10 // - Track and react to nacl process create / exit / suspend. | 10 // - Track and react to nacl process create / exit / suspend. |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 } | 285 } |
286 }); | 286 }); |
287 | 287 |
288 // Drop the listener on disconnect. | 288 // Drop the listener on disconnect. |
289 port.onDisconnect.addListener(function() { | 289 port.onDisconnect.addListener(function() { |
290 delete g_listeners[id]; | 290 delete g_listeners[id]; |
291 }); | 291 }); |
292 | 292 |
293 // Announce the new module. | 293 // Announce the new module. |
294 notifyListeners('join'); | 294 notifyListeners('join'); |
295 }; | 295 } |
296 | 296 |
297 /** | 297 /** |
298 * Listen for internal connection events (from main.js). | 298 * Listen for internal connection events (from main.js). |
299 */ | 299 */ |
300 chrome.runtime.onConnect.addListener(handleConnect); | 300 chrome.runtime.onConnect.addListener(handleConnect); |
301 | 301 |
302 /** | 302 /** |
303 * Allow an external connection only for testing and install check. | 303 * Allow an external connection only for testing and install check. |
304 */ | 304 */ |
305 chrome.runtime.onConnectExternal.addListener(function(port) { | 305 chrome.runtime.onConnectExternal.addListener(function(port) { |
306 // Check the sender only when not in testing mode. | 306 // Check the sender only when not in testing mode. |
307 if (navigator.userAgent.indexOf('ChromeTestAgent/') < 0) { | 307 if (navigator.userAgent.indexOf('ChromeTestAgent/') < 0) { |
308 // Reject if the sender is an extension (unsupported for now). | 308 // Reject if the sender is an extension (unsupported for now). |
309 // Allow urls (as we're only whitelisting the install page). | 309 // Allow urls (as we're only whitelisting the install page). |
310 if (port.sender.id !== undefined) { | 310 if (port.sender.id !== undefined) { |
311 port.disconnect(); | 311 port.disconnect(); |
312 return; | 312 return; |
313 } | 313 } |
314 } | 314 } |
315 handleConnect(port); | 315 handleConnect(port); |
316 }); | 316 }); |
OLD | NEW |