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/screenshot_delegate.h" | 5 #include "chrome/browser/chromeos/policy/remote_commands/screenshot_delegate.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/syslog_logging.h" | 8 #include "base/syslog_logging.h" |
9 #include "base/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 // shutdown (and unit tests) - don't allow screenshots unless we have a | 35 // shutdown (and unit tests) - don't allow screenshots unless we have a |
36 // StatusUploader that can confirm that screenshots are allowed. | 36 // StatusUploader that can confirm that screenshots are allowed. |
37 return manager && manager->GetStatusUploader() && | 37 return manager && manager->GetStatusUploader() && |
38 manager->GetStatusUploader()->IsSessionDataUploadAllowed(); | 38 manager->GetStatusUploader()->IsSessionDataUploadAllowed(); |
39 } | 39 } |
40 | 40 |
41 void ScreenshotDelegate::TakeSnapshot( | 41 void ScreenshotDelegate::TakeSnapshot( |
42 gfx::NativeWindow window, | 42 gfx::NativeWindow window, |
43 const gfx::Rect& source_rect, | 43 const gfx::Rect& source_rect, |
44 const ui::GrabWindowSnapshotAsyncPNGCallback& callback) { | 44 const ui::GrabWindowSnapshotAsyncPNGCallback& callback) { |
45 ui::GrabWindowSnapshotAsyncPNG( | 45 ui::GrabWindowSnapshotAsync( |
46 window, source_rect, blocking_task_runner_, | 46 window, source_rect, blocking_task_runner_, |
47 base::Bind(&ScreenshotDelegate::StoreScreenshot, | 47 base::Bind(&ScreenshotDelegate::StoreScreenshot, |
48 weak_ptr_factory_.GetWeakPtr(), callback)); | 48 weak_ptr_factory_.GetWeakPtr(), callback)); |
49 } | 49 } |
50 | 50 |
51 std::unique_ptr<UploadJob> ScreenshotDelegate::CreateUploadJob( | 51 std::unique_ptr<UploadJob> ScreenshotDelegate::CreateUploadJob( |
52 const GURL& upload_url, | 52 const GURL& upload_url, |
53 UploadJob::Delegate* delegate) { | 53 UploadJob::Delegate* delegate) { |
54 chromeos::DeviceOAuth2TokenService* device_oauth2_token_service = | 54 chromeos::DeviceOAuth2TokenService* device_oauth2_token_service = |
55 chromeos::DeviceOAuth2TokenServiceFactory::Get(); | 55 chromeos::DeviceOAuth2TokenServiceFactory::Get(); |
56 | 56 |
57 scoped_refptr<net::URLRequestContextGetter> system_request_context = | 57 scoped_refptr<net::URLRequestContextGetter> system_request_context = |
58 g_browser_process->system_request_context(); | 58 g_browser_process->system_request_context(); |
59 std::string robot_account_id = | 59 std::string robot_account_id = |
60 device_oauth2_token_service->GetRobotAccountId(); | 60 device_oauth2_token_service->GetRobotAccountId(); |
61 | 61 |
62 SYSLOG(INFO) << "Creating upload job for screenshot"; | 62 SYSLOG(INFO) << "Creating upload job for screenshot"; |
63 return std::unique_ptr<UploadJob>(new UploadJobImpl( | 63 return std::unique_ptr<UploadJob>(new UploadJobImpl( |
64 upload_url, robot_account_id, device_oauth2_token_service, | 64 upload_url, robot_account_id, device_oauth2_token_service, |
65 system_request_context, delegate, | 65 system_request_context, delegate, |
66 base::WrapUnique(new UploadJobImpl::RandomMimeBoundaryGenerator), | 66 base::WrapUnique(new UploadJobImpl::RandomMimeBoundaryGenerator), |
67 base::ThreadTaskRunnerHandle::Get())); | 67 base::ThreadTaskRunnerHandle::Get())); |
68 } | 68 } |
69 | 69 |
70 void ScreenshotDelegate::StoreScreenshot( | 70 void ScreenshotDelegate::StoreScreenshot( |
71 const ui::GrabWindowSnapshotAsyncPNGCallback& callback, | 71 const ui::GrabWindowSnapshotAsyncPNGCallback& callback, |
72 scoped_refptr<base::RefCountedMemory> png_data) { | 72 scoped_refptr<base::RefCountedBytes> png_data) { |
73 callback.Run(png_data); | 73 callback.Run(png_data); |
74 } | 74 } |
75 | 75 |
76 } // namespace policy | 76 } // namespace policy |
OLD | NEW |