| 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_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 10 matching lines...) Expand all Loading... |
| 21 #include "chrome/browser/profile.h" | 21 #include "chrome/browser/profile.h" |
| 22 #include "chrome/browser/renderer_host/render_process_host.h" | 22 #include "chrome/browser/renderer_host/render_process_host.h" |
| 23 #include "chrome/browser/renderer_host/render_view_host.h" | 23 #include "chrome/browser/renderer_host/render_view_host.h" |
| 24 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 24 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
| 25 #include "chrome/browser/tab_contents/tab_util.h" | 25 #include "chrome/browser/tab_contents/tab_util.h" |
| 26 #include "chrome/browser/tab_contents/web_contents.h" | 26 #include "chrome/browser/tab_contents/web_contents.h" |
| 27 #include "chrome/common/chrome_constants.h" | 27 #include "chrome/common/chrome_constants.h" |
| 28 #include "chrome/common/chrome_paths.h" | 28 #include "chrome/common/chrome_paths.h" |
| 29 #include "chrome/common/l10n_util.h" | 29 #include "chrome/common/l10n_util.h" |
| 30 #include "chrome/common/notification_service.h" | 30 #include "chrome/common/notification_service.h" |
| 31 #include "chrome/common/platform_util.h" |
| 31 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
| 32 #include "chrome/common/pref_service.h" | 33 #include "chrome/common/pref_service.h" |
| 33 #include "chrome/common/stl_util-inl.h" | 34 #include "chrome/common/stl_util-inl.h" |
| 34 #include "googleurl/src/gurl.h" | 35 #include "googleurl/src/gurl.h" |
| 35 #include "grit/generated_resources.h" | 36 #include "grit/generated_resources.h" |
| 36 #include "net/base/mime_util.h" | 37 #include "net/base/mime_util.h" |
| 37 #include "net/base/net_util.h" | 38 #include "net/base/net_util.h" |
| 38 #include "net/url_request/url_request_context.h" | 39 #include "net/url_request/url_request_context.h" |
| 39 | 40 |
| 40 #if defined(OS_WIN) | 41 #if defined(OS_WIN) |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 if (info->save_as) { | 630 if (info->save_as) { |
| 630 // We must ask the user for the place to put the download. | 631 // We must ask the user for the place to put the download. |
| 631 if (!select_file_dialog_.get()) | 632 if (!select_file_dialog_.get()) |
| 632 select_file_dialog_ = SelectFileDialog::Create(this); | 633 select_file_dialog_ = SelectFileDialog::Create(this); |
| 633 | 634 |
| 634 WebContents* contents = tab_util::GetWebContentsByID( | 635 WebContents* contents = tab_util::GetWebContentsByID( |
| 635 info->render_process_id, info->render_view_id); | 636 info->render_process_id, info->render_view_id); |
| 636 #if defined(OS_WIN) | 637 #if defined(OS_WIN) |
| 637 std::wstring filter = | 638 std::wstring filter = |
| 638 win_util::GetFileFilterFromPath(info->suggested_path.value()); | 639 win_util::GetFileFilterFromPath(info->suggested_path.value()); |
| 639 gfx::NativeWindow owning_window = | |
| 640 contents ? GetAncestor(contents->GetNativeView(), GA_ROOT) : NULL; | |
| 641 #elif defined(OS_LINUX) | 640 #elif defined(OS_LINUX) |
| 642 std::wstring filter; | 641 std::wstring filter; |
| 643 gfx::NativeWindow owning_window = contents ? | |
| 644 GTK_WINDOW(gtk_widget_get_toplevel(contents->GetNativeView())) : | |
| 645 NULL; | |
| 646 #endif | 642 #endif |
| 643 gfx::NativeWindow owning_window = |
| 644 contents ? platform_util::GetTopLevel(contents->GetNativeView()) : NULL; |
| 647 select_file_dialog_->SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE, | 645 select_file_dialog_->SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE, |
| 648 std::wstring(), | 646 std::wstring(), |
| 649 info->suggested_path.ToWStringHack(), | 647 info->suggested_path.ToWStringHack(), |
| 650 filter, 0, std::wstring(), | 648 filter, 0, std::wstring(), |
| 651 owning_window, info); | 649 owning_window, info); |
| 652 } else { | 650 } else { |
| 653 // No prompting for download, just continue with the suggested name. | 651 // No prompting for download, just continue with the suggested name. |
| 654 ContinueStartDownload(info, info->suggested_path); | 652 ContinueStartDownload(info, info->suggested_path); |
| 655 } | 653 } |
| 656 #elif defined(OS_MACOSX) | 654 #elif defined(OS_MACOSX) |
| (...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1450 searched_downloads.push_back(dit->second); | 1448 searched_downloads.push_back(dit->second); |
| 1451 } | 1449 } |
| 1452 | 1450 |
| 1453 requestor->SetDownloads(searched_downloads); | 1451 requestor->SetDownloads(searched_downloads); |
| 1454 } | 1452 } |
| 1455 | 1453 |
| 1456 // Clears the last download path, used to initialize "save as" dialogs. | 1454 // Clears the last download path, used to initialize "save as" dialogs. |
| 1457 void DownloadManager::ClearLastDownloadPath() { | 1455 void DownloadManager::ClearLastDownloadPath() { |
| 1458 last_download_path_ = FilePath(); | 1456 last_download_path_ = FilePath(); |
| 1459 } | 1457 } |
| OLD | NEW |