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

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

Issue 540563002: Export vendor capabilities to the CJT ticket. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 // TODO(rltoscano): Maybe clear print ticket when destination changes. Or 8 // TODO(rltoscano): Maybe clear print ticket when destination changes. Or
9 // better yet, carry over any print ticket state that is possible. I.e. if 9 // better yet, carry over any print ticket state that is possible. I.e. if
10 // destination changes, the new destination might not support duplex anymore, 10 // destination changes, the new destination might not support duplex anymore,
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 170
171 /** 171 /**
172 * Print selection only ticket item. 172 * Print selection only ticket item.
173 * @type {!print_preview.ticket_items.SelectionOnly} 173 * @type {!print_preview.ticket_items.SelectionOnly}
174 * @private 174 * @private
175 */ 175 */
176 this.selectionOnly_ = 176 this.selectionOnly_ =
177 new print_preview.ticket_items.SelectionOnly(this.documentInfo_); 177 new print_preview.ticket_items.SelectionOnly(this.documentInfo_);
178 178
179 /** 179 /**
180 * Vendor ticket items.
181 * @type {!print_preview.ticket_items.VendorItems}
182 * @private
183 */
184 this.vendorItems_ = new print_preview.ticket_items.VendorItems(
185 this.appState_, this.destinationStore_);
186
187 /**
180 * Keeps track of event listeners for the print ticket store. 188 * Keeps track of event listeners for the print ticket store.
181 * @type {!EventTracker} 189 * @type {!EventTracker}
182 * @private 190 * @private
183 */ 191 */
184 this.tracker_ = new EventTracker(); 192 this.tracker_ = new EventTracker();
185 193
186 /** 194 /**
187 * Whether the print preview has been initialized. 195 * Whether the print preview has been initialized.
188 * @type {boolean} 196 * @type {boolean}
189 * @private 197 * @private
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 }, 268 },
261 269
262 get pageRange() { 270 get pageRange() {
263 return this.pageRange_; 271 return this.pageRange_;
264 }, 272 },
265 273
266 get selectionOnly() { 274 get selectionOnly() {
267 return this.selectionOnly_; 275 return this.selectionOnly_;
268 }, 276 },
269 277
278 get vendorItems() {
279 return this.vendorItems_;
280 },
281
270 /** 282 /**
271 * @return {!print_preview.MeasurementSystem} Measurement system of the 283 * @return {!print_preview.MeasurementSystem} Measurement system of the
272 * local system. 284 * local system.
273 */ 285 */
274 get measurementSystem() { 286 get measurementSystem() {
275 return this.measurementSystem_; 287 return this.measurementSystem_;
276 }, 288 },
277 289
278 /** 290 /**
279 * Initializes the print ticket store. Dispatches an INITIALIZE event. 291 * Initializes the print ticket store. Dispatches an INITIALIZE event.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 if (this.appState_.hasField( 340 if (this.appState_.hasField(
329 print_preview.AppState.Field.IS_COLLATE_ENABLED)) { 341 print_preview.AppState.Field.IS_COLLATE_ENABLED)) {
330 this.collate_.updateValue(this.appState_.getField( 342 this.collate_.updateValue(this.appState_.getField(
331 print_preview.AppState.Field.IS_COLLATE_ENABLED)); 343 print_preview.AppState.Field.IS_COLLATE_ENABLED));
332 } 344 }
333 if (this.appState_.hasField( 345 if (this.appState_.hasField(
334 print_preview.AppState.Field.IS_CSS_BACKGROUND_ENABLED)) { 346 print_preview.AppState.Field.IS_CSS_BACKGROUND_ENABLED)) {
335 this.cssBackground_.updateValue(this.appState_.getField( 347 this.cssBackground_.updateValue(this.appState_.getField(
336 print_preview.AppState.Field.IS_CSS_BACKGROUND_ENABLED)); 348 print_preview.AppState.Field.IS_CSS_BACKGROUND_ENABLED));
337 } 349 }
350 if (this.appState_.hasField(
351 print_preview.AppState.Field.VENDOR_OPTIONS)) {
352 this.vendorItems_.updateValue(this.appState_.getField(
353 print_preview.AppState.Field.VENDOR_OPTIONS));
354 }
338 }, 355 },
339 356
340 /** 357 /**
341 * @return {boolean} {@code true} if the stored print ticket is valid, 358 * @return {boolean} {@code true} if the stored print ticket is valid,
342 * {@code false} otherwise. 359 * {@code false} otherwise.
343 */ 360 */
344 isTicketValid: function() { 361 isTicketValid: function() {
345 return this.isTicketValidForPreview() && 362 return this.isTicketValidForPreview() &&
346 (!this.copies_.isCapabilityAvailable() || this.copies_.isValid()) && 363 (!this.copies_.isCapabilityAvailable() || this.copies_.isValid()) &&
347 (!this.pageRange_.isCapabilityAvailable() || 364 (!this.pageRange_.isCapabilityAvailable() ||
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 height_microns: value.height_microns, 418 height_microns: value.height_microns,
402 is_continuous_feed: value.is_continuous_feed, 419 is_continuous_feed: value.is_continuous_feed,
403 vendor_id: value.vendor_id 420 vendor_id: value.vendor_id
404 }; 421 };
405 } 422 }
406 if (this.landscape.isCapabilityAvailable() && 423 if (this.landscape.isCapabilityAvailable() &&
407 this.landscape.isUserEdited()) { 424 this.landscape.isUserEdited()) {
408 cjt.print.page_orientation = 425 cjt.print.page_orientation =
409 {type: this.landscape.getValue() ? 'LANDSCAPE' : 'PORTRAIT'}; 426 {type: this.landscape.getValue() ? 'LANDSCAPE' : 'PORTRAIT'};
410 } 427 }
428 if (this.vendorItems.isCapabilityAvailable() &&
429 this.vendorItems.isUserEdited()) {
430 var items = this.vendorItems.ticketItems;
431 cjt.print.vendor_ticket_item = [];
432 for (var itemId in items) {
433 if (items.hasOwnProperty(itemId)) {
434 cjt.print.vendor_ticket_item.push(
435 {id: itemId, value: items[itemId]});
436 }
437 }
438 }
411 return JSON.stringify(cjt); 439 return JSON.stringify(cjt);
412 }, 440 },
413 441
414 /** 442 /**
415 * Adds event listeners for the print ticket store. 443 * Adds event listeners for the print ticket store.
416 * @private 444 * @private
417 */ 445 */
418 addEventListeners_: function() { 446 addEventListeners_: function() {
419 this.tracker_.add( 447 this.tracker_.add(
420 this.destinationStore_, 448 this.destinationStore_,
(...skipping 28 matching lines...) Expand all
449 */ 477 */
450 onDestinationSelect_: function() { 478 onDestinationSelect_: function() {
451 // Reset user selection for certain ticket items. 479 // Reset user selection for certain ticket items.
452 if (this.capabilitiesHolder_.get() != null) { 480 if (this.capabilitiesHolder_.get() != null) {
453 this.customMargins_.updateValue(null); 481 this.customMargins_.updateValue(null);
454 if (this.marginsType_.getValue() == 482 if (this.marginsType_.getValue() ==
455 print_preview.ticket_items.MarginsType.Value.CUSTOM) { 483 print_preview.ticket_items.MarginsType.Value.CUSTOM) {
456 this.marginsType_.updateValue( 484 this.marginsType_.updateValue(
457 print_preview.ticket_items.MarginsType.Value.DEFAULT); 485 print_preview.ticket_items.MarginsType.Value.DEFAULT);
458 } 486 }
487 this.vendorItems_.updateValue({});
459 } 488 }
460 }, 489 },
461 490
462 /** 491 /**
463 * Called when the capabilities of the selected destination are ready. 492 * Called when the capabilities of the selected destination are ready.
464 * @private 493 * @private
465 */ 494 */
466 onSelectedDestinationCapabilitiesReady_: function() { 495 onSelectedDestinationCapabilitiesReady_: function() {
467 var caps = this.destinationStore_.selectedDestination.capabilities; 496 var caps = this.destinationStore_.selectedDestination.capabilities;
468 var isFirstUpdate = this.capabilitiesHolder_.get() == null; 497 var isFirstUpdate = this.capabilitiesHolder_.get() == null;
(...skipping 15 matching lines...) Expand all
484 onDocumentInfoChange_: function() { 513 onDocumentInfoChange_: function() {
485 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.DOCUMENT_CHANGE); 514 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.DOCUMENT_CHANGE);
486 }, 515 },
487 }; 516 };
488 517
489 // Export 518 // Export
490 return { 519 return {
491 PrintTicketStore: PrintTicketStore 520 PrintTicketStore: PrintTicketStore
492 }; 521 };
493 }); 522 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698