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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 LOG(ERROR) << "Capture screenshot failed"; | 352 LOG(ERROR) << "Capture screenshot failed"; |
353 Shutdown(); | 353 Shutdown(); |
354 return; | 354 return; |
355 } | 355 } |
356 WriteFile(switches::kScreenshot, kDefaultScreenshotFileName, | 356 WriteFile(switches::kScreenshot, kDefaultScreenshotFileName, |
357 result->GetData()); | 357 result->GetData()); |
358 } | 358 } |
359 | 359 |
360 void HeadlessShell::PrintToPDF() { | 360 void HeadlessShell::PrintToPDF() { |
361 devtools_client_->GetPage()->GetExperimental()->PrintToPDF( | 361 devtools_client_->GetPage()->GetExperimental()->PrintToPDF( |
362 page::PrintToPDFParams::Builder().Build(), | 362 page::PrintToPDFParams::Builder() |
| 363 .SetDisplayHeaderFooter(true) |
| 364 .SetPrintBackgrounds(true) |
| 365 .Build(), |
363 base::Bind(&HeadlessShell::OnPDFCreated, weak_factory_.GetWeakPtr())); | 366 base::Bind(&HeadlessShell::OnPDFCreated, weak_factory_.GetWeakPtr())); |
364 } | 367 } |
365 | 368 |
366 void HeadlessShell::OnPDFCreated( | 369 void HeadlessShell::OnPDFCreated( |
367 std::unique_ptr<page::PrintToPDFResult> result) { | 370 std::unique_ptr<page::PrintToPDFResult> result) { |
368 if (!result) { | 371 if (!result) { |
369 LOG(ERROR) << "Print to PDF failed"; | 372 LOG(ERROR) << "Print to PDF failed"; |
370 Shutdown(); | 373 Shutdown(); |
371 return; | 374 return; |
372 } | 375 } |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 if (net::HttpUtil::IsValidHeaderValue(ua)) | 594 if (net::HttpUtil::IsValidHeaderValue(ua)) |
592 builder.SetUserAgent(ua); | 595 builder.SetUserAgent(ua); |
593 } | 596 } |
594 | 597 |
595 return HeadlessBrowserMain( | 598 return HeadlessBrowserMain( |
596 builder.Build(), | 599 builder.Build(), |
597 base::Bind(&HeadlessShell::OnStart, base::Unretained(&shell))); | 600 base::Bind(&HeadlessShell::OnStart, base::Unretained(&shell))); |
598 } | 601 } |
599 | 602 |
600 } // namespace headless | 603 } // namespace headless |
OLD | NEW |