summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorgrt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-24 23:11:33 +0000
committergrt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-24 23:11:33 +0000
commitb6fdf085ad4a8122b2b5287ab6b7ff82955c2139 (patch)
treecd4dd40c5513f0ce6cf915c0164421237fd25c2d /ui
parent9b780ee7fc388ff280023b40686cc1a33af8ffd2 (diff)
downloadchromium_src-b6fdf085ad4a8122b2b5287ab6b7ff82955c2139.zip
chromium_src-b6fdf085ad4a8122b2b5287ab6b7ff82955c2139.tar.gz
chromium_src-b6fdf085ad4a8122b2b5287ab6b7ff82955c2139.tar.bz2
Add ui::GrabDesktopSnapshot for Windows.
GrabWindowSnapshot(NULL) had been used previously to get the desktop, but this doesn't work for Aura builds. BUG=223560 Review URL: https://chromiumcodereview.appspot.com/13926006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@196256 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/snapshot/snapshot.gyp26
-rw-r--r--ui/snapshot/snapshot_win.cc35
-rw-r--r--ui/snapshot/snapshot_win.h32
-rw-r--r--ui/snapshot/test/snapshot_desktop.h25
-rw-r--r--ui/snapshot/test/snapshot_desktop_win.cc16
5 files changed, 119 insertions, 15 deletions
diff --git a/ui/snapshot/snapshot.gyp b/ui/snapshot/snapshot.gyp
index 40744bf..cf93fa9 100644
--- a/ui/snapshot/snapshot.gyp
+++ b/ui/snapshot/snapshot.gyp
@@ -27,6 +27,7 @@
'snapshot_ios.mm',
'snapshot_mac.mm',
'snapshot_win.cc',
+ 'snapshot_win.h',
],
'include_dirs': [
'..',
@@ -38,11 +39,6 @@
'../compositor/compositor.gyp:compositor',
],
}],
- ['use_aura==1 and OS=="win"', {
- 'sources/': [
- ['exclude', 'snapshot_win.cc'],
- ],
- }],
],
},
{
@@ -62,4 +58,24 @@
]
},
],
+ 'conditions': [
+ ['OS=="win"', {
+ 'targets': [
+ {
+ 'target_name': 'snapshot_test_support',
+ 'type': 'static_library',
+ 'sources': [
+ 'test/snapshot_desktop.h',
+ 'test/snapshot_desktop_win.cc',
+ ],
+ 'dependencies': [
+ 'snapshot',
+ ],
+ 'include_dirs': [
+ '../..',
+ ],
+ },
+ ],
+ }],
+ ],
}
diff --git a/ui/snapshot/snapshot_win.cc b/ui/snapshot/snapshot_win.cc
index 3a8d1e7..8c2ff3b 100644
--- a/ui/snapshot/snapshot_win.cc
+++ b/ui/snapshot/snapshot_win.cc
@@ -2,7 +2,7 @@
// 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 "ui/snapshot/snapshot_win.h"
#include "base/win/scoped_gdi_object.h"
#include "base/win/scoped_hdc.h"
@@ -11,10 +11,11 @@
#include "ui/gfx/gdi_util.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/size.h"
+#include "ui/snapshot/snapshot.h"
namespace {
-gfx::Rect GetWindowBounds(gfx::NativeWindow window_handle) {
+gfx::Rect GetWindowBounds(HWND window_handle) {
RECT content_rect = {0, 0, 0, 0};
if (window_handle) {
::GetWindowRect(window_handle, &content_rect);
@@ -36,15 +37,11 @@ gfx::Rect GetWindowBounds(gfx::NativeWindow window_handle) {
namespace ui {
-bool GrabViewSnapshot(gfx::NativeView view_handle,
- std::vector<unsigned char>* png_representation,
- const gfx::Rect& snapshot_bounds) {
- return GrabWindowSnapshot(view_handle, png_representation, snapshot_bounds);
-}
+namespace internal {
-bool GrabWindowSnapshot(gfx::NativeWindow window_handle,
- std::vector<unsigned char>* png_representation,
- const gfx::Rect& snapshot_bounds) {
+bool GrabHwndSnapshot(HWND window_handle,
+ const gfx::Rect& snapshot_bounds,
+ std::vector<unsigned char>* png_representation) {
DCHECK(snapshot_bounds.right() <= GetWindowBounds(window_handle).right());
DCHECK(snapshot_bounds.bottom() <= GetWindowBounds(window_handle).bottom());
@@ -103,4 +100,22 @@ bool GrabWindowSnapshot(gfx::NativeWindow window_handle,
return true;
}
+} // namespace internal
+
+#if !defined(USE_AURA)
+bool GrabViewSnapshot(gfx::NativeView view_handle,
+ std::vector<unsigned char>* png_representation,
+ const gfx::Rect& snapshot_bounds) {
+ return GrabWindowSnapshot(view_handle, png_representation, snapshot_bounds);
+}
+
+bool GrabWindowSnapshot(gfx::NativeWindow window_handle,
+ std::vector<unsigned char>* png_representation,
+ const gfx::Rect& snapshot_bounds) {
+ DCHECK(window_handle);
+ return internal::GrabHwndSnapshot(window_handle, snapshot_bounds,
+ png_representation);
+}
+#endif // !defined(USE_AURA)
+
} // namespace ui
diff --git a/ui/snapshot/snapshot_win.h b/ui/snapshot/snapshot_win.h
new file mode 100644
index 0000000..e521484
--- /dev/null
+++ b/ui/snapshot/snapshot_win.h
@@ -0,0 +1,32 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_SNAPSHOT_SNAPSHOT_WIN_H_
+#define UI_SNAPSHOT_SNAPSHOT_WIN_H_
+
+#include <windows.h>
+
+#include <vector>
+
+#include "ui/snapshot/snapshot_export.h"
+
+namespace gfx {
+class Rect;
+}
+
+namespace ui {
+namespace internal {
+
+// Grabs a snapshot of the desktop. No security checks are done. This is
+// intended to be used for debugging purposes where no BrowserProcess instance
+// is available (ie. tests). DO NOT use in a result of user action.
+SNAPSHOT_EXPORT bool GrabHwndSnapshot(
+ HWND window_handle,
+ const gfx::Rect& snapshot_bounds,
+ std::vector<unsigned char>* png_representation);
+
+} // namespace internal
+} // namespace ui
+
+#endif // UI_SNAPSHOT_SNAPSHOT_WIN_H_
diff --git a/ui/snapshot/test/snapshot_desktop.h b/ui/snapshot/test/snapshot_desktop.h
new file mode 100644
index 0000000..bbd54de
--- /dev/null
+++ b/ui/snapshot/test/snapshot_desktop.h
@@ -0,0 +1,25 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_SNAPSHOT_TEST_SNAPSHOT_DESKTOP_H_
+#define UI_SNAPSHOT_TEST_SNAPSHOT_DESKTOP_H_
+
+#include <vector>
+
+namespace gfx {
+class Rect;
+}
+
+namespace ui {
+
+// Grabs a snapshot of the desktop. No security checks are done. This is
+// intended to be used for debugging purposes where no BrowserProcess instance
+// is available (ie. tests). DO NOT use in a result of user action.
+bool GrabDesktopSnapshot(
+ const gfx::Rect& snapshot_bounds,
+ std::vector<unsigned char>* png_representation);
+
+} // namespace ui
+
+#endif // UI_SNAPSHOT_TEST_SNAPSHOT_DESKTOP_H_
diff --git a/ui/snapshot/test/snapshot_desktop_win.cc b/ui/snapshot/test/snapshot_desktop_win.cc
new file mode 100644
index 0000000..1d4a29b
--- /dev/null
+++ b/ui/snapshot/test/snapshot_desktop_win.cc
@@ -0,0 +1,16 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/snapshot/test/snapshot_desktop.h"
+
+#include "ui/snapshot/snapshot_win.h"
+
+namespace ui {
+
+bool GrabDesktopSnapshot(const gfx::Rect& snapshot_bounds,
+ std::vector<unsigned char>* png_representation) {
+ return internal::GrabHwndSnapshot(NULL, snapshot_bounds, png_representation);
+}
+
+} // namespace ui