| OLD | NEW |
| 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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 */ | 343 */ |
| 344 onSearchDone_: function(isRecent, status, result) { | 344 onSearchDone_: function(isRecent, status, result) { |
| 345 --this.outstandingCloudSearchRequestCount_; | 345 --this.outstandingCloudSearchRequestCount_; |
| 346 if (status == 200 && result['success']) { | 346 if (status == 200 && result['success']) { |
| 347 var printerListJson = result['printers'] || []; | 347 var printerListJson = result['printers'] || []; |
| 348 var printerList = []; | 348 var printerList = []; |
| 349 printerListJson.forEach(function(printerJson) { | 349 printerListJson.forEach(function(printerJson) { |
| 350 try { | 350 try { |
| 351 printerList.push( | 351 printerList.push( |
| 352 cloudprint.CloudDestinationParser.parse( | 352 cloudprint.CloudDestinationParser.parse( |
| 353 printerJson, print_preview.Destination.AuthType.COOKIES)); | 353 printerJson, print_preview.Destination.Origin.COOKIES)); |
| 354 } catch (err) { | 354 } catch (err) { |
| 355 console.error('Unable to parse cloud print destination: ' + err); | 355 console.error('Unable to parse cloud print destination: ' + err); |
| 356 } | 356 } |
| 357 }); | 357 }); |
| 358 var searchDoneEvent = | 358 var searchDoneEvent = |
| 359 new cr.Event(CloudPrintInterface.EventType.SEARCH_DONE); | 359 new cr.Event(CloudPrintInterface.EventType.SEARCH_DONE); |
| 360 searchDoneEvent.printers = printerList; | 360 searchDoneEvent.printers = printerList; |
| 361 searchDoneEvent.isRecent = isRecent; | 361 searchDoneEvent.isRecent = isRecent; |
| 362 searchDoneEvent.email = result['request']['user']; | 362 searchDoneEvent.email = result['request']['user']; |
| 363 this.dispatchEvent(searchDoneEvent); | 363 this.dispatchEvent(searchDoneEvent); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 393 * @param {number} status Status of the HTTP request. | 393 * @param {number} status Status of the HTTP request. |
| 394 * @param {Object} result JSON response. | 394 * @param {Object} result JSON response. |
| 395 * @private | 395 * @private |
| 396 */ | 396 */ |
| 397 onPrinterDone_: function(destinationId, status, result) { | 397 onPrinterDone_: function(destinationId, status, result) { |
| 398 if (status == 200 && result['success']) { | 398 if (status == 200 && result['success']) { |
| 399 var printerJson = result['printers'][0]; | 399 var printerJson = result['printers'][0]; |
| 400 var printer; | 400 var printer; |
| 401 try { | 401 try { |
| 402 printer = cloudprint.CloudDestinationParser.parse( | 402 printer = cloudprint.CloudDestinationParser.parse( |
| 403 printerJson, print_preview.Destination.AuthType.COOKIES); | 403 printerJson, print_preview.Destination.Origin.COOKIES); |
| 404 } catch (err) { | 404 } catch (err) { |
| 405 console.error('Failed to parse cloud print destination: ' + | 405 console.error('Failed to parse cloud print destination: ' + |
| 406 JSON.stringify(printerJson)); | 406 JSON.stringify(printerJson)); |
| 407 return; | 407 return; |
| 408 } | 408 } |
| 409 var printerDoneEvent = | 409 var printerDoneEvent = |
| 410 new cr.Event(CloudPrintInterface.EventType.PRINTER_DONE); | 410 new cr.Event(CloudPrintInterface.EventType.PRINTER_DONE); |
| 411 printerDoneEvent.printer = printer; | 411 printerDoneEvent.printer = printer; |
| 412 this.dispatchEvent(printerDoneEvent); | 412 this.dispatchEvent(printerDoneEvent); |
| 413 } else { | 413 } else { |
| 414 var errorEvent = this.createErrorEvent_( | 414 var errorEvent = this.createErrorEvent_( |
| 415 CloudPrintInterface.EventType.PRINTER_FAILED, status, result); | 415 CloudPrintInterface.EventType.PRINTER_FAILED, status, result); |
| 416 errorEvent.destinationId = destinationId; | 416 errorEvent.destinationId = destinationId; |
| 417 errorEvent.destinationOrigin = print_preview.Destination.Origin.COOKIES; |
| 417 this.dispatchEvent(errorEvent); | 418 this.dispatchEvent(errorEvent); |
| 418 } | 419 } |
| 419 }, | 420 }, |
| 420 | 421 |
| 421 /** | 422 /** |
| 422 * Called when the update printer TOS acceptance request completes. | 423 * Called when the update printer TOS acceptance request completes. |
| 423 * @param {number} status Status of the HTTP request. | 424 * @param {number} status Status of the HTTP request. |
| 424 * @param {Object} result JSON response. | 425 * @param {Object} result JSON response. |
| 425 * @private | 426 * @private |
| 426 */ | 427 */ |
| (...skipping 26 matching lines...) Expand all Loading... |
| 453 * @type {string} | 454 * @type {string} |
| 454 */ | 455 */ |
| 455 this.value = value; | 456 this.value = value; |
| 456 }; | 457 }; |
| 457 | 458 |
| 458 // Export | 459 // Export |
| 459 return { | 460 return { |
| 460 CloudPrintInterface: CloudPrintInterface | 461 CloudPrintInterface: CloudPrintInterface |
| 461 }; | 462 }; |
| 462 }); | 463 }); |
| OLD | NEW |