mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-04-27 00:48:45 +02:00
110 lines
4.0 KiB
Diff
110 lines
4.0 KiB
Diff
diff --git chrome/browser/download/chrome_download_manager_delegate.cc chrome/browser/download/chrome_download_manager_delegate.cc
|
|
index cfcae9fc073be..b8c140692facc 100644
|
|
--- chrome/browser/download/chrome_download_manager_delegate.cc
|
|
+++ chrome/browser/download/chrome_download_manager_delegate.cc
|
|
@@ -30,6 +30,7 @@
|
|
#include "base/task/thread_pool.h"
|
|
#include "base/time/time.h"
|
|
#include "build/build_config.h"
|
|
+#include "cef/libcef/features/features.h"
|
|
#include "chrome/browser/browser_process.h"
|
|
#include "chrome/browser/download/bubble/download_bubble_prefs.h"
|
|
#include "chrome/browser/download/download_core_service.h"
|
|
@@ -164,6 +165,10 @@
|
|
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
|
|
#endif // BUILDFLAG(SAFE_BROWSING_DOWNLOAD_PROTECTION)
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
+#include "cef/libcef/browser/download_manager_delegate.h"
|
|
+#endif
|
|
+
|
|
using content::BrowserThread;
|
|
using content::DownloadManager;
|
|
using download::DownloadItem;
|
|
@@ -523,6 +528,11 @@ ChromeDownloadManagerDelegate::ChromeDownloadManagerDelegate(Profile* profile)
|
|
download_dialog_bridge_ = std::make_unique<DownloadDialogBridge>();
|
|
download_message_bridge_ = std::make_unique<DownloadMessageBridge>();
|
|
#endif
|
|
+
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
+ cef_delegate_ =
|
|
+ cef::DownloadManagerDelegate::Create(profile_->GetDownloadManager());
|
|
+#endif
|
|
}
|
|
|
|
ChromeDownloadManagerDelegate::~ChromeDownloadManagerDelegate() {
|
|
@@ -586,6 +596,9 @@ void ChromeDownloadManagerDelegate::Shutdown() {
|
|
download_manager_->RemoveObserver(this);
|
|
download_manager_ = nullptr;
|
|
}
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
+ cef_delegate_.reset();
|
|
+#endif
|
|
}
|
|
|
|
void ChromeDownloadManagerDelegate::OnDownloadCanceledAtShutdown(
|
|
@@ -654,6 +667,12 @@ bool ChromeDownloadManagerDelegate::DetermineDownloadTarget(
|
|
ReportPDFLoadStatus(PDFLoadStatus::kTriggeredNoGestureDriveByDownload);
|
|
}
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
+ if (cef_delegate_->DetermineDownloadTarget(download, callback)) {
|
|
+ return true;
|
|
+ }
|
|
+#endif
|
|
+
|
|
DownloadTargetDeterminer::CompletionCallback target_determined_callback =
|
|
base::BindOnce(&ChromeDownloadManagerDelegate::OnDownloadTargetDetermined,
|
|
weak_ptr_factory_.GetWeakPtr(), download->GetId(),
|
|
@@ -1142,8 +1161,13 @@ void ChromeDownloadManagerDelegate::OpenDownload(DownloadItem* download) {
|
|
return;
|
|
}
|
|
|
|
+
|
|
Browser* browser = chrome::ScopedTabbedBrowserDisplayer(profile_).browser();
|
|
- CHECK(browser && browser->CanSupportWindowFeature(Browser::FEATURE_TABSTRIP));
|
|
+ CHECK(browser
|
|
+#if !BUILDFLAG(ENABLE_CEF)
|
|
+ && browser->CanSupportWindowFeature(Browser::FEATURE_TABSTRIP)
|
|
+#endif
|
|
+ );
|
|
content::OpenURLParams params(
|
|
net::FilePathToFileURL(download->GetTargetFilePath()),
|
|
content::Referrer(), WindowOpenDisposition::NEW_FOREGROUND_TAB,
|
|
diff --git chrome/browser/download/chrome_download_manager_delegate.h chrome/browser/download/chrome_download_manager_delegate.h
|
|
index 41db535e5cf9c..015d84cc95b49 100644
|
|
--- chrome/browser/download/chrome_download_manager_delegate.h
|
|
+++ chrome/browser/download/chrome_download_manager_delegate.h
|
|
@@ -19,6 +19,7 @@
|
|
#include "base/task/sequenced_task_runner.h"
|
|
#include "base/unguessable_token.h"
|
|
#include "build/build_config.h"
|
|
+#include "cef/libcef/features/features.h"
|
|
#include "chrome/browser/download/download_completion_blocker.h"
|
|
#include "chrome/browser/download/download_target_determiner_delegate.h"
|
|
#include "components/download/public/common/download_danger_type.h"
|
|
@@ -58,6 +59,12 @@ class CrxInstallError;
|
|
}
|
|
#endif
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
+namespace cef {
|
|
+class DownloadManagerDelegate;
|
|
+}
|
|
+#endif
|
|
+
|
|
// This is the Chrome side helper for the download system.
|
|
class ChromeDownloadManagerDelegate
|
|
: public content::DownloadManagerDelegate,
|
|
@@ -406,6 +413,10 @@ class ChromeDownloadManagerDelegate
|
|
// Whether a file picker dialog is showing.
|
|
bool is_file_picker_showing_;
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
+ std::unique_ptr<cef::DownloadManagerDelegate> cef_delegate_;
|
|
+#endif
|
|
+
|
|
base::WeakPtrFactory<ChromeDownloadManagerDelegate> weak_ptr_factory_{this};
|
|
};
|
|
|