Bug 1206246 - Change identity icon for sites with granted permissions. r=paolo
authorJohann Hofmann <jhofmann@mozilla.com>
Wed, 01 Jun 2016 18:17:26 +0200
changeset 301460 c2ffbe22285487d5443d840e4c5feaa391f66c8d
parent 301459 0fcee5543705980cf79c0709665826ba8744e606
child 301461 7f8f1d4b1de01c358970a3ff1c51bba23ebcc429
push id30335
push usercbook@mozilla.com
push dateSun, 12 Jun 2016 09:25:20 +0000
treeherdermozilla-central@9694e3713635 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspaolo
bugs1206246
milestone50.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 1206246 - Change identity icon for sites with granted permissions. r=paolo MozReview-Commit-ID: 2GV4fBrB6vO
browser/base/content/browser.js
browser/base/content/test/general/browser_permissions.js
browser/themes/shared/identity-block/identity-block.inc.css
browser/themes/shared/identity-block/identity-icon.svg
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -6890,16 +6890,20 @@ var gIdentityHandler = {
       if (this._hasInsecureLoginForms) {
         // Insecure login forms can only be present on "unknown identity"
         // pages, either already insecure or with mixed active content loaded.
         this._identityBox.classList.add("insecureLoginForms");
       }
       tooltip = gNavigatorBundle.getString("identity.unknown.tooltip");
     }
 
+    if (SitePermissions.hasGrantedPermissions(this._uri)) {
+      this._identityBox.classList.add("grantedPermissions");
+    }
+
     // Push the appropriate strings out to the UI
     this._identityBox.tooltipText = tooltip;
     this._identityIcon.tooltipText = gNavigatorBundle.getString("identity.icon.tooltip");
     this._identityIconLabel.value = icon_label;
     this._identityIconCountryLabel.value = icon_country_label;
     // Set cropping and direction
     this._identityIconLabel.crop = icon_country_label ? "end" : "center";
     this._identityIconLabel.parentNode.style.direction = icon_labels_dir;
--- a/browser/base/content/test/general/browser_permissions.js
+++ b/browser/base/content/test/general/browser_permissions.js
@@ -3,16 +3,20 @@
  */
 
 var {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
 const PERMISSIONS_PAGE = "http://example.com/browser/browser/base/content/test/general/permissions.html";
 var {SitePermissions} = Cu.import("resource:///modules/SitePermissions.jsm", {});
 
 registerCleanupFunction(function() {
   SitePermissions.remove(gBrowser.currentURI, "install");
+  SitePermissions.remove(gBrowser.currentURI, "cookie");
+  SitePermissions.remove(gBrowser.currentURI, "geo");
+  SitePermissions.remove(gBrowser.currentURI, "camera");
+
   while (gBrowser.tabs.length > 1) {
     gBrowser.removeCurrentTab();
   }
 });
 
 add_task(function* testMainViewVisible() {
   let {gIdentityHandler} = gBrowser.ownerGlobal;
   let tab = gBrowser.selectedTab = gBrowser.addTab();
@@ -20,17 +24,17 @@ add_task(function* testMainViewVisible()
 
   let permissionsList = document.getElementById("identity-popup-permission-list");
   let emptyLabel = permissionsList.nextSibling;
 
   gIdentityHandler._identityBox.click();
   ok(!is_hidden(emptyLabel), "List of permissions is empty");
   gIdentityHandler._identityPopup.hidden = true;
 
-  gIdentityHandler.setPermission("install", 1);
+  gIdentityHandler.setPermission("install", SitePermissions.ALLOW);
 
   gIdentityHandler._identityBox.click();
   ok(is_hidden(emptyLabel), "List of permissions is not empty");
 
   let labelText = SitePermissions.getPermissionLabel("install");
   let labels = permissionsList.querySelectorAll(".identity-popup-permission-label");
   is(labels.length, 1, "One permission visible in main view");
   is(labels[0].textContent, labelText, "Correct value");
@@ -42,8 +46,38 @@ add_task(function* testMainViewVisible()
   gIdentityHandler._identityPopup.hidden = true;
 
   gIdentityHandler.setPermission("install", SitePermissions.getDefault("install"));
 
   gIdentityHandler._identityBox.click();
   ok(!is_hidden(emptyLabel), "List of permissions is empty");
   gIdentityHandler._identityPopup.hidden = true;
 });
+
+add_task(function* testIdentityIcon() {
+  let {gIdentityHandler} = gBrowser.ownerGlobal;
+  let tab = gBrowser.selectedTab = gBrowser.addTab();
+  yield promiseTabLoadEvent(tab, PERMISSIONS_PAGE);
+
+  gIdentityHandler.setPermission("geo", SitePermissions.ALLOW);
+  gIdentityHandler.refreshIdentityBlock();
+
+  ok(gIdentityHandler._identityBox.classList.contains("grantedPermissions"),
+    "identity-box signals granted permssions");
+
+  gIdentityHandler.setPermission("geo", SitePermissions.getDefault("geo"));
+  gIdentityHandler.refreshIdentityBlock();
+
+  ok(!gIdentityHandler._identityBox.classList.contains("grantedPermissions"),
+    "identity-box doesn't signal granted permssions");
+
+  gIdentityHandler.setPermission("camera", SitePermissions.BLOCK);
+  gIdentityHandler.refreshIdentityBlock();
+
+  ok(!gIdentityHandler._identityBox.classList.contains("grantedPermissions"),
+    "identity-box doesn't signal granted permssions");
+
+  gIdentityHandler.setPermission("cookie", SitePermissions.SESSION);
+  gIdentityHandler.refreshIdentityBlock();
+
+  ok(gIdentityHandler._identityBox.classList.contains("grantedPermissions"),
+    "identity-box signals granted permssions");
+});
--- a/browser/themes/shared/identity-block/identity-block.inc.css
+++ b/browser/themes/shared/identity-block/identity-block.inc.css
@@ -96,16 +96,25 @@
   list-style-image: url(chrome://browser/skin/identity-icon.svg#normal);
 }
 
 #identity-box:hover > #identity-icon,
 #identity-box[open=true] > #identity-icon {
   list-style-image: url(chrome://browser/skin/identity-icon.svg#hover);
 }
 
+#identity-box.grantedPermissions > #identity-icon {
+  list-style-image: url(chrome://browser/skin/identity-icon.svg#notice);
+}
+
+#identity-box.grantedPermissions:hover > #identity-icon,
+#identity-box.grantedPermissions[open=true] > #identity-icon {
+  list-style-image: url(chrome://browser/skin/identity-icon.svg#notice-hover);
+}
+
 #urlbar[pageproxystate="valid"] > #identity-box.chromeUI > #identity-icon {
   list-style-image: url(chrome://branding/content/identity-icons-brand.svg);
 }
 
 #urlbar[pageproxystate="invalid"] > #identity-box > #identity-icon {
   opacity: 0.3;
 }
 
--- a/browser/themes/shared/identity-block/identity-icon.svg
+++ b/browser/themes/shared/identity-block/identity-icon.svg
@@ -1,31 +1,36 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
-     width="48" height="16" viewBox="0 0 32 16">
+     width="64" height="16" viewBox="0 0 64 16">
   <defs>
-    <circle id="shape-circle-base" cx="8" cy="8" r="7" />
-    <g id="shape-i">
-      <circle cx="8" cy="5" r="1" />
-      <rect x="7" y="7" width="2" height="5" rx="1" ry="1" />
-    </g>
-    <mask id="mask-ring-cutout">
-      <rect width="16" height="16" fill="#000" />
-      <use xlink:href="#shape-circle-base" fill="#fff" />
-      <circle cx="8" cy="8" r="6" fill="#000" />
-    </mask>
+    <style>
+      path {
+        fill-rule: evenodd;
+        fill: #999999;
+      }
+    </style>
   </defs>
 
   <view id="normal" viewBox="0 0 16 16"/>
   <g>
-    <use xlink:href="#shape-circle-base" mask="url(#mask-ring-cutout)" fill="#999" />
-    <use xlink:href="#shape-i" fill="#999" />
+    <path d="M128,193a7,7,0,1,1,7-7A7,7,0,0,1,128,193Zm0-13a6,6,0,1,0,6,6A6,6,0,0,0,128,180Zm0,10a1,1,0,0,1-1-1v-3a1,1,0,0,1,2,0v3A1,1,0,0,1,128,190Zm0-6a1,1,0,1,1,1-1A1,1,0,0,1,128,184Z" transform="translate(-120 -178)"/>
   </g>
 
   <view id="hover" viewBox="16 0 16 16"/>
   <g transform="translate(16)">
-    <use xlink:href="#shape-circle-base" fill="#4c9ed9" />
-    <use xlink:href="#shape-i" fill="#fff" />
+    <path d="M102,179a7,7,0,1,1-7,7A7,7,0,0,1,102,179Zm0,3a1,1,0,1,1-1,1A1,1,0,0,1,102,182Zm0,3a1,1,0,0,1,1,1v3a1,1,0,0,1-2,0v-3A1,1,0,0,1,102,185Z" transform="translate(-94 -178)"/>
+  </g>
+
+  <view id="notice" viewBox="32 0 16 16"/>
+  <g transform="translate(32)">
+    <path d="M133.5,202a2.5,2.5,0,1,1,2.5-2.5A2.5,2.5,0,0,1,133.5,202Zm-5.5,1a1,1,0,1,1,1-1A1,1,0,0,1,128,203Zm1,5a1,1,0,0,1-2,0v-3a1,1,0,0,1,2,0v3Zm-1-9a6.08,6.08,0,1,0,5.629,3.987,3.452,3.452,0,0,0,.984-0.185A6.9,6.9,0,0,1,135,205a7,7,0,1,1-7-7,6.9,6.9,0,0,1,2.2.387,3.452,3.452,0,0,0-.185.984A5.951,5.951,0,0,0,128,199Z" transform="translate(-120 -197)"/>
   </g>
+
+  <view id="notice-hover" viewBox="48 0 16 16"/>
+  <g transform="translate(48)">
+    <path d="M107.5,202a2.5,2.5,0,1,1,2.5-2.5A2.5,2.5,0,0,1,107.5,202Zm0,1.039a3.5,3.5,0,0,0,1.125-.2,7.124,7.124,0,1,1-4.464-4.464,3.5,3.5,0,0,0-.2,1.125A3.54,3.54,0,0,0,107.5,203.039ZM102,201a1,1,0,1,0,1,1A1,1,0,0,0,102,201Zm1,4a1,1,0,0,0-2,0v3a1,1,0,0,0,2,0v-3Z" transform="translate(-94 -197)"/>
+  </g>
+
 </svg>