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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 } | 85 } |
86 | 86 |
87 ChromeDownloadManagerDelegate::~ChromeDownloadManagerDelegate() { | 87 ChromeDownloadManagerDelegate::~ChromeDownloadManagerDelegate() { |
88 } | 88 } |
89 | 89 |
90 bool ChromeDownloadManagerDelegate::IsExtensionDownload( | 90 bool ChromeDownloadManagerDelegate::IsExtensionDownload( |
91 const DownloadItem* item) { | 91 const DownloadItem* item) { |
92 if (item->PromptUserForSaveLocation()) | 92 if (item->PromptUserForSaveLocation()) |
93 return false; | 93 return false; |
94 | 94 |
95 return (item->GetMimeType() == Extension::kMimeType) || | 95 if ((item->GetMimeType() != Extension::kMimeType) && |
96 UserScript::IsURLUserScript(item->GetURL(), item->GetMimeType()); | 96 !UserScript::IsURLUserScript(item->GetURL(), item->GetMimeType())) { |
| 97 return false; |
| 98 } |
| 99 |
| 100 return download_crx_util::ShouldOpenExtensionDownload(*item); |
97 } | 101 } |
98 | 102 |
99 void ChromeDownloadManagerDelegate::SetDownloadManager(DownloadManager* dm) { | 103 void ChromeDownloadManagerDelegate::SetDownloadManager(DownloadManager* dm) { |
100 download_manager_ = dm; | 104 download_manager_ = dm; |
101 download_history_.reset(new DownloadHistory(profile_)); | 105 download_history_.reset(new DownloadHistory(profile_)); |
102 download_history_->Load( | 106 download_history_->Load( |
103 base::Bind(&DownloadManager::OnPersistentStoreQueryComplete, | 107 base::Bind(&DownloadManager::OnPersistentStoreQueryComplete, |
104 base::Unretained(dm))); | 108 base::Unretained(dm))); |
105 } | 109 } |
106 | 110 |
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 int32 download_id, int64 db_handle) { | 704 int32 download_id, int64 db_handle) { |
701 // It's not immediately obvious, but HistoryBackend::CreateDownload() can | 705 // It's not immediately obvious, but HistoryBackend::CreateDownload() can |
702 // call this function with an invalid |db_handle|. For instance, this can | 706 // call this function with an invalid |db_handle|. For instance, this can |
703 // happen when the history database is offline. We cannot have multiple | 707 // happen when the history database is offline. We cannot have multiple |
704 // DownloadItems with the same invalid db_handle, so we need to assign a | 708 // DownloadItems with the same invalid db_handle, so we need to assign a |
705 // unique |db_handle| here. | 709 // unique |db_handle| here. |
706 if (db_handle == DownloadItem::kUninitializedHandle) | 710 if (db_handle == DownloadItem::kUninitializedHandle) |
707 db_handle = download_history_->GetNextFakeDbHandle(); | 711 db_handle = download_history_->GetNextFakeDbHandle(); |
708 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); | 712 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); |
709 } | 713 } |
OLD | NEW |