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

Side by Side Diff: content/shell/browser/shell_download_manager_delegate.cc

Issue 1513413002: Enable "Hide Extension" option when "Save Link As" on the Mac Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix nits. Created 5 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/shell/browser/shell_download_manager_delegate.h" 5 #include "content/shell/browser/shell_download_manager_delegate.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <commdlg.h> 9 #include <commdlg.h>
10 #endif 10 #endif
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 // SetDownloadManager, the system is not fully initialized. 64 // SetDownloadManager, the system is not fully initialized.
65 if (default_download_path_.empty()) { 65 if (default_download_path_.empty()) {
66 default_download_path_ = download_manager_->GetBrowserContext()->GetPath(). 66 default_download_path_ = download_manager_->GetBrowserContext()->GetPath().
67 Append(FILE_PATH_LITERAL("Downloads")); 67 Append(FILE_PATH_LITERAL("Downloads"));
68 } 68 }
69 69
70 if (!download->GetForcedFilePath().empty()) { 70 if (!download->GetForcedFilePath().empty()) {
71 callback.Run(download->GetForcedFilePath(), 71 callback.Run(download->GetForcedFilePath(),
72 DownloadItem::TARGET_DISPOSITION_OVERWRITE, 72 DownloadItem::TARGET_DISPOSITION_OVERWRITE,
73 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, 73 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
74 download->GetForcedFilePath()); 74 download->GetForcedFilePath(),
75 false);
75 return true; 76 return true;
76 } 77 }
77 78
78 FilenameDeterminedCallback filename_determined_callback = 79 FilenameDeterminedCallback filename_determined_callback =
79 base::Bind(&ShellDownloadManagerDelegate::OnDownloadPathGenerated, 80 base::Bind(&ShellDownloadManagerDelegate::OnDownloadPathGenerated,
80 weak_ptr_factory_.GetWeakPtr(), 81 weak_ptr_factory_.GetWeakPtr(),
81 download->GetId(), 82 download->GetId(),
82 callback); 83 callback);
83 84
84 BrowserThread::PostTask( 85 BrowserThread::PostTask(
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 133
133 void ShellDownloadManagerDelegate::OnDownloadPathGenerated( 134 void ShellDownloadManagerDelegate::OnDownloadPathGenerated(
134 uint32 download_id, 135 uint32 download_id,
135 const DownloadTargetCallback& callback, 136 const DownloadTargetCallback& callback,
136 const base::FilePath& suggested_path) { 137 const base::FilePath& suggested_path) {
137 DCHECK_CURRENTLY_ON(BrowserThread::UI); 138 DCHECK_CURRENTLY_ON(BrowserThread::UI);
138 if (suppress_prompting_) { 139 if (suppress_prompting_) {
139 // Testing exit. 140 // Testing exit.
140 callback.Run(suggested_path, DownloadItem::TARGET_DISPOSITION_OVERWRITE, 141 callback.Run(suggested_path, DownloadItem::TARGET_DISPOSITION_OVERWRITE,
141 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, 142 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
142 suggested_path.AddExtension(FILE_PATH_LITERAL(".crdownload"))); 143 suggested_path.AddExtension(FILE_PATH_LITERAL(".crdownload")),
144 false);
143 return; 145 return;
144 } 146 }
145 147
146 ChooseDownloadPath(download_id, callback, suggested_path); 148 ChooseDownloadPath(download_id, callback, suggested_path);
147 } 149 }
148 150
149 void ShellDownloadManagerDelegate::ChooseDownloadPath( 151 void ShellDownloadManagerDelegate::ChooseDownloadPath(
150 uint32 download_id, 152 uint32 download_id,
151 const DownloadTargetCallback& callback, 153 const DownloadTargetCallback& callback,
152 const base::FilePath& suggested_path) { 154 const base::FilePath& suggested_path) {
(...skipping 23 matching lines...) Expand all
176 save_as.Flags = OFN_OVERWRITEPROMPT | OFN_EXPLORER | OFN_ENABLESIZING | 178 save_as.Flags = OFN_OVERWRITEPROMPT | OFN_EXPLORER | OFN_ENABLESIZING |
177 OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST; 179 OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST;
178 180
179 if (GetSaveFileName(&save_as)) 181 if (GetSaveFileName(&save_as))
180 result = base::FilePath(std::wstring(save_as.lpstrFile)); 182 result = base::FilePath(std::wstring(save_as.lpstrFile));
181 #else 183 #else
182 NOTIMPLEMENTED(); 184 NOTIMPLEMENTED();
183 #endif 185 #endif
184 186
185 callback.Run(result, DownloadItem::TARGET_DISPOSITION_PROMPT, 187 callback.Run(result, DownloadItem::TARGET_DISPOSITION_PROMPT,
186 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, result); 188 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, result, false);
187 } 189 }
188 190
189 void ShellDownloadManagerDelegate::SetDownloadBehaviorForTesting( 191 void ShellDownloadManagerDelegate::SetDownloadBehaviorForTesting(
190 const base::FilePath& default_download_path) { 192 const base::FilePath& default_download_path) {
191 default_download_path_ = default_download_path; 193 default_download_path_ = default_download_path;
192 suppress_prompting_ = true; 194 suppress_prompting_ = true;
193 } 195 }
194 196
195 } // namespace content 197 } // namespace content
OLDNEW
« no previous file with comments | « content/public/browser/download_manager_delegate.h ('k') | ui/shell_dialogs/select_file_dialog_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698