Left: | ||
Right: |
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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 | 143 |
144 if (!appIntegration.isTypoCorrectionEnabled(window, prefix, domain, suffix)) | 144 if (!appIntegration.isTypoCorrectionEnabled(window, prefix, domain, suffix)) |
145 return; | 145 return null; |
Wladimir Palant
2012/11/09 08:26:15
This should be |return null|
| |
146 | 146 |
147 // Show infobar to inform and ask about correction | 147 // Show infobar to inform and ask about correction |
148 let [message, yes, no] = getInfobarTexts(); | 148 let [message, yes, no] = getInfobarTexts(); |
149 message = message.replace(/\?1\?/g, prefix+domain); | 149 message = message.replace(/\?1\?/g, prefix+domain); |
150 let buttons = [ | 150 let buttons = [ |
151 { | 151 { |
152 label: yes, | 152 label: yes, |
153 accessKey: null, | 153 accessKey: null, |
154 callback: function() | 154 callback: function() |
155 { | 155 { |
(...skipping 10 matching lines...) Expand all Loading... | |
166 Prefs.whitelist[entry] = true; | 166 Prefs.whitelist[entry] = true; |
167 onWhitelistEntryAdded(entry); | 167 onWhitelistEntryAdded(entry); |
168 Prefs.whitelist = JSON.parse(JSON.stringify(Prefs.whitelist)); | 168 Prefs.whitelist = JSON.parse(JSON.stringify(Prefs.whitelist)); |
169 | 169 |
170 appIntegration.loadURI(window, value); | 170 appIntegration.loadURI(window, value); |
171 processFalsePositive(domain, oldDomain); | 171 processFalsePositive(domain, oldDomain); |
172 } | 172 } |
173 } | 173 } |
174 ]; | 174 ]; |
175 // 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 |
176 appIntegration.openInfobar(window, "url-fixer-infobar-askafter", message, butt ons, 1); | 176 appIntegration.openInfobar(window, require("info").addonName + "-infobar-askaf ter", message, buttons, 1); |
Wladimir Palant
2012/11/09 08:26:15
This should be dependent on addonName as well, jus
| |
177 | 177 |
178 require("typoSurvey").incrementCorrectionsCounter(); | 178 require("typoSurvey").incrementCorrectionsCounter(); |
179 | 179 |
180 return prefix + domain + suffix; | 180 return prefix + domain + suffix; |
181 } | 181 } |
182 | 182 |
183 let stringBundle = null; | 183 let stringBundle = null; |
184 | 184 |
185 function getInfobarTexts() | 185 function getInfobarTexts() |
186 { | 186 { |
187 // Randomize URI to work around bug 719376 | 187 // Randomize URI to work around bug 719376 |
188 if (!stringBundle) | 188 if (!stringBundle) |
189 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()); |
190 let result = [ | 190 let result = [ |
191 stringBundle.GetStringFromName("urlfixer.isItCorrect"), | 191 stringBundle.GetStringFromName("urlfixer.isItCorrect"), |
192 stringBundle.GetStringFromName("urlfixer.yes"), | 192 stringBundle.GetStringFromName("urlfixer.yes"), |
193 stringBundle.GetStringFromName("urlfixer.no") | 193 stringBundle.GetStringFromName("urlfixer.no") |
194 ]; | 194 ]; |
195 | 195 |
196 getInfobarTexts = function() result; | 196 getInfobarTexts = function() result; |
197 return getInfobarTexts(); | 197 return getInfobarTexts(); |
198 } | 198 } |
LEFT | RIGHT |