Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // require: cr/ui/print_preview_cloud.js | 5 // require: cr/ui/print_preview_cloud.js |
| 6 | 6 |
| 7 var localStrings = new LocalStrings(); | 7 var localStrings = new LocalStrings(); |
| 8 | 8 |
| 9 // If useCloudPrint is true we attempt to connect to cloud print | 9 // If useCloudPrint is true we attempt to connect to cloud print |
| 10 // and populate the list of printers with cloud print printers. | 10 // and populate the list of printers with cloud print printers. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 const maxCloudPrinters = 10; | 75 const maxCloudPrinters = 10; |
| 76 | 76 |
| 77 /** | 77 /** |
| 78 * Window onload handler, sets up the page and starts print preview by getting | 78 * Window onload handler, sets up the page and starts print preview by getting |
| 79 * the printer list. | 79 * the printer list. |
| 80 */ | 80 */ |
| 81 function onLoad() { | 81 function onLoad() { |
| 82 cr.enablePlatformSpecificCSSRules(); | 82 cr.enablePlatformSpecificCSSRules(); |
| 83 | 83 |
| 84 if (!checkCompatiblePluginExists()) { | 84 if (!checkCompatiblePluginExists()) { |
| 85 disableInputElementsInSidebar(); | |
| 86 displayErrorMessageWithButton(localStrings.getString('noPlugin'), | 85 displayErrorMessageWithButton(localStrings.getString('noPlugin'), |
| 87 localStrings.getString('launchNativeDialog'), | 86 localStrings.getString('launchNativeDialog'), |
| 88 launchNativePrintDialog); | 87 launchNativePrintDialog); |
| 89 $('mainview').parentElement.removeChild($('dummy-viewer')); | 88 $('mainview').parentElement.removeChild($('dummy-viewer')); |
| 90 return; | 89 return; |
| 91 } | 90 } |
| 92 | 91 |
| 93 $('system-dialog-link').addEventListener('click', onSystemDialogLinkClicked); | 92 $('system-dialog-link').addEventListener('click', onSystemDialogLinkClicked); |
| 94 $('mainview').parentElement.removeChild($('dummy-viewer')); | 93 $('mainview').parentElement.removeChild($('dummy-viewer')); |
| 95 | 94 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 */ | 154 */ |
| 156 function launchNativePrintDialog() { | 155 function launchNativePrintDialog() { |
| 157 showingSystemDialog = true; | 156 showingSystemDialog = true; |
| 158 $('error-button').disabled = true; | 157 $('error-button').disabled = true; |
| 159 $('native-print-dialog-throbber').classList.remove('hidden'); | 158 $('native-print-dialog-throbber').classList.remove('hidden'); |
| 160 chrome.send('showSystemDialog'); | 159 chrome.send('showSystemDialog'); |
| 161 } | 160 } |
| 162 | 161 |
| 163 /** | 162 /** |
| 164 * Disables the controls which need the initiator tab to generate preview | 163 * Disables the controls which need the initiator tab to generate preview |
| 164 * data. This function is called when the initiator tab has crashed. | |
| 165 * @param {string} initiatorTabURL The URL of the initiator tab. | |
| 166 */ | |
| 167 function onInitiatorTabCrashed(initiatorTabURL) { | |
| 168 displayErrorMessageWithButton( | |
| 169 localStrings.getString('initiatorTabCrashed'), | |
| 170 localStrings.getString('reopenPage'), | |
| 171 function() { chrome.send('reloadCrashedInitiatorTab') }); | |
|
dpapad
2011/08/08 22:01:58
Nit: add a semicolon after chrome.send('reloadCras
kmadhusu
2011/08/10 16:46:59
Done.
| |
| 172 } | |
| 173 | |
| 174 /** | |
| 175 * Disables the controls which need the initiator tab to generate preview | |
| 165 * data. This function is called when the initiator tab is closed. | 176 * data. This function is called when the initiator tab is closed. |
| 166 * @param {string} initiatorTabURL The URL of the initiator tab. | 177 * @param {string} initiatorTabURL The URL of the initiator tab. |
| 167 */ | 178 */ |
| 168 function onInitiatorTabClosed(initiatorTabURL) { | 179 function onInitiatorTabClosed(initiatorTabURL) { |
| 169 disableInputElementsInSidebar(); | |
| 170 displayErrorMessageWithButton( | 180 displayErrorMessageWithButton( |
| 171 localStrings.getString('initiatorTabClosed'), | 181 localStrings.getString('initiatorTabClosed'), |
| 172 localStrings.getString('reopenPage'), | 182 localStrings.getString('reopenPage'), |
| 173 function() { window.location = initiatorTabURL; }); | 183 function() { window.location = initiatorTabURL; }); |
| 174 } | 184 } |
| 175 | 185 |
| 176 /** | 186 /** |
| 177 * Gets the selected printer capabilities and updates the controls accordingly. | 187 * Gets the selected printer capabilities and updates the controls accordingly. |
| 178 */ | 188 */ |
| 179 function updateControlsWithSelectedPrinterCapabilities() { | 189 function updateControlsWithSelectedPrinterCapabilities() { |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 743 /** | 753 /** |
| 744 * Display an error message in the center of the preview area followed by a | 754 * Display an error message in the center of the preview area followed by a |
| 745 * button. | 755 * button. |
| 746 * @param {string} errorMessage The error message to be displayed. | 756 * @param {string} errorMessage The error message to be displayed. |
| 747 * @param {string} buttonText The text to be displayed within the button. | 757 * @param {string} buttonText The text to be displayed within the button. |
| 748 * @param {string} buttonListener The listener to be executed when the button is | 758 * @param {string} buttonListener The listener to be executed when the button is |
| 749 * clicked. | 759 * clicked. |
| 750 */ | 760 */ |
| 751 function displayErrorMessageWithButton( | 761 function displayErrorMessageWithButton( |
| 752 errorMessage, buttonText, buttonListener) { | 762 errorMessage, buttonText, buttonListener) { |
| 763 disableInputElementsInSidebar(); | |
| 764 | |
| 753 var errorButton = $('error-button'); | 765 var errorButton = $('error-button'); |
| 754 errorButton.disabled = false; | 766 errorButton.disabled = false; |
| 755 errorButton.textContent = buttonText; | 767 errorButton.textContent = buttonText; |
| 756 errorButton.onclick = buttonListener; | 768 errorButton.onclick = buttonListener; |
| 757 errorButton.classList.remove('hidden'); | 769 errorButton.classList.remove('hidden'); |
| 758 $('system-dialog-throbber').classList.add('hidden'); | 770 $('system-dialog-throbber').classList.add('hidden'); |
| 759 $('native-print-dialog-throbber').classList.add('hidden'); | 771 $('native-print-dialog-throbber').classList.add('hidden'); |
| 760 displayErrorMessage(errorMessage); | 772 displayErrorMessage(errorMessage); |
| 761 } | 773 } |
| 762 | 774 |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 959 } | 971 } |
| 960 | 972 |
| 961 /** | 973 /** |
| 962 * Takes a snapshot of the print settings. | 974 * Takes a snapshot of the print settings. |
| 963 */ | 975 */ |
| 964 PrintSettings.prototype.save = function() { | 976 PrintSettings.prototype.save = function() { |
| 965 this.deviceName = getSelectedPrinterName(); | 977 this.deviceName = getSelectedPrinterName(); |
| 966 this.isLandscape = layoutSettings.isLandscape(); | 978 this.isLandscape = layoutSettings.isLandscape(); |
| 967 } | 979 } |
| 968 | 980 |
| OLD | NEW |