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

Unified Diff: chrome/browser/resources/print_preview/search/destination_search.js

Issue 10545181: Optimizes loading initial printer on non-chromeos platforms. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add bug reference to TODOs. Created 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/print_preview/search/destination_search.js
diff --git a/chrome/browser/resources/print_preview/search/destination_search.js b/chrome/browser/resources/print_preview/search/destination_search.js
index b14e2dd3128fe0ceeee9d13a036ed9bc63b4f062..afccb8b5cd500b4dc342b91593f59c79d5dc8d0e 100644
--- a/chrome/browser/resources/print_preview/search/destination_search.js
+++ b/chrome/browser/resources/print_preview/search/destination_search.js
@@ -223,7 +223,7 @@ cr.define('print_preview', function() {
this.tracker.add(
this.destinationStore_,
print_preview.DestinationStore.EventType.DESTINATIONS_INSERTED,
- this.onDestinationsInserted_.bind(this));
+ this.renderDestinations_.bind(this));
this.tracker.add(
this.destinationStore_,
print_preview.DestinationStore.EventType.DESTINATION_SELECT,
@@ -247,6 +247,9 @@ cr.define('print_preview', function() {
this.userInfo_,
print_preview.UserInfo.EventType.EMAIL_CHANGE,
this.onEmailChange_.bind(this));
+
+ // Render any destinations already in the store.
+ this.renderDestinations_();
},
/** @override */
@@ -303,6 +306,29 @@ cr.define('print_preview', function() {
},
/**
+ * Renders all of the destinations in the destination store.
+ * @private
+ */
+ renderDestinations_: function() {
+ var recentDestinations = [];
+ var localDestinations = [];
+ var cloudDestinations = [];
+ this.destinationStore_.destinations.forEach(function(destination) {
+ if (destination.isRecent) {
+ recentDestinations.push(destination);
+ }
+ if (destination.isLocal) {
+ localDestinations.push(destination);
+ } else {
+ cloudDestinations.push(destination);
+ }
+ });
+ this.recentList_.updateDestinations(recentDestinations);
+ this.localList_.updateDestinations(localDestinations);
+ this.cloudList_.updateDestinations(cloudDestinations);
+ },
+
+ /**
* Called when a destination search should be executed. Filters the
* destination lists with the given query.
* @param {cr.Event} evt Contains the search query.
@@ -338,30 +364,6 @@ cr.define('print_preview', function() {
},
/**
- * Called when destinations are added to the destination store. Refreshes UI
- * with new destinations.
- * @private
- */
- onDestinationsInserted_: function() {
- var recentDestinations = [];
- var localDestinations = [];
- var cloudDestinations = [];
- this.destinationStore_.destinations.forEach(function(destination) {
- if (destination.isRecent) {
- recentDestinations.push(destination);
- }
- if (destination.isLocal) {
- localDestinations.push(destination);
- } else {
- cloudDestinations.push(destination);
- }
- });
- this.recentList_.updateDestinations(recentDestinations);
- this.localList_.updateDestinations(localDestinations);
- this.cloudList_.updateDestinations(cloudDestinations);
- },
-
- /**
* Called when a destination is selected. Selected destination are marked as
* recent, so we have to update our recent destinations list.
* @private
« no previous file with comments | « chrome/browser/resources/print_preview/data/destination_store.js ('k') | chrome/test/data/webui/print_preview.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698