| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 1 /* This Source Code Form is subject to the terms of the Mozilla Public | 1 /* This Source Code Form is subject to the terms of the Mozilla Public |
| 2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, | 2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
| 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ | 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 4 | 4 |
| 5 Cu.import("resource://gre/modules/Services.jsm"); | 5 Cu.import("resource://gre/modules/Services.jsm"); |
| 6 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); | 6 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
| 7 | 7 |
| 8 let {Prefs} = require("prefs"); | 8 let {Prefs} = require("prefs"); |
| 9 let {WindowObserver} = require("windowObserver"); | 9 let {WindowObserver} = require("windowObserver"); |
| 10 let {getSchemeCorrection, isKnownScheme, getDomainCorrection, getDomainReferral, onWhitelistEntryAdded} = require("typoRules"); | 10 let {getSchemeCorrection, isKnownScheme, getDomainCorrection, getDomainReferral, onWhitelistEntryAdded} = require("typoRules"); |
| 11 let {processTypedDomain, processDomainCorrection, processFalsePositive} = requir e("typoCollector"); | 11 let {processTypedDomain, processDomainCorrection, processFalsePositive} = requir e("typoCollector"); |
| 12 let appIntegration = require("typoAppIntegration"); | 12 let appIntegration = require("typoAppIntegration"); |
| 13 let netError = require("typoNetError"); | 13 let netError = require("typoNetError"); |
| 14 | 14 |
| 15 // Attach our handlers to all browser windows | 15 |
| 16 new WindowObserver( | 16 let typoWindowObserver = null; |
| 17 | |
| 18 exports.attachWindowObserver = attachWindowObserver; | |
| 19 function attachWindowObserver() | |
| 17 { | 20 { |
|
Wladimir Palant
2012/11/19 07:30:02
Please check whether the observer is already attac
| |
| 18 applyToWindow: function(window) | 21 // Attach our handlers to all browser windows |
| 22 typoWindowObserver = new WindowObserver( | |
| 19 { | 23 { |
| 20 if (!appIntegration.isKnownWindow(window)) | 24 applyToWindow: function(window) |
| 21 return; | 25 { |
| 22 | 26 if (!appIntegration.isKnownWindow(window)) |
| 23 netError.applyToWindow(window); | 27 return; |
| 24 appIntegration.applyToWindow(window, correctURL); | 28 |
| 25 }, | 29 netError.applyToWindow(window); |
| 30 appIntegration.applyToWindow(window, correctURL); | |
| 31 }, | |
| 26 | 32 |
| 27 removeFromWindow: function(window) | 33 removeFromWindow: function(window) |
| 28 { | 34 { |
| 29 if (!appIntegration.isKnownWindow(window)) | 35 if (!appIntegration.isKnownWindow(window)) |
| 30 return; | 36 return; |
| 31 | 37 |
| 32 netError.removeFromWindow(window); | 38 netError.removeFromWindow(window); |
| 33 appIntegration.removeFromWindow(window); | 39 appIntegration.removeFromWindow(window); |
| 34 } | 40 } |
| 35 }); | 41 }); |
| 42 } | |
| 43 attachWindowObserver(); | |
| 44 | |
| 45 exports.detachWindowObserver = detachWindowObserver; | |
| 46 function detachWindowObserver() | |
| 47 { | |
|
Wladimir Palant
2012/11/19 07:30:02
Please check whether the observer is already detac
| |
| 48 // Detach our handlers from all browser windows | |
| 49 typoWindowObserver.shutdown(); | |
| 50 typoWindowObserver = null; | |
| 51 } | |
| 36 | 52 |
| 37 function parseURL(url) | 53 function parseURL(url) |
| 38 { | 54 { |
| 39 if (/^\s*((?:\w+:)?\/*(?:[^\/#]*@)?)([^\/:#]*)/.test(url)) | 55 if (/^\s*((?:\w+:)?\/*(?:[^\/#]*@)?)([^\/:#]*)/.test(url)) |
| 40 return [RegExp.$1, RegExp.$2.toLowerCase(), RegExp.rightContext]; | 56 return [RegExp.$1, RegExp.$2.toLowerCase(), RegExp.rightContext]; |
| 41 else | 57 else |
| 42 return [url, null, null]; | 58 return [url, null, null]; |
| 43 } | 59 } |
| 44 | 60 |
| 45 function isIPAddress(domain) | 61 function isIPAddress(domain) |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 stringBundle = Services.strings.createBundle("chrome://" + require("info").a ddonName + "/locale/typo.properties?" + Math.random()); | 205 stringBundle = Services.strings.createBundle("chrome://" + require("info").a ddonName + "/locale/typo.properties?" + Math.random()); |
| 190 let result = [ | 206 let result = [ |
| 191 stringBundle.GetStringFromName("urlfixer.isItCorrect"), | 207 stringBundle.GetStringFromName("urlfixer.isItCorrect"), |
| 192 stringBundle.GetStringFromName("urlfixer.yes"), | 208 stringBundle.GetStringFromName("urlfixer.yes"), |
| 193 stringBundle.GetStringFromName("urlfixer.no") | 209 stringBundle.GetStringFromName("urlfixer.no") |
| 194 ]; | 210 ]; |
| 195 | 211 |
| 196 getInfobarTexts = function() result; | 212 getInfobarTexts = function() result; |
| 197 return getInfobarTexts(); | 213 return getInfobarTexts(); |
| 198 } | 214 } |
| OLD | NEW |