Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Side by Side Diff: remoting/webapp/gnubby_auth_handler.js

Issue 205493005: Do minimal processing of gnubby data. Add request timeouts and send error (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comment changes Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 13 matching lines...) Expand all
24 24
25 /** 25 /**
26 * Processes gnubby-auth messages. 26 * Processes gnubby-auth messages.
27 * @param {string} data The gnubby-auth message data. 27 * @param {string} data The gnubby-auth message data.
28 */ 28 */
29 remoting.GnubbyAuthHandler.prototype.onMessage = function(data) { 29 remoting.GnubbyAuthHandler.prototype.onMessage = function(data) {
30 var message = getJsonObjectFromString(data); 30 var message = getJsonObjectFromString(data);
31 var messageType = getStringAttr(message, 'type'); 31 var messageType = getStringAttr(message, 'type');
32 if (messageType == 'data') { 32 if (messageType == 'data') {
33 this.sendMessageToGnubbyd_( 33 this.sendMessageToGnubbyd_(
34 getJsonObjectFromString(getStringAttr(message, 'jsonMessage')), 34 {'type': 'auth-agent@openssh.com',
Sergey Ulanov 2014/03/22 00:45:57 nit: space before 'type'
psj 2014/03/22 01:30:19 Hmm, I mis-remembered the style guide here - the b
35 'data': getArrayAttr(message, 'data')},
35 this.callback_.bind(this, getNumberAttr(message, 'connectionId'))); 36 this.callback_.bind(this, getNumberAttr(message, 'connectionId')));
36 } else { 37 } else {
37 console.error('Invalid gnubby-auth message: ' + messageType); 38 console.error('Invalid gnubby-auth message: ' + messageType);
38 } 39 }
39 }; 40 };
40 41
41 /** 42 /**
42 * Callback invoked with data to be returned to the host. 43 * Callback invoked with data to be returned to the host.
43 * @param {number} connectionId The connection id. 44 * @param {number} connectionId The connection id.
44 * @param {Object} data The JSON object to send to the host. 45 * @param {Object} response The JSON response with the data to send to the host.
45 * @private 46 * @private
46 */ 47 */
47 remoting.GnubbyAuthHandler.prototype.callback_ = 48 remoting.GnubbyAuthHandler.prototype.callback_ =
48 function(connectionId, data) { 49 function(connectionId, response) {
49 var json_data = JSON.stringify(data); 50 try {
50 this.clientSession_.sendGnubbyAuthMessage({'type': 'data', 51 this.clientSession_.sendGnubbyAuthMessage({
51 'connectionId': connectionId, 52 'type': 'data',
52 'jsonMessage': json_data}); 53 'connectionId': connectionId,
54 'data': getArrayAttr(response, 'data')});
Sergey Ulanov 2014/03/22 00:45:57 nit: space before }
psj 2014/03/22 01:30:19 Similar to the opening brace, the multiline initia
55 } catch (err) {
56 console.error('gnubby callback failed: ', /** @type {*} */ (err));
57 this.clientSession_.sendGnubbyAuthMessage({'type': 'error',
58 'connectionId': connectionId});
Sergey Ulanov 2014/03/22 00:45:57 nit: move type field to match the formatting in li
psj 2014/03/22 01:30:19 Done.
59 return;
60 }
53 }; 61 };
54 62
55 /** 63 /**
56 * Send data to the gnubbyd extension. 64 * Send data to the gnubbyd extension.
57 * @param {Object} jsonObject The JSON object to send to the gnubbyd extension. 65 * @param {Object} jsonObject The JSON object to send to the gnubbyd extension.
58 * @param {function(Object)} callback The callback to invoke with reply data. 66 * @param {function(Object)} callback The callback to invoke with reply data.
59 * @private 67 * @private
60 */ 68 */
61 remoting.GnubbyAuthHandler.prototype.sendMessageToGnubbyd_ = 69 remoting.GnubbyAuthHandler.prototype.sendMessageToGnubbyd_ =
62 function(jsonObject, callback) { 70 function(jsonObject, callback) {
(...skipping 16 matching lines...) Expand all
79 * @private 87 * @private
80 */ 88 */
81 function onGnubbydDevReply_(jsonObject, callback, reply) { 89 function onGnubbydDevReply_(jsonObject, callback, reply) {
82 var kGnubbydStableExtensionId = 'beknehfpfkghjoafdifaflglpjkojoco'; 90 var kGnubbydStableExtensionId = 'beknehfpfkghjoafdifaflglpjkojoco';
83 91
84 if (reply) { 92 if (reply) {
85 callback(reply); 93 callback(reply);
86 } else { 94 } else {
87 chrome.runtime.sendMessage(kGnubbydStableExtensionId, jsonObject, callback); 95 chrome.runtime.sendMessage(kGnubbydStableExtensionId, jsonObject, callback);
88 } 96 }
89 }; 97 }
OLDNEW
« remoting/host/gnubby_auth_handler_posix.cc ('K') | « remoting/remoting_test.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698