Index: ui/snapshot/screenshot_grabber.cc |
diff --git a/ui/snapshot/screenshot_grabber.cc b/ui/snapshot/screenshot_grabber.cc |
index 4534a857b4beab8a5b77dc15a825a6098b8a508e..92a3e9e33de30843a05acf73e513b3d070042a3f 100644 |
--- a/ui/snapshot/screenshot_grabber.cc |
+++ b/ui/snapshot/screenshot_grabber.cc |
@@ -24,6 +24,7 @@ |
#include "ui/snapshot/snapshot.h" |
#if defined(USE_AURA) |
+#include "ui/aura/client/cursor_client.h" |
#include "ui/aura/window.h" |
#endif |
@@ -108,6 +109,40 @@ void ScreenshotGrabberDelegate::PrepareFileAndRunOnBlockingPool( |
base::Bind(EnsureLocalDirectoryExists, path, callback_on_blocking_pool)); |
} |
+#if defined(USE_AURA) |
+class ScreenshotGrabber::ScopedCursorHider { |
+ public: |
+ explicit ScopedCursorHider(aura::Window* window) |
+ : window_(window), hid_cursor_(false) { |
+ if (!window_->IsRootWindow()) |
sky
2016/07/22 16:14:44
This should be a DCHECK.
Qiang(Joe) Xu
2016/07/22 20:15:26
Done.
|
+ return; |
+ aura::client::CursorClient* cursor_client = |
sky
2016/07/22 16:14:44
Having to have all these checks in both the constr
Qiang(Joe) Xu
2016/07/22 20:15:26
done. Thanks for suggestion.
|
+ aura::client::GetCursorClient(window_); |
+ if (!cursor_client) |
+ return; |
+ cursor_client->HideCursor(); |
+ hid_cursor_ = true; |
+ } |
+ ~ScopedCursorHider() { |
+ if (!window_->IsRootWindow()) |
+ return; |
+ if (hid_cursor_) { |
+ aura::client::CursorClient* cursor_client = |
+ aura::client::GetCursorClient(window_); |
+ if (!cursor_client) |
+ return; |
+ cursor_client->ShowCursor(); |
+ } |
+ } |
+ |
+ private: |
+ aura::Window* window_; |
+ bool hid_cursor_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ScopedCursorHider); |
+}; |
+#endif |
+ |
ScreenshotGrabber::ScreenshotGrabber( |
ScreenshotGrabberDelegate* client, |
scoped_refptr<base::TaskRunner> blocking_task_runner) |
@@ -134,6 +169,8 @@ void ScreenshotGrabber::TakeScreenshot(gfx::NativeWindow window, |
aura::Window* aura_window = static_cast<aura::Window*>(window); |
is_partial = rect.size() != aura_window->bounds().size(); |
window_identifier = aura_window->GetBoundsInScreen().ToString(); |
+ |
+ cursor_hider_.reset(new ScopedCursorHider(aura_window->GetRootWindow())); |
#endif |
ui::GrabWindowSnapshotAsync( |
window, rect, blocking_task_runner_, |
@@ -152,6 +189,9 @@ void ScreenshotGrabber::NotifyScreenshotCompleted( |
ScreenshotGrabberObserver::Result screenshot_result, |
const base::FilePath& screenshot_path) { |
DCHECK(base::MessageLoopForUI::IsCurrent()); |
+#if defined(USE_AURA) |
+ cursor_hider_.reset(); |
+#endif |
FOR_EACH_OBSERVER(ScreenshotGrabberObserver, observers_, |
OnScreenshotCompleted(screenshot_result, screenshot_path)); |
} |