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

Issue 2780433002: add print to pdf for headless (Closed)

Created:
3 years, 9 months ago by jzfeng
Modified:
3 years, 8 months ago
CC:
chromium-reviews, devtools-reviews_chromium.org, dvallet, pfeldman
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

Let users to print a webpage into pdf through PrintToPDF devtools command under headless chrome. This patch includes: 1) adding a new print manager, i.e., HeadlessPrintManager to handle all the printing related IPCs for headless. 2) plumbing through the pdf data from HeadlessPrintManager to HeadlessDevToolsManagerDelegate to handle the PrintToPDF command. 3) adding a new option to PrintWebViewHelper on Mac to return all the printed pages in the first PrintHostMsg_DidPrintPage message as a single file. This makes it conform to Linux and Windows, which simplify the logic in HeadlessPrintManager. This patch guarantees that HeadlessPrintManager is the only IPC entry point. In the future, if there are requirements to support the same devtools command in regular chrome, we may consider a framework to ensure multiple print managers to work properly under a content embedder. BUG=603559 Review-Url: https://codereview.chromium.org/2780433002 Cr-Commit-Position: refs/heads/master@{#463105} Committed: https://chromium.googlesource.com/chromium/src/+/0cbec8b353f24515cc77a67ee95addc4f7a714ab

Patch Set 1 #

Total comments: 54

Patch Set 2 : fix lint and style errors #

Total comments: 48

Patch Set 3 : fix style #

Patch Set 4 : test mac #

Patch Set 5 : add new option for mac #

Total comments: 2

Patch Set 6 : fix mac page setting #

Total comments: 24

Patch Set 7 : polish code #

Patch Set 8 : fix typo #

Total comments: 6

Patch Set 9 : add more comment and error handle protection #

Total comments: 1

Patch Set 10 : improve comments as suggested #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+685 lines, -78 lines) Patch
M build/args/headless.gn View 1 chunk +0 lines, -1 line 0 comments Download
M components/printing/renderer/print_web_view_helper.h View 1 2 3 4 5 6 7 8 9 2 chunks +12 lines, -2 lines 0 comments Download
M components/printing/renderer/print_web_view_helper.cc View 1 2 3 4 5 6 1 chunk +6 lines, -0 lines 0 comments Download
M components/printing/renderer/print_web_view_helper_mac.mm View 1 2 3 4 5 6 2 chunks +19 lines, -10 lines 2 comments Download
M content/public/browser/devtools_manager_delegate.h View 1 2 1 chunk +3 lines, -1 line 0 comments Download
M content/public/browser/devtools_manager_delegate.cc View 1 1 chunk +4 lines, -3 lines 0 comments Download
M headless/BUILD.gn View 1 2 3 4 5 6 3 chunks +8 lines, -0 lines 0 comments Download
M headless/app/headless_shell.h View 1 2 5 chunks +29 lines, -16 lines 0 comments Download
M headless/app/headless_shell.cc View 1 2 3 4 5 5 chunks +78 lines, -39 lines 0 comments Download
M headless/app/headless_shell_switches.h View 1 chunk +1 line, -0 lines 0 comments Download
M headless/app/headless_shell_switches.cc View 1 chunk +3 lines, -0 lines 0 comments Download
M headless/lib/browser/DEPS View 1 1 chunk +3 lines, -0 lines 0 comments Download
M headless/lib/browser/headless_devtools_manager_delegate.h View 1 2 3 3 chunks +13 lines, -0 lines 0 comments Download
M headless/lib/browser/headless_devtools_manager_delegate.cc View 1 2 3 7 chunks +64 lines, -5 lines 0 comments Download
A headless/lib/browser/headless_print_manager.h View 1 2 3 1 chunk +79 lines, -0 lines 0 comments Download
A headless/lib/browser/headless_print_manager.cc View 1 2 3 4 5 6 7 8 1 chunk +217 lines, -0 lines 0 comments Download
M headless/lib/browser/headless_web_contents_impl.cc View 1 2 3 4 5 6 3 chunks +3 lines, -0 lines 0 comments Download
M headless/lib/headless_content_main_delegate.h View 1 2 3 chunks +3 lines, -0 lines 0 comments Download
M headless/lib/headless_content_main_delegate.cc View 1 2 3 4 5 6 3 chunks +11 lines, -1 line 0 comments Download
A headless/lib/renderer/DEPS View 1 chunk +5 lines, -0 lines 0 comments Download
A headless/lib/renderer/headless_content_renderer_client.h View 1 2 1 chunk +25 lines, -0 lines 0 comments Download
A headless/lib/renderer/headless_content_renderer_client.cc View 1 2 1 chunk +23 lines, -0 lines 0 comments Download
A headless/lib/renderer/headless_print_web_view_helper_delegate.h View 1 2 3 1 chunk +32 lines, -0 lines 0 comments Download
A headless/lib/renderer/headless_print_web_view_helper_delegate.cc View 1 2 3 1 chunk +44 lines, -0 lines 0 comments Download

Messages

Total messages: 69 (28 generated)
jzfeng
This is a proto type that only works on linux. PTAL.
3 years, 9 months ago (2017-03-27 07:03:51 UTC) #3
jzfeng
Hi Lei, Could you take some time to read and give some high level comments? ...
3 years, 8 months ago (2017-03-28 23:01:09 UTC) #4
Lei Zhang
On 2017/03/28 23:01:09, jzfeng wrote: > Hi Lei, > > Could you take some time ...
3 years, 8 months ago (2017-03-28 23:12:12 UTC) #5
Lei Zhang
This is much more straight-forward. My main concern is about getting browser / renderer separation ...
3 years, 8 months ago (2017-03-29 01:38:04 UTC) #6
jzfeng
Thanks for the review! I'm setting up my windows and mac machine for development. Eric, ...
3 years, 8 months ago (2017-03-29 03:50:14 UTC) #8
Lei Zhang
https://codereview.chromium.org/2780433002/diff/1/headless/BUILD.gn File headless/BUILD.gn (right): https://codereview.chromium.org/2780433002/diff/1/headless/BUILD.gn#newcode299 headless/BUILD.gn:299: "//components/printing/browser", On 2017/03/29 03:50:12, jzfeng wrote: > On 2017/03/29 ...
3 years, 8 months ago (2017-03-29 05:30:16 UTC) #9
Eric Seckler
https://codereview.chromium.org/2780433002/diff/1/headless/BUILD.gn File headless/BUILD.gn (right): https://codereview.chromium.org/2780433002/diff/1/headless/BUILD.gn#newcode299 headless/BUILD.gn:299: "//components/printing/browser", On 2017/03/29 05:30:15, Lei Zhang wrote: > On ...
3 years, 8 months ago (2017-03-29 11:21:20 UTC) #10
jzfeng
Thanks for the review! I will 1) keep working to make it work on windows ...
3 years, 8 months ago (2017-03-30 03:04:57 UTC) #11
jzfeng
https://codereview.chromium.org/2780433002/diff/1/headless/BUILD.gn File headless/BUILD.gn (right): https://codereview.chromium.org/2780433002/diff/1/headless/BUILD.gn#newcode299 headless/BUILD.gn:299: "//components/printing/browser", On 2017/03/30 at 03:04:56, jzfeng wrote: > On ...
3 years, 8 months ago (2017-03-30 03:20:13 UTC) #12
Lei Zhang
If we added a runtime option for the renderer on Mac to select between: a) ...
3 years, 8 months ago (2017-03-30 06:06:17 UTC) #13
Eric Seckler
On 2017/03/30 06:06:17, Lei Zhang wrote: > If we added a runtime option for the ...
3 years, 8 months ago (2017-03-30 06:33:42 UTC) #14
Lei Zhang
On 2017/03/30 06:33:42, Eric Seckler wrote: > Yeah, I think not having to deal with ...
3 years, 8 months ago (2017-03-30 06:37:43 UTC) #15
jzfeng
On 2017/03/30 at 06:37:43, thestig wrote: > On 2017/03/30 06:33:42, Eric Seckler wrote: > > ...
3 years, 8 months ago (2017-03-30 06:43:37 UTC) #16
Eric Seckler
On 2017/03/30 06:43:37, jzfeng wrote: > On 2017/03/30 at 06:37:43, thestig wrote: > > On ...
3 years, 8 months ago (2017-03-30 06:59:37 UTC) #17
jzfeng
Added the option to let mac return all pages PDF in the first PrintHostMsg_DidPrintPage. I ...
3 years, 8 months ago (2017-04-03 09:47:38 UTC) #18
Eric Seckler
lgtm % comment below. Btw, please also reformat the patch description to be <72 chars ...
3 years, 8 months ago (2017-04-03 10:34:34 UTC) #19
jzfeng
Hi Lei, Would you mind take a look at the new changes, which added the ...
3 years, 8 months ago (2017-04-04 05:05:20 UTC) #25
jzfeng
Hi Lei, Do you have time to take a look at this patch? Thanks!
3 years, 8 months ago (2017-04-05 11:39:00 UTC) #26
Lei Zhang
On 2017/04/03 09:47:38, jzfeng wrote: > I tested it on mac. The pdf file is ...
3 years, 8 months ago (2017-04-06 07:38:38 UTC) #29
jzfeng
On 2017/04/06 at 07:38:38, thestig wrote: > On 2017/04/03 09:47:38, jzfeng wrote: > > I ...
3 years, 8 months ago (2017-04-06 07:43:51 UTC) #30
Eric Seckler
On 2017/04/06 07:43:51, jzfeng wrote: > Hi Lei, I have fixed the issue on mac. ...
3 years, 8 months ago (2017-04-06 07:52:35 UTC) #35
Lei Zhang
On 2017/04/06 07:38:38, Lei Zhang wrote: > On 2017/04/03 09:47:38, jzfeng wrote: > > I ...
3 years, 8 months ago (2017-04-06 07:52:56 UTC) #36
jzfeng
On 2017/04/06 at 07:52:56, thestig wrote: > On 2017/04/06 07:38:38, Lei Zhang wrote: > > ...
3 years, 8 months ago (2017-04-06 07:57:08 UTC) #37
Lei Zhang
https://codereview.chromium.org/2780433002/diff/20001/headless/lib/browser/headless_print_manager.cc File headless/lib/browser/headless_print_manager.cc (right): https://codereview.chromium.org/2780433002/diff/20001/headless/lib/browser/headless_print_manager.cc#newcode192 headless/lib/browser/headless_print_manager.cc:192: data_ = std::string(buffer.data(), buffer.size()); On 2017/03/29 11:21:19, Eric Seckler ...
3 years, 8 months ago (2017-04-06 08:08:42 UTC) #38
jzfeng
Thanks for the review! PTAL. https://codereview.chromium.org/2780433002/diff/100001/components/printing/renderer/print_web_view_helper.h File components/printing/renderer/print_web_view_helper.h (right): https://codereview.chromium.org/2780433002/diff/100001/components/printing/renderer/print_web_view_helper.h#newcode113 components/printing/renderer/print_web_view_helper.h:113: virtual bool UseSingleMetafile(); On ...
3 years, 8 months ago (2017-04-06 09:01:51 UTC) #39
Eric Seckler
https://codereview.chromium.org/2780433002/diff/100001/headless/lib/browser/headless_print_manager.cc File headless/lib/browser/headless_print_manager.cc (right): https://codereview.chromium.org/2780433002/diff/100001/headless/lib/browser/headless_print_manager.cc#newcode146 headless/lib/browser/headless_print_manager.cc:146: const PrintHostMsg_DidPrintPage_Params& params) { On 2017/04/06 09:01:51, jzfeng wrote: ...
3 years, 8 months ago (2017-04-06 09:14:26 UTC) #40
Lei Zhang
Getting close, so let's also talk about the commit message. It should make sense to ...
3 years, 8 months ago (2017-04-06 10:23:00 UTC) #41
Eric Seckler
https://codereview.chromium.org/2780433002/diff/140001/headless/lib/browser/headless_print_manager.cc File headless/lib/browser/headless_print_manager.cc (right): https://codereview.chromium.org/2780433002/diff/140001/headless/lib/browser/headless_print_manager.cc#newcode105 headless/lib/browser/headless_print_manager.cc:105: DCHECK(callback); On 2017/04/06 10:23:00, Lei Zhang wrote: > DCHECK ...
3 years, 8 months ago (2017-04-06 10:28:55 UTC) #42
Lei Zhang
https://codereview.chromium.org/2780433002/diff/140001/headless/lib/browser/headless_print_manager.cc File headless/lib/browser/headless_print_manager.cc (right): https://codereview.chromium.org/2780433002/diff/140001/headless/lib/browser/headless_print_manager.cc#newcode105 headless/lib/browser/headless_print_manager.cc:105: DCHECK(callback); On 2017/04/06 10:28:55, Eric Seckler wrote: > This ...
3 years, 8 months ago (2017-04-06 10:46:40 UTC) #43
Lei Zhang
+weili: Does this help or hinder OOPIF printing?
3 years, 8 months ago (2017-04-06 21:09:37 UTC) #44
Wei Li
On 2017/04/06 21:09:37, Lei Zhang wrote: > +weili: Does this help or hinder OOPIF printing? ...
3 years, 8 months ago (2017-04-06 23:11:23 UTC) #49
jzfeng
Thanks for the review! I have rewrite the commit message. It should be easier to ...
3 years, 8 months ago (2017-04-07 03:24:06 UTC) #52
Lei Zhang
lgtm https://codereview.chromium.org/2780433002/diff/160001/components/printing/renderer/print_web_view_helper.h File components/printing/renderer/print_web_view_helper.h (right): https://codereview.chromium.org/2780433002/diff/160001/components/printing/renderer/print_web_view_helper.h#newcode115 components/printing/renderer/print_web_view_helper.h:115: // NOTE: This option only returns one set ...
3 years, 8 months ago (2017-04-07 04:09:43 UTC) #53
jzfeng
On 2017/04/07 at 04:09:43, thestig wrote: > lgtm > > https://codereview.chromium.org/2780433002/diff/160001/components/printing/renderer/print_web_view_helper.h > File components/printing/renderer/print_web_view_helper.h (right): ...
3 years, 8 months ago (2017-04-07 04:38:19 UTC) #56
Dirk Pranke
//build lgtm.
3 years, 8 months ago (2017-04-07 18:23:58 UTC) #57
pfeldman
content lgtm
3 years, 8 months ago (2017-04-07 23:28:10 UTC) #58
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2780433002/180001
3 years, 8 months ago (2017-04-07 23:36:20 UTC) #61
commit-bot: I haz the power
Committed patchset #10 (id:180001) as https://chromium.googlesource.com/chromium/src/+/0cbec8b353f24515cc77a67ee95addc4f7a714ab
3 years, 8 months ago (2017-04-08 02:00:04 UTC) #64
hal.canary
https://codereview.chromium.org/2780433002/diff/180001/components/printing/renderer/print_web_view_helper_mac.mm File components/printing/renderer/print_web_view_helper_mac.mm (right): https://codereview.chromium.org/2780433002/diff/180001/components/printing/renderer/print_web_view_helper_mac.mm#newcode76 components/printing/renderer/print_web_view_helper_mac.mm:76: page_params.metafile_data_handle = base::SharedMemoryHandle(); What does line 76 do here? ...
3 years, 8 months ago (2017-04-24 20:07:54 UTC) #66
Lei Zhang
Also, why is there a patch set 11 when commit-bot landed patch set 10? https://codereview.chromium.org/2780433002/diff/180001/components/printing/renderer/print_web_view_helper_mac.mm ...
3 years, 8 months ago (2017-04-24 21:30:05 UTC) #67
jzfeng
3 years, 8 months ago (2017-04-24 22:48:46 UTC) #69
Message was sent while issue was closed.
On 2017/04/24 at 21:30:05, thestig wrote:
> Also, why is there a patch set 11 when commit-bot landed patch set 10?

I kept using the same git branch and did a git cl upload, without noticing it
would upload a new patch to this CL. 
Deleted patch 11.

Powered by Google App Engine
This is Rietveld 408576698