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/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1297 #elif defined(OS_WIN) | 1297 #elif defined(OS_WIN) |
1298 base::FilePath::StringType mime_type(base::UTF8ToWide(contents_mime_type)); | 1298 base::FilePath::StringType mime_type(base::UTF8ToWide(contents_mime_type)); |
1299 #endif // OS_WIN | 1299 #endif // OS_WIN |
1300 for (uint32 i = 0; i < ARRAYSIZE_UNSAFE(extensions); ++i) { | 1300 for (uint32 i = 0; i < ARRAYSIZE_UNSAFE(extensions); ++i) { |
1301 if (mime_type == extensions[i].mime_type) | 1301 if (mime_type == extensions[i].mime_type) |
1302 return extensions[i].suggested_extension; | 1302 return extensions[i].suggested_extension; |
1303 } | 1303 } |
1304 return FILE_PATH_LITERAL(""); | 1304 return FILE_PATH_LITERAL(""); |
1305 } | 1305 } |
1306 | 1306 |
1307 WebContents* SavePackage::web_contents() const { | |
1308 return WebContentsObserver::web_contents(); | |
1309 } | |
1310 | |
1311 void SavePackage::GetSaveInfo() { | 1307 void SavePackage::GetSaveInfo() { |
1312 // Can't use web_contents_ in the file thread, so get the data that we need | 1308 // Can't use web_contents_ in the file thread, so get the data that we need |
1313 // before calling to it. | 1309 // before calling to it. |
1314 base::FilePath website_save_dir, download_save_dir; | 1310 base::FilePath website_save_dir, download_save_dir; |
1315 bool skip_dir_check = false; | 1311 bool skip_dir_check = false; |
1316 DCHECK(download_manager_); | 1312 DCHECK(download_manager_); |
1317 if (download_manager_->GetDelegate()) { | 1313 if (download_manager_->GetDelegate()) { |
1318 download_manager_->GetDelegate()->GetSaveDir( | 1314 download_manager_->GetDelegate()->GetSaveDir( |
1319 web_contents()->GetBrowserContext(), &website_save_dir, | 1315 web_contents()->GetBrowserContext(), &website_save_dir, |
1320 &download_save_dir, &skip_dir_check); | 1316 &download_save_dir, &skip_dir_check); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1440 | 1436 |
1441 void SavePackage::FinalizeDownloadEntry() { | 1437 void SavePackage::FinalizeDownloadEntry() { |
1442 DCHECK(download_); | 1438 DCHECK(download_); |
1443 DCHECK(download_manager_); | 1439 DCHECK(download_manager_); |
1444 | 1440 |
1445 download_manager_->OnSavePackageSuccessfullyFinished(download_); | 1441 download_manager_->OnSavePackageSuccessfullyFinished(download_); |
1446 StopObservation(); | 1442 StopObservation(); |
1447 } | 1443 } |
1448 | 1444 |
1449 } // namespace content | 1445 } // namespace content |
OLD | NEW |