summaryrefslogtreecommitdiffstats
path: root/base/mac
diff options
context:
space:
mode:
Diffstat (limited to 'base/mac')
-rw-r--r--base/mac/mac_util.h8
-rw-r--r--base/mac/mac_util.mm31
-rw-r--r--base/mac/mac_util_unittest.mm32
3 files changed, 0 insertions, 71 deletions
diff --git a/base/mac/mac_util.h b/base/mac/mac_util.h
index 968756a..d75fb6e 100644
--- a/base/mac/mac_util.h
+++ b/base/mac/mac_util.h
@@ -8,7 +8,6 @@
#include <Carbon/Carbon.h>
#include <string>
-#include <vector>
#include "base/logging.h"
@@ -17,10 +16,8 @@
#if defined(__OBJC__)
#import <Foundation/Foundation.h>
-@class NSWindow;
#else // __OBJC__
class NSImage;
-class NSWindow;
#endif // __OBJC__
class FilePath;
@@ -77,11 +74,6 @@ void SetCursorVisibility(bool visible);
// Should windows miniaturize on a double-click (on the title bar)?
bool ShouldWindowsMiniaturizeOnDoubleClick();
-// Pulls a snapshot of the entire browser into png_representation.
-void GrabWindowSnapshot(NSWindow* window,
- std::vector<unsigned char>* png_representation,
- int* width, int* height);
-
// Activates the process with the given PID.
void ActivateProcess(pid_t pid);
diff --git a/base/mac/mac_util.mm b/base/mac/mac_util.mm
index c32be37..7f3be18 100644
--- a/base/mac/mac_util.mm
+++ b/base/mac/mac_util.mm
@@ -9,7 +9,6 @@
#include "base/file_path.h"
#include "base/logging.h"
#include "base/mac/scoped_cftyperef.h"
-#include "base/message_loop.h"
#include "base/scoped_nsobject.h"
#include "base/sys_string_conversions.h"
@@ -229,36 +228,6 @@ bool ShouldWindowsMiniaturizeOnDoubleClick() {
[NSWindow performSelector:@selector(_shouldMiniaturizeOnDoubleClick)];
}
-void GrabWindowSnapshot(NSWindow* window,
- std::vector<unsigned char>* png_representation,
- int* width, int* height) {
- png_representation->clear();
- *width = 0;
- *height = 0;
-
- // Make sure to grab the "window frame" view so we get current tab +
- // tabstrip.
- NSView* view = [[window contentView] superview];
- ScopedCFTypeRef<CGImageRef> windowSnapshot(CGWindowListCreateImage(
- CGRectNull, kCGWindowListOptionIncludingWindow,
- [[view window] windowNumber], kCGWindowImageBoundsIgnoreFraming));
- if (CGImageGetWidth(windowSnapshot) <= 0)
- return;
-
- scoped_nsobject<NSBitmapImageRep> rep(
- [[NSBitmapImageRep alloc] initWithCGImage:windowSnapshot]);
- 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)
- return;
-
- *width = static_cast<int>([rep pixelsWide]);
- *height = static_cast<int>([rep pixelsHigh]);
- png_representation->assign(buf, buf + length);
- DCHECK(png_representation->size() > 0);
-}
-
void ActivateProcess(pid_t pid) {
ProcessSerialNumber process;
OSStatus status = GetProcessForPID(pid, &process);
diff --git a/base/mac/mac_util_unittest.mm b/base/mac/mac_util_unittest.mm
index 17fc04f..bae0019 100644
--- a/base/mac/mac_util_unittest.mm
+++ b/base/mac/mac_util_unittest.mm
@@ -3,7 +3,6 @@
// found in the LICENSE file.
#import <Cocoa/Cocoa.h>
-#include <vector>
#include "base/mac/mac_util.h"
@@ -11,7 +10,6 @@
#include "base/file_util.h"
#include "base/mac/scoped_cftyperef.h"
#include "base/scoped_nsobject.h"
-#include "base/scoped_ptr.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
@@ -52,36 +50,6 @@ TEST_F(MacUtilTest, TestLibraryPath) {
EXPECT_FALSE(library_dir.value().empty());
}
-TEST_F(MacUtilTest, TestGrabWindowSnapshot) {
- // Launch a test window so we can take a snapshot.
- NSRect frame = NSMakeRect(0, 0, 400, 400);
- scoped_nsobject<NSWindow> window(
- [[NSWindow alloc] initWithContentRect:frame
- styleMask:NSBorderlessWindowMask
- backing:NSBackingStoreBuffered
- defer:NO]);
- [window setBackgroundColor:[NSColor whiteColor]];
- [window makeKeyAndOrderFront:NSApp];
-
- scoped_ptr<std::vector<unsigned char> > png_representation(
- new std::vector<unsigned char>);
- int width, height;
- GrabWindowSnapshot(window, png_representation.get(),
- &width, &height);
-
- // Copy png back into NSData object so we can make sure we grabbed a png.
- scoped_nsobject<NSData> image_data(
- [[NSData alloc] initWithBytes:&(*png_representation)[0]
- length:png_representation->size()]);
- NSBitmapImageRep* rep = [NSBitmapImageRep imageRepWithData:image_data.get()];
- EXPECT_TRUE([rep isKindOfClass:[NSBitmapImageRep class]]);
- EXPECT_TRUE(CGImageGetWidth([rep CGImage]) == 400);
- NSColor* color = [rep colorAtX:200 y:200];
- CGFloat red = 0, green = 0, blue = 0, alpha = 0;
- [color getRed:&red green:&green blue:&blue alpha:&alpha];
- EXPECT_GE(red + green + blue, 3.0);
-}
-
TEST_F(MacUtilTest, TestGetAppBundlePath) {
FilePath out;