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

Side by Side Diff: content/browser/devtools/protocol/page_handler.cc

Issue 2732923002: Add fromSurface optional parameter to devtools Page.CaptureScreenshot (Closed)
Patch Set: Marked fromSurface parameter as experimental 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/browser/devtools/protocol/page_handler.h" 5 #include "content/browser/devtools/protocol/page_handler.h"
6 6
7 #include <algorithm>
8 #include <memory>
7 #include <string> 9 #include <string>
10 #include <utility>
11 #include <vector>
8 12
9 #include "base/base64.h" 13 #include "base/base64.h"
10 #include "base/bind.h" 14 #include "base/bind.h"
11 #include "base/location.h" 15 #include "base/location.h"
12 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
13 #include "base/memory/ref_counted_memory.h" 17 #include "base/memory/ref_counted_memory.h"
14 #include "base/single_thread_task_runner.h" 18 #include "base/single_thread_task_runner.h"
15 #include "base/strings/string16.h" 19 #include "base/strings/string16.h"
16 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
17 #include "base/task_scheduler/post_task.h" 21 #include "base/task_scheduler/post_task.h"
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 return Response::OK(); 281 return Response::OK();
278 } 282 }
279 } 283 }
280 284
281 return Response::InvalidParams("No entry with passed id"); 285 return Response::InvalidParams("No entry with passed id");
282 } 286 }
283 287
284 void PageHandler::CaptureScreenshot( 288 void PageHandler::CaptureScreenshot(
285 Maybe<std::string> format, 289 Maybe<std::string> format,
286 Maybe<int> quality, 290 Maybe<int> quality,
291 Maybe<bool> from_surface,
287 std::unique_ptr<CaptureScreenshotCallback> callback) { 292 std::unique_ptr<CaptureScreenshotCallback> callback) {
288 if (!host_ || !host_->GetRenderWidgetHost()) { 293 if (!host_ || !host_->GetRenderWidgetHost()) {
289 callback->sendFailure(Response::InternalError()); 294 callback->sendFailure(Response::InternalError());
290 return; 295 return;
291 } 296 }
292 297
293 std::string screenshot_format = format.fromMaybe(kPng); 298 std::string screenshot_format = format.fromMaybe(kPng);
294 int screenshot_quality = quality.fromMaybe(kDefaultScreenshotQuality); 299 int screenshot_quality = quality.fromMaybe(kDefaultScreenshotQuality);
300 bool screenshot_from_surface = from_surface.fromMaybe(false);
295 301
302 if (screenshot_from_surface) {
303 host_->GetRenderWidgetHost()->GetSurfaceSnapshotFromBrowser(
304 base::Bind(&PageHandler::ScreenshotCaptured, weak_factory_.GetWeakPtr(),
305 base::Passed(std::move(callback)), screenshot_format,
306 screenshot_quality));
307 return;
308 }
296 host_->GetRenderWidgetHost()->GetSnapshotFromBrowser( 309 host_->GetRenderWidgetHost()->GetSnapshotFromBrowser(
297 base::Bind(&PageHandler::ScreenshotCaptured, weak_factory_.GetWeakPtr(), 310 base::Bind(&PageHandler::ScreenshotCaptured, weak_factory_.GetWeakPtr(),
298 base::Passed(std::move(callback)), screenshot_format, 311 base::Passed(std::move(callback)), screenshot_format,
299 screenshot_quality)); 312 screenshot_quality));
300 } 313 }
301 314
302 void PageHandler::PrintToPDF(std::unique_ptr<PrintToPDFCallback> callback) { 315 void PageHandler::PrintToPDF(std::unique_ptr<PrintToPDFCallback> callback) {
303 callback->sendFailure(Response::Error("PrintToPDF is not implemented")); 316 callback->sendFailure(Response::Error("PrintToPDF is not implemented"));
304 return; 317 return;
305 } 318 }
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 Response PageHandler::StopLoading() { 602 Response PageHandler::StopLoading() {
590 WebContentsImpl* web_contents = GetWebContents(); 603 WebContentsImpl* web_contents = GetWebContents();
591 if (!web_contents) 604 if (!web_contents)
592 return Response::InternalError(); 605 return Response::InternalError();
593 web_contents->Stop(); 606 web_contents->Stop();
594 return Response::OK(); 607 return Response::OK();
595 } 608 }
596 609
597 } // namespace protocol 610 } // namespace protocol
598 } // namespace content 611 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698