With content analysis active, if a DLP agent pops up a dialog but allows
the print to happen (for example, when responding REPORT_ONLY), this can
cause ::StartDocW() to fail for "printer"s that pop open a dialog for the
user to choose where to save the file. (i.e. Microsoft Print to PDF)
After trying some various hacks, the one that worked was calling
SetForegroundWindow() on a Firefox window before calling ::StartDocW().
It even works if the Firefox window that we call SetForegroundWindow()
isn't the one that the print is happening in. (which I verified by starting
a print and then quickly clicking on another window)
I put this behind a pref just in case this causes problems in the future,
but I doubt it will.
I also reverted the previous attempt to fix this by calling
::LockSetForegroundWindow(), which does not work.
Original Revision: https://phabricator.services.mozilla.com/D261572
Differential Revision: https://phabricator.services.mozilla.com/D262385