|
Enable "Hide Extension" option when "Save Link As" on the Mac
When you choose "Save Link As..." on the Mac, the file picker includes
an option to hide the downloaded file's extension in the Finder. This
cl propagates this boolean so that the downloaded file, at the end of
the download process, has its file extension hidden.
To make it easier to understand what I did to implement this
change, the following describes how the "Hide Extension" flag makes it
from the file picker dialog to the point at which the download file's
extension gets hidden.
The "Hide Extension" setting comes from the Mac version of
SelectFileDialogImpl::FileWasSelected(), which stores it in a
ui::SelectedFileInfo that's returned to the DownloadFilePicker via
its FileSelectedWithExtraInfo() method.
FileSelectedWithExtraInfo() extracts the flag and passes it to
DownloadFilePicker's OnFileSelected() method, which passes the flag to
its file_selected_callback_, which is a call to
DownloadTargetDeterminer's PromptUserForDownloadPathDone() method,
defined by the FileSelectedCallback interface.
The DownloadTargetDeterminer stashes the "Hide Extension" flag until its
state machine completes at ScheduleCallbackAndDeleteSelf(), where it
calls its completion_callback_. It places the flag inside the
DownloadTargetInfo which is a parameter to the callback.
The callback invokes ChromeDownloadManagerDelegate's
OnDownloadTargetDetermined() method, which sends the flag to its
callback, which is defined in DownloadTargetCallback. This same
interface is redeclared by DownloadItemImpl, which allows a DownloadItem
to be the callback destination of the DownloadTargetDeterminer. The
callback invokes DownloadItemImpl::OnDownloadTargetDetermined(), which
stores the flag in a DownloadFile (DownloadFile actually stores the flag
in the BaseFile that it wraps; this is where the flag is ultimately
needed anyway).
Eventually DownloadFileImpl::RenameWithRetryInternal() calls
file_.AnnotateWithSourceInformation(). base_file_mac.cc's modified
version of this method now calls the newly-added
SetExtensionHiddenForFile() if the BaseFile’s "Hide Extension" flag is
true.
The changes to the other classes, unittests, and browsertests are
unfortunate collateral damage resulting from piping the "Hide Extension"
flag through so many interfaces.
BUG= 540874
Total comments: 10
|
Unified diffs |
Side-by-side diffs |
Delta from patch set |
Stats (+214 lines, -49 lines) |
Patch |
|
M |
chrome/browser/download/chrome_download_manager_delegate.cc
|
View
|
|
1 chunk |
+2 lines, -1 line |
0 comments
|
Download
|
|
M |
chrome/browser/download/chrome_download_manager_delegate_unittest.cc
|
View
|
|
2 chunks |
+3 lines, -2 lines |
0 comments
|
Download
|
|
M |
chrome/browser/download/download_file_picker.h
|
View
|
|
2 chunks |
+7 lines, -3 lines |
0 comments
|
Download
|
|
M |
chrome/browser/download/download_file_picker.cc
|
View
|
|
2 chunks |
+14 lines, -4 lines |
0 comments
|
Download
|
|
M |
chrome/browser/download/download_target_determiner.h
|
View
|
|
2 chunks |
+3 lines, -1 line |
0 comments
|
Download
|
|
M |
chrome/browser/download/download_target_determiner.cc
|
View
|
|
4 chunks |
+4 lines, -1 line |
0 comments
|
Download
|
|
M |
chrome/browser/download/download_target_determiner_delegate.h
|
View
|
|
1 chunk |
+2 lines, -2 lines |
0 comments
|
Download
|
|
M |
chrome/browser/download/download_target_determiner_unittest.cc
|
View
|
|
5 chunks |
+7 lines, -7 lines |
0 comments
|
Download
|
|
M |
chrome/browser/download/download_target_info.h
|
View
|
|
1 chunk |
+4 lines, -0 lines |
0 comments
|
Download
|
|
M |
chrome/browser/download/download_test_file_activity_observer.cc
|
View
|
|
1 chunk |
+2 lines, -1 line |
0 comments
|
Download
|
|
M |
chrome/browser/lifetime/browser_close_manager_browsertest.cc
|
View
|
|
1 chunk |
+4 lines, -2 lines |
0 comments
|
Download
|
|
M |
content/browser/download/base_file.h
|
View
|
|
2 chunks |
+6 lines, -0 lines |
0 comments
|
Download
|
|
M |
content/browser/download/base_file.cc
|
View
|
|
2 chunks |
+6 lines, -1 line |
0 comments
|
Download
|
|
M |
content/browser/download/base_file_mac.cc
|
View
|
|
1 chunk |
+7 lines, -0 lines |
0 comments
|
Download
|
|
M |
content/browser/download/download_file.h
|
View
|
|
1 chunk |
+3 lines, -0 lines |
0 comments
|
Download
|
|
M |
content/browser/download/download_file_impl.h
|
View
|
|
1 chunk |
+1 line, -0 lines |
0 comments
|
Download
|
|
M |
content/browser/download/download_file_impl.cc
|
View
|
|
1 chunk |
+4 lines, -0 lines |
0 comments
|
Download
|
|
M |
content/browser/download/download_item_impl.h
|
View
|
|
1 chunk |
+2 lines, -1 line |
0 comments
|
Download
|
|
M |
content/browser/download/download_item_impl.cc
|
View
|
|
2 chunks |
+6 lines, -1 line |
0 comments
|
Download
|
|
M |
content/browser/download/download_item_impl_delegate.h
|
View
|
|
1 chunk |
+2 lines, -2 lines |
0 comments
|
Download
|
|
M |
content/browser/download/download_item_impl_delegate.cc
|
View
|
|
1 chunk |
+2 lines, -1 line |
0 comments
|
Download
|
|
M |
content/browser/download/download_item_impl_unittest.cc
|
View
|
|
9 chunks |
+10 lines, -9 lines |
0 comments
|
Download
|
|
M |
content/browser/download/download_manager_impl.cc
|
View
|
|
1 chunk |
+2 lines, -1 line |
0 comments
|
Download
|
|
M |
content/browser/download/download_manager_impl_unittest.cc
|
View
|
|
2 chunks |
+4 lines, -3 lines |
0 comments
|
Download
|
|
M |
content/browser/download/file_metadata_mac.h
|
View
|
|
2 chunks |
+7 lines, -0 lines |
0 comments
|
Download
|
|
M |
content/browser/download/file_metadata_mac.mm
|
View
|
1
|
1 chunk |
+11 lines, -0 lines |
0 comments
|
Download
|
|
A |
content/browser/download/file_metadata_unittest_mac.mm
|
View
|
1
|
1 chunk |
+56 lines, -0 lines |
0 comments
|
Download
|
|
M |
content/browser/download/mock_download_file.h
|
View
|
|
1 chunk |
+1 line, -0 lines |
0 comments
|
Download
|
|
M |
content/content_tests.gypi
|
View
|
|
1 chunk |
+1 line, -0 lines |
0 comments
|
Download
|
|
M |
content/public/browser/download_manager_delegate.h
|
View
|
|
1 chunk |
+2 lines, -1 line |
0 comments
|
Download
|
|
M |
content/shell/browser/shell_download_manager_delegate.cc
|
View
|
|
3 chunks |
+5 lines, -3 lines |
0 comments
|
Download
|
|
M |
ui/shell_dialogs/select_file_dialog_mac.mm
|
View
|
|
2 chunks |
+6 lines, -1 line |
0 comments
|
Download
|
|
M |
ui/shell_dialogs/selected_file_info.h
|
View
|
|
1 chunk |
+8 lines, -0 lines |
0 comments
|
Download
|
|
M |
ui/shell_dialogs/selected_file_info.cc
|
View
|
|
1 chunk |
+10 lines, -1 line |
0 comments
|
Download
|
Total messages: 19 (5 generated)
|