Chromium Code Reviews| Index: chrome/browser/resources/print_preview/print_preview.js |
| diff --git a/chrome/browser/resources/print_preview/print_preview.js b/chrome/browser/resources/print_preview/print_preview.js |
| index 24919446d36ecbfa7522528dabf4aec3361e3cbe..f9ea6092e062915dc1edb6dcc0e2b43fa92e3875 100644 |
| --- a/chrome/browser/resources/print_preview/print_preview.js |
| +++ b/chrome/browser/resources/print_preview/print_preview.js |
| @@ -164,9 +164,26 @@ function onLoad() { |
| $('printer-list').onchange = updateControlsWithSelectedPrinterCapabilities; |
| previewArea.showLoadingAnimation(); |
| - chrome.send('getInitiatorTabTitle'); |
| - chrome.send('getDefaultPrinter'); |
| - chrome.send('getNumberFormatAndMeasurementSystem'); |
| + chrome.send('getInitialSettings'); |
| +} |
| + |
| +/** |
| + * @param {string} initiatorTabTitle The title of the initiator tab. |
| + * @param {object} initialSettings An object containing all the initial |
| + * settings. |
| + */ |
| +function setInitialSettings(initialSettings) { |
| + console.log(initialSettings); |
|
kmadhusu
2011/11/10 18:39:56
nit: remove console.log
dpapad
2011/11/10 20:04:01
Done.
|
| + setInitiatorTabTitle(initialSettings['initiatorTabTitle']); |
| + previewModifiable = initialSettings['previewModifiable']; |
| + if (previewModifiable) { |
| + print_preview.MarginSettings.setNumberFormatAndMeasurementSystem( |
| + initialSettings['numberFormat'], |
| + initialSettings['measurementSystem']); |
| + marginSettings.setLastUsedMargins(initialSettings); |
| + } |
| + setDefaultPrinter(initialSettings['printerName'], |
| + initialSettings['cloudPrintData']); |
| } |
| /** |
| @@ -578,18 +595,14 @@ function fileSelectionCompleted() { |
| * @param {string} printer Name of the default printer. Empty if none. |
| * @param {string} cloudPrintData Cloud print related data to restore if |
| * the default printer is a cloud printer. |
| - * @param {number} lastUsedMarginsType Indicates the last used margins type |
| - * (matches enum MarginType in printing/print_job_constants.h. |
| */ |
| -function setDefaultPrinter(printer_name, cloudPrintData, lastUsedMarginsType) { |
| - // Setting the margin selection to the last used one. |
| - marginSettings.setLastUsedMarginsType(lastUsedMarginsType); |
| +function setDefaultPrinter(printerName, cloudPrintData) { |
| // Add a placeholder value so the printer list looks valid. |
| addDestinationListOption('', '', true, true, true); |
| - if (printer_name) { |
| - defaultOrLastUsedPrinterName = printer_name; |
| + if (printerName) { |
| + defaultOrLastUsedPrinterName = printerName; |
| if (cloudPrintData) { |
| - cloudprint.setDefaultPrinter(printer_name, |
| + cloudprint.setDefaultPrinter(printerName, |
| cloudPrintData, |
| addDestinationListOptionAtPosition, |
| doUpdateCloudPrinterCapabilities); |
| @@ -779,16 +792,13 @@ function setPluginPreviewPageCount() { |
| * Update the page count and check the page range. |
| * Called from PrintPreviewUI::OnDidGetPreviewPageCount(). |
| * @param {number} pageCount The number of pages. |
| - * @param {boolean} isModifiable Indicates whether the previewed document can be |
| - * modified. |
| * @param {number} previewResponseId The preview request id that resulted in |
| * this response. |
| */ |
| -function onDidGetPreviewPageCount(pageCount, isModifiable, previewResponseId) { |
| +function onDidGetPreviewPageCount(pageCount, previewResponseId) { |
| if (!isExpectedPreviewResponse(previewResponseId)) |
| return; |
| pageSettings.updateState(pageCount); |
| - previewModifiable = isModifiable; |
| if (!previewModifiable && pageSettings.requestPrintPreviewIfNeeded()) |
| return; |
| @@ -1058,8 +1068,6 @@ PrintSettings.prototype.save = function() { |
| /** |
| * Updates the title of the print preview tab according to |initiatorTabTitle|. |
| - * Called from PrintPreviewUI::OnGetInitiatorTabTitle as a result of sending a |
| - * 'getInitiatorTabTitle' message. |
| * @param {string} initiatorTabTitle The title of the initiator tab. |
| */ |
| function setInitiatorTabTitle(initiatorTabTitle) { |