Index: chrome/browser/ui/webui/screenshot_source.cc |
diff --git a/chrome/browser/ui/webui/screenshot_source.cc b/chrome/browser/ui/webui/screenshot_source.cc |
index 15d0d57090d1a715a60ba9caec211875800aabab..d1e8235473361995aeeb3960d9c8e5175311d510 100644 |
--- a/chrome/browser/ui/webui/screenshot_source.cc |
+++ b/chrome/browser/ui/webui/screenshot_source.cc |
@@ -21,6 +21,9 @@ |
#if defined(OS_CHROMEOS) |
#include "ash/shell.h" |
#include "ash/shell_delegate.h" |
+#include "chrome/browser/chromeos/gdata/gdata_file_system_interface.h" |
+#include "chrome/browser/chromeos/gdata/gdata_system_service.h" |
+#include "chrome/browser/chromeos/gdata/gdata_util.h" |
#include "content/public/browser/browser_thread.h" |
#endif |
@@ -30,8 +33,10 @@ static const char kSavedScreenshotsBasePath[] = "saved/"; |
#endif |
ScreenshotSource::ScreenshotSource( |
- std::vector<unsigned char>* current_screenshot) |
- : DataSource(chrome::kChromeUIScreenshotPath, MessageLoop::current()) { |
+ std::vector<unsigned char>* current_screenshot, |
+ Profile* profile) |
+ : DataSource(chrome::kChromeUIScreenshotPath, MessageLoop::current()), |
+ profile_(profile) { |
// Setup the last screenshot taken. |
if (current_screenshot) |
current_screenshot_.reset(new ScreenshotData(*current_screenshot)); |
@@ -90,7 +95,6 @@ void ScreenshotSource::SendScreenshot(const std::string& screenshot_path, |
#if defined(OS_CHROMEOS) |
void ScreenshotSource::SendSavedScreenshot(const std::string& screenshot_path, |
int request_id) { |
- ScreenshotDataPtr read_bytes(new ScreenshotData); |
std::string filename = screenshot_path.substr( |
strlen(kSavedScreenshotsBasePath)); |
@@ -101,11 +105,42 @@ void ScreenshotSource::SendSavedScreenshot(const std::string& screenshot_path, |
std::string decoded_filename = UTF16ToASCII(string16( |
decoded.data(), decoded.length())); |
- int64 file_size = 0; |
DownloadPrefs* download_prefs = DownloadPrefs::FromBrowserContext( |
ash::Shell::GetInstance()->delegate()->GetCurrentBrowserContext()); |
- FilePath file = download_prefs->DownloadPath().Append(decoded_filename); |
- if (!file_util::GetFileSize(file, &file_size)) { |
+ FilePath download_path = download_prefs->DownloadPath(); |
+ if (gdata::util::IsUnderGDataMountPoint(download_path)) { |
+ gdata::GDataFileSystemInterface* file_system = |
+ gdata::GDataSystemServiceFactory::GetForProfile( |
+ profile_)->file_system(); |
+ file_system->GetFileByResourceId( |
kinaba
2012/08/15 08:19:57
The method is DCHECKED to run on UI or IO thread,
Jun Mukai
2012/08/15 08:30:42
Aagh, right. Modified to do that.
|
+ decoded_filename, |
+ base::Bind(&ScreenshotSource::SendSavedScreenshotInternal, |
+ base::Unretained(this), screenshot_path, request_id), |
+ gdata::GetContentCallback()); |
+ } else { |
+ SendSavedScreenshotInternal(screenshot_path, |
+ request_id, |
+ gdata::GDATA_FILE_OK, |
+ download_path.Append(decoded_filename), |
+ "", |
+ gdata::REGULAR_FILE); |
+ } |
+ |
+} |
+ |
+void ScreenshotSource::SendSavedScreenshotInternal( |
+ const std::string& screenshot_path, |
+ int request_id, |
+ gdata::GDataFileError error, |
+ const FilePath& file, |
+ const std::string& mime_type, |
+ gdata::GDataFileType file_type) { |
+ ScreenshotDataPtr read_bytes(new ScreenshotData); |
+ int64 file_size = 0; |
+ |
+ if (error != gdata::GDATA_FILE_OK || |
+ file_type != gdata::REGULAR_FILE || |
+ !file_util::GetFileSize(file, &file_size)) { |
CacheAndSendScreenshot(screenshot_path, request_id, read_bytes); |
return; |
} |