OLD | NEW |
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 "ui/snapshot/snapshot.h" | 5 #include "ui/snapshot/snapshot.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/mac/scoped_cftyperef.h" | 11 #include "base/mac/scoped_cftyperef.h" |
12 #include "base/mac/scoped_nsobject.h" | 12 #include "base/mac/scoped_nsobject.h" |
| 13 #include "base/task_runner.h" |
| 14 #include "ui/gfx/image/image.h" |
13 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
14 | 16 |
15 namespace ui { | 17 namespace ui { |
16 | 18 |
17 bool GrabViewSnapshot(gfx::NativeView view, | 19 bool GrabViewSnapshot(gfx::NativeView view, |
18 std::vector<unsigned char>* png_representation, | 20 std::vector<unsigned char>* png_representation, |
19 const gfx::Rect& snapshot_bounds) { | 21 const gfx::Rect& snapshot_bounds) { |
20 NSWindow* window = [view window]; | 22 NSWindow* window = [view window]; |
21 NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; | 23 NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; |
22 gfx::Rect screen_bounds = gfx::Rect(NSRectToCGRect([screen frame])); | 24 gfx::Rect screen_bounds = gfx::Rect(NSRectToCGRect([screen frame])); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 return GrabViewSnapshot([[window contentView] superview], png_representation, | 74 return GrabViewSnapshot([[window contentView] superview], png_representation, |
73 snapshot_bounds); | 75 snapshot_bounds); |
74 } | 76 } |
75 | 77 |
76 void GrabWindowSnapshotAndScaleAsync( | 78 void GrabWindowSnapshotAndScaleAsync( |
77 gfx::NativeWindow window, | 79 gfx::NativeWindow window, |
78 const gfx::Rect& snapshot_bounds, | 80 const gfx::Rect& snapshot_bounds, |
79 const gfx::Size& target_size, | 81 const gfx::Size& target_size, |
80 scoped_refptr<base::TaskRunner> background_task_runner, | 82 scoped_refptr<base::TaskRunner> background_task_runner, |
81 GrabWindowSnapshotAsyncCallback callback) { | 83 GrabWindowSnapshotAsyncCallback callback) { |
82 NOTIMPLEMENTED(); | 84 callback.Run(gfx::Image()); |
| 85 } |
| 86 |
| 87 void GrabViewSnapshotAsync( |
| 88 gfx::NativeView view, |
| 89 const gfx::Rect& source_rect, |
| 90 scoped_refptr<base::TaskRunner> background_task_runner, |
| 91 const GrabWindowSnapshotAsyncPNGCallback& callback) { |
| 92 callback.Run(scoped_refptr<base::RefCountedBytes>()); |
83 } | 93 } |
84 | 94 |
85 void GrabWindowSnapshotAsync( | 95 void GrabWindowSnapshotAsync( |
86 gfx::NativeWindow window, | 96 gfx::NativeWindow window, |
87 const gfx::Rect& source_rect, | 97 const gfx::Rect& source_rect, |
88 scoped_refptr<base::TaskRunner> background_task_runner, | 98 scoped_refptr<base::TaskRunner> background_task_runner, |
89 const GrabWindowSnapshotAsyncPNGCallback& callback) { | 99 const GrabWindowSnapshotAsyncPNGCallback& callback) { |
90 NOTIMPLEMENTED(); | 100 return GrabViewSnapshotAsync([[window contentView] superview], source_rect, |
| 101 background_task_runner, callback); |
91 } | 102 } |
92 | 103 |
93 } // namespace ui | 104 } // namespace ui |
OLD | NEW |