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

Side by Side 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, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « base/mac_util.h ('k') | base/mac_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008-2009 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 "base/mac_util.h" 5 #include "base/mac_util.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 154
155 // Release a request for full screen mode. If there are no other outstanding 155 // Release a request for full screen mode. If there are no other outstanding
156 // requests, show the menu bar. Must be called on main thread. 156 // requests, show the menu bar. Must be called on main thread.
157 void ReleaseFullScreen() { 157 void ReleaseFullScreen() {
158 DCHECK_GT(g_full_screen_requests, 0); 158 DCHECK_GT(g_full_screen_requests, 0);
159 --g_full_screen_requests; 159 --g_full_screen_requests;
160 if (g_full_screen_requests == 0) 160 if (g_full_screen_requests == 0)
161 SetSystemUIMode(kUIModeNormal, 0); 161 SetSystemUIMode(kUIModeNormal, 0);
162 } 162 }
163 163
164 void GrabWindowSnapshot(NSWindow* window,
165 std::vector<unsigned char>* png_representation) {
166 // Make sure to grab the "window frame" view so we get current tab +
167 // tabstrip.
168 NSView* view = [[window contentView] superview];
169 NSBitmapImageRep* rep =
170 [view bitmapImageRepForCachingDisplayInRect:[view bounds]];
171 [view cacheDisplayInRect:[view bounds] toBitmapImageRep:rep];
172 NSData* data = [rep representationUsingType:NSPNGFileType properties:nil];
173 const unsigned char* buf = static_cast<const unsigned char*>([data bytes]);
174 NSUInteger length = [data length];
175 if (buf != NULL && length > 0){
176 png_representation->assign(buf, buf + length);
177 DCHECK(png_representation->size() > 0);
178 }
179 }
180
164 } // namespace mac_util 181 } // namespace mac_util
OLDNEW
« 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