From ef4d8a79ac7d680fa033682b956d041ec4353375 Mon Sep 17 00:00:00 2001 From: Tim Abraldes Date: Thu, 16 May 2013 11:57:26 -0700 Subject: [PATCH] bug 801090. Display a lock in the url bar for tabs that have loaded secure pages. Remove the lock when the user types in the URL bar, or switches to a tab displaying an insecure page. r=mbrubeck --- browser/metro/base/content/WebProgress.js | 34 +++++++++++++++++------ browser/metro/base/content/browser.js | 3 -- browser/metro/theme/browser.css | 10 +++---- 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/browser/metro/base/content/WebProgress.js b/browser/metro/base/content/WebProgress.js index e811ba20330..836a7d86200 100644 --- a/browser/metro/base/content/WebProgress.js +++ b/browser/metro/base/content/WebProgress.js @@ -16,6 +16,11 @@ const WebProgress = { messageManager.addMessageListener("Content:LocationChange", this); messageManager.addMessageListener("Content:SecurityChange", this); Elements.progress.addEventListener("transitionend", this._progressTransEnd, true); + Elements.tabList.addEventListener("TabSelect", this._onTabSelect, true); + + let urlBar = document.getElementById("urlbar-edit"); + urlBar.addEventListener("input", this._onUrlBarInput, false); + return this; }, @@ -58,12 +63,17 @@ const WebProgress = { }, _securityChange: function _securityChange(aJson, aTab) { - // Don't need to do anything if the data we use to update the UI hasn't changed - if (aTab.state == aJson.state && !aTab.hostChanged) - return; + let state = aJson.state; + let identityBox = document.getElementById("identity-box-inner"); + let nsIWebProgressListener = Ci.nsIWebProgressListener; - aTab.hostChanged = false; - aTab.state = aJson.state; + if (state & nsIWebProgressListener.STATE_IDENTITY_EV_TOPLEVEL) { + aTab._identityState = identityBox.className = "verifiedIdentity"; + } else if (state & nsIWebProgressListener.STATE_IS_SECURE) { + aTab._identityState = identityBox.className = "verifiedDomain"; + } else { + aTab._identityState = identityBox.className = ""; + } }, _locationChange: function _locationChange(aJson, aTab) { @@ -77,7 +87,6 @@ const WebProgress = { if (locationHasChanged) { Browser.getNotificationBox(aTab.browser).removeTransientNotifications(); aTab.resetZoomLevel(); - aTab.hostChanged = true; aTab.browser.lastLocation = location; aTab.browser.userTypedValue = ""; aTab.browser.appIcon = { href: null, size:-1 }; @@ -204,6 +213,15 @@ const WebProgress = { Elements.progressContainer.setAttribute("collapsed", true); } }, + + _onTabSelect: function(aEvent) { + let identityBox = document.getElementById("identity-box-inner"); + let tab = Browser.getTabFromChrome(aEvent.originalTarget); + identityBox.className = tab._identityState || ""; + }, + + _onUrlBarInput: function(aEvent) { + let identityBox = document.getElementById("identity-box-inner"); + Browser.selectedTab._identityState = identityBox.className = ""; + }, }; - - diff --git a/browser/metro/base/content/browser.js b/browser/metro/base/content/browser.js index c16020eef88..08a59f5adc5 100644 --- a/browser/metro/base/content/browser.js +++ b/browser/metro/base/content/browser.js @@ -1392,9 +1392,6 @@ function Tab(aURI, aParams, aOwner) { this.owner = aOwner || null; - this.hostChanged = false; - this.state = null; - // Set to 0 since new tabs that have not been viewed yet are good tabs to // toss if app needs more memory. this.lastSelected = 0; diff --git a/browser/metro/theme/browser.css b/browser/metro/theme/browser.css index 35d5cdb13e3..c693ab3530e 100644 --- a/browser/metro/theme/browser.css +++ b/browser/metro/theme/browser.css @@ -377,12 +377,12 @@ documenttab[selected] .documenttab-selection { list-style-image: url(chrome://browser/skin/images/identity-icons-generic.png); } -#identity-box[mode="verifiedDomain"] > #identity-icon[pageproxystate="valid"] { - list-style-image: url(chrome://browser/skin/images/identity-icons-https.png); +#identity-box-inner.verifiedDomain > #identity-icon { + list-style-image: url(chrome://browser/skin/images/locked-hdpi.png); } - -#identity-box[mode="verifiedIdentity"] > #identity-icon[pageproxystate="valid"] { - list-style-image: url(chrome://browser/skin/identity-icons-https-ev.png); + +#identity-box-inner.verifiedIdentity > #identity-icon { + list-style-image: url(chrome://browser/skin/images/locked-hdpi.png); } /* Main URL textbox */