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

Unified Diff: lib/typoFixer.js

Issue 8397151: Use a better format for typed in data and record domain corrections; only send data once per hour (Closed)
Patch Set: Created Sept. 28, 2012, 8:10 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/typedItCollector.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/typoFixer.js
===================================================================
--- a/lib/typoFixer.js
+++ b/lib/typoFixer.js
@@ -3,19 +3,18 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
let {Prefs} = require("prefs");
let {WindowObserver} = require("windowObserver");
let {getSchemeCorrection, isKnownScheme, getDomainCorrection, getDomainReferral} = require("rules");
-let {processTypedDomain} = require("typedItCollector");
-let {processUserCorrection} = require("typedItCollector");
-let {processFalsePositive} = require("typedItCollector");
+let {processTypedDomain, processDomainCorrection,
+ processUserCorrection, processFalsePositive} = require("typedItCollector");
let appIntegration = require("appIntegration");
// Attach our handlers to all browser windows
new WindowObserver(
{
applyToWindow: function(window)
{
if (!appIntegration.isKnownWindow(window))
@@ -89,17 +88,16 @@ function handlePageLoad(event)
{
let newURL = textField.value.replace(/^\s+/, "").replace(/\s+$/, "");
if (!newURL.length)
return;
let [prefix, newHost, suffix] = parseURL(newURL);
let oldHost = document.defaultView.location.hostname.toLowerCase();
- processTypedDomain(newHost);
processUserCorrection(oldHost, newHost);
if (newHost.indexOf("www.") == 0 && oldHost.indexOf("www.") == 0)
{
// Ignore www. prefix if they both start with it
newHost = newHost.substr(4);
oldHost = oldHost.substr(4);
}
@@ -187,16 +185,17 @@ function correctURL(window, value)
let oldDomain = domain;
if (!isIPAddress(domain))
{
processTypedDomain(domain);
let newDomain = getDomainCorrection(domain);
if (newDomain != domain)
{
+ processDomainCorrection(domain, newDomain);
domain = newDomain;
hasCorrection = true;
let referral = getDomainReferral(domain.replace(/^www\./, ""));
if (referral)
{
// We need to add a query string parameter when sending users to this domain
let anchorIndex = suffix.indexOf("#");
@@ -249,28 +248,24 @@ function correctURL(window, value)
// No: Add to list of corrections (ignore)
let {onWhitelistEntryAdded} = require("rules");
let entry = oldDomain.replace(/^www\./, "");
Prefs.whitelist[entry] = true;
onWhitelistEntryAdded(entry);
Prefs.whitelist = JSON.parse(JSON.stringify(Prefs.whitelist));
require("appIntegration").loadURI(window, value);
- processFalsePositive(oldDomain, domain);
+ processFalsePositive(domain, oldDomain);
}
}
];
require("appIntegration").openInfobar(window, "url-fixer-infobar-askafter", message, buttons, 1);
require("survey").incrementCorrectionsCounter();
- // Consider the correction a second typed domain
- if (!isIPAddress(domain))
- processTypedDomain(domain);
-
return prefix + domain + suffix;
}
let stringBundle = null;
function getInfobarTexts()
{
// Randomize URI to work around bug 719376
« no previous file with comments | « lib/typedItCollector.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld