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