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-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 |
(...skipping 14 matching lines...) Expand all Loading... |
25 let appIntegration = require("typoAppIntegration"); | 25 let appIntegration = require("typoAppIntegration"); |
26 let netError = require("typoNetError"); | 26 let netError = require("typoNetError"); |
27 | 27 |
28 let typoWindowObserver = null; | 28 let typoWindowObserver = null; |
29 | 29 |
30 exports.attachWindowObserver = attachWindowObserver; | 30 exports.attachWindowObserver = attachWindowObserver; |
31 function attachWindowObserver() | 31 function attachWindowObserver() |
32 { | 32 { |
33 if (typoWindowObserver) | 33 if (typoWindowObserver) |
34 return; | 34 return; |
35 | 35 |
36 // Attach our handlers to all browser windows | 36 // Attach our handlers to all browser windows |
37 typoWindowObserver = new WindowObserver({ | 37 typoWindowObserver = new WindowObserver({ |
38 applyToWindow: function(window) | 38 applyToWindow: function(window) |
39 { | 39 { |
40 if (!appIntegration.isKnownWindow(window)) | 40 if (!appIntegration.isKnownWindow(window)) |
41 return; | 41 return; |
42 | 42 |
43 appIntegration.applyToWindow(window, correctURL); | 43 appIntegration.applyToWindow(window, correctURL); |
44 }, | 44 }, |
45 | 45 |
46 removeFromWindow: function(window) | 46 removeFromWindow: function(window) |
47 { | 47 { |
48 if (!appIntegration.isKnownWindow(window)) | 48 if (!appIntegration.isKnownWindow(window)) |
49 return; | 49 return; |
50 | 50 |
51 appIntegration.removeFromWindow(window); | 51 appIntegration.removeFromWindow(window); |
52 } | 52 } |
53 }); | 53 }); |
54 } | 54 } |
55 attachWindowObserver(); | 55 attachWindowObserver(); |
56 | 56 |
57 exports.detachWindowObserver = detachWindowObserver; | 57 exports.detachWindowObserver = detachWindowObserver; |
58 function detachWindowObserver() | 58 function detachWindowObserver() |
59 { | 59 { |
60 if (!typoWindowObserver) | 60 if (!typoWindowObserver) |
61 return; | 61 return; |
62 | 62 |
63 // Detach our handlers from all browser windows | 63 // Detach our handlers from all browser windows |
64 typoWindowObserver.shutdown(); | 64 typoWindowObserver.shutdown(); |
65 typoWindowObserver = null; | 65 typoWindowObserver = null; |
66 } | 66 } |
67 | 67 |
68 function parseURL(url) | 68 function parseURL(url) |
69 { | 69 { |
70 if (/^\s*((?:\w+:)?\/*(?:[^\/#]*@)?)([^\/:#]*)/.test(url)) | 70 if (/^\s*((?:\w+:)?\/*(?:[^\/#]*@)?)([^\/:#]*)/.test(url)) |
71 return [RegExp.$1, RegExp.$2.toLowerCase(), RegExp.rightContext]; | 71 return [RegExp.$1, RegExp.$2.toLowerCase(), RegExp.rightContext]; |
72 else | 72 else |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 suffix += "?" + referral; | 167 suffix += "?" + referral; |
168 } | 168 } |
169 | 169 |
170 suffix += anchor; | 170 suffix += anchor; |
171 } | 171 } |
172 } | 172 } |
173 } | 173 } |
174 | 174 |
175 if (!hasCorrection) | 175 if (!hasCorrection) |
176 return null; | 176 return null; |
177 | 177 |
178 if (!appIntegration.isTypoCorrectionEnabled(window, prefix, domain, suffix)) | 178 if (!appIntegration.isTypoCorrectionEnabled(window, prefix, domain, suffix)) |
179 return null; | 179 return null; |
180 | 180 |
181 // Show infobar to inform and ask about correction | 181 // Show infobar to inform and ask about correction |
182 let [message, yes, no] = getInfobarTexts(); | 182 let [message, yes, no] = getInfobarTexts(); |
183 message = message.replace(/\?1\?/g, prefix+domain); | 183 message = message.replace(/\?1\?/g, prefix+domain); |
184 let buttons = [ | 184 let buttons = [ |
185 { | 185 { |
186 label: yes, | 186 label: yes, |
187 accessKey: "", | 187 accessKey: "", |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 { | 220 { |
221 // Randomize URI to work around bug 719376 | 221 // Randomize URI to work around bug 719376 |
222 if (!stringBundle) | 222 if (!stringBundle) |
223 stringBundle = Services.strings.createBundle("chrome://" + require("info").a
ddonName + "/locale/typo.properties?" + Math.random()); | 223 stringBundle = Services.strings.createBundle("chrome://" + require("info").a
ddonName + "/locale/typo.properties?" + Math.random()); |
224 let result = [ | 224 let result = [ |
225 stringBundle.GetStringFromName("urlfixer.isItCorrect"), | 225 stringBundle.GetStringFromName("urlfixer.isItCorrect"), |
226 stringBundle.GetStringFromName("urlfixer.yes"), | 226 stringBundle.GetStringFromName("urlfixer.yes"), |
227 stringBundle.GetStringFromName("urlfixer.no") | 227 stringBundle.GetStringFromName("urlfixer.no") |
228 ]; | 228 ]; |
229 | 229 |
230 getInfobarTexts = function() result; | 230 getInfobarTexts = () => result; |
231 return getInfobarTexts(); | 231 return getInfobarTexts(); |
232 } | 232 } |
OLD | NEW |