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

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

Issue 233623003: Remember and restore the account last used destination is registered for. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
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 var localStrings = new LocalStrings(templateData); 7 var localStrings = new LocalStrings(templateData);
8 8
9 <include src="component.js"/> 9 <include src="component.js"/>
10 10
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 onInitialSettingsSet_: function(event) { 514 onInitialSettingsSet_: function(event) {
515 assert(this.uiState_ == PrintPreview.UiState_.INITIALIZING, 515 assert(this.uiState_ == PrintPreview.UiState_.INITIALIZING,
516 'Updating initial settings when not in initializing state: ' + 516 'Updating initial settings when not in initializing state: ' +
517 this.uiState_); 517 this.uiState_);
518 this.uiState_ = PrintPreview.UiState_.READY; 518 this.uiState_ = PrintPreview.UiState_.READY;
519 519
520 var settings = event.initialSettings; 520 var settings = event.initialSettings;
521 this.isInKioskAutoPrintMode_ = settings.isInKioskAutoPrintMode; 521 this.isInKioskAutoPrintMode_ = settings.isInKioskAutoPrintMode;
522 522
523 // The following components must be initialized in this order. 523 // The following components must be initialized in this order.
524 this.appState_.init(settings.serializedAppStateStr); 524 this.appState_.init(
525 settings.serializedAppStateStr,
526 settings.systemDefaultDestinationId);
525 this.documentInfo_.init( 527 this.documentInfo_.init(
526 settings.isDocumentModifiable, 528 settings.isDocumentModifiable,
527 settings.documentTitle, 529 settings.documentTitle,
528 settings.documentHasSelection); 530 settings.documentHasSelection);
529 this.printTicketStore_.init( 531 this.printTicketStore_.init(
530 settings.thousandsDelimeter, 532 settings.thousandsDelimeter,
531 settings.decimalDelimeter, 533 settings.decimalDelimeter,
532 settings.unitType, 534 settings.unitType,
533 settings.selectionOnly); 535 settings.selectionOnly);
534 this.destinationStore_.init(settings.systemDefaultDestinationId); 536 this.destinationStore_.init();
535 this.appState_.setInitialized(); 537 this.appState_.setInitialized();
536 538
537 $('document-title').innerText = settings.documentTitle; 539 $('document-title').innerText = settings.documentTitle;
538 setIsVisible($('system-dialog-link'), 540 setIsVisible($('system-dialog-link'),
539 !settings.hidePrintWithSystemDialogLink); 541 !settings.hidePrintWithSystemDialogLink);
540 }, 542 },
541 543
542 /** 544 /**
543 * Calls when the native layer enables Google Cloud Print integration. 545 * Calls when the native layer enables Google Cloud Print integration.
544 * Fetches the user's cloud printers. 546 * Fetches the user's cloud printers.
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 if ((cr.isMac && e.metaKey && e.altKey && !e.shiftKey && !e.ctrlKey) || 778 if ((cr.isMac && e.metaKey && e.altKey && !e.shiftKey && !e.ctrlKey) ||
777 (!cr.isMac && e.shiftKey && e.ctrlKey && !e.altKey && !e.metaKey)) { 779 (!cr.isMac && e.shiftKey && e.ctrlKey && !e.altKey && !e.metaKey)) {
778 this.openSystemPrintDialog_(); 780 this.openSystemPrintDialog_();
779 e.preventDefault(); 781 e.preventDefault();
780 return; 782 return;
781 } 783 }
782 } 784 }
783 785
784 if (e.keyCode == 13 /*enter*/ && 786 if (e.keyCode == 13 /*enter*/ &&
785 !this.destinationSearch_.getIsVisible() && 787 !this.destinationSearch_.getIsVisible() &&
788 this.destinationStore_.selectedDestination &&
786 this.printTicketStore_.isTicketValid()) { 789 this.printTicketStore_.isTicketValid()) {
787 assert(this.uiState_ == PrintPreview.UiState_.READY, 790 assert(this.uiState_ == PrintPreview.UiState_.READY,
788 'Trying to print when not in ready state: ' + this.uiState_); 791 'Trying to print when not in ready state: ' + this.uiState_);
789 var activeElementTag = document.activeElement ? 792 var activeElementTag = document.activeElement ?
790 document.activeElement.tagName.toUpperCase() : ''; 793 document.activeElement.tagName.toUpperCase() : '';
791 if (activeElementTag != 'BUTTON' && activeElementTag != 'SELECT') { 794 if (activeElementTag != 'BUTTON' && activeElementTag != 'SELECT') {
792 this.printDocumentOrOpenPdfPreview_(false /*isPdfPreview*/); 795 this.printDocumentOrOpenPdfPreview_(false /*isPdfPreview*/);
793 e.preventDefault(); 796 e.preventDefault();
794 } 797 }
795 return; 798 return;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 this.printIfReady_(); 893 this.printIfReady_();
891 }, 894 },
892 895
893 /** 896 /**
894 * Called when a print destination is selected. Shows/hides the "Print with 897 * Called when a print destination is selected. Shows/hides the "Print with
895 * Cloud Print" link in the navbar. 898 * Cloud Print" link in the navbar.
896 * @private 899 * @private
897 */ 900 */
898 onDestinationSelect_: function() { 901 onDestinationSelect_: function() {
899 var selectedDest = this.destinationStore_.selectedDestination; 902 var selectedDest = this.destinationStore_.selectedDestination;
900 setIsVisible($('cloud-print-dialog-link'), 903 setIsVisible(
901 !cr.isChromeOS && !selectedDest.isLocal); 904 $('cloud-print-dialog-link'),
902 if (this.isInKioskAutoPrintMode_) { 905 selectedDest && !cr.isChromeOS && !selectedDest.isLocal);
906 if (selectedDest && this.isInKioskAutoPrintMode_) {
903 this.onPrintButtonClick_(); 907 this.onPrintButtonClick_();
904 } 908 }
905 }, 909 },
906 910
907 /** 911 /**
908 * Called when the destination store loads a group of destinations. Shows 912 * Called when the destination store loads a group of destinations. Shows
909 * a promo on Chrome OS if the user has no print destinations promoting 913 * a promo on Chrome OS if the user has no print destinations promoting
910 * Google Cloud Print. 914 * Google Cloud Print.
911 * @private 915 * @private
912 */ 916 */
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 <include src="search/recent_destination_list.js"/> 1020 <include src="search/recent_destination_list.js"/>
1017 <include src="search/destination_list_item.js"/> 1021 <include src="search/destination_list_item.js"/>
1018 <include src="search/destination_search.js"/> 1022 <include src="search/destination_search.js"/>
1019 <include src="search/search_box.js"/> 1023 <include src="search/search_box.js"/>
1020 <include src="search/fedex_tos.js"/> 1024 <include src="search/fedex_tos.js"/>
1021 1025
1022 window.addEventListener('DOMContentLoaded', function() { 1026 window.addEventListener('DOMContentLoaded', function() {
1023 printPreview = new print_preview.PrintPreview(); 1027 printPreview = new print_preview.PrintPreview();
1024 printPreview.initialize(); 1028 printPreview.initialize();
1025 }); 1029 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698