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

Unified Diff: ui/snapshot/snapshot.cc

Issue 2592983002: [devtools] Support different encodings for Page.CaptureScreenshot. (Closed)
Patch Set: Wait for load in CaptureScreenshotTest to fix android bot. Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: ui/snapshot/snapshot.cc
diff --git a/ui/snapshot/snapshot.cc b/ui/snapshot/snapshot.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f12667898da88b53eb6d6eb91f4931429dd73045
--- /dev/null
+++ b/ui/snapshot/snapshot.cc
@@ -0,0 +1,40 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
Avi (use Gerrit) 2017/01/09 16:57:33 It's 2017.
Eric Seckler 2017/01/11 15:58:44 Done.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/snapshot/snapshot.h"
+
+#include "base/bind.h"
+#include "base/callback.h"
+#include "base/task_runner_util.h"
+#include "ui/gfx/image/image.h"
+
+namespace ui {
+
+namespace {
+
+scoped_refptr<base::RefCountedMemory> EncodeImage(const gfx::Image& image) {
+ return image.As1xPNGBytes();
+}
+
+void EncodeImageAndSchedulePNGCallback(
+ scoped_refptr<base::TaskRunner> background_task_runner,
+ const GrabWindowSnapshotAsyncPNGCallback& callback,
+ const gfx::Image& image) {
+ base::PostTaskAndReplyWithResult(background_task_runner.get(), FROM_HERE,
+ base::Bind(EncodeImage, image), callback);
+}
+
+} // namespace
+
+void GrabWindowSnapshotAsyncPNG(
+ gfx::NativeWindow window,
+ const gfx::Rect& source_rect,
+ scoped_refptr<base::TaskRunner> background_task_runner,
+ const GrabWindowSnapshotAsyncPNGCallback& callback) {
+ GrabWindowSnapshotAsync(window, source_rect,
+ base::Bind(EncodeImageAndSchedulePNGCallback,
+ background_task_runner, callback));
sadrul 2017/01/10 05:12:49 std::move(background_task_runner)
Eric Seckler 2017/01/11 15:58:44 Done.
+}
+
+} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698