OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/webui/screenshot_source.h" | 5 #include "chrome/browser/ui/webui/screenshot_source.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 decoded.data(), decoded.length())); | 194 decoded.data(), decoded.length())); |
195 | 195 |
196 base::FilePath download_path; | 196 base::FilePath download_path; |
197 GetScreenshotDirectory(&download_path); | 197 GetScreenshotDirectory(&download_path); |
198 if (drive::util::IsUnderDriveMountPoint(download_path)) { | 198 if (drive::util::IsUnderDriveMountPoint(download_path)) { |
199 drive::FileSystemInterface* file_system = | 199 drive::FileSystemInterface* file_system = |
200 drive::DriveIntegrationServiceFactory::GetForProfile( | 200 drive::DriveIntegrationServiceFactory::GetForProfile( |
201 profile_)->file_system(); | 201 profile_)->file_system(); |
202 file_system->GetFileByResourceId( | 202 file_system->GetFileByResourceId( |
203 decoded_filename, | 203 decoded_filename, |
204 drive::DriveClientContext(drive::USER_INITIATED), | 204 drive::ClientContext(drive::USER_INITIATED), |
205 base::Bind(&ScreenshotSource::GetSavedScreenshotCallback, | 205 base::Bind(&ScreenshotSource::GetSavedScreenshotCallback, |
206 base::Unretained(this), screenshot_path, callback), | 206 base::Unretained(this), screenshot_path, callback), |
207 google_apis::GetContentCallback()); | 207 google_apis::GetContentCallback()); |
208 } else { | 208 } else { |
209 BrowserThread::PostTask( | 209 BrowserThread::PostTask( |
210 BrowserThread::FILE, FROM_HERE, | 210 BrowserThread::FILE, FROM_HERE, |
211 base::Bind(&ScreenshotSource::SendSavedScreenshot, | 211 base::Bind(&ScreenshotSource::SendSavedScreenshot, |
212 base::Unretained(this), | 212 base::Unretained(this), |
213 screenshot_path, | 213 screenshot_path, |
214 callback, download_path.Append(decoded_filename))); | 214 callback, download_path.Append(decoded_filename))); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 void ScreenshotSource::CacheAndSendScreenshot( | 263 void ScreenshotSource::CacheAndSendScreenshot( |
264 const std::string& screenshot_path, | 264 const std::string& screenshot_path, |
265 const content::URLDataSource::GotDataCallback& callback, | 265 const content::URLDataSource::GotDataCallback& callback, |
266 ScreenshotDataPtr bytes) { | 266 ScreenshotDataPtr bytes) { |
267 // Strip the query from the screenshot path. | 267 // Strip the query from the screenshot path. |
268 std::string path = screenshot_path.substr( | 268 std::string path = screenshot_path.substr( |
269 0, screenshot_path.find_first_of("?")); | 269 0, screenshot_path.find_first_of("?")); |
270 cached_screenshots_[path] = bytes; | 270 cached_screenshots_[path] = bytes; |
271 callback.Run(new base::RefCountedBytes(*bytes)); | 271 callback.Run(new base::RefCountedBytes(*bytes)); |
272 } | 272 } |
OLD | NEW |