diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-15 08:34:45 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-15 08:34:45 +0000 |
commit | 861d3d8991717345cdf62c4ce20ae30664afad62 (patch) | |
tree | 3554033977d79de6f82018bde7ea4f7ff6e08a44 /chrome/browser/resources/print_preview | |
parent | 61c1046892028090afc10fd0e58d992e739c3b31 (diff) | |
download | chromium_src-861d3d8991717345cdf62c4ce20ae30664afad62.zip chromium_src-861d3d8991717345cdf62c4ce20ae30664afad62.tar.gz chromium_src-861d3d8991717345cdf62c4ce20ae30664afad62.tar.bz2 |
Print Preview: Make print preview tab modal.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/8136027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110056 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/resources/print_preview')
-rw-r--r-- | chrome/browser/resources/print_preview/print_header.js | 8 | ||||
-rw-r--r-- | chrome/browser/resources/print_preview/print_preview.js | 61 |
2 files changed, 30 insertions, 39 deletions
diff --git a/chrome/browser/resources/print_preview/print_header.js b/chrome/browser/resources/print_preview/print_header.js index 4e8fcaf..6443b59 100644 --- a/chrome/browser/resources/print_preview/print_header.js +++ b/chrome/browser/resources/print_preview/print_header.js @@ -53,6 +53,14 @@ cr.define('print_preview', function() { }, /** + * Enables the cancel button and attaches its keydown event listener. + */ + enableCancelButton: function() { + window.onkeydown = onKeyDown; + this.cancelButton_.disabled = false; + }, + + /** * Executes when a |customEvents.PDF_GENERATION_ERROR| event occurs. * @private */ diff --git a/chrome/browser/resources/print_preview/print_preview.js b/chrome/browser/resources/print_preview/print_preview.js index 036f549..dc7d77f 100644 --- a/chrome/browser/resources/print_preview/print_preview.js +++ b/chrome/browser/resources/print_preview/print_preview.js @@ -206,6 +206,7 @@ function onSystemDialogLinkClicked() { return; showingSystemDialog = true; disableInputElementsInSidebar(); + printHeader.disableCancelButton(); $('system-dialog-throbber').hidden = false; chrome.send('showSystemDialog'); } @@ -225,42 +226,6 @@ function launchNativePrintDialog() { } /** - * Disables the controls which need the initiator tab to generate preview - * data. This function is called when the initiator tab has crashed. - * @param {string} initiatorTabURL The URL of the initiator tab. - */ -function onInitiatorTabCrashed(initiatorTabURL) { - disableInputElementsInSidebar(); - if (initiatorTabURL) { - previewArea.displayErrorMessageWithButtonAndNotify( - localStrings.getString('initiatorTabCrashed'), - localStrings.getString('reopenPage'), - function() { chrome.send('reloadCrashedInitiatorTab'); }); - } else { - previewArea.displayErrorMessageAndNotify( - localStrings.getString('initiatorTabCrashed')); - } -} - -/** - * Disables the controls which need the initiator tab to generate preview - * data. This function is called when the initiator tab is closed. - * @param {string} initiatorTabURL The URL of the initiator tab. - */ -function onInitiatorTabClosed(initiatorTabURL) { - disableInputElementsInSidebar(); - if (initiatorTabURL) { - previewArea.displayErrorMessageWithButtonAndNotify( - localStrings.getString('initiatorTabClosed'), - localStrings.getString('reopenPage'), - function() { window.location = initiatorTabURL; }); - } else { - previewArea.displayErrorMessageAndNotify( - localStrings.getString('initiatorTabClosed')); - } -} - -/** * Gets the selected printer capabilities and updates the controls accordingly. */ function updateControlsWithSelectedPrinterCapabilities() { @@ -339,6 +304,16 @@ function updateWithPrinterCapabilities(settingInfo) { } /** + * Reloads the printer list. + */ +function reloadPrintersList() { + $('printer-list').length = 0; + firstCloudPrintOptionPos = 0; + lastCloudPrintOptionPos = 0; + chrome.send('getPrinters'); +} + +/** * Turn on the integration of Cloud Print. * @param {string} cloudPrintUrl The URL to use for cloud print servers. */ @@ -360,7 +335,7 @@ function printToCloud(data) { * Cloud print upload of the PDF file is finished, time to close the dialog. */ function finishedCloudPrinting() { - window.location = cloudprint.getBaseURL(); + closePrintPreviewTab(); } /** @@ -578,7 +553,7 @@ function requestPrintPreview() { * preview tab regarding the file selection cancel event. */ function fileSelectionCancelled() { - // TODO(thestig) re-enable controls here. + printHeader.enableCancelButton(); } /** @@ -619,7 +594,7 @@ function setDefaultPrinter(printerName, cloudPrintData) { /** * Fill the printer list drop down. - * Called from PrintPreviewHandler::SendPrinterList(). + * Called from PrintPreviewHandler::SetupPrinterList(). * @param {Array} printers Array of printer info objects. */ function setPrinters(printers) { @@ -1085,6 +1060,7 @@ function setInitiatorTabTitle(initiatorTabTitle) { */ function closePrintPreviewTab() { chrome.send('closePrintPreviewTab'); + chrome.send('DialogClose'); } /** @@ -1097,6 +1073,13 @@ function onKeyDown(e) { printHeader.disableCancelButton(); closePrintPreviewTab(); } + if (e.keyCode == 80) { + if ((cr.isMac && e.metaKey && e.altKey && !e.shiftKey && !e.ctrlKey) || + (!cr.isMac && e.shiftKey && e.ctrlKey && !e.altKey && !e.metaKey)) { + window.onkeydown = null; + onSystemDialogLinkClicked(); + } + } } window.addEventListener('DOMContentLoaded', onLoad); |