Support override of client id for file scanning (fixes issue #2368).

This commit is contained in:
Ananyo Maiti 2019-05-07 16:22:16 +00:00 committed by Marshall Greenblatt
parent 8b400331c7
commit 3827f817c7
6 changed files with 34 additions and 5 deletions

View File

@ -34,7 +34,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=dd6129d832b33b4da283d86722ba5a7b743a15a5$
// $hash=e9ff73cc80e162b173ecd1a62b0cb48f9e46de99$
//
#ifndef CEF_INCLUDE_API_HASH_H_
@ -47,13 +47,13 @@
// way that may cause binary incompatibility with other builds. The universal
// hash value will change if any platform is affected whereas the platform hash
// values will change only if that particular platform is affected.
#define CEF_API_HASH_UNIVERSAL "91bb58af264779076e95dfd1a63033bc7da296cd"
#define CEF_API_HASH_UNIVERSAL "fa535acbd95d3d7a25e43b015dfea09700d7bf72"
#if defined(OS_WIN)
#define CEF_API_HASH_PLATFORM "7cacaf3f958d22f84e4ee6b5216dc5ccc4c18e31"
#define CEF_API_HASH_PLATFORM "a729d5a21d1f3655db514d47093abe59794f5f26"
#elif defined(OS_MACOSX)
#define CEF_API_HASH_PLATFORM "b471cf826966f5917fd3855996c8998898df2334"
#define CEF_API_HASH_PLATFORM "6b77f0976c19ba6b15a8a054fe35bde0ba2cf89d"
#elif defined(OS_LINUX)
#define CEF_API_HASH_PLATFORM "1b0a73214b4f50b23e2dab96d7a1d6def2c195dc"
#define CEF_API_HASH_PLATFORM "c21503860303873c2148e3740d6c407ae6ece32b"
#endif
#ifdef __cplusplus

View File

@ -412,6 +412,14 @@ typedef struct _cef_settings_t {
// CefRequestContextSettings.accept_language_list value.
///
cef_string_t accept_language_list;
///
// GUID string used for identifying the application. This is passed to the
// system AV function for scanning downloaded files. By default, the GUID
// will be an empty string and the file will be treated as an untrusted
// file when the GUID is empty.
///
cef_string_t application_client_id_for_file_scanning;
} cef_settings_t;
///

View File

@ -553,6 +553,7 @@ struct CefSettingsTraits {
cef_string_clear(&s->resources_dir_path);
cef_string_clear(&s->locales_dir_path);
cef_string_clear(&s->accept_language_list);
cef_string_clear(&s->application_client_id_for_file_scanning);
}
static inline void set(const struct_type* src,
@ -603,6 +604,9 @@ struct CefSettingsTraits {
cef_string_set(src->accept_language_list.str,
src->accept_language_list.length,
&target->accept_language_list, copy);
cef_string_set(src->application_client_id_for_file_scanning.str,
src->application_client_id_for_file_scanning.length,
&target->application_client_id_for_file_scanning, copy);
}
};

View File

@ -5,6 +5,7 @@
#include "libcef/browser/download_manager_delegate.h"
#include "include/cef_download_handler.h"
#include "libcef/browser/context.h"
#include "libcef/browser/download_item_impl.h"
#include "libcef/browser/thread_util.h"
@ -14,6 +15,7 @@
#include "base/path_service.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/common/chrome_constants.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/download_item_utils.h"
#include "content/public/browser/web_contents.h"
@ -387,6 +389,16 @@ void CefDownloadManagerDelegate::GetNextId(
callback.Run(next_id++);
}
std::string CefDownloadManagerDelegate::ApplicationClientIdForFileScanning()
const {
const CefSettings& settings = CefContext::Get()->settings();
if (settings.application_client_id_for_file_scanning.length > 0) {
return CefString(&settings.application_client_id_for_file_scanning)
.ToString();
}
return std::string();
}
void CefDownloadManagerDelegate::OnBrowserDestroyed(
CefBrowserHostImpl* browser) {
ItemBrowserMap::iterator it = item_browser_map_.begin();

View File

@ -39,6 +39,7 @@ class CefDownloadManagerDelegate : public download::DownloadItem::Observer,
download::DownloadItem* item,
const content::DownloadTargetCallback& callback) override;
void GetNextId(const content::DownloadIdCallback& callback) override;
std::string ApplicationClientIdForFileScanning() const override;
// CefBrowserHostImpl::Observer methods.
void OnBrowserDestroyed(CefBrowserHostImpl* browser) override;

View File

@ -76,6 +76,10 @@ int RunMain(HINSTANCE hInstance, int nCmdShow) {
settings.no_sandbox = true;
#endif
// Applications should specify a unique GUID here to enable trusted downloads.
CefString(&settings.application_client_id_for_file_scanning)
.FromString("9A8DE24D-B822-4C6C-8259-5A848FEA1E68");
// Populate the settings based on command line arguments.
context->PopulateSettings(&settings);