LEFT | RIGHT |
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 Loading... |
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 Loading... |
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 } |
LEFT | RIGHT |