Commit 4149192d authored by Marshall Greenblatt's avatar Marshall Greenblatt

Call OnBeforePluginLoad when building the plugin list (issue #1708)

parent a3372055
......@@ -1124,6 +1124,8 @@
'libcef/browser/permission_manager.h',
'libcef/browser/plugins/plugin_info_message_filter.cc',
'libcef/browser/plugins/plugin_info_message_filter.h',
'libcef/browser/plugins/plugin_service_filter.cc',
'libcef/browser/plugins/plugin_service_filter.h',
'libcef/browser/print_settings_impl.cc',
'libcef/browser/print_settings_impl.h',
'libcef/browser/printing/printing_message_filter.cc',
......
......@@ -140,6 +140,16 @@ typedef struct _cef_request_context_t {
///
int (CEF_CALLBACK *clear_scheme_handler_factories)(
struct _cef_request_context_t* self);
///
// Tells all renderer processes associated with this context to throw away
// their plugin list cache. If |reload_pages| is true (1) they will also
// reload all pages with plugins.
// cef_request_tContextHandler::OnBeforePluginLoad may be called to rebuild
// the plugin list cache.
///
void (CEF_CALLBACK *purge_plugin_list_cache)(
struct _cef_request_context_t* self, int reload_pages);
} cef_request_context_t;
......
......@@ -67,15 +67,21 @@ typedef struct _cef_request_context_handler_t {
struct _cef_request_context_handler_t* self);
///
// Called on the browser process IO thread before a plugin instance is loaded.
// |mime_type| is the mime type of the plugin that will be loaded.
// Called on multiple browser process threads before a plugin instance is
// loaded. |mime_type| is the mime type of the plugin that will be loaded.
// |plugin_url| is the content URL that the plugin will load and may be NULL.
// |top_origin_url| is the URL for the top-level frame that contains the
// plugin. |plugin_info| includes additional information about the plugin that
// will be loaded. |plugin_policy| is the recommended policy. Modify
// |plugin_policy| and return true (1) to change the policy. Return false (0)
// to use the recommended policy. The default plugin policy can be set at
// runtime using the `--plugin-policy=[allow|detect|block]` command-line flag.
// plugin when loading a specific plugin instance or NULL when building the
// initial list of enabled plugins for 'navigator.plugins' JavaScript state.
// |plugin_info| includes additional information about the plugin that will be
// loaded. |plugin_policy| is the recommended policy. Modify |plugin_policy|
// and return true (1) to change the policy. Return false (0) to use the
// recommended policy. The default plugin policy can be set at runtime using
// the `--plugin-policy=[allow|detect|block]` command-line flag. Decisions to
// mark a plugin as disabled by setting |plugin_policy| to
// PLUGIN_POLICY_DISABLED may be cached when |top_origin_url| is NULL. To
// purge the plugin list cache and potentially trigger new calls to this
// function call cef_request_tContext::PurgePluginListCache.
///
int (CEF_CALLBACK *on_before_plugin_load)(
struct _cef_request_context_handler_t* self,
......
......@@ -157,6 +157,15 @@ class CefRequestContext : public virtual CefBase {
///
/*--cef()--*/
virtual bool ClearSchemeHandlerFactories() =0;
///
// Tells all renderer processes associated with this context to throw away
// their plugin list cache. If |reload_pages| is true they will also reload
// all pages with plugins. CefRequestContextHandler::OnBeforePluginLoad may
// be called to rebuild the plugin list cache.
///
/*--cef()--*/
virtual void PurgePluginListCache(bool reload_pages) =0;
};
#endif // CEF_INCLUDE_CEF_REQUEST_CONTEXT_H_
......@@ -61,17 +61,23 @@ class CefRequestContextHandler : public virtual CefBase {
virtual CefRefPtr<CefCookieManager> GetCookieManager() { return NULL; }
///
// Called on the browser process IO thread before a plugin instance is loaded.
// |mime_type| is the mime type of the plugin that will be loaded.
// Called on multiple browser process threads before a plugin instance is
// loaded. |mime_type| is the mime type of the plugin that will be loaded.
// |plugin_url| is the content URL that the plugin will load and may be empty.
// |top_origin_url| is the URL for the top-level frame that contains the
// plugin. |plugin_info| includes additional information about the plugin that
// will be loaded. |plugin_policy| is the recommended policy. Modify
// |plugin_policy| and return true to change the policy. Return false to use
// the recommended policy. The default plugin policy can be set at runtime
// using the `--plugin-policy=[allow|detect|block]` command-line flag.
// plugin when loading a specific plugin instance or empty when building the
// initial list of enabled plugins for 'navigator.plugins' JavaScript state.
// |plugin_info| includes additional information about the plugin that will be
// loaded. |plugin_policy| is the recommended policy. Modify |plugin_policy|
// and return true to change the policy. Return false to use the recommended
// policy. The default plugin policy can be set at runtime using the
// `--plugin-policy=[allow|detect|block]` command-line flag. Decisions to mark
// a plugin as disabled by setting |plugin_policy| to PLUGIN_POLICY_DISABLED
// may be cached when |top_origin_url| is empty. To purge the plugin list
// cache and potentially trigger new calls to this method call
// CefRequestContext::PurgePluginListCache.
///
/*--cef(optional_param=plugin_url)--*/
/*--cef(optional_param=plugin_url,optional_param=top_origin_url)--*/
virtual bool OnBeforePluginLoad(const CefString& mime_type,
const CefString& plugin_url,
const CefString& top_origin_url,
......
......@@ -52,7 +52,8 @@ void CefBrowserContext::Initialize() {
resource_context_.reset(new CefResourceContext(
IsOffTheRecord(),
extensions_enabled ? extension_system_->info_map() : NULL));
extensions_enabled ? extension_system_->info_map() : NULL,
GetHandler()));
BrowserContextDependencyManager::GetInstance()->CreateBrowserContextServices(
this);
......
......@@ -19,12 +19,12 @@
#include "libcef/browser/media_capture_devices_dispatcher.h"
#include "libcef/browser/pepper/browser_pepper_host_factory.h"
#include "libcef/browser/plugins/plugin_info_message_filter.h"
#include "libcef/browser/plugins/plugin_service_filter.h"
#include "libcef/browser/printing/printing_message_filter.h"
#include "libcef/browser/resource_dispatcher_host_delegate.h"
#include "libcef/browser/speech_recognition_manager_delegate.h"
#include "libcef/browser/ssl_info_impl.h"
#include "libcef/browser/thread_util.h"
#include "libcef/browser/web_plugin_impl.h"
#include "libcef/common/cef_messages.h"
#include "libcef/common/cef_switches.h"
#include "libcef/common/command_line_impl.h"
......@@ -38,6 +38,7 @@
#include "base/path_service.h"
#include "chrome/browser/spellchecker/spellcheck_message_filter.h"
#include "chrome/common/chrome_switches.h"
#include "content/browser/plugin_service_impl.h"
#include "content/public/browser/access_token_store.h"
#include "content/public/browser/browser_ppapi_host.h"
#include "content/public/browser/browser_url_handler.h"
......@@ -358,6 +359,10 @@ int GetCrashSignalFD(const base::CommandLine& command_line) {
CefContentBrowserClient::CefContentBrowserClient()
: browser_main_parts_(NULL),
next_browser_id_(0) {
plugin_service_filter_.reset(new CefPluginServiceFilter);
content::PluginServiceImpl::GetInstance()->SetFilter(
plugin_service_filter_.get());
last_create_window_params_.opener_process_id = MSG_ROUTING_NONE;
}
......
......@@ -32,6 +32,7 @@ class CefResourceDispatcherHostDelegate;
class PrefService;
namespace content {
class PluginServiceFilter;
class SiteInstance;
}
......@@ -173,6 +174,7 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
CefBrowserMainParts* browser_main_parts_;
scoped_ptr<content::PluginServiceFilter> plugin_service_filter_;
scoped_ptr<CefResourceDispatcherHostDelegate>
resource_dispatcher_host_delegate_;
......
......@@ -6,9 +6,9 @@
#include "libcef/browser/plugins/plugin_info_message_filter.h"
#include "libcef/browser/browser_context.h"
#include "libcef/browser/plugins/plugin_service_filter.h"
#include "libcef/browser/web_plugin_impl.h"
#include "libcef/common/cef_messages.h"
#include "libcef/common/content_client.h"
#include "base/bind.h"
#include "base/memory/scoped_ptr.h"
......@@ -243,83 +243,15 @@ void CefPluginInfoMessageFilter::PluginsLoaded(
IPC::Message* reply_msg,
const std::vector<WebPluginInfo>& plugins) {
CefViewHostMsg_GetPluginInfo_Output output;
// This also fills in |actual_mime_type|.
scoped_ptr<PluginMetadata> plugin_metadata;
if (context_.FindEnabledPlugin(params.render_frame_id, params.url,
params.top_origin_url, params.mime_type,
&output.status, &output.plugin,
&output.actual_mime_type,
&plugin_metadata)) {
context_.DecidePluginStatus(params, output.plugin, plugin_metadata.get(),
&output.status);
const bool is_found =
output.status != CefViewHostMsg_GetPluginInfo_Status::kNotFound &&
output.status != CefViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported;
const bool is_internal_pdf_plugin =
is_found &&
(output.plugin.path == CefString(CefContentClient::kPDFPluginPath));
if (is_internal_pdf_plugin &&
output.status != CefViewHostMsg_GetPluginInfo_Status::kAllowed) {
// Always allow the internal PDF plugin to load if it exists.
output.status = CefViewHostMsg_GetPluginInfo_Status::kAllowed;
}
// Give the handler an opportunity to modify the policy.
CefRefPtr<CefRequestContextHandler> handler =
CefRefPtr<CefRequestContextHandler> handler =
browser_context_->GetHandler();
if (handler.get() &&
is_found &&
!is_internal_pdf_plugin) {
cef_plugin_policy_t plugin_policy = PLUGIN_POLICY_DISABLE;
switch (output.status) {
case CefViewHostMsg_GetPluginInfo_Status::kAllowed:
plugin_policy = PLUGIN_POLICY_ALLOW;
break;
case CefViewHostMsg_GetPluginInfo_Status::kBlocked:
case CefViewHostMsg_GetPluginInfo_Status::kBlockedByPolicy:
case CefViewHostMsg_GetPluginInfo_Status::kOutdatedBlocked:
case CefViewHostMsg_GetPluginInfo_Status::kOutdatedDisallowed:
case CefViewHostMsg_GetPluginInfo_Status::kUnauthorized:
plugin_policy = PLUGIN_POLICY_BLOCK;
break;
case CefViewHostMsg_GetPluginInfo_Status::kDisabled:
plugin_policy = PLUGIN_POLICY_DISABLE;
break;
case CefViewHostMsg_GetPluginInfo_Status::kPlayImportantContent:
plugin_policy = PLUGIN_POLICY_DETECT_IMPORTANT;
break;
default:
NOTREACHED();
break;
}
CefRefPtr<CefWebPluginInfoImpl> pluginInfo(
new CefWebPluginInfoImpl(output.plugin));
if (handler->OnBeforePluginLoad(output.actual_mime_type,
params.url.spec(),
params.top_origin_url.spec(),
pluginInfo.get(),
&plugin_policy)) {
switch (plugin_policy) {
case PLUGIN_POLICY_ALLOW:
output.status = CefViewHostMsg_GetPluginInfo_Status::kAllowed;
break;
case PLUGIN_POLICY_DETECT_IMPORTANT:
output.status =
CefViewHostMsg_GetPluginInfo_Status::kPlayImportantContent;
break;
case PLUGIN_POLICY_BLOCK:
output.status = CefViewHostMsg_GetPluginInfo_Status::kBlocked;
break;
case PLUGIN_POLICY_DISABLE:
output.status = CefViewHostMsg_GetPluginInfo_Status::kDisabled;
break;
}
}
}
}
// This also fills in |actual_mime_type|.
scoped_ptr<PluginMetadata> plugin_metadata;
context_.FindEnabledPlugin(params, handler.get(),
&output.status, &output.plugin,
&output.actual_mime_type,
&plugin_metadata);
if (plugin_metadata) {
output.group_identifier = plugin_metadata->identifier();
......@@ -488,10 +420,8 @@ void CefPluginInfoMessageFilter::Context::DecidePluginStatus(
}
bool CefPluginInfoMessageFilter::Context::FindEnabledPlugin(
int render_frame_id,
const GURL& url,
const GURL& top_origin_url,
const std::string& mime_type,
const GetPluginInfo_Params& params,
CefRequestContextHandler* handler,
CefViewHostMsg_GetPluginInfo_Status* status,
WebPluginInfo* plugin,
std::string* actual_mime_type,
......@@ -502,7 +432,8 @@ bool CefPluginInfoMessageFilter::Context::FindEnabledPlugin(
std::vector<WebPluginInfo> matching_plugins;
std::vector<std::string> mime_types;
PluginService::GetInstance()->GetPluginInfoArray(
url, mime_type, allow_wildcard, &matching_plugins, &mime_types);
params.url, params.mime_type, allow_wildcard, &matching_plugins,
&mime_types);
if (matching_plugins.empty()) {
*status = CefViewHostMsg_GetPluginInfo_Status::kNotFound;
#if defined(OS_WIN) || defined(OS_MACOSX)
......@@ -511,39 +442,48 @@ bool CefPluginInfoMessageFilter::Context::FindEnabledPlugin(
// could be a not-yet-installed Pepper plugin. To avoid notifying on
// these types, bail early based on a blacklist of pepper mime types.
for (auto pepper_mime_type : kPepperPluginMimeTypes)
if (pepper_mime_type == mime_type)
if (pepper_mime_type == params.mime_type)
return false;
}
#endif
return false;
}
content::PluginServiceFilter* filter =
PluginService::GetInstance()->GetFilter();
CefPluginServiceFilter* filter = static_cast<CefPluginServiceFilter*>(
PluginService::GetInstance()->GetFilter());
DCHECK(filter);
CefViewHostMsg_GetPluginInfo_Status first_status = *status;
size_t i = 0;
for (; i < matching_plugins.size(); ++i) {
if (!filter || filter->IsPluginAvailable(render_process_id_,
render_frame_id,
resource_context_,
url,
top_origin_url,
&matching_plugins[i])) {
*plugin = matching_plugins[i];
*actual_mime_type = mime_types[i];
*plugin_metadata = PluginFinder::GetInstance()->GetPluginMetadata(*plugin);
DecidePluginStatus(params, *plugin, (*plugin_metadata).get(), status);
if (filter->IsPluginAvailable(handler,
params.url,
params.top_origin_url,
plugin,
status)) {
break;
}
if (i == 0)
first_status = *status;
}
// If we broke out of the loop, we have found an enabled plugin.
bool enabled = i < matching_plugins.size();
if (!enabled) {
// Otherwise, we only found disabled plugins, so we take the first one.
i = 0;
*status = CefViewHostMsg_GetPluginInfo_Status::kDisabled;
}
*plugin = matching_plugins[i];
*actual_mime_type = mime_types[i];
if (plugin_metadata)
// Otherwise, we only found disabled/not-found plugins, so we take the first
// one.
*plugin = matching_plugins[0];
*actual_mime_type = mime_types[0];
*plugin_metadata = PluginFinder::GetInstance()->GetPluginMetadata(*plugin);
*status = first_status;
}
return enabled;
}
......
......@@ -20,6 +20,7 @@
#include "content/public/browser/browser_message_filter.h"
class CefBrowserContext;
class CefRequestContextHandler;
struct CefViewHostMsg_GetPluginInfo_Output;
enum class CefViewHostMsg_GetPluginInfo_Status;
class GURL;
......@@ -50,10 +51,8 @@ class CefPluginInfoMessageFilter : public content::BrowserMessageFilter {
const content::WebPluginInfo& plugin,
const PluginMetadata* plugin_metadata,
CefViewHostMsg_GetPluginInfo_Status* status) const;
bool FindEnabledPlugin(int render_frame_id,
const GURL& url,
const GURL& top_origin_url,
const std::string& mime_type,
bool FindEnabledPlugin(const GetPluginInfo_Params& params,
CefRequestContextHandler* handler,
CefViewHostMsg_GetPluginInfo_Status* status,
content::WebPluginInfo* plugin,
std::string* actual_mime_type,
......
// Copyright (c) 2015 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that can
// be found in the LICENSE file.
#include "libcef/browser/plugins/plugin_service_filter.h"
#include "include/cef_request_context_handler.h"
#include "libcef/browser/browser_host_impl.h"
#include "libcef/browser/resource_context.h"
#include "libcef/browser/thread_util.h"
#include "libcef/browser/web_plugin_impl.h"
#include "libcef/common/cef_messages.h"
#include "libcef/common/content_client.h"
CefPluginServiceFilter::CefPluginServiceFilter() {
}
bool CefPluginServiceFilter::IsPluginAvailable(
int render_process_id,
int render_frame_id,
const void* context,
const GURL& url,
const GURL& policy_url,
content::WebPluginInfo* plugin) {
CefRefPtr<CefRequestContextHandler> handler =
reinterpret_cast<const CefResourceContext*>(context)->GetHandler();
CefViewHostMsg_GetPluginInfo_Status status =
CefViewHostMsg_GetPluginInfo_Status::kAllowed;
return IsPluginAvailable(handler.get(), url, policy_url, plugin, &status);
}
bool CefPluginServiceFilter::CanLoadPlugin(int render_process_id,
const base::FilePath& path) {
return true;
}
bool CefPluginServiceFilter::IsPluginAvailable(
CefRequestContextHandler* handler,
const GURL& url,
const GURL& policy_url,
content::WebPluginInfo* plugin,
CefViewHostMsg_GetPluginInfo_Status* status) {
if (*status == CefViewHostMsg_GetPluginInfo_Status::kNotFound ||
*status == CefViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported) {
// The plugin does not exist so no need to query the handler.
return false;
}
if (plugin->path == CefString(CefContentClient::kPDFPluginPath)) {
// Always allow the internal PDF plugin to load.
*status = CefViewHostMsg_GetPluginInfo_Status::kAllowed;
return true;
}
if (handler) {
CefRefPtr<CefWebPluginInfoImpl> pluginInfo(
new CefWebPluginInfoImpl(*plugin));
cef_plugin_policy_t plugin_policy = PLUGIN_POLICY_ALLOW;
switch (*status) {
case CefViewHostMsg_GetPluginInfo_Status::kAllowed:
plugin_policy = PLUGIN_POLICY_ALLOW;
break;
case CefViewHostMsg_GetPluginInfo_Status::kBlocked:
case CefViewHostMsg_GetPluginInfo_Status::kBlockedByPolicy:
case CefViewHostMsg_GetPluginInfo_Status::kOutdatedBlocked:
case CefViewHostMsg_GetPluginInfo_Status::kOutdatedDisallowed:
case CefViewHostMsg_GetPluginInfo_Status::kUnauthorized:
plugin_policy = PLUGIN_POLICY_BLOCK;
break;
case CefViewHostMsg_GetPluginInfo_Status::kDisabled:
plugin_policy = PLUGIN_POLICY_DISABLE;
break;
case CefViewHostMsg_GetPluginInfo_Status::kPlayImportantContent:
plugin_policy = PLUGIN_POLICY_DETECT_IMPORTANT;
break;
default:
NOTREACHED();
break;
}
if (handler->OnBeforePluginLoad(plugin->mime_types[0].mime_type,
url.possibly_invalid_spec(),
policy_url.possibly_invalid_spec(),
pluginInfo.get(),
&plugin_policy)) {
switch (plugin_policy) {
case PLUGIN_POLICY_ALLOW:
*status = CefViewHostMsg_GetPluginInfo_Status::kAllowed;
break;
case PLUGIN_POLICY_DETECT_IMPORTANT:
*status = CefViewHostMsg_GetPluginInfo_Status::kPlayImportantContent;
break;
case PLUGIN_POLICY_BLOCK:
*status = CefViewHostMsg_GetPluginInfo_Status::kBlocked;
break;
case PLUGIN_POLICY_DISABLE:
*status = CefViewHostMsg_GetPluginInfo_Status::kDisabled;
break;
}
}
}
return (*status != CefViewHostMsg_GetPluginInfo_Status::kDisabled);
}
// Copyright (c) 2015 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that can
// be found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_PLUGINS_PLUGIN_SERVICE_FILTER_H_
#define CEF_LIBCEF_BROWSER_PLUGINS_PLUGIN_SERVICE_FILTER_H_
#include "content/public/browser/plugin_service_filter.h"
#include "include/internal/cef_types.h"
#include "base/macros.h"
class CefRequestContextHandler;
enum class CefViewHostMsg_GetPluginInfo_Status;
class CefPluginServiceFilter : public content::PluginServiceFilter {
public:
CefPluginServiceFilter();
// Called whenever the plugin list is queried. For example, when choosing the
// plugin to handle a mime type or when determining the plugins that will be
// exposed to JavaScript via 'navigator.plugins'.
bool IsPluginAvailable(int render_process_id,
int render_frame_id,
const void* context,
const GURL& url,
const GURL& policy_url,
content::WebPluginInfo* plugin) override;
bool CanLoadPlugin(int render_process_id,
const base::FilePath& path) override;
// Returns false if the plugin is not found or disabled. May call
// CefRequestContextHandler::OnBeforePluginLoad if possible/necessary.
bool IsPluginAvailable(CefRequestContextHandler* handler,
const GURL& url,
const GURL& policy_url,
content::WebPluginInfo* plugin,
CefViewHostMsg_GetPluginInfo_Status* status);
private:
DISALLOW_COPY_AND_ASSIGN(CefPluginServiceFilter);
};
#endif // CEF_LIBCEF_BROWSER_PLUGINS_PLUGIN_SERVICE_FILTER_H_
......@@ -9,8 +9,10 @@
#include "libcef/browser/context.h"
#include "libcef/browser/cookie_manager_impl.h"
#include "libcef/browser/thread_util.h"
#include "base/atomic_sequence_num.h"
#include "base/logging.h"
#include "content/public/browser/plugin_service.h"
using content::BrowserThread;
......@@ -283,6 +285,13 @@ bool CefRequestContextImpl::ClearSchemeHandlerFactories() {
return true;
}
void CefRequestContextImpl::PurgePluginListCache(bool reload_pages) {
GetBrowserContext(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
base::Bind(&CefRequestContextImpl::PurgePluginListCacheInternal,
this, reload_pages));
}
CefRequestContextImpl::CefRequestContextImpl(
scoped_refptr<CefBrowserContext> browser_context)
: browser_context_(browser_context),
......@@ -375,3 +384,11 @@ void CefRequestContextImpl::ClearSchemeHandlerFactoriesInternal(
CEF_REQUIRE_IOT();
request_context->request_manager()->ClearFactories();
}
void CefRequestContextImpl::PurgePluginListCacheInternal(
bool reload_pages,
scoped_refptr<CefBrowserContext> browser_context) {
CEF_REQUIRE_UIT();
content::PluginService::GetInstance()->PurgePluginListCache(
browser_context.get(), false);
}
......@@ -60,6 +60,7 @@ class CefRequestContextImpl : public CefRequestContext {
const CefString& domain_name,
CefRefPtr<CefSchemeHandlerFactory> factory) override;
bool ClearSchemeHandlerFactories() override;
void PurgePluginListCache(bool reload_pages) override;
const CefRequestContextSettings& settings() const { return settings_; }
......@@ -85,9 +86,12 @@ class CefRequestContextImpl : public CefRequestContext {
const CefString& scheme_name,
const CefString& domain_name,
CefRefPtr<CefSchemeHandlerFactory> factory,
scoped_refptr<CefURLRequestContextGetterImpl> request_context);
scoped_refptr<CefURLRequestContextGetterImpl> request_context);
void ClearSchemeHandlerFactoriesInternal(
scoped_refptr<CefURLRequestContextGetterImpl> request_context);
scoped_refptr<CefURLRequestContextGetterImpl> request_context);
void PurgePluginListCacheInternal(
bool reload_pages,
scoped_refptr<CefBrowserContext> browser_context);
scoped_refptr<CefBrowserContext> browser_context_;
CefRequestContextSettings settings_;
......
......@@ -22,9 +22,11 @@
CefResourceContext::CefResourceContext(
bool is_off_the_record,
extensions::InfoMap* extension_info_map)
extensions::InfoMap* extension_info_map,
CefRefPtr<CefRequestContextHandler> handler)
: is_off_the_record_(is_off_the_record),
extension_info_map_(extension_info_map) {
extension_info_map_(extension_info_map),
handler_(handler) {
}
CefResourceContext::~CefResourceContext() {
......
......@@ -6,6 +6,8 @@
#define CEF_LIBCEF_BROWSER_RESOURCE_CONTEXT_H_
#pragma once
#include "include/cef_request_context_handler.h"
#include "content/public/browser/resource_context.h"
#include "extensions/browser/info_map.h"
......@@ -22,7 +24,8 @@ class CefURLRequestContextGetter;
class CefResourceContext : public content::ResourceContext {
public:
CefResourceContext(bool is_off_the_record,
extensions::InfoMap* extension_info_map);
extensions::InfoMap* extension_info_map,
CefRefPtr<CefRequestContextHandler> handler);
~CefResourceContext() override;
// ResourceContext implementation.
......@@ -38,12 +41,14 @@ class CefResourceContext : public content::ResourceContext {
const extensions::InfoMap* GetExtensionInfoMap() const {
return extension_info_map_.get();
}
CefRefPtr<CefRequestContextHandler> GetHandler() const { return handler_; }
private:
scoped_refptr<CefURLRequestContextGetter> getter_;
bool is_off_the_record_;
scoped_refptr<extensions::InfoMap> extension_info_map_;
CefRefPtr<CefRequestContextHandler> handler_;
DISALLOW_COPY_AND_ASSIGN(CefResourceContext);
};
......
......@@ -226,6 +226,19 @@ int CEF_CALLBACK request_context_clear_scheme_handler_factories(
return _retval;
}
void CEF_CALLBACK request_context_purge_plugin_list_cache(
struct _cef_request_context_t* self, int reload_pages) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Execute
CefRequestContextCppToC::Get(self)->PurgePluginListCache(
reload_pages?true:false);
}
} // namespace
......@@ -243,6 +256,8 @@ CefRequestContextCppToC::CefRequestContextCppToC() {
request_context_register_scheme_handler_factory;
GetStruct()->clear_scheme_handler_factories =
request_context_clear_scheme_handler_factories;
GetStruct()->purge_plugin_list_cache =
request_context_purge_plugin_list_cache;
}
template<> CefRefPtr<CefRequestContext> CefCppToC<CefRequestContextCppToC,
......
......@@ -49,10 +49,6 @@ int CEF_CALLBACK request_context_handler_on_before_plugin_load(
DCHECK(mime_type);
if (!mime_type)
return 0;
// Verify param: top_origin_url; type: string_byref_const
DCHECK(top_origin_url);