From 9ba4603109898118ef62364317237070c2f23605 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Fri, 24 Feb 2012 17:33:50 +0000 Subject: [PATCH] Merge revision 457 changes: - 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/branches/963@519 5089003a-bbd8-11dd-ad1f-f1f9622dbc98 --- .../cpptoc/permission_handler_cpptoc.cc | 70 +++++++++++++++++++ libcef_dll/cpptoc/permission_handler_cpptoc.h | 37 ++++++++++ .../ctocpp/permission_handler_ctocpp.cc | 58 +++++++++++++++ libcef_dll/ctocpp/permission_handler_ctocpp.h | 43 ++++++++++++ 4 files changed, 208 insertions(+) create mode 100644 libcef_dll/cpptoc/permission_handler_cpptoc.cc create mode 100644 libcef_dll/cpptoc/permission_handler_cpptoc.h create mode 100644 libcef_dll/ctocpp/permission_handler_ctocpp.cc create mode 100644 libcef_dll/ctocpp/permission_handler_ctocpp.h diff --git a/libcef_dll/cpptoc/permission_handler_cpptoc.cc b/libcef_dll/cpptoc/permission_handler_cpptoc.cc new file mode 100644 index 000000000..3b6e37899 --- /dev/null +++ b/libcef_dll/cpptoc/permission_handler_cpptoc.cc @@ -0,0 +1,70 @@ +// 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/permission_handler_cpptoc.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" +#include "libcef_dll/ctocpp/frame_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK permission_handler_on_before_script_extension_load( + struct _cef_permission_handler_t* self, cef_browser_t* browser, + cef_frame_t* frame, const cef_string_t* extensionName) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: frame; type: refptr_diff + DCHECK(frame); + if (!frame) + return 0; + // Verify param: extensionName; type: string_byref_const + DCHECK(extensionName); + if (!extensionName) + return 0; + + // Execute + bool _retval = CefPermissionHandlerCppToC::Get( + self)->OnBeforeScriptExtensionLoad( + CefBrowserCToCpp::Wrap(browser), + CefFrameCToCpp::Wrap(frame), + CefString(extensionName)); + + // Return type: bool + return _retval; +} + + + +// CONSTRUCTOR - Do not edit by hand. + +CefPermissionHandlerCppToC::CefPermissionHandlerCppToC( + CefPermissionHandler* cls) + : CefCppToC(cls) +{ + struct_.struct_.on_before_script_extension_load = + permission_handler_on_before_script_extension_load; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/cpptoc/permission_handler_cpptoc.h b/libcef_dll/cpptoc/permission_handler_cpptoc.h new file mode 100644 index 000000000..520a30064 --- /dev/null +++ b/libcef_dll/cpptoc/permission_handler_cpptoc.h @@ -0,0 +1,37 @@ +// 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_CPPTOC_H +#define _PERMISSIONHANDLER_CPPTOC_H + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef.h" +#include "include/cef_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefPermissionHandlerCppToC + : public CefCppToC +{ +public: + CefPermissionHandlerCppToC(CefPermissionHandler* cls); + virtual ~CefPermissionHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // _PERMISSIONHANDLER_CPPTOC_H + diff --git a/libcef_dll/ctocpp/permission_handler_ctocpp.cc b/libcef_dll/ctocpp/permission_handler_ctocpp.cc new file mode 100644 index 000000000..3db27e7f8 --- /dev/null +++ b/libcef_dll/ctocpp/permission_handler_ctocpp.cc @@ -0,0 +1,58 @@ +// 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 browser, CefRefPtr 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::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/ctocpp/permission_handler_ctocpp.h b/libcef_dll/ctocpp/permission_handler_ctocpp.h new file mode 100644 index 000000000..ae6441678 --- /dev/null +++ b/libcef_dll/ctocpp/permission_handler_ctocpp.h @@ -0,0 +1,43 @@ +// 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.h" +#include "include/cef_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 +{ +public: + CefPermissionHandlerCToCpp(cef_permission_handler_t* str) + : CefCToCpp(str) {} + virtual ~CefPermissionHandlerCToCpp() {} + + // CefPermissionHandler methods + virtual bool OnBeforeScriptExtensionLoad(CefRefPtr browser, + CefRefPtr frame, const CefString& extensionName) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // _PERMISSIONHANDLER_CTOCPP_H +