| 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 bindings for the tabs API. | 5 // Custom bindings for the tabs API. |
| 6 | 6 |
| 7 (function() { | 7 (function() { |
| 8 | 8 |
| 9 native function GetChromeHidden(); | 9 native function GetChromeHidden(); |
| 10 native function OpenChannelToTab(); | 10 native function OpenChannelToTab(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 port.onMessage.addListener(function(response) { | 36 port.onMessage.addListener(function(response) { |
| 37 try { | 37 try { |
| 38 if (responseCallback) | 38 if (responseCallback) |
| 39 responseCallback(response); | 39 responseCallback(response); |
| 40 } finally { | 40 } finally { |
| 41 port.disconnect(); | 41 port.disconnect(); |
| 42 port = null; | 42 port = null; |
| 43 } | 43 } |
| 44 }); | 44 }); |
| 45 }); | 45 }); |
| 46 | |
| 47 // TODO(skerner,mtytel): The next step to omitting optional arguments is the | |
| 48 // replacement of this code with code that matches arguments by type. | |
| 49 // Once this is working for captureVisibleTab() it can be enabled for | |
| 50 // the rest of the API. See crbug/29215 . | |
| 51 apiFunctions.setUpdateArgumentsPreValidate('tabs.captureVisibleTab', | |
| 52 function() { | |
| 53 // Old signature: | |
| 54 // captureVisibleTab(int windowId, function callback); | |
| 55 // New signature: | |
| 56 // captureVisibleTab(int windowId, object details, function callback); | |
| 57 var newArgs; | |
| 58 if (arguments.length == 2 && typeof(arguments[1]) == 'function') { | |
| 59 // If the old signature is used, add a null details object. | |
| 60 newArgs = [arguments[0], null, arguments[1]]; | |
| 61 } else { | |
| 62 newArgs = arguments; | |
| 63 } | |
| 64 return newArgs; | |
| 65 }); | |
| 66 }); | 46 }); |
| 67 | 47 |
| 68 })(); | 48 })(); |
| OLD | NEW |