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

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

Issue 9317072: Allow omitting optional parameters for Extensions API functions (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Better error message distinguishing signature errors and type validation errors. Created 8 years, 10 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 (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
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 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698