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

Delta Between Two Patch Sets: lib/typoFixer.js

Issue 8788183: Detect and handle the case of our own typo correction extension being installed in parallel (Closed)
Left Patch Set: Created Nov. 15, 2012, 1:18 p.m.
Right Patch Set: Created Nov. 20, 2012, 11:38 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « lib/typoBootstrap.js ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
16 let typoWindowObserver = null; 15 let typoWindowObserver = null;
17 16
18 exports.attachWindowObserver = attachWindowObserver; 17 exports.attachWindowObserver = attachWindowObserver;
19 function attachWindowObserver() 18 function attachWindowObserver()
20 { 19 {
Wladimir Palant 2012/11/19 07:30:02 Please check whether the observer is already attac
20 if (typoWindowObserver)
21 return;
22
21 // Attach our handlers to all browser windows 23 // Attach our handlers to all browser windows
22 typoWindowObserver = new WindowObserver( 24 typoWindowObserver = new WindowObserver(
23 { 25 {
24 applyToWindow: function(window) 26 applyToWindow: function(window)
25 { 27 {
26 if (!appIntegration.isKnownWindow(window)) 28 if (!appIntegration.isKnownWindow(window))
27 return; 29 return;
28 30
29 netError.applyToWindow(window); 31 netError.applyToWindow(window);
30 appIntegration.applyToWindow(window, correctURL); 32 appIntegration.applyToWindow(window, correctURL);
31 }, 33 },
32 34
33 removeFromWindow: function(window) 35 removeFromWindow: function(window)
34 { 36 {
35 if (!appIntegration.isKnownWindow(window)) 37 if (!appIntegration.isKnownWindow(window))
36 return; 38 return;
37 39
38 netError.removeFromWindow(window); 40 netError.removeFromWindow(window);
39 appIntegration.removeFromWindow(window); 41 appIntegration.removeFromWindow(window);
40 } 42 }
41 }); 43 });
42 } 44 }
43 attachWindowObserver(); 45 attachWindowObserver();
44 46
45 exports.detachWindowObserver = detachWindowObserver; 47 exports.detachWindowObserver = detachWindowObserver;
46 function detachWindowObserver() 48 function detachWindowObserver()
47 { 49 {
Wladimir Palant 2012/11/19 07:30:02 Please check whether the observer is already detac
50 if (!typoWindowObserver)
51 return;
52
48 // Detach our handlers from all browser windows 53 // Detach our handlers from all browser windows
49 typoWindowObserver.shutdown(); 54 typoWindowObserver.shutdown();
50 typoWindowObserver = null; 55 typoWindowObserver = null;
51 } 56 }
52 57
53 function parseURL(url) 58 function parseURL(url)
54 { 59 {
55 if (/^\s*((?:\w+:)?\/*(?:[^\/#]*@)?)([^\/:#]*)/.test(url)) 60 if (/^\s*((?:\w+:)?\/*(?:[^\/#]*@)?)([^\/:#]*)/.test(url))
56 return [RegExp.$1, RegExp.$2.toLowerCase(), RegExp.rightContext]; 61 return [RegExp.$1, RegExp.$2.toLowerCase(), RegExp.rightContext];
57 else 62 else
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 stringBundle = Services.strings.createBundle("chrome://" + require("info").a ddonName + "/locale/typo.properties?" + Math.random()); 210 stringBundle = Services.strings.createBundle("chrome://" + require("info").a ddonName + "/locale/typo.properties?" + Math.random());
206 let result = [ 211 let result = [
207 stringBundle.GetStringFromName("urlfixer.isItCorrect"), 212 stringBundle.GetStringFromName("urlfixer.isItCorrect"),
208 stringBundle.GetStringFromName("urlfixer.yes"), 213 stringBundle.GetStringFromName("urlfixer.yes"),
209 stringBundle.GetStringFromName("urlfixer.no") 214 stringBundle.GetStringFromName("urlfixer.no")
210 ]; 215 ];
211 216
212 getInfobarTexts = function() result; 217 getInfobarTexts = function() result;
213 return getInfobarTexts(); 218 return getInfobarTexts();
214 } 219 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld