Index: chrome/browser/resources/print_preview.js |
diff --git a/chrome/browser/resources/print_preview.js b/chrome/browser/resources/print_preview.js |
index b281892b2c25406be57646c2d00fbda4fdba4bcc..e76d58dec8e90e33c7b8a655e21d7f19a2a7d5af 100644 |
--- a/chrome/browser/resources/print_preview.js |
+++ b/chrome/browser/resources/print_preview.js |
@@ -26,6 +26,9 @@ var previouslySelectedLayout = null; |
// needed. |
var timerId; |
+// Store the last selected printer index. |
+var lastSelectedPrinterIndex = 0; |
+ |
/** |
* Window onload handler, sets up the page and starts print preview by getting |
* the printer list. |
@@ -96,11 +99,18 @@ function updateControlsWithSelectedPrinterCapabilities() { |
if (printerName == localStrings.getString('printToPDF')) { |
updateWithPrinterCapabilities({'disableColorOption': true, |
'setColorAsDefault': true}); |
+ } else if (printerName == localStrings.getString('managePrinters')) { |
+ printerList.selectedIndex = lastSelectedPrinterIndex; |
+ chrome.send('managePrinters'); |
+ return; |
} else { |
// This message will call back to 'updateWithPrinterCapabilities' |
// function. |
chrome.send('getPrinterCapabilities', [printerName]); |
} |
+ |
+ if (lastSelectedPrinterIndex != selectedPrinter) |
Lei Zhang
2011/04/27 23:46:36
no need for this if statement.
kmadhusu
2011/04/28 00:08:26
Done.
|
+ lastSelectedPrinterIndex = selectedPrinter; |
} |
/** |
@@ -328,18 +338,14 @@ function requestPrintPreview() { |
*/ |
function setPrinters(printers, defaultPrinterIndex) { |
var printerList = $('printer-list'); |
- for (var i = 0; i < printers.length; ++i) { |
- var option = document.createElement('option'); |
- option.textContent = printers[i]; |
- printerList.add(option); |
- if (i == defaultPrinterIndex) |
- option.selected = true; |
- } |
+ for (var i = 0; i < printers.length; ++i) |
+ addDestinationListOption(printers[i], i == defaultPrinterIndex); |
// Adding option for saving PDF to disk. |
- var option = document.createElement('option'); |
- option.textContent = localStrings.getString('printToPDF'); |
- printerList.add(option); |
+ addDestinationListOption(localStrings.getString('printToPDF'), false); |
+ |
+ // Add an option to manage printers. |
+ addDestinationListOption(localStrings.getString('managePrinters'), false); |
Lei Zhang
2011/04/27 23:46:36
nit: can you keep the new line after this?
kmadhusu
2011/04/28 00:08:26
Done.
|
printerList.disabled = false; |
updateControlsWithSelectedPrinterCapabilities(); |
@@ -349,6 +355,19 @@ function setPrinters(printers, defaultPrinterIndex) { |
} |
/** |
+ * Adds an option to the destination list. |
Lei Zhang
2011/04/27 23:46:36
nit: the printer destination list.
kmadhusu
2011/04/28 00:08:26
Done.
|
+ * @param {String} optionText specifies the option text content. |
+ * @param {boolean} is_default is true if the option needs to be selected. |
+ */ |
+function addDestinationListOption(optionText, is_default) { |
+ var option = document.createElement('option'); |
+ option.textContent = optionText; |
+ $('printer-list').add(option); |
+ if (is_default) |
+ option.selected = true; |
+} |
+ |
+/** |
* Sets the color mode for the PDF plugin. |
* Called from PrintPreviewHandler::ProcessColorSetting(). |
* @param {boolean} color is true if the PDF plugin should display in color. |