OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <memory> | 5 #include <memory> |
6 #include <sstream> | 6 #include <sstream> |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 LOG(ERROR) << "Capture screenshot failed"; | 354 LOG(ERROR) << "Capture screenshot failed"; |
355 Shutdown(); | 355 Shutdown(); |
356 return; | 356 return; |
357 } | 357 } |
358 WriteFile(switches::kScreenshot, kDefaultScreenshotFileName, | 358 WriteFile(switches::kScreenshot, kDefaultScreenshotFileName, |
359 result->GetData()); | 359 result->GetData()); |
360 } | 360 } |
361 | 361 |
362 void HeadlessShell::PrintToPDF() { | 362 void HeadlessShell::PrintToPDF() { |
363 devtools_client_->GetPage()->GetExperimental()->PrintToPDF( | 363 devtools_client_->GetPage()->GetExperimental()->PrintToPDF( |
364 page::PrintToPDFParams::Builder().Build(), | 364 page::PrintToPDFParams::Builder() |
| 365 .SetDisplayHeaderFooter(true) |
| 366 .SetPrintBackground(true) |
| 367 .Build(), |
365 base::Bind(&HeadlessShell::OnPDFCreated, weak_factory_.GetWeakPtr())); | 368 base::Bind(&HeadlessShell::OnPDFCreated, weak_factory_.GetWeakPtr())); |
366 } | 369 } |
367 | 370 |
368 void HeadlessShell::OnPDFCreated( | 371 void HeadlessShell::OnPDFCreated( |
369 std::unique_ptr<page::PrintToPDFResult> result) { | 372 std::unique_ptr<page::PrintToPDFResult> result) { |
370 if (!result) { | 373 if (!result) { |
371 LOG(ERROR) << "Print to PDF failed"; | 374 LOG(ERROR) << "Print to PDF failed"; |
372 Shutdown(); | 375 Shutdown(); |
373 return; | 376 return; |
374 } | 377 } |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 if (net::HttpUtil::IsValidHeaderValue(ua)) | 622 if (net::HttpUtil::IsValidHeaderValue(ua)) |
620 builder.SetUserAgent(ua); | 623 builder.SetUserAgent(ua); |
621 } | 624 } |
622 | 625 |
623 return HeadlessBrowserMain( | 626 return HeadlessBrowserMain( |
624 builder.Build(), | 627 builder.Build(), |
625 base::Bind(&HeadlessShell::OnStart, base::Unretained(&shell))); | 628 base::Bind(&HeadlessShell::OnStart, base::Unretained(&shell))); |
626 } | 629 } |
627 | 630 |
628 } // namespace headless | 631 } // namespace headless |
OLD | NEW |