OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |