| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/base/filter.h" | 5 #include "net/base/filter.h" |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "net/base/gzip_filter.h" | 9 #include "net/base/gzip_filter.h" |
| 10 #include "net/base/bzip2_filter.h" | 10 #include "net/base/bzip2_filter.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 97 |
| 98 GURL url; | 98 GURL url; |
| 99 success = filter_context.GetURL(&url); | 99 success = filter_context.GetURL(&url); |
| 100 DCHECK(success); | 100 DCHECK(success); |
| 101 FilePath filename = FilePath().AppendASCII(url.ExtractFileName()); | 101 FilePath filename = FilePath().AppendASCII(url.ExtractFileName()); |
| 102 FilePath::StringType extension = filename.Extension(); | 102 FilePath::StringType extension = filename.Extension(); |
| 103 | 103 |
| 104 // Firefox does not apply the filter to the following extensions. | 104 // Firefox does not apply the filter to the following extensions. |
| 105 // See Firefox's nsHttpChannel::nsContentEncodings::GetNext() and | 105 // See Firefox's nsHttpChannel::nsContentEncodings::GetNext() and |
| 106 // nonDecodableExtensions in nsExternalHelperAppService.cpp | 106 // nonDecodableExtensions in nsExternalHelperAppService.cpp |
| 107 // For the case of svgz files, we use the extension to distinguish |
| 108 // between svgz files and svg files compressed with gzip by the server. |
| 109 // When viewing a .svgz file, we need to uncompress it, but we don't |
| 110 // want to do that when downloading. |
| 107 if (0 == extension.compare(FILE_PATH_LITERAL(".gz")) || | 111 if (0 == extension.compare(FILE_PATH_LITERAL(".gz")) || |
| 108 0 == extension.compare(FILE_PATH_LITERAL(".tgz")) || | 112 0 == extension.compare(FILE_PATH_LITERAL(".tgz")) || |
| 109 0 == extension.compare(FILE_PATH_LITERAL(".svgz"))) { | 113 (0 == extension.compare(FILE_PATH_LITERAL(".svgz")) && |
| 114 filter_context.IsDownload())) { |
| 110 encoding_types->clear(); | 115 encoding_types->clear(); |
| 111 } | 116 } |
| 112 } | 117 } |
| 113 | 118 |
| 114 if (!filter_context.IsSdchResponse()) { | 119 if (!filter_context.IsSdchResponse()) { |
| 115 if (1 < encoding_types->size()) { | 120 if (1 < encoding_types->size()) { |
| 116 // Multiple filters were intended to only be used for SDCH (thus far!) | 121 // Multiple filters were intended to only be used for SDCH (thus far!) |
| 117 SdchManager::SdchErrorRecovery( | 122 SdchManager::SdchErrorRecovery( |
| 118 SdchManager::MULTIENCODING_FOR_NON_SDCH_REQUEST); | 123 SdchManager::MULTIENCODING_FOR_NON_SDCH_REQUEST); |
| 119 } | 124 } |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 | 359 |
| 355 DCHECK(stream_buffer()); | 360 DCHECK(stream_buffer()); |
| 356 // Bail out if there is more data in the stream buffer to be filtered. | 361 // Bail out if there is more data in the stream buffer to be filtered. |
| 357 if (!stream_buffer() || stream_data_len_) | 362 if (!stream_buffer() || stream_data_len_) |
| 358 return false; | 363 return false; |
| 359 | 364 |
| 360 next_stream_data_ = stream_buffer()->data(); | 365 next_stream_data_ = stream_buffer()->data(); |
| 361 stream_data_len_ = stream_data_len; | 366 stream_data_len_ = stream_data_len; |
| 362 return true; | 367 return true; |
| 363 } | 368 } |
| OLD | NEW |