| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview | 6 * @fileoverview |
| 7 * Class that routes gnubby-auth extension messages to and from the gnubbyd | 7 * Class that routes gnubby-auth extension messages to and from the gnubbyd |
| 8 * extension. | 8 * extension. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 */ | 46 */ |
| 47 remoting.GnubbyAuthHandler.prototype.sendMessageToHost_ = function(data) { | 47 remoting.GnubbyAuthHandler.prototype.sendMessageToHost_ = function(data) { |
| 48 this.sendMessageToHostCallback_(this.getType(), JSON.stringify(data)); | 48 this.sendMessageToHostCallback_(this.getType(), JSON.stringify(data)); |
| 49 } | 49 } |
| 50 | 50 |
| 51 /** | 51 /** |
| 52 * Processes gnubby-auth messages. | 52 * Processes gnubby-auth messages. |
| 53 * @param {string} data The gnubby-auth message data. | 53 * @param {string} data The gnubby-auth message data. |
| 54 */ | 54 */ |
| 55 remoting.GnubbyAuthHandler.prototype.onMessage = function(data) { | 55 remoting.GnubbyAuthHandler.prototype.onMessage = function(data) { |
| 56 var message = getJsonObjectFromString(data); | 56 var message = base.getJsonObjectFromString(data); |
| 57 var messageType = getStringAttr(message, 'type'); | 57 var messageType = base.getStringAttr(message, 'type'); |
| 58 if (messageType == 'data') { | 58 if (messageType == 'data') { |
| 59 this.sendMessageToGnubbyd_({ | 59 this.sendMessageToGnubbyd_({ |
| 60 'type': 'auth-agent@openssh.com', | 60 'type': 'auth-agent@openssh.com', |
| 61 'data': getArrayAttr(message, 'data') | 61 'data': base.getArrayAttr(message, 'data') |
| 62 }, this.callback_.bind(this, getNumberAttr(message, 'connectionId'))); | 62 }, this.callback_.bind(this, base.getNumberAttr(message, 'connectionId'))); |
| 63 } else { | 63 } else { |
| 64 console.error('Invalid gnubby-auth message: ' + messageType); | 64 console.error('Invalid gnubby-auth message: ' + messageType); |
| 65 } | 65 } |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 /** | 68 /** |
| 69 * Callback invoked with data to be returned to the host. | 69 * Callback invoked with data to be returned to the host. |
| 70 * @param {number} connectionId The connection id. | 70 * @param {number} connectionId The connection id. |
| 71 * @param {Object} response The JSON response with the data to send to the host. | 71 * @param {Object} response The JSON response with the data to send to the host. |
| 72 * @private | 72 * @private |
| 73 */ | 73 */ |
| 74 remoting.GnubbyAuthHandler.prototype.callback_ = | 74 remoting.GnubbyAuthHandler.prototype.callback_ = |
| 75 function(connectionId, response) { | 75 function(connectionId, response) { |
| 76 try { | 76 try { |
| 77 this.sendMessageToHost_({ | 77 this.sendMessageToHost_({ |
| 78 'type': 'data', | 78 'type': 'data', |
| 79 'connectionId': connectionId, | 79 'connectionId': connectionId, |
| 80 'data': getArrayAttr(response, 'data') | 80 'data': base.getArrayAttr(response, 'data') |
| 81 }); | 81 }); |
| 82 } catch (/** @type {*} */ err) { | 82 } catch (/** @type {*} */ err) { |
| 83 console.error('gnubby callback failed: ', err); | 83 console.error('gnubby callback failed: ', err); |
| 84 this.sendMessageToHost_({ | 84 this.sendMessageToHost_({ |
| 85 'type': 'error', | 85 'type': 'error', |
| 86 'connectionId': connectionId | 86 'connectionId': connectionId |
| 87 }); | 87 }); |
| 88 return; | 88 return; |
| 89 } | 89 } |
| 90 }; | 90 }; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 117 */ | 117 */ |
| 118 function onGnubbydDevReply_(jsonObject, callback, reply) { | 118 function onGnubbydDevReply_(jsonObject, callback, reply) { |
| 119 var kGnubbydStableExtensionId = 'beknehfpfkghjoafdifaflglpjkojoco'; | 119 var kGnubbydStableExtensionId = 'beknehfpfkghjoafdifaflglpjkojoco'; |
| 120 | 120 |
| 121 if (reply) { | 121 if (reply) { |
| 122 callback(reply); | 122 callback(reply); |
| 123 } else { | 123 } else { |
| 124 chrome.runtime.sendMessage(kGnubbydStableExtensionId, jsonObject, callback); | 124 chrome.runtime.sendMessage(kGnubbydStableExtensionId, jsonObject, callback); |
| 125 } | 125 } |
| 126 } | 126 } |
| OLD | NEW |