Bug 1497527 - Introduce URL and security display for content tab pages. r=darktrojan,Paenglab
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Tue, 16 Oct 2018 08:07:00 +0200
changeset 33389 33b63fc7b450d1149e5329a6a3855f1fd622cba6
parent 33388 902afac94dad7580f1aab16cd60c8e29737f7b8d
child 33390 8d9aee111a9dd52af84642ea4ea81f9e49e074b5
push id387
push userclokep@gmail.com
push dateMon, 10 Dec 2018 21:30:47 +0000
reviewersdarktrojan, Paenglab
bugs1497527
Bug 1497527 - Introduce URL and security display for content tab pages. r=darktrojan,Paenglab
mail/base/content/messenger.xul
mail/base/content/specialTabs.js
mail/themes/linux/mail/tabmail.css
mail/themes/osx/mail/tabmail.css
mail/themes/shared/mail/tabmail.css
mail/themes/windows/mail/tabmail.css
--- a/mail/base/content/messenger.xul
+++ b/mail/base/content/messenger.xul
@@ -662,16 +662,23 @@
 #include ../../components/im/content/chat-messenger.inc
       </tabpanels>
      </tabbox>
     </tabmail>
     <vbox id="contentTab" collapsed="true">
       <vbox flex="1" class="contentTabInstance">
         <toolbox id="dummycontenttoolbox" class="contentTabToolbox">
           <toolbar id="dummycontenttoolbar" class="contentTabToolbar">
+            <toolbarspacer/>
+            <toolbaritem class="contentTabAddress" align="center">
+              <hbox class="searchBox" align="center">
+                <image class="contentTabSecurity"/>
+                <description class="contentTabUrlbar"/>
+              </hbox>
+            </toolbaritem>
           </toolbar>
         </toolbox>
         <notificationbox flex="1" notificationside="top">
           <browser id="dummycontentbrowser" type="content" flex="1"
                    disablehistory="true" autocompletepopup="PopupAutoComplete"
                    context="mailContext"/>
         </notificationbox>
       </vbox>
--- a/mail/base/content/specialTabs.js
+++ b/mail/base/content/specialTabs.js
@@ -67,16 +67,22 @@ tabProgressListener.prototype =
       // Don't clear the favicon if this onLocationChange was triggered
       // by a pushState or a replaceState. See bug 550565.
       if (aWebProgress.isLoadingDocument &&
           !(this.mBrowser.docShell.loadType &
             Ci.nsIDocShell.LOAD_CMD_PUSHSTATE))
         this.mBrowser.mIconURL = null;
 
       var location = aLocationURI ? aLocationURI.spec : "";
+      if (aLocationURI && !aLocationURI.schemeIs("about")) {
+        this.mTab.urlbar.textContent = location;
+        this.mTab.root.removeAttribute("collapsed");
+      } else {
+        this.mTab.root.setAttribute("collapsed", "false");
+      }
 
       // Set the reload command only if this is a report that is coming in about
       // the top-level content location change.
       if (aWebProgress.DOMWindow == this.mBrowser.contentWindow) {
         // Although we're unlikely to be loading about:blank, we'll check it
         // anyway just in case. The second condition is for new tabs, otherwise
         // the reload function is enabled until tab is refreshed.
         this.mTab.reloadEnabled =
@@ -108,27 +114,29 @@ tabProgressListener.prototype =
       // the count of open requests should now be 0.
       this.mRequestCount = 0;
     }
 
     if (aStateFlags & nsIWebProgressListener.STATE_START &&
         aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK) {
       if (!this.mBlank) {
         this.mTab.title = specialTabs.contentTabType.loadingTabString;
+        this.mTab.security.setAttribute("loading", "true");
         tabmail.setTabBusy(this.mTab, true);
         tabmail.setTabTitle(this.mTab);
       }
 
       // Set our unit testing variables accordingly
       this.mTab.pageLoading = true;
       this.mTab.pageLoaded = false;
     }
     else if (aStateFlags & nsIWebProgressListener.STATE_STOP &&
              aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK) {
       this.mBlank = false;
+      this.mTab.security.removeAttribute("loading");
       tabmail.setTabBusy(this.mTab, false);
       tabmail.setTabTitle(this.mTab);
 
       // Set our unit testing variables accordingly
       this.mTab.pageLoading = false;
       this.mTab.pageLoaded = true;
 
       // If we've finished loading, and we've not had an icon loaded from a
@@ -143,16 +151,44 @@ tabProgressListener.prototype =
     if (this.mProgressListener)
       this.mProgressListener.onStatusChange(aWebProgress, aRequest, aStatus,
         aMessage);
   },
   onSecurityChange: function tPL_onSecurityChange(aWebProgress, aRequest,
                                                   aOldState, aState, aContentBlockingLogJSON) {
     if (this.mProgressListener)
       this.mProgressListener.onSecurityChange(aWebProgress, aRequest, aOldState, aState, aContentBlockingLogJSON);
+
+    const wpl = Ci.nsIWebProgressListener;
+    const wpl_security_bits = wpl.STATE_IS_SECURE |
+                              wpl.STATE_IS_BROKEN |
+                              wpl.STATE_IS_INSECURE |
+                              wpl.STATE_SECURE_HIGH |
+                              wpl.STATE_SECURE_MED |
+                              wpl.STATE_SECURE_LOW;
+    let level = "";
+    switch (aState & wpl_security_bits) {
+      case wpl.STATE_IS_SECURE | wpl.STATE_SECURE_HIGH:
+        level = "high";
+        break;
+      case wpl.STATE_IS_SECURE | wpl.STATE_SECURE_MED:
+      case wpl.STATE_IS_SECURE | wpl.STATE_SECURE_LOW:
+        level = "low";
+        break;
+      case wpl.STATE_IS_BROKEN:
+        level = "broken";
+        break;
+    }
+    if (level) {
+      this.mTab.security.setAttribute("level", level);
+      this.mTab.security.hidden = false;
+    } else {
+      this.mTab.security.hidden = true;
+      this.mTab.security.removeAttribute("level");
+    }
   },
   onRefreshAttempted: function tPL_OnRefreshAttempted(aWebProgress, aURI,
                                                       aDelay, aSameURI) {
     if (this.mProgressListener)
       this.mProgressListener.onRefreshAttempted(aWebProgress, aURI, aDelay,
         aSameURI);
   },
   QueryInterface: ChromeUtils.generateQI([Ci.nsIWebProgressListener,
@@ -709,16 +745,19 @@ var specialTabs = {
 
       aTab.panel.setAttribute("id", "contentTabWrapper" + this.lastBrowserId);
       aTab.panel.appendChild(clone);
       aTab.root = clone;
 
       // Start setting up the browser.
       aTab.browser = aTab.panel.querySelector("browser");
       aTab.toolbar = aTab.panel.querySelector(".contentTabToolbar");
+      aTab.security = aTab.panel.querySelector(".contentTabSecurity");
+      aTab.urlbar = aTab.panel.querySelector(".contentTabUrlbar");
+      aTab.urlbar.textContent = aArgs.contentPage;
 
       ExtensionParent.apiManager.emit("extension-browser-inserted", aTab.browser);
 
       // As we're opening this tab, showTab may not get called, so set
       // the type according to if we're opening in background or not.
       let background = ("background" in aArgs) && aArgs.background;
       aTab.browser.setAttribute("type", "content");
       if (background)
--- a/mail/themes/linux/mail/tabmail.css
+++ b/mail/themes/linux/mail/tabmail.css
@@ -108,8 +108,13 @@ tabpanels {
 
 .tabs-alltabs-button > .toolbarbutton-icon {
   margin-inline-end: 0;
 }
 
 .alltabs-item > .menu-iconic-left {
   visibility: visible !important;
 }
+
+/* Content Tabs */
+.contentTabAddress {
+  height: 32px;
+}
--- a/mail/themes/osx/mail/tabmail.css
+++ b/mail/themes/osx/mail/tabmail.css
@@ -177,8 +177,13 @@ tabmail > tabbox > tabpanels {
  * All Tabs Menupopup
  */
 
 @media (min-resolution: 1.1dppx) {
   alltabs-item[busy] {
     list-style-image: url("chrome://global/skin/icons/loading@2x.png") !important;
   }
 }
+
+/* Content Tabs */
+.contentTabAddress {
+  height: 31px;
+}
--- a/mail/themes/shared/mail/tabmail.css
+++ b/mail/themes/shared/mail/tabmail.css
@@ -345,13 +345,32 @@
 }
 
 /* Content Tabs */
 .chromeTabInstance[collapsed="false"] .contentTabToolbox,
 .contentTabInstance[collapsed="false"] .contentTabToolbox {
   display: none;
 }
 
-.contentTabToolbar {
-  height: 0;
-  min-height: 0;
-  padding: 0;
+.contentTabSecurity {
+  height: 20px;
+  width: 20px;
+  margin-inline-end: 5px;
+  background-repeat: no-repeat;
+}
+
+.contentTabSecurity[level="high"],
+.contentTabSecurity[level="low"] {
+  background-image: url("chrome://messenger/skin/icons/secure.png");
 }
+
+.contentTabSecurity[level="broken"] {
+  background-image: url("chrome://messenger/skin/icons/insecure.png");
+}
+
+.contentTabSecurity[loading="true"] {
+  background-image: url("chrome://global/skin/icons/loading.png");
+  background-position: 4px 2px;
+}
+
+.contentTabUrlbar {
+  margin: 0;
+}
--- a/mail/themes/windows/mail/tabmail.css
+++ b/mail/themes/windows/mail/tabmail.css
@@ -137,16 +137,21 @@ tabpanels {
   padding-right: 3px !important;
   padding-left: 3px !important;
 }
 
 .tabs-alltabs-button > hbox > .toolbarbutton-menu-dropmarker {
   display: none;
 }
 
+/* Content Tabs */
+.contentTabAddress {
+  height: 34px;
+}
+
 @media (-moz-os-version: windows-win7) and (-moz-windows-default-theme) {
   @media (-moz-windows-glass: 0) {
     :root[tabsintitlebar][sizemode=normal] #mail-toolbar-menubar2[autohide=true][inactive] ~
       #tabs-toolbar {
       margin-top: 6px;
     }
   }
 }