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

Delta Between Two Patch Sets: lib/typoBootstrap.js

Issue 8788183: Detect and handle the case of our own typo correction extension being installed in parallel (Closed)
Left Patch Set: Created Nov. 20, 2012, 10:27 a.m.
Right Patch Set: Created Nov. 20, 2012, 11:38 a.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/typoFixer.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 /* 1 /*
2 * This Source Code is subject to the terms of the Mozilla Public License 2 * This file is part of the Adblock Plus,
3 * version 2.0 (the "License"). You can obtain a copy of the License at 3 * Copyright (C) 2006-2012 Eyeo GmbH
4 * http://mozilla.org/MPL/2.0/. 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
5 */ 16 */
6 17
7 /** 18 /**
8 * @fileOverview Adds typo correction feature 19 * @fileOverview Adds typo correction feature
9 */ 20 */
10 21
11 Cu.import("resource://gre/modules/AddonManager.jsm"); 22 Cu.import("resource://gre/modules/AddonManager.jsm");
12 23
13 let {Prefs} = require("prefs"); 24 let {Prefs} = require("prefs");
14 let urlfixerID = "{0fa2149e-bb2c-4ac2-a8d3-479599819475}"; 25 let urlfixerID = "{0fa2149e-bb2c-4ac2-a8d3-479599819475}";
(...skipping 16 matching lines...) Expand all
31 { 42 {
32 init(); 43 init();
33 Prefs.removeListener(onPrefChange); 44 Prefs.removeListener(onPrefChange);
34 } 45 }
35 } 46 }
36 47
37 Prefs.addListener(onPrefChange); 48 Prefs.addListener(onPrefChange);
38 } 49 }
39 } 50 }
40 51
41 function cleanup()
42 {
43 if (addonListener)
44 {
45 AddonManager.removeAddonListener(addonListener);
46 addonListener = null;
47 }
48 }
49 onShutdown.add(cleanup);
Wladimir Palant 2012/11/20 11:13:30 Seriously, please look around at how this is done
50
51 function startTypoCorrection(isInstalledAndEnabled) 52 function startTypoCorrection(isInstalledAndEnabled)
52 { 53 {
53 if (isInstalledAndEnabled) 54 if (isInstalledAndEnabled)
54 require("typoFixer").detachWindowObserver(); 55 require("typoFixer").detachWindowObserver();
55 else 56 else
56 require("typoFixer").attachWindowObserver(); 57 require("typoFixer").attachWindowObserver();
57 58
58 if (!addonListener) 59 if (!addonListener)
59 { 60 {
60 addonListener = { 61 addonListener = {
(...skipping 13 matching lines...) Expand all
74 startTypoCorrection(true); 75 startTypoCorrection(true);
75 }, 76 },
76 onUninstalled: function(addon) 77 onUninstalled: function(addon)
77 { 78 {
78 if (addon.id == urlfixerID) 79 if (addon.id == urlfixerID)
79 startTypoCorrection(false); 80 startTypoCorrection(false);
80 } 81 }
81 } 82 }
82 83
83 AddonManager.addAddonListener(addonListener); 84 AddonManager.addAddonListener(addonListener);
85 onShutdown.add(function() AddonManager.removeAddonListener(addonListener));
84 } 86 }
85 } 87 }
86 88
87 init(); 89 init();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld