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

Side by Side Diff: headless/app/headless_shell.cc

Issue 2732923002: Add fromSurface optional parameter to devtools Page.CaptureScreenshot (Closed)
Patch Set: nits Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/base_switches.h" 10 #include "base/base_switches.h"
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 std::unique_ptr<runtime::EvaluateResult> result) { 305 std::unique_ptr<runtime::EvaluateResult> result) {
306 std::unique_ptr<base::Value> value = result->Serialize(); 306 std::unique_ptr<base::Value> value = result->Serialize();
307 std::string result_json; 307 std::string result_json;
308 base::JSONWriter::Write(*value, &result_json); 308 base::JSONWriter::Write(*value, &result_json);
309 printf("%s\n", result_json.c_str()); 309 printf("%s\n", result_json.c_str());
310 InputExpression(); 310 InputExpression();
311 } 311 }
312 312
313 void HeadlessShell::CaptureScreenshot() { 313 void HeadlessShell::CaptureScreenshot() {
314 devtools_client_->GetPage()->GetExperimental()->CaptureScreenshot( 314 devtools_client_->GetPage()->GetExperimental()->CaptureScreenshot(
315 page::CaptureScreenshotParams::Builder().Build(), 315 page::CaptureScreenshotParams::Builder().SetFromSurface(true).Build(),
316 base::Bind(&HeadlessShell::OnScreenshotCaptured, 316 base::Bind(&HeadlessShell::OnScreenshotCaptured,
317 weak_factory_.GetWeakPtr())); 317 weak_factory_.GetWeakPtr()));
318 } 318 }
319 319
320 void HeadlessShell::OnScreenshotCaptured( 320 void HeadlessShell::OnScreenshotCaptured(
321 std::unique_ptr<page::CaptureScreenshotResult> result) { 321 std::unique_ptr<page::CaptureScreenshotResult> result) {
322 base::FilePath file_name = 322 base::FilePath file_name =
323 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( 323 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath(
324 switches::kScreenshot); 324 switches::kScreenshot);
325 if (file_name.empty()) { 325 if (file_name.empty()) {
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 builder.SetOverrideWebPreferencesCallback(base::Bind([]( 518 builder.SetOverrideWebPreferencesCallback(base::Bind([](
519 WebPreferences* preferences) { preferences->hide_scrollbars = true; })); 519 WebPreferences* preferences) { preferences->hide_scrollbars = true; }));
520 } 520 }
521 521
522 return HeadlessBrowserMain( 522 return HeadlessBrowserMain(
523 builder.Build(), 523 builder.Build(),
524 base::Bind(&HeadlessShell::OnStart, base::Unretained(&shell))); 524 base::Bind(&HeadlessShell::OnStart, base::Unretained(&shell)));
525 } 525 }
526 526
527 } // namespace headless 527 } // namespace headless
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.cc ('k') | headless/lib/headless_web_contents_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698