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

Issue 83002: download filename fix (Closed)

Created:
11 years, 8 months ago by jungshik at Google
Modified:
9 years, 7 months ago
CC:
chromium-reviews_googlegroups.com
Visibility:
Public.

Description

This CL makes Chrome on par with Firefox in terms of 'GetSuggestedFilename' for file download via context-menu. For a download initiated with a click on a link in a web page, a webkit-side change is necessary, which will be done later. Add a field (referrer_charset) to URLRequestContext and DownloadCreateInfo. It's set to the character encoding of a document where the download request originates from when it's known (download initiated via "save as" in the context menu). If it's not known (a download initiated by clicking on a download link or typing a url directly to the omnibox), it's initialized to the default character encoding in the user's preference. I guess this is marginally better than leaving it empty (in that case, step 2b below will be skipped and step 2c will be taken) because a user has a better control over how raw 8bit characters in C-D are interpreted (especially on Windows where a reboot is required to change the OS default codepage). This is later passed to GetSuggestedFilename and used as one of fallback encodings (1. UTF-8, 2. origin_charset, 3. default OS codepage). With this change, we support the following: 1. RFC 2047 2. Raw-8bit-characters : a. UTF-8, b. origin_charset, c. default os codepage. 3. %-escaped UTF-8. In this CL, for #3, I didn't add a fallback similar to one used for #2. If necessary, it can be added easily. New entries are added to 3 existing tests. What's previously not covered (raw 8bit Content-Disposition header) is now covered in all 3 tests. BUG=1148 TEST=net unit test: NetUtilTest.GetFileNameFromCD NetUtilTest.GetSuggestedFilename unittest : DownloadManagerTest.TestDownloadFilename Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=15113

Patch Set 1 #

Patch Set 2 : '' #

Patch Set 3 : '' #

Patch Set 4 : '' #

Patch Set 5 : '' #

Patch Set 6 : '' #

Patch Set 7 : '' #

Patch Set 8 : '' #

Patch Set 9 : '' #

Patch Set 10 : '' #

Patch Set 11 : '' #

Patch Set 12 : '' #

Total comments: 10

Patch Set 13 : '' #

Patch Set 14 : '' #

Unified diffs Side-by-side diffs Delta from patch set Stats (+257 lines, -115 lines) Patch
M chrome/browser/download/download_manager.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +1 line, -0 lines 0 comments Download
M chrome/browser/download/download_manager.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 2 chunks +3 lines, -0 lines 0 comments Download
M chrome/browser/download/download_manager_unittest.cc View 2 3 4 5 6 7 8 9 10 11 12 13 3 chunks +24 lines, -2 lines 0 comments Download
M chrome/browser/download/save_package.cc View 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +3 lines, -1 line 0 comments Download
M chrome/browser/history/download_types.h View 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +3 lines, -0 lines 0 comments Download
M chrome/browser/net/chrome_url_request_context.cc View 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +14 lines, -0 lines 0 comments Download
M chrome/browser/renderer_host/download_resource_handler.cc View 2 3 4 5 6 7 8 9 10 11 12 13 2 chunks +2 lines, -0 lines 0 comments Download
M chrome/browser/tab_contents/render_view_context_menu.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +2 lines, -1 line 0 comments Download
M chrome/browser/tab_contents/tab_contents.cc View 13 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/tab_contents/tab_contents_view_win.cc View 10 11 12 13 1 chunk +1 line, -1 line 0 comments Download
M chrome/common/os_exchange_data.cc View 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +1 line, -1 line 0 comments Download
M chrome/common/render_messages.h View 5 6 7 8 9 10 11 12 13 2 chunks +3 lines, -1 line 0 comments Download
M chrome/renderer/render_view.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +2 lines, -1 line 0 comments Download
M chrome/renderer/render_view.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 2 chunks +3 lines, -1 line 0 comments Download
M net/base/net_util.h View 2 3 4 5 6 7 8 9 10 11 12 13 3 chunks +19 lines, -12 lines 0 comments Download
M net/base/net_util.cc View 2 3 4 5 6 7 8 9 10 11 12 13 7 chunks +21 lines, -17 lines 0 comments Download
M net/base/net_util_unittest.cc View 11 12 13 4 chunks +123 lines, -65 lines 0 comments Download
M net/url_request/url_request_context.h View 2 3 4 5 6 7 8 9 10 11 12 13 2 chunks +11 lines, -0 lines 0 comments Download
M webkit/glue/context_menu.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +3 lines, -0 lines 0 comments Download
M webkit/glue/context_menu_client_impl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 3 chunks +4 lines, -4 lines 0 comments Download
M webkit/glue/resource_handle_impl.cc View 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +3 lines, -1 line 0 comments Download
M webkit/glue/webview_delegate.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 2 chunks +6 lines, -4 lines 0 comments Download
M webkit/tools/test_shell/test_webview_delegate.h View 1 chunk +2 lines, -1 line 0 comments Download
M webkit/tools/test_shell/test_webview_delegate.cc View 1 chunk +2 lines, -1 line 0 comments Download

Messages

Total messages: 8 (0 generated)
jungshik at Google
I'm not sure why ContextMenu..* test fails (it fails even with the patch removed in ...
11 years, 8 months ago (2009-04-21 22:41:46 UTC) #1
jungshik at Google
Adding abarth per Paul.
11 years, 8 months ago (2009-04-23 00:16:16 UTC) #2
abarth-chromium
I'm not a charset expert, but this looks entirely reasonable to me. (Minor style nits ...
11 years, 8 months ago (2009-04-23 01:06:37 UTC) #3
Paul Godavari
LGTM. http://codereview.chromium.org/83002/diff/4202/4207 File chrome/browser/download/download_manager.h (right): http://codereview.chromium.org/83002/diff/4202/4207#newcode359 Line 359: const std::string& referrer_encoding, Just curious why use ...
11 years, 8 months ago (2009-04-24 01:47:18 UTC) #4
jungshik at Google
Thank you, Paul and Adam for review. I've been waiting for Darin to take a ...
11 years, 8 months ago (2009-04-29 00:59:26 UTC) #5
wtc
Jungshik, do you want me to look at the whole CL or just the files ...
11 years, 7 months ago (2009-04-29 19:18:07 UTC) #6
jungshik at Google
On 2009/04/29 19:18:07, wtc wrote: > Jungshik, do you want me to look at the ...
11 years, 7 months ago (2009-04-29 23:09:39 UTC) #7
wtc
11 years, 7 months ago (2009-04-29 23:50:22 UTC) #8
LGTM.  I only reviewed your changes to the net module.

Please review my comments below and fix the nits as
appropriate.

Some of the things you said in the CL's description probably
should be moved to the source files so that we don't need
to do "svn log" to get this useful info.  Just a thought...

http://codereview.chromium.org/83002/diff/4202/4214
File net/base/net_util.h (right):

http://codereview.chromium.org/83002/diff/4202/4214#newcode74
Line 74: // Return the filename extracted from Content-Disposition header.  Only
two
Please review this block comment and update it as
appropriate.  For example, your CL's description says:

  With this change, we support the following:

  1. RFC 2047
  2. Raw-8bit-characters : a. UTF-8, b. origin_charset,
     c. default os codepage. 
  3. %-escaped UTF-8.

but this block comment says:

  Only two formats are supported: a. %-escaped UTF-8
  b. RFC 2047.

In addition, the comment should document the new
origin_charset parameter and the fact that it can be
an empty string (meaning the origin charset is unknown).

http://codereview.chromium.org/83002/diff/4202/4214#newcode134
Line 134: // Gets the filename from the raw Content-Disposition header (as read
from the
Nit: we should also document the origin_charset and
default_name parameters.

http://codereview.chromium.org/83002/diff/4202/4215
File net/base/net_util_unittest.cc (right):

http://codereview.chromium.org/83002/diff/4202/4215#newcode42
Line 42: const char* charset;
Should we name this member origin_charset?

http://codereview.chromium.org/83002/diff/4202/4215#newcode358
Line 358: #if 0
Did you mean to add this commented-out test case?

http://codereview.chromium.org/83002/diff/4202/4215#newcode821
Line 821: test_cases[i].default_filename);
Nit: this line should fit on the previous line...

http://codereview.chromium.org/83002/diff/4202/4212
File net/url_request/url_request_context.h (right):

http://codereview.chromium.org/83002/diff/4202/4212#newcode95
Line 95: // The charset of the referrer where this request comes from. It's not
Should we name this member referer_charset_, since it's the
charset of the referrer?

Powered by Google App Engine
This is Rietveld 408576698