Chromium Code Reviews| Index: ui/snapshot/screenshot_grabber.cc |
| diff --git a/ui/snapshot/screenshot_grabber.cc b/ui/snapshot/screenshot_grabber.cc |
| index 4534a857b4beab8a5b77dc15a825a6098b8a508e..16bc3e6f8dbd099f77e4305dff94c67821cd3557 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,34 @@ void ScreenshotGrabberDelegate::PrepareFileAndRunOnBlockingPool( |
| base::Bind(EnsureLocalDirectoryExists, path, callback_on_blocking_pool)); |
| } |
| +#if defined(USE_AURA) |
| +class ScreenshotGrabber::ScopedCursorHider { |
| + public: |
| + static std::unique_ptr<ScopedCursorHider> Get(aura::Window* window) { |
|
sky
2016/07/22 23:35:04
nit: Get->Create, with a suitable description that
Qiang(Joe) Xu
2016/07/22 23:48:09
Done.
|
| + DCHECK(window->IsRootWindow()); |
| + aura::client::CursorClient* cursor_client = |
| + aura::client::GetCursorClient(window); |
| + if (!cursor_client) |
| + return nullptr; |
| + cursor_client->HideCursor(); |
| + return std::unique_ptr<ScopedCursorHider>( |
| + base::WrapUnique(new ScopedCursorHider(window))); |
| + } |
| + |
| + ~ScopedCursorHider() { |
| + aura::client::CursorClient* cursor_client = |
| + aura::client::GetCursorClient(window_); |
| + cursor_client->ShowCursor(); |
| + } |
| + |
| + private: |
| + explicit ScopedCursorHider(aura::Window* window) : window_(window) {} |
| + aura::Window* window_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ScopedCursorHider); |
| +}; |
| +#endif |
| + |
| ScreenshotGrabber::ScreenshotGrabber( |
| ScreenshotGrabberDelegate* client, |
| scoped_refptr<base::TaskRunner> blocking_task_runner) |
| @@ -134,6 +163,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_ = ScopedCursorHider::Get(aura_window->GetRootWindow()); |
| #endif |
| ui::GrabWindowSnapshotAsync( |
| window, rect, blocking_task_runner_, |
| @@ -152,6 +183,10 @@ void ScreenshotGrabber::NotifyScreenshotCompleted( |
| ScreenshotGrabberObserver::Result screenshot_result, |
| const base::FilePath& screenshot_path) { |
| DCHECK(base::MessageLoopForUI::IsCurrent()); |
| +#if defined(USE_AURA) |
| + if (cursor_hider_) |
|
sky
2016/07/22 23:35:04
You don't need the conditional here, cursor_hider_
Qiang(Joe) Xu
2016/07/22 23:48:09
Done.
|
| + cursor_hider_.reset(); |
| +#endif |
| FOR_EACH_OBSERVER(ScreenshotGrabberObserver, observers_, |
| OnScreenshotCompleted(screenshot_result, screenshot_path)); |
| } |