Commit 41e97392 authored by rbpotter's avatar rbpotter Committed by Commit Bot

Print Preview: Update CloudPrintInterface and InvitationStore events

- Remove PROCESS_INVITE_FAILED event that was handled identically to
PROCESS_INVITE event.
- Use CustomEvent instead of Event for all events

Bug: None
Change-Id: I9de2723779267dc0e8b8d195337b89d9aeb5ca8f
Reviewed-on: https://chromium-review.googlesource.com/c/1395178
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#619886}
parent 2a7d9319
...@@ -14,7 +14,6 @@ cloudprint.CloudPrintInterfaceEventType = { ...@@ -14,7 +14,6 @@ cloudprint.CloudPrintInterfaceEventType = {
PRINTER_DONE: 'cloudprint.CloudPrintInterface.PRINTER_DONE', PRINTER_DONE: 'cloudprint.CloudPrintInterface.PRINTER_DONE',
PRINTER_FAILED: 'cloudprint.CloudPrintInterface.PRINTER_FAILED', PRINTER_FAILED: 'cloudprint.CloudPrintInterface.PRINTER_FAILED',
PROCESS_INVITE_DONE: 'cloudprint.CloudPrintInterface.PROCESS_INVITE_DONE', PROCESS_INVITE_DONE: 'cloudprint.CloudPrintInterface.PROCESS_INVITE_DONE',
PROCESS_INVITE_FAILED: 'cloudprint.CloudPrintInterface.PROCESS_INVITE_FAILED',
SEARCH_DONE: 'cloudprint.CloudPrintInterface.SEARCH_DONE', SEARCH_DONE: 'cloudprint.CloudPrintInterface.SEARCH_DONE',
SEARCH_FAILED: 'cloudprint.CloudPrintInterface.SEARCH_FAILED', SEARCH_FAILED: 'cloudprint.CloudPrintInterface.SEARCH_FAILED',
SUBMIT_DONE: 'cloudprint.CloudPrintInterface.SUBMIT_DONE', SUBMIT_DONE: 'cloudprint.CloudPrintInterface.SUBMIT_DONE',
...@@ -25,25 +24,19 @@ cloudprint.CloudPrintInterfaceEventType = { ...@@ -25,25 +24,19 @@ cloudprint.CloudPrintInterfaceEventType = {
* @typedef {{ * @typedef {{
* user: string, * user: string,
* origin: !print_preview.DestinationOrigin, * origin: !print_preview.DestinationOrigin,
* printers: (!Array<!print_preview.Destination>|undefined) * printers: (!Array<!print_preview.Destination>|undefined),
* searchDone: boolean,
* }} * }}
*/ */
cloudprint.CloudPrintInterfaceSearchDoneEvent; cloudprint.CloudPrintInterfaceSearchDoneDetail;
/**
* @typedef {{
* printer: !print_preview.Destination,
* }}
*/
cloudprint.CloudPrintInterfacePrinterDoneEvent;
/** /**
* @typedef {{ * @typedef {{
* destinationId: string, * destinationId: string,
* destinationOrigin: !print_preview.DestinationOrigin, * origin: !print_preview.DestinationOrigin,
* }} * }}
*/ */
cloudprint.CloudPrintInterfacePrinterFailedEvent; cloudprint.CloudPrintInterfacePrinterFailedDetail;
/** /**
* @typedef {{ * @typedef {{
...@@ -51,21 +44,17 @@ cloudprint.CloudPrintInterfacePrinterFailedEvent; ...@@ -51,21 +44,17 @@ cloudprint.CloudPrintInterfacePrinterFailedEvent;
* user: string, * user: string,
* }} * }}
*/ */
cloudprint.CloudPrintInterfaceInvitesDoneEvent; cloudprint.CloudPrintInterfaceInvitesDoneDetail;
/**
* @typedef {{
* user: string,
* }}
*/
cloudprint.CloudPrintInterfaceInvitesFailedEvent;
/** /**
* @typedef {{ * @typedef {{
* invitation: !print_preview.Invitation, * invitation: !print_preview.Invitation,
* printer: ?print_preview.Destination,
* accept: boolean,
* user: string,
* }} * }}
*/ */
cloudprint.CloudPrintInterfaceProcessInviteEvent; cloudprint.CloudPrintInterfaceProcessInviteDetail;
cr.define('cloudprint', function() { cr.define('cloudprint', function() {
/** @interface */ /** @interface */
......
...@@ -287,26 +287,25 @@ cr.define('cloudprint', function() { ...@@ -287,26 +287,25 @@ cr.define('cloudprint', function() {
} }
/** /**
* Creates a Google Cloud Print interface error that is ready to dispatch. * Creates an object containing information about the error based on the
* @param {!cloudprint.CloudPrintInterfaceEventType} type Type of the * request.
* error.
* @param {!cloudprint.CloudPrintRequest} request Request that has been * @param {!cloudprint.CloudPrintRequest} request Request that has been
* completed. * completed.
* @return {!Event} Google Cloud Print interface error event. * @return {!{ status: number,
* errorCode: number,
* message: string,
* origin: !print_preview.DestinationOrigin }} Information
* about the error.
* @private * @private
*/ */
createErrorEvent_(type, request) { createErrorEventDetail_(request) {
const errorEvent = new Event(type); const status200 = request.xhr.status === 200;
errorEvent.status = request.xhr.status; return {
if (request.xhr.status == 200) { status: request.xhr.status,
errorEvent.errorCode = request.result['errorCode']; errorCode: status200 ? request.result['errorCode'] : 0,
errorEvent.message = request.result['message']; message: status200 ? request.result['message'] : '',
} else { origin: request.origin,
errorEvent.errorCode = 0; };
errorEvent.message = '';
}
errorEvent.origin = request.origin;
return errorEvent;
} }
/** /**
...@@ -407,7 +406,6 @@ cr.define('cloudprint', function() { ...@@ -407,7 +406,6 @@ cr.define('cloudprint', function() {
activeUser = request.result && request.result['request'] && activeUser = request.result && request.result['request'] &&
request.result['request']['user']; request.result['request']['user'];
} }
let event = null;
if (request.xhr.status == 200 && request.result['success']) { if (request.xhr.status == 200 && request.result['success']) {
// Extract printers. // Extract printers.
const printerListJson = request.result['printers'] || []; const printerListJson = request.result['printers'] || [];
...@@ -423,17 +421,24 @@ cr.define('cloudprint', function() { ...@@ -423,17 +421,24 @@ cr.define('cloudprint', function() {
// Extract and store users. // Extract and store users.
this.setUsers_(request); this.setUsers_(request);
// Dispatch SEARCH_DONE event. // Dispatch SEARCH_DONE event.
event = new Event(CloudPrintInterfaceEventType.SEARCH_DONE); this.eventTarget_.dispatchEvent(
event.origin = request.origin; new CustomEvent(CloudPrintInterfaceEventType.SEARCH_DONE, {
event.printers = printerList; detail: {
event.isRecent = isRecent; origin: request.origin,
printers: printerList,
isRecent: isRecent,
user: activeUser,
searchDone: lastRequestForThisOrigin,
}
}));
} else { } else {
event = this.createErrorEvent_( const errorEventDetail = this.createErrorEventDetail_(request);
CloudPrintInterfaceEventType.SEARCH_FAILED, request); errorEventDetail.user = activeUser;
errorEventDetail.searchDone = lastRequestForThisOrigin;
this.eventTarget_.dispatchEvent(new CustomEvent(
CloudPrintInterfaceEventType.SEARCH_FAILED,
{detail: errorEventDetail}));
} }
event.user = activeUser;
event.searchDone = lastRequestForThisOrigin;
this.eventTarget_.dispatchEvent(event);
} }
/** /**
...@@ -443,7 +448,6 @@ cr.define('cloudprint', function() { ...@@ -443,7 +448,6 @@ cr.define('cloudprint', function() {
* @private * @private
*/ */
onInvitesDone_(request) { onInvitesDone_(request) {
let event = null;
const activeUser = (request.result && request.result['request'] && const activeUser = (request.result && request.result['request'] &&
request.result['request']['user']) || request.result['request']['user']) ||
''; '';
...@@ -460,14 +464,17 @@ cr.define('cloudprint', function() { ...@@ -460,14 +464,17 @@ cr.define('cloudprint', function() {
} }
}); });
// Dispatch INVITES_DONE event. // Dispatch INVITES_DONE event.
event = new Event(CloudPrintInterfaceEventType.INVITES_DONE); this.eventTarget_.dispatchEvent(
event.invitations = invitationList; new CustomEvent(CloudPrintInterfaceEventType.INVITES_DONE, {
detail: {
invitations: invitationList,
user: activeUser,
}
}));
} else { } else {
event = this.createErrorEvent_( this.eventTarget_.dispatchEvent(new CustomEvent(
CloudPrintInterfaceEventType.INVITES_FAILED, request); CloudPrintInterfaceEventType.INVITES_FAILED, {detail: activeUser}));
} }
event.user = activeUser;
this.eventTarget_.dispatchEvent(event);
} }
/** /**
...@@ -479,28 +486,27 @@ cr.define('cloudprint', function() { ...@@ -479,28 +486,27 @@ cr.define('cloudprint', function() {
* @private * @private
*/ */
onProcessInviteDone_(invitation, accept, request) { onProcessInviteDone_(invitation, accept, request) {
let event = null;
const activeUser = (request.result && request.result['request'] && const activeUser = (request.result && request.result['request'] &&
request.result['request']['user']) || request.result['request']['user']) ||
''; '';
if (request.xhr.status == 200 && request.result['success']) { let printer = null;
event = new Event(CloudPrintInterfaceEventType.PROCESS_INVITE_DONE); if (request.xhr.status == 200 && request.result['success'] && accept) {
if (accept) { try {
try { printer = cloudprint.parseCloudDestination(
event.printer = cloudprint.parseCloudDestination( request.result['printer'], request.origin, activeUser);
request.result['printer'], request.origin, activeUser); } catch (e) {
} catch (e) { console.error('Failed to parse cloud print destination: ' + e);
console.error('Failed to parse cloud print destination: ' + e);
}
} }
} else {
event = this.createErrorEvent_(
CloudPrintInterfaceEventType.PROCESS_INVITE_FAILED, request);
} }
event.invitation = invitation; this.eventTarget_.dispatchEvent(
event.accept = accept; new CustomEvent(CloudPrintInterfaceEventType.PROCESS_INVITE_DONE, {
event.user = activeUser; detail: {
this.eventTarget_.dispatchEvent(event); printer: printer,
invitation: invitation,
accept: accept,
user: activeUser,
}
}));
} }
/** /**
...@@ -511,14 +517,14 @@ cr.define('cloudprint', function() { ...@@ -511,14 +517,14 @@ cr.define('cloudprint', function() {
*/ */
onSubmitDone_(request) { onSubmitDone_(request) {
if (request.xhr.status == 200 && request.result['success']) { if (request.xhr.status == 200 && request.result['success']) {
const submitDoneEvent = this.eventTarget_.dispatchEvent(new CustomEvent(
new Event(CloudPrintInterfaceEventType.SUBMIT_DONE); CloudPrintInterfaceEventType.SUBMIT_DONE,
submitDoneEvent.jobId = request.result['job']['id']; {detail: request.result['job']['id']}));
this.eventTarget_.dispatchEvent(submitDoneEvent);
} else { } else {
const errorEvent = this.createErrorEvent_( const errorEventDetail = this.createErrorEventDetail_(request);
CloudPrintInterfaceEventType.SUBMIT_FAILED, request); this.eventTarget_.dispatchEvent(new CustomEvent(
this.eventTarget_.dispatchEvent(errorEvent); CloudPrintInterfaceEventType.SUBMIT_FAILED,
{detail: errorEventDetail}));
} }
} }
...@@ -567,16 +573,14 @@ cr.define('cloudprint', function() { ...@@ -567,16 +573,14 @@ cr.define('cloudprint', function() {
JSON.stringify(printerJson)); JSON.stringify(printerJson));
return; return;
} }
const printerDoneEvent = this.eventTarget_.dispatchEvent(new CustomEvent(
new Event(CloudPrintInterfaceEventType.PRINTER_DONE); CloudPrintInterfaceEventType.PRINTER_DONE, {detail: printer}));
printerDoneEvent.printer = printer;
this.eventTarget_.dispatchEvent(printerDoneEvent);
} else { } else {
const errorEvent = this.createErrorEvent_( const errorEventDetail = this.createErrorEventDetail_(request);
CloudPrintInterfaceEventType.PRINTER_FAILED, request); errorEventDetail.destinationId = destinationId;
errorEvent.destinationId = destinationId; this.eventTarget_.dispatchEvent(new CustomEvent(
errorEvent.destinationOrigin = request.origin; CloudPrintInterfaceEventType.PRINTER_FAILED,
this.eventTarget_.dispatchEvent(errorEvent); {detail: errorEventDetail}));
} }
} }
} }
......
...@@ -1220,22 +1220,25 @@ cr.define('print_preview', function() { ...@@ -1220,22 +1220,25 @@ cr.define('print_preview', function() {
/** /**
* Called when the /search call completes, either successfully or not. * Called when the /search call completes, either successfully or not.
* In case of success, stores fetched destinations. * In case of success, stores fetched destinations.
* @param {!cloudprint.CloudPrintInterfaceSearchDoneEvent} event Contains * @param {!CustomEvent} event Contains the request result.
* the request result.
* @private * @private
*/ */
onCloudPrintSearchDone_(event) { onCloudPrintSearchDone_(event) {
if (event.printers && event.printers.length > 0) { const payload =
this.insertDestinations_(event.printers); /** @type {!cloudprint.CloudPrintInterfaceSearchDoneDetail} */ (
event.detail);
if (payload.printers && payload.printers.length > 0) {
this.insertDestinations_(payload.printers);
if (this.selectFirstDestination_) { if (this.selectFirstDestination_) {
this.selectDestination(this.destinations_[0]); this.selectDestination(this.destinations_[0]);
this.selectFirstDestination_ = false; this.selectFirstDestination_ = false;
} }
} }
if (event.searchDone) { if (payload.searchDone) {
const origins = this.loadedCloudOrigins_[event.user] || []; const origins = this.loadedCloudOrigins_[payload.user] || [];
if (origins.indexOf(event.origin) < 0) { if (origins.indexOf(payload.origin) < 0) {
this.loadedCloudOrigins_[event.user] = origins.concat([event.origin]); this.loadedCloudOrigins_[payload.user] =
origins.concat([payload.origin]);
} }
} }
this.dispatchEvent( this.dispatchEvent(
...@@ -1262,43 +1265,46 @@ cr.define('print_preview', function() { ...@@ -1262,43 +1265,46 @@ cr.define('print_preview', function() {
/** /**
* Called when /printer call completes. Updates the specified destination's * Called when /printer call completes. Updates the specified destination's
* print capabilities. * print capabilities.
* @param {!cloudprint.CloudPrintInterfacePrinterDoneEvent} event Contains * @param {!CustomEvent} event Contains detailed information about the
* detailed information about the destination. * destination.
* @private * @private
*/ */
onCloudPrintPrinterDone_(event) { onCloudPrintPrinterDone_(event) {
this.updateDestination_(event.printer); this.updateDestination_(
/** @type {!print_preview.Destination} */ (event.detail));
} }
/** /**
* Called when the Google Cloud Print interface fails to lookup a * Called when the Google Cloud Print interface fails to lookup a
* destination. Selects another destination if the failed destination was * destination. Selects another destination if the failed destination was
* the initial destination. * the initial destination.
* @param {!cloudprint.CloudPrintInterfacePrinterFailedEvent} event * @param {!CustomEvent} event Contains the ID of the destination that was
* Contains the ID of the destination that was failed to be looked up. * failed to be looked up.
* @private * @private
*/ */
onCloudPrintPrinterFailed_(event) { onCloudPrintPrinterFailed_(event) {
const eventDetail =
/** @type {!cloudprint.CloudPrintInterfacePrinterFailedDetail } */ (
event.detail);
if (this.autoSelectMatchingDestination_ && if (this.autoSelectMatchingDestination_ &&
this.autoSelectMatchingDestination_.matchIdAndOrigin( this.autoSelectMatchingDestination_.matchIdAndOrigin(
event.destinationId, event.destinationOrigin)) { eventDetail.destinationId, eventDetail.origin)) {
console.error( console.error(
'Failed to fetch last used printer caps: ' + event.destinationId); 'Failed to fetch last used printer caps: ' +
eventDetail.destinationId);
this.selectDefaultDestination_(); this.selectDefaultDestination_();
} }
} }
/** /**
* Called when printer sharing invitation was processed successfully. * Called when printer sharing invitation was processed successfully.
* @param {Event} event Contains detailed information about the invite and * @param {!CustomEvent} event Contains detailed information about the
* newly accepted destination (if known). * invite and newly accepted destination (if known).
* @private * @private
*/ */
onCloudPrintProcessInviteDone_(event) { onCloudPrintProcessInviteDone_(event) {
if (event.accept && event.printer) { if (event.detail.accept && event.detail.printer) {
// Hint the destination list to promote this new destination. this.insertDestination_(event.detail.printer);
event.printer.isRecent = true;
this.insertDestination_(event.printer);
} }
} }
......
...@@ -96,15 +96,11 @@ cr.define('print_preview', function() { ...@@ -96,15 +96,11 @@ cr.define('print_preview', function() {
this.tracker_.add( this.tracker_.add(
this.cloudPrintInterface_.getEventTarget(), this.cloudPrintInterface_.getEventTarget(),
cloudprint.CloudPrintInterfaceEventType.INVITES_FAILED, cloudprint.CloudPrintInterfaceEventType.INVITES_FAILED,
this.onCloudPrintInvitesDone_.bind(this)); this.onCloudPrintInvitesFailed_.bind(this));
this.tracker_.add( this.tracker_.add(
this.cloudPrintInterface_.getEventTarget(), this.cloudPrintInterface_.getEventTarget(),
cloudprint.CloudPrintInterfaceEventType.PROCESS_INVITE_DONE, cloudprint.CloudPrintInterfaceEventType.PROCESS_INVITE_DONE,
this.onCloudPrintProcessInviteDone_.bind(this)); this.onCloudPrintProcessInviteDone_.bind(this));
this.tracker_.add(
this.cloudPrintInterface_.getEventTarget(),
cloudprint.CloudPrintInterfaceEventType.PROCESS_INVITE_FAILED,
this.onCloudPrintProcessInviteFailed_.bind(this));
} }
/** Initiates loading of cloud printer sharing invitations. */ /** Initiates loading of cloud printer sharing invitations. */
...@@ -118,8 +114,8 @@ cr.define('print_preview', function() { ...@@ -118,8 +114,8 @@ cr.define('print_preview', function() {
if (this.loadStatus_.hasOwnProperty(this.userInfo_.activeUser)) { if (this.loadStatus_.hasOwnProperty(this.userInfo_.activeUser)) {
if (this.loadStatus_[this.userInfo_.activeUser] == if (this.loadStatus_[this.userInfo_.activeUser] ==
print_preview.InvitationStoreLoadStatus.DONE) { print_preview.InvitationStoreLoadStatus.DONE) {
cr.dispatchSimpleEvent( this.dispatchEvent(new CustomEvent(
this, InvitationStore.EventType.INVITATION_SEARCH_DONE); InvitationStore.EventType.INVITATION_SEARCH_DONE));
} }
return; return;
} }
...@@ -161,54 +157,44 @@ cr.define('print_preview', function() { ...@@ -161,54 +157,44 @@ cr.define('print_preview', function() {
/** /**
* Called when printer sharing invitations are fetched. * Called when printer sharing invitations are fetched.
* @param {!cloudprint.CloudPrintInterfaceInvitesDoneEvent} event Contains * @param {!CustomEvent} event Contains the list of invitations.
* the list of invitations.
* @private * @private
*/ */
onCloudPrintInvitesDone_(event) { onCloudPrintInvitesDone_(event) {
this.loadStatus_[event.user] = const invitesDoneDetail =
/** @type {!cloudprint.CloudPrintInterfaceInvitesDoneDetail} */ (
event.detail);
this.loadStatus_[invitesDoneDetail.user] =
print_preview.InvitationStoreLoadStatus.DONE; print_preview.InvitationStoreLoadStatus.DONE;
this.invitations_[event.user] = event.invitations; this.invitations_[invitesDoneDetail.user] = invitesDoneDetail.invitations;
cr.dispatchSimpleEvent( this.dispatchEvent(
this, InvitationStore.EventType.INVITATION_SEARCH_DONE); new CustomEvent(InvitationStore.EventType.INVITATION_SEARCH_DONE));
} }
/** /**
* Called when printer sharing invitations fetch has failed. * Called when printer sharing invitations fetch has failed.
* @param {!cloudprint.CloudPrintInterfaceInvitesFailedEvent} event * @param {!CustomEvent} event
* @private * @private
*/ */
onCloudPrintInvitesFailed_(event) { onCloudPrintInvitesFailed_(event) {
this.loadStatus_[event.user] = this.loadStatus_[/** @type {string} */ (event.detail)] =
print_preview.InvitationStoreLoadStatus.FAILED; print_preview.InvitationStoreLoadStatus.FAILED;
} }
/** /**
* Called when printer sharing invitation was processed successfully. * Called when printer sharing invitation was processed successfully.
* @param {!cloudprint.CloudPrintInterfaceProcessInviteEvent} event * @param {!CustomEvent} event Contains detailed information about the
* Contains detailed information about the invite and newly accepted * invite.
* destination.
* @private * @private
*/ */
onCloudPrintProcessInviteDone_(event) { onCloudPrintProcessInviteDone_(event) {
this.invitationProcessed_(event.invitation); this.invitationProcessed_(
cr.dispatchSimpleEvent( /** @type {!cloudprint.CloudPrintInterfaceProcessInviteDetail} */ (
this, InvitationStore.EventType.INVITATION_PROCESSED); event.detail)
} .invitation);
this.dispatchEvent(
/** new CustomEvent(InvitationStore.EventType.INVITATION_PROCESSED));
* Called when /printer call completes. Updates the specified destination's
* print capabilities.
* @param {!cloudprint.CloudPrintInterfaceProcessInviteEvent} event
* Contains detailed information about the invite and destination.
* @private
*/
onCloudPrintProcessInviteFailed_(event) {
this.invitationProcessed_(event.invitation);
// TODO: Display an error.
cr.dispatchSimpleEvent(
this, InvitationStore.EventType.INVITATION_PROCESSED);
} }
} }
......
...@@ -604,26 +604,29 @@ Polymer({ ...@@ -604,26 +604,29 @@ Polymer({
/** /**
* Called when there was an error communicating with Google Cloud print. * Called when there was an error communicating with Google Cloud print.
* Displays an error message in the print header. * Displays an error message in the print header.
* @param {!Event} event Contains the error message. * @param {!CustomEvent} event Contains the error message.
* @private * @private
*/ */
onCloudPrintError_: function(event) { onCloudPrintError_: function(event) {
if (event.status == 0) { if (event.detail.status == 0) {
return; // Ignore, the system does not have internet connectivity. return; // Ignore, the system does not have internet connectivity.
} }
if (event.status == 403) { if (event.detail.status == 403) {
if (!this.isInAppKioskMode_) { if (!this.isInAppKioskMode_) {
this.$.destinationSettings.showCloudPrintPromo(); this.$.destinationSettings.showCloudPrintPromo();
} }
} else { } else {
this.errorMessage_ = event.message; this.errorMessage_ = event.detail.message;
this.$.state.transitTo(print_preview_new.State.FATAL_ERROR); this.$.state.transitTo(print_preview_new.State.FATAL_ERROR);
} }
if (event.status == 200) { if (event.detail.status == 200) {
console.error( console.error(
`Google Cloud Print Error: (${event.errorCode}) ${event.message}`); 'Google Cloud Print Error: ' +
`(${event.detail.errorCode}) ${event.detail.message}`);
} else { } else {
console.error(`Google Cloud Print Error: HTTP status ${event.status}`); console.error(
'Google Cloud Print Error: ' +
`HTTP status ${event.detail.status}`);
} }
}, },
......
...@@ -45,16 +45,19 @@ cr.define('print_preview', function() { ...@@ -45,16 +45,19 @@ cr.define('print_preview', function() {
*/ */
search() { search() {
this.searchInProgress_ = true; this.searchInProgress_ = true;
const printers = [];
this.cloudPrintersMap_.forEach((value) => printers.push(value));
const searchDoneEvent = const searchDoneEvent =
new Event(cloudprint.CloudPrintInterfaceEventType.SEARCH_DONE); new CustomEvent(cloudprint.CloudPrintInterfaceEventType.SEARCH_DONE, {
searchDoneEvent.origin = print_preview.DestinationOrigin.COOKIES; detail: {
searchDoneEvent.printers = []; origin: print_preview.DestinationOrigin.COOKIES,
this.cloudPrintersMap_.forEach((value) => { printers: printers,
searchDoneEvent.printers.push(value); isRecent: true,
}); user: 'foo@chromium.org',
searchDoneEvent.isRecent = true; searchDone: true,
searchDoneEvent.user = 'foo@chromium.org'; }
searchDoneEvent.searchDone = true; });
this.searchInProgress_ = false; this.searchInProgress_ = false;
this.eventTarget_.dispatchEvent(searchDoneEvent); this.eventTarget_.dispatchEvent(searchDoneEvent);
} }
...@@ -70,12 +73,11 @@ cr.define('print_preview', function() { ...@@ -70,12 +73,11 @@ cr.define('print_preview', function() {
printer(printerId, origin, account) { printer(printerId, origin, account) {
const printer = this.cloudPrintersMap_.get(printerId); const printer = this.cloudPrintersMap_.get(printerId);
if (!!printer) { if (!!printer) {
const printerDoneEvent = printer.capabilities =
new Event(cloudprint.CloudPrintInterfaceEventType.PRINTER_DONE);
printerDoneEvent.printer = printer;
printerDoneEvent.printer.capabilities =
print_preview_test_utils.getCddTemplate(printerId); print_preview_test_utils.getCddTemplate(printerId);
this.eventTarget_.dispatchEvent(printerDoneEvent); this.eventTarget_.dispatchEvent(new CustomEvent(
cloudprint.CloudPrintInterfaceEventType.PRINTER_DONE,
{detail: printer}));
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment