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

Unified Diff: base/mac_util.mm

Issue 333018: Add GrabWindowSnapshot method to mac_util class. This code is due to dmaclac... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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
« no previous file with comments | « base/mac_util.h ('k') | base/mac_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/mac_util.mm
===================================================================
--- base/mac_util.mm (revision 30116)
+++ base/mac_util.mm (working copy)
@@ -1,4 +1,4 @@
-// Copyright (c) 2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2008-2009 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.
@@ -161,4 +161,21 @@
SetSystemUIMode(kUIModeNormal, 0);
}
+void GrabWindowSnapshot(NSWindow* window,
+ std::vector<unsigned char>* png_representation) {
+ // Make sure to grab the "window frame" view so we get current tab +
+ // tabstrip.
+ NSView* view = [[window contentView] superview];
+ NSBitmapImageRep* rep =
+ [view bitmapImageRepForCachingDisplayInRect:[view bounds]];
+ [view cacheDisplayInRect:[view bounds] toBitmapImageRep:rep];
+ NSData* data = [rep representationUsingType:NSPNGFileType properties:nil];
+ const unsigned char* buf = static_cast<const unsigned char*>([data bytes]);
+ NSUInteger length = [data length];
+ if (buf != NULL && length > 0){
+ png_representation->assign(buf, buf + length);
+ DCHECK(png_representation->size() > 0);
+ }
+}
+
} // namespace mac_util
« no previous file with comments | « base/mac_util.h ('k') | base/mac_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698