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

Side by Side Diff: chrome/content/subscribeLinkHandler.js

Issue 29322679: Issue 1730 - Fixed abp:subscribe functionality with e10s (Closed)
Patch Set: Created July 20, 2015, 3:19 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | lib/appSupport.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
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/>.
16 */
17
18 (function()
19 {
20 addEventListener("click", onClick, false);
21 addMessageListener("AdblockPlus:Shutdown", onShutdown);
22
23 function onShutdown(message)
24 {
25 if (message.data == Components.stack.filename)
26 {
27 removeEventListener("click", onClick, false);
28 removeMessageListener("AdblockPlus:Shutdown", onShutdown);
29 }
30 }
31
32 function onClick(event)
33 {
34 // Ignore right-clicks
35 if (event.button == 2)
36 return;
37
38 // Search the link associated with the click
39 let link = event.target;
40 while (!(link instanceof content.HTMLAnchorElement))
Wladimir Palant 2015/07/20 15:20:53 The code in this function was only moved. The only
41 {
42 link = link.parentNode;
43
44 if (!link)
45 return;
46 }
47
48 let queryString = null;
49 if (link.protocol == "http:" || link.protocol == "https:")
50 {
51 if (link.host == "subscribe.adblockplus.org" && link.pathname == "/")
52 queryString = link.search.substr(1);
53 }
54 else
55 {
56 // Firefox doesn't populate the "search" property for links with
57 // non-standard URL schemes so we need to extract the query string
58 // manually
59 let match = /^abp:\/*subscribe\/*\?(.*)/i.exec(link.href);
60 if (match)
61 queryString = match[1];
62 }
63
64 if (!queryString)
65 return;
66
67 // This is our link - make sure the browser doesn't handle it
68 event.preventDefault();
69 event.stopPropagation();
70
71 // Decode URL parameters
72 let title = null;
73 let url = null;
74 let mainSubscriptionTitle = null;
75 let mainSubscriptionURL = null;
76 for (let param of queryString.split("&"))
77 {
78 let parts = param.split("=", 2);
79 if (parts.length != 2 || !/\S/.test(parts[1]))
80 continue;
81 switch (parts[0])
82 {
83 case "title":
84 title = decodeURIComponent(parts[1]);
85 break;
86 case "location":
87 url = decodeURIComponent(parts[1]);
88 break;
89 case "requiresTitle":
90 mainSubscriptionTitle = decodeURIComponent(parts[1]);
91 break;
92 case "requiresLocation":
93 mainSubscriptionURL = decodeURIComponent(parts[1]);
94 break;
95 }
96 }
97
98 sendAsyncMessage("AdblockPlus:SubscribeLink", {
99 title: title,
100 url: url,
101 mainSubscriptionTitle: mainSubscriptionTitle,
102 mainSubscriptionURL: mainSubscriptionURL
103 });
Thomas Greiner 2015/07/21 09:54:03 Detail: This can be simplified like this: sendAsy
Wladimir Palant 2015/07/21 13:12:12 Interesting. However, this is only supported start
104 }
105 })();
106
OLDNEW
« no previous file with comments | « no previous file | lib/appSupport.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld