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

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

Issue 10692110: screenshot disabling policy (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Addressed comments (2), hooking into GrabWindowSnapshot instead of ChromeShellDelegate, rebased on … Created 8 years, 5 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 browser { 14 namespace browser {
15 15
16 bool GrabWindowSnapshot(gfx::NativeWindow window, 16 bool GrabWindowSnapshotOS(gfx::NativeWindow window,
17 std::vector<unsigned char>* png_representation, 17 std::vector<unsigned char>* png_representation,
Mattias Nissler (ping if slow) 2012/07/12 08:59:32 indentation
qfel 2012/07/12 14:48:06 That's how it was in the original. Changed to the
18 const gfx::Rect& snapshot_bounds) { 18 const gfx::Rect& snapshot_bounds) {
19 NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; 19 NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
20 gfx::Rect screen_bounds = gfx::Rect(NSRectToCGRect([screen frame])); 20 gfx::Rect screen_bounds = gfx::Rect(NSRectToCGRect([screen frame]));
21 gfx::Rect window_bounds = gfx::Rect(NSRectToCGRect([window frame])); 21 gfx::Rect window_bounds = gfx::Rect(NSRectToCGRect([window frame]));
22 22
23 // Flip window coordinates based on the primary screen. 23 // Flip window coordinates based on the primary screen.
24 window_bounds.set_y( 24 window_bounds.set_y(
25 screen_bounds.height() - window_bounds.y() - window_bounds.height()); 25 screen_bounds.height() - window_bounds.y() - window_bounds.height());
26 26
27 // Convert snapshot bounds relative to window into bounds relative to 27 // Convert snapshot bounds relative to window into bounds relative to
(...skipping 24 matching lines...) Expand all
52 if (buf == NULL || length == 0) 52 if (buf == NULL || length == 0)
53 return false; 53 return false;
54 54
55 png_representation->assign(buf, buf + length); 55 png_representation->assign(buf, buf + length);
56 DCHECK(!png_representation->empty()); 56 DCHECK(!png_representation->empty());
57 57
58 return true; 58 return true;
59 } 59 }
60 60
61 } // namespace browser 61 } // namespace browser
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698