| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/chrome_download_manager_delegate.h" | 5 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 state.prompt_user_for_save_location = true; | 398 state.prompt_user_for_save_location = true; |
| 399 } | 399 } |
| 400 if (download_prefs_->IsDownloadPathManaged()) { | 400 if (download_prefs_->IsDownloadPathManaged()) { |
| 401 state.prompt_user_for_save_location = false; | 401 state.prompt_user_for_save_location = false; |
| 402 } | 402 } |
| 403 | 403 |
| 404 // Determine the proper path for a download, by either one of the following: | 404 // Determine the proper path for a download, by either one of the following: |
| 405 // 1) using the default download directory. | 405 // 1) using the default download directory. |
| 406 // 2) prompting the user. | 406 // 2) prompting the user. |
| 407 if (state.prompt_user_for_save_location && | 407 if (state.prompt_user_for_save_location && |
| 408 !download_manager_->last_download_path().empty()) { | 408 !download_manager_->LastDownloadPath().empty()) { |
| 409 state.suggested_path = download_manager_->last_download_path(); | 409 state.suggested_path = download_manager_->LastDownloadPath(); |
| 410 } else { | 410 } else { |
| 411 state.suggested_path = download_prefs_->download_path(); | 411 state.suggested_path = download_prefs_->download_path(); |
| 412 } | 412 } |
| 413 state.suggested_path = state.suggested_path.Append(generated_name); | 413 state.suggested_path = state.suggested_path.Append(generated_name); |
| 414 } else { | 414 } else { |
| 415 state.suggested_path = state.force_file_name; | 415 state.suggested_path = state.force_file_name; |
| 416 } | 416 } |
| 417 | 417 |
| 418 if (!state.prompt_user_for_save_location && state.force_file_name.empty()) { | 418 if (!state.prompt_user_for_save_location && state.force_file_name.empty()) { |
| 419 state.is_dangerous_file = | 419 state.is_dangerous_file = |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 int32 download_id, int64 db_handle) { | 572 int32 download_id, int64 db_handle) { |
| 573 // It's not immediately obvious, but HistoryBackend::CreateDownload() can | 573 // It's not immediately obvious, but HistoryBackend::CreateDownload() can |
| 574 // call this function with an invalid |db_handle|. For instance, this can | 574 // call this function with an invalid |db_handle|. For instance, this can |
| 575 // happen when the history database is offline. We cannot have multiple | 575 // happen when the history database is offline. We cannot have multiple |
| 576 // DownloadItems with the same invalid db_handle, so we need to assign a | 576 // DownloadItems with the same invalid db_handle, so we need to assign a |
| 577 // unique |db_handle| here. | 577 // unique |db_handle| here. |
| 578 if (db_handle == DownloadItem::kUninitializedHandle) | 578 if (db_handle == DownloadItem::kUninitializedHandle) |
| 579 db_handle = download_history_->GetNextFakeDbHandle(); | 579 db_handle = download_history_->GetNextFakeDbHandle(); |
| 580 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); | 580 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); |
| 581 } | 581 } |
| OLD | NEW |