| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 | 55 |
| 56 /** | 56 /** |
| 57 * Processes gnubby-auth messages. | 57 * Processes gnubby-auth messages. |
| 58 * | 58 * |
| 59 * @param {string} type The message type. | 59 * @param {string} type The message type. |
| 60 * @param {Object} message The parsed extension message data. | 60 * @param {Object} message The parsed extension message data. |
| 61 * @return {boolean} True if the extension message was handled. | 61 * @return {boolean} True if the extension message was handled. |
| 62 */ | 62 */ |
| 63 remoting.GnubbyAuthHandler.prototype.onExtensionMessage = | 63 remoting.GnubbyAuthHandler.prototype.onExtensionMessage = |
| 64 function(type, message) { | 64 function(type, message) { |
| 65 var messageType = getStringAttr(message, 'type'); | 65 var messageType = base.getStringAttr(message, 'type'); |
| 66 if (messageType == 'data') { | 66 if (messageType == 'data') { |
| 67 this.sendMessageToGnubbyd_({ | 67 this.sendMessageToGnubbyd_({ |
| 68 'type': 'auth-agent@openssh.com', | 68 'type': 'auth-agent@openssh.com', |
| 69 'data': getArrayAttr(message, 'data') | 69 'data': base.getArrayAttr(message, 'data') |
| 70 }, this.callback_.bind(this, getNumberAttr(message, 'connectionId'))); | 70 }, this.callback_.bind(this, base.getNumberAttr(message, 'connectionId'))); |
| 71 } else { | 71 } else { |
| 72 console.error('Invalid gnubby-auth message: ' + messageType); | 72 console.error('Invalid gnubby-auth message: ' + messageType); |
| 73 return false; | 73 return false; |
| 74 } | 74 } |
| 75 return true; | 75 return true; |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 /** | 78 /** |
| 79 * Callback invoked with data to be returned to the host. | 79 * Callback invoked with data to be returned to the host. |
| 80 * @param {number} connectionId The connection id. | 80 * @param {number} connectionId The connection id. |
| 81 * @param {Object} response The JSON response with the data to send to the host. | 81 * @param {Object} response The JSON response with the data to send to the host. |
| 82 * @private | 82 * @private |
| 83 */ | 83 */ |
| 84 remoting.GnubbyAuthHandler.prototype.callback_ = | 84 remoting.GnubbyAuthHandler.prototype.callback_ = |
| 85 function(connectionId, response) { | 85 function(connectionId, response) { |
| 86 try { | 86 try { |
| 87 this.sendMessageToHost_({ | 87 this.sendMessageToHost_({ |
| 88 'type': 'data', | 88 'type': 'data', |
| 89 'connectionId': connectionId, | 89 'connectionId': connectionId, |
| 90 'data': getArrayAttr(response, 'data') | 90 'data': base.getArrayAttr(response, 'data') |
| 91 }); | 91 }); |
| 92 } catch (/** @type {*} */ err) { | 92 } catch (/** @type {*} */ err) { |
| 93 console.error('gnubby callback failed: ', err); | 93 console.error('gnubby callback failed: ', err); |
| 94 this.sendMessageToHost_({ | 94 this.sendMessageToHost_({ |
| 95 'type': 'error', | 95 'type': 'error', |
| 96 'connectionId': connectionId | 96 'connectionId': connectionId |
| 97 }); | 97 }); |
| 98 return; | 98 return; |
| 99 } | 99 } |
| 100 }; | 100 }; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 127 */ | 127 */ |
| 128 function onGnubbydDevReply_(jsonObject, callback, reply) { | 128 function onGnubbydDevReply_(jsonObject, callback, reply) { |
| 129 var kGnubbydStableExtensionId = 'beknehfpfkghjoafdifaflglpjkojoco'; | 129 var kGnubbydStableExtensionId = 'beknehfpfkghjoafdifaflglpjkojoco'; |
| 130 | 130 |
| 131 if (reply) { | 131 if (reply) { |
| 132 callback(reply); | 132 callback(reply); |
| 133 } else { | 133 } else { |
| 134 chrome.runtime.sendMessage(kGnubbydStableExtensionId, jsonObject, callback); | 134 chrome.runtime.sendMessage(kGnubbydStableExtensionId, jsonObject, callback); |
| 135 } | 135 } |
| 136 } | 136 } |
| OLD | NEW |