Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(444)

Side by Side Diff: chrome/browser/chromeos/policy/remote_commands/device_command_screenshot_job.cc

Issue 1135413002: Disable screenshot uploading if there has been user input. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Self-review Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <fstream> 7 #include <fstream>
8 8
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 } 183 }
184 upload_job_->Start(); 184 upload_job_->Start();
185 } 185 }
186 186
187 void DeviceCommandScreenshotJob::RunImpl( 187 void DeviceCommandScreenshotJob::RunImpl(
188 const CallbackWithResult& succeeded_callback, 188 const CallbackWithResult& succeeded_callback,
189 const CallbackWithResult& failed_callback) { 189 const CallbackWithResult& failed_callback) {
190 succeeded_callback_ = succeeded_callback; 190 succeeded_callback_ = succeeded_callback;
191 failed_callback_ = failed_callback; 191 failed_callback_ = failed_callback;
192 192
193 upload_job_ = screenshot_delegate_->CreateUploadJob(upload_url_, this); 193 // Fail if the delegate says screenshots are not allowed in this session.
194 DCHECK(upload_job_); 194 if (!screenshot_delegate_->IsScreenshotAllowed()) {
195 base::ThreadTaskRunnerHandle::Get()->PostTask(
196 FROM_HERE,
197 base::Bind(failed_callback_, base::Passed(make_scoped_ptr(
198 new Payload(FAILURE_USER_INPUT)))));
199 }
195 200
196 aura::Window::Windows root_windows = ash::Shell::GetAllRootWindows(); 201 aura::Window::Windows root_windows = ash::Shell::GetAllRootWindows();
197 202
198 // Immediately fail if there are no attached screens. 203 // Immediately fail if there are no attached screens.
199 if (root_windows.size() == 0) { 204 if (root_windows.size() == 0) {
200 base::ThreadTaskRunnerHandle::Get()->PostTask( 205 base::ThreadTaskRunnerHandle::Get()->PostTask(
201 FROM_HERE, 206 FROM_HERE,
202 base::Bind(failed_callback_, base::Passed(make_scoped_ptr(new Payload( 207 base::Bind(failed_callback_, base::Passed(make_scoped_ptr(new Payload(
203 FAILURE_SCREENSHOT_ACQUISITION))))); 208 FAILURE_SCREENSHOT_ACQUISITION)))));
204 } 209 }
205 210
211 upload_job_ = screenshot_delegate_->CreateUploadJob(upload_url_, this);
212 DCHECK(upload_job_);
213
206 // Post tasks to the sequenced worker pool for taking screenshots on each 214 // Post tasks to the sequenced worker pool for taking screenshots on each
207 // attached screen. 215 // attached screen.
208 num_pending_screenshots_ = root_windows.size(); 216 num_pending_screenshots_ = root_windows.size();
209 for (size_t screen = 0; screen < root_windows.size(); ++screen) { 217 for (size_t screen = 0; screen < root_windows.size(); ++screen) {
210 aura::Window* root_window = root_windows[screen]; 218 aura::Window* root_window = root_windows[screen];
211 gfx::Rect rect = root_window->bounds(); 219 gfx::Rect rect = root_window->bounds();
212 screenshot_delegate_->TakeSnapshot( 220 screenshot_delegate_->TakeSnapshot(
213 root_window, rect, 221 root_window, rect,
214 base::Bind(&RunStoreScreenshotOnTaskRunner, 222 base::Bind(&RunStoreScreenshotOnTaskRunner,
215 base::Bind(&DeviceCommandScreenshotJob::StoreScreenshot, 223 base::Bind(&DeviceCommandScreenshotJob::StoreScreenshot,
216 weak_ptr_factory_.GetWeakPtr(), screen), 224 weak_ptr_factory_.GetWeakPtr(), screen),
217 base::ThreadTaskRunnerHandle::Get())); 225 base::ThreadTaskRunnerHandle::Get()));
218 } 226 }
219 } 227 }
220 228
221 void DeviceCommandScreenshotJob::TerminateImpl() { 229 void DeviceCommandScreenshotJob::TerminateImpl() {
222 weak_ptr_factory_.InvalidateWeakPtrs(); 230 weak_ptr_factory_.InvalidateWeakPtrs();
223 } 231 }
224 232
225 } // namespace policy 233 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698