| 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #include "chrome/browser/download/save_file_manager.h" | 7 #include "chrome/browser/download/save_file_manager.h" |
| 8 | 8 |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "base/task.h" | 12 #include "base/task.h" |
| 13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/download/save_file.h" | 14 #include "chrome/browser/download/save_file.h" |
| 15 #include "chrome/browser/download/save_package.h" | 15 #include "chrome/browser/download/save_package.h" |
| 16 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 16 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
| 17 #include "chrome/browser/tab_contents/tab_util.h" | 17 #include "chrome/browser/tab_contents/tab_util.h" |
| 18 #include "chrome/browser/tab_contents/web_contents.h" | 18 #include "chrome/browser/tab_contents/web_contents.h" |
| 19 #include "chrome/common/chrome_paths.h" | 19 #include "chrome/common/chrome_paths.h" |
| 20 #include "chrome/common/platform_util.h" |
| 20 #include "chrome/common/stl_util-inl.h" | 21 #include "chrome/common/stl_util-inl.h" |
| 21 #include "googleurl/src/gurl.h" | 22 #include "googleurl/src/gurl.h" |
| 22 #include "net/base/net_util.h" | 23 #include "net/base/net_util.h" |
| 23 #include "net/base/io_buffer.h" | 24 #include "net/base/io_buffer.h" |
| 24 #include "net/url_request/url_request_context.h" | 25 #include "net/url_request/url_request_context.h" |
| 25 | 26 |
| 26 #if defined(OS_WIN) | 27 #if defined(OS_WIN) |
| 27 #include "chrome/common/win_util.h" | |
| 28 #endif | |
| 29 | |
| 30 #if defined(OS_WIN) | |
| 31 // TODO(port): port these headers to posix. | 28 // TODO(port): port these headers to posix. |
| 32 #include "chrome/browser/tab_contents/tab_contents.h" | 29 #include "chrome/browser/tab_contents/tab_contents.h" |
| 33 #elif defined(OS_POSIX) | 30 #elif defined(OS_POSIX) |
| 34 #include "chrome/common/temp_scaffolding_stubs.h" | 31 #include "chrome/common/temp_scaffolding_stubs.h" |
| 35 #endif | 32 #endif |
| 36 | 33 |
| 37 SaveFileManager::SaveFileManager(MessageLoop* ui_loop, | 34 SaveFileManager::SaveFileManager(MessageLoop* ui_loop, |
| 38 MessageLoop* io_loop, | 35 MessageLoop* io_loop, |
| 39 ResourceDispatcherHost* rdh) | 36 ResourceDispatcherHost* rdh) |
| 40 : next_id_(0), | 37 : next_id_(0), |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 DCHECK(MessageLoop::current() == GetSaveLoop()); | 511 DCHECK(MessageLoop::current() == GetSaveLoop()); |
| 515 DCHECK(!full_path.empty()); | 512 DCHECK(!full_path.empty()); |
| 516 | 513 |
| 517 file_util::Delete(full_path, is_dir); | 514 file_util::Delete(full_path, is_dir); |
| 518 } | 515 } |
| 519 | 516 |
| 520 // Open a saved page package, show it in a Windows Explorer window. | 517 // Open a saved page package, show it in a Windows Explorer window. |
| 521 // We run on this thread to avoid blocking the UI with slow Shell operations. | 518 // We run on this thread to avoid blocking the UI with slow Shell operations. |
| 522 void SaveFileManager::OnShowSavedFileInShell(const FilePath full_path) { | 519 void SaveFileManager::OnShowSavedFileInShell(const FilePath full_path) { |
| 523 DCHECK(MessageLoop::current() == GetSaveLoop()); | 520 DCHECK(MessageLoop::current() == GetSaveLoop()); |
| 524 // TODO(port): make an equivalent call on mac/linux. | 521 platform_util::ShowItemInFolder(full_path); |
| 525 #if defined(OS_WIN) | |
| 526 win_util::ShowItemInFolder(full_path.value()); | |
| 527 #elif defined(OS_POSIX) | |
| 528 NOTIMPLEMENTED(); | |
| 529 #endif | |
| 530 } | 522 } |
| 531 | 523 |
| 532 void SaveFileManager::RenameAllFiles( | 524 void SaveFileManager::RenameAllFiles( |
| 533 const FinalNameList& final_names, | 525 const FinalNameList& final_names, |
| 534 const FilePath& resource_dir, | 526 const FilePath& resource_dir, |
| 535 int render_process_id, | 527 int render_process_id, |
| 536 int render_view_id) { | 528 int render_view_id) { |
| 537 DCHECK(MessageLoop::current() == GetSaveLoop()); | 529 DCHECK(MessageLoop::current() == GetSaveLoop()); |
| 538 | 530 |
| 539 if (!resource_dir.empty() && !file_util::PathExists(resource_dir)) | 531 if (!resource_dir.empty() && !file_util::PathExists(resource_dir)) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 SaveFileMap::iterator it = save_file_map_.find(*i); | 572 SaveFileMap::iterator it = save_file_map_.find(*i); |
| 581 if (it != save_file_map_.end()) { | 573 if (it != save_file_map_.end()) { |
| 582 SaveFile* save_file = it->second; | 574 SaveFile* save_file = it->second; |
| 583 DCHECK(!save_file->in_progress()); | 575 DCHECK(!save_file->in_progress()); |
| 584 file_util::Delete(save_file->full_path(), false); | 576 file_util::Delete(save_file->full_path(), false); |
| 585 delete save_file; | 577 delete save_file; |
| 586 save_file_map_.erase(it); | 578 save_file_map_.erase(it); |
| 587 } | 579 } |
| 588 } | 580 } |
| 589 } | 581 } |
| OLD | NEW |