1 console.log("gssweb_background.js loading: #4");
6 var gssNativePort = null;
7 var applicationPort = null;
9 /* What to do with the output of the GSS command line */
10 function onGSSResponse(msg) {
11 console.info('Response from GSS command line: [' +
12 JSON.stringify(msg) + ']'
15 // Send the message on to the content script
16 applicationPort.postMessage(msg);
17 console.info('Response sent to the content script.');
20 function connectToNativeHost() {
21 console.info('Connecting to json_gssapi command line.');
22 // var host = 'com.google.chrome.example.echo';
23 var host = 'com.painlesssecurity.jsongss';
24 gssNativePort = chrome.runtime.connectNative( host );
25 gssNativePort.onMessage.addListener( onGSSResponse );
29 connectToNativeHost();
31 // When we receive a connection from a page through the content script...
32 chrome.runtime.onConnect.addListener(
35 // ... First, make sure that we're talking to the right people
36 console.assert(thePort.name == "com.painlesssecurity.gssweb");
38 // ... Second, save out the port
39 applicationPort = thePort;
41 applicationPort.onMessage.addListener(
42 // Now, when we receive a message
46 'About to send message to Native Port: [' +
47 JSON.stringify(msg) + ']'
49 gssNativePort.postMessage(msg);
50 console.info('... message sent to Native Port.')