| 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 30 matching lines...) Expand all Loading... |
| 41 #include "ui/base/l10n/l10n_util.h" | 41 #include "ui/base/l10n/l10n_util.h" |
| 42 | 42 |
| 43 #if !defined(OS_ANDROID) | 43 #if !defined(OS_ANDROID) |
| 44 #include "chrome/browser/ui/browser.h" | 44 #include "chrome/browser/ui/browser.h" |
| 45 #include "chrome/browser/ui/browser_list.h" | 45 #include "chrome/browser/ui/browser_list.h" |
| 46 #endif | 46 #endif |
| 47 | 47 |
| 48 #if defined(OS_CHROMEOS) | 48 #if defined(OS_CHROMEOS) |
| 49 #include "chrome/browser/chromeos/gdata/gdata_download_observer.h" | 49 #include "chrome/browser/chromeos/gdata/gdata_download_observer.h" |
| 50 #include "chrome/browser/download/download_file_picker_chromeos.h" | 50 #include "chrome/browser/download/download_file_picker_chromeos.h" |
| 51 #include "chrome/browser/download/save_package_file_picker_chromeos.h" |
| 51 #endif | 52 #endif |
| 52 | 53 |
| 53 using content::BrowserThread; | 54 using content::BrowserThread; |
| 54 using content::DownloadId; | 55 using content::DownloadId; |
| 55 using content::DownloadItem; | 56 using content::DownloadItem; |
| 56 using content::DownloadManager; | 57 using content::DownloadManager; |
| 57 using content::WebContents; | 58 using content::WebContents; |
| 58 using safe_browsing::DownloadProtectionService; | 59 using safe_browsing::DownloadProtectionService; |
| 59 | 60 |
| 60 namespace { | 61 namespace { |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 *download_save_dir = prefs->GetFilePath(prefs::kDownloadDefaultDirectory); | 311 *download_save_dir = prefs->GetFilePath(prefs::kDownloadDefaultDirectory); |
| 311 } | 312 } |
| 312 | 313 |
| 313 void ChromeDownloadManagerDelegate::ChooseSavePath( | 314 void ChromeDownloadManagerDelegate::ChooseSavePath( |
| 314 WebContents* web_contents, | 315 WebContents* web_contents, |
| 315 const FilePath& suggested_path, | 316 const FilePath& suggested_path, |
| 316 const FilePath::StringType& default_extension, | 317 const FilePath::StringType& default_extension, |
| 317 bool can_save_as_complete, | 318 bool can_save_as_complete, |
| 318 content::SaveFilePathPickedCallback callback) { | 319 content::SaveFilePathPickedCallback callback) { |
| 319 // Deletes itself. | 320 // Deletes itself. |
| 321 #if defined(OS_CHROMEOS) |
| 322 new SavePackageFilePickerChromeOS( |
| 323 #else |
| 320 new SavePackageFilePicker( | 324 new SavePackageFilePicker( |
| 325 #endif |
| 321 web_contents, suggested_path, default_extension, can_save_as_complete, | 326 web_contents, suggested_path, default_extension, can_save_as_complete, |
| 322 download_prefs_.get(), callback); | 327 download_prefs_.get(), callback); |
| 323 } | 328 } |
| 324 | 329 |
| 325 #if defined(ENABLE_SAFE_BROWSING) | 330 #if defined(ENABLE_SAFE_BROWSING) |
| 326 DownloadProtectionService* | 331 DownloadProtectionService* |
| 327 ChromeDownloadManagerDelegate::GetDownloadProtectionService() { | 332 ChromeDownloadManagerDelegate::GetDownloadProtectionService() { |
| 328 SafeBrowsingService* sb_service = g_browser_process->safe_browsing_service(); | 333 SafeBrowsingService* sb_service = g_browser_process->safe_browsing_service(); |
| 329 if (sb_service && sb_service->download_protection_service() && | 334 if (sb_service && sb_service->download_protection_service() && |
| 330 profile_->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled)) { | 335 profile_->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled)) { |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 int32 download_id, int64 db_handle) { | 639 int32 download_id, int64 db_handle) { |
| 635 // It's not immediately obvious, but HistoryBackend::CreateDownload() can | 640 // It's not immediately obvious, but HistoryBackend::CreateDownload() can |
| 636 // call this function with an invalid |db_handle|. For instance, this can | 641 // call this function with an invalid |db_handle|. For instance, this can |
| 637 // happen when the history database is offline. We cannot have multiple | 642 // happen when the history database is offline. We cannot have multiple |
| 638 // DownloadItems with the same invalid db_handle, so we need to assign a | 643 // DownloadItems with the same invalid db_handle, so we need to assign a |
| 639 // unique |db_handle| here. | 644 // unique |db_handle| here. |
| 640 if (db_handle == DownloadItem::kUninitializedHandle) | 645 if (db_handle == DownloadItem::kUninitializedHandle) |
| 641 db_handle = download_history_->GetNextFakeDbHandle(); | 646 db_handle = download_history_->GetNextFakeDbHandle(); |
| 642 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); | 647 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); |
| 643 } | 648 } |
| OLD | NEW |