Merge "p2b: Rename remaining PipeToBrowser instances to Pipe2Browser"
diff --git a/Makefile b/Makefile
index ca72f73..89e5a6f 100644
--- a/Makefile
+++ b/Makefile
@@ -7,15 +7,13 @@
 # All HTML/CSS files except index.html and third party
 HTML_FILES = $(shell find browser -name "*.css" -a -not -path "*third-party*" -o  -name "*.html" -a -not -name "index.html" -a -not -path "*third-party*")
 
-# Builds everything
-all: node_modules browser/third-party browser/build.js browser/index.html $(V23_ROOT)/release/go/bin
+all: build
 
-# Build vdl.go
-go/src/v.io/x/p2b/vdl/p2b.vdl.go:
-	v23 run vdl generate -lang=go p2b/vdl
+# Builds everything
+build: node_modules go/bin/p2b browser/third-party browser/build.js browser/index.html
 
 # Compile p2b cli binary
-go/bin/p2b: go/src/v.io/x/p2b/main.go go/src/v.io/x/p2b/vdl/p2b.vdl.go
+go/bin/p2b: go/src/v.io/x/p2b/main.go go/src/v.io/x/p2b/vdl/p2b.vdl
 	v23 go install v.io/x/p2b/...
 
 # Install what we need from NPM, tools such as jspm, serve, etc...
@@ -46,11 +44,11 @@
 browser/third-party/ag-data-grid:
 	yes | cp -rf browser/libs/ui-components/data-grid browser/third-party/ag-data-grid
 
-browser/services/vdl/index.js:
+browser/services/v.io/x/p2b/vdl/index.js:
 	v23 run vdl generate --lang=javascript --js-out-dir=browser/services v.io/x/p2b/vdl
 
 # Bundle whole app and third-party JavaScript into a single build.js
-browser/build.js: $(JS_FILES) browser/services/vdl/index.js  browser/third-party node_modules
+browser/build.js: $(JS_FILES) browser/services/v.io/x/p2b/vdl/index.js browser/third-party node_modules
 	cd browser; \
 	jspm setmode local; \
 	jspm bundle app build.js
@@ -61,7 +59,7 @@
 	vulcanize -o index.html app.html
 
 # Serve
-start: browser/index.html
+start: build browser/index.html
 	serve browser/. --port 8000
 
 # Continuously watch for changes to .js, .html or .css files.
diff --git a/README.md b/README.md
index 7268c47..e279715 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
-# Pipe to Browser
+# Pipe2Browser
 P2B allows one to pipe anything from shell console to the browser. Data being
 piped to the browser then is displayed in a graphical and formatted way by a
-"viewer". Viewers are pluggable pieces of code that know how to handle and
+**viewer**. Viewers are pluggable pieces of code that know how to handle and
 display a stream of data.
 
 For example one can do:
@@ -16,30 +16,28 @@
 cat cat.jpg | p2b -binary users/jane@google.com/chrome/p2b/jane/image
 ``
 
-where **users/jane@google.com/chrome/p2b** is the Object name where p2b service
-is running in the browser. The suffix **console** or **image** specifies what
+where *users/jane@google.com/chrome/p2b/jane* is the Object name where p2b service
+is running in the browser. The suffix *console* or *image* specifies what
 viewer should be used to display the data.
 
 Please see the help page inside the P2B application for detailed tutorials.
 
 ## Building and Running
-To build
-``
-make
-``
-To run
-``
-make go/bin/p2b #Builds the p2b binary
-make start #Starts a web server at 8080
-``
-and then navigate to http://localhost:8080 and publish under a name such as 'foo'
-and run p2b rpc under vbash  with commands such as
-```
-# run vbash
-$V23_ROOT/release/go/src/v.io/x/ref/cmd/vbash
 
+```
+# build everything and start a web server at 8000
+make start
+```
+Navigate to [http://localhost:8000](http://localhost:8000) and publish under a name such as 'foo'
+then run the `vbash` tool to setup your Vanadium credentials
+```
+# run vbash to setup your Vanadium credentials
+$V23_ROOT/release/go/src/v.io/x/ref/cmd/vbash
+```
+and then run `p2b` cli client, for instance:
+```
 # run a sample p2b command
-echo "Hello World" | go/bin/p2b users/<email-address>/chrome/p2b/foo/console
+echo "Hello World" | go/bin/p2b users/<<email-address>>/chrome/p2b/foo/console
 
 ```
 
diff --git a/browser/config.js b/browser/config.js
index 56a6f8a..34f8b87 100644
--- a/browser/config.js
+++ b/browser/config.js
@@ -54,6 +54,16 @@
     "github:jspm/nodelibs-https@0.1.0": {
       "https-browserify": "npm:https-browserify@0.0.0"
     },
+    "github:jspm/nodelibs-net@0.1.2": {
+      "buffer": "github:jspm/nodelibs-buffer@0.1.0",
+      "crypto": "github:jspm/nodelibs-crypto@0.1.0",
+      "http": "github:jspm/nodelibs-http@1.7.0",
+      "net": "github:jspm/nodelibs-net@0.1.2",
+      "process": "github:jspm/nodelibs-process@0.1.1",
+      "stream": "github:jspm/nodelibs-stream@0.1.0",
+      "timers": "github:jspm/nodelibs-timers@0.1.0",
+      "util": "github:jspm/nodelibs-util@0.1.0"
+    },
     "github:jspm/nodelibs-os@0.1.0": {
       "os-browserify": "npm:os-browserify@0.1.2"
     },
@@ -387,8 +397,15 @@
       "process": "github:jspm/nodelibs-process@0.1.1"
     },
     "npm:vanadium@0.0.1": {
+      "assert": "github:jspm/nodelibs-assert@0.1.0",
       "bluebird": "npm:bluebird@2.9.8",
       "buffer": "github:jspm/nodelibs-buffer@0.1.0",
+      "child_process": "github:jspm/nodelibs-child_process@0.1.0",
+      "console": "github:jspm/nodelibs-console@0.1.0",
+      "constants": "github:jspm/nodelibs-constants@0.1.0",
+      "crypto": "github:jspm/nodelibs-crypto@0.1.0",
+      "dgram": "github:jspm/nodelibs-dgram@0.1.0",
+      "dns": "github:jspm/nodelibs-dns@0.1.0",
       "domready": "npm:domready@1.0.7",
       "es6-shim": "npm:es6-shim@0.20.4",
       "eventemitter2": "npm:eventemitter2@0.4.14",
@@ -401,13 +418,26 @@
       "is-browser": "npm:is-browser@2.0.1",
       "lru-cache": "npm:lru-cache@2.5.0",
       "minimatch": "npm:minimatch@1.0.0",
+      "module": "github:jspm/nodelibs-module@0.1.0",
+      "net": "github:jspm/nodelibs-net@0.1.2",
+      "os": "github:jspm/nodelibs-os@0.1.0",
+      "path": "github:jspm/nodelibs-path@0.1.0",
       "process": "github:jspm/nodelibs-process@0.1.1",
+      "punycode": "github:jspm/nodelibs-punycode@0.1.0",
+      "querystring": "github:jspm/nodelibs-querystring@0.1.0",
       "randombytes": "npm:randombytes@2.0.1",
       "stream": "github:jspm/nodelibs-stream@0.1.0",
+      "string_decoder": "github:jspm/nodelibs-string_decoder@0.1.0",
+      "systemjs-json": "github:systemjs/plugin-json@0.1.0",
+      "timers": "github:jspm/nodelibs-timers@0.1.0",
+      "tls": "github:jspm/nodelibs-tls@0.1.0",
+      "tty": "github:jspm/nodelibs-tty@0.1.0",
       "url": "github:jspm/nodelibs-url@0.1.0",
       "util": "github:jspm/nodelibs-util@0.1.0",
+      "vm": "github:jspm/nodelibs-vm@0.1.0",
       "ws": "npm:ws@0.4.32",
-      "xtend": "npm:xtend@4.0.0"
+      "xtend": "npm:xtend@4.0.0",
+      "zlib": "github:jspm/nodelibs-zlib@0.1.0"
     },
     "npm:vm-browserify@0.0.4": {
       "indexof": "npm:indexof@0.0.1"
diff --git a/browser/services/pipe-to-browser-client.js b/browser/services/pipe-to-browser-client.js
index cc06442..0dd4b1a 100644
--- a/browser/services/pipe-to-browser-client.js
+++ b/browser/services/pipe-to-browser-client.js
@@ -28,5 +28,11 @@
       stream.pipe(remoteStream);
       return Promise.resolve();
     });
+  }).catch((err) => {
+    if (err instanceof vanadium.verror.ExtensionNotInstalledError) {
+      vanadium.extension.promptUserToInstallExtension();
+    } else {
+      throw err;
+    }
   });
 }
diff --git a/browser/services/pipe-to-browser-namespace.js b/browser/services/pipe-to-browser-namespace.js
index d4f99e4..24c2f2a 100644
--- a/browser/services/pipe-to-browser-namespace.js
+++ b/browser/services/pipe-to-browser-namespace.js
@@ -36,5 +36,11 @@
       ctx.cancel();
       return p2bServices;
     });
+  }).catch((err) => {
+    if (err instanceof vanadium.verror.ExtensionNotInstalledError) {
+      vanadium.extension.promptUserToInstallExtension();
+    } else {
+      throw err;
+    }
   });
 }
diff --git a/browser/services/pipe-to-browser-server.js b/browser/services/pipe-to-browser-server.js
index 04e78f9..24679d8 100644
--- a/browser/services/pipe-to-browser-server.js
+++ b/browser/services/pipe-to-browser-server.js
@@ -13,7 +13,7 @@
 import { StreamByteCounter } from 'libs/utils/stream-byte-counter'
 import { StreamCopy } from 'libs/utils/stream-copy'
 import vanadium from 'vanadium'
-import vdl from 'services/p2b/vdl/index'
+import vdl from 'services/v.io/x/p2b/vdl/index'
 
 var log = new Logger('services/p2b-server');
 var server;
@@ -135,7 +135,15 @@
 
       return;
     });
-  }).catch((err) => { state.reset(); throw err; });
+  }).catch(function(err) {
+    if (err instanceof vanadium.verror.ExtensionNotInstalledError) {
+      vanadium.extension.promptUserToInstallExtension();
+      return;
+    } else {
+      state.reset();
+      throw err;
+    }
+  });
 }
 
 /*
diff --git a/browser/services/p2b/vdl/index.js b/browser/services/v.io/x/p2b/vdl/index.js
similarity index 85%
rename from browser/services/p2b/vdl/index.js
rename to browser/services/v.io/x/p2b/vdl/index.js
index fdfec9a..1171258 100644
--- a/browser/services/p2b/vdl/index.js
+++ b/browser/services/v.io/x/p2b/vdl/index.js
@@ -16,9 +16,9 @@
 
 // Types:
 var _type1 = new vdl.Type();
-_type1.kind = vdl.Kind.LIST;
+_type1.kind = vdl.kind.LIST;
 _type1.name = "";
-_type1.elem = vdl.Types.BYTE;
+_type1.elem = vdl.types.BYTE;
 _type1.freeze();
 
 
@@ -37,11 +37,11 @@
   
     
 function Viewer(){}
-module.exports.Viewer = Viewer
+module.exports.Viewer = Viewer;
 
     
       
-Viewer.prototype.pipe = function(ctx) {
+Viewer.prototype.pipe = function(ctx, serverCall) {
   throw new Error('Method Pipe not implemented');
 };
      
@@ -49,7 +49,7 @@
     
 Viewer.prototype._serviceDescription = {
   name: 'Viewer',
-  pkgPath: 'p2b/vdl',
+  pkgPath: 'v.io/x/p2b/vdl',
   doc: "// Viewer allows clients to stream data to it and to request a\n// particular viewer to format and display the data.",
   embeds: [],
   methods: [
@@ -62,7 +62,7 @@
     outArgs: [{
       name: '',
       doc: "",
-      type: vdl.Types.ANY
+      type: vdl.types.ANY
     },
     ],
     inStream: {