diff options
author | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-18 11:14:13 +0000 |
---|---|---|
committer | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-18 11:14:13 +0000 |
commit | e6875c1f87e04c966d490ba9bd04d267f3ebecbf (patch) | |
tree | e5ac735ea092c1deb8f67a10cb23214c8becc312 /chrome/browser/download | |
parent | 73f6547f0262578a96ab478c5d9e7f841e39d13e (diff) | |
download | chromium_src-e6875c1f87e04c966d490ba9bd04d267f3ebecbf.zip chromium_src-e6875c1f87e04c966d490ba9bd04d267f3ebecbf.tar.gz chromium_src-e6875c1f87e04c966d490ba9bd04d267f3ebecbf.tar.bz2 |
Recommit r52848 - Option-click to download should not display "Save As" UI.
Review URL: http://codereview.chromium.org/2825056
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52850 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/download')
-rw-r--r-- | chrome/browser/download/download_file_manager.cc | 3 | ||||
-rw-r--r-- | chrome/browser/download/download_manager.cc | 23 | ||||
-rw-r--r-- | chrome/browser/download/download_manager_unittest.cc | 5 |
3 files changed, 19 insertions, 12 deletions
diff --git a/chrome/browser/download/download_file_manager.cc b/chrome/browser/download/download_file_manager.cc index 90a95f4..04336cf 100644 --- a/chrome/browser/download/download_file_manager.cc +++ b/chrome/browser/download/download_file_manager.cc @@ -84,9 +84,12 @@ void DownloadFileManager::OnDownloadUrl( URLRequestContext* context = request_context_getter->GetURLRequestContext(); context->set_referrer_charset(referrer_charset); + // Show "Save As" UI. + bool prompt_for_save_location = true; resource_dispatcher_host_->BeginDownload(url, referrer, save_info, + prompt_for_save_location, render_process_host_id, render_view_id, context); diff --git a/chrome/browser/download/download_manager.cc b/chrome/browser/download/download_manager.cc index 26d1d54..622d108 100644 --- a/chrome/browser/download/download_manager.cc +++ b/chrome/browser/download/download_manager.cc @@ -404,7 +404,8 @@ void DownloadManager::StartDownload(DownloadCreateInfo* info) { DCHECK(info); // Check whether this download is for an extension install or not. - if (!info->save_as) { // Allow extensions to be explicitly saved. + // Allow extensions to be explicitly saved. + if (!info->prompt_user_for_save_location) { if (UserScript::HasUserScriptFileExtension(info->url) || info->mime_type == Extension::kMimeType) info->is_extension_install = true; @@ -426,13 +427,13 @@ void DownloadManager::StartDownload(DownloadCreateInfo* info) { // opened, don't bother asking where to keep it. if (!info->is_extension_install && !ShouldOpenFileBasedOnExtension(generated_name)) - info->save_as = true; + info->prompt_user_for_save_location = true; } // Determine the proper path for a download, by either one of the following: // 1) using the default download directory. // 2) prompting the user. - if (info->save_as && !last_download_path_.empty()) + if (info->prompt_user_for_save_location && !last_download_path_.empty()) info->suggested_path = last_download_path_; else info->suggested_path = download_path(); @@ -441,7 +442,8 @@ void DownloadManager::StartDownload(DownloadCreateInfo* info) { info->suggested_path = info->save_info.file_path; } - if (!info->save_as && info->save_info.file_path.empty()) { + if (!info->prompt_user_for_save_location && + info->save_info.file_path.empty()) { // Downloads can be marked as dangerous for two reasons: // a) They have a dangerous-looking filename // b) They are an extension that is not from the gallery @@ -470,7 +472,7 @@ void DownloadManager::CheckIfSuggestedPathExists(DownloadCreateInfo* info) { FilePath dir = info->suggested_path.DirName(); FilePath filename = info->suggested_path.BaseName(); if (!file_util::PathIsWritable(dir)) { - info->save_as = true; + info->prompt_user_for_save_location = true; PathService::Get(chrome::DIR_USER_DOCUMENTS, &info->suggested_path); info->suggested_path = info->suggested_path.Append(filename); } @@ -507,11 +509,12 @@ void DownloadManager::CheckIfSuggestedPathExists(DownloadCreateInfo* info) { info->path_uniquifier = 0; } else if (info->path_uniquifier == -1) { // We failed to find a unique path. We have to prompt the user. - info->save_as = true; + info->prompt_user_for_save_location = true; } } - if (!info->save_as && info->save_info.file_path.empty()) { + if (!info->prompt_user_for_save_location && + info->save_info.file_path.empty()) { // Create an empty file at the suggested path so that we don't allocate the // same "non-existant" path to multiple downloads. // See: http://code.google.com/p/chromium/issues/detail?id=3662 @@ -530,7 +533,7 @@ void DownloadManager::OnPathExistenceAvailable(DownloadCreateInfo* info) { DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); DCHECK(info); - if (info->save_as) { + if (info->prompt_user_for_save_location) { // We must ask the user for the place to put the download. if (!select_file_dialog_.get()) select_file_dialog_ = SelectFileDialog::Create(this); @@ -577,7 +580,7 @@ void DownloadManager::ContinueStartDownload(DownloadCreateInfo* info, info->child_id, info->request_id, info->is_dangerous, - info->save_as, + info->prompt_user_for_save_location, profile_->IsOffTheRecord(), info->is_extension_install, !info->save_info.file_path.empty()); @@ -1410,7 +1413,7 @@ void DownloadManager::SaveAutoOpens() { void DownloadManager::FileSelected(const FilePath& path, int index, void* params) { DownloadCreateInfo* info = reinterpret_cast<DownloadCreateInfo*>(params); - if (info->save_as) + if (info->prompt_user_for_save_location) last_download_path_ = path.DirName(); ContinueStartDownload(info, path); } diff --git a/chrome/browser/download/download_manager_unittest.cc b/chrome/browser/download/download_manager_unittest.cc index c971115..7087863 100644 --- a/chrome/browser/download/download_manager_unittest.cc +++ b/chrome/browser/download/download_manager_unittest.cc @@ -685,12 +685,13 @@ TEST_F(DownloadManagerTest, StartDownload) { kStartDownloadCases[i].prompt_for_download); DownloadCreateInfo info; - info.save_as = kStartDownloadCases[i].save_as; + info.prompt_user_for_save_location = kStartDownloadCases[i].save_as; info.url = GURL(kStartDownloadCases[i].url); info.mime_type = kStartDownloadCases[i].mime_type; download_manager_->StartDownload(&info); - EXPECT_EQ(kStartDownloadCases[i].expected_save_as, info.save_as); + EXPECT_EQ(kStartDownloadCases[i].expected_save_as, + info.prompt_user_for_save_location); } } |