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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 WebContents* ChromeDownloadManagerDelegate:: | 216 WebContents* ChromeDownloadManagerDelegate:: |
217 GetAlternativeWebContentsToNotifyForDownload() { | 217 GetAlternativeWebContentsToNotifyForDownload() { |
218 #if defined(OS_ANDROID) | 218 #if defined(OS_ANDROID) |
219 // Android does not implement BrowserList or any other way to get an | 219 // Android does not implement BrowserList or any other way to get an |
220 // alternate web contents. | 220 // alternate web contents. |
221 return NULL; | 221 return NULL; |
222 #else | 222 #else |
223 // Start the download in the last active browser. This is not ideal but better | 223 // Start the download in the last active browser. This is not ideal but better |
224 // than fully hiding the download from the user. | 224 // than fully hiding the download from the user. |
225 Browser* last_active = browser::FindLastActiveWithProfile(profile_); | 225 Browser* last_active = browser::FindLastActiveWithProfile(profile_); |
226 return last_active ? last_active->GetSelectedWebContents() : NULL; | 226 return last_active ? last_active->GetActiveWebContents() : NULL; |
227 #endif | 227 #endif |
228 } | 228 } |
229 | 229 |
230 bool ChromeDownloadManagerDelegate::ShouldOpenFileBasedOnExtension( | 230 bool ChromeDownloadManagerDelegate::ShouldOpenFileBasedOnExtension( |
231 const FilePath& path) { | 231 const FilePath& path) { |
232 FilePath::StringType extension = path.Extension(); | 232 FilePath::StringType extension = path.Extension(); |
233 if (extension.empty()) | 233 if (extension.empty()) |
234 return false; | 234 return false; |
235 if (extensions::Extension::IsExtension(path)) | 235 if (extensions::Extension::IsExtension(path)) |
236 return false; | 236 return false; |
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 int32 download_id, int64 db_handle) { | 809 int32 download_id, int64 db_handle) { |
810 // It's not immediately obvious, but HistoryBackend::CreateDownload() can | 810 // It's not immediately obvious, but HistoryBackend::CreateDownload() can |
811 // call this function with an invalid |db_handle|. For instance, this can | 811 // call this function with an invalid |db_handle|. For instance, this can |
812 // happen when the history database is offline. We cannot have multiple | 812 // happen when the history database is offline. We cannot have multiple |
813 // DownloadItems with the same invalid db_handle, so we need to assign a | 813 // DownloadItems with the same invalid db_handle, so we need to assign a |
814 // unique |db_handle| here. | 814 // unique |db_handle| here. |
815 if (db_handle == DownloadItem::kUninitializedHandle) | 815 if (db_handle == DownloadItem::kUninitializedHandle) |
816 db_handle = download_history_->GetNextFakeDbHandle(); | 816 db_handle = download_history_->GetNextFakeDbHandle(); |
817 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); | 817 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); |
818 } | 818 } |
OLD | NEW |