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

Side by Side Diff: chrome/browser/download/download_manager.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, 5 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 | « base/file_path_unittest.cc ('k') | net/base/filter.cc » ('j') | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/download/download_manager.h" 5 #include "chrome/browser/download/download_manager.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 if (extension.empty()) { 1143 if (extension.empty()) {
1144 net::GetPreferredExtensionForMimeType(mime_type, &extension); 1144 net::GetPreferredExtensionForMimeType(mime_type, &extension);
1145 } else { 1145 } else {
1146 // Append extension generated from the mime type if: 1146 // Append extension generated from the mime type if:
1147 // 1. New extension is not ".txt" 1147 // 1. New extension is not ".txt"
1148 // 2. New extension is not the same as the already existing extension. 1148 // 2. New extension is not the same as the already existing extension.
1149 // 3. New extension is not executable. This action mitigates the case when 1149 // 3. New extension is not executable. This action mitigates the case when
1150 // an executable is hidden in a benign file extension; 1150 // an executable is hidden in a benign file extension;
1151 // E.g. my-cat.jpg becomes my-cat.jpg.js if content type is 1151 // E.g. my-cat.jpg becomes my-cat.jpg.js if content type is
1152 // application/x-javascript. 1152 // application/x-javascript.
1153 // 4. New extension is not ".tar" for .gz files. For misconfigured web 1153 // 4. New extension is not ".tar" for .tar.gz files. For misconfigured web
1154 // servers, i.e. bug 5772. 1154 // servers, i.e. bug 5772.
1155 // 5. The original extension is not ".tgz" & the new extension is not "gz". 1155 // 5. The original extension is not ".tgz" & the new extension is not "gz".
1156 FilePath::StringType append_extension; 1156 FilePath::StringType append_extension;
1157 if (net::GetPreferredExtensionForMimeType(mime_type, &append_extension)) { 1157 if (net::GetPreferredExtensionForMimeType(mime_type, &append_extension)) {
1158 if (append_extension != FILE_PATH_LITERAL("txt") && 1158 if (append_extension != FILE_PATH_LITERAL("txt") &&
1159 append_extension != extension && 1159 append_extension != extension &&
1160 !IsExecutableExtension(append_extension) && 1160 !IsExecutableExtension(append_extension) &&
1161 !(append_extension == FILE_PATH_LITERAL("gz") && 1161 !(append_extension == FILE_PATH_LITERAL("gz") &&
1162 extension == FILE_PATH_LITERAL("tgz")) && 1162 extension == FILE_PATH_LITERAL("tgz")) &&
1163 (append_extension != FILE_PATH_LITERAL("tar") || 1163 (append_extension != FILE_PATH_LITERAL("tar") ||
1164 extension != FILE_PATH_LITERAL("gz"))) { 1164 extension != FILE_PATH_LITERAL("tar.gz"))) {
1165 extension += FILE_PATH_LITERAL("."); 1165 extension += FILE_PATH_LITERAL(".");
1166 extension += append_extension; 1166 extension += append_extension;
1167 } 1167 }
1168 } 1168 }
1169 } 1169 }
1170 1170
1171 generated_extension->swap(extension); 1171 generated_extension->swap(extension);
1172 } 1172 }
1173 1173
1174 void DownloadManager::GenerateFileNameFromInfo(DownloadCreateInfo* info, 1174 void DownloadManager::GenerateFileNameFromInfo(DownloadCreateInfo* info,
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
1632 observing_download_manager_->NotifyModelChanged(); 1632 observing_download_manager_->NotifyModelChanged();
1633 } 1633 }
1634 1634
1635 void DownloadManager::OtherDownloadManagerObserver::SetDownloads( 1635 void DownloadManager::OtherDownloadManagerObserver::SetDownloads(
1636 std::vector<DownloadItem*>& downloads) { 1636 std::vector<DownloadItem*>& downloads) {
1637 } 1637 }
1638 1638
1639 void DownloadManager::OtherDownloadManagerObserver::ManagerGoingDown() { 1639 void DownloadManager::OtherDownloadManagerObserver::ManagerGoingDown() {
1640 observed_download_manager_ = NULL; 1640 observed_download_manager_ = NULL;
1641 } 1641 }
OLDNEW
« no previous file with comments | « base/file_path_unittest.cc ('k') | net/base/filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698