| Index: lib/typoFixer.js |
| =================================================================== |
| --- a/lib/typoFixer.js |
| +++ b/lib/typoFixer.js |
| @@ -12,27 +12,48 @@ |
| let appIntegration = require("typoAppIntegration"); |
| let netError = require("typoNetError"); |
| -// Attach our handlers to all browser windows |
| -new WindowObserver( |
| +let typoWindowObserver = null; |
| + |
| +exports.attachWindowObserver = attachWindowObserver; |
| +function attachWindowObserver() |
| { |
| - applyToWindow: function(window) |
| + if (typoWindowObserver) |
| + return; |
| + |
| + // Attach our handlers to all browser windows |
| + typoWindowObserver = new WindowObserver( |
| { |
| - if (!appIntegration.isKnownWindow(window)) |
| - return; |
| - |
| - netError.applyToWindow(window); |
| - appIntegration.applyToWindow(window, correctURL); |
| - }, |
| + applyToWindow: function(window) |
| + { |
| + if (!appIntegration.isKnownWindow(window)) |
| + return; |
| + |
| + netError.applyToWindow(window); |
| + appIntegration.applyToWindow(window, correctURL); |
| + }, |
| - removeFromWindow: function(window) |
| - { |
| - if (!appIntegration.isKnownWindow(window)) |
| - return; |
| - |
| - netError.removeFromWindow(window); |
| - appIntegration.removeFromWindow(window); |
| - } |
| -}); |
| + removeFromWindow: function(window) |
| + { |
| + if (!appIntegration.isKnownWindow(window)) |
| + return; |
| + |
| + netError.removeFromWindow(window); |
| + appIntegration.removeFromWindow(window); |
| + } |
| + }); |
| +} |
| +attachWindowObserver(); |
| + |
| +exports.detachWindowObserver = detachWindowObserver; |
| +function detachWindowObserver() |
| +{ |
| + if (!typoWindowObserver) |
| + return; |
| + |
| + // Detach our handlers from all browser windows |
| + typoWindowObserver.shutdown(); |
| + typoWindowObserver = null; |
| +} |
| function parseURL(url) |
| { |