mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
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:
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
|
||||
// Copyright (c) 2012 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.
|
||||
//
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "libcef_dll/ctocpp/life_span_handler_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/load_handler_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/menu_handler_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/permission_handler_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/print_handler_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/render_handler_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/request_handler_ctocpp.h"
|
||||
@@ -126,6 +127,20 @@ CefRefPtr<CefMenuHandler> CefClientCToCpp::GetMenuHandler()
|
||||
return CefMenuHandlerCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
CefRefPtr<CefPermissionHandler> CefClientCToCpp::GetPermissionHandler()
|
||||
{
|
||||
if (CEF_MEMBER_MISSING(struct_, get_permission_handler))
|
||||
return NULL;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_permission_handler_t* _retval = struct_->get_permission_handler(struct_);
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefPermissionHandlerCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
CefRefPtr<CefPrintHandler> CefClientCToCpp::GetPrintHandler()
|
||||
{
|
||||
if (CEF_MEMBER_MISSING(struct_, get_print_handler))
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
|
||||
// Copyright (c) 2012 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.
|
||||
//
|
||||
@@ -39,6 +39,7 @@ public:
|
||||
virtual CefRefPtr<CefFocusHandler> GetFocusHandler() OVERRIDE;
|
||||
virtual CefRefPtr<CefKeyboardHandler> GetKeyboardHandler() OVERRIDE;
|
||||
virtual CefRefPtr<CefMenuHandler> GetMenuHandler() OVERRIDE;
|
||||
virtual CefRefPtr<CefPermissionHandler> GetPermissionHandler() OVERRIDE;
|
||||
virtual CefRefPtr<CefPrintHandler> GetPrintHandler() OVERRIDE;
|
||||
virtual CefRefPtr<CefFindHandler> GetFindHandler() OVERRIDE;
|
||||
virtual CefRefPtr<CefJSDialogHandler> GetJSDialogHandler() OVERRIDE;
|
||||
|
57
libcef_dll/ctocpp/permission_handler_ctocpp.cc
Normal file
57
libcef_dll/ctocpp/permission_handler_ctocpp.cc
Normal file
@@ -0,0 +1,57 @@
|
||||
// Copyright (c) 2012 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.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/browser_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/frame_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/permission_handler_ctocpp.h"
|
||||
|
||||
|
||||
// VIRTUAL METHODS - Body may be edited by hand.
|
||||
|
||||
bool CefPermissionHandlerCToCpp::OnBeforeScriptExtensionLoad(
|
||||
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
||||
const CefString& extensionName)
|
||||
{
|
||||
if (CEF_MEMBER_MISSING(struct_, on_before_script_extension_load))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: browser; type: refptr_diff
|
||||
DCHECK(browser.get());
|
||||
if (!browser.get())
|
||||
return false;
|
||||
// Verify param: frame; type: refptr_diff
|
||||
DCHECK(frame.get());
|
||||
if (!frame.get())
|
||||
return false;
|
||||
// Verify param: extensionName; type: string_byref_const
|
||||
DCHECK(!extensionName.empty());
|
||||
if (extensionName.empty())
|
||||
return false;
|
||||
|
||||
// Execute
|
||||
int _retval = struct_->on_before_script_extension_load(struct_,
|
||||
CefBrowserCppToC::Wrap(browser),
|
||||
CefFrameCppToC::Wrap(frame),
|
||||
extensionName.GetStruct());
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
}
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> long CefCToCpp<CefPermissionHandlerCToCpp, CefPermissionHandler,
|
||||
cef_permission_handler_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
47
libcef_dll/ctocpp/permission_handler_ctocpp.h
Normal file
47
libcef_dll/ctocpp/permission_handler_ctocpp.h
Normal file
@@ -0,0 +1,47 @@
|
||||
// Copyright (c) 2012 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.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#ifndef _PERMISSIONHANDLER_CTOCPP_H
|
||||
#define _PERMISSIONHANDLER_CTOCPP_H
|
||||
|
||||
#ifndef BUILDING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
|
||||
#else // BUILDING_CEF_SHARED
|
||||
|
||||
#include "include/cef_permission_handler.h"
|
||||
#include "include/capi/cef_permission_handler_capi.h"
|
||||
#include "include/cef_browser.h"
|
||||
#include "include/capi/cef_browser_capi.h"
|
||||
#include "include/cef_frame.h"
|
||||
#include "include/capi/cef_frame_capi.h"
|
||||
#include "libcef_dll/ctocpp/ctocpp.h"
|
||||
|
||||
// Wrap a C structure with a C++ class.
|
||||
// This class may be instantiated and accessed DLL-side only.
|
||||
class CefPermissionHandlerCToCpp
|
||||
: public CefCToCpp<CefPermissionHandlerCToCpp, CefPermissionHandler,
|
||||
cef_permission_handler_t>
|
||||
{
|
||||
public:
|
||||
CefPermissionHandlerCToCpp(cef_permission_handler_t* str)
|
||||
: CefCToCpp<CefPermissionHandlerCToCpp, CefPermissionHandler,
|
||||
cef_permission_handler_t>(str) {}
|
||||
virtual ~CefPermissionHandlerCToCpp() {}
|
||||
|
||||
// CefPermissionHandler methods
|
||||
virtual bool OnBeforeScriptExtensionLoad(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame, const CefString& extensionName) OVERRIDE;
|
||||
};
|
||||
|
||||
#endif // BUILDING_CEF_SHARED
|
||||
#endif // _PERMISSIONHANDLER_CTOCPP_H
|
||||
|
Reference in New Issue
Block a user