| 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 #include "chrome/browser/chromeos/policy/remote_commands/device_command_screensh
ot_job.h" | 5 #include "chrome/browser/chromeos/policy/remote_commands/device_command_screensh
ot_job.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 public: | 141 public: |
| 142 MockScreenshotDelegate( | 142 MockScreenshotDelegate( |
| 143 std::unique_ptr<UploadJob::ErrorCode> upload_job_error_code, | 143 std::unique_ptr<UploadJob::ErrorCode> upload_job_error_code, |
| 144 bool screenshot_allowed); | 144 bool screenshot_allowed); |
| 145 ~MockScreenshotDelegate() override; | 145 ~MockScreenshotDelegate() override; |
| 146 | 146 |
| 147 bool IsScreenshotAllowed() override; | 147 bool IsScreenshotAllowed() override; |
| 148 void TakeSnapshot( | 148 void TakeSnapshot( |
| 149 gfx::NativeWindow window, | 149 gfx::NativeWindow window, |
| 150 const gfx::Rect& source_rect, | 150 const gfx::Rect& source_rect, |
| 151 const ui::GrabWindowSnapshotAsyncPNGCallback& callback) override; | 151 const ui::GrabWindowSnapshotAsyncEncodedCallback& callback) override; |
| 152 std::unique_ptr<UploadJob> CreateUploadJob(const GURL&, | 152 std::unique_ptr<UploadJob> CreateUploadJob(const GURL&, |
| 153 UploadJob::Delegate*) override; | 153 UploadJob::Delegate*) override; |
| 154 | 154 |
| 155 private: | 155 private: |
| 156 std::unique_ptr<UploadJob::ErrorCode> upload_job_error_code_; | 156 std::unique_ptr<UploadJob::ErrorCode> upload_job_error_code_; |
| 157 bool screenshot_allowed_; | 157 bool screenshot_allowed_; |
| 158 }; | 158 }; |
| 159 | 159 |
| 160 MockScreenshotDelegate::MockScreenshotDelegate( | 160 MockScreenshotDelegate::MockScreenshotDelegate( |
| 161 std::unique_ptr<UploadJob::ErrorCode> upload_job_error_code, | 161 std::unique_ptr<UploadJob::ErrorCode> upload_job_error_code, |
| 162 bool screenshot_allowed) | 162 bool screenshot_allowed) |
| 163 : upload_job_error_code_(std::move(upload_job_error_code)), | 163 : upload_job_error_code_(std::move(upload_job_error_code)), |
| 164 screenshot_allowed_(screenshot_allowed) {} | 164 screenshot_allowed_(screenshot_allowed) {} |
| 165 | 165 |
| 166 MockScreenshotDelegate::~MockScreenshotDelegate() { | 166 MockScreenshotDelegate::~MockScreenshotDelegate() { |
| 167 } | 167 } |
| 168 | 168 |
| 169 bool MockScreenshotDelegate::IsScreenshotAllowed() { | 169 bool MockScreenshotDelegate::IsScreenshotAllowed() { |
| 170 return screenshot_allowed_; | 170 return screenshot_allowed_; |
| 171 } | 171 } |
| 172 | 172 |
| 173 void MockScreenshotDelegate::TakeSnapshot( | 173 void MockScreenshotDelegate::TakeSnapshot( |
| 174 gfx::NativeWindow window, | 174 gfx::NativeWindow window, |
| 175 const gfx::Rect& source_rect, | 175 const gfx::Rect& source_rect, |
| 176 const ui::GrabWindowSnapshotAsyncPNGCallback& callback) { | 176 const ui::GrabWindowSnapshotAsyncEncodedCallback& callback) { |
| 177 const int width = source_rect.width(); | 177 const int width = source_rect.width(); |
| 178 const int height = source_rect.height(); | 178 const int height = source_rect.height(); |
| 179 scoped_refptr<base::RefCountedBytes> test_png = | 179 scoped_refptr<base::RefCountedBytes> test_png = |
| 180 GenerateTestPNG(width, height); | 180 GenerateTestPNG(width, height); |
| 181 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 181 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, |
| 182 base::Bind(callback, test_png)); | 182 base::Bind(callback, test_png)); |
| 183 } | 183 } |
| 184 | 184 |
| 185 std::unique_ptr<UploadJob> MockScreenshotDelegate::CreateUploadJob( | 185 std::unique_ptr<UploadJob> MockScreenshotDelegate::CreateUploadJob( |
| 186 const GURL& upload_url, | 186 const GURL& upload_url, |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 base::Bind(&DeviceCommandScreenshotTest::VerifyResults, | 309 base::Bind(&DeviceCommandScreenshotTest::VerifyResults, |
| 310 base::Unretained(this), base::Unretained(job.get()), | 310 base::Unretained(this), base::Unretained(job.get()), |
| 311 RemoteCommandJob::FAILED, | 311 RemoteCommandJob::FAILED, |
| 312 CreatePayloadFromResultCode( | 312 CreatePayloadFromResultCode( |
| 313 DeviceCommandScreenshotJob::FAILURE_AUTHENTICATION))); | 313 DeviceCommandScreenshotJob::FAILURE_AUTHENTICATION))); |
| 314 EXPECT_TRUE(success); | 314 EXPECT_TRUE(success); |
| 315 run_loop_.Run(); | 315 run_loop_.Run(); |
| 316 } | 316 } |
| 317 | 317 |
| 318 } // namespace policy | 318 } // namespace policy |
| OLD | NEW |