OLD | NEW |
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 Loading... |
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 |
OLD | NEW |