Fix keyboard focus on webpages after finishing window.print() with ESC.

This is another variant of the issue fixed by r637595. Instead of
pressing the cancel button in the Print Preview UI, users can press the
ESC key instead. In this case, the sequence of events is different, and
PrintPreviewDialogDelegate::OnDialogClosed() gets called too late.

To fix this, add ui::WebDialogDelegate::OnDialogClosingFromKeyEvent(),
and call it when the ConstrainedDialogWebView sees the ESC key being
pressed. In PrintPreviewDialogDelegate::OnDialogClosingFromKeyEvent(),
call OnDialogClosed() to properly unblock the webpage.

TEST=Manual, see bug.

Change-Id: I0640ee7da86d407965ba6c6bbe3bbb17accf2ed5
Reviewed-by: Avi Drissman <>
Commit-Queue: Lei Zhang <>
Cr-Commit-Position: refs/heads/master@{#640026}
3 files changed