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. |
11 var useCloudPrint = false; | 11 var useCloudPrint = false; |
12 | 12 |
13 // Store the last selected printer index. | 13 // Store the last selected printer index. |
14 var lastSelectedPrinterIndex = 0; | 14 var lastSelectedPrinterIndex = 0; |
15 | 15 |
16 // Used to disable some printing options when the preview is not modifiable. | 16 // Used to disable some printing options when the preview is not modifiable. |
17 var previewModifiable = false; | 17 var previewModifiable = false; |
18 | 18 |
| 19 // Used to identify whether the printing frame has specific page size style. |
| 20 var hasPageSizeStyle = false; |
| 21 |
19 // Destination list special value constants. | 22 // Destination list special value constants. |
20 const MANAGE_CLOUD_PRINTERS = 'manageCloudPrinters'; | 23 const MANAGE_CLOUD_PRINTERS = 'manageCloudPrinters'; |
21 const MANAGE_LOCAL_PRINTERS = 'manageLocalPrinters'; | 24 const MANAGE_LOCAL_PRINTERS = 'manageLocalPrinters'; |
22 const SIGN_IN = 'signIn'; | 25 const SIGN_IN = 'signIn'; |
23 const PRINT_TO_PDF = 'Print to PDF'; | 26 const PRINT_TO_PDF = 'Print to PDF'; |
24 const PRINT_WITH_CLOUD_PRINT = 'printWithCloudPrint'; | 27 const PRINT_WITH_CLOUD_PRINT = 'printWithCloudPrint'; |
25 | 28 |
26 // State of the print preview settings. | 29 // State of the print preview settings. |
27 var printSettings = new PrintSettings(); | 30 var printSettings = new PrintSettings(); |
28 | 31 |
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 function setPluginPreviewPageCount() { | 821 function setPluginPreviewPageCount() { |
819 $('pdf-viewer').printPreviewPageCount( | 822 $('pdf-viewer').printPreviewPageCount( |
820 pageSettings.previouslySelectedPages.length); | 823 pageSettings.previouslySelectedPages.length); |
821 } | 824 } |
822 | 825 |
823 /** | 826 /** |
824 * Update the page count and check the page range. | 827 * Update the page count and check the page range. |
825 * Called from PrintPreviewUI::OnDidGetPreviewPageCount(). | 828 * Called from PrintPreviewUI::OnDidGetPreviewPageCount(). |
826 * @param {number} pageCount The number of pages. | 829 * @param {number} pageCount The number of pages. |
827 * @param {number} previewResponseId The preview request id that resulted in | 830 * @param {number} previewResponseId The preview request id that resulted in |
828 * this response. | 831 * this response. |
829 */ | 832 */ |
830 function onDidGetPreviewPageCount(pageCount, previewResponseId) { | 833 function onDidGetPreviewPageCount(pageCount, previewResponseId) { |
831 if (!isExpectedPreviewResponse(previewResponseId)) | 834 if (!isExpectedPreviewResponse(previewResponseId)) |
832 return; | 835 return; |
833 pageSettings.updateState(pageCount); | 836 pageSettings.updateState(pageCount); |
834 if (!previewModifiable && pageSettings.requestPrintPreviewIfNeeded()) | 837 if (!previewModifiable && pageSettings.requestPrintPreviewIfNeeded()) |
835 return; | 838 return; |
836 | 839 |
837 cr.dispatchSimpleEvent(document, customEvents.UPDATE_SUMMARY); | 840 cr.dispatchSimpleEvent(document, customEvents.UPDATE_SUMMARY); |
838 } | 841 } |
839 | 842 |
840 /** | 843 /** |
841 * @param {printing::PageSizeMargins} pageLayout The default layout of the page | 844 * @param {printing::PageSizeMargins} pageLayout The default layout of the page |
842 * in points. | 845 * in points. |
| 846 * @param {boolean} hasCustomPageSizeStyle Indicates whether the previewed |
| 847 * document has a custom page size style. |
843 */ | 848 */ |
844 function onDidGetDefaultPageLayout(pageLayout) { | 849 function onDidGetDefaultPageLayout(pageLayout, hasCustomPageSizeStyle) { |
| 850 hasPageSizeStyle = hasCustomPageSizeStyle; |
845 marginSettings.currentDefaultPageLayout = new print_preview.PageLayout( | 851 marginSettings.currentDefaultPageLayout = new print_preview.PageLayout( |
846 pageLayout.contentWidth, | 852 pageLayout.contentWidth, |
847 pageLayout.contentHeight, | 853 pageLayout.contentHeight, |
848 pageLayout.marginLeft, | 854 pageLayout.marginLeft, |
849 pageLayout.marginTop, | 855 pageLayout.marginTop, |
850 pageLayout.marginRight, | 856 pageLayout.marginRight, |
851 pageLayout.marginBottom); | 857 pageLayout.marginBottom); |
852 } | 858 } |
853 | 859 |
854 /** | 860 /** |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1150 <include src="copies_settings.js"/> | 1156 <include src="copies_settings.js"/> |
1151 <include src="header_footer_settings.js"/> | 1157 <include src="header_footer_settings.js"/> |
1152 <include src="layout_settings.js"/> | 1158 <include src="layout_settings.js"/> |
1153 <include src="color_settings.js"/> | 1159 <include src="color_settings.js"/> |
1154 <include src="margin_settings.js"/> | 1160 <include src="margin_settings.js"/> |
1155 <include src="margin_textbox.js"/> | 1161 <include src="margin_textbox.js"/> |
1156 <include src="margin_utils.js"/> | 1162 <include src="margin_utils.js"/> |
1157 <include src="margins_ui.js"/> | 1163 <include src="margins_ui.js"/> |
1158 <include src="margins_ui_pair.js"/> | 1164 <include src="margins_ui_pair.js"/> |
1159 <include src="preview_area.js"/> | 1165 <include src="preview_area.js"/> |
OLD | NEW |