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

Side by Side 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 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 cr.define('print_preview', function() { 5 cr.define('print_preview', function() {
6 'use strict'; 6 'use strict';
7 7
8 /** 8 /**
9 * Component used for searching for a print destination. 9 * Component used for searching for a print destination.
10 * This is a modal dialog that allows the user to search and select a 10 * This is a modal dialog that allows the user to search and select a
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 print_preview.SearchBox.EventType.SEARCH, 216 print_preview.SearchBox.EventType.SEARCH,
217 this.onSearch_.bind(this)); 217 this.onSearch_.bind(this));
218 this.tracker.add( 218 this.tracker.add(
219 this, 219 this,
220 print_preview.DestinationListItem.EventType.SELECT, 220 print_preview.DestinationListItem.EventType.SELECT,
221 this.onDestinationSelect_.bind(this)); 221 this.onDestinationSelect_.bind(this));
222 222
223 this.tracker.add( 223 this.tracker.add(
224 this.destinationStore_, 224 this.destinationStore_,
225 print_preview.DestinationStore.EventType.DESTINATIONS_INSERTED, 225 print_preview.DestinationStore.EventType.DESTINATIONS_INSERTED,
226 this.onDestinationsInserted_.bind(this)); 226 this.renderDestinations_.bind(this));
227 this.tracker.add( 227 this.tracker.add(
228 this.destinationStore_, 228 this.destinationStore_,
229 print_preview.DestinationStore.EventType.DESTINATION_SELECT, 229 print_preview.DestinationStore.EventType.DESTINATION_SELECT,
230 this.onDestinationStoreSelect_.bind(this)); 230 this.onDestinationStoreSelect_.bind(this));
231 231
232 this.tracker.add( 232 this.tracker.add(
233 this.localList_, 233 this.localList_,
234 print_preview.DestinationList.EventType.ACTION_LINK_ACTIVATED, 234 print_preview.DestinationList.EventType.ACTION_LINK_ACTIVATED,
235 this.onManageLocalDestinationsActivated_.bind(this)); 235 this.onManageLocalDestinationsActivated_.bind(this));
236 this.tracker.add( 236 this.tracker.add(
237 this.cloudList_, 237 this.cloudList_,
238 print_preview.DestinationList.EventType.ACTION_LINK_ACTIVATED, 238 print_preview.DestinationList.EventType.ACTION_LINK_ACTIVATED,
239 this.onManageCloudDestinationsActivated_.bind(this)); 239 this.onManageCloudDestinationsActivated_.bind(this));
240 240
241 this.tracker.add( 241 this.tracker.add(
242 this.getElement(), 'click', this.onClick_.bind(this)); 242 this.getElement(), 'click', this.onClick_.bind(this));
243 this.tracker.add( 243 this.tracker.add(
244 this.pageEl_, 'webkitAnimationEnd', this.onAnimationEnd_.bind(this)); 244 this.pageEl_, 'webkitAnimationEnd', this.onAnimationEnd_.bind(this));
245 245
246 this.tracker.add( 246 this.tracker.add(
247 this.userInfo_, 247 this.userInfo_,
248 print_preview.UserInfo.EventType.EMAIL_CHANGE, 248 print_preview.UserInfo.EventType.EMAIL_CHANGE,
249 this.onEmailChange_.bind(this)); 249 this.onEmailChange_.bind(this));
250
251 // Render any destinations already in the store.
252 this.renderDestinations_();
250 }, 253 },
251 254
252 /** @override */ 255 /** @override */
253 exitDocument: function() { 256 exitDocument: function() {
254 print_preview.Component.prototype.exitDocument.call(this); 257 print_preview.Component.prototype.exitDocument.call(this);
255 this.pageEl_ = null; 258 this.pageEl_ = null;
256 }, 259 },
257 260
258 /** @override */ 261 /** @override */
259 decorateInternal: function() { 262 decorateInternal: function() {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 /** 299 /**
297 * Resets the search query. 300 * Resets the search query.
298 * @private 301 * @private
299 */ 302 */
300 resetSearch_: function() { 303 resetSearch_: function() {
301 this.searchBox_.setQuery(null); 304 this.searchBox_.setQuery(null);
302 this.filterLists_(null); 305 this.filterLists_(null);
303 }, 306 },
304 307
305 /** 308 /**
309 * Renders all of the destinations in the destination store.
310 * @private
311 */
312 renderDestinations_: function() {
313 var recentDestinations = [];
314 var localDestinations = [];
315 var cloudDestinations = [];
316 this.destinationStore_.destinations.forEach(function(destination) {
317 if (destination.isRecent) {
318 recentDestinations.push(destination);
319 }
320 if (destination.isLocal) {
321 localDestinations.push(destination);
322 } else {
323 cloudDestinations.push(destination);
324 }
325 });
326 this.recentList_.updateDestinations(recentDestinations);
327 this.localList_.updateDestinations(localDestinations);
328 this.cloudList_.updateDestinations(cloudDestinations);
329 },
330
331 /**
306 * Called when a destination search should be executed. Filters the 332 * Called when a destination search should be executed. Filters the
307 * destination lists with the given query. 333 * destination lists with the given query.
308 * @param {cr.Event} evt Contains the search query. 334 * @param {cr.Event} evt Contains the search query.
309 * @private 335 * @private
310 */ 336 */
311 onSearch_: function(evt) { 337 onSearch_: function(evt) {
312 this.filterLists_(evt.query); 338 this.filterLists_(evt.query);
313 }, 339 },
314 340
315 /** 341 /**
(...skipping 15 matching lines...) Expand all
331 */ 357 */
332 onDestinationSelect_: function(evt) { 358 onDestinationSelect_: function(evt) {
333 this.setIsVisible(false); 359 this.setIsVisible(false);
334 this.resetSearch_(); 360 this.resetSearch_();
335 this.destinationStore_.selectDestination(evt.destination); 361 this.destinationStore_.selectDestination(evt.destination);
336 this.metrics_.increment( 362 this.metrics_.increment(
337 print_preview.Metrics.Bucket.DESTINATION_SELECTED); 363 print_preview.Metrics.Bucket.DESTINATION_SELECTED);
338 }, 364 },
339 365
340 /** 366 /**
341 * Called when destinations are added to the destination store. Refreshes UI
342 * with new destinations.
343 * @private
344 */
345 onDestinationsInserted_: function() {
346 var recentDestinations = [];
347 var localDestinations = [];
348 var cloudDestinations = [];
349 this.destinationStore_.destinations.forEach(function(destination) {
350 if (destination.isRecent) {
351 recentDestinations.push(destination);
352 }
353 if (destination.isLocal) {
354 localDestinations.push(destination);
355 } else {
356 cloudDestinations.push(destination);
357 }
358 });
359 this.recentList_.updateDestinations(recentDestinations);
360 this.localList_.updateDestinations(localDestinations);
361 this.cloudList_.updateDestinations(cloudDestinations);
362 },
363
364 /**
365 * Called when a destination is selected. Selected destination are marked as 367 * Called when a destination is selected. Selected destination are marked as
366 * recent, so we have to update our recent destinations list. 368 * recent, so we have to update our recent destinations list.
367 * @private 369 * @private
368 */ 370 */
369 onDestinationStoreSelect_: function() { 371 onDestinationStoreSelect_: function() {
370 var destinations = this.destinationStore_.destinations; 372 var destinations = this.destinationStore_.destinations;
371 var recentDestinations = []; 373 var recentDestinations = [];
372 destinations.forEach(function(destination) { 374 destinations.forEach(function(destination) {
373 if (destination.isRecent) { 375 if (destination.isRecent) {
374 recentDestinations.push(destination); 376 recentDestinations.push(destination);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 this.setCloudPrintEmail(userEmail); 449 this.setCloudPrintEmail(userEmail);
448 } 450 }
449 } 451 }
450 }; 452 };
451 453
452 // Export 454 // Export
453 return { 455 return {
454 DestinationSearch: DestinationSearch 456 DestinationSearch: DestinationSearch
455 }; 457 };
456 }); 458 });
OLDNEW
« 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