OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/screenshot_grabber.h" | 5 #include "ui/snapshot/screenshot_grabber.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <climits> | 9 #include <climits> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
15 #include "base/location.h" | 15 #include "base/location.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
18 #include "base/single_thread_task_runner.h" | 18 #include "base/single_thread_task_runner.h" |
19 #include "base/task_runner.h" | 19 #include "base/task_runner.h" |
20 #include "base/threading/sequenced_worker_pool.h" | 20 #include "base/threading/sequenced_worker_pool.h" |
21 #include "base/threading/thread_task_runner_handle.h" | 21 #include "base/threading/thread_task_runner_handle.h" |
22 #include "base/time/time.h" | 22 #include "base/time/time.h" |
23 #include "ui/gfx/image/image.h" | 23 #include "ui/gfx/image/image.h" |
24 #include "ui/snapshot/snapshot.h" | 24 #include "ui/snapshot/snapshot.h" |
25 | 25 |
26 #if defined(USE_AURA) | 26 #if defined(USE_AURA) |
27 #include "ui/aura/client/cursor_client.h" | |
27 #include "ui/aura/window.h" | 28 #include "ui/aura/window.h" |
28 #endif | 29 #endif |
29 | 30 |
30 namespace ui { | 31 namespace ui { |
31 | 32 |
32 namespace { | 33 namespace { |
33 // The minimum interval between two screenshot commands. It has to be | 34 // The minimum interval between two screenshot commands. It has to be |
34 // more than 1000 to prevent the conflict of filenames. | 35 // more than 1000 to prevent the conflict of filenames. |
35 const int kScreenshotMinimumIntervalInMS = 1000; | 36 const int kScreenshotMinimumIntervalInMS = 1000; |
36 | 37 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 | 128 |
128 bool is_partial = true; | 129 bool is_partial = true; |
129 // Window identifier is used to log a message on failure to capture a full | 130 // Window identifier is used to log a message on failure to capture a full |
130 // screen (i.e. non partial) screenshot. The only time is_partial can be | 131 // screen (i.e. non partial) screenshot. The only time is_partial can be |
131 // false, we will also have an identification string for the window. | 132 // false, we will also have an identification string for the window. |
132 std::string window_identifier; | 133 std::string window_identifier; |
133 #if defined(USE_AURA) | 134 #if defined(USE_AURA) |
134 aura::Window* aura_window = static_cast<aura::Window*>(window); | 135 aura::Window* aura_window = static_cast<aura::Window*>(window); |
135 is_partial = rect.size() != aura_window->bounds().size(); | 136 is_partial = rect.size() != aura_window->bounds().size(); |
136 window_identifier = aura_window->GetBoundsInScreen().ToString(); | 137 window_identifier = aura_window->GetBoundsInScreen().ToString(); |
138 | |
139 aura::client::CursorClient* cursor_client = | |
140 aura::client::GetCursorClient(aura_window->GetRootWindow()); | |
141 if (cursor_client) | |
142 cursor_client->HideCursor(); | |
sky
2016/07/21 15:31:42
Aren't you missing a corresonding Show?
Qiang(Joe) Xu
2016/07/21 17:48:26
Yes. It is missing. I add it now.
| |
137 #endif | 143 #endif |
138 ui::GrabWindowSnapshotAsync( | 144 ui::GrabWindowSnapshotAsync( |
139 window, rect, blocking_task_runner_, | 145 window, rect, blocking_task_runner_, |
140 base::Bind(&ScreenshotGrabber::GrabWindowSnapshotAsyncCallback, | 146 base::Bind(&ScreenshotGrabber::GrabWindowSnapshotAsyncCallback, |
141 factory_.GetWeakPtr(), window_identifier, screenshot_path, | 147 factory_.GetWeakPtr(), window_identifier, screenshot_path, |
142 is_partial)); | 148 is_partial)); |
143 } | 149 } |
144 | 150 |
145 bool ScreenshotGrabber::CanTakeScreenshot() { | 151 bool ScreenshotGrabber::CanTakeScreenshot() { |
146 return last_screenshot_timestamp_.is_null() || | 152 return last_screenshot_timestamp_.is_null() || |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
193 | 199 |
194 ShowNotificationCallback notification_callback(base::Bind( | 200 ShowNotificationCallback notification_callback(base::Bind( |
195 &ScreenshotGrabber::NotifyScreenshotCompleted, factory_.GetWeakPtr())); | 201 &ScreenshotGrabber::NotifyScreenshotCompleted, factory_.GetWeakPtr())); |
196 client_->PrepareFileAndRunOnBlockingPool( | 202 client_->PrepareFileAndRunOnBlockingPool( |
197 screenshot_path, blocking_task_runner_, | 203 screenshot_path, blocking_task_runner_, |
198 base::Bind(&SaveScreenshot, base::ThreadTaskRunnerHandle::Get(), | 204 base::Bind(&SaveScreenshot, base::ThreadTaskRunnerHandle::Get(), |
199 notification_callback, screenshot_path, png_data)); | 205 notification_callback, screenshot_path, png_data)); |
200 } | 206 } |
201 | 207 |
202 } // namespace ui | 208 } // namespace ui |
OLD | NEW |