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

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

Issue 2919693002: Print Preview: Change getPrinters to cr.sendWithPromise (Closed)
Patch Set: Address comments Created 3 years, 6 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
« no previous file with comments | « no previous file | chrome/browser/resources/print_preview/data/local_parsers.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 cr.define('print_preview', function() { 5 cr.define('print_preview', function() {
6 'use strict'; 6 'use strict';
7 7
8 /** 8 /**
9 * A data store that stores destinations and dispatches events when the data 9 * A data store that stores destinations and dispatches events when the data
10 * store changes. 10 * store changes.
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 } 1071 }
1072 } 1072 }
1073 } 1073 }
1074 this.selectPdfDestination_(); 1074 this.selectPdfDestination_();
1075 }, 1075 },
1076 1076
1077 /** Initiates loading of local print destinations. */ 1077 /** Initiates loading of local print destinations. */
1078 startLoadLocalDestinations: function() { 1078 startLoadLocalDestinations: function() {
1079 if (!this.hasLoadedAllLocalDestinations_) { 1079 if (!this.hasLoadedAllLocalDestinations_) {
1080 this.hasLoadedAllLocalDestinations_ = true; 1080 this.hasLoadedAllLocalDestinations_ = true;
1081 this.nativeLayer_.startGetLocalDestinations(); 1081 this.nativeLayer_.getPrinters().then(
1082 this.onLocalDestinationsSet_.bind(this));
1082 this.isLocalDestinationSearchInProgress_ = true; 1083 this.isLocalDestinationSearchInProgress_ = true;
1083 cr.dispatchSimpleEvent( 1084 cr.dispatchSimpleEvent(
1084 this, DestinationStore.EventType.DESTINATION_SEARCH_STARTED); 1085 this, DestinationStore.EventType.DESTINATION_SEARCH_STARTED);
1085 } 1086 }
1086 }, 1087 },
1087 1088
1088 /** Initiates loading of privet print destinations. */ 1089 /** Initiates loading of privet print destinations. */
1089 startLoadPrivetDestinations: function() { 1090 startLoadPrivetDestinations: function() {
1090 if (!this.hasLoadedAllPrivetDestinations_) { 1091 if (!this.hasLoadedAllPrivetDestinations_) {
1091 if (this.privetDestinationSearchInProgress_) 1092 if (this.privetDestinationSearchInProgress_)
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
1355 }, 1356 },
1356 1357
1357 /** 1358 /**
1358 * Binds handlers to events. 1359 * Binds handlers to events.
1359 * @private 1360 * @private
1360 */ 1361 */
1361 addEventListeners_: function() { 1362 addEventListeners_: function() {
1362 var nativeLayerEventTarget = this.nativeLayer_.getEventTarget(); 1363 var nativeLayerEventTarget = this.nativeLayer_.getEventTarget();
1363 this.tracker_.add( 1364 this.tracker_.add(
1364 nativeLayerEventTarget, 1365 nativeLayerEventTarget,
1365 print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET,
1366 this.onLocalDestinationsSet_.bind(this));
1367 this.tracker_.add(
1368 nativeLayerEventTarget,
1369 print_preview.NativeLayer.EventType.CAPABILITIES_SET, 1366 print_preview.NativeLayer.EventType.CAPABILITIES_SET,
1370 this.onLocalDestinationCapabilitiesSet_.bind(this)); 1367 this.onLocalDestinationCapabilitiesSet_.bind(this));
1371 this.tracker_.add( 1368 this.tracker_.add(
1372 nativeLayerEventTarget, 1369 nativeLayerEventTarget,
1373 print_preview.NativeLayer.EventType.GET_CAPABILITIES_FAIL, 1370 print_preview.NativeLayer.EventType.GET_CAPABILITIES_FAIL,
1374 this.onGetCapabilitiesFail_.bind(this)); 1371 this.onGetCapabilitiesFail_.bind(this));
1375 this.tracker_.add( 1372 this.tracker_.add(
1376 nativeLayerEventTarget, 1373 nativeLayerEventTarget,
1377 print_preview.NativeLayer.EventType.DESTINATIONS_RELOAD, 1374 print_preview.NativeLayer.EventType.DESTINATIONS_RELOAD,
1378 this.onDestinationsReload_.bind(this)); 1375 this.onDestinationsReload_.bind(this));
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1430 this.hasLoadedAllExtensionDestinations_ = false; 1427 this.hasLoadedAllExtensionDestinations_ = false;
1431 1428
1432 clearTimeout(this.autoSelectTimeout_); 1429 clearTimeout(this.autoSelectTimeout_);
1433 this.autoSelectTimeout_ = setTimeout( 1430 this.autoSelectTimeout_ = setTimeout(
1434 this.selectDefaultDestination_.bind(this), 1431 this.selectDefaultDestination_.bind(this),
1435 DestinationStore.AUTO_SELECT_TIMEOUT_); 1432 DestinationStore.AUTO_SELECT_TIMEOUT_);
1436 }, 1433 },
1437 1434
1438 /** 1435 /**
1439 * Called when the local destinations have been got from the native layer. 1436 * Called when the local destinations have been got from the native layer.
1440 * @param {Event} event Contains the local destinations. 1437 * @param {!Array<!print_preview.LocalDestinationInfo>} destinationInfos A
1438 * list of the local destinations retrieved.
1441 * @private 1439 * @private
1442 */ 1440 */
1443 onLocalDestinationsSet_: function(event) { 1441 onLocalDestinationsSet_: function(destinationInfos) {
1444 var localDestinations = event.destinationInfos.map(function(destInfo) { 1442 var localDestinations = destinationInfos.map(function(destInfo) {
1445 return print_preview.LocalDestinationParser.parse(destInfo); 1443 return print_preview.LocalDestinationParser.parse(destInfo);
1446 }); 1444 });
1447 this.insertDestinations_(localDestinations); 1445 this.insertDestinations_(localDestinations);
1448 this.isLocalDestinationSearchInProgress_ = false; 1446 this.isLocalDestinationSearchInProgress_ = false;
1449 cr.dispatchSimpleEvent( 1447 cr.dispatchSimpleEvent(
1450 this, DestinationStore.EventType.DESTINATION_SEARCH_DONE); 1448 this, DestinationStore.EventType.DESTINATION_SEARCH_DONE);
1451 }, 1449 },
1452 1450
1453 /** 1451 /**
1454 * Called when the native layer retrieves the capabilities for the selected 1452 * Called when the native layer retrieves the capabilities for the selected
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1697 return this.getDestinationKey_( 1695 return this.getDestinationKey_(
1698 destination.origin, destination.id, destination.account); 1696 destination.origin, destination.id, destination.account);
1699 } 1697 }
1700 }; 1698 };
1701 1699
1702 // Export 1700 // Export
1703 return { 1701 return {
1704 DestinationStore: DestinationStore 1702 DestinationStore: DestinationStore
1705 }; 1703 };
1706 }); 1704 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/print_preview/data/local_parsers.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698