Add new CefRequestHandler::OnBeforePluginLoad callback and functions for controlling plugin loading and life span (issue #645).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@822 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2012-09-28 20:14:02 +00:00
parent ccb2b296ac
commit a3ac7b446f
19 changed files with 888 additions and 43 deletions

View File

@@ -173,6 +173,14 @@ typedef struct _cef_request_handler_t {
void (CEF_CALLBACK *on_protocol_execution)(
struct _cef_request_handler_t* self, struct _cef_browser_t* browser,
const cef_string_t* url, int* allow_os_execution);
///
// Called on the browser process IO thread before a plugin is loaded. Return
// true (1) to block loading of the plugin.
///
int (CEF_CALLBACK *on_before_plugin_load)(struct _cef_request_handler_t* self,
struct _cef_browser_t* browser, const cef_string_t* url,
const cef_string_t* policy_url, struct _cef_web_plugin_info_t* info);
} cef_request_handler_t;

View File

@@ -46,11 +46,66 @@ extern "C" {
///
// Visit web plugin information.
// Visit web plugin information. Can be called on any thread in the browser
// process.
///
CEF_EXPORT void cef_visit_web_plugin_info(
struct _cef_web_plugin_info_visitor_t* visitor);
///
// Cause the plugin list to refresh the next time it is accessed regardless of
// whether it has already been loaded. Can be called on any thread in the
// browser process.
///
CEF_EXPORT void cef_refresh_web_plugins();
///
// Add a plugin path (directory + file). This change may not take affect until
// after cef_refresh_web_plugins() is called. Can be called on any thread in the
// browser process.
///
CEF_EXPORT void cef_add_web_plugin_path(const cef_string_t* path);
///
// Add a plugin directory. This change may not take affect until after
// cef_refresh_web_plugins() is called. Can be called on any thread in the
// browser process.
///
CEF_EXPORT void cef_add_web_plugin_directory(const cef_string_t* dir);
///
// Remove a plugin path (directory + file). This change may not take affect
// until after cef_refresh_web_plugins() is called. Can be called on any thread
// in the browser process.
///
CEF_EXPORT void cef_remove_web_plugin_path(const cef_string_t* path);
///
// Unregister an internal plugin. This may be undone the next time
// cef_refresh_web_plugins() is called. Can be called on any thread in the
// browser process.
///
CEF_EXPORT void cef_unregister_internal_web_plugin(const cef_string_t* path);
///
// Force a plugin to shutdown. Can be called on any thread in the browser
// process but will be executed on the IO thread.
///
CEF_EXPORT void cef_force_web_plugin_shutdown(const cef_string_t* path);
///
// Register a plugin crash. Can be called on any thread in the browser process
// but will be executed on the IO thread.
///
CEF_EXPORT void cef_register_web_plugin_crash(const cef_string_t* path);
///
// Query if a plugin is unstable. Can be called on any thread in the browser
// process.
///
CEF_EXPORT void cef_is_web_plugin_unstable(const cef_string_t* path,
struct _cef_web_plugin_unstable_callback_t* callback);
///
// Information about a specific web plugin.
///
@@ -92,7 +147,7 @@ typedef struct _cef_web_plugin_info_t {
///
// Structure to implement for visiting web plugin information. The functions of
// this structure will be called on the UI thread.
// this structure will be called on the browser process UI thread.
///
typedef struct _cef_web_plugin_info_visitor_t {
///
@@ -111,6 +166,27 @@ typedef struct _cef_web_plugin_info_visitor_t {
} cef_web_plugin_info_visitor_t;
///
// Structure to implement for receiving unstable plugin information. The
// functions of this structure will be called on the browser process IO thread.
///
typedef struct _cef_web_plugin_unstable_callback_t {
///
// Base structure.
///
cef_base_t base;
///
// Method that will be called for the requested plugin. |unstable| will be
// true (1) if the plugin has reached the crash count threshold of 3 times in
// 120 seconds.
///
void (CEF_CALLBACK *is_unstable)(
struct _cef_web_plugin_unstable_callback_t* self,
const cef_string_t* path, int unstable);
} cef_web_plugin_unstable_callback_t;
#ifdef __cplusplus
}
#endif

View File

@@ -45,6 +45,7 @@
#include "include/cef_resource_handler.h"
#include "include/cef_response.h"
#include "include/cef_request.h"
#include "include/cef_web_plugin.h"
///
// Callback interface used for asynchronous continuation of authentication
@@ -190,6 +191,18 @@ class CefRequestHandler : public virtual CefBase {
virtual void OnProtocolExecution(CefRefPtr<CefBrowser> browser,
const CefString& url,
bool& allow_os_execution) {}
///
// Called on the browser process IO thread before a plugin is loaded. Return
// true to block loading of the plugin.
///
/*--cef(optional_param=url,optional_param=policy_url)--*/
virtual bool OnBeforePluginLoad(CefRefPtr<CefBrowser> browser,
const CefString& url,
const CefString& policy_url,
CefRefPtr<CefWebPluginInfo> info) {
return false;
}
};
#endif // CEF_INCLUDE_CEF_REQUEST_HANDLER_H_

View File

@@ -38,16 +38,7 @@
#define CEF_INCLUDE_CEF_WEB_PLUGIN_H_
#include "include/cef_base.h"
class CefWebPluginInfoVisitor;
///
// Visit web plugin information.
///
/*--cef()--*/
void CefVisitWebPluginInfo(CefRefPtr<CefWebPluginInfoVisitor> visitor);
#include "include/cef_browser.h"
///
// Information about a specific web plugin.
@@ -80,10 +71,9 @@ class CefWebPluginInfo : public virtual CefBase {
virtual CefString GetDescription() =0;
};
///
// Interface to implement for visiting web plugin information. The methods of
// this class will be called on the UI thread.
// this class will be called on the browser process UI thread.
///
/*--cef(source=client)--*/
class CefWebPluginInfoVisitor : public virtual CefBase {
@@ -98,4 +88,91 @@ class CefWebPluginInfoVisitor : public virtual CefBase {
virtual bool Visit(CefRefPtr<CefWebPluginInfo> info, int count, int total) =0;
};
///
// Visit web plugin information. Can be called on any thread in the browser
// process.
///
/*--cef()--*/
void CefVisitWebPluginInfo(CefRefPtr<CefWebPluginInfoVisitor> visitor);
///
// Cause the plugin list to refresh the next time it is accessed regardless
// of whether it has already been loaded. Can be called on any thread in the
// browser process.
///
/*--cef()--*/
void CefRefreshWebPlugins();
///
// Add a plugin path (directory + file). This change may not take affect until
// after CefRefreshWebPlugins() is called. Can be called on any thread in the
// browser process.
///
/*--cef()--*/
void CefAddWebPluginPath(const CefString& path);
///
// Add a plugin directory. This change may not take affect until after
// CefRefreshWebPlugins() is called. Can be called on any thread in the browser
// process.
///
/*--cef()--*/
void CefAddWebPluginDirectory(const CefString& dir);
///
// Remove a plugin path (directory + file). This change may not take affect
// until after CefRefreshWebPlugins() is called. Can be called on any thread in
// the browser process.
///
/*--cef()--*/
void CefRemoveWebPluginPath(const CefString& path);
///
// Unregister an internal plugin. This may be undone the next time
// CefRefreshWebPlugins() is called. Can be called on any thread in the browser
// process.
///
/*--cef()--*/
void CefUnregisterInternalWebPlugin(const CefString& path);
///
// Force a plugin to shutdown. Can be called on any thread in the browser
// process but will be executed on the IO thread.
///
/*--cef()--*/
void CefForceWebPluginShutdown(const CefString& path);
///
// Register a plugin crash. Can be called on any thread in the browser process
// but will be executed on the IO thread.
///
/*--cef()--*/
void CefRegisterWebPluginCrash(const CefString& path);
///
// Interface to implement for receiving unstable plugin information. The methods
// of this class will be called on the browser process IO thread.
///
/*--cef(source=client)--*/
class CefWebPluginUnstableCallback : public virtual CefBase {
public:
///
// Method that will be called for the requested plugin. |unstable| will be
// true if the plugin has reached the crash count threshold of 3 times in 120
// seconds.
///
/*--cef()--*/
virtual void IsUnstable(const CefString& path,
bool unstable) =0;
};
///
// Query if a plugin is unstable. Can be called on any thread in the browser
// process.
///
/*--cef()--*/
void CefIsWebPluginUnstable(const CefString& path,
CefRefPtr<CefWebPluginUnstableCallback> callback);
#endif // CEF_INCLUDE_CEF_WEB_PLUGIN_H_