OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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_manager.h" | 5 #include "chrome/browser/download/download_manager.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 DCHECK(MessageLoop::current() == ui_loop_); | 633 DCHECK(MessageLoop::current() == ui_loop_); |
634 DCHECK(info); | 634 DCHECK(info); |
635 | 635 |
636 if (info->save_as) { | 636 if (info->save_as) { |
637 // We must ask the user for the place to put the download. | 637 // We must ask the user for the place to put the download. |
638 if (!select_file_dialog_.get()) | 638 if (!select_file_dialog_.get()) |
639 select_file_dialog_ = SelectFileDialog::Create(this); | 639 select_file_dialog_ = SelectFileDialog::Create(this); |
640 | 640 |
641 WebContents* contents = tab_util::GetWebContentsByID( | 641 WebContents* contents = tab_util::GetWebContentsByID( |
642 info->render_process_id, info->render_view_id); | 642 info->render_process_id, info->render_view_id); |
643 #if defined(OS_WIN) | 643 SelectFileDialog::FileTypeInfo file_type_info; |
644 std::wstring filter = | 644 file_type_info.extensions.resize(1); |
645 win_util::GetFileFilterFromPath(info->suggested_path.value()); | 645 file_type_info.extensions[0].push_back(info->suggested_path.Extension()); |
646 #elif defined(OS_LINUX) | 646 file_type_info.include_all_files = true; |
647 std::wstring filter; | |
648 #endif | |
649 gfx::NativeWindow owning_window = | 647 gfx::NativeWindow owning_window = |
650 contents ? platform_util::GetTopLevel(contents->GetNativeView()) : NULL; | 648 contents ? platform_util::GetTopLevel(contents->GetNativeView()) : NULL; |
651 select_file_dialog_->SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE, | 649 select_file_dialog_->SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE, |
652 string16(), | 650 string16(), |
653 info->suggested_path, | 651 info->suggested_path, |
654 filter, 0, FILE_PATH_LITERAL(""), | 652 &file_type_info, 0, FILE_PATH_LITERAL(""), |
655 owning_window, info); | 653 owning_window, info); |
656 } else { | 654 } else { |
657 // No prompting for download, just continue with the suggested name. | 655 // No prompting for download, just continue with the suggested name. |
658 ContinueStartDownload(info, info->suggested_path); | 656 ContinueStartDownload(info, info->suggested_path); |
659 } | 657 } |
660 #elif defined(OS_MACOSX) | 658 #elif defined(OS_MACOSX) |
661 // TODO(port): port this file -- need dialogs. | 659 // TODO(port): port this file -- need dialogs. |
662 NOTIMPLEMENTED(); | 660 NOTIMPLEMENTED(); |
663 #endif | 661 #endif |
664 } | 662 } |
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1518 searched_downloads.push_back(dit->second); | 1516 searched_downloads.push_back(dit->second); |
1519 } | 1517 } |
1520 | 1518 |
1521 requestor->SetDownloads(searched_downloads); | 1519 requestor->SetDownloads(searched_downloads); |
1522 } | 1520 } |
1523 | 1521 |
1524 // Clears the last download path, used to initialize "save as" dialogs. | 1522 // Clears the last download path, used to initialize "save as" dialogs. |
1525 void DownloadManager::ClearLastDownloadPath() { | 1523 void DownloadManager::ClearLastDownloadPath() { |
1526 last_download_path_ = FilePath(); | 1524 last_download_path_ = FilePath(); |
1527 } | 1525 } |
OLD | NEW |