OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 6 |
7 // The URL to use to access the cloud print servers. | 7 // The URL to use to access the cloud print servers. |
8 // Set by a call to setBaseURL. | 8 // Set by a call to setBaseURL. |
9 var cloudPrintBaseURL = ''; | 9 var cloudPrintBaseURL = ''; |
10 | 10 |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 for (var i = 0; i < printers.length; i++) { | 399 for (var i = 0; i < printers.length; i++) { |
400 if (!cloudPrinterAlreadyAdded(printers[i]['id'])) { | 400 if (!cloudPrinterAlreadyAdded(printers[i]['id'])) { |
401 if (!trackCloudPrinterAdded(printers[i]['id'])) { | 401 if (!trackCloudPrinterAdded(printers[i]['id'])) { |
402 break; | 402 break; |
403 } | 403 } |
404 var option = addDestinationListOptionAtPosition( | 404 var option = addDestinationListOptionAtPosition( |
405 lastCloudPrintOptionPos++, | 405 lastCloudPrintOptionPos++, |
406 printers[i]['name'], | 406 printers[i]['name'], |
407 printers[i]['id'], | 407 printers[i]['id'], |
408 printers[i]['name'] == defaultOrLastUsedPrinterName, | 408 printers[i]['name'] == defaultOrLastUsedPrinterName, |
409 false, | |
410 false); | 409 false); |
411 cloudprint.setCloudPrint(option, | 410 cloudprint.setCloudPrint(option, |
412 printers[i]['name'], | 411 printers[i]['name'], |
413 printers[i]['id']); | 412 printers[i]['id']); |
414 } | 413 } |
415 } | 414 } |
416 } else { | 415 } else { |
417 if (!cloudPrinterAlreadyAdded(SIGN_IN)) { | 416 if (!cloudPrinterAlreadyAdded(SIGN_IN)) { |
418 addDestinationListOptionAtPosition(lastCloudPrintOptionPos++, | 417 addDestinationListOptionAtPosition(lastCloudPrintOptionPos++, |
419 localStrings.getString('signIn'), | 418 localStrings.getString('signIn'), |
420 SIGN_IN, | 419 SIGN_IN, |
421 false, | 420 false, |
422 false, | |
423 false); | 421 false); |
424 trackCloudPrinterAdded(SIGN_IN); | 422 trackCloudPrinterAdded(SIGN_IN); |
425 chrome.send('signIn'); | 423 chrome.send('signIn'); |
426 } | 424 } |
427 } | 425 } |
428 var selectedPrinter = printerList.selectedIndex; | 426 var selectedPrinter = printerList.selectedIndex; |
429 if (selectedPrinter < 0) | 427 if (selectedPrinter < 0) |
430 return null; | 428 return null; |
431 return printerList.options[selectedPrinter]; | 429 return printerList.options[selectedPrinter]; |
432 } | 430 } |
433 | 431 |
434 return { | 432 return { |
435 addCloudPrinters: addCloudPrinters, | 433 addCloudPrinters: addCloudPrinters, |
436 colorIsDefault: colorIsDefault, | 434 colorIsDefault: colorIsDefault, |
437 fetchPrinters: fetchPrinters, | 435 fetchPrinters: fetchPrinters, |
438 getBaseURL: getBaseURL, | 436 getBaseURL: getBaseURL, |
439 getData: getData, | 437 getData: getData, |
440 getPrintTicketJSON: getPrintTicketJSON, | 438 getPrintTicketJSON: getPrintTicketJSON, |
441 isCloudPrint: isCloudPrint, | 439 isCloudPrint: isCloudPrint, |
442 printToCloud: printToCloud, | 440 printToCloud: printToCloud, |
443 setBaseURL: setBaseURL, | 441 setBaseURL: setBaseURL, |
444 setCloudPrint: setCloudPrint, | 442 setCloudPrint: setCloudPrint, |
445 setColor: setColor, | 443 setColor: setColor, |
446 setDefaultPrinter: setDefaultPrinter, | 444 setDefaultPrinter: setDefaultPrinter, |
447 supportsColor: supportsColor, | 445 supportsColor: supportsColor, |
448 updatePrinterCaps: updatePrinterCaps | 446 updatePrinterCaps: updatePrinterCaps |
449 }; | 447 }; |
450 }); | 448 }); |
OLD | NEW |