Fix the build.  We shouldn't be importing profiles in libraries.

Change-Id: I47c68316f3a4419f8b2b7ec2bc947644e5bc50d4
diff --git a/services/wsprd/app/app.go b/services/wsprd/app/app.go
index f17b6dd..d433c67 100644
--- a/services/wsprd/app/app.go
+++ b/services/wsprd/app/app.go
@@ -12,7 +12,6 @@
 	"sync"
 	"time"
 
-	"veyron.io/veyron/veyron/profiles/roaming"
 	vsecurity "veyron.io/veyron/veyron/security"
 	"veyron.io/veyron/veyron2"
 	"veyron.io/veyron/veyron2/context"
@@ -153,8 +152,10 @@
 // NewController creates a new Controller.  writerCreator will be used to create a new flow for rpcs to
 // javascript server. veyronProxyEP is an endpoint for the veyron proxy to serve through.  It can't be empty.
 // opts are any options that should be passed to the rt.New().
-func NewController(writerCreator func(id int64) lib.ClientWriter, listenSpec *ipc.ListenSpec, namespaceRoots []string, opts ...veyron2.ROpt) (*Controller, error) {
-	opts = append(opts, options.Profile{roaming.New()})
+func NewController(writerCreator func(id int64) lib.ClientWriter, profile veyron2.Profile, listenSpec *ipc.ListenSpec, namespaceRoots []string, opts ...veyron2.ROpt) (*Controller, error) {
+	if profile != nil {
+		opts = append(opts, options.Profile{profile})
+	}
 	r, err := rt.New(opts...)
 	if err != nil {
 		return nil, err
diff --git a/services/wsprd/browspr/browspr.go b/services/wsprd/browspr/browspr.go
index ca6d653..de82b9f 100644
--- a/services/wsprd/browspr/browspr.go
+++ b/services/wsprd/browspr/browspr.go
@@ -19,6 +19,7 @@
 // Browspr is an intermediary between our javascript code and the veyron network that allows our javascript library to use veyron.
 type Browspr struct {
 	rt             veyron2.Runtime
+	profileFactory func() veyron2.Profile
 	listenSpec     ipc.ListenSpec
 	identdEP       string
 	namespaceRoots []string
@@ -30,7 +31,7 @@
 }
 
 // Create a new Browspr instance.
-func NewBrowspr(postMessage func(instanceId int32, ty, msg string), listenSpec ipc.ListenSpec, identdEP string, namespaceRoots []string, opts ...veyron2.ROpt) *Browspr {
+func NewBrowspr(postMessage func(instanceId int32, ty, msg string), profileFactory func() veyron2.Profile, listenSpec ipc.ListenSpec, identdEP string, namespaceRoots []string, opts ...veyron2.ROpt) *Browspr {
 	if listenSpec.Proxy == "" {
 		vlog.Fatalf("a veyron proxy must be set")
 	}
@@ -51,6 +52,7 @@
 	runtime.Namespace().SetRoots(wsNamespaceRoots...)
 
 	browspr := &Browspr{
+		profileFactory:  profileFactory,
 		listenSpec:      listenSpec,
 		identdEP:        identdEP,
 		namespaceRoots:  wsNamespaceRoots,
diff --git a/services/wsprd/browspr/main/main_nacl.go b/services/wsprd/browspr/main/main_nacl.go
index 43d0d6c..890db0c 100644
--- a/services/wsprd/browspr/main/main_nacl.go
+++ b/services/wsprd/browspr/main/main_nacl.go
@@ -9,7 +9,7 @@
 	"runtime/ppapi"
 
 	"veyron.io/veyron/veyron/lib/websocket"
-	_ "veyron.io/veyron/veyron/profiles/chrome"
+	"veyron.io/veyron/veyron/profiles/chrome"
 	vsecurity "veyron.io/veyron/veyron/security"
 	"veyron.io/veyron/veyron2/ipc"
 	"veyron.io/veyron/veyron2/ipc/stream"
@@ -226,7 +226,7 @@
 	}
 
 	fmt.Printf("Starting browspr with config: proxy=%q mounttable=%q identityd=%q ", veyronProxy, mounttable, identityd)
-	inst.browspr = browspr.NewBrowspr(inst.BrowsprOutgoingPostMessage, listenSpec, identityd, []string{mounttable}, options.RuntimePrincipal{principal})
+	inst.browspr = browspr.NewBrowspr(inst.BrowsprOutgoingPostMessage, chrome.New, listenSpec, identityd, []string{mounttable}, options.RuntimePrincipal{principal})
 
 	inst.BrowsprOutgoingPostMessage(instanceId, "browsprStarted", "blah")
 	return nil
diff --git a/services/wsprd/browspr/pipe.go b/services/wsprd/browspr/pipe.go
index 9406bd4..3bb3dac 100644
--- a/services/wsprd/browspr/pipe.go
+++ b/services/wsprd/browspr/pipe.go
@@ -30,7 +30,7 @@
 		// TODO(bjornick): Send an error to the client when all of the principal stuff is set up.
 	}
 
-	pipe.controller, err = app.NewController(pipe.createWriter, &b.listenSpec, b.namespaceRoots, options.RuntimePrincipal{p})
+	pipe.controller, err = app.NewController(pipe.createWriter, b.profileFactory(), &b.listenSpec, b.namespaceRoots, options.RuntimePrincipal{p})
 	if err != nil {
 		b.rt.Logger().Errorf("Could not create controller: %v", err)
 		return nil
diff --git a/services/wsprd/wspr.go b/services/wsprd/wspr.go
index 8b84612..849adb6 100644
--- a/services/wsprd/wspr.go
+++ b/services/wsprd/wspr.go
@@ -18,7 +18,7 @@
 
 	rt.Init()
 
-	proxy := wspr.NewWSPR(*port, roaming.ListenSpec, *identd, nil)
+	proxy := wspr.NewWSPR(*port, roaming.New, &roaming.ListenSpec, *identd, nil)
 	defer proxy.Shutdown()
 
 	proxy.Listen()
diff --git a/services/wsprd/wspr/pipe.go b/services/wsprd/wspr/pipe.go
index ddd2b27..e2aaa84 100644
--- a/services/wsprd/wspr/pipe.go
+++ b/services/wsprd/wspr/pipe.go
@@ -8,6 +8,7 @@
 	_ "net/http/pprof"
 	"time"
 
+	"veyron.io/veyron/veyron2"
 	"veyron.io/veyron/veyron2/options"
 	"veyron.io/veyron/veyron2/vlog"
 	"veyron.io/wspr/veyron/services/wsprd/app"
@@ -68,7 +69,11 @@
 		// TODO(bjornick): Send an error to the client when all of the principal stuff is set up.
 	}
 
-	pipe.controller, err = app.NewController(creator, &wspr.listenSpec, wspr.namespaceRoots, options.RuntimePrincipal{p})
+	var profile veyron2.Profile
+	if wspr.profileFactory != nil {
+		profile = wspr.profileFactory()
+	}
+	pipe.controller, err = app.NewController(creator, profile, wspr.listenSpec, wspr.namespaceRoots, options.RuntimePrincipal{p})
 	if err != nil {
 		wspr.rt.Logger().Errorf("Could not create controller: %v", err)
 		http.Error(w, fmt.Sprintf("Failed to create controller: %v", err), http.StatusInternalServerError)
diff --git a/services/wsprd/wspr/wspr.go b/services/wsprd/wspr/wspr.go
index 287d43c..64a3e53 100644
--- a/services/wsprd/wspr/wspr.go
+++ b/services/wsprd/wspr/wspr.go
@@ -48,7 +48,8 @@
 	httpPort         int
 	ln               *net.TCPListener // HTTP listener
 	logger           vlog.Logger
-	listenSpec       ipc.ListenSpec
+	profileFactory   func() veyron2.Profile
+	listenSpec       *ipc.ListenSpec
 	identdEP         string
 	namespaceRoots   []string
 	principalManager *principal.PrincipalManager
@@ -127,7 +128,7 @@
 }
 
 // Creates a new WebSocket Proxy object.
-func NewWSPR(httpPort int, listenSpec ipc.ListenSpec, identdEP string, namespaceRoots []string, opts ...veyron2.ROpt) *WSPR {
+func NewWSPR(httpPort int, profileFactory func() veyron2.Profile, listenSpec *ipc.ListenSpec, identdEP string, namespaceRoots []string, opts ...veyron2.ROpt) *WSPR {
 	if listenSpec.Proxy == "" {
 		vlog.Fatalf("a veyron proxy must be set")
 	}
@@ -145,6 +146,7 @@
 
 	wspr := &WSPR{
 		httpPort:       httpPort,
+		profileFactory: profileFactory,
 		listenSpec:     listenSpec,
 		identdEP:       identdEP,
 		namespaceRoots: namespaceRoots,