summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos
diff options
context:
space:
mode:
authorachuith@chromium.org <achuith@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-27 03:03:16 +0000
committerachuith@chromium.org <achuith@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-27 03:03:16 +0000
commit9ec4be8fef87de672f9741ac85a921510ad9da20 (patch)
treee4b8ec06d939689a3109c710c7f35bda9c4fc724 /chrome/browser/chromeos
parent8d56affe747035f60bdaf34295b46eb3a79346b0 (diff)
downloadchromium_src-9ec4be8fef87de672f9741ac85a921510ad9da20.zip
chromium_src-9ec4be8fef87de672f9741ac85a921510ad9da20.tar.gz
chromium_src-9ec4be8fef87de672f9741ac85a921510ad9da20.tar.bz2
GData save package support with MHTML.
* Introduce SavePackageFilePickerChromeOS, which derives from SavePackageFilePicker. * For gdata targets, we save the selected path, create a temporary mhtml file using WebContents::GenerateMHTML, and call GDataFileSystem::TransferFile to transfer the file to gdata. * For non-gdata targets, we just generate the mhtml file in place. * DownloadObserver::GetGDataTempDownloadPath is a static helper method to create a temporary gdata download file, used by SavePackageFilePickerChromeOS and DownloadFilePickerChromeOS. BUG=chromium-os:28210 TEST=Go to a web page, use Save As, or ctrl-s to save a page to docs. TBR=rdsmith@chromium.org Review URL: https://chromiumcodereview.appspot.com/9809011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129115 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos')
-rw-r--r--chrome/browser/chromeos/gdata/gdata_download_observer.cc15
-rw-r--r--chrome/browser/chromeos/gdata/gdata_download_observer.h6
-rw-r--r--chrome/browser/chromeos/gdata/gdata_file_system.cc1
3 files changed, 22 insertions, 0 deletions
diff --git a/chrome/browser/chromeos/gdata/gdata_download_observer.cc b/chrome/browser/chromeos/gdata/gdata_download_observer.cc
index f5cc19c..4f14a63 100644
--- a/chrome/browser/chromeos/gdata/gdata_download_observer.cc
+++ b/chrome/browser/chromeos/gdata/gdata_download_observer.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/chromeos/gdata/gdata_download_observer.h"
+#include "base/file_util.h"
#include "chrome/browser/chromeos/gdata/gdata_uploader.h"
#include "chrome/browser/chromeos/gdata/gdata_upload_file_info.h"
#include "chrome/browser/chromeos/gdata/gdata_util.h"
@@ -153,6 +154,20 @@ int GDataDownloadObserver::PercentComplete(DownloadItem* download) {
return -1;
}
+// |gdata_tmp_download_path| is set to a temporary local download path in
+// ~/GCache/v1/tmp/downloads/
+// static
+void GDataDownloadObserver::GetGDataTempDownloadPath(
+ const FilePath& gdata_tmp_download_dir,
+ FilePath* gdata_tmp_download_path) {
+ bool created = file_util::CreateDirectory(gdata_tmp_download_dir);
+ DCHECK(created) << "Can not create temp download directory at "
+ << gdata_tmp_download_dir.value();
+ created = file_util::CreateTemporaryFileInDir(gdata_tmp_download_dir,
+ gdata_tmp_download_path);
+ DCHECK(created) << "Temporary download file creation failed";
+}
+
void GDataDownloadObserver::ManagerGoingDown(
DownloadManager* download_manager) {
download_manager->RemoveObserver(this);
diff --git a/chrome/browser/chromeos/gdata/gdata_download_observer.h b/chrome/browser/chromeos/gdata/gdata_download_observer.h
index ef67487..8d5cf95 100644
--- a/chrome/browser/chromeos/gdata/gdata_download_observer.h
+++ b/chrome/browser/chromeos/gdata/gdata_download_observer.h
@@ -54,6 +54,12 @@ class GDataDownloadObserver : public content::DownloadManager::Observer,
// progress is unknown, returns -1.
static int PercentComplete(content::DownloadItem* download);
+ // Create a temporary file |gdata_tmp_download_path| in
+ // |gdata_tmp_download_dir|. Must be called on a thread that allows file
+ // operations.
+ static void GetGDataTempDownloadPath(const FilePath& gdata_tmp_download_dir,
+ FilePath* gdata_tmp_download_path);
+
private:
// Gets the gdata_path from external data in |download|.
// GetGDataPath may return an empty path in case SetGDataPath was not
diff --git a/chrome/browser/chromeos/gdata/gdata_file_system.cc b/chrome/browser/chromeos/gdata/gdata_file_system.cc
index c2649b5..7f86155 100644
--- a/chrome/browser/chromeos/gdata/gdata_file_system.cc
+++ b/chrome/browser/chromeos/gdata/gdata_file_system.cc
@@ -631,6 +631,7 @@ void GDataFileSystem::TransferFile(const FilePath& local_file_path,
if (!dest_dir || !dest_dir->AsGDataDirectory()) {
base::MessageLoopProxy::current()->PostTask(FROM_HERE,
base::Bind(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND));
+ NOTREACHED();
return;
}