OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/download/save_package.h" | 5 #include "content/browser/download/save_package.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1285 static const struct { | 1285 static const struct { |
1286 const base::FilePath::CharType *mime_type; | 1286 const base::FilePath::CharType *mime_type; |
1287 const base::FilePath::CharType *suggested_extension; | 1287 const base::FilePath::CharType *suggested_extension; |
1288 } extensions[] = { | 1288 } extensions[] = { |
1289 { FILE_PATH_LITERAL("text/html"), kDefaultHtmlExtension }, | 1289 { FILE_PATH_LITERAL("text/html"), kDefaultHtmlExtension }, |
1290 { FILE_PATH_LITERAL("text/xml"), FILE_PATH_LITERAL("xml") }, | 1290 { FILE_PATH_LITERAL("text/xml"), FILE_PATH_LITERAL("xml") }, |
1291 { FILE_PATH_LITERAL("application/xhtml+xml"), FILE_PATH_LITERAL("xhtml") }, | 1291 { FILE_PATH_LITERAL("application/xhtml+xml"), FILE_PATH_LITERAL("xhtml") }, |
1292 { FILE_PATH_LITERAL("text/plain"), FILE_PATH_LITERAL("txt") }, | 1292 { FILE_PATH_LITERAL("text/plain"), FILE_PATH_LITERAL("txt") }, |
1293 { FILE_PATH_LITERAL("text/css"), FILE_PATH_LITERAL("css") }, | 1293 { FILE_PATH_LITERAL("text/css"), FILE_PATH_LITERAL("css") }, |
1294 }; | 1294 }; |
1295 #if defined(OS_POSIX) | 1295 base::FilePath::StringType mime_type = |
1296 base::FilePath::StringType mime_type(contents_mime_type); | 1296 base::FilePath::StringType::FromUTF8Unsafe(contents_mime_type); |
jochen (gone - plz use gerrit)
2014/10/08 14:10:32
please clang-format this
| |
1297 #elif defined(OS_WIN) | |
1298 base::FilePath::StringType mime_type(base::UTF8ToWide(contents_mime_type)); | |
1299 #endif // OS_WIN | |
1300 for (uint32 i = 0; i < ARRAYSIZE_UNSAFE(extensions); ++i) { | 1297 for (uint32 i = 0; i < ARRAYSIZE_UNSAFE(extensions); ++i) { |
1301 if (mime_type == extensions[i].mime_type) | 1298 if (mime_type == extensions[i].mime_type) |
1302 return extensions[i].suggested_extension; | 1299 return extensions[i].suggested_extension; |
1303 } | 1300 } |
1304 return FILE_PATH_LITERAL(""); | 1301 return FILE_PATH_LITERAL(""); |
1305 } | 1302 } |
1306 | 1303 |
1307 void SavePackage::GetSaveInfo() { | 1304 void SavePackage::GetSaveInfo() { |
1308 // Can't use web_contents_ in the file thread, so get the data that we need | 1305 // Can't use web_contents_ in the file thread, so get the data that we need |
1309 // before calling to it. | 1306 // before calling to it. |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1436 | 1433 |
1437 void SavePackage::FinalizeDownloadEntry() { | 1434 void SavePackage::FinalizeDownloadEntry() { |
1438 DCHECK(download_); | 1435 DCHECK(download_); |
1439 DCHECK(download_manager_); | 1436 DCHECK(download_manager_); |
1440 | 1437 |
1441 download_manager_->OnSavePackageSuccessfullyFinished(download_); | 1438 download_manager_->OnSavePackageSuccessfullyFinished(download_); |
1442 StopObservation(); | 1439 StopObservation(); |
1443 } | 1440 } |
1444 | 1441 |
1445 } // namespace content | 1442 } // namespace content |
OLD | NEW |