-
Notifications
You must be signed in to change notification settings - Fork 16.2k
fix: callback values for printing cancellation and success #17400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hi, Is this PR ready for merge or should you do some more works ? Can I help ? p.s. I think your should remove the "wip" label. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me though I think @deepak1556 should weigh in on this one.
Also, a rebase should resolve the CircleCI issue on the Linux tests.
Hi @deepak1556 Do you have some time to review this small PR ? Huge thanks :) And is they any backport planned for electron 4.x.x ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested this, although the callback now gets triggered, it doesn't get invoked until app quits or page navigates. Needs further investigation.
b752a08
to
e732655
Compare
DCHECK(query); | ||
|
||
- // Disconnect the current |print_job_|. | ||
- DisconnectFromCurrentPrintJob(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't want to call this twice, since it prevents printing_succeeded_
from ever being set to true and thus causes #17265
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@codebytere thanks for your works ! And I hope that we could use this fix soon ;) Is there any backport to 4.x.x planned ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, with some changes.
- case JobEventDetails::USER_INIT_DONE: | ||
- case JobEventDetails::DEFAULT_INIT_DONE: | ||
case JobEventDetails::USER_INIT_CANCELED: { | ||
+ ReleasePrintJob(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't it be better to call TerminatePrintJob
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both should work! either way the callback is called with false
:)
DCHECK(query); | ||
|
||
- // Disconnect the current |print_job_|. | ||
- DisconnectFromCurrentPrintJob(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whats the reason behind this change ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DCHECK(!print_job_); | ||
print_job_ = base::MakeRefCounted<PrintJob>(); | ||
print_job_->Initialize(query, RenderSourceName(), number_pages_); | ||
- registrar_.Add(this, chrome::NOTIFICATION_PRINT_JOB_EVENT, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why change the registrar source ? The notification from PrintJobWorker
posts in on print_job_
, so it will be received by PrintViewManagerBase
who is listening on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I am against the idea of using chrome notification observer for all sources on an object that may never be created, its not straightforward to get the response from acquiring print settings back to the user. This needs a refactor which reuses the print preview code to handle printing, which is better to be done as a follow up.
Release Notes Persisted
|
I was unable to backport this PR to "6-0-x" cleanly; |
I was unable to backport this PR to "5-0-x" cleanly; |
Description of Change
Resolves #17265.
Resolves #16085.
Callback
false
when disconnecting from the print job if the current printing job has not completed, andtrue
if printing is triggered successfully.cc @deepak1556 @jkleinsc
Checklist
npm test
passesRelease Notes
Notes: Fixed
webContents.print()
callback not returning boolean correctly in all cases.