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

Unified Diff: chrome/browser/resources/print_preview.js

Issue 7064006: Print Preview: Fixing printer list when no printer is installed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Localizing strings Created 9 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/print_preview.css ('k') | chrome/browser/ui/webui/print_preview_ui_html_source.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/print_preview.js
diff --git a/chrome/browser/resources/print_preview.js b/chrome/browser/resources/print_preview.js
index 9bc3731f709260e2d504da5ab2f1cc35a6328143..ce5bd1cc40b21b3ee20b6864c306cb92a904b1c9 100644
--- a/chrome/browser/resources/print_preview.js
+++ b/chrome/browser/resources/print_preview.js
@@ -290,12 +290,8 @@ function getDuplexMode() {
* @return {string} JSON string with print job settings.
*/
function getSettingsJSON() {
- var printerList = $('printer-list')
- var selectedPrinter = printerList.selectedIndex;
- var deviceName = '';
- if (selectedPrinter >= 0)
- deviceName = printerList.options[selectedPrinter].value;
var printAll = $('all-pages').checked;
+ var deviceName = getSelectedPrinterName();
var printToPDF = (deviceName == PRINT_TO_PDF);
return JSON.stringify({'deviceName': deviceName,
@@ -310,10 +306,33 @@ function getSettingsJSON() {
}
/**
+ * Returns the name of the selected printer or the empty string if no
+ * printer is selected.
+ */
+function getSelectedPrinterName() {
+ var printerList = $('printer-list')
+ var selectedPrinter = printerList.selectedIndex;
+ var deviceName = '';
+ if (selectedPrinter >= 0)
+ deviceName = printerList.options[selectedPrinter].value;
+ return deviceName;
+}
+
+/**
* Asks the browser to print the preview PDF based on current print settings.
*/
function printFile() {
- chrome.send('print', [getSettingsJSON()]);
+ var printButton = $('print-button');
Lei Zhang 2011/05/24 00:58:29 nit: you don't need |printButton| and |cancelButto
dpapad 2011/05/24 01:10:05 Done.
+ var cancelButton = $('cancel-button');
+ printButton.classList.add('loading');
+ $('print-summary').innerHTML = localStrings.getString('printing');
Lei Zhang 2011/05/24 00:58:29 nit: can you put this one line down?
dpapad 2011/05/24 01:10:05 Done.
+ cancelButton.classList.add('loading');
dpapad 2011/05/24 00:23:57 I will remove all the event listeners here to be s
+
+ if (getSelectedPrinterName() != PRINT_TO_PDF)
Lei Zhang 2011/05/24 00:58:29 nit: { } around multi line if blocks.
dpapad 2011/05/24 01:10:05 Done.
+ window.setTimeout(function() { chrome.send('print', [getSettingsJSON()]); },
+ 1000);
+ else
+ chrome.send('print', [getSettingsJSON()]);
}
/**
@@ -338,12 +357,14 @@ function setPrinters(printers, defaultPrinterIndex) {
addDestinationListOption(printers[i].printerName, printers[i].deviceName,
i == defaultPrinterIndex, false);
}
- addDestinationListOption('','',false, true);
+
+ if (printers.length != 0)
+ addDestinationListOption('','', false, true);
Lei Zhang 2011/05/24 00:58:29 nit: still need a space after the first comma.
dpapad 2011/05/24 01:10:05 Done.
// Adding option for saving PDF to disk.
addDestinationListOption(localStrings.getString('printToPDF'),
PRINT_TO_PDF, false, false);
- addDestinationListOption('','',false, true);
+ addDestinationListOption('','', false, true);
// Add an option to manage printers.
addDestinationListOption(localStrings.getString('managePrinters'),
« no previous file with comments | « chrome/browser/resources/print_preview.css ('k') | chrome/browser/ui/webui/print_preview_ui_html_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698