Bug 402620 - protocol handling dialog should display icons and hostnames for web applications. r=Mano, ui-r=beltzner, a=blocking-firefox3+
authorflorian@queze.net
Tue, 22 Jan 2008 15:53:26 -0800
changeset 10550 a2564480351b362767b7d63684d792fdce7dfaad
parent 10549 5d0ce48d3bed9843e08c6964dd28352d6bbbc9a8
child 10551 cc4b60c869b0daba08419e22bc0720297c32a70d
push id1
push userbsmedberg@mozilla.com
push dateThu, 20 Mar 2008 16:49:24 +0000
treeherdermozilla-central@61007906a1f8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMano, beltzner, blocking-firefox3
bugs402620
milestone1.9b3pre
Bug 402620 - protocol handling dialog should display icons and hostnames for web applications. r=Mano, ui-r=beltzner, a=blocking-firefox3+
toolkit/mozapps/handling/content/dialog.js
toolkit/mozapps/handling/content/handler.xml
toolkit/themes/pinstripe/mozapps/handling/handling.css
toolkit/themes/winstripe/mozapps/handling/handling.css
--- a/toolkit/mozapps/handling/content/dialog.js
+++ b/toolkit/mozapps/handling/content/dialog.js
@@ -16,16 +16,17 @@
  * The Initial Developer of the Original Code is
  *   Mozilla Corporation.
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Shawn Wilsher <me@shawnwilsher.com> (original author)
  *   Dan Mosedale <dmose@mozilla.org>
+ *   Florian Queze <florian@queze.net>
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  * in which case the provisions of the GPL or the LGPL are applicable instead
  * of those above. If you wish to allow use of your version of this file only
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the MPL, indicate your
@@ -129,28 +130,43 @@ var dialog = {
     var items = document.getElementById("items");
     var possibleHandlers = this._handlerInfo.possibleApplicationHandlers;
     var preferredHandler = this._handlerInfo.preferredApplicationHandler;
     for (let i = possibleHandlers.length - 1; i >= 0; --i) {
       let app = possibleHandlers.queryElementAt(i, Ci.nsIHandlerApp);
       let elm = document.createElement("richlistitem");
       elm.setAttribute("type", "handler");
       elm.setAttribute("name", app.name);
-      try {
+      elm.obj = app;
+
+      if (app instanceof Ci.nsILocalHandlerApp) {
         // See if we have an nsILocalHandlerApp and set the icon
-        app = app.QueryInterface(Ci.nsILocalHandlerApp);
         let uri = Cc["@mozilla.org/network/util;1"].
                   getService(Ci.nsIIOService).
                   newFileURI(app.executable);
         elm.setAttribute("image", "moz-icon://" + uri.spec + "?size=32");
-      } catch (e) {
-        // so we have an nsIWebHandlerApp
-        // TODO get some icon for this
       }
-      elm.obj = app;
+      else if (app instanceof Ci.nsIWebHandlerApp) {
+        let uri = IO.newURI(app.uriTemplate);
+        if (/^https?/.test(uri.scheme)) {
+          let iconURI;
+          try {
+            iconURI = Cc["@mozilla.org/browser/favicon-service;1"].
+                      getService(Ci.nsIFaviconService).
+                      getFaviconForPage(IO.newURI(uri.prePath)).spec;
+          }
+          catch (e) {
+            iconURI = uri.prePath + "/favicon.ico";
+          }
+          elm.setAttribute("image", iconURI);
+        }
+        elm.setAttribute("description", uri.prePath);
+      }
+      else
+        throw "unknown handler type";
 
       items.insertBefore(elm, this._itemChoose);
       if (preferredHandler && app == preferredHandler)
         this.selectedItem = elm;
     }
 
     if (this._handlerInfo.hasDefaultHandler) {
       let elm = document.createElement("richlistitem");
--- a/toolkit/mozapps/handling/content/handler.xml
+++ b/toolkit/mozapps/handling/content/handler.xml
@@ -44,14 +44,15 @@
   <binding id="handler"
            extends="chrome://global/content/bindings/richlistbox.xml#richlistitem">
 
     <content>
       <xul:vbox pack="center">
         <xul:image xbl:inherits="src=image" height="32" width="32"/>
       </xul:vbox>
       <xul:vbox flex="1">
-        <xul:label xbl:inherits="value=name"/>
+        <xul:label class="name" xbl:inherits="value=name"/>
+        <xul:label class="description" xbl:inherits="value=description"/>
       </xul:vbox>
     </content>
   </binding>
 
 </bindings>
--- a/toolkit/themes/pinstripe/mozapps/handling/handling.css
+++ b/toolkit/themes/pinstripe/mozapps/handling/handling.css
@@ -1,17 +1,26 @@
 #description-image:not([src]) {
   height: 32px;
   width: 32px;
 }
 
 richlistitem[type] {
   min-height: 36px; /* Don't forget to update the richlistbox height! */
+  -moz-padding-start: 2px;
  }
 
 richlistitem {
   -moz-box-align: center;
 }
 
 richlistbox {
   /* 3 items high, plus 4px for top and bottom margins, less 2px for border */
   min-height: 110px;
 }
+
+.name {
+  font-weight: bold;
+}
+
+.description {
+  color: GrayText;
+}
--- a/toolkit/themes/winstripe/mozapps/handling/handling.css
+++ b/toolkit/themes/winstripe/mozapps/handling/handling.css
@@ -1,17 +1,26 @@
 #description-image:not([src]) {
   height: 32px;
   width: 32px;
 }
 
 richlistitem[type] {
   min-height: 36px; /* Don't forget to update the richlistbox height! */
+  -moz-padding-start: 2px;
  }
  
 richlistitem {
   -moz-box-align: center;
 }
 
 richlistbox {
   /* 3 items high, plus 4px for top and bottom margins, less 2px for border */
   min-height: 110px;
 }
+
+.name {
+  font-weight: bold;
+}
+
+.description {
+  color: GrayText;
+}