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 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 bool visited_referrer_before) { | 489 bool visited_referrer_before) { |
490 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 490 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
491 | 491 |
492 // Anything loaded directly from the address bar is OK. | 492 // Anything loaded directly from the address bar is OK. |
493 if (download.GetTransitionType() & content::PAGE_TRANSITION_FROM_ADDRESS_BAR) | 493 if (download.GetTransitionType() & content::PAGE_TRANSITION_FROM_ADDRESS_BAR) |
494 return false; | 494 return false; |
495 | 495 |
496 // Extensions that are not from the gallery are considered dangerous. | 496 // Extensions that are not from the gallery are considered dangerous. |
497 // When off-store install is disabled we skip this, since in this case, we | 497 // When off-store install is disabled we skip this, since in this case, we |
498 // will not offer to install the extension. | 498 // will not offer to install the extension. |
499 if (extensions::switch_utils::IsOffStoreInstallEnabled() && | 499 if (extensions::switch_utils::IsEasyOffStoreInstallEnabled() && |
500 download_crx_util::IsExtensionDownload(download) && | 500 download_crx_util::IsExtensionDownload(download) && |
501 !WebstoreInstaller::GetAssociatedApproval(download)) { | 501 !WebstoreInstaller::GetAssociatedApproval(download)) { |
502 return true; | 502 return true; |
503 } | 503 } |
504 | 504 |
505 // Anything the user has marked auto-open is OK if it's user-initiated. | 505 // Anything the user has marked auto-open is OK if it's user-initiated. |
506 if (ShouldOpenFileBasedOnExtension(suggested_path) && | 506 if (ShouldOpenFileBasedOnExtension(suggested_path) && |
507 download.HasUserGesture()) | 507 download.HasUserGesture()) |
508 return false; | 508 return false; |
509 | 509 |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 int32 download_id, int64 db_handle) { | 803 int32 download_id, int64 db_handle) { |
804 // It's not immediately obvious, but HistoryBackend::CreateDownload() can | 804 // It's not immediately obvious, but HistoryBackend::CreateDownload() can |
805 // call this function with an invalid |db_handle|. For instance, this can | 805 // call this function with an invalid |db_handle|. For instance, this can |
806 // happen when the history database is offline. We cannot have multiple | 806 // happen when the history database is offline. We cannot have multiple |
807 // DownloadItems with the same invalid db_handle, so we need to assign a | 807 // DownloadItems with the same invalid db_handle, so we need to assign a |
808 // unique |db_handle| here. | 808 // unique |db_handle| here. |
809 if (db_handle == DownloadItem::kUninitializedHandle) | 809 if (db_handle == DownloadItem::kUninitializedHandle) |
810 db_handle = download_history_->GetNextFakeDbHandle(); | 810 db_handle = download_history_->GetNextFakeDbHandle(); |
811 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); | 811 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); |
812 } | 812 } |
OLD | NEW |