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

Side by Side Diff: lib/typoFixer.js

Issue 8432103: Proper Fennec support (Closed)
Patch Set: Created Sept. 28, 2012, 7:18 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« lib/appIntegration.js ('K') | « lib/hooks.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} = require("rules"); 10 let {getSchemeCorrection, isKnownScheme, getDomainCorrection, getDomainReferral} = require("rules");
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } 136 }
137 catch (e) 137 catch (e)
138 { 138 {
139 return (e.result == Cr.NS_ERROR_HOST_IS_IP_ADDRESS); 139 return (e.result == Cr.NS_ERROR_HOST_IS_IP_ADDRESS);
140 } 140 }
141 } 141 }
142 142
143 function correctURL(window, value) 143 function correctURL(window, value)
144 { 144 {
145 let hasCorrection = false; 145 let hasCorrection = false;
146 146
147 value = value.trim(); 147 value = value.trim();
148 if (value.length == 0) 148 if (value.length == 0)
149 return null; 149 return null;
150 150
151 // Replace backslashes 151 // Replace backslashes
152 value = value.replace(/\\/g, "/"); 152 value = value.replace(/\\/g, "/");
153 153
154 // Does the URL scheme need correcting? 154 // Does the URL scheme need correcting?
155 if (/^([^\/]+)(\/.*)/.test(value)) 155 if (/^([^\/]+)(\/.*)/.test(value))
156 { 156 {
(...skipping 15 matching lines...) Expand all
172 if ("getShortcutOrURI" in window && window.getShortcutOrURI(value) != value) 172 if ("getShortcutOrURI" in window && window.getShortcutOrURI(value) != value)
173 return null; 173 return null;
174 174
175 // Spaces before the first slash or period is probably a quick search 175 // Spaces before the first slash or period is probably a quick search
176 if (/^[^\/\.\s]+\s/.test(value)) 176 if (/^[^\/\.\s]+\s/.test(value))
177 return null; 177 return null;
178 178
179 // Check manually entered corrections 179 // Check manually entered corrections
180 if (Prefs.custom_replace.hasOwnProperty(value) && Prefs.custom_replace[value]) 180 if (Prefs.custom_replace.hasOwnProperty(value) && Prefs.custom_replace[value])
181 return Prefs.custom_replace[value]; 181 return Prefs.custom_replace[value];
182 182
183 let [prefix, domain, suffix] = parseURL(value); 183 let [prefix, domain, suffix] = parseURL(value);
184 if (!domain) 184 if (!domain)
185 return null; 185 return null;
186 186
187 let oldDomain = domain; 187 let oldDomain = domain;
188 if (!isIPAddress(domain)) 188 if (!isIPAddress(domain))
189 { 189 {
190 processTypedDomain(domain); 190 processTypedDomain(domain);
191 191
192 let newDomain = getDomainCorrection(domain); 192 let newDomain = getDomainCorrection(domain);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 accessKey: null, 246 accessKey: null,
247 callback: function() 247 callback: function()
248 { 248 {
249 // No: Add to list of corrections (ignore) 249 // No: Add to list of corrections (ignore)
250 let {onWhitelistEntryAdded} = require("rules"); 250 let {onWhitelistEntryAdded} = require("rules");
251 let entry = oldDomain.replace(/^www\./, ""); 251 let entry = oldDomain.replace(/^www\./, "");
252 Prefs.whitelist[entry] = true; 252 Prefs.whitelist[entry] = true;
253 onWhitelistEntryAdded(entry); 253 onWhitelistEntryAdded(entry);
254 Prefs.whitelist = JSON.parse(JSON.stringify(Prefs.whitelist)); 254 Prefs.whitelist = JSON.parse(JSON.stringify(Prefs.whitelist));
255 255
256 require("appIntegration").loadURI(value); 256 require("appIntegration").loadURI(window, value);
257 processFalsePositive(oldDomain, domain); 257 processFalsePositive(oldDomain, domain);
258 } 258 }
259 } 259 }
260 ]; 260 ];
261 require("appIntegration").openInfobar(window, "url-fixer-infobar-askafter", me ssage, buttons, 1); 261 require("appIntegration").openInfobar(window, "url-fixer-infobar-askafter", me ssage, buttons, 1);
262 262
263 require("survey").incrementCorrectionsCounter(); 263 require("survey").incrementCorrectionsCounter();
264 264
265 // Consider the correction a second typed domain 265 // Consider the correction a second typed domain
266 if (!isIPAddress(domain)) 266 if (!isIPAddress(domain))
(...skipping 12 matching lines...) Expand all
279 let result = [ 279 let result = [
280 stringBundle.GetStringFromName("urlfixer.isItCorrect"), 280 stringBundle.GetStringFromName("urlfixer.isItCorrect"),
281 stringBundle.GetStringFromName("urlfixer.yes"), 281 stringBundle.GetStringFromName("urlfixer.yes"),
282 stringBundle.GetStringFromName("urlfixer.no"), 282 stringBundle.GetStringFromName("urlfixer.no"),
283 stringBundle.GetStringFromName("urlfixer.cancel") 283 stringBundle.GetStringFromName("urlfixer.cancel")
284 ]; 284 ];
285 285
286 getInfobarTexts = function() result; 286 getInfobarTexts = function() result;
287 return getInfobarTexts(); 287 return getInfobarTexts();
288 } 288 }
OLDNEW
« lib/appIntegration.js ('K') | « lib/hooks.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld