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

Delta Between Two Patch Sets: lib/typoAppIntegration.js

Issue 8559070: Integrated URL Fixer into Adblock Plus (Closed)
Left Patch Set: First batch of changes Created Nov. 9, 2012, 1:04 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/main.js ('k') | lib/typoCollector.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 let {hook} = require("hooks"); 5 let {hook} = require("hooks");
6 let {application, addonName} = require("info"); 6 let {application, addonName} = require("info");
7 7
8 let functionHooks = new WeakMap(); 8 let functionHooks = new WeakMap();
9 9
10 exports.removeFromWindow = function(window) 10 exports.removeFromWindow = function(window)
(...skipping 11 matching lines...) Expand all
22 case "url-fixer": 22 case "url-fixer":
23 { 23 {
24 // URL Fixer 24 // URL Fixer
25 exports.isTypoCorrectionEnabled = function(window, prefix, domain, suffix) t rue; 25 exports.isTypoCorrectionEnabled = function(window, prefix, domain, suffix) t rue;
26 26
27 break; 27 break;
28 } 28 }
29 case "adblockplus": 29 case "adblockplus":
30 { 30 {
31 // Adblock Plus 31 // Adblock Plus
32 let {Prefs} = require("prefs");
33
34 // Do not ask to opt-in if user found setting
35 if (!Prefs.correctTyposAsked)
36 {
37 let onPrefChange = function(name)
38 {
39 if (name == "correctTypos")
40 {
41 Prefs.correctTyposAsked = true;
42 Prefs.removeListener(onPrefChange);
43 }
44 }
45
46 Prefs.addListener(onPrefChange);
47 }
48
32 exports.isTypoCorrectionEnabled = function(window, prefix, domain, suffix) 49 exports.isTypoCorrectionEnabled = function(window, prefix, domain, suffix)
33 { 50 {
34 let {Prefs} = require("prefs");
35
36 if (!Prefs.correctTyposAsked && !Prefs.correctTypos) 51 if (!Prefs.correctTyposAsked && !Prefs.correctTypos)
37 { 52 {
38 let {Utils} = require("utils"); 53 let {Utils} = require("utils");
39 let message = Utils.getString("typo_optin_message").replace(/\?1\?/, dom ain); 54 let message = Utils.getString("typo_optin_message").replace(/\?1\?/, dom ain);
40 let yes = Utils.getString("typo_optin_yes"); 55 let yes = Utils.getString("typo_optin_yes");
41 let no = Utils.getString("typo_optin_no"); 56 let no = Utils.getString("typo_optin_no");
42 let buttons = [ 57 let buttons = [
43 { 58 {
44 label: yes, 59 label: yes,
45 accessKey: null, 60 accessKey: null,
46 callback: function() 61 callback: function()
47 { 62 {
48 // Yes: Enable typo correction 63 // Yes: Enable typo correction
49 Prefs.correctTypos = true; 64 Prefs.correctTypos = true;
50
51 exports.loadURI(window, prefix + domain + suffix); 65 exports.loadURI(window, prefix + domain + suffix);
66 Prefs.correctTyposAsked = true;
52 } 67 }
53 }, 68 },
54 { 69 {
55 label: no, 70 label: no,
56 accessKey: null, 71 accessKey: null,
57 callback: function() 72 callback: function()
58 { 73 {
59 // No: Do nothing 74 // No: Do nothing
75 Prefs.correctTyposAsked = true;
60 } 76 }
61 } 77 }
62 ]; 78 ];
63 // We need to have persistence being set to 1 due to redirect which happ ens afterwards 79 // We need to have persistence being set to 1 due to redirect which happ ens afterwards
64 exports.openInfobar(window, "adblockplus-infobar-correct-typos-ask", mes sage, buttons, 1); 80 exports.openInfobar(window, "adblockplus-infobar-correct-typos-ask", mes sage, buttons, 1);
65
66 Prefs.correctTyposAsked = true;
67
68 return false;
69 } 81 }
70 82
71 return Prefs.correctTypos; 83 return Prefs.correctTypos;
72 }; 84 };
73 85
74 break; 86 break;
75 } 87 }
76 } 88 }
77 89
78 switch (application) 90 switch (application)
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 }; 356 };
345 357
346 break; 358 break;
347 } 359 }
348 default: 360 default:
349 { 361 {
350 exports.isKnownWindow = function(window) false; 362 exports.isKnownWindow = function(window) false;
351 break; 363 break;
352 } 364 }
353 } 365 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld