| 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 28 matching lines...) Expand all Loading... |
| 39 #include "content/public/browser/notification_source.h" | 39 #include "content/public/browser/notification_source.h" |
| 40 #include "content/public/browser/web_contents.h" | 40 #include "content/public/browser/web_contents.h" |
| 41 #include "content/public/browser/web_contents_delegate.h" | 41 #include "content/public/browser/web_contents_delegate.h" |
| 42 #include "content/public/browser/web_intents_dispatcher.h" | 42 #include "content/public/browser/web_intents_dispatcher.h" |
| 43 #include "grit/generated_resources.h" | 43 #include "grit/generated_resources.h" |
| 44 #include "ui/base/l10n/l10n_util.h" | 44 #include "ui/base/l10n/l10n_util.h" |
| 45 #include "webkit/glue/web_intent_data.h" | 45 #include "webkit/glue/web_intent_data.h" |
| 46 | 46 |
| 47 #if !defined(OS_ANDROID) | 47 #if !defined(OS_ANDROID) |
| 48 #include "chrome/browser/ui/browser.h" | 48 #include "chrome/browser/ui/browser.h" |
| 49 #include "chrome/browser/ui/browser_list.h" | 49 #include "chrome/browser/ui/browser_finder.h" |
| 50 #endif | 50 #endif |
| 51 | 51 |
| 52 #if defined(OS_CHROMEOS) | 52 #if defined(OS_CHROMEOS) |
| 53 #include "chrome/browser/chromeos/gdata/gdata_download_observer.h" | 53 #include "chrome/browser/chromeos/gdata/gdata_download_observer.h" |
| 54 #include "chrome/browser/download/download_file_picker_chromeos.h" | 54 #include "chrome/browser/download/download_file_picker_chromeos.h" |
| 55 #include "chrome/browser/download/save_package_file_picker_chromeos.h" | 55 #include "chrome/browser/download/save_package_file_picker_chromeos.h" |
| 56 #endif | 56 #endif |
| 57 | 57 |
| 58 using content::BrowserThread; | 58 using content::BrowserThread; |
| 59 using content::DownloadId; | 59 using content::DownloadId; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 172 |
| 173 WebContents* ChromeDownloadManagerDelegate:: | 173 WebContents* ChromeDownloadManagerDelegate:: |
| 174 GetAlternativeWebContentsToNotifyForDownload() { | 174 GetAlternativeWebContentsToNotifyForDownload() { |
| 175 #if defined(OS_ANDROID) | 175 #if defined(OS_ANDROID) |
| 176 // Android does not implement BrowserList or any other way to get an | 176 // Android does not implement BrowserList or any other way to get an |
| 177 // alternate web contents. | 177 // alternate web contents. |
| 178 return NULL; | 178 return NULL; |
| 179 #else | 179 #else |
| 180 // Start the download in the last active browser. This is not ideal but better | 180 // Start the download in the last active browser. This is not ideal but better |
| 181 // than fully hiding the download from the user. | 181 // than fully hiding the download from the user. |
| 182 Browser* last_active = BrowserList::GetLastActiveWithProfile(profile_); | 182 Browser* last_active = browser::FindLastActiveWithProfile(profile_); |
| 183 return last_active ? last_active->GetSelectedWebContents() : NULL; | 183 return last_active ? last_active->GetSelectedWebContents() : NULL; |
| 184 #endif | 184 #endif |
| 185 } | 185 } |
| 186 | 186 |
| 187 | 187 |
| 188 bool ChromeDownloadManagerDelegate::ShouldOpenFileBasedOnExtension( | 188 bool ChromeDownloadManagerDelegate::ShouldOpenFileBasedOnExtension( |
| 189 const FilePath& path) { | 189 const FilePath& path) { |
| 190 FilePath::StringType extension = path.Extension(); | 190 FilePath::StringType extension = path.Extension(); |
| 191 if (extension.empty()) | 191 if (extension.empty()) |
| 192 return false; | 192 return false; |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 int32 download_id, int64 db_handle) { | 719 int32 download_id, int64 db_handle) { |
| 720 // It's not immediately obvious, but HistoryBackend::CreateDownload() can | 720 // It's not immediately obvious, but HistoryBackend::CreateDownload() can |
| 721 // call this function with an invalid |db_handle|. For instance, this can | 721 // call this function with an invalid |db_handle|. For instance, this can |
| 722 // happen when the history database is offline. We cannot have multiple | 722 // 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 | 723 // DownloadItems with the same invalid db_handle, so we need to assign a |
| 724 // unique |db_handle| here. | 724 // unique |db_handle| here. |
| 725 if (db_handle == DownloadItem::kUninitializedHandle) | 725 if (db_handle == DownloadItem::kUninitializedHandle) |
| 726 db_handle = download_history_->GetNextFakeDbHandle(); | 726 db_handle = download_history_->GetNextFakeDbHandle(); |
| 727 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); | 727 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); |
| 728 } | 728 } |
| OLD | NEW |