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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 std::unique_ptr<runtime::EvaluateResult> result) { | 347 std::unique_ptr<runtime::EvaluateResult> result) { |
348 std::unique_ptr<base::Value> value = result->Serialize(); | 348 std::unique_ptr<base::Value> value = result->Serialize(); |
349 std::string result_json; | 349 std::string result_json; |
350 base::JSONWriter::Write(*value, &result_json); | 350 base::JSONWriter::Write(*value, &result_json); |
351 printf("%s\n", result_json.c_str()); | 351 printf("%s\n", result_json.c_str()); |
352 InputExpression(); | 352 InputExpression(); |
353 } | 353 } |
354 | 354 |
355 void HeadlessShell::CaptureScreenshot() { | 355 void HeadlessShell::CaptureScreenshot() { |
356 devtools_client_->GetPage()->GetExperimental()->CaptureScreenshot( | 356 devtools_client_->GetPage()->GetExperimental()->CaptureScreenshot( |
357 page::CaptureScreenshotParams::Builder().SetFromSurface(true).Build(), | 357 page::CaptureScreenshotParams::Builder().Build(), |
358 base::Bind(&HeadlessShell::OnScreenshotCaptured, | 358 base::Bind(&HeadlessShell::OnScreenshotCaptured, |
359 weak_factory_.GetWeakPtr())); | 359 weak_factory_.GetWeakPtr())); |
360 } | 360 } |
361 | 361 |
362 void HeadlessShell::OnScreenshotCaptured( | 362 void HeadlessShell::OnScreenshotCaptured( |
363 std::unique_ptr<page::CaptureScreenshotResult> result) { | 363 std::unique_ptr<page::CaptureScreenshotResult> result) { |
364 if (!result) { | 364 if (!result) { |
365 LOG(ERROR) << "Capture screenshot failed"; | 365 LOG(ERROR) << "Capture screenshot failed"; |
366 Shutdown(); | 366 Shutdown(); |
367 return; | 367 return; |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 if (net::HttpUtil::IsValidHeaderValue(ua)) | 633 if (net::HttpUtil::IsValidHeaderValue(ua)) |
634 builder.SetUserAgent(ua); | 634 builder.SetUserAgent(ua); |
635 } | 635 } |
636 | 636 |
637 return HeadlessBrowserMain( | 637 return HeadlessBrowserMain( |
638 builder.Build(), | 638 builder.Build(), |
639 base::Bind(&HeadlessShell::OnStart, base::Unretained(&shell))); | 639 base::Bind(&HeadlessShell::OnStart, base::Unretained(&shell))); |
640 } | 640 } |
641 | 641 |
642 } // namespace headless | 642 } // namespace headless |
OLD | NEW |