summaryrefslogtreecommitdiffstats
path: root/base/mac
diff options
context:
space:
mode:
authormsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-03 06:01:16 +0000
committermsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-03 06:01:16 +0000
commit75b6805083c906bb17192a738b311bd21791e9f8 (patch)
treebce38efec20d50a7ef55a694f58036ae365d5e0a /base/mac
parent2aa8b71eb688aa13a4f745027bcd4bb726bf6663 (diff)
downloadchromium_src-75b6805083c906bb17192a738b311bd21791e9f8.zip
chromium_src-75b6805083c906bb17192a738b311bd21791e9f8.tar.gz
chromium_src-75b6805083c906bb17192a738b311bd21791e9f8.tar.bz2
Cross-platform CL to remove app/win/win_util.h&cc and related work.
See Issue 70141 for the full move details; see my inline review comments. Changes significantly different from or beyond those prescribed by the bug: *Consolidated a lot of GrabWindowSnapshot code. *Moved EnsureRectIsVisibleInRect to views::internal namespace for test access. *Moved app/win/win_util_unittest.cc to views/window/window_win_unittest.h *Named ui/base/message_box_win.h instead of ui/base/message_box.h *Made WindowWin::GetWindowTitleFont static; needed in static contexts. *Denoted WindowWin::FrameTypeChanged as a Window override, moved code. *Moved TestGrabWindowSnapshot into new file: chrome/browser/ui/window_snapshot/window_snapshot_mac_unittest.mm BUG=70141 TEST=none Review URL: http://codereview.chromium.org/6386009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@73589 0039d316-1c4b-4281-b951-d872f2087c98
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;