OLD | NEW |
1 /* | 1 /* |
2 * This file is part of the URL Fixer, | 2 * This file is part of the URL Fixer, |
3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 Eyeo GmbH |
4 * | 4 * |
5 * URL Fixer is free software: you can redistribute it and/or modify | 5 * URL Fixer 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 * URL Fixer is distributed in the hope that it will be useful, | 9 * URL Fixer 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 URL Fixer. If not, see <http://www.gnu.org/licenses/>. | 15 * along with URL Fixer. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 let {Prefs} = require("prefs"); | 18 let {Prefs} = require("prefs"); |
19 let {onWhitelistEntryRemoved} = require("typoRules"); | 19 let {onWhitelistEntryRemoved} = require("typoRules"); |
20 let {processUserCorrection} = require("typoCollector"); | |
21 | 20 |
22 function getNetErrorOverlay(message) | 21 function getNetErrorOverlay(message) |
23 { | 22 { |
24 let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"] | 23 let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"] |
25 .createInstance(Ci.nsIXMLHttpRequest); | 24 .createInstance(Ci.nsIXMLHttpRequest); |
26 request.open("GET", "chrome://" + require("info").addonName + | 25 request.open("GET", "chrome://" + require("info").addonName + |
27 "/content/netError.xhtml"); | 26 "/content/netError.xhtml"); |
28 request.addEventListener("load", function(event) | 27 request.addEventListener("load", function(event) |
29 { | 28 { |
30 message.target.sendAsyncMessage("URLFixer:NetErrorOverlay", | 29 message.target.sendAsyncMessage("URLFixer:NetErrorOverlay", |
31 event.target.responseText); | 30 event.target.responseText); |
32 }); | 31 }); |
33 request.send(null); | 32 request.send(null); |
34 } | 33 } |
35 | 34 |
36 function processCorrection(message) | 35 function processCorrection(message) |
37 { | 36 { |
38 let {oldHost, newHost} = message.data; | 37 let {oldHost, newHost} = message.data; |
39 | 38 |
40 processUserCorrection(oldHost, newHost); | |
41 | |
42 if (newHost.indexOf("www.") == 0 && oldHost.indexOf("www.") == 0) | 39 if (newHost.indexOf("www.") == 0 && oldHost.indexOf("www.") == 0) |
43 { | 40 { |
44 // Ignore www. prefix if they both start with it | 41 // Ignore www. prefix if they both start with it |
45 newHost = newHost.substr(4); | 42 newHost = newHost.substr(4); |
46 oldHost = oldHost.substr(4); | 43 oldHost = oldHost.substr(4); |
47 } | 44 } |
48 if (oldHost && newHost != oldHost) | 45 if (oldHost && newHost != oldHost) |
49 { | 46 { |
50 Prefs.custom_replace[oldHost] = newHost; | 47 Prefs.custom_replace[oldHost] = newHost; |
51 Prefs.custom_replace = JSON.parse(JSON.stringify(Prefs.custom_replace)); | 48 Prefs.custom_replace = JSON.parse(JSON.stringify(Prefs.custom_replace)); |
(...skipping 26 matching lines...) Expand all Loading... |
78 getNetErrorOverlay); | 75 getNetErrorOverlay); |
79 messageManager.addMessageListener("URLFixer:UserCorrection", | 76 messageManager.addMessageListener("URLFixer:UserCorrection", |
80 processCorrection); | 77 processCorrection); |
81 onShutdown.add(() => | 78 onShutdown.add(() => |
82 { | 79 { |
83 messageManager.removeMessageListener("URLFixer:GetNetErrorOverlay", | 80 messageManager.removeMessageListener("URLFixer:GetNetErrorOverlay", |
84 getNetErrorOverlay); | 81 getNetErrorOverlay); |
85 messageManager.removeMessageListener("URLFixer:UserCorrection", | 82 messageManager.removeMessageListener("URLFixer:UserCorrection", |
86 processCorrection); | 83 processCorrection); |
87 }); | 84 }); |
OLD | NEW |