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

Side by Side Diff: net/base/filter.cc

Issue 3018011: POSIX: treat multiple extensions like .tar.gz as a single extension. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: more review comments Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/download/download_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/io_buffer.h" 10 #include "net/base/io_buffer.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 FilePath::StringType extension = filename.Extension(); 101 FilePath::StringType extension = filename.Extension();
102 102
103 if (filter_context.IsDownload()) { 103 if (filter_context.IsDownload()) {
104 // We don't want to decompress gzipped files when the user explicitly 104 // We don't want to decompress gzipped files when the user explicitly
105 // asks to download them. 105 // asks to download them.
106 // For the case of svgz files, we use the extension to distinguish 106 // For the case of svgz files, we use the extension to distinguish
107 // between svgz files and svg files compressed with gzip by the server. 107 // between svgz files and svg files compressed with gzip by the server.
108 // When viewing a .svgz file, we need to uncompress it, but we don't 108 // When viewing a .svgz file, we need to uncompress it, but we don't
109 // want to do that when downloading. 109 // want to do that when downloading.
110 // See Firefox's nonDecodableExtensions in nsExternalHelperAppService.cpp 110 // See Firefox's nonDecodableExtensions in nsExternalHelperAppService.cpp
111 if (FILE_PATH_LITERAL(".gz" == extension) || 111 if (EndsWith(extension, FILE_PATH_LITERAL(".gz"), false) ||
112 FILE_PATH_LITERAL(".tgz" == extension) || 112 LowerCaseEqualsASCII(extension, ".tgz") ||
113 FILE_PATH_LITERAL(".svgz") == extension) 113 LowerCaseEqualsASCII(extension, ".svgz"))
114 encoding_types->clear(); 114 encoding_types->clear();
115 } else { 115 } else {
116 // When the user does not explicitly ask to download a file, if we get a 116 // When the user does not explicitly ask to download a file, if we get a
117 // supported mime type, then we attempt to decompress in order to view it. 117 // supported mime type, then we attempt to decompress in order to view it.
118 // However, if it's not a supported mime type, then we will attempt to 118 // However, if it's not a supported mime type, then we will attempt to
119 // download it, and in that case, don't decompress .gz/.tgz files. 119 // download it, and in that case, don't decompress .gz/.tgz files.
120 if ((FILE_PATH_LITERAL(".gz" == extension) || 120 if ((EndsWith(extension, FILE_PATH_LITERAL(".gz"), false) ||
121 FILE_PATH_LITERAL(".tgz") == extension) && 121 LowerCaseEqualsASCII(extension, ".tgz")) &&
122 !net::IsSupportedMimeType(mime_type)) 122 !net::IsSupportedMimeType(mime_type))
123 encoding_types->clear(); 123 encoding_types->clear();
124 } 124 }
125 } 125 }
126 126
127 // If the request was for SDCH content, then we might need additional fixups. 127 // If the request was for SDCH content, then we might need additional fixups.
128 if (!filter_context.IsSdchResponse()) { 128 if (!filter_context.IsSdchResponse()) {
129 // It was not an SDCH request, so we'll just record stats. 129 // It was not an SDCH request, so we'll just record stats.
130 if (1 < encoding_types->size()) { 130 if (1 < encoding_types->size()) {
131 // Multiple filters were intended to only be used for SDCH (thus far!) 131 // Multiple filters were intended to only be used for SDCH (thus far!)
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 384
385 DCHECK(stream_buffer()); 385 DCHECK(stream_buffer());
386 // Bail out if there is more data in the stream buffer to be filtered. 386 // Bail out if there is more data in the stream buffer to be filtered.
387 if (!stream_buffer() || stream_data_len_) 387 if (!stream_buffer() || stream_data_len_)
388 return false; 388 return false;
389 389
390 next_stream_data_ = stream_buffer()->data(); 390 next_stream_data_ = stream_buffer()->data();
391 stream_data_len_ = stream_data_len; 391 stream_data_len_ = stream_data_len;
392 return true; 392 return true;
393 } 393 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698