| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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" |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 // return ![defaults objectForKey:@"AppleMiniaturizeOnDoubleClick"] || | 237 // return ![defaults objectForKey:@"AppleMiniaturizeOnDoubleClick"] || |
| 238 // [defaults boolForKey:@"AppleMiniaturizeOnDoubleClick"]; | 238 // [defaults boolForKey:@"AppleMiniaturizeOnDoubleClick"]; |
| 239 BOOL methodImplemented = | 239 BOOL methodImplemented = |
| 240 [NSWindow respondsToSelector:@selector(_shouldMiniaturizeOnDoubleClick)]; | 240 [NSWindow respondsToSelector:@selector(_shouldMiniaturizeOnDoubleClick)]; |
| 241 DCHECK(methodImplemented); | 241 DCHECK(methodImplemented); |
| 242 return !methodImplemented || | 242 return !methodImplemented || |
| 243 [NSWindow performSelector:@selector(_shouldMiniaturizeOnDoubleClick)]; | 243 [NSWindow performSelector:@selector(_shouldMiniaturizeOnDoubleClick)]; |
| 244 } | 244 } |
| 245 | 245 |
| 246 void GrabWindowSnapshot(NSWindow* window, | 246 void GrabWindowSnapshot(NSWindow* window, |
| 247 std::vector<unsigned char>* png_representation) { | 247 std::vector<unsigned char>* png_representation, |
| 248 int* width, int* height) { |
| 248 // Make sure to grab the "window frame" view so we get current tab + | 249 // Make sure to grab the "window frame" view so we get current tab + |
| 249 // tabstrip. | 250 // tabstrip. |
| 250 NSView* view = [[window contentView] superview]; | 251 NSView* view = [[window contentView] superview]; |
| 251 NSBitmapImageRep* rep = | 252 NSBitmapImageRep* rep = |
| 252 [view bitmapImageRepForCachingDisplayInRect:[view bounds]]; | 253 [view bitmapImageRepForCachingDisplayInRect:[view bounds]]; |
| 253 [view cacheDisplayInRect:[view bounds] toBitmapImageRep:rep]; | 254 [view cacheDisplayInRect:[view bounds] toBitmapImageRep:rep]; |
| 254 NSData* data = [rep representationUsingType:NSPNGFileType properties:nil]; | 255 NSData* data = [rep representationUsingType:NSPNGFileType properties:nil]; |
| 255 const unsigned char* buf = static_cast<const unsigned char*>([data bytes]); | 256 const unsigned char* buf = static_cast<const unsigned char*>([data bytes]); |
| 256 NSUInteger length = [data length]; | 257 NSUInteger length = [data length]; |
| 257 if (buf != NULL && length > 0){ | 258 if (buf != NULL && length > 0){ |
| 259 *width = static_cast<int>([rep pixelsWide]); |
| 260 *height = static_cast<int>([rep pixelsHigh]); |
| 258 png_representation->assign(buf, buf + length); | 261 png_representation->assign(buf, buf + length); |
| 259 DCHECK(png_representation->size() > 0); | 262 DCHECK(png_representation->size() > 0); |
| 260 } | 263 } |
| 261 } | 264 } |
| 262 | 265 |
| 263 void ActivateProcess(pid_t pid) { | 266 void ActivateProcess(pid_t pid) { |
| 264 ProcessSerialNumber process; | 267 ProcessSerialNumber process; |
| 265 OSStatus status = GetProcessForPID(pid, &process); | 268 OSStatus status = GetProcessForPID(pid, &process); |
| 266 if (status == noErr) { | 269 if (status == noErr) { |
| 267 SetFrontProcess(&process); | 270 SetFrontProcess(&process); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 const int magic_session_constant = -2; | 473 const int magic_session_constant = -2; |
| 471 OSErr err = | 474 OSErr err = |
| 472 ls_set_application_information_item_func(magic_session_constant, asn, | 475 ls_set_application_information_item_func(magic_session_constant, asn, |
| 473 ls_display_name_key, | 476 ls_display_name_key, |
| 474 process_name, | 477 process_name, |
| 475 NULL /* optional out param */); | 478 NULL /* optional out param */); |
| 476 LOG_IF(ERROR, err) << "Call to set process name failed, err " << err; | 479 LOG_IF(ERROR, err) << "Call to set process name failed, err " << err; |
| 477 } | 480 } |
| 478 | 481 |
| 479 } // namespace mac_util | 482 } // namespace mac_util |
| OLD | NEW |