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

Side by Side Diff: chrome/browser/resources/cryptotoken/webrequest.js

Issue 607913003: Improved error reporting in cryptotoken (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « chrome/browser/resources/cryptotoken/signer.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 Does common handling for requests coming from web pages and 6 * @fileoverview Does common handling for requests coming from web pages and
7 * routes them to the provided handler. 7 * routes them to the provided handler.
8 */ 8 */
9 9
10 /** 10 /**
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 return forSign ? GnubbyCodeTypes.NONE_PLUGGED_ENROLLED : 221 return forSign ? GnubbyCodeTypes.NONE_PLUGGED_ENROLLED :
222 GnubbyCodeTypes.ALREADY_ENROLLED; 222 GnubbyCodeTypes.ALREADY_ENROLLED;
223 223
224 case ErrorCodes.TIMEOUT: 224 case ErrorCodes.TIMEOUT:
225 return GnubbyCodeTypes.WAIT_TOUCH; 225 return GnubbyCodeTypes.WAIT_TOUCH;
226 } 226 }
227 return GnubbyCodeTypes.UNKNOWN_ERROR; 227 return GnubbyCodeTypes.UNKNOWN_ERROR;
228 } 228 }
229 229
230 /** 230 /**
231 * Maps a helper's error code from the DeviceStatusCodes namespace to the 231 * Maps a helper's error code from the DeviceStatusCodes namespace to a
232 * ErrorCodes namespace. 232 * U2fError.
233 * @param {number} code Error code from DeviceStatusCodes namespace. 233 * @param {number} code Error code from DeviceStatusCodes namespace.
234 * @return {ErrorCodes} A ErrorCodes error code. 234 * @return {U2fError} An error.
235 */ 235 */
236 function mapDeviceStatusCodeToErrorCode(code) { 236 function mapDeviceStatusCodeToU2fError(code) {
237 var reportedError = ErrorCodes.OTHER_ERROR;
238 switch (code) { 237 switch (code) {
239 case DeviceStatusCodes.WRONG_DATA_STATUS: 238 case DeviceStatusCodes.WRONG_DATA_STATUS:
240 reportedError = ErrorCodes.DEVICE_INELIGIBLE; 239 return {errorCode: ErrorCodes.DEVICE_INELIGIBLE};
241 break;
242 240
243 case DeviceStatusCodes.TIMEOUT_STATUS: 241 case DeviceStatusCodes.TIMEOUT_STATUS:
244 case DeviceStatusCodes.WAIT_TOUCH_STATUS: 242 case DeviceStatusCodes.WAIT_TOUCH_STATUS:
245 reportedError = ErrorCodes.TIMEOUT; 243 return {errorCode: ErrorCodes.TIMEOUT};
246 break; 244
245 default:
246 var reportedError = {
247 errorCode: ErrorCodes.OTHER_ERROR,
248 errorMessage: 'device status code: ' + code.toString(16)
249 };
250 return reportedError;
247 } 251 }
248 return reportedError;
249 } 252 }
250 253
251 /** 254 /**
252 * Sends a response, using the given sentinel to ensure at most one response is 255 * Sends a response, using the given sentinel to ensure at most one response is
253 * sent. Also closes the closeable, if it's given. 256 * sent. Also closes the closeable, if it's given.
254 * @param {boolean} sentResponse Whether a response has already been sent. 257 * @param {boolean} sentResponse Whether a response has already been sent.
255 * @param {?Closeable} closeable A thing to close. 258 * @param {?Closeable} closeable A thing to close.
256 * @param {*} response The response to send. 259 * @param {*} response The response to send.
257 * @param {Function} sendResponse A function to send the response. 260 * @param {Function} sendResponse A function to send the response.
258 */ 261 */
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 'type': 'sign_helper_request', 421 'type': 'sign_helper_request',
419 'signData': challenges, 422 'signData': challenges,
420 'timeout': opt_timeoutSeconds || 0, 423 'timeout': opt_timeoutSeconds || 0,
421 'timeoutSeconds': opt_timeoutSeconds || 0 424 'timeoutSeconds': opt_timeoutSeconds || 0
422 }; 425 };
423 if (opt_logMsgUrl !== undefined) { 426 if (opt_logMsgUrl !== undefined) {
424 request.logMsgUrl = opt_logMsgUrl; 427 request.logMsgUrl = opt_logMsgUrl;
425 } 428 }
426 return request; 429 return request;
427 } 430 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/cryptotoken/signer.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698