Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Unified Diff: chrome/browser/download/chrome_download_manager_delegate.cc

Issue 12662032: Merge SavePackageFilePicker{,ChromeOS} (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: @r198452 Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/download/chrome_download_manager_delegate.cc
diff --git a/chrome/browser/download/chrome_download_manager_delegate.cc b/chrome/browser/download/chrome_download_manager_delegate.cc
index 90e9755bc83a1ea5c14bb6086275e9fc3c59191a..76538ec6a9de68f332d682540353c78f4f28b5f3 100644
--- a/chrome/browser/download/chrome_download_manager_delegate.cc
+++ b/chrome/browser/download/chrome_download_manager_delegate.cc
@@ -44,10 +44,8 @@
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/drive/download_handler.h"
#include "chrome/browser/chromeos/drive/file_system_util.h"
-#include "chrome/browser/download/save_package_file_picker_chromeos.h"
#endif
-using content::BrowserContext;
using content::BrowserThread;
using content::DownloadId;
using content::DownloadItem;
@@ -137,17 +135,6 @@ void CheckDownloadUrlDone(
} // namespace
-// static
-void ChromeDownloadManagerDelegate::RegisterUserPrefs(
- user_prefs::PrefRegistrySyncable* registry) {
- const base::FilePath& default_download_path =
- download_util::GetDefaultDownloadDirectory();
- registry->RegisterFilePathPref(
- prefs::kSaveFileDefaultDirectory,
- default_download_path,
- user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
-}
-
ChromeDownloadManagerDelegate::ChromeDownloadManagerDelegate(Profile* profile)
: profile_(profile),
next_download_id_(0),
@@ -169,8 +156,8 @@ DownloadId ChromeDownloadManagerDelegate::GetNextId() {
if (!profile_->IsOffTheRecord())
return DownloadId(this, next_download_id_++);
- return BrowserContext::GetDownloadManager(profile_->GetOriginalProfile())->
- GetDelegate()->GetNextId();
+ return content::BrowserContext::GetDownloadManager(
+ profile_->GetOriginalProfile())->GetDelegate()->GetNextId();
}
bool ChromeDownloadManagerDelegate::DetermineDownloadTarget(
@@ -178,7 +165,6 @@ bool ChromeDownloadManagerDelegate::DetermineDownloadTarget(
const content::DownloadTargetCallback& callback) {
DownloadTargetDeterminer::Start(download,
download_prefs_.get(),
- last_download_path_,
this,
callback);
return true;
@@ -296,28 +282,15 @@ bool ChromeDownloadManagerDelegate::GenerateFileHash() {
}
void ChromeDownloadManagerDelegate::GetSaveDir(
- BrowserContext* browser_context,
+ content::BrowserContext* browser_context,
base::FilePath* website_save_dir,
base::FilePath* download_save_dir,
bool* skip_dir_check) {
Profile* profile = Profile::FromBrowserContext(browser_context);
PrefService* prefs = profile->GetPrefs();
- // Check whether the preference for the preferred directory for
- // saving file has been explicitly set. If not, and the preference
- // for the default download directory has been set, initialize it
- // with the latter. Note that the defaults for both are the same.
- const PrefService::Preference* download_default_directory =
- prefs->FindPreference(prefs::kDownloadDefaultDirectory);
- if (!download_default_directory->IsDefaultValue() &&
- prefs->FindPreference(
- prefs::kSaveFileDefaultDirectory)->IsDefaultValue()) {
- prefs->Set(prefs::kSaveFileDefaultDirectory,
- *(download_default_directory->GetValue()));
- }
-
// Get the directory from preference.
- *website_save_dir = prefs->GetFilePath(prefs::kSaveFileDefaultDirectory);
+ *website_save_dir = download_prefs_->SaveFilePath();
DCHECK(!website_save_dir->empty());
*download_save_dir = prefs->GetFilePath(prefs::kDownloadDefaultDirectory);
@@ -335,13 +308,6 @@ void ChromeDownloadManagerDelegate::ChooseSavePath(
bool can_save_as_complete,
const content::SavePackagePathPickedCallback& callback) {
// Deletes itself.
-#if defined(OS_CHROMEOS)
- new SavePackageFilePickerChromeOS(
- web_contents,
- suggested_path,
- can_save_as_complete,
- callback);
-#else
new SavePackageFilePicker(
web_contents,
suggested_path,
@@ -349,7 +315,6 @@ void ChromeDownloadManagerDelegate::ChooseSavePath(
can_save_as_complete,
download_prefs_.get(),
callback);
-#endif
}
void ChromeDownloadManagerDelegate::OpenDownload(DownloadItem* download) {
@@ -379,10 +344,6 @@ void ChromeDownloadManagerDelegate::CheckForFileExistence(
callback);
}
-void ChromeDownloadManagerDelegate::ClearLastDownloadPath() {
- last_download_path_.clear();
-}
-
DownloadProtectionService*
ChromeDownloadManagerDelegate::GetDownloadProtectionService() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -456,7 +417,7 @@ void ChromeDownloadManagerDelegate::OnDownloadPathSelected(
const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback,
const base::FilePath& virtual_path) {
if (!virtual_path.empty())
- last_download_path_ = virtual_path.DirName();
+ download_prefs_->SetSaveFilePath(virtual_path.DirName());
callback.Run(virtual_path);
}

Powered by Google App Engine
This is Rietveld 408576698