Bug 800905 - Load script in to every new tab. r=davidb
authorEitan Isaacson <eitan@monotonous.org>
Tue, 16 Oct 2012 11:07:16 -0700
changeset 110555 e21bd5ae8cb26812a0808f3187757270266fd39c
parent 110554 8ce5daee047019b2d579cfaad61e150e09611045
child 110556 ed39040f53ad3057e8af7b3a7888255dea70bb9d
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersdavidb
bugs800905
milestone19.0a1
Bug 800905 - Load script in to every new tab. r=davidb
accessible/src/jsat/AccessFu.jsm
--- a/accessible/src/jsat/AccessFu.jsm
+++ b/accessible/src/jsat/AccessFu.jsm
@@ -94,16 +94,17 @@ var AccessFu = {
     Input.attach(this.chromeWin);
     Output.attach(this.chromeWin);
     this.touchAdapter.attach(this.chromeWin);
 
     Services.obs.addObserver(this, 'remote-browser-frame-shown', false);
     Services.obs.addObserver(this, 'Accessibility:NextObject', false);
     Services.obs.addObserver(this, 'Accessibility:PreviousObject', false);
     Services.obs.addObserver(this, 'Accessibility:CurrentObject', false);
+    this.chromeWin.addEventListener('TabOpen', this);
   },
 
   /**
    * Disable AccessFu and return to default interaction mode.
    */
   _disable: function _disable() {
     if (!this._enabled)
       return;
@@ -113,16 +114,18 @@ var AccessFu = {
     Logger.info('disable');
 
     this.chromeWin.document.removeChild(this.stylesheet);
     for each (let mm in Utils.getAllMessageManagers(this.chromeWin))
       mm.sendAsyncMessage('AccessFu:Stop');
 
     Input.detach();
 
+    this.chromeWin.removeEventListener('TabOpen', this);
+
     Services.obs.removeObserver(this, 'remote-browser-frame-shown');
     Services.obs.removeObserver(this, 'Accessibility:NextObject');
     Services.obs.removeObserver(this, 'Accessibility:PreviousObject');
     Services.obs.removeObserver(this, 'Accessibility:CurrentObject');
   },
 
   _enableOrDisable: function _enableOrDisable() {
     try {
@@ -200,20 +203,30 @@ var AccessFu = {
         this._loadFrameScript(
           aSubject.QueryInterface(Ci.nsIFrameLoader).messageManager);
         break;
       }
     }
   },
 
   handleEvent: function handleEvent(aEvent) {
-    if (aEvent.type == 'mozContentEvent' &&
-        aEvent.detail.type == 'accessibility-screenreader') {
-      this._systemPref = aEvent.detail.enabled;
-      this._enableOrDisable();
+    switch (aEvent.type) {
+      case 'mozContentEvent':
+      {
+        if (aEvent.detail.type == 'accessibility-screenreader') {
+          this._systemPref = aEvent.detail.enabled;
+          this._enableOrDisable();
+        }
+        break;
+      }
+      case 'TabOpen':
+      {
+        this._loadFrameScript(Utils.getMessageManager(aEvent.target));
+        break;
+      }
     }
   },
 
   // So we don't enable/disable twice
   _enabled: false
 };
 
 var Output = {