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

Side by Side Diff: chrome/browser/ui/window_snapshot/window_snapshot_mac.mm

Issue 10830158: Refactor GrabWindowSnapshot and GrabWindowSnapshotImpl names to GrabWindowSnapshotForUser and GrabW… (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed compiling tests, fixed indent Created 8 years, 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/ui/window_snapshot/window_snapshot.h" 5 #include "chrome/browser/ui/window_snapshot/window_snapshot.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/mac/scoped_cftyperef.h" 10 #include "base/mac/scoped_cftyperef.h"
11 #include "base/memory/scoped_nsobject.h" 11 #include "base/memory/scoped_nsobject.h"
12 #include "ui/gfx/rect.h" 12 #include "ui/gfx/rect.h"
13 13
14 namespace chrome { 14 namespace chrome {
15 namespace internal {
15 16
16 bool GrabWindowSnapshotImpl(gfx::NativeWindow window, 17 bool GrabWindowSnapshot(gfx::NativeWindow window,
17 std::vector<unsigned char>* png_representation, 18 std::vector<unsigned char>* png_representation,
18 const gfx::Rect& snapshot_bounds) { 19 const gfx::Rect& snapshot_bounds) {
19 NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; 20 NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
20 gfx::Rect screen_bounds = gfx::Rect(NSRectToCGRect([screen frame])); 21 gfx::Rect screen_bounds = gfx::Rect(NSRectToCGRect([screen frame]));
21 gfx::Rect window_bounds = gfx::Rect(NSRectToCGRect([window frame])); 22 gfx::Rect window_bounds = gfx::Rect(NSRectToCGRect([window frame]));
22 23
23 // Flip window coordinates based on the primary screen. 24 // Flip window coordinates based on the primary screen.
24 window_bounds.set_y( 25 window_bounds.set_y(
25 screen_bounds.height() - window_bounds.y() - window_bounds.height()); 26 screen_bounds.height() - window_bounds.y() - window_bounds.height());
26 27
27 // Convert snapshot bounds relative to window into bounds relative to 28 // Convert snapshot bounds relative to window into bounds relative to
28 // screen. 29 // screen.
(...skipping 22 matching lines...) Expand all
51 NSUInteger length = [data length]; 52 NSUInteger length = [data length];
52 if (buf == NULL || length == 0) 53 if (buf == NULL || length == 0)
53 return false; 54 return false;
54 55
55 png_representation->assign(buf, buf + length); 56 png_representation->assign(buf, buf + length);
56 DCHECK(!png_representation->empty()); 57 DCHECK(!png_representation->empty());
57 58
58 return true; 59 return true;
59 } 60 }
60 61
62 } // namespace internal
61 } // namespace chrome 63 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698