Elim cr-checkbox
[chromium-blink-merge.git] / chrome / browser / chromeos / policy / remote_commands / screenshot_delegate.h
blobfd15c7e7f5cb12e8226bf1783c5119a485ee219d
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_REMOTE_COMMANDS_SCREENSHOT_DELEGATE_H_
6 #define CHROME_BROWSER_CHROMEOS_POLICY_REMOTE_COMMANDS_SCREENSHOT_DELEGATE_H_
8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/task_runner.h"
13 #include "chrome/browser/chromeos/policy/remote_commands/device_command_screenshot_job.h"
14 #include "chrome/browser/chromeos/policy/upload_job.h"
15 #include "ui/gfx/geometry/rect.h"
16 #include "ui/gfx/native_widget_types.h"
17 #include "ui/snapshot/snapshot.h"
18 #include "url/gurl.h"
20 namespace policy {
22 // An implementation of the |DeviceCommandScreenshotJob::Delegate| that uses
23 // aura's GrabWindowSnapshotAsync() to acquire the window snapshot.
24 class ScreenshotDelegate : public DeviceCommandScreenshotJob::Delegate {
25 public:
26 explicit ScreenshotDelegate(
27 scoped_refptr<base::TaskRunner> blocking_task_runner);
28 ~ScreenshotDelegate() override;
30 // DeviceCommandScreenshotJob::Delegate:
31 bool IsScreenshotAllowed() override;
32 void TakeSnapshot(
33 gfx::NativeWindow window,
34 const gfx::Rect& source_rect,
35 const ui::GrabWindowSnapshotAsyncPNGCallback& callback) override;
36 scoped_ptr<UploadJob> CreateUploadJob(const GURL& upload_url,
37 UploadJob::Delegate* delegate) override;
39 private:
40 void StoreScreenshot(const ui::GrabWindowSnapshotAsyncPNGCallback& callback,
41 scoped_refptr<base::RefCountedBytes> png_data);
43 scoped_refptr<base::TaskRunner> blocking_task_runner_;
45 base::WeakPtrFactory<ScreenshotDelegate> weak_ptr_factory_;
47 DISALLOW_COPY_AND_ASSIGN(ScreenshotDelegate);
50 } // namespace policy
52 #endif // CHROME_BROWSER_CHROMEOS_POLICY_REMOTE_COMMANDS_SCREENSHOT_DELEGATE_H_