diff options
author | achuith@chromium.org <achuith@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-08 23:05:36 +0000 |
---|---|---|
committer | achuith@chromium.org <achuith@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-08 23:05:36 +0000 |
commit | 31ee43f906c22d4ef85a7ca02ca07d0e1851b686 (patch) | |
tree | c0ed53bd783bb7da166ad4b9f6f6b2d6fc3d25ab /content | |
parent | 42132be3f9f8aadc2de3f8c29ece41e19a4f6281 (diff) | |
download | chromium_src-31ee43f906c22d4ef85a7ca02ca07d0e1851b686.zip chromium_src-31ee43f906c22d4ef85a7ca02ca07d0e1851b686.tar.gz chromium_src-31ee43f906c22d4ef85a7ca02ca07d0e1851b686.tar.bz2 |
Support for drive as default download location on chromeos.
* Add SubstituteGDataDownloadPathCallback step between CheckVisitedReferrerBeforeDone and CheckIfSuggestedPathExists.
* Change the signature of ChooseDownloadPath with DownloadItem* arg only.
* DownloadFilePicker has an empty ctor and does most of the work in Init() now.
* DownloadFilePicker::SetSuggestedPath is a virtual that is overriden by DownloadFilePickerChromeOS to suggest the gdata path instead.
* GetSaveDir takes an addition skip_dir_check boolean param. We shouldn't do the directory existence check for cloud folders.
BUG=127159
TEST=manual
TBR=rdsmith@chromium.org,avi@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10501014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141318 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/download/download_manager_impl.cc | 5 | ||||
-rw-r--r-- | content/browser/download/download_manager_impl_unittest.cc | 10 | ||||
-rw-r--r-- | content/browser/download/save_package.cc | 10 | ||||
-rw-r--r-- | content/browser/download/save_package.h | 1 | ||||
-rw-r--r-- | content/public/browser/download_manager_delegate.h | 7 | ||||
-rw-r--r-- | content/shell/shell_download_manager_delegate.cc | 12 | ||||
-rw-r--r-- | content/shell/shell_download_manager_delegate.h | 4 |
7 files changed, 22 insertions, 27 deletions
diff --git a/content/browser/download/download_manager_impl.cc b/content/browser/download/download_manager_impl.cc index 6b1875d..479d07a 100644 --- a/content/browser/download/download_manager_impl.cc +++ b/content/browser/download/download_manager_impl.cc @@ -398,11 +398,8 @@ void DownloadManagerImpl::RestartDownload(int32 download_id) { if (download->GetTargetDisposition() == DownloadItem::TARGET_DISPOSITION_PROMPT) { // We must ask the user for the place to put the download. - WebContents* contents = download->GetWebContents(); - if (delegate_) { - delegate_->ChooseDownloadPath(contents, download->GetTargetFilePath(), - download_id); + delegate_->ChooseDownloadPath(download); FOR_EACH_OBSERVER(Observer, observers_, SelectFileDialogDisplayed(this, download_id)); } else { diff --git a/content/browser/download/download_manager_impl_unittest.cc b/content/browser/download/download_manager_impl_unittest.cc index fe6f4a2..49b022a 100644 --- a/content/browser/download/download_manager_impl_unittest.cc +++ b/content/browser/download/download_manager_impl_unittest.cc @@ -145,26 +145,24 @@ class TestDownloadManagerDelegate : public content::DownloadManagerDelegate { } } - virtual void ChooseDownloadPath(WebContents* web_contents, - const FilePath& suggested_path, - int32 download_id) OVERRIDE { + virtual void ChooseDownloadPath(DownloadItem* item) OVERRIDE { if (!expected_suggested_path_.empty()) { EXPECT_STREQ(expected_suggested_path_.value().c_str(), - suggested_path.value().c_str()); + item->GetTargetFilePath().value().c_str()); } if (file_selection_response_.empty()) { BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, base::Bind(&DownloadManager::FileSelectionCanceled, download_manager_, - download_id)); + item->GetId())); } else { BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, base::Bind(&DownloadManager::FileSelected, download_manager_, file_selection_response_, - download_id)); + item->GetId())); } expected_suggested_path_.clear(); file_selection_response_.clear(); diff --git a/content/browser/download/save_package.cc b/content/browser/download/save_package.cc index 383342f..d138602 100644 --- a/content/browser/download/save_package.cc +++ b/content/browser/download/save_package.cc @@ -1239,10 +1239,11 @@ void SavePackage::GetSaveInfo() { // Can't use web_contents_ in the file thread, so get the data that we need // before calling to it. FilePath website_save_dir, download_save_dir; + bool skip_dir_check; DCHECK(download_manager_); if (download_manager_->GetDelegate()) { download_manager_->GetDelegate()->GetSaveDir( - web_contents(), &website_save_dir, &download_save_dir); + web_contents(), &website_save_dir, &download_save_dir, &skip_dir_check); } std::string mime_type = web_contents()->GetContentsMimeType(); std::string accept_languages = @@ -1252,17 +1253,20 @@ void SavePackage::GetSaveInfo() { BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, base::Bind(&SavePackage::CreateDirectoryOnFileThread, this, - website_save_dir, download_save_dir, mime_type, accept_languages)); + website_save_dir, download_save_dir, skip_dir_check, + mime_type, accept_languages)); } void SavePackage::CreateDirectoryOnFileThread( const FilePath& website_save_dir, const FilePath& download_save_dir, + bool skip_dir_check, const std::string& mime_type, const std::string& accept_langs) { FilePath save_dir; // If the default html/websites save folder doesn't exist... - if (!file_util::DirectoryExists(website_save_dir)) { + // We skip the directory check for gdata directories on ChromeOS. + if (!skip_dir_check && !file_util::DirectoryExists(website_save_dir)) { // If the default download dir doesn't exist, create it. if (!file_util::DirectoryExists(download_save_dir)) { bool res = file_util::CreateDirectory(download_save_dir); diff --git a/content/browser/download/save_package.h b/content/browser/download/save_package.h index d35b9c3..2343843 100644 --- a/content/browser/download/save_package.h +++ b/content/browser/download/save_package.h @@ -189,6 +189,7 @@ class CONTENT_EXPORT SavePackage void CreateDirectoryOnFileThread(const FilePath& website_save_dir, const FilePath& download_save_dir, + bool skip_dir_check, const std::string& mime_type, const std::string& accept_langs); void ContinueGetSaveInfo(const FilePath& suggested_path, diff --git a/content/public/browser/download_manager_delegate.h b/content/public/browser/download_manager_delegate.h index a5f77e8..84a5db6 100644 --- a/content/public/browser/download_manager_delegate.h +++ b/content/public/browser/download_manager_delegate.h @@ -52,9 +52,7 @@ class CONTENT_EXPORT DownloadManagerDelegate { // Asks the user for the path for a download. The delegate calls // DownloadManager::FileSelected or DownloadManager::FileSelectionCanceled to // give the answer. - virtual void ChooseDownloadPath(WebContents* web_contents, - const FilePath& suggested_path, - int32 download_id) {} + virtual void ChooseDownloadPath(DownloadItem* item) {} // Allows the embedder to set an intermediate name for the download until it's // complete. The return value is the intermediate path to use. If the embedder @@ -124,7 +122,8 @@ class CONTENT_EXPORT DownloadManagerDelegate { // Retrieve the directories to save html pages and downloads to. virtual void GetSaveDir(WebContents* web_contents, FilePath* website_save_dir, - FilePath* download_save_dir) {} + FilePath* download_save_dir, + bool* skip_dir_check) {} // Asks the user for the path to save a page. The delegate calls the callback // to give the answer. diff --git a/content/shell/shell_download_manager_delegate.cc b/content/shell/shell_download_manager_delegate.cc index 3c8309a..2bb5425 100644 --- a/content/shell/shell_download_manager_delegate.cc +++ b/content/shell/shell_download_manager_delegate.cc @@ -96,19 +96,17 @@ void ShellDownloadManagerDelegate::RestartDownload( download_manager_->RestartDownload(download_id); } -void ShellDownloadManagerDelegate::ChooseDownloadPath( - WebContents* web_contents, - const FilePath& suggested_path, - int32 download_id) { +void ShellDownloadManagerDelegate::ChooseDownloadPath(DownloadItem* item) { FilePath result; #if defined(OS_WIN) && !defined(USE_AURA) + const FilePath suggested_path(item->GetTargetFilePath()); std::wstring file_part = FilePath(suggested_path).BaseName().value(); wchar_t file_name[MAX_PATH]; base::wcslcpy(file_name, file_part.c_str(), arraysize(file_name)); OPENFILENAME save_as; ZeroMemory(&save_as, sizeof(save_as)); save_as.lStructSize = sizeof(OPENFILENAME); - save_as.hwndOwner = web_contents->GetNativeView(); + save_as.hwndOwner = item->GetWebContents()->GetNativeView(); save_as.lpstrFile = file_name; save_as.nMaxFile = arraysize(file_name); @@ -127,9 +125,9 @@ void ShellDownloadManagerDelegate::ChooseDownloadPath( #endif if (result.empty()) { - download_manager_->FileSelectionCanceled(download_id); + download_manager_->FileSelectionCanceled(item->GetId()); } else { - download_manager_->FileSelected(result, download_id); + download_manager_->FileSelected(result, item->GetId()); } } diff --git a/content/shell/shell_download_manager_delegate.h b/content/shell/shell_download_manager_delegate.h index b9387c8..ee362ba 100644 --- a/content/shell/shell_download_manager_delegate.h +++ b/content/shell/shell_download_manager_delegate.h @@ -23,9 +23,7 @@ class ShellDownloadManagerDelegate void SetDownloadManager(DownloadManager* manager); virtual bool ShouldStartDownload(int32 download_id) OVERRIDE; - virtual void ChooseDownloadPath(WebContents* web_contents, - const FilePath& suggested_path, - int32 download_id) OVERRIDE; + virtual void ChooseDownloadPath(DownloadItem* item) OVERRIDE; private: friend class base::RefCountedThreadSafe<ShellDownloadManagerDelegate>; |