mirror of
				https://bitbucket.org/chromiumembedded/cef
				synced 2025-06-05 21:39:12 +02:00 
			
		
		
		
	Behaves the same as Alloy runtime except that CanDownload is not called for invalid protocol schemes.
		
			
				
	
	
		
			122 lines
		
	
	
		
			4.4 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			122 lines
		
	
	
		
			4.4 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
| diff --git chrome/browser/download/chrome_download_manager_delegate.cc chrome/browser/download/chrome_download_manager_delegate.cc
 | |
| index 447e7d0d5dc6d..7bba632f1331c 100644
 | |
| --- chrome/browser/download/chrome_download_manager_delegate.cc
 | |
| +++ chrome/browser/download/chrome_download_manager_delegate.cc
 | |
| @@ -146,6 +146,10 @@
 | |
|  #include "chrome/browser/safe_browsing/download_protection/download_protection_util.h"
 | |
|  #endif
 | |
|  
 | |
| +#if BUILDFLAG(ENABLE_CEF)
 | |
| +#include "cef/libcef/browser/download_manager_delegate.h"
 | |
| +#endif
 | |
| +
 | |
|  using content::BrowserThread;
 | |
|  using content::DownloadManager;
 | |
|  using download::DownloadItem;
 | |
| @@ -490,6 +494,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() {
 | |
| @@ -549,6 +558,9 @@ void ChromeDownloadManagerDelegate::Shutdown() {
 | |
|      download_manager_->RemoveObserver(this);
 | |
|      download_manager_ = nullptr;
 | |
|    }
 | |
| +#if BUILDFLAG(ENABLE_CEF)
 | |
| +  cef_delegate_.reset();
 | |
| +#endif
 | |
|  }
 | |
|  
 | |
|  void ChromeDownloadManagerDelegate::OnDownloadCanceledAtShutdown(
 | |
| @@ -617,6 +629,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(),
 | |
| diff --git chrome/browser/download/chrome_download_manager_delegate.h chrome/browser/download/chrome_download_manager_delegate.h
 | |
| index e2cf12d2c8fee..376818e28798c 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/runtime.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"
 | |
| @@ -57,6 +58,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,
 | |
| @@ -387,6 +394,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};
 | |
|  };
 | |
|  
 | |
| diff --git chrome/browser/download/download_prefs.cc chrome/browser/download/download_prefs.cc
 | |
| index 773f72da82f90..6d0307988406f 100644
 | |
| --- chrome/browser/download/download_prefs.cc
 | |
| +++ chrome/browser/download/download_prefs.cc
 | |
| @@ -23,6 +23,7 @@
 | |
|  #include "base/strings/utf_string_conversions.h"
 | |
|  #include "build/build_config.h"
 | |
|  #include "build/chromeos_buildflags.h"
 | |
| +#include "cef/libcef/features/runtime.h"
 | |
|  #include "chrome/browser/download/chrome_download_manager_delegate.h"
 | |
|  #include "chrome/browser/download/download_core_service_factory.h"
 | |
|  #include "chrome/browser/download/download_core_service_impl.h"
 | |
| @@ -64,6 +65,10 @@
 | |
|  #include "chrome/browser/flags/android/chrome_feature_list.h"
 | |
|  #endif
 | |
|  
 | |
| +#if BUILDFLAG(ENABLE_CEF)
 | |
| +#include "cef/libcef/browser/alloy/alloy_download_util.h"
 | |
| +#endif
 | |
| +
 | |
|  using content::BrowserContext;
 | |
|  using content::BrowserThread;
 | |
|  using content::DownloadManager;
 | |
| @@ -355,6 +360,11 @@ DownloadPrefs* DownloadPrefs::FromDownloadManager(
 | |
|  // static
 | |
|  DownloadPrefs* DownloadPrefs::FromBrowserContext(
 | |
|      content::BrowserContext* context) {
 | |
| +#if BUILDFLAG(ENABLE_CEF)
 | |
| +  if (cef::IsAlloyRuntimeEnabled()) {
 | |
| +    return alloy::GetDownloadPrefsFromBrowserContext(context);
 | |
| +  }
 | |
| +#endif
 | |
|    return FromDownloadManager(context->GetDownloadManager());
 | |
|  }
 | |
|  
 |