Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Issue 740983002: Implement window.print() on Android (Closed)

Created:
6 years, 1 month ago by dgn
Modified:
6 years ago
CC:
mlamouri (slow - plz ping), sgurun-gerrit only, chromium-reviews
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Project:
chromium
Visibility:
Public.

Description

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 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 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+207 lines, -33 lines) Patch
M chrome/android/java/src/org/chromium/chrome/browser/Tab.java View 1 2 3 4 5 6 7 8 9 10 11 12 3 chunks +13 lines, -0 lines 0 comments Download
M chrome/browser/android/tab_android.h View 1 2 3 4 5 6 7 1 chunk +4 lines, -0 lines 0 comments Download
M chrome/browser/android/tab_android.cc View 1 2 3 4 5 6 7 1 chunk +5 lines, -0 lines 0 comments Download
M chrome/browser/printing/print_job_worker.h View 1 2 3 4 5 6 7 8 9 10 3 chunks +6 lines, -2 lines 0 comments Download
M chrome/browser/printing/print_job_worker.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 4 chunks +28 lines, -3 lines 0 comments Download
M chrome/browser/printing/printer_query.h View 1 2 3 4 5 6 7 8 9 2 chunks +2 lines, -1 line 0 comments Download
M chrome/browser/printing/printer_query.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +6 lines, -3 lines 0 comments Download
M chrome/browser/printing/printing_message_filter.cc View 1 2 3 4 5 6 7 8 9 10 3 chunks +5 lines, -2 lines 0 comments Download
M chrome/common/print_messages.h View 1 2 3 4 5 6 7 8 9 1 chunk +3 lines, -0 lines 0 comments Download
M chrome/renderer/printing/print_web_view_helper.h View 1 2 3 4 5 6 7 8 9 10 2 chunks +6 lines, -2 lines 0 comments Download
M chrome/renderer/printing/print_web_view_helper.cc View 1 2 3 4 5 6 7 8 9 10 9 chunks +11 lines, -10 lines 0 comments Download
M printing/android/java/src/org/chromium/printing/PrintingContext.java View 1 2 3 4 5 6 7 8 9 10 11 12 2 chunks +18 lines, -0 lines 0 comments Download
M printing/android/java/src/org/chromium/printing/PrintingContextInterface.java View 1 2 1 chunk +6 lines, -0 lines 0 comments Download
M printing/android/java/src/org/chromium/printing/PrintingController.java View 1 2 3 4 5 6 7 8 9 10 11 12 13 2 chunks +22 lines, -1 line 0 comments Download
M printing/android/java/src/org/chromium/printing/PrintingControllerImpl.java View 1 2 3 4 5 6 5 chunks +37 lines, -3 lines 0 comments Download
M printing/printing_context.h View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +4 lines, -0 lines 0 comments Download
M printing/printing_context_android.h View 1 2 3 4 5 6 7 8 9 2 chunks +5 lines, -2 lines 0 comments Download
M printing/printing_context_android.cc View 1 2 3 4 5 6 7 8 9 10 11 12 3 chunks +14 lines, -3 lines 0 comments Download
M printing/printing_context_linux.h View 1 2 3 4 5 6 7 8 9 1 chunk +1 line, -0 lines 0 comments Download
M printing/printing_context_linux.cc View 1 2 3 4 5 6 7 8 9 1 chunk +1 line, -0 lines 0 comments Download
M printing/printing_context_mac.h View 1 2 3 4 5 6 7 8 9 1 chunk +1 line, -0 lines 0 comments Download
M printing/printing_context_mac.mm View 1 2 3 4 5 6 7 8 9 1 chunk +1 line, -0 lines 0 comments Download
M printing/printing_context_no_system_dialog.h View 1 2 3 4 5 6 7 8 9 1 chunk +1 line, -0 lines 0 comments Download
M printing/printing_context_no_system_dialog.cc View 1 2 3 4 5 6 7 8 9 1 chunk +1 line, -0 lines 0 comments Download
M printing/printing_context_system_dialog_win.h View 1 2 3 4 5 6 7 8 9 1 chunk +1 line, -0 lines 0 comments Download
M printing/printing_context_system_dialog_win.cc View 1 2 3 4 5 6 7 8 9 1 chunk +1 line, -0 lines 0 comments Download
M printing/printing_context_win.h View 1 2 3 4 5 6 7 8 9 1 chunk +1 line, -0 lines 0 comments Download
M printing/printing_context_win.cc View 1 2 3 4 5 6 7 8 9 10 2 chunks +2 lines, -1 line 0 comments Download
M printing/printing_context_win_unittest.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 51 (10 generated)
dgn
I have trouble finding the right place call Send(reply_msg) at the right time. I'm trying ...
6 years, 1 month ago (2014-11-20 12:26:16 UTC) #2
Vitaly Buka (NO REVIEWS)
https://codereview.chromium.org/740983002/diff/1/chrome/browser/printing/printing_message_filter.cc File chrome/browser/printing/printing_message_filter.cc (right): https://codereview.chromium.org/740983002/diff/1/chrome/browser/printing/printing_message_filter.cc#newcode134 chrome/browser/printing/printing_message_filter.cc:134: IPC_MESSAGE_HANDLER_DELAY_REPLY(PrintHostMsg_InitiateAndroidPrint, don't need new message https://codereview.chromium.org/740983002/diff/1/chrome/browser/printing/printing_message_filter.cc#newcode334 chrome/browser/printing/printing_message_filter.cc:334: printer_query->GetSettings( Here ...
6 years, 1 month ago (2014-11-21 17:05:13 UTC) #5
dgn
It suspect that the path of least resistance would be to use the print preview ...
6 years ago (2014-11-25 17:07:43 UTC) #6
Vitaly Buka (NO REVIEWS)
On 2014/11/25 17:07:43, dgn wrote: > It suspect that the path of least resistance would ...
6 years ago (2014-11-25 19:08:25 UTC) #7
dgn
dcheng@chromium.org: Please review changes in chrome/common/print_messages.h
6 years ago (2014-11-26 16:32:03 UTC) #9
dcheng
Sorry, it's a bit difficult for me to review. The message filter implementation has commented ...
6 years ago (2014-11-26 19:00:53 UTC) #10
dgn
The patch should be in a good state for a review now. I left some ...
6 years ago (2014-11-27 18:55:44 UTC) #11
mlamouri (slow - plz ping)
I did a very superficial review because I have a hard time to understand the ...
6 years ago (2014-11-27 20:26:02 UTC) #13
dgn
Updated the description to give more context about the changes. https://codereview.chromium.org/740983002/diff/100001/chrome/android/java/src/org/chromium/chrome/browser/Tab.java File chrome/android/java/src/org/chromium/chrome/browser/Tab.java (right): https://codereview.chromium.org/740983002/diff/100001/chrome/android/java/src/org/chromium/chrome/browser/Tab.java#newcode564 ...
6 years ago (2014-11-28 11:51:15 UTC) #14
dgn
PTAL thestig@, vitalybuka@: The current changes are working are expected on L and JB. Can ...
6 years ago (2014-12-02 11:01:15 UTC) #15
Vitaly Buka (NO REVIEWS)
On 2014/12/02 11:01:15, dgn wrote: > PTAL > > thestig@, vitalybuka@: The current changes are ...
6 years ago (2014-12-09 23:22:21 UTC) #16
Vitaly Buka (NO REVIEWS)
https://codereview.chromium.org/740983002/diff/120001/chrome/browser/printing/print_job_worker.cc File chrome/browser/printing/print_job_worker.cc (right): https://codereview.chromium.org/740983002/diff/120001/chrome/browser/printing/print_job_worker.cc#newcode15 chrome/browser/printing/print_job_worker.cc:15: #include "chrome/browser/android/tab_android.h" put conditional includes after the main section ...
6 years ago (2014-12-09 23:46:49 UTC) #17
dgn
https://codereview.chromium.org/740983002/diff/120001/chrome/browser/printing/print_job_worker.cc File chrome/browser/printing/print_job_worker.cc (right): https://codereview.chromium.org/740983002/diff/120001/chrome/browser/printing/print_job_worker.cc#newcode15 chrome/browser/printing/print_job_worker.cc:15: #include "chrome/browser/android/tab_android.h" On 2014/12/09 23:46:48, Vitaly Buka wrote: > ...
6 years ago (2014-12-10 18:12:52 UTC) #18
dgn
dcheng@: Could you please do an IPC review? relevant files would be print_messages.h, printing_message_filter.cc and ...
6 years ago (2014-12-10 18:17:47 UTC) #19
Vitaly Buka (NO REVIEWS)
https://codereview.chromium.org/740983002/diff/140001/chrome/browser/printing/printing_message_filter.cc File chrome/browser/printing/printing_message_filter.cc (right): https://codereview.chromium.org/740983002/diff/140001/chrome/browser/printing/printing_message_filter.cc#newcode330 chrome/browser/printing/printing_message_filter.cc:330: ask_param = PrinterQuery::GetSettingsAskParam::SYSTEM_SPECIFIC; here we know if it's android ...
6 years ago (2014-12-10 19:32:22 UTC) #20
dgn
https://codereview.chromium.org/740983002/diff/140001/chrome/browser/printing/printing_message_filter.cc File chrome/browser/printing/printing_message_filter.cc (right): https://codereview.chromium.org/740983002/diff/140001/chrome/browser/printing/printing_message_filter.cc#newcode330 chrome/browser/printing/printing_message_filter.cc:330: ask_param = PrinterQuery::GetSettingsAskParam::SYSTEM_SPECIFIC; On 2014/12/10 19:32:21, Vitaly Buka wrote: ...
6 years ago (2014-12-11 10:06:19 UTC) #22
Vitaly Buka (NO REVIEWS)
https://codereview.chromium.org/740983002/diff/160001/chrome/android/java/src/org/chromium/chrome/browser/Tab.java File chrome/android/java/src/org/chromium/chrome/browser/Tab.java (right): https://codereview.chromium.org/740983002/diff/160001/chrome/android/java/src/org/chromium/chrome/browser/Tab.java#newcode607 chrome/android/java/src/org/chromium/chrome/browser/Tab.java:607: public void setPendingPrint() { maybe scriptedPrint() ? https://codereview.chromium.org/740983002/diff/160001/chrome/browser/printing/print_job_worker.cc File ...
6 years ago (2014-12-12 08:37:17 UTC) #23
dgn
I'm currently implementing these changes. To summarize, I was trying to avoid getting into functions ...
6 years ago (2014-12-12 16:49:44 UTC) #24
Vitaly Buka (NO REVIEWS)
On 2014/12/12 16:49:44, dgn wrote: > I'm currently implementing these changes. To summarize, I was ...
6 years ago (2014-12-12 17:26:27 UTC) #25
Vitaly Buka (NO REVIEWS)
On 2014/12/12 16:49:44, dgn wrote: > I'm currently implementing these changes. To summarize, I was ...
6 years ago (2014-12-12 17:31:22 UTC) #26
Vitaly Buka (NO REVIEWS)
> Actually OnPrintPages must have false, because you are not printing web page > there, ...
6 years ago (2014-12-12 17:36:42 UTC) #27
dgn
On 2014/12/12 17:36:42, Vitaly Buka wrote: > > Actually OnPrintPages must have false, because you ...
6 years ago (2014-12-12 17:47:35 UTC) #28
dgn
https://codereview.chromium.org/740983002/diff/160001/chrome/browser/printing/printing_message_filter.cc File chrome/browser/printing/printing_message_filter.cc (right): https://codereview.chromium.org/740983002/diff/160001/chrome/browser/printing/printing_message_filter.cc#newcode354 chrome/browser/printing/printing_message_filter.cc:354: if (printer_query->last_status() != PrintingContext::OK || Here, having something different ...
6 years ago (2014-12-12 17:47:44 UTC) #29
Vitaly Buka (NO REVIEWS)
https://codereview.chromium.org/740983002/diff/160001/chrome/browser/printing/printing_message_filter.cc File chrome/browser/printing/printing_message_filter.cc (right): https://codereview.chromium.org/740983002/diff/160001/chrome/browser/printing/printing_message_filter.cc#newcode364 chrome/browser/printing/printing_message_filter.cc:364: if (params.params.dpi && params.params.document_cookie) { On 2014/12/12 17:47:44, dgn ...
6 years ago (2014-12-12 18:41:07 UTC) #30
dgn
Looks like adding is_scripted to GetSettings will have tons of side effects.. https://codereview.chromium.org/740983002/diff/180001/chrome/browser/printing/printing_message_filter.cc File chrome/browser/printing/printing_message_filter.cc ...
6 years ago (2014-12-12 18:42:49 UTC) #31
Vitaly Buka (NO REVIEWS)
https://codereview.chromium.org/740983002/diff/180001/chrome/renderer/printing/print_web_view_helper.cc File chrome/renderer/printing/print_web_view_helper.cc (right): https://codereview.chromium.org/740983002/diff/180001/chrome/renderer/printing/print_web_view_helper.cc#newcode978 chrome/renderer/printing/print_web_view_helper.cc:978: void PrintWebViewHelper::OnPrintForSystemDialog() { On 2014/12/12 18:42:49, dgn wrote: > ...
6 years ago (2014-12-12 18:52:09 UTC) #32
Vitaly Buka (NO REVIEWS)
lgtm Thanks Nicolas. Please also ask to take a look someone with Android experience. https://codereview.chromium.org/740983002/diff/200001/printing/printing_context.h ...
6 years ago (2014-12-12 20:38:31 UTC) #33
dgn
Final review ready. dcheng@: Please review changes in print_message.h bauerb@: Please review changes in Tab.java, ...
6 years ago (2014-12-12 20:52:38 UTC) #35
Bernhard Bauer
Just some nits: https://codereview.chromium.org/740983002/diff/210001/chrome/android/java/src/org/chromium/chrome/browser/Tab.java File chrome/android/java/src/org/chromium/chrome/browser/Tab.java (right): https://codereview.chromium.org/740983002/diff/210001/chrome/android/java/src/org/chromium/chrome/browser/Tab.java#newcode610 chrome/android/java/src/org/chromium/chrome/browser/Tab.java:610: return; Either put everything on one ...
6 years ago (2014-12-15 09:38:02 UTC) #36
Bernhard Bauer
Also: did you remove chromium-reviews@chromium.org from the CC list, or is your git-cl misconfigured?
6 years ago (2014-12-15 09:40:51 UTC) #37
dgn
You're right, I forgot to add blink-reviews back. fixed now. https://codereview.chromium.org/740983002/diff/210001/chrome/android/java/src/org/chromium/chrome/browser/Tab.java File chrome/android/java/src/org/chromium/chrome/browser/Tab.java (right): https://codereview.chromium.org/740983002/diff/210001/chrome/android/java/src/org/chromium/chrome/browser/Tab.java#newcode610 ...
6 years ago (2014-12-15 10:27:06 UTC) #38
Bernhard Bauer
On 2014/12/15 10:27:06, dgn wrote: > You're right, I forgot to add blink-reviews back. fixed ...
6 years ago (2014-12-15 10:38:20 UTC) #39
Bernhard Bauer
https://codereview.chromium.org/740983002/diff/230001/chrome/browser/printing/print_job_worker.cc File chrome/browser/printing/print_job_worker.cc (right): https://codereview.chromium.org/740983002/diff/230001/chrome/browser/printing/print_job_worker.cc#newcode216 chrome/browser/printing/print_job_worker.cc:216: // does nothing and will notify that printing is ...
6 years ago (2014-12-15 10:44:59 UTC) #40
dgn
https://codereview.chromium.org/740983002/diff/230001/chrome/browser/printing/print_job_worker.cc File chrome/browser/printing/print_job_worker.cc (right): https://codereview.chromium.org/740983002/diff/230001/chrome/browser/printing/print_job_worker.cc#newcode216 chrome/browser/printing/print_job_worker.cc:216: // does nothing and will notify that printing is ...
6 years ago (2014-12-15 13:16:24 UTC) #41
Bernhard Bauer
LGTM!
6 years ago (2014-12-15 13:24:17 UTC) #42
jschuh
ipc security lgtm. notes: boolean identifying whether print event was triggered from script
6 years ago (2014-12-15 17:42:30 UTC) #43
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/740983002/250001
6 years ago (2014-12-15 17:44:52 UTC) #45
commit-bot: I haz the power
Try jobs failed on following builders: linux_chromium_asan_rel on tryserver.chromium.linux (http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_asan_rel/builds/18411)
6 years ago (2014-12-15 19:34:34 UTC) #47
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/740983002/250001
6 years ago (2014-12-15 20:10:53 UTC) #49
commit-bot: I haz the power
Committed patchset #14 (id:250001)
6 years ago (2014-12-15 21:11:42 UTC) #50
commit-bot: I haz the power
6 years ago (2014-12-15 21:12:28 UTC) #51
Message was sent while issue was closed.
Patchset 14 (id:??) landed as
https://crrev.com/4c172eea8b6649f1c1c620d1daa20ce733cee9e1
Cr-Commit-Position: refs/heads/master@{#308416}

Powered by Google App Engine
This is Rietveld 408576698