Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: ext/content.js

Issue 6180766664884224: Issue 1663 - Made first-run page use an asynchronous messaging protocol (Closed)
Left Patch Set: Documentation fixes Created Dec. 17, 2014, 5:46 p.m.
Right Patch Set: Adressed comments Created Dec. 18, 2014, 7:30 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « README.md ('k') | firstRun.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 (function(global) 18 (function(global)
19 { 19 {
20 if (!global.ext) 20 if (!global.ext)
21 global.ext = {}; 21 global.ext = {};
22 22
23 function getURLParameters(data) 23 function updateFromURL(data)
24 { 24 {
25 if (window.location.search) 25 if (window.location.search)
26 { 26 {
27 var params = window.location.search.substr(1).split("&"); 27 var params = window.location.search.substr(1).split("&");
28 for (var i = 0; i < params.length; i++) 28 for (var i = 0; i < params.length; i++)
29 { 29 {
30 var parts = params[i].split("=", 2); 30 var parts = params[i].split("=", 2);
31 if (parts.length == 2 && parts[0] in data) 31 if (parts.length == 2 && parts[0] in data)
32 data[parts[0]] = decodeURIComponent(parts[1]); 32 data[parts[0]] = decodeURIComponent(parts[1]);
33 } 33 }
(...skipping 24 matching lines...) Expand all
58 global.ext.onMessage._dispatch({ 58 global.ext.onMessage._dispatch({
59 type: "subscriptions.listen", 59 type: "subscriptions.listen",
60 action: match[1], 60 action: match[1],
61 args: Array.prototype.slice.call(arguments, 1) 61 args: Array.prototype.slice.call(arguments, 1)
62 }); 62 });
63 } 63 }
64 }; 64 };
65 65
66 switch (message.type) 66 switch (message.type)
67 { 67 {
68 case "app.doclink": 68 case "app.get":
69 respond("https://adblockplus.org/redirect?link=" + encodeURIComponent( message.args[0])); 69 if (message.what == "issues")
70 {
71 var response = {seenDataCorruption: false, filterlistsReinitialized: false};
72 updateFromURL(response);
73
74 var info = {platform: "gecko", platformVersion: "34.0", application: "firefox", applicationVersion: "34.0"};
75 updateFromURL(info);
76 response.legacySafariVersion = (info.platform == "safari" && (
77 parseInt(info.platformVersion, 10) < 6 || // beforeload breaks we bsites in Safari 5
78 info.platformVersion == "6.1" || // extensions are broke n in 6.1 and 7.0
79 info.platformVersion == "7.0"));
80
81 respond(response);
82 }
83 else if (message.what == "doclink")
84 respond("https://adblockplus.org/redirect?link=" + encodeURIComponen t(message.link));
85 else
86 respond(null);
70 break; 87 break;
71 case "app.info": 88 case "app.open":
72 var response = {platform: "gecko", platformVersion: "34.0", applicatio n: "firefox", applicationVersion: "34.0"}; 89 if (message.what == "options")
73 getURLParameters(response); 90 window.open("http://example.com/options.html", "_blank");
74 respond(response);
75 break;
76 case "app.issues":
77 var response = {seenDataCorruption: false, filterlistsReinitialized: f alse};
78 getURLParameters(response);
79 respond(response);
80 break;
81 case "app.options":
82 window.open("http://example.com/options.html", "_blank");
83 break; 91 break;
84 case "subscriptions.get": 92 case "subscriptions.get":
85 respond(subscriptions); 93 respond(subscriptions);
86 break; 94 break;
87 case "filters.blocked": 95 case "filters.blocked":
88 var params = {blockedURLs: ""}; 96 var params = {blockedURLs: ""};
89 getURLParameters(params); 97 updateFromURL(params);
90 var blocked = params.blockedURLs.split(","); 98 var blocked = params.blockedURLs.split(",");
91 respond(blocked.indexOf(message.url) >= 0); 99 respond(blocked.indexOf(message.url) >= 0);
92 break; 100 break;
93 case "subscriptions.toggle": 101 case "subscriptions.toggle":
94 var index = subscriptions.indexOf(message.url); 102 var index = subscriptions.indexOf(message.url);
95 if (index >= 0) 103 if (index >= 0)
96 { 104 {
97 subscriptions.splice(index, 1); 105 subscriptions.splice(index, 1);
98 dispatchListenerNotification("subscription.removed", message.url); 106 dispatchListenerNotification("subscription.removed", message.url);
99 } 107 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 145
138 if (this._cancelable && result === false) 146 if (this._cancelable && result === false)
139 break; 147 break;
140 } 148 }
141 149
142 return result; 150 return result;
143 } 151 }
144 }; 152 };
145 global.ext.onMessage = new EventTarget(); 153 global.ext.onMessage = new EventTarget();
146 })(this); 154 })(this);
LEFTRIGHT

Powered by Google App Engine
This is Rietveld