diff options
author | paul@chromium.org <paul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-18 22:29:58 +0000 |
---|---|---|
committer | paul@chromium.org <paul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-18 22:29:58 +0000 |
commit | 8b6ff019c982f3929cf09b7090c9ec38c2751fc1 (patch) | |
tree | 015a4b4a26fd5c8729fa1f3a3f57e25e8666e586 /chrome/browser/download/save_package.cc | |
parent | 7c23cfc44c6fa5d224acd7cae942dc7310138c7b (diff) | |
download | chromium_src-8b6ff019c982f3929cf09b7090c9ec38c2751fc1.zip chromium_src-8b6ff019c982f3929cf09b7090c9ec38c2751fc1.tar.gz chromium_src-8b6ff019c982f3929cf09b7090c9ec38c2751fc1.tar.bz2 |
Show or open downloaded items on the UI thread for Mac. This is
required because NSWorkspace, which is used for the open or show
operation, must be called on the main thread.
BUG=19447 (http://crbug.com/19447)
TEST=Repro steps fully described in the bug report.
Review URL: http://codereview.chromium.org/172074
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23667 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/download/save_package.cc')
-rw-r--r-- | chrome/browser/download/save_package.cc | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/chrome/browser/download/save_package.cc b/chrome/browser/download/save_package.cc index cfd6e05..c6003e7 100644 --- a/chrome/browser/download/save_package.cc +++ b/chrome/browser/download/save_package.cc @@ -437,7 +437,7 @@ void SavePackage::StartSave(const SaveFileCreateInfo* info) { // If the save source is from file system, inform SaveFileManager to copy // corresponding file to the file path which this SaveItem specifies. if (info->save_source == SaveFileCreateInfo::SAVE_FILE_FROM_FILE) { - file_manager_->GetSaveLoop()->PostTask(FROM_HERE, + file_manager_->file_loop()->PostTask(FROM_HERE, NewRunnableMethod(file_manager_, &SaveFileManager::SaveLocalFile, save_item->url(), @@ -543,7 +543,7 @@ void SavePackage::Stop() { it != saved_failed_items_.end(); ++it) save_ids.push_back(it->second->save_id()); - file_manager_->GetSaveLoop()->PostTask(FROM_HERE, + file_manager_->file_loop()->PostTask(FROM_HERE, NewRunnableMethod(file_manager_, &SaveFileManager::RemoveSavedFileFromFileMap, save_ids)); @@ -572,7 +572,7 @@ void SavePackage::CheckFinish() { final_names.push_back(std::make_pair(it->first, it->second->full_path())); - file_manager_->GetSaveLoop()->PostTask(FROM_HERE, + file_manager_->file_loop()->PostTask(FROM_HERE, NewRunnableMethod(file_manager_, &SaveFileManager::RenameAllFiles, final_names, @@ -597,7 +597,7 @@ void SavePackage::Finish() { it != saved_failed_items_.end(); ++it) save_ids.push_back(it->second->save_id()); - file_manager_->GetSaveLoop()->PostTask(FROM_HERE, + file_manager_->file_loop()->PostTask(FROM_HERE, NewRunnableMethod(file_manager_, &SaveFileManager::RemoveSavedFileFromFileMap, save_ids)); @@ -693,7 +693,7 @@ void SavePackage::SaveCanceled(SaveItem* save_item) { save_item->url(), this); if (save_item->save_id() != -1) - file_manager_->GetSaveLoop()->PostTask(FROM_HERE, + file_manager_->file_loop()->PostTask(FROM_HERE, NewRunnableMethod(file_manager_, &SaveFileManager::CancelSave, save_item->save_id())); @@ -735,10 +735,16 @@ void SavePackage::SaveNextFile(bool process_all_remaining_items) { void SavePackage::ShowDownloadInShell() { DCHECK(file_manager_); DCHECK(finished_ && !canceled() && !saved_main_file_path_.empty()); - file_manager_->GetSaveLoop()->PostTask(FROM_HERE, + DCHECK(MessageLoop::current() == file_manager_->ui_loop()); +#if defined(OS_MACOSX) + // Mac OS X requires opening downloads on the UI thread. + platform_util::ShowItemInFolder(saved_main_file_path_); +#else + file_manager_->file_loop()->PostTask(FROM_HERE, NewRunnableMethod(file_manager_, &SaveFileManager::OnShowSavedFileInShell, saved_main_file_path_)); +#endif } // Calculate the percentage of whole save page job. @@ -855,7 +861,7 @@ void SavePackage::OnReceivedSerializedHtmlData(const GURL& frame_url, if (flag == webkit_glue::DomSerializerDelegate::ALL_FRAMES_ARE_FINISHED) { for (SaveUrlItemMap::iterator it = in_progress_items_.begin(); it != in_progress_items_.end(); ++it) { - file_manager_->GetSaveLoop()->PostTask(FROM_HERE, + file_manager_->file_loop()->PostTask(FROM_HERE, NewRunnableMethod(file_manager_, &SaveFileManager::SaveFinished, it->second->save_id(), @@ -879,7 +885,7 @@ void SavePackage::OnReceivedSerializedHtmlData(const GURL& frame_url, memcpy(new_data->data(), data.data(), data.size()); // Call write file functionality in file thread. - file_manager_->GetSaveLoop()->PostTask(FROM_HERE, + file_manager_->file_loop()->PostTask(FROM_HERE, NewRunnableMethod(file_manager_, &SaveFileManager::UpdateSaveProgress, save_item->save_id(), @@ -889,7 +895,7 @@ void SavePackage::OnReceivedSerializedHtmlData(const GURL& frame_url, // Current frame is completed saving, call finish in file thread. if (flag == webkit_glue::DomSerializerDelegate::CURRENT_FRAME_IS_FINISHED) { - file_manager_->GetSaveLoop()->PostTask(FROM_HERE, + file_manager_->file_loop()->PostTask(FROM_HERE, NewRunnableMethod(file_manager_, &SaveFileManager::SaveFinished, save_item->save_id(), |