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

Side by Side Diff: chrome/browser/resources/print_preview/cloud_print_interface.js

Issue 595153003: Compile print_preview, part 5: reduce down to 104 errors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@I_print_preview_4
Patch Set: revert movement of enums: now handle in compiler pass 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 cr.define('cloudprint', function() { 5 cr.define('cloudprint', function() {
6 'use strict'; 6 'use strict';
7 7
8 /** 8 /**
9 * API to the Google Cloud Print service. 9 * API to the Google Cloud Print service.
10 * @param {string} baseUrl Base part of the Google Cloud Print service URL 10 * @param {string} baseUrl Base part of the Google Cloud Print service URL
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 /** 60 /**
61 * Stores last received XSRF tokens for each user account. Sent as 61 * Stores last received XSRF tokens for each user account. Sent as
62 * a parameter with every request. 62 * a parameter with every request.
63 * @type {!Object.<string, string>} 63 * @type {!Object.<string, string>}
64 * @private 64 * @private
65 */ 65 */
66 this.xsrfTokens_ = {}; 66 this.xsrfTokens_ = {};
67 67
68 /** 68 /**
69 * Pending requests delayed until we get access token. 69 * Pending requests delayed until we get access token.
70 * @type {!Array.<!CloudPrintRequest>} 70 * @type {!Array.<!cloudprint.CloudPrintRequest>}
71 * @private 71 * @private
72 */ 72 */
73 this.requestQueue_ = []; 73 this.requestQueue_ = [];
74 74
75 /** 75 /**
76 * Outstanding cloud destination search requests. 76 * Outstanding cloud destination search requests.
77 * @type {!Array.<!CloudPrintRequest>} 77 * @type {!Array.<!cloudprint.CloudPrintRequest>}
78 * @private 78 * @private
79 */ 79 */
80 this.outstandingCloudSearchRequests_ = []; 80 this.outstandingCloudSearchRequests_ = [];
81 81
82 /** 82 /**
83 * Event tracker used to keep track of native layer events. 83 * Event tracker used to keep track of native layer events.
84 * @type {!EventTracker} 84 * @type {!EventTracker}
85 * @private 85 * @private
86 */ 86 */
87 this.tracker_ = new EventTracker(); 87 this.tracker_ = new EventTracker();
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 destination.origin, 310 destination.origin,
311 destination.account, 311 destination.account,
312 this.onSubmitDone_.bind(this)); 312 this.onSubmitDone_.bind(this));
313 this.sendOrQueueRequest_(cpRequest); 313 this.sendOrQueueRequest_(cpRequest);
314 }, 314 },
315 315
316 /** 316 /**
317 * Sends a Google Cloud Print printer API request. 317 * Sends a Google Cloud Print printer API request.
318 * @param {string} printerId ID of the printer to lookup. 318 * @param {string} printerId ID of the printer to lookup.
319 * @param {!print_preview.Destination.Origin} origin Origin of the printer. 319 * @param {!print_preview.Destination.Origin} origin Origin of the printer.
320 * @param {string=} account Account this printer is registered for. When 320 * @param {?string} account Account this printer is registered for. When
321 * provided for COOKIES {@code origin}, and users sessions are still not 321 * provided for COOKIES {@code origin}, and users sessions are still not
322 * known, will be checked against the response (both success and failure 322 * known, will be checked against the response (both success and failure
323 * to get printer) and, if the active user account is not the one 323 * to get printer) and, if the active user account is not the one
324 * requested, {@code account} is activated and printer request reissued. 324 * requested, {@code account} is activated and printer request reissued.
325 */ 325 */
326 printer: function(printerId, origin, account) { 326 printer: function(printerId, origin, account) {
327 var params = [ 327 var params = [
328 new HttpParam('printerid', printerId), 328 new HttpParam('printerid', printerId),
329 new HttpParam('use_cdd', 'true'), 329 new HttpParam('use_cdd', 'true'),
330 new HttpParam('printer_connection_status', 'true') 330 new HttpParam('printer_connection_status', 'true')
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 * @param {string} method HTTP method of the request. 375 * @param {string} method HTTP method of the request.
376 * @param {string} action Google Cloud Print action to perform. 376 * @param {string} action Google Cloud Print action to perform.
377 * @param {Array.<!HttpParam>} params HTTP parameters to include in the 377 * @param {Array.<!HttpParam>} params HTTP parameters to include in the
378 * request. 378 * request.
379 * @param {!print_preview.Destination.Origin} origin Origin for destination. 379 * @param {!print_preview.Destination.Origin} origin Origin for destination.
380 * @param {?string} account Account the request is sent for. Can be 380 * @param {?string} account Account the request is sent for. Can be
381 * {@code null} or empty string if the request is not cookie bound or 381 * {@code null} or empty string if the request is not cookie bound or
382 * is sent on behalf of the primary user. 382 * is sent on behalf of the primary user.
383 * @param {function(number, Object, !print_preview.Destination.Origin)} 383 * @param {function(number, Object, !print_preview.Destination.Origin)}
384 * callback Callback to invoke when request completes. 384 * callback Callback to invoke when request completes.
385 * @return {!CloudPrintRequest} Partially prepared request. 385 * @return {!cloudprint.CloudPrintRequest} Partially prepared request.
386 * @private 386 * @private
387 */ 387 */
388 buildRequest_: function(method, action, params, origin, account, callback) { 388 buildRequest_: function(method, action, params, origin, account, callback) {
389 var url = this.baseUrl_ + '/' + action + '?xsrf='; 389 var url = this.baseUrl_ + '/' + action + '?xsrf=';
390 if (origin == print_preview.Destination.Origin.COOKIES) { 390 if (origin == print_preview.Destination.Origin.COOKIES) {
391 var xsrfToken = this.xsrfTokens_[account]; 391 var xsrfToken = account ? this.xsrfTokens_[account] : undefined;
Dan Beam 2014/09/29 22:13:41 nit: unless there's an account named "undefined",
392 if (!xsrfToken) { 392 if (!xsrfToken) {
393 // TODO(rltoscano): Should throw an error if not a read-only action or 393 // TODO(rltoscano): Should throw an error if not a read-only action or
394 // issue an xsrf token request. 394 // issue an xsrf token request.
395 } else { 395 } else {
396 url = url + xsrfToken; 396 url = url + xsrfToken;
397 } 397 }
398 if (account) { 398 if (account) {
399 var index = this.userSessionIndex_[account] || 0; 399 var index = this.userSessionIndex_[account] || 0;
400 if (index > 0) { 400 if (index > 0) {
401 url += '&user=' + index; 401 url += '&user=' + index;
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 /** 822 /**
823 * Result for requests. 823 * Result for requests.
824 * @type {Object} JSON response. 824 * @type {Object} JSON response.
825 */ 825 */
826 this.result = null; 826 this.result = null;
827 }; 827 };
828 828
829 /** 829 /**
830 * Data structure that represents an HTTP parameter. 830 * Data structure that represents an HTTP parameter.
831 * @param {string} name Name of the parameter. 831 * @param {string} name Name of the parameter.
832 * @param {string} value Value of the parameter. 832 * @param {print_preview.ValueType} value Value of the parameter.
833 * @constructor 833 * @constructor
834 */ 834 */
835 function HttpParam(name, value) { 835 function HttpParam(name, value) {
836 /** 836 /**
837 * Name of the parameter. 837 * Name of the parameter.
838 * @type {string} 838 * @type {string}
839 */ 839 */
840 this.name = name; 840 this.name = name;
841 841
842 /** 842 /**
843 * Name of the value. 843 * Name of the value.
844 * @type {string} 844 * @type {print_preview.ValueType}
845 */ 845 */
846 this.value = value; 846 this.value = value;
847 }; 847 };
848 848
849 // Export 849 // Export
850 return { 850 return {
851 CloudPrintInterface: CloudPrintInterface 851 CloudPrintInterface: CloudPrintInterface,
852
853 // CloudPrintRequest is exported to be used in type definitions inside this
854 // file. It isn't actually exported to be used from other files.
855 CloudPrintRequest: CloudPrintRequest
852 }; 856 };
853 }); 857 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698