Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_REMOTE_COMMANDS_DEVICE_COMMAND_SCREENSHOT _JOB_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_REMOTE_COMMANDS_DEVICE_COMMAND_SCREENSHOT _JOB_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_POLICY_REMOTE_COMMANDS_DEVICE_COMMAND_SCREENSHOT _JOB_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POLICY_REMOTE_COMMANDS_DEVICE_COMMAND_SCREENSHOT _JOB_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/ref_counted_memory.h" | 14 #include "base/memory/ref_counted_memory.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/task_runner.h" | 17 #include "base/task_runner.h" |
| 18 #include "base/timer/timer.h" | 18 #include "base/timer/timer.h" |
| 19 #include "chrome/browser/chromeos/policy/upload_job.h" | 19 #include "chrome/browser/chromeos/policy/upload_job.h" |
| 20 #include "components/policy/core/common/remote_commands/remote_command_job.h" | 20 #include "components/policy/core/common/remote_commands/remote_command_job.h" |
| 21 #include "google_apis/gaia/oauth2_token_service.h" | 21 #include "google_apis/gaia/oauth2_token_service.h" |
| 22 #include "net/url_request/url_request_context_getter.h" | 22 #include "net/url_request/url_request_context_getter.h" |
| 23 #include "ui/snapshot/snapshot.h" | 23 #include "ui/snapshot/snapshot.h" |
| 24 #include "url/gurl.h" | 24 #include "url/gurl.h" |
| 25 | 25 |
| 26 namespace policy { | 26 namespace policy { |
| 27 | 27 |
| 28 class StatusUploader; | |
| 29 | |
| 28 // This class implementens a RemoteCommandJob that captures a screenshot from | 30 // This class implementens a RemoteCommandJob that captures a screenshot from |
| 29 // each attached screen and uploads the collected PNG data using UploadJob to | 31 // each attached screen and uploads the collected PNG data using UploadJob to |
| 30 // the url specified in the "fileUploadUrl" field of the CommandPayload. Only | 32 // the url specified in the "fileUploadUrl" field of the CommandPayload. Only |
| 31 // one instance of this command will be running at a time. The | 33 // one instance of this command will be running at a time. The |
| 32 // RemoteCommandsQueue owns all instances of this class. | 34 // RemoteCommandsQueue owns all instances of this class. |
| 33 class DeviceCommandScreenshotJob : public RemoteCommandJob, | 35 class DeviceCommandScreenshotJob : public RemoteCommandJob, |
| 34 public UploadJob::Delegate { | 36 public UploadJob::Delegate { |
| 35 public: | 37 public: |
| 36 // When the screenshot command terminates, the result payload that gets sent | 38 // When the screenshot command terminates, the result payload that gets sent |
| 37 // to the server is populated with one of the following result codes. These | 39 // to the server is populated with one of the following result codes. These |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 gfx::NativeWindow window, | 71 gfx::NativeWindow window, |
| 70 const gfx::Rect& source_rect, | 72 const gfx::Rect& source_rect, |
| 71 const ui::GrabWindowSnapshotAsyncPNGCallback& callback) = 0; | 73 const ui::GrabWindowSnapshotAsyncPNGCallback& callback) = 0; |
| 72 | 74 |
| 73 // Creates a new fully configured instance of an UploadJob. This method | 75 // Creates a new fully configured instance of an UploadJob. This method |
| 74 // may be called any number of times. | 76 // may be called any number of times. |
| 75 virtual scoped_ptr<UploadJob> CreateUploadJob(const GURL&, | 77 virtual scoped_ptr<UploadJob> CreateUploadJob(const GURL&, |
| 76 UploadJob::Delegate*) = 0; | 78 UploadJob::Delegate*) = 0; |
| 77 }; | 79 }; |
| 78 | 80 |
| 79 explicit DeviceCommandScreenshotJob(scoped_ptr<Delegate> screenshot_delegate); | 81 DeviceCommandScreenshotJob(scoped_ptr<Delegate> screenshot_delegate, |
| 82 StatusUploader* uploader); | |
|
cschuet (SLOW)
2015/05/13 15:56:09
This is quite a heavy dependency just to call a bo
Andrew T Wilson (Slow)
2015/05/15 09:43:51
Moved logic into ScreenshotDelegate - good call.
| |
| 80 ~DeviceCommandScreenshotJob() override; | 83 ~DeviceCommandScreenshotJob() override; |
| 81 | 84 |
| 82 // RemoteCommandJob: | 85 // RemoteCommandJob: |
| 83 enterprise_management::RemoteCommand_Type GetType() const override; | 86 enterprise_management::RemoteCommand_Type GetType() const override; |
| 84 | 87 |
| 85 private: | 88 private: |
| 86 class Payload; | 89 class Payload; |
| 87 | 90 |
| 88 // UploadJob::Delegate: | 91 // UploadJob::Delegate: |
| 89 void OnSuccess() override; | 92 void OnSuccess() override; |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 116 | 119 |
| 117 // Caches the already completed screenshots for the different displays. | 120 // Caches the already completed screenshots for the different displays. |
| 118 std::map<int, scoped_refptr<base::RefCountedBytes>> screenshots_; | 121 std::map<int, scoped_refptr<base::RefCountedBytes>> screenshots_; |
| 119 | 122 |
| 120 // The Delegate is used to acquire screenshots and create UploadJobs. | 123 // The Delegate is used to acquire screenshots and create UploadJobs. |
| 121 scoped_ptr<Delegate> screenshot_delegate_; | 124 scoped_ptr<Delegate> screenshot_delegate_; |
| 122 | 125 |
| 123 // The upload job instance that will upload the screenshots. | 126 // The upload job instance that will upload the screenshots. |
| 124 scoped_ptr<UploadJob> upload_job_; | 127 scoped_ptr<UploadJob> upload_job_; |
| 125 | 128 |
| 129 // StatusUploader used to check whether screenshot uploads are allowed in | |
| 130 // this session. | |
| 131 StatusUploader* status_uploader_; | |
| 132 | |
| 126 base::WeakPtrFactory<DeviceCommandScreenshotJob> weak_ptr_factory_; | 133 base::WeakPtrFactory<DeviceCommandScreenshotJob> weak_ptr_factory_; |
| 127 | 134 |
| 128 DISALLOW_COPY_AND_ASSIGN(DeviceCommandScreenshotJob); | 135 DISALLOW_COPY_AND_ASSIGN(DeviceCommandScreenshotJob); |
| 129 }; | 136 }; |
| 130 | 137 |
| 131 } // namespace policy | 138 } // namespace policy |
| 132 | 139 |
| 133 #endif // CHROME_BROWSER_CHROMEOS_POLICY_REMOTE_COMMANDS_DEVICE_COMMAND_SCREENS HOT_JOB_H_ | 140 #endif // CHROME_BROWSER_CHROMEOS_POLICY_REMOTE_COMMANDS_DEVICE_COMMAND_SCREENS HOT_JOB_H_ |
| OLD | NEW |