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

Side by Side Diff: lib/typoFixer.js

Issue 8788183: Detect and handle the case of our own typo correction extension being installed in parallel (Closed)
Patch Set: Created Nov. 19, 2012, 3:32 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 | « lib/typoBootstrap.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 let typoWindowObserver = null;
16 new WindowObserver( 16
17 exports.attachWindowObserver = attachWindowObserver;
18 function attachWindowObserver()
17 { 19 {
18 applyToWindow: function(window) 20 if (typoWindowObserver)
21 return;
22
23 // Attach our handlers to all browser windows
24 typoWindowObserver = new WindowObserver(
19 { 25 {
20 if (!appIntegration.isKnownWindow(window)) 26 applyToWindow: function(window)
21 return; 27 {
22 28 if (!appIntegration.isKnownWindow(window))
23 netError.applyToWindow(window); 29 return;
24 appIntegration.applyToWindow(window, correctURL); 30
25 }, 31 netError.applyToWindow(window);
32 appIntegration.applyToWindow(window, correctURL);
33 },
26 34
27 removeFromWindow: function(window) 35 removeFromWindow: function(window)
28 { 36 {
29 if (!appIntegration.isKnownWindow(window)) 37 if (!appIntegration.isKnownWindow(window))
30 return; 38 return;
31 39
32 netError.removeFromWindow(window); 40 netError.removeFromWindow(window);
33 appIntegration.removeFromWindow(window); 41 appIntegration.removeFromWindow(window);
34 } 42 }
35 }); 43 });
44 }
45
46 exports.detachWindowObserver = detachWindowObserver;
47 function detachWindowObserver()
48 {
49 if (!typoWindowObserver)
50 return;
51
52 // Detach our handlers from all browser windows
53 typoWindowObserver.shutdown();
54 typoWindowObserver = null;
55 }
36 56
37 function parseURL(url) 57 function parseURL(url)
38 { 58 {
39 if (/^\s*((?:\w+:)?\/*(?:[^\/#]*@)?)([^\/:#]*)/.test(url)) 59 if (/^\s*((?:\w+:)?\/*(?:[^\/#]*@)?)([^\/:#]*)/.test(url))
40 return [RegExp.$1, RegExp.$2.toLowerCase(), RegExp.rightContext]; 60 return [RegExp.$1, RegExp.$2.toLowerCase(), RegExp.rightContext];
41 else 61 else
42 return [url, null, null]; 62 return [url, null, null];
43 } 63 }
44 64
45 function isIPAddress(domain) 65 function isIPAddress(domain)
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 stringBundle = Services.strings.createBundle("chrome://" + require("info").a ddonName + "/locale/typo.properties?" + Math.random()); 209 stringBundle = Services.strings.createBundle("chrome://" + require("info").a ddonName + "/locale/typo.properties?" + Math.random());
190 let result = [ 210 let result = [
191 stringBundle.GetStringFromName("urlfixer.isItCorrect"), 211 stringBundle.GetStringFromName("urlfixer.isItCorrect"),
192 stringBundle.GetStringFromName("urlfixer.yes"), 212 stringBundle.GetStringFromName("urlfixer.yes"),
193 stringBundle.GetStringFromName("urlfixer.no") 213 stringBundle.GetStringFromName("urlfixer.no")
194 ]; 214 ];
195 215
196 getInfobarTexts = function() result; 216 getInfobarTexts = function() result;
197 return getInfobarTexts(); 217 return getInfobarTexts();
198 } 218 }
OLDNEW
« no previous file with comments | « lib/typoBootstrap.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld