Implement 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
Review URL: https://codereview.chromium.org/
740983002
Cr-Commit-Position: refs/heads/master@{#308416}