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

Side by Side Diff: base/mac/mac_util.mm

Issue 6386009: Remove app/win/win_util.h,cc etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code cleanup Created 9 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/mac_util.h" 5 #include "base/mac/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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 // NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; 349 // NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
350 // return ![defaults objectForKey:@"AppleMiniaturizeOnDoubleClick"] || 350 // return ![defaults objectForKey:@"AppleMiniaturizeOnDoubleClick"] ||
351 // [defaults boolForKey:@"AppleMiniaturizeOnDoubleClick"]; 351 // [defaults boolForKey:@"AppleMiniaturizeOnDoubleClick"];
352 BOOL methodImplemented = 352 BOOL methodImplemented =
353 [NSWindow respondsToSelector:@selector(_shouldMiniaturizeOnDoubleClick)]; 353 [NSWindow respondsToSelector:@selector(_shouldMiniaturizeOnDoubleClick)];
354 DCHECK(methodImplemented); 354 DCHECK(methodImplemented);
355 return !methodImplemented || 355 return !methodImplemented ||
356 [NSWindow performSelector:@selector(_shouldMiniaturizeOnDoubleClick)]; 356 [NSWindow performSelector:@selector(_shouldMiniaturizeOnDoubleClick)];
357 } 357 }
358 358
359 void GrabWindowSnapshot(NSWindow* window,
360 std::vector<unsigned char>* png_representation,
361 int* width, int* height) {
362 png_representation->clear();
363 *width = 0;
364 *height = 0;
365
366 // Make sure to grab the "window frame" view so we get current tab +
367 // tabstrip.
368 NSView* view = [[window contentView] superview];
369 ScopedCFTypeRef<CGImageRef> windowSnapshot(CGWindowListCreateImage(
370 CGRectNull, kCGWindowListOptionIncludingWindow,
371 [[view window] windowNumber], kCGWindowImageBoundsIgnoreFraming));
372 if (CGImageGetWidth(windowSnapshot) <= 0)
373 return;
374
375 scoped_nsobject<NSBitmapImageRep> rep(
376 [[NSBitmapImageRep alloc] initWithCGImage:windowSnapshot]);
377 NSData* data = [rep representationUsingType:NSPNGFileType properties:nil];
378 const unsigned char* buf = static_cast<const unsigned char*>([data bytes]);
379 NSUInteger length = [data length];
380 if (buf == NULL || length == 0)
381 return;
382
383 *width = static_cast<int>([rep pixelsWide]);
384 *height = static_cast<int>([rep pixelsHigh]);
385 png_representation->assign(buf, buf + length);
386 DCHECK(png_representation->size() > 0);
387 }
388
389 void ActivateProcess(pid_t pid) { 359 void ActivateProcess(pid_t pid) {
390 ProcessSerialNumber process; 360 ProcessSerialNumber process;
391 OSStatus status = GetProcessForPID(pid, &process); 361 OSStatus status = GetProcessForPID(pid, &process);
392 if (status == noErr) { 362 if (status == noErr) {
393 SetFrontProcess(&process); 363 SetFrontProcess(&process);
394 } else { 364 } else {
395 LOG(WARNING) << "Unable to get process for pid " << pid; 365 LOG(WARNING) << "Unable to get process for pid " << pid;
396 } 366 }
397 } 367 }
398 368
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 [nsobj retain]; 687 [nsobj retain];
718 } 688 }
719 689
720 void NSObjectRelease(void* obj) { 690 void NSObjectRelease(void* obj) {
721 id<NSObject> nsobj = static_cast<id<NSObject> >(obj); 691 id<NSObject> nsobj = static_cast<id<NSObject> >(obj);
722 [nsobj release]; 692 [nsobj release];
723 } 693 }
724 694
725 } // namespace mac 695 } // namespace mac
726 } // namespace base 696 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698