| LEFT | RIGHT |
| 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 Loading... |
| 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); | |
| 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 Loading... |
| 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(); |
| LEFT | RIGHT |