OLD | NEW |
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 "chrome/browser/download/download_file.h" | 5 #include "chrome/browser/download/download_file.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 // Actions from the UI thread and run on the download thread | 523 // Actions from the UI thread and run on the download thread |
524 | 524 |
525 // Open a download, or show it in a file explorer window. We run on this | 525 // Open a download, or show it in a file explorer window. We run on this |
526 // thread to avoid blocking the UI with (potentially) slow Shell operations. | 526 // thread to avoid blocking the UI with (potentially) slow Shell operations. |
527 // TODO(paulg): File 'stat' operations. | 527 // TODO(paulg): File 'stat' operations. |
528 void DownloadFileManager::OnShowDownloadInShell(const FilePath& full_path) { | 528 void DownloadFileManager::OnShowDownloadInShell(const FilePath& full_path) { |
529 DCHECK(MessageLoop::current() == file_loop_); | 529 DCHECK(MessageLoop::current() == file_loop_); |
530 platform_util::ShowItemInFolder(full_path); | 530 platform_util::ShowItemInFolder(full_path); |
531 } | 531 } |
532 | 532 |
533 // Launches the selected download using ShellExecute 'open' verb. If there is | 533 // Launches the selected download using ShellExecute 'open' verb. For windows, |
534 // a valid parent window, the 'safer' version will be used which can | 534 // if there is a valid parent window, the 'safer' version will be used which can |
535 // display a modal dialog asking for user consent on dangerous files. | 535 // display a modal dialog asking for user consent on dangerous files. |
536 void DownloadFileManager::OnOpenDownloadInShell(const FilePath& full_path, | 536 void DownloadFileManager::OnOpenDownloadInShell(const FilePath& full_path, |
537 const GURL& url, | 537 const GURL& url, |
538 gfx::NativeView parent_window) { | 538 gfx::NativeView parent_window) { |
| 539 DCHECK(MessageLoop::current() == file_loop_); |
| 540 |
539 #if defined(OS_WIN) | 541 #if defined(OS_WIN) |
540 DCHECK(MessageLoop::current() == file_loop_); | |
541 if (NULL != parent_window) { | 542 if (NULL != parent_window) { |
542 win_util::SaferOpenItemViaShell(parent_window, L"", full_path, | 543 win_util::SaferOpenItemViaShell(parent_window, L"", full_path, |
543 UTF8ToWide(url.spec()), true); | 544 UTF8ToWide(url.spec())); |
544 } else { | 545 return; |
545 win_util::OpenItemViaShell(full_path, true); | |
546 } | 546 } |
547 #else | |
548 // TODO(port) implement me. | |
549 NOTREACHED(); | |
550 #endif | 547 #endif |
| 548 |
| 549 platform_util::OpenItem(full_path); |
551 } | 550 } |
552 | 551 |
553 // The DownloadManager in the UI thread has provided a final name for the | 552 // The DownloadManager in the UI thread has provided a final name for the |
554 // download specified by 'id'. Rename the in progress download, and remove it | 553 // download specified by 'id'. Rename the in progress download, and remove it |
555 // from our table if it has been completed or cancelled already. | 554 // from our table if it has been completed or cancelled already. |
556 void DownloadFileManager::OnFinalDownloadName(int id, | 555 void DownloadFileManager::OnFinalDownloadName(int id, |
557 const FilePath& full_path, | 556 const FilePath& full_path, |
558 DownloadManager* manager) { | 557 DownloadManager* manager) { |
559 DCHECK(MessageLoop::current() == file_loop_); | 558 DCHECK(MessageLoop::current() == file_loop_); |
560 DownloadFileMap::iterator it = downloads_.find(id); | 559 DownloadFileMap::iterator it = downloads_.find(id); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 ui_loop_->PostTask(FROM_HERE, NewRunnableMethod( | 598 ui_loop_->PostTask(FROM_HERE, NewRunnableMethod( |
600 this, &DownloadFileManager::StopUpdateTimer)); | 599 this, &DownloadFileManager::StopUpdateTimer)); |
601 } | 600 } |
602 | 601 |
603 // static | 602 // static |
604 void DownloadFileManager::DeleteFile(const FilePath& path) { | 603 void DownloadFileManager::DeleteFile(const FilePath& path) { |
605 // Make sure we only delete files. | 604 // Make sure we only delete files. |
606 if (!file_util::DirectoryExists(path)) | 605 if (!file_util::DirectoryExists(path)) |
607 file_util::Delete(path, false); | 606 file_util::Delete(path, false); |
608 } | 607 } |
OLD | NEW |