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

Side by Side Diff: chrome/browser/download/download_file.cc

Issue 172074: Show or open downloaded items on the UI thread for Mac (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/download/download_file.h ('k') | chrome/browser/download/download_manager.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) 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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 render_process_host_id, 519 render_process_host_id,
520 render_view_id, 520 render_view_id,
521 request_context); 521 request_context);
522 } 522 }
523 523
524 // Actions from the UI thread and run on the download thread 524 // Actions from the UI thread and run on the download thread
525 525
526 // Open a download, or show it in a file explorer window. We run on this 526 // Open a download, or show it in a file explorer window. We run on this
527 // thread to avoid blocking the UI with (potentially) slow Shell operations. 527 // thread to avoid blocking the UI with (potentially) slow Shell operations.
528 // TODO(paulg): File 'stat' operations. 528 // TODO(paulg): File 'stat' operations.
529 #if !defined(OS_MACOSX)
529 void DownloadFileManager::OnShowDownloadInShell(const FilePath& full_path) { 530 void DownloadFileManager::OnShowDownloadInShell(const FilePath& full_path) {
530 DCHECK(MessageLoop::current() == file_loop_); 531 DCHECK(MessageLoop::current() == file_loop_);
531 platform_util::ShowItemInFolder(full_path); 532 platform_util::ShowItemInFolder(full_path);
532 } 533 }
534 #endif
533 535
534 // Launches the selected download using ShellExecute 'open' verb. For windows, 536 // Launches the selected download using ShellExecute 'open' verb. For windows,
535 // if there is a valid parent window, the 'safer' version will be used which can 537 // if there is a valid parent window, the 'safer' version will be used which can
536 // display a modal dialog asking for user consent on dangerous files. 538 // display a modal dialog asking for user consent on dangerous files.
539 #if !defined(OS_MACOSX)
537 void DownloadFileManager::OnOpenDownloadInShell(const FilePath& full_path, 540 void DownloadFileManager::OnOpenDownloadInShell(const FilePath& full_path,
538 const GURL& url, 541 const GURL& url,
539 gfx::NativeView parent_window) { 542 gfx::NativeView parent_window) {
540 DCHECK(MessageLoop::current() == file_loop_); 543 DCHECK(MessageLoop::current() == file_loop_);
541 #if defined(OS_WIN) 544 #if defined(OS_WIN)
542 if (NULL != parent_window) { 545 if (NULL != parent_window) {
543 win_util::SaferOpenItemViaShell(parent_window, L"", full_path, 546 win_util::SaferOpenItemViaShell(parent_window, L"", full_path,
544 UTF8ToWide(url.spec())); 547 UTF8ToWide(url.spec()));
545 return; 548 return;
546 } 549 }
547 #endif 550 #endif
548
549 platform_util::OpenItem(full_path); 551 platform_util::OpenItem(full_path);
550 } 552 }
553 #endif // OS_MACOSX
551 554
552 // The DownloadManager in the UI thread has provided a final name for the 555 // The DownloadManager in the UI thread has provided a final name for the
553 // download specified by 'id'. Rename the in progress download, and remove it 556 // download specified by 'id'. Rename the in progress download, and remove it
554 // from our table if it has been completed or cancelled already. 557 // from our table if it has been completed or cancelled already.
555 void DownloadFileManager::OnFinalDownloadName(int id, 558 void DownloadFileManager::OnFinalDownloadName(int id,
556 const FilePath& full_path, 559 const FilePath& full_path,
557 DownloadManager* manager) { 560 DownloadManager* manager) {
558 DCHECK(MessageLoop::current() == file_loop_); 561 DCHECK(MessageLoop::current() == file_loop_);
559 DownloadFileMap::iterator it = downloads_.find(id); 562 DownloadFileMap::iterator it = downloads_.find(id);
560 if (it == downloads_.end()) 563 if (it == downloads_.end())
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 ui_loop_->PostTask(FROM_HERE, NewRunnableMethod( 601 ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(
599 this, &DownloadFileManager::StopUpdateTimer)); 602 this, &DownloadFileManager::StopUpdateTimer));
600 } 603 }
601 604
602 // static 605 // static
603 void DownloadFileManager::DeleteFile(const FilePath& path) { 606 void DownloadFileManager::DeleteFile(const FilePath& path) {
604 // Make sure we only delete files. 607 // Make sure we only delete files.
605 if (!file_util::DirectoryExists(path)) 608 if (!file_util::DirectoryExists(path))
606 file_util::Delete(path, false); 609 file_util::Delete(path, false);
607 } 610 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_file.h ('k') | chrome/browser/download/download_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698