OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 if (arguments.length > 0) | 49 if (arguments.length > 0) |
50 { | 50 { |
51 var lastArg = arguments[arguments.length - 1]; | 51 var lastArg = arguments[arguments.length - 1]; |
52 if (typeof lastArg == "function") | 52 if (typeof lastArg == "function") |
53 callback = lastArg; | 53 callback = lastArg; |
54 | 54 |
55 for (var i = 0; i < arguments.length - (callback ? 1 : 0); i++) | 55 for (var i = 0; i < arguments.length - (callback ? 1 : 0); i++) |
56 message[paramKeys[i]] = arguments[i]; | 56 message[paramKeys[i]] = arguments[i]; |
57 } | 57 } |
58 | 58 |
59 ext.backgroundPage.sendMessage(message, callback); | 59 // Chrome 30 throws an exception when sendMessage is called with a callback |
| 60 // parameter of undefined, so we work around that here. (See issue 4052) |
| 61 if (callback) |
| 62 ext.backgroundPage.sendMessage(message, callback); |
| 63 else |
| 64 ext.backgroundPage.sendMessage(message); |
60 }; | 65 }; |
61 } | 66 } |
62 | 67 |
63 var getDocLink = wrapper({type: "app.get", what: "doclink"}, "link"); | 68 var getDocLink = wrapper({type: "app.get", what: "doclink"}, "link"); |
64 var getInfo = wrapper({type: "app.get"}, "what"); | 69 var getInfo = wrapper({type: "app.get"}, "what"); |
65 var getPref = wrapper({type: "prefs.get"}, "key"); | 70 var getPref = wrapper({type: "prefs.get"}, "key"); |
66 var togglePref = wrapper({type: "prefs.toggle"}, "key"); | 71 var togglePref = wrapper({type: "prefs.toggle"}, "key"); |
67 var getSubscriptions = wrapper({type: "subscriptions.get"}, | 72 var getSubscriptions = wrapper({type: "subscriptions.get"}, |
68 "downloadable", "special"); | 73 "downloadable", "special"); |
69 var removeSubscription = wrapper({type: "subscriptions.remove"}, "url"); | 74 var removeSubscription = wrapper({type: "subscriptions.remove"}, "url"); |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 onFilterMessage(message.action, message.args[0]); | 767 onFilterMessage(message.action, message.args[0]); |
763 break; | 768 break; |
764 case "prefs.respond": | 769 case "prefs.respond": |
765 onPrefMessage(message.action, message.args[0]); | 770 onPrefMessage(message.action, message.args[0]); |
766 break; | 771 break; |
767 case "subscriptions.respond": | 772 case "subscriptions.respond": |
768 onSubscriptionMessage(message.action, message.args[0]); | 773 onSubscriptionMessage(message.action, message.args[0]); |
769 break; | 774 break; |
770 } | 775 } |
771 }); | 776 }); |
OLD | NEW |