Bug 839961 - Refactor login manager's content actions into a separate JSM. (mobile and metro changes) r=mfinkle
authorJustin Dolske <dolske@mozilla.com>
Wed, 19 Jun 2013 16:30:53 -0700
changeset 147213 f5df5ee7bd177a4863ea551060c45d92c27e0e2a
parent 147212 58d5552a5ef406e591187b932e528fe84f0db16f
child 147214 1213ea1ff91a09cdf209389d79229d10e3bac56a
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs839961
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 839961 - Refactor login manager's content actions into a separate JSM. (mobile and metro changes) r=mfinkle
browser/metro/base/content/contenthandlers/Content.js
mobile/android/chrome/content/browser.js
--- a/browser/metro/base/content/contenthandlers/Content.js
+++ b/browser/metro/base/content/contenthandlers/Content.js
@@ -23,16 +23,19 @@ XPCOMUtils.defineLazyGetter(this, "Rect"
   return Rect;
 });
 
 XPCOMUtils.defineLazyGetter(this, "Point", function() {
   Cu.import("resource://gre/modules/Geometry.jsm");
   return Point;
 });
 
+XPCOMUtils.defineLazyModuleGetter(this, "LoginManagerContent",
+  "resource://gre/modules/LoginManagerContent.jsm");
+
 XPCOMUtils.defineLazyServiceGetter(this, "gFocusManager",
   "@mozilla.org/focus-manager;1", "nsIFocusManager");
 
 XPCOMUtils.defineLazyServiceGetter(this, "gDOMUtils",
   "@mozilla.org/inspector/dom-utils;1", "inIDOMUtils");
 
 let XULDocument = Ci.nsIDOMXULDocument;
 let HTMLHtmlElement = Ci.nsIDOMHTMLHtmlElement;
@@ -131,16 +134,18 @@ let Content = {
     addEventListener("touchstart", this, false);
     addEventListener("click", this, true);
     addEventListener("keydown", this);
     addEventListener("keyup", this);
 
     // Synchronous events caught during the bubbling phase
     addEventListener("MozApplicationManifest", this, false);
     addEventListener("DOMContentLoaded", this, false);
+    addEventListener("DOMAutoComplete", this, false);
+    addEventListener("blur", this, false);
     addEventListener("pagehide", this, false);
     // Attach a listener to watch for "click" events bubbling up from error
     // pages and other similar page. This lets us fix bugs like 401575 which
     // require error page UI to do privileged things, without letting error
     // pages have any privilege themselves.
     addEventListener("click", this, false);
 
     docShell.useGlobalHistory = true;
@@ -178,21 +183,27 @@ let Content = {
         break;
 
       case "click":
         if (aEvent.eventPhase == aEvent.BUBBLING_PHASE)
           this._onClickBubble(aEvent);
         else
           this._onClickCapture(aEvent);
         break;
-      
+
       case "DOMContentLoaded":
+        LoginManagerContent.onContentLoaded(aEvent);
         this._maybeNotifyErrorPage();
         break;
 
+      case "DOMAutoComplete":
+      case "blur":
+        LoginManagerContent.onUsernameInput(aEvent);
+        break;
+
       case "pagehide":
         if (aEvent.target == content.document)
           this._resetFontSize();          
         break;
 
       case "touchstart":
         this._onTouchStart(aEvent);
         break;
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -25,16 +25,19 @@ XPCOMUtils.defineLazyModuleGetter(this, 
                                   "resource://gre/modules/PluralForm.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "DebuggerServer",
                                   "resource://gre/modules/devtools/dbg-server.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "UserAgentOverrides",
                                   "resource://gre/modules/UserAgentOverrides.jsm");
 
+XPCOMUtils.defineLazyModuleGetter(this, "LoginManagerContent",
+                                  "resource://gre/modules/LoginManagerContent.jsm");
+
 XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
                                   "resource://gre/modules/NetUtil.jsm");
 
 #ifdef MOZ_SAFE_BROWSING
 XPCOMUtils.defineLazyModuleGetter(this, "SafeBrowsing",
                                   "resource://gre/modules/SafeBrowsing.jsm");
 #endif
 
@@ -2558,16 +2561,18 @@ Tab.prototype = {
     this.browser.addProgressListener(this, flags);
     this.browser.sessionHistory.addSHistoryListener(this);
 
     this.browser.addEventListener("DOMContentLoaded", this, true);
     this.browser.addEventListener("DOMLinkAdded", this, true);
     this.browser.addEventListener("DOMTitleChanged", this, true);
     this.browser.addEventListener("DOMWindowClose", this, true);
     this.browser.addEventListener("DOMWillOpenModalDialog", this, true);
+    this.browser.addEventListener("DOMAutoComplete", this, true);
+    this.browser.addEventListener("blur", this, true);
     this.browser.addEventListener("scroll", this, true);
     this.browser.addEventListener("MozScrolledAreaChanged", this, true);
     // Note that the XBL binding is untrusted
     this.browser.addEventListener("PluginBindingAttached", this, true, true);
     this.browser.addEventListener("pageshow", this, true);
     this.browser.addEventListener("MozApplicationManifest", this, true);
 
     Services.obs.addObserver(this, "before-first-paint", false);
@@ -2707,16 +2712,18 @@ Tab.prototype = {
     this.browser.removeProgressListener(this);
     this.browser.sessionHistory.removeSHistoryListener(this);
 
     this.browser.removeEventListener("DOMContentLoaded", this, true);
     this.browser.removeEventListener("DOMLinkAdded", this, true);
     this.browser.removeEventListener("DOMTitleChanged", this, true);
     this.browser.removeEventListener("DOMWindowClose", this, true);
     this.browser.removeEventListener("DOMWillOpenModalDialog", this, true);
+    this.browser.removeEventListener("DOMAutoComplete", this, true);
+    this.browser.removeEventListener("blur", this, true);
     this.browser.removeEventListener("scroll", this, true);
     this.browser.removeEventListener("MozScrolledAreaChanged", this, true);
     this.browser.removeEventListener("PluginBindingAttached", this, true);
     this.browser.removeEventListener("pageshow", this, true);
     this.browser.removeEventListener("MozApplicationManifest", this, true);
 
     Services.obs.removeObserver(this, "before-first-paint");
     Services.prefs.removeObserver("browser.ui.zoom.force-user-scalable", this);
@@ -3200,16 +3207,18 @@ Tab.prototype = {
     }
   },
 
   handleEvent: function(aEvent) {
     switch (aEvent.type) {
       case "DOMContentLoaded": {
         let target = aEvent.originalTarget;
 
+        LoginManagerContent.onContentLoaded(aEvent);
+
         // ignore on frames and other documents
         if (target != this.browser.contentDocument)
           return;
 
         // Sample the background color of the page and pass it along. (This is used to draw the
         // checkerboard.) Right now we don't detect changes in the background color after this
         // event fires; it's not clear that doing so is worth the effort.
         var backgroundColor = null;
@@ -3363,16 +3372,22 @@ Tab.prototype = {
 
         // We're about to open a modal dialog, make sure the opening
         // tab is brought to the front.
         let tab = BrowserApp.getTabForWindow(aEvent.target.top);
         BrowserApp.selectTab(tab);
         break;
       }
 
+      case "DOMAutoComplete":
+      case "blur": {
+        LoginManagerContent.onUsernameInput(aEvent);
+        break;
+      }
+
       case "scroll": {
         let win = this.browser.contentWindow;
         if (this.userScrollPos.x != win.scrollX || this.userScrollPos.y != win.scrollY) {
           this.sendViewportUpdate();
         }
         break;
       }