OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "net/filter/filter.h" | 5 #include "net/filter/filter.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "net/base/io_buffer.h" | 9 #include "net/base/io_buffer.h" |
10 #include "net/base/mime_util.h" | 10 #include "net/base/mime_util.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 if (LowerCaseEqualsASCII(mime_type, kApplicationXGzip) || | 163 if (LowerCaseEqualsASCII(mime_type, kApplicationXGzip) || |
164 LowerCaseEqualsASCII(mime_type, kApplicationGzip) || | 164 LowerCaseEqualsASCII(mime_type, kApplicationGzip) || |
165 LowerCaseEqualsASCII(mime_type, kApplicationXGunzip)) | 165 LowerCaseEqualsASCII(mime_type, kApplicationXGunzip)) |
166 // The server has told us that it sent us gziped content with a gzip | 166 // The server has told us that it sent us gziped content with a gzip |
167 // content encoding. Sadly, Apache mistakenly sets these headers for all | 167 // content encoding. Sadly, Apache mistakenly sets these headers for all |
168 // .gz files. We match Firefox's nsHttpChannel::ProcessNormal and ignore | 168 // .gz files. We match Firefox's nsHttpChannel::ProcessNormal and ignore |
169 // the Content-Encoding here. | 169 // the Content-Encoding here. |
170 encoding_types->clear(); | 170 encoding_types->clear(); |
171 | 171 |
172 GURL url; | 172 GURL url; |
173 std::string server_filename; | |
173 success = filter_context.GetURL(&url); | 174 success = filter_context.GetURL(&url); |
174 DCHECK(success); | 175 DCHECK(success); |
175 base::FilePath filename = | 176 base::FilePath filename; |
176 base::FilePath().AppendASCII(url.ExtractFileName()); | 177 if (filter_context.GetFilename(&server_filename)) |
178 filename = base::FilePath().AppendASCII(server_filename); | |
asanka
2014/03/20 23:07:16
Nit: server_filename is UTF-8, not necessarily ASC
| |
179 else | |
180 filename = base::FilePath().AppendASCII(url.ExtractFileName()); | |
177 base::FilePath::StringType extension = filename.Extension(); | 181 base::FilePath::StringType extension = filename.Extension(); |
178 | 182 |
179 if (filter_context.IsDownload()) { | 183 if (filter_context.IsDownload()) { |
180 // We don't want to decompress gzipped files when the user explicitly | 184 // We don't want to decompress gzipped files when the user explicitly |
181 // asks to download them. | 185 // asks to download them. |
182 // For the case of svgz files, we use the extension to distinguish | 186 // For the case of svgz files, we use the extension to distinguish |
183 // between svgz files and svg files compressed with gzip by the server. | 187 // between svgz files and svg files compressed with gzip by the server. |
184 // When viewing a .svgz file, we need to uncompress it, but we don't | 188 // When viewing a .svgz file, we need to uncompress it, but we don't |
185 // want to do that when downloading. | 189 // want to do that when downloading. |
186 // See Firefox's nonDecodableExtensions in nsExternalHelperAppService.cpp | 190 // See Firefox's nonDecodableExtensions in nsExternalHelperAppService.cpp |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
394 | 398 |
395 void Filter::PushDataIntoNextFilter() { | 399 void Filter::PushDataIntoNextFilter() { |
396 IOBuffer* next_buffer = next_filter_->stream_buffer(); | 400 IOBuffer* next_buffer = next_filter_->stream_buffer(); |
397 int next_size = next_filter_->stream_buffer_size(); | 401 int next_size = next_filter_->stream_buffer_size(); |
398 last_status_ = ReadFilteredData(next_buffer->data(), &next_size); | 402 last_status_ = ReadFilteredData(next_buffer->data(), &next_size); |
399 if (FILTER_ERROR != last_status_) | 403 if (FILTER_ERROR != last_status_) |
400 next_filter_->FlushStreamBuffer(next_size); | 404 next_filter_->FlushStreamBuffer(next_size); |
401 } | 405 } |
402 | 406 |
403 } // namespace net | 407 } // namespace net |
OLD | NEW |