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

Issue 4883003: Add FilePath::FinalExtension() to avoid double extensions (.tar.gz) for file selector (Closed)

Created:
10 years, 1 month ago by davidben
Modified:
7 years ago
CC:
chromium-reviews, pam+watch_chromium.org, ben+cc_chromium.org
Visibility:
Public.

Description

Add FilePath::FinalExtension() to avoid double extensions (.tar.gz) for file selector Windows and OS X file selectors break badly on double-extensions. GTK and Chrome OS handle it slightly better, but CrOS has a slight bug and GTK's handling of file extensions is minimal, so not a whole lot changed. See https://codereview.chromium.org/4883003/#msg14 for full analysis of platform behavior. There is some logic that does benefit from long extensions (renaming "foo.tar.gz" to "foo (1).tar.gz" instead of "foo.tar (1).gz"), and some other callers store state based on extension, so rather than changing FilePath::Extension, add a new FilePath::FinalExtension and change SelectFileDialog callers to use it. Also work around a problem in NSSavePanel when saving "foo.tar.gz" with extensions hidden. TEST=FilePath.Extension, FilePath.Extension2 FilePath.RemoveExtension Enabling "Ask where to save each file before downloading"; saving a tar.gz doesn't result in weird confirmation prompt on OS X, with or without "Show all filename extensions" enabled in Finder. BUG=83084 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=239505

Patch Set 1 #

Patch Set 2 : #

Total comments: 3

Patch Set 3 : FilePath::FinalExtension #

Patch Set 4 : Rebase, work around new Mac problem. #

Total comments: 4

Patch Set 5 : Comment (also a rebase) #

Unified diffs Side-by-side diffs Delta from patch set Stats (+102 lines, -28 lines) Patch
M base/files/file_path.h View 1 2 3 4 1 chunk +16 lines, -1 line 0 comments Download
M base/files/file_path.cc View 1 2 3 4 3 chunks +31 lines, -8 lines 0 comments Download
M base/files/file_path_unittest.cc View 1 2 3 4 6 chunks +33 lines, -10 lines 0 comments Download
M chrome/browser/download/download_extensions.cc View 1 2 3 4 2 chunks +1 line, -4 lines 0 comments Download
M chrome/browser/download/download_file_picker.cc View 1 2 3 4 1 chunk +3 lines, -1 line 0 comments Download
M chrome/browser/download/save_package_file_picker.cc View 1 2 3 4 2 chunks +4 lines, -3 lines 0 comments Download
M ui/shell_dialogs/select_file_dialog_mac.mm View 1 2 3 4 1 chunk +14 lines, -1 line 0 comments Download

Messages

Total messages: 30 (0 generated)
davidben
Right, I had this patch I was sitting on for ages and forgot about. Not ...
8 years, 1 month ago (2012-11-13 18:37:14 UTC) #1
asanka
On 2012/11/13 18:37:14, David Benjamin wrote: > Right, I had this patch I was sitting ...
8 years, 1 month ago (2012-11-13 19:38:21 UTC) #2
Nico
I think avi's been looking at this code somewhat recently, he's probably the best reviewer.
8 years, 1 month ago (2012-11-13 19:42:42 UTC) #3
davidben
On 2012/11/13 19:38:21, asanka wrote: > What's the resulting behavior? If I try to save ...
8 years, 1 month ago (2012-11-13 19:56:17 UTC) #4
Avi (use Gerrit)
In any case, it's kinda bogus that this code is being passed an "extension" of ...
8 years, 1 month ago (2012-11-13 20:41:00 UTC) #5
davidben
https://chromiumcodereview.appspot.com/4883003/diff/2003/ui/base/dialogs/select_file_dialog_mac.mm File ui/base/dialogs/select_file_dialog_mac.mm (right): https://chromiumcodereview.appspot.com/4883003/diff/2003/ui/base/dialogs/select_file_dialog_mac.mm#newcode42 ui/base/dialogs/select_file_dialog_mac.mm:42: return ext.substr(last_dot + 1); On 2012/11/13 20:41:00, Avi wrote: ...
8 years, 1 month ago (2012-11-13 20:53:28 UTC) #6
Avi (use Gerrit)
+Mark Mark, this is a question about FilePath functionality, where it says that the "extension" ...
8 years, 1 month ago (2012-11-13 21:00:20 UTC) #7
Mark Mentovai
I really wish FilePath didn’t have this double-extension logic to begin with. I think adding ...
8 years, 1 month ago (2012-11-13 21:09:57 UTC) #8
Avi (use Gerrit)
I'm not thrilled with what FilePath does either, but at least we should put this ...
8 years, 1 month ago (2012-11-13 21:22:13 UTC) #9
davidben
On 2012/11/13 21:22:13, Avi wrote: > I'm not thrilled with what FilePath does either, but ...
8 years, 1 month ago (2012-11-14 17:47:23 UTC) #10
Avi (use Gerrit)
:( The ideal solution would be to have FinalExtension (not thrilled with the naming btw) ...
8 years, 1 month ago (2012-11-14 17:55:48 UTC) #11
davidben
On 2012/11/14 17:55:48, Avi wrote: > :( > > The ideal solution would be to ...
8 years, 1 month ago (2012-11-15 04:23:26 UTC) #12
Avi (use Gerrit)
On 2012/11/15 04:23:26, David Benjamin wrote: > something like FullExtension/Extension or > LongExtension/Extension would probably ...
8 years, 1 month ago (2012-11-15 05:31:32 UTC) #13
davidben
On 2012/11/15 05:31:32, Avi wrote: > On 2012/11/15 04:23:26, David Benjamin wrote: > > something ...
8 years, 1 month ago (2012-11-17 20:30:26 UTC) #14
Avi (use Gerrit)
Wow. That is an excellent analysis. When you make your change, it would definitely be ...
8 years, 1 month ago (2012-11-17 20:40:21 UTC) #15
davidben
> /\.tar\.bz2$/ Er, correction: that regex is actually /\.(tar.bz2|tbz|tbz2)$/i and so incorrectly matches foo.tarXbz2. :-)
8 years, 1 month ago (2012-11-17 20:42:38 UTC) #16
Avi (use Gerrit)
On 2012/11/17 20:42:38, David Benjamin wrote: > > /\.tar\.bz2$/ > > Er, correction: that regex ...
8 years, 1 month ago (2012-11-17 20:45:18 UTC) #17
davidben
[I'm calling this long vs short extensions below just because that's what my notes use. ...
7 years, 11 months ago (2013-01-13 16:30:09 UTC) #18
Mark Mentovai
Code LGTM. The audit you mention would still be nice.
7 years, 11 months ago (2013-01-14 19:20:15 UTC) #19
davidben
Now that I'm actually working here again, I should close the loop on some of ...
7 years, 2 months ago (2013-10-24 20:13:46 UTC) #20
Mark Mentovai
Well, this was reviewed in the past, and I liked it then. What’s changed, or ...
7 years ago (2013-12-03 22:35:11 UTC) #21
davidben
On 2013/12/03 22:35:11, Mark Mentovai wrote: > Well, this was reviewed in the past, and ...
7 years ago (2013-12-04 00:20:56 UTC) #22
Mark Mentovai
LGTM. Good use of “penultimate.”
7 years ago (2013-12-06 18:02:07 UTC) #23
Nico
lgtm, feel free to ignore: https://codereview.chromium.org/4883003/diff/32002/ui/shell_dialogs/select_file_dialog_mac.mm File ui/shell_dialogs/select_file_dialog_mac.mm (right): https://codereview.chromium.org/4883003/diff/32002/ui/shell_dialogs/select_file_dialog_mac.mm#newcode272 ui/shell_dialogs/select_file_dialog_mac.mm:272: // is trying to ...
7 years ago (2013-12-06 21:36:36 UTC) #24
davidben
https://codereview.chromium.org/4883003/diff/32002/ui/shell_dialogs/select_file_dialog_mac.mm File ui/shell_dialogs/select_file_dialog_mac.mm (right): https://codereview.chromium.org/4883003/diff/32002/ui/shell_dialogs/select_file_dialog_mac.mm#newcode272 ui/shell_dialogs/select_file_dialog_mac.mm:272: // is trying to override the default extension. This ...
7 years ago (2013-12-06 21:48:51 UTC) #25
asanka
/download/ lgtm
7 years ago (2013-12-06 22:13:11 UTC) #26
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/davidben@chromium.org/4883003/122002
7 years ago (2013-12-06 23:28:52 UTC) #27
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/davidben@chromium.org/4883003/122002
7 years ago (2013-12-09 16:49:54 UTC) #29
commit-bot: I haz the power
7 years ago (2013-12-09 17:06:54 UTC) #30
Message was sent while issue was closed.
Change committed as 239505

Powered by Google App Engine
This is Rietveld 408576698