DescriptionImplement window.print() on Android
Essentially wires up the window.print() and the basic printing path
to Android framwork's PrintManager.
The changes affect the basic printing path using
PrintingMessageFilter::OnScriptedPrint. When calling window.print() on
Android, it would now be called twice.
The first time is directly after the JS call, OnScriptedPrint is called
with a parameter telling it that it's being called from JS. It will then
end up calling PrintJobWorker::GetSettings, forwarding that information.
PrintJobWorker then takes care of calling PrintingController through JNI,
joining the same code path used when printing from chrome's menu in android:
Android framework's PrintManager is invoked, and it manages the preview, using
the tab to generate the output as the user changes his/her preferences.
Why so many changes for just that: the window.print() call is blocked until the
end of the process by message pumping. It has to be disabled when printing is
finished. It is currently done by setting a callback in the current
PrintingContext, that will be called when printing is done. PrintingController
stores the reference to it, but here we have two queries at the same time, and
only the latest PrintingContext would be stored. I added a field to store
separately the one coming from the initial call, so
that it can be used when printing is done to stop the message pumping.
TL;DR: When window.print() is called, the basic printing path is used to forward
the query to PrintManager. The PrintManager then uses almost the same path to
actually print the document (as previously implemented to power the 'Print...'
entry in the menu). The changes are mostly to ensure that JS returns when
printing is completed and not before (or never).
BUG=437338
Committed: https://crrev.com/4c172eea8b6649f1c1c620d1daa20ce733cee9e1
Cr-Commit-Position: refs/heads/master@{#308416}
Patch Set 1 #
Total comments: 14
Patch Set 2 : #
Total comments: 3
Patch Set 3 : working implementation #Patch Set 4 : typos, sorry #
Total comments: 2
Patch Set 5 : Cleanup, failure handling and linux compile fixes #Patch Set 6 : Handle printing disabled or not supported #
Total comments: 11
Patch Set 7 : Adressed mounir's comments #
Total comments: 11
Patch Set 8 : Nit fixes and split into 2 patches #
Total comments: 2
Patch Set 9 : rebase #
Total comments: 23
Patch Set 10 : WIP - removing enums and new methods #
Total comments: 4
Patch Set 11 : fix win compilation, values of is_scripted #
Total comments: 1
Patch Set 12 : reverted a comment #
Total comments: 12
Patch Set 13 : Fixed nits #
Total comments: 2
Patch Set 14 : #Messages
Total messages: 51 (10 generated)
|