| 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 "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 // insert the new DownloadItem into 'downloads_' or inform our observers at this | 559 // insert the new DownloadItem into 'downloads_' or inform our observers at this |
| 560 // point. OnCreateDatabaseEntryComplete() handles that finalization of the the | 560 // point. OnCreateDatabaseEntryComplete() handles that finalization of the the |
| 561 // download creation as a callback from the history thread. | 561 // download creation as a callback from the history thread. |
| 562 void DownloadManager::StartDownload(DownloadCreateInfo* info) { | 562 void DownloadManager::StartDownload(DownloadCreateInfo* info) { |
| 563 DCHECK(MessageLoop::current() == ui_loop_); | 563 DCHECK(MessageLoop::current() == ui_loop_); |
| 564 DCHECK(info); | 564 DCHECK(info); |
| 565 | 565 |
| 566 // Freeze the user's preference for showing a Save As dialog. We're going to | 566 // Freeze the user's preference for showing a Save As dialog. We're going to |
| 567 // bounce around a bunch of threads and we don't want to worry about race | 567 // bounce around a bunch of threads and we don't want to worry about race |
| 568 // conditions where the user changes this pref out from under us. | 568 // conditions where the user changes this pref out from under us. |
| 569 if (*prompt_for_download_) | 569 if (*prompt_for_download_) { |
| 570 info->save_as = true; | 570 // But never obey the preference for extension installation. Note that we |
| 571 // only care here about the case where an extension is installed, not when |
| 572 // one is downloaded with "save as...". |
| 573 if (!IsExtensionInstall(info)) |
| 574 info->save_as = true; |
| 575 } |
| 571 | 576 |
| 572 // Determine the proper path for a download, by choosing either the default | 577 // Determine the proper path for a download, by choosing either the default |
| 573 // download directory, or prompting the user. | 578 // download directory, or prompting the user. |
| 574 FilePath generated_name; | 579 FilePath generated_name; |
| 575 GenerateFilename(info, &generated_name); | 580 GenerateFilename(info, &generated_name); |
| 576 if (info->save_as && !last_download_path_.empty()) | 581 if (info->save_as && !last_download_path_.empty()) |
| 577 info->suggested_path = last_download_path_; | 582 info->suggested_path = last_download_path_; |
| 578 else | 583 else |
| 579 info->suggested_path = download_path(); | 584 info->suggested_path = download_path(); |
| 580 info->suggested_path = info->suggested_path.Append(generated_name); | 585 info->suggested_path = info->suggested_path.Append(generated_name); |
| (...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1546 | 1551 |
| 1547 if (contents) | 1552 if (contents) |
| 1548 contents->OnStartDownload(download); | 1553 contents->OnStartDownload(download); |
| 1549 } | 1554 } |
| 1550 | 1555 |
| 1551 // Clears the last download path, used to initialize "save as" dialogs. | 1556 // Clears the last download path, used to initialize "save as" dialogs. |
| 1552 void DownloadManager::ClearLastDownloadPath() { | 1557 void DownloadManager::ClearLastDownloadPath() { |
| 1553 last_download_path_ = FilePath(); | 1558 last_download_path_ = FilePath(); |
| 1554 } | 1559 } |
| 1555 | 1560 |
| OLD | NEW |