| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 | 501 |
| 502 // Anything loaded directly from the address bar is OK. | 502 // Anything loaded directly from the address bar is OK. |
| 503 if (download.GetTransitionType() & content::PAGE_TRANSITION_FROM_ADDRESS_BAR) | 503 if (download.GetTransitionType() & content::PAGE_TRANSITION_FROM_ADDRESS_BAR) |
| 504 return false; | 504 return false; |
| 505 | 505 |
| 506 // Extensions that are not from the gallery are considered dangerous. | 506 // Extensions that are not from the gallery are considered dangerous. |
| 507 // When off-store install is disabled we skip this, since in this case, we | 507 // When off-store install is disabled we skip this, since in this case, we |
| 508 // will not offer to install the extension. | 508 // will not offer to install the extension. |
| 509 if (extensions::switch_utils::IsEasyOffStoreInstallEnabled() && | 509 if (extensions::switch_utils::IsEasyOffStoreInstallEnabled() && |
| 510 download_crx_util::IsExtensionDownload(download) && | 510 download_crx_util::IsExtensionDownload(download) && |
| 511 !WebstoreInstaller::GetAssociatedApproval(download)) { | 511 !extensions::WebstoreInstaller::GetAssociatedApproval(download)) { |
| 512 return true; | 512 return true; |
| 513 } | 513 } |
| 514 | 514 |
| 515 // Anything the user has marked auto-open is OK if it's user-initiated. | 515 // Anything the user has marked auto-open is OK if it's user-initiated. |
| 516 if (ShouldOpenFileBasedOnExtension(suggested_path) && | 516 if (ShouldOpenFileBasedOnExtension(suggested_path) && |
| 517 download.HasUserGesture()) | 517 download.HasUserGesture()) |
| 518 return false; | 518 return false; |
| 519 | 519 |
| 520 // "Allow on user gesture" is OK when we have a user gesture and the hosting | 520 // "Allow on user gesture" is OK when we have a user gesture and the hosting |
| 521 // page has been visited before today. | 521 // page has been visited before today. |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 int32 download_id, int64 db_handle) { | 756 int32 download_id, int64 db_handle) { |
| 757 // It's not immediately obvious, but HistoryBackend::CreateDownload() can | 757 // It's not immediately obvious, but HistoryBackend::CreateDownload() can |
| 758 // call this function with an invalid |db_handle|. For instance, this can | 758 // call this function with an invalid |db_handle|. For instance, this can |
| 759 // happen when the history database is offline. We cannot have multiple | 759 // happen when the history database is offline. We cannot have multiple |
| 760 // DownloadItems with the same invalid db_handle, so we need to assign a | 760 // DownloadItems with the same invalid db_handle, so we need to assign a |
| 761 // unique |db_handle| here. | 761 // unique |db_handle| here. |
| 762 if (db_handle == DownloadItem::kUninitializedHandle) | 762 if (db_handle == DownloadItem::kUninitializedHandle) |
| 763 db_handle = download_history_->GetNextFakeDbHandle(); | 763 db_handle = download_history_->GetNextFakeDbHandle(); |
| 764 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); | 764 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); |
| 765 } | 765 } |
| OLD | NEW |