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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 if ((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; | 97 return false; |
98 } | 98 } |
99 | 99 |
100 return download_crx_util::ShouldOpenExtensionDownload(*item); | 100 Profile* profile = Profile::FromBrowserContext(item->GetBrowserContext()); |
| 101 return download_crx_util::ShouldOpenExtensionDownload( |
| 102 profile->GetExtensionService(), *item); |
101 } | 103 } |
102 | 104 |
103 void ChromeDownloadManagerDelegate::SetDownloadManager(DownloadManager* dm) { | 105 void ChromeDownloadManagerDelegate::SetDownloadManager(DownloadManager* dm) { |
104 download_manager_ = dm; | 106 download_manager_ = dm; |
105 download_history_.reset(new DownloadHistory(profile_)); | 107 download_history_.reset(new DownloadHistory(profile_)); |
106 download_history_->Load( | 108 download_history_->Load( |
107 base::Bind(&DownloadManager::OnPersistentStoreQueryComplete, | 109 base::Bind(&DownloadManager::OnPersistentStoreQueryComplete, |
108 base::Unretained(dm))); | 110 base::Unretained(dm))); |
109 } | 111 } |
110 | 112 |
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 int32 download_id, int64 db_handle) { | 721 int32 download_id, int64 db_handle) { |
720 // It's not immediately obvious, but HistoryBackend::CreateDownload() can | 722 // It's not immediately obvious, but HistoryBackend::CreateDownload() can |
721 // call this function with an invalid |db_handle|. For instance, this can | 723 // call this function with an invalid |db_handle|. For instance, this can |
722 // happen when the history database is offline. We cannot have multiple | 724 // happen when the history database is offline. We cannot have multiple |
723 // DownloadItems with the same invalid db_handle, so we need to assign a | 725 // DownloadItems with the same invalid db_handle, so we need to assign a |
724 // unique |db_handle| here. | 726 // unique |db_handle| here. |
725 if (db_handle == DownloadItem::kUninitializedHandle) | 727 if (db_handle == DownloadItem::kUninitializedHandle) |
726 db_handle = download_history_->GetNextFakeDbHandle(); | 728 db_handle = download_history_->GetNextFakeDbHandle(); |
727 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); | 729 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); |
728 } | 730 } |
OLD | NEW |