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

Side by Side Diff: lib/typoFixer.js

Issue 9276041: Fixed: bogus access keys in typo correction message (Closed)
Patch Set: Created Jan. 29, 2013, 2: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/typoAppIntegration.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 /* 1 /*
2 * This file is part of the Adblock Plus, 2 * This file is part of the Adblock Plus,
3 * Copyright (C) 2006-2012 Eyeo GmbH 3 * Copyright (C) 2006-2012 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus 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 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus 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
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 { 38 {
39 applyToWindow: function(window) 39 applyToWindow: function(window)
40 { 40 {
41 if (!appIntegration.isKnownWindow(window)) 41 if (!appIntegration.isKnownWindow(window))
42 return; 42 return;
43 43
44 netError.applyToWindow(window); 44 netError.applyToWindow(window);
45 appIntegration.applyToWindow(window, correctURL); 45 appIntegration.applyToWindow(window, correctURL);
46 }, 46 },
47 47
48 removeFromWindow: function(window) 48 removeFromWindow: function(window)
49 { 49 {
50 if (!appIntegration.isKnownWindow(window)) 50 if (!appIntegration.isKnownWindow(window))
51 return; 51 return;
52 52
53 netError.removeFromWindow(window); 53 netError.removeFromWindow(window);
54 appIntegration.removeFromWindow(window); 54 appIntegration.removeFromWindow(window);
55 } 55 }
56 }); 56 });
57 } 57 }
58 attachWindowObserver(); 58 attachWindowObserver();
59 59
60 exports.detachWindowObserver = detachWindowObserver; 60 exports.detachWindowObserver = detachWindowObserver;
61 function detachWindowObserver() 61 function detachWindowObserver()
62 { 62 {
63 if (!typoWindowObserver) 63 if (!typoWindowObserver)
64 return; 64 return;
65 65
66 // Detach our handlers from all browser windows 66 // Detach our handlers from all browser windows
67 typoWindowObserver.shutdown(); 67 typoWindowObserver.shutdown();
68 typoWindowObserver = null; 68 typoWindowObserver = null;
69 } 69 }
70 70
71 function parseURL(url) 71 function parseURL(url)
72 { 72 {
73 if (/^\s*((?:\w+:)?\/*(?:[^\/#]*@)?)([^\/:#]*)/.test(url)) 73 if (/^\s*((?:\w+:)?\/*(?:[^\/#]*@)?)([^\/:#]*)/.test(url))
74 return [RegExp.$1, RegExp.$2.toLowerCase(), RegExp.rightContext]; 74 return [RegExp.$1, RegExp.$2.toLowerCase(), RegExp.rightContext];
75 else 75 else
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
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: null, 187 accessKey: "",
188 callback: function() 188 callback: function()
189 { 189 {
190 // Yes: Do nothing 190 // Yes: Do nothing
191 } 191 }
192 }, 192 },
193 { 193 {
194 label: no, 194 label: no,
195 accessKey: null, 195 accessKey: "",
196 callback: function() 196 callback: function()
197 { 197 {
198 // No: Add to list of corrections (ignore) 198 // No: Add to list of corrections (ignore)
199 let entry = oldDomain.replace(/^www\./, ""); 199 let entry = oldDomain.replace(/^www\./, "");
200 Prefs.whitelist[entry] = true; 200 Prefs.whitelist[entry] = true;
201 onWhitelistEntryAdded(entry); 201 onWhitelistEntryAdded(entry);
202 Prefs.whitelist = JSON.parse(JSON.stringify(Prefs.whitelist)); 202 Prefs.whitelist = JSON.parse(JSON.stringify(Prefs.whitelist));
203 203
204 appIntegration.loadURI(window, value); 204 appIntegration.loadURI(window, value);
205 processFalsePositive(domain, oldDomain); 205 processFalsePositive(domain, oldDomain);
(...skipping 17 matching lines...) Expand all
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 = function() result;
231 return getInfobarTexts(); 231 return getInfobarTexts();
232 } 232 }
OLDNEW
« no previous file with comments | « lib/typoAppIntegration.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld