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

Side by Side Diff: chrome/browser/resources/print_preview/print_preview.js

Issue 588713002: Compile print_preview, part 3: reduce down to 185 errors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@I_print_preview_2
Patch Set: revert movement of enums: now handle in compiler pass Created 6 years, 2 months 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // TODO(rltoscano): Move data/* into print_preview.data namespace 5 // TODO(rltoscano): Move data/* into print_preview.data namespace
6 6
7 <include src="component.js"> 7 <include src="component.js">
8 <include src="print_preview_focus_manager.js"> 8 <include src="print_preview_focus_manager.js">
9 9
10 cr.define('print_preview', function() { 10 cr.define('print_preview', function() {
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 var devicesUrl = 'chrome://devices/register?id=' + e.destination.id; 850 var devicesUrl = 'chrome://devices/register?id=' + e.destination.id;
851 this.nativeLayer_.startForceOpenNewTab(devicesUrl); 851 this.nativeLayer_.startForceOpenNewTab(devicesUrl);
852 this.destinationStore_.waitForRegister(e.destination.id); 852 this.destinationStore_.waitForRegister(e.destination.id);
853 }, 853 },
854 854
855 /** 855 /**
856 * Consume escape key presses and ctrl + shift + p. Delegate everything else 856 * Consume escape key presses and ctrl + shift + p. Delegate everything else
857 * to the preview area. 857 * to the preview area.
858 * @param {KeyboardEvent} e The keyboard event. 858 * @param {KeyboardEvent} e The keyboard event.
859 * @private 859 * @private
860 * @suppress {uselessCode}
861 * Current compiler preprocessor leaves all the code inside all the <if>s,
862 * so the compiler claims that code after first return is unreachable.
860 */ 863 */
861 onKeyDown_: function(e) { 864 onKeyDown_: function(e) {
862 // Escape key closes the dialog. 865 // Escape key closes the dialog.
863 if (e.keyCode == 27 && !e.shiftKey && !e.ctrlKey && !e.altKey && 866 if (e.keyCode == 27 && !e.shiftKey && !e.ctrlKey && !e.altKey &&
864 !e.metaKey) { 867 !e.metaKey) {
865 <if expr="toolkit_views"> 868 <if expr="toolkit_views">
Dan Beam 2014/09/29 18:42:00 arguably these <if>s should be 0-indented, e.g. <
Vitaly Pavlenko 2014/10/01 00:33:37 Done.
866 // On the toolkit_views environment, ESC key is handled by C++-side 869 // On the toolkit_views environment, ESC key is handled by C++-side
867 // instead of JS-side. 870 // instead of JS-side.
868 return; 871 return;
869 </if> 872 </if>
870 <if expr="not toolkit_views"> 873 <if expr="not toolkit_views">
871 this.close_(); 874 this.close_();
872 </if> 875 </if>
873 e.preventDefault(); 876 e.preventDefault();
874 return; 877 return;
875 } 878 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 this.destinationSearch_.setIsVisible(true); 933 this.destinationSearch_.setIsVisible(true);
931 }, 934 },
932 935
933 /** 936 /**
934 * Called when the destination settings' change button is activated. 937 * Called when the destination settings' change button is activated.
935 * Displays the destination search component. 938 * Displays the destination search component.
936 * @private 939 * @private
937 */ 940 */
938 onAdvancedOptionsButtonActivated_: function() { 941 onAdvancedOptionsButtonActivated_: function() {
939 this.advancedSettings_.showForDestination( 942 this.advancedSettings_.showForDestination(
940 this.destinationStore_.selectedDestination); 943 assert(this.destinationStore_.selectedDestination));
941 }, 944 },
942 945
943 /** 946 /**
944 * Called when the destination search dispatches manage cloud destinations 947 * Called when the destination search dispatches manage cloud destinations
945 * event. Calls corresponding native layer method. 948 * event. Calls corresponding native layer method.
946 * @private 949 * @private
947 */ 950 */
948 onManageCloudDestinationsActivated_: function() { 951 onManageCloudDestinationsActivated_: function() {
949 this.nativeLayer_.startManageCloudDestinations(); 952 this.nativeLayer_.startManageCloudDestinations();
950 }, 953 },
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 loadTimeData.getString('couldNotPrint')); 994 loadTimeData.getString('couldNotPrint'));
992 }, 995 },
993 996
994 /** 997 /**
995 * Called when the print preview settings need to be changed for testing. 998 * Called when the print preview settings need to be changed for testing.
996 * @param {Event} event Event object that contains the option that is to 999 * @param {Event} event Event object that contains the option that is to
997 * be changed and what to set that option. 1000 * be changed and what to set that option.
998 * @private 1001 * @private
999 */ 1002 */
1000 onManipulateSettingsForTest_: function(event) { 1003 onManipulateSettingsForTest_: function(event) {
1004 event.settings =
Dan Beam 2014/09/29 18:42:00 nit: var settings (try not to re-assign to argumen
Vitaly Pavlenko 2014/10/01 00:33:37 Done.
1005 /** @type {print_preview.PreviewSettings} */(event.settings);
1001 if ('selectSaveAsPdfDestination' in event.settings) { 1006 if ('selectSaveAsPdfDestination' in event.settings) {
1002 this.saveAsPdfForTest_(); // No parameters. 1007 this.saveAsPdfForTest_(); // No parameters.
1003 } else if ('layoutSettings' in event.settings) { 1008 } else if ('layoutSettings' in event.settings) {
1004 this.setLayoutSettingsForTest_(event.settings.layoutSettings.portrait); 1009 this.setLayoutSettingsForTest_(event.settings.layoutSettings.portrait);
1005 } else if ('pageRange' in event.settings) { 1010 } else if ('pageRange' in event.settings) {
1006 this.setPageRangeForTest_(event.settings.pageRange); 1011 this.setPageRangeForTest_(event.settings.pageRange);
1007 } else if ('headersAndFooters' in event.settings) { 1012 } else if ('headersAndFooters' in event.settings) {
1008 this.setHeadersAndFootersForTest_(event.settings.headersAndFooters); 1013 this.setHeadersAndFootersForTest_(event.settings.headersAndFooters);
1009 } else if ('backgroundColorsAndImages' in event.settings) { 1014 } else if ('backgroundColorsAndImages' in event.settings) {
1010 this.setBackgroundColorsAndImagesForTest_( 1015 this.setBackgroundColorsAndImagesForTest_(
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1130 * Returns true if "Print using system dialog" link should be shown for 1135 * Returns true if "Print using system dialog" link should be shown for
1131 * current destination. 1136 * current destination.
1132 * @return {boolean} Returns true if link should be shown. 1137 * @return {boolean} Returns true if link should be shown.
1133 */ 1138 */
1134 shouldShowSystemDialogLink_: function() { 1139 shouldShowSystemDialogLink_: function() {
1135 if (!this.isSystemDialogAvailable_) 1140 if (!this.isSystemDialogAvailable_)
1136 return false; 1141 return false;
1137 if (!cr.isWindows) 1142 if (!cr.isWindows)
1138 return true; 1143 return true;
1139 var selectedDest = this.destinationStore_.selectedDestination; 1144 var selectedDest = this.destinationStore_.selectedDestination;
1140 return selectedDest && 1145 return !!selectedDest &&
1141 selectedDest.origin == print_preview.Destination.Origin.LOCAL && 1146 selectedDest.origin == print_preview.Destination.Origin.LOCAL &&
1142 selectedDest.id != 1147 selectedDest.id !=
1143 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF; 1148 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF;
1144 }, 1149 },
1145 1150
1146 /** 1151 /**
1147 * Called when the open-cloud-print-dialog link is clicked. Opens the Google 1152 * Called when the open-cloud-print-dialog link is clicked. Opens the Google
1148 * Cloud Print web dialog. 1153 * Cloud Print web dialog.
1149 * @private 1154 * @private
1150 */ 1155 */
1151 onCloudPrintDialogLinkClick_: function() { 1156 onCloudPrintDialogLinkClick_: function() {
1152 assert(this.uiState_ == PrintPreview.UiState_.READY, 1157 assert(this.uiState_ == PrintPreview.UiState_.READY,
1153 'Opening Google Cloud Print dialog when not in ready state: ' + 1158 'Opening Google Cloud Print dialog when not in ready state: ' +
1154 this.uiState_); 1159 this.uiState_);
1155 setIsVisible(getRequiredElement('cloud-print-dialog-throbber'), true); 1160 setIsVisible(getRequiredElement('cloud-print-dialog-throbber'), true);
1156 this.setIsEnabled_(false); 1161 this.setIsEnabled_(false);
1157 this.uiState_ = PrintPreview.UiState_.OPENING_CLOUD_PRINT_DIALOG; 1162 this.uiState_ = PrintPreview.UiState_.OPENING_CLOUD_PRINT_DIALOG;
1158 this.printIfReady_(); 1163 this.printIfReady_();
1159 }, 1164 },
1160 1165
1161 /** 1166 /**
1162 * Called when a print destination is selected. Shows/hides the "Print with 1167 * Called when a print destination is selected. Shows/hides the "Print with
1163 * Cloud Print" link in the navbar. 1168 * Cloud Print" link in the navbar.
1164 * @private 1169 * @private
1165 */ 1170 */
1166 onDestinationSelect_: function() { 1171 onDestinationSelect_: function() {
1167 var selectedDest = this.destinationStore_.selectedDestination; 1172 var selectedDest = this.destinationStore_.selectedDestination;
1168 setIsVisible( 1173 setIsVisible(
1169 getRequiredElement('cloud-print-dialog-link'), 1174 getRequiredElement('cloud-print-dialog-link'),
1170 selectedDest && !cr.isChromeOS && !selectedDest.isLocal); 1175 !!selectedDest && !cr.isChromeOS && !selectedDest.isLocal);
1171 setIsVisible( 1176 setIsVisible(
1172 getRequiredElement('system-dialog-link'), 1177 getRequiredElement('system-dialog-link'),
1173 this.shouldShowSystemDialogLink_()); 1178 this.shouldShowSystemDialogLink_());
1174 if (selectedDest && this.isInKioskAutoPrintMode_) { 1179 if (selectedDest && this.isInKioskAutoPrintMode_) {
1175 this.onPrintButtonClick_(); 1180 this.onPrintButtonClick_();
1176 } 1181 }
1177 }, 1182 },
1178 1183
1179 /** 1184 /**
1180 * Called when the destination store loads a group of destinations. Shows 1185 * Called when the destination store loads a group of destinations. Shows
1181 * a promo on Chrome OS if the user has no print destinations promoting 1186 * a promo on Chrome OS if the user has no print destinations promoting
1182 * Google Cloud Print. 1187 * Google Cloud Print.
1183 * @private 1188 * @private
1184 */ 1189 */
1185 onDestinationSearchDone_: function() { 1190 onDestinationSearchDone_: function() {
1186 var isPromoVisible = cr.isChromeOS && 1191 var isPromoVisible = cr.isChromeOS &&
1187 this.cloudPrintInterface_ && 1192 this.cloudPrintInterface_ &&
1188 this.userInfo_.activeUser && 1193 this.userInfo_.activeUser &&
1189 !this.appState_.isGcpPromoDismissed && 1194 !this.appState_.isGcpPromoDismissed &&
1190 !this.destinationStore_.isLocalDestinationsSearchInProgress && 1195 !this.destinationStore_.isLocalDestinationSearchInProgress &&
1191 !this.destinationStore_.isCloudDestinationsSearchInProgress && 1196 !this.destinationStore_.isCloudDestinationSearchInProgress &&
1192 this.destinationStore_.hasOnlyDefaultCloudDestinations(); 1197 this.destinationStore_.hasOnlyDefaultCloudDestinations();
1193 setIsVisible(this.getChildElement('#no-destinations-promo'), 1198 setIsVisible(this.getChildElement('#no-destinations-promo'),
1194 isPromoVisible); 1199 isPromoVisible);
1195 if (isPromoVisible) { 1200 if (isPromoVisible) {
1196 new print_preview.GcpPromoMetricsContext().record( 1201 new print_preview.GcpPromoMetricsContext().record(
1197 print_preview.Metrics.GcpPromoBucket.PROMO_SHOWN); 1202 print_preview.Metrics.GcpPromoBucket.PROMO_SHOWN);
1198 } 1203 }
1199 }, 1204 },
1200 1205
1201 /** 1206 /**
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1302 <include src="search/cloud_destination_list.js"> 1307 <include src="search/cloud_destination_list.js">
1303 <include src="search/recent_destination_list.js"> 1308 <include src="search/recent_destination_list.js">
1304 <include src="search/destination_list_item.js"> 1309 <include src="search/destination_list_item.js">
1305 <include src="search/destination_search.js"> 1310 <include src="search/destination_search.js">
1306 <include src="search/fedex_tos.js"> 1311 <include src="search/fedex_tos.js">
1307 1312
1308 window.addEventListener('DOMContentLoaded', function() { 1313 window.addEventListener('DOMContentLoaded', function() {
1309 printPreview = new print_preview.PrintPreview(); 1314 printPreview = new print_preview.PrintPreview();
1310 printPreview.initialize(); 1315 printPreview.initialize();
1311 }); 1316 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698