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

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

Issue 6903083: PrintPreview:[MAC & WIN] Added code to show the native printer management dialog. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Addressed review comments Created 9 years, 8 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
Index: chrome/browser/resources/print_preview.js
diff --git a/chrome/browser/resources/print_preview.js b/chrome/browser/resources/print_preview.js
index 24fbd978392a8e10ec4974a404db010d97b6dc0e..23d98b2d12eb2d0b49da38a1ba98b266928a9623 100644
--- a/chrome/browser/resources/print_preview.js
+++ b/chrome/browser/resources/print_preview.js
@@ -32,6 +32,9 @@ var isPreviewStillLoading = false;
// Currently selected printer capabilities.
var printerCapabilities;
+// 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.
@@ -102,11 +105,17 @@ 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]);
}
+
+ lastSelectedPrinterIndex = selectedPrinter;
}
/**
@@ -336,18 +345,15 @@ 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);
+
printerList.disabled = false;
updateControlsWithSelectedPrinterCapabilities();
@@ -357,6 +363,19 @@ function setPrinters(printers, defaultPrinterIndex) {
}
/**
+ * Adds an option to the printer destination list.
+ * @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.
« no previous file with comments | « chrome/browser/printing/printer_manager_dialog_win.cc ('k') | chrome/browser/ui/webui/print_preview_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698