Skip to content

Commit

Permalink
Revert "Download auto-open files to temp folder"
Browse files Browse the repository at this point in the history
This reverts commit 049eaa1.

Reason for revert: <INSERT REASONING HERE>

Original change's description:
> Download auto-open files to temp folder
> 
> If a user has marked a file extension to auto-open on download, we
> assume that the user only intends to use the file for one-time use.
> Therefore, these files are now downloaded to the system temp directory
> to prevent cluttering the user's download folder.
> 
> Download the file again -- the first file will be in your downloads
> folder, but the second one will be in the temp directory.
> 
> Bug: 55567
> Test: Download a file and choose to Always Open Files of This Type. 
> Change-Id: If23db247f7ed03df7c4f2492c3fefe5e37c8f8ca
> Reviewed-on: https://chromium-review.googlesource.com/602788
> Commit-Queue: David Trainor <[email protected]>
> Reviewed-by: David Trainor <[email protected]>
> Cr-Commit-Position: refs/heads/master@{#493787}

[email protected],[email protected],[email protected]

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 55567
Change-Id: Ie1c3df69c1bf05d7291bc6373b3f9a4254a03d5f
Reviewed-on: https://chromium-review.googlesource.com/655877
Reviewed-by: David Trainor <[email protected]>
Commit-Queue: David Trainor <[email protected]>
Cr-Original-Commit-Position: refs/heads/master@{#500693}(cherry picked from commit 2843aad)
Reviewed-on: https://chromium-review.googlesource.com/667411
Cr-Commit-Position: refs/branch-heads/3202@{crosswalk-project#230}
Cr-Branched-From: fa6a5d8-refs/heads/master@{#499098}
  • Loading branch information
David Trainor committed Sep 14, 2017
1 parent 985e6dd commit fcf79af
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 229 deletions.
8 changes: 1 addition & 7 deletions chrome/browser/download/download_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -503,12 +503,6 @@ class DownloadTest : public InProcessBrowserTest {
return GetDownloadDirectory(browser).Append(file.BaseName());
}

base::FilePath TemporaryFile(const base::FilePath& file) {
base::FilePath tmp;
base::GetTempDir(&tmp);
return tmp.Append(file.BaseName());
}

// Must be called after browser creation. Creates a temporary
// directory for downloads that is auto-deleted on destruction.
// Returning false indicates a failure of the function, and should be asserted
Expand Down Expand Up @@ -2032,7 +2026,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, AutoOpen) {

// As long as we're here, confirmed everything else is good.
EXPECT_EQ(1, browser()->tab_strip_model()->count());
CheckDownloadFullPaths(browser(), TemporaryFile(file), OriginFile(file));
CheckDownload(browser(), file, file);
}

// Download an extension. Expect a dangerous download warning.
Expand Down
12 changes: 0 additions & 12 deletions chrome/browser/download/download_prefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ bool DownloadPathIsDangerous(const base::FilePath& download_path) {
class DefaultDownloadDirectory {
public:
const base::FilePath& path() const { return path_; }
const base::FilePath& temp_path() const { return temp_path_; }

private:
friend struct base::LazyInstanceTraitsBase<DefaultDownloadDirectory>;
Expand All @@ -88,11 +87,6 @@ class DefaultDownloadDirectory {
if (!PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, &path_)) {
NOTREACHED();
}

if (!base::GetTempDir(&temp_path_)) {
NOTREACHED();
}

if (DownloadPathIsDangerous(path_)) {
// This is only useful on platforms that support
// DIR_DEFAULT_DOWNLOADS_SAFE.
Expand All @@ -103,7 +97,6 @@ class DefaultDownloadDirectory {
}

base::FilePath path_;
base::FilePath temp_path_;

DISALLOW_COPY_AND_ASSIGN(DefaultDownloadDirectory);
};
Expand Down Expand Up @@ -244,11 +237,6 @@ const base::FilePath& DownloadPrefs::GetDefaultDownloadDirectory() {
return g_default_download_directory.Get().path();
}

// static
const base::FilePath& DownloadPrefs::GetTempDownloadDirectory() {
return g_default_download_directory.Get().temp_path();
}

// static
DownloadPrefs* DownloadPrefs::FromDownloadManager(
DownloadManager* download_manager) {
Expand Down
3 changes: 0 additions & 3 deletions chrome/browser/download/download_prefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ class DownloadPrefs {

static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);

// Returns the download directory for temporary files.
static const base::FilePath& GetTempDownloadDirectory();

// Returns the default download directory.
static const base::FilePath& GetDefaultDownloadDirectory();

Expand Down
7 changes: 0 additions & 7 deletions chrome/browser/download/download_target_determiner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,7 @@ DownloadTargetDeterminer::Result
// If the user is going to be prompted and the user has been prompted
// before, then always prefer the last directory that the user selected.
target_directory = download_prefs_->SaveFilePath();
} else if (download_prefs_->IsAutoOpenEnabledBasedOnExtension(
generated_filename)) {
// If we do not need user confirmation and we are going to auto-open the
// file, just download it to the system temp directory.
target_directory = download_prefs_->GetTempDownloadDirectory();
} else {
// The user has not configured this file to be auto-opened. Download it to
// the standard location.
target_directory = download_prefs_->DownloadPath();
}
virtual_path_ = target_directory.Append(generated_filename);
Expand Down
Loading

0 comments on commit fcf79af

Please sign in to comment.