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

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

Issue 8351048: Print Preview: Making margin selection sticky (part 2/2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressing coments Created 9 years, 1 month 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/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..f552fa8f23e1ad2611c90f5ae2d7ac091a8db167 100644
--- a/chrome/browser/resources/print_preview/print_preview.js
+++ b/chrome/browser/resources/print_preview/print_preview.js
@@ -164,11 +164,30 @@ function onLoad() {
previewArea.showLoadingAnimation();
chrome.send('getInitiatorTabTitle');
- chrome.send('getDefaultPrinter');
+ serializeRequests();
chrome.send('getNumberFormatAndMeasurementSystem');
}
/**
+ * Serializes requests |getNumberFormatAndMeasurementSystem|,
+ * |getLastUsedMarginSettings| and |getDefaultPrinter|. It guarantees that
+ * responses to those requests will arrive in the order requested.
+ */
+function serializeRequests() {
+ print_preview.setNumberFormatAndMeasurementSystem =
+ function(numberFormat, measurementSystem) {
+ print_preview.MarginSettings.setNumberFormatAndMeasurementSystem(
vandebo (ex-Chrome) 2011/11/02 22:36:54 As discussed, this is brittle, save the old value
dpapad 2011/11/03 00:15:27 Done.
+ numberFormat, measurementSystem);
+ chrome.send('getLastUsedMarginSettings');
+ };
+ print_preview.setLastUsedMargins = function (
+ lastUsedMarginType, lastUsedMargins) {
+ marginSettings.setLastUsedMargins(lastUsedMarginType, lastUsedMargins);
+ chrome.send('getDefaultPrinter');
+ };
+}
+
+/**
* Disables the input elements in the sidebar.
*/
function disableInputElementsInSidebar() {
@@ -283,7 +302,7 @@ function updateControlsWithSelectedPrinterCapabilities() {
lastSelectedPrinterIndex = selectedIndex;
// Regenerate the preview data based on selected printer settings.
- setDefaultValuesAndRegeneratePreview(true);
+ setDefaultValuesAndRegeneratePreview(false);
}
}
@@ -303,7 +322,7 @@ function doUpdateCloudPrinterCapabilities(printer) {
lastSelectedPrinterIndex = selectedIndex;
// Regenerate the preview data based on selected printer settings.
- setDefaultValuesAndRegeneratePreview(true);
+ setDefaultValuesAndRegeneratePreview(false);
}
/**
@@ -577,12 +596,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) {

Powered by Google App Engine
This is Rietveld 408576698