| 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 04ffee4529118a18fcfe7092d53e3c59cca8957e..1886ea30f27c79a9d61b781206f2b92cb3f124e0 100644
|
| --- a/chrome/browser/resources/print_preview/print_preview.js
|
| +++ b/chrome/browser/resources/print_preview/print_preview.js
|
| @@ -163,9 +163,50 @@ function onLoad() {
|
| $('printer-list').onchange = updateControlsWithSelectedPrinterCapabilities;
|
|
|
| previewArea.showLoadingAnimation();
|
| - chrome.send('getInitiatorTabTitle');
|
| - chrome.send('getDefaultPrinter');
|
| - chrome.send('getNumberFormatAndMeasurementSystem');
|
| + serializeRequests();
|
| + chrome.send('getInitialSettings');
|
| +}
|
| +
|
| +/**
|
| + * Serializes requests |getNumberFormatAndMeasurementSystem|,
|
| + * |getLastUsedMarginSettings| and |getDefaultPrinter|. It guarantees that
|
| + * responses to those requests will arrive in the order requested.
|
| + */
|
| +function serializeRequests() {
|
| + var oldSetInitialSettings = setInitialSettings;
|
| + setInitialSettings = function setInitialSettings(initiatorTabTitle,
|
| + numberFormat, measurementSystem, lastUsedMarginType,
|
| + lastUsedCustomMargins, isModifiable) {
|
| + oldSetInitialSettings(initiatorTabTitle, numberFormat, measurementSystem,
|
| + lastUsedMarginType, lastUsedCustomMargins, isModifiable);
|
| + chrome.send('getDefaultPrinter');
|
| + };
|
| +}
|
| +
|
| +/**
|
| + * @param {string} initiatorTabTitle The title of the initiator tab.
|
| + * @param {string} numberFormat Look at
|
| + * |MarginSettings.setNumberFormatAndMeasurementSystem| for documentation.
|
| + * @param {numner} measurementSystem Look at
|
| + * |MarginSettings.setNumberFormatAndMeasurementSystem| for documentation.
|
| + * @param {number} lastUsedMarginType Look at
|
| + * |MarginSettings.setLastUsedMargins| for documentation.
|
| + * @param {object} lastUsedCustomMargins Look at
|
| + * |MarginSettings.setLastUsedMargins| for documentation.
|
| + * @param {boolean} isModifiable Indicates whether the previewed document
|
| + * can be modified.
|
| + */
|
| +function setInitialSettings(initiatorTabTitle, numberFormat, measurementSystem,
|
| + lastUsedMarginType, lastUsedCustomMargins,
|
| + isModifiable) {
|
| + setInitiatorTabTitle(initiatorTabTitle);
|
| + previewModifiable = isModifiable;
|
| + if (previewModifiable) {
|
| + print_preview.MarginSettings.setNumberFormatAndMeasurementSystem(
|
| + numberFormat, measurementSystem);
|
| + marginSettings.setLastUsedMargins(lastUsedMarginType,
|
| + lastUsedCustomMargins);
|
| + }
|
| }
|
|
|
| /**
|
| @@ -283,7 +324,7 @@ function updateControlsWithSelectedPrinterCapabilities() {
|
| lastSelectedPrinterIndex = selectedIndex;
|
|
|
| // Regenerate the preview data based on selected printer settings.
|
| - setDefaultValuesAndRegeneratePreview(true);
|
| + setDefaultValuesAndRegeneratePreview(false);
|
| }
|
| }
|
|
|
| @@ -303,7 +344,7 @@ function doUpdateCloudPrinterCapabilities(printer) {
|
| lastSelectedPrinterIndex = selectedIndex;
|
|
|
| // Regenerate the preview data based on selected printer settings.
|
| - setDefaultValuesAndRegeneratePreview(true);
|
| + setDefaultValuesAndRegeneratePreview(false);
|
| }
|
|
|
| /**
|
| @@ -577,12 +618,8 @@ 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(printer_name, cloudPrintData) {
|
| // Add a placeholder value so the printer list looks valid.
|
| addDestinationListOption('', '', true, true, true);
|
| if (printer_name) {
|
| @@ -778,16 +815,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;
|
|
|
| @@ -1057,8 +1091,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) {
|
|
|