Moved functionality from ndnToolbarGetVersion to NdnProtocolInfo.getVersion so that Firefox for Android can use it too.
diff --git a/ndnProtocol/content/ndnToolbar.js b/ndnProtocol/content/ndnToolbar.js
index ddd5cda..41aa8ab 100644
--- a/ndnProtocol/content/ndnToolbar.js
+++ b/ndnProtocol/content/ndnToolbar.js
@@ -1,67 +1,26 @@
+/*
+ * @author: Jeff Thompson
+ * See COPYING for copyright and distribution information.
+ * This is called from the NDN toolbar and the doorhanger popup on Firefox for Android.
+ */
+
 Components.utils.import("chrome://modules/content/ndn-js.jsm");
 Components.utils.import("chrome://modules/content/NdnProtocolInfo.jsm");
 
 function ndnToolbarGetVersion(selector) {
- try {
-  if (window._content.document.location.protocol != "ndn:") {
-    alert("The address must start with ndn:");
-    return;
-  }
-
-  // Parse the same as in ndnProtocolService newChannel.
-  var uriParts = NdnProtocolInfo.splitUri(window._content.document.location.href);
-  var name = new Name(uriParts.name);
-  var indexOfVersion = getIndexOfVersion(name);
-  if (indexOfVersion < 0) {
-    alert("The ndn address does not have a version");
-    return;
-  }
-  
-  var escapedVersion = Name.toEscapedString(name.components[indexOfVersion]);
-
-  var childSelector;
-  if (selector == "earliest")
-      childSelector = "ndn.ChildSelector=0";
-  else if (selector == "latest")
-      childSelector = "ndn.ChildSelector=1";
-  else if (selector == "previous")
-      childSelector = "ndn.ChildSelector=1&ndn.Exclude=" + escapedVersion + ",*";
-  else if (selector == "next")
-      childSelector = "ndn.ChildSelector=0&ndn.Exclude=*," + escapedVersion;
-  else
-      // Don't expect this to happen.
-      return;
-
-  var nameWithoutVersion = new Name(name.components.slice(0, indexOfVersion));
-  var searchWithChildSelector = (uriParts.search == "" ? "?" : uriParts.search + "&") + childSelector;
-    
-  var uri = "ndn:" + nameWithoutVersion.to_uri() + searchWithChildSelector + uriParts.hash;
-  window._content.document.location = uri;
- } catch (ex) {
-       dump("ndnToolbarGetVersion exception: " + ex + "\n" + ex.stack);
- }
-} 
-
-/*
- * Return the index of the last component that starts with 0xfd, or -1 if not found.
- */
-function getIndexOfVersion(name) {
-  for (var i = name.components.length - 1; i >= 0; --i) {
-    if (name.components[i].length >= 1 && name.components[i][0] == 0xfd)
-      return i;
-  }
-
-  return -1;
+  NdnProtocolInfo.getVersion(selector, window, alert);
 }
 
 /*
  * This is called when the connected NDN hub changes.
  */
 function onNdnHubChanged(host, port) {
-   document.getElementById("ndnHubLabel").setAttribute("value", "Hub: " + host + ":" + port);
+  document.getElementById("ndnHubLabel").setAttribute("value", "Hub: " + host + ":" + port);
 }
 
-window.addEventListener("load", function() { NdnProtocolInfo.addNdnHubChangedListener(onNdnHubChanged); }, false);
+if (window) 
+  window.addEventListener("load", function() { NdnProtocolInfo.addNdnHubChangedListener(onNdnHubChanged); }, 
+                          false);
 
 function ndnToolbarSetHub() {
     var host = prompt("Enter hub host:", NdnProtocolInfo.ndn.host);
diff --git a/ndnProtocol/modules/NdnProtocolInfo.jsm b/ndnProtocol/modules/NdnProtocolInfo.jsm
index 396aeb9..4b24d96 100644
--- a/ndnProtocol/modules/NdnProtocolInfo.jsm
+++ b/ndnProtocol/modules/NdnProtocolInfo.jsm
@@ -15,7 +15,8 @@
 var NdnProtocolInfo = function NdnProtocolInfo(){
 };
 
-NdnProtocolInfo.ndn = new NDN({ getTransport: function() { return new XpcomTransport(); }, 
+NdnProtocolInfo.ndn = new NDN({ getTransport: function() { return new XpcomTransport(); },
+                              host: "A.hub.ndn.ucla.edu", port: 9695,
                               verify: false });
 
 // These are set once a connection is established.
@@ -38,7 +39,7 @@
             // Ignore error from the listener.
         }
     }
-}
+};
 
 /*
  * If host and port are different than ndnHubHost or ndnHubPort, set them and call each
@@ -59,7 +60,7 @@
             // Ignore error from the listener.
         }
     }
-}
+};
 
 /*
  * Split the URI spec and return an object with protocol (including ':'), name, 
@@ -87,4 +88,64 @@
     }
     
     return result;
+};
+
+/*
+ * Do the work of the NDN Get Version buttons.
+ * selector is "earliest", "latest", "previous" or "next".
+ * currentWindow is the window with the address.
+ * alertFunction(message) shows an alert.
+ */
+NdnProtocolInfo.getVersion = function(selector, currentWindow, alertFunction) {
+ alertFunction("ndnGetVersion called");
+ try {
+  if (currentWindow._content.document.location.protocol != "ndn:") {
+    alertFunction("The address must start with ndn:");
+    return;
+  }
+
+  // Parse the same as in ndnProtocolService newChannel.
+  var uriParts = NdnProtocolInfo.splitUri(currentWindow._content.document.location.href);
+  var name = new Name(uriParts.name);
+  var indexOfVersion = getIndexOfVersion(name);
+  if (indexOfVersion < 0) {
+    alertFunction("The ndn address does not have a version");
+    return;
+  }
+  
+  var escapedVersion = Name.toEscapedString(name.components[indexOfVersion]);
+
+  var childSelector;
+  if (selector == "earliest")
+      childSelector = "ndn.ChildSelector=0";
+  else if (selector == "latest")
+      childSelector = "ndn.ChildSelector=1";
+  else if (selector == "previous")
+      childSelector = "ndn.ChildSelector=1&ndn.Exclude=" + escapedVersion + ",*";
+  else if (selector == "next")
+      childSelector = "ndn.ChildSelector=0&ndn.Exclude=*," + escapedVersion;
+  else
+      // Don't expect this to happen.
+      return;
+
+  var nameWithoutVersion = new Name(name.components.slice(0, indexOfVersion));
+  var searchWithChildSelector = (uriParts.search == "" ? "?" : uriParts.search + "&") + childSelector;
+    
+  var uri = "ndn:" + nameWithoutVersion.to_uri() + searchWithChildSelector + uriParts.hash;
+  currentWindow._content.document.location = uri;
+ } catch (ex) {
+       dump("ndnToolbarGetVersion exception: " + ex + "\n" + ex.stack);
+ }
+};
+
+/*
+ * Return the index of the last component that starts with 0xfd, or -1 if not found.
+ */
+function getIndexOfVersion(name) {
+  for (var i = name.components.length - 1; i >= 0; --i) {
+    if (name.components[i].length >= 1 && name.components[i][0] == 0xfd)
+      return i;
+  }
+
+  return -1;
 }