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

Delta Between Two Patch Sets: lib/typoFixer.js

Issue 8559070: Integrated URL Fixer into Adblock Plus (Closed)
Left Patch Set: Created Oct. 12, 2012, 2:18 p.m.
Right Patch Set: Created Nov. 9, 2012, 3:21 p.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/typoCollector.js ('k') | lib/typoNetError.js » ('j') | 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");
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 suffix += "?" + referral; 133 suffix += "?" + referral;
134 } 134 }
135 135
136 suffix += anchor; 136 suffix += anchor;
137 } 137 }
138 } 138 }
139 } 139 }
140 140
141 if (!hasCorrection) 141 if (!hasCorrection)
142 return null; 142 return null;
143
144 if (!appIntegration.isTypoCorrectionEnabled(window, prefix, domain, suffix))
145 return null;
143 146
144 // Show infobar to inform and ask about correction 147 // Show infobar to inform and ask about correction
145 let [message, yes, no] = getInfobarTexts(); 148 let [message, yes, no] = getInfobarTexts();
146 message = message.replace(/\?1\?/g, prefix+domain); 149 message = message.replace(/\?1\?/g, prefix+domain);
147 let buttons = [ 150 let buttons = [
148 { 151 {
149 label: yes, 152 label: yes,
150 accessKey: null, 153 accessKey: null,
151 callback: function() 154 callback: function()
152 { 155 {
(...skipping 10 matching lines...) Expand all
163 Prefs.whitelist[entry] = true; 166 Prefs.whitelist[entry] = true;
164 onWhitelistEntryAdded(entry); 167 onWhitelistEntryAdded(entry);
165 Prefs.whitelist = JSON.parse(JSON.stringify(Prefs.whitelist)); 168 Prefs.whitelist = JSON.parse(JSON.stringify(Prefs.whitelist));
166 169
167 appIntegration.loadURI(window, value); 170 appIntegration.loadURI(window, value);
168 processFalsePositive(domain, oldDomain); 171 processFalsePositive(domain, oldDomain);
169 } 172 }
170 } 173 }
171 ]; 174 ];
172 // We need to have persistence being set to 1 due to redirect which happens af terwards 175 // We need to have persistence being set to 1 due to redirect which happens af terwards
173 appIntegration.openInfobar(window, "url-fixer-infobar-askafter", message, butt ons, 1); 176 appIntegration.openInfobar(window, require("info").addonName + "-infobar-askaf ter", message, buttons, 1);
174 177
175 require("typoSurvey").incrementCorrectionsCounter(); 178 require("typoSurvey").incrementCorrectionsCounter();
176 179
177 return prefix + domain + suffix; 180 return prefix + domain + suffix;
178 } 181 }
179 182
180 let stringBundle = null; 183 let stringBundle = null;
181 184
182 function getInfobarTexts() 185 function getInfobarTexts()
183 { 186 {
184 // Randomize URI to work around bug 719376 187 // Randomize URI to work around bug 719376
185 if (!stringBundle) 188 if (!stringBundle)
186 stringBundle = Services.strings.createBundle("chrome://" + require("info").a ddonName + "/locale/typo.properties?" + Math.random()); 189 stringBundle = Services.strings.createBundle("chrome://" + require("info").a ddonName + "/locale/typo.properties?" + Math.random());
187 let result = [ 190 let result = [
188 stringBundle.GetStringFromName("urlfixer.isItCorrect"), 191 stringBundle.GetStringFromName("urlfixer.isItCorrect"),
189 stringBundle.GetStringFromName("urlfixer.yes"), 192 stringBundle.GetStringFromName("urlfixer.yes"),
190 stringBundle.GetStringFromName("urlfixer.no") 193 stringBundle.GetStringFromName("urlfixer.no")
191 ]; 194 ];
192 195
193 getInfobarTexts = function() result; 196 getInfobarTexts = function() result;
194 return getInfobarTexts(); 197 return getInfobarTexts();
195 } 198 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld