| 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 windows API. | 5 // Custom bindings for the windows API. |
| 6 | 6 |
| 7 (function() { | 7 (function() { |
| 8 | 8 |
| 9 native function GetChromeHidden(); | 9 native function GetChromeHidden(); |
| 10 | 10 |
| 11 GetChromeHidden().registerCustomHook('windows', function(api) { | 11 GetChromeHidden().registerCustomHook('windows', function(api) { |
| 12 var apiFunctions = api.apiFunctions; | 12 var apiFunctions = api.apiFunctions; |
| 13 | 13 |
| 14 apiFunctions.setUpdateArgumentsPreValidate("windows.get", function() { | 14 apiFunctions.setUpdateArgumentsPreValidate('get', function() { |
| 15 // Old signature: | 15 // Old signature: |
| 16 // get(int windowId, function callback); | 16 // get(int windowId, function callback); |
| 17 // New signature: | 17 // New signature: |
| 18 // get(int windowId, object populate, function callback); | 18 // get(int windowId, object populate, function callback); |
| 19 if (arguments.length == 2 && typeof(arguments[1]) == "function") { | 19 if (arguments.length == 2 && typeof(arguments[1]) == 'function') { |
| 20 // If the old signature is used, add a null populate object. | 20 // If the old signature is used, add a null populate object. |
| 21 newArgs = [arguments[0], null, arguments[1]]; | 21 newArgs = [arguments[0], null, arguments[1]]; |
| 22 } else { | 22 } else { |
| 23 newArgs = arguments; | 23 newArgs = arguments; |
| 24 } | 24 } |
| 25 return newArgs; | 25 return newArgs; |
| 26 }); | 26 }); |
| 27 | 27 |
| 28 apiFunctions.setUpdateArgumentsPreValidate("windows.getCurrent", | 28 apiFunctions.setUpdateArgumentsPreValidate('getCurrent', function() { |
| 29 function() { | |
| 30 // Old signature: | 29 // Old signature: |
| 31 // getCurrent(function callback); | 30 // getCurrent(function callback); |
| 32 // New signature: | 31 // New signature: |
| 33 // getCurrent(object populate, function callback); | 32 // getCurrent(object populate, function callback); |
| 34 if (arguments.length == 1 && typeof(arguments[0]) == "function") { | 33 if (arguments.length == 1 && typeof(arguments[0]) == 'function') { |
| 35 // If the old signature is used, add a null populate object. | 34 // If the old signature is used, add a null populate object. |
| 36 newArgs = [null, arguments[0]]; | 35 newArgs = [null, arguments[0]]; |
| 37 } else { | 36 } else { |
| 38 newArgs = arguments; | 37 newArgs = arguments; |
| 39 } | 38 } |
| 40 return newArgs; | 39 return newArgs; |
| 41 }); | 40 }); |
| 42 | 41 |
| 43 apiFunctions.setUpdateArgumentsPreValidate("windows.getLastFocused", | 42 apiFunctions.setUpdateArgumentsPreValidate('getLastFocused', function() { |
| 44 function() { | |
| 45 // Old signature: | 43 // Old signature: |
| 46 // getLastFocused(function callback); | 44 // getLastFocused(function callback); |
| 47 // New signature: | 45 // New signature: |
| 48 // getLastFocused(object populate, function callback); | 46 // getLastFocused(object populate, function callback); |
| 49 if (arguments.length == 1 && typeof(arguments[0]) == "function") { | 47 if (arguments.length == 1 && typeof(arguments[0]) == 'function') { |
| 50 // If the old signature is used, add a null populate object. | 48 // If the old signature is used, add a null populate object. |
| 51 newArgs = [null, arguments[0]]; | 49 newArgs = [null, arguments[0]]; |
| 52 } else { | 50 } else { |
| 53 newArgs = arguments; | 51 newArgs = arguments; |
| 54 } | 52 } |
| 55 return newArgs; | 53 return newArgs; |
| 56 }); | 54 }); |
| 57 | 55 |
| 58 apiFunctions.setUpdateArgumentsPreValidate("windows.getAll", function() { | 56 apiFunctions.setUpdateArgumentsPreValidate('getAll', function() { |
| 59 // Old signature: | 57 // Old signature: |
| 60 // getAll(function callback); | 58 // getAll(function callback); |
| 61 // New signature: | 59 // New signature: |
| 62 // getAll(object populate, function callback); | 60 // getAll(object populate, function callback); |
| 63 if (arguments.length == 1 && typeof(arguments[0]) == "function") { | 61 if (arguments.length == 1 && typeof(arguments[0]) == 'function') { |
| 64 // If the old signature is used, add a null populate object. | 62 // If the old signature is used, add a null populate object. |
| 65 newArgs = [null, arguments[0]]; | 63 newArgs = [null, arguments[0]]; |
| 66 } else { | 64 } else { |
| 67 newArgs = arguments; | 65 newArgs = arguments; |
| 68 } | 66 } |
| 69 return newArgs; | 67 return newArgs; |
| 70 }); | 68 }); |
| 71 }); | 69 }); |
| 72 | 70 |
| 73 })(); | 71 })(); |
| OLD | NEW |