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

Unified Diff: lib/typoFixer.js

Issue 8788183: Detect and handle the case of our own typo correction extension being installed in parallel (Closed)
Patch Set: Created Nov. 19, 2012, 3:32 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/typoBootstrap.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/typoFixer.js
===================================================================
--- a/lib/typoFixer.js
+++ b/lib/typoFixer.js
@@ -12,27 +12,47 @@
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);
+ }
+ });
+}
+
+exports.detachWindowObserver = detachWindowObserver;
+function detachWindowObserver()
+{
+ if (!typoWindowObserver)
+ return;
+
+ // Detach our handlers from all browser windows
+ typoWindowObserver.shutdown();
+ typoWindowObserver = null;
+}
function parseURL(url)
{
« no previous file with comments | « lib/typoBootstrap.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld