Add the ability to restrict V8 extension loading by frame using a new CefPermissionHandler::OnBeforeScriptExtensionLoad() callback (issue #471).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@457 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2012-01-05 19:34:20 +00:00
parent ad65bb8532
commit b8ba27a671
23 changed files with 572 additions and 22 deletions

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2011 Marshall A. Greenblatt. All rights reserved.
// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -96,6 +96,12 @@ typedef struct _cef_client_t
struct _cef_menu_handler_t* (CEF_CALLBACK *get_menu_handler)(
struct _cef_client_t* self);
///
// Return the handler for browser permission events.
///
struct _cef_permission_handler_t* (CEF_CALLBACK *get_permission_handler)(
struct _cef_client_t* self);
///
// Return the handler for printing events.
///

View File

@@ -0,0 +1,73 @@
// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#ifndef _CEF_PERMISSION_HANDLER_CAPI_H
#define _CEF_PERMISSION_HANDLER_CAPI_H
#ifdef __cplusplus
extern "C" {
#endif
#include "cef_base_capi.h"
///
// Implement this structure to handle events related to browser permissions. The
// functions of this structure will be called on the UI thread.
///
typedef struct _cef_permission_handler_t
{
///
// Base structure.
///
cef_base_t base;
///
// Called on the UI thread before a script extension is loaded. Return false
// (0) to prevent the extension from loading.
///
int (CEF_CALLBACK *on_before_script_extension_load)(
struct _cef_permission_handler_t* self, struct _cef_browser_t* browser,
struct _cef_frame_t* frame, const cef_string_t* extensionName);
} cef_permission_handler_t;
#ifdef __cplusplus
}
#endif
#endif // _CEF_PERMISSION_HANDLER_CAPI_H

View File

@@ -47,6 +47,7 @@
#include "cef_life_span_handler.h"
#include "cef_load_handler.h"
#include "cef_menu_handler.h"
#include "cef_permission_handler.h"
#include "cef_print_handler.h"
#include "cef_render_handler.h"
#include "cef_request_handler.h"
@@ -63,79 +64,127 @@ public:
// Return the handler for browser life span events.
///
/*--cef()--*/
virtual CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() { return NULL; }
virtual CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler()
{
return NULL;
}
///
// Return the handler for browser load status events.
///
/*--cef()--*/
virtual CefRefPtr<CefLoadHandler> GetLoadHandler() { return NULL; }
virtual CefRefPtr<CefLoadHandler> GetLoadHandler()
{
return NULL;
}
///
// Return the handler for browser request events.
///
/*--cef()--*/
virtual CefRefPtr<CefRequestHandler> GetRequestHandler() { return NULL; }
virtual CefRefPtr<CefRequestHandler> GetRequestHandler()
{
return NULL;
}
///
// Return the handler for browser display state events.
///
/*--cef()--*/
virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() { return NULL; }
virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler()
{
return NULL;
}
///
// Return the handler for focus events.
///
/*--cef()--*/
virtual CefRefPtr<CefFocusHandler> GetFocusHandler() { return NULL; }
virtual CefRefPtr<CefFocusHandler> GetFocusHandler()
{
return NULL;
}
///
// Return the handler for keyboard events.
///
/*--cef()--*/
virtual CefRefPtr<CefKeyboardHandler> GetKeyboardHandler() { return NULL; }
virtual CefRefPtr<CefKeyboardHandler> GetKeyboardHandler()
{
return NULL;
}
///
// Return the handler for context menu events.
///
/*--cef()--*/
virtual CefRefPtr<CefMenuHandler> GetMenuHandler() { return NULL; }
virtual CefRefPtr<CefMenuHandler> GetMenuHandler()
{
return NULL;
}
///
// Return the handler for browser permission events.
///
/*--cef()--*/
virtual CefRefPtr<CefPermissionHandler> GetPermissionHandler()
{
return NULL;
}
///
// Return the handler for printing events.
///
/*--cef()--*/
virtual CefRefPtr<CefPrintHandler> GetPrintHandler() { return NULL; }
virtual CefRefPtr<CefPrintHandler> GetPrintHandler()
{
return NULL;
}
///
// Return the handler for find result events.
///
/*--cef()--*/
virtual CefRefPtr<CefFindHandler> GetFindHandler() { return NULL; }
virtual CefRefPtr<CefFindHandler> GetFindHandler()
{
return NULL;
}
///
// Return the handler for JavaScript dialog events.
///
/*--cef()--*/
virtual CefRefPtr<CefJSDialogHandler> GetJSDialogHandler() { return NULL; }
virtual CefRefPtr<CefJSDialogHandler> GetJSDialogHandler()
{
return NULL;
}
///
// Return the handler for V8 context events.
///
/*--cef()--*/
virtual CefRefPtr<CefV8ContextHandler> GetV8ContextHandler() { return NULL; }
virtual CefRefPtr<CefV8ContextHandler> GetV8ContextHandler()
{
return NULL;
}
///
// Return the handler for off-screen rendering events.
///
/*--cef()--*/
virtual CefRefPtr<CefRenderHandler> GetRenderHandler() { return NULL; }
virtual CefRefPtr<CefRenderHandler> GetRenderHandler()
{
return NULL;
}
///
// Return the handler for drag events.
///
/*--cef()--*/
virtual CefRefPtr<CefDragHandler> GetDragHandler() { return NULL; }
virtual CefRefPtr<CefDragHandler> GetDragHandler()
{
return NULL;
}
};
#endif // _CEF_CLIENT_H

View File

@@ -0,0 +1,66 @@
// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// The contents of this file must follow a specific format in order to
// support the CEF translator tool. See the translator.README.txt file in the
// tools directory for more information.
//
#ifndef _CEF_PERMISSION_HANDLER_H
#define _CEF_PERMISSION_HANDLER_H
#include "cef_base.h"
class CefBrowser;
class CefFrame;
///
// Implement this interface to handle events related to browser permissions.
// The methods of this class will be called on the UI thread.
///
/*--cef(source=client)--*/
class CefPermissionHandler : public virtual CefBase
{
public:
///
// Called on the UI thread before a script extension is loaded.
// Return false to let the extension load normally.
///
/*--cef()--*/
virtual bool OnBeforeScriptExtensionLoad(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const CefString& extensionName)
{
return false;
}
};
#endif // _CEF_PERMISSION_HANDLER_H