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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 /** | 112 /** |
113 * Parse the response from the fetchPrinters call. | 113 * Parse the response from the fetchPrinters call. |
114 * @param {function} callback Function to be called to process response. | 114 * @param {function} callback Function to be called to process response. |
115 * @param {XMLHttpRequest} xhr The object used to make the request. | 115 * @param {XMLHttpRequest} xhr The object used to make the request. |
116 */ | 116 */ |
117 function fetchPrintersResponse(callback, xhr) { | 117 function fetchPrintersResponse(callback, xhr) { |
118 if (xhr.status == 200) { | 118 if (xhr.status == 200) { |
119 var searchResult = JSON.parse(xhr.responseText); | 119 var searchResult = JSON.parse(xhr.responseText); |
120 if (searchResult['success']) { | 120 if (searchResult['success']) { |
121 var printerList = searchResult['printers']; | 121 var printerList = searchResult['printers']; |
122 callback.call(this, printerList, false); | 122 callback.call(this, printerList); |
123 } else { | 123 } else { |
124 callback.call(this, null, false); | 124 callback.call(this, null); |
125 } | 125 } |
126 } else { | 126 } else { |
127 callback.call(this, null, false); | 127 callback.call(this, null); |
128 } | 128 } |
129 } | 129 } |
130 | 130 |
131 /** | 131 /** |
132 * Retrieve the list of printers available via cloud print. | 132 * Retrieve the list of printers available via cloud print. |
133 * @param {function} callback Function to be called to process response. | 133 * @param {function} callback Function to be called to process response. |
dpapad
2011/07/19 18:44:55
Document parameter |all|.
| |
134 */ | 134 */ |
135 function fetchPrinters(callback, all) { | 135 function fetchPrinters(callback, all) { |
136 var query = 'q=^recent'; | 136 var query = 'q=^recent'; |
137 if (all) { | 137 if (all) { |
138 query = ''; | 138 query = ''; |
139 } | 139 } |
140 sendCloudPrintRequest('GET', | 140 sendCloudPrintRequest('GET', |
141 'search', | 141 'search', |
142 xCloudPrintURLHeader, | 142 xCloudPrintURLHeader, |
143 [query], | 143 [query], |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
298 * @param {Object} cloud_print_data Data to be stored in cloudPrintOptions. | 298 * @param {Object} cloud_print_data Data to be stored in cloudPrintOptions. |
299 * @param {function} add_callback The callback to be called to add the new | 299 * @param {function} add_callback The callback to be called to add the new |
300 * printer to the print preview UI. | 300 * printer to the print preview UI. |
301 * @param {function} update_caps_callback The callback to be called to update | 301 * @param {function} update_caps_callback The callback to be called to update |
302 * capabilities on the new printer. | 302 * capabilities on the new printer. |
303 */ | 303 */ |
304 function setDefaultPrinter(printer_name, | 304 function setDefaultPrinter(printer_name, |
305 cloud_print_data, | 305 cloud_print_data, |
306 add_callback, | 306 add_callback, |
307 update_caps_callback) { | 307 update_caps_callback) { |
308 var printer = add_callback([JSON.parse(cloud_print_data)], false); | 308 var printer = add_callback([JSON.parse(cloud_print_data)]); |
309 if (printer) | 309 if (printer) |
310 update_caps_callback(printer); | 310 update_caps_callback(printer); |
311 } | 311 } |
312 | 312 |
313 /** Returns the data necessary to serialize a cloud print printer. | 313 /** Returns the data necessary to serialize a cloud print printer. |
314 * @param {Object} printer The printer object to get data for. | 314 * @param {Object} printer The printer object to get data for. |
315 * @return {string} A JSON string that can be used to recreate the | 315 * @return {string} A JSON string that can be used to recreate the |
316 * cloud print portion of the printer object, or | 316 * cloud print portion of the printer object, or |
317 * an empty string if there is no data to save. | 317 * an empty string if there is no data to save. |
318 */ | 318 */ |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
355 isCloudPrint: isCloudPrint, | 355 isCloudPrint: isCloudPrint, |
356 printToCloud: printToCloud, | 356 printToCloud: printToCloud, |
357 setBaseURL: setBaseURL, | 357 setBaseURL: setBaseURL, |
358 setCloudPrint: setCloudPrint, | 358 setCloudPrint: setCloudPrint, |
359 setColor: setColor, | 359 setColor: setColor, |
360 setDefaultPrinter: setDefaultPrinter, | 360 setDefaultPrinter: setDefaultPrinter, |
361 supportsColor: supportsColor, | 361 supportsColor: supportsColor, |
362 updatePrinterCaps: updatePrinterCaps | 362 updatePrinterCaps: updatePrinterCaps |
363 }; | 363 }; |
364 }); | 364 }); |
OLD | NEW |