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
|
# reserved. Use of this source code is governed by a BSD-style license that
|
||||||
# can be found in the LICENSE file.
|
# can be found in the LICENSE file.
|
||||||
#
|
#
|
||||||
@ -32,6 +32,7 @@
|
|||||||
'include/cef_load_handler.h',
|
'include/cef_load_handler.h',
|
||||||
'include/cef_menu_handler.h',
|
'include/cef_menu_handler.h',
|
||||||
'include/cef_origin_whitelist.h',
|
'include/cef_origin_whitelist.h',
|
||||||
|
'include/cef_permission_handler.h',
|
||||||
'include/cef_print_handler.h',
|
'include/cef_print_handler.h',
|
||||||
'include/cef_proxy_handler.h',
|
'include/cef_proxy_handler.h',
|
||||||
'include/cef_render_handler.h',
|
'include/cef_render_handler.h',
|
||||||
@ -70,6 +71,7 @@
|
|||||||
'include/capi/cef_load_handler_capi.h',
|
'include/capi/cef_load_handler_capi.h',
|
||||||
'include/capi/cef_menu_handler_capi.h',
|
'include/capi/cef_menu_handler_capi.h',
|
||||||
'include/capi/cef_origin_whitelist_capi.h',
|
'include/capi/cef_origin_whitelist_capi.h',
|
||||||
|
'include/capi/cef_permission_handler_capi.h',
|
||||||
'include/capi/cef_print_handler_capi.h',
|
'include/capi/cef_print_handler_capi.h',
|
||||||
'include/capi/cef_proxy_handler_capi.h',
|
'include/capi/cef_proxy_handler_capi.h',
|
||||||
'include/capi/cef_render_handler_capi.h',
|
'include/capi/cef_render_handler_capi.h',
|
||||||
@ -134,6 +136,8 @@
|
|||||||
'libcef_dll/ctocpp/load_handler_ctocpp.h',
|
'libcef_dll/ctocpp/load_handler_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/menu_handler_ctocpp.cc',
|
'libcef_dll/ctocpp/menu_handler_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/menu_handler_ctocpp.h',
|
'libcef_dll/ctocpp/menu_handler_ctocpp.h',
|
||||||
|
'libcef_dll/ctocpp/permission_handler_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/permission_handler_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/post_data_cpptoc.cc',
|
'libcef_dll/cpptoc/post_data_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/post_data_cpptoc.h',
|
'libcef_dll/cpptoc/post_data_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/post_data_element_cpptoc.cc',
|
'libcef_dll/cpptoc/post_data_element_cpptoc.cc',
|
||||||
@ -236,6 +240,8 @@
|
|||||||
'libcef_dll/cpptoc/load_handler_cpptoc.h',
|
'libcef_dll/cpptoc/load_handler_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/menu_handler_cpptoc.cc',
|
'libcef_dll/cpptoc/menu_handler_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/menu_handler_cpptoc.h',
|
'libcef_dll/cpptoc/menu_handler_cpptoc.h',
|
||||||
|
'libcef_dll/cpptoc/permission_handler_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/permission_handler_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/post_data_ctocpp.cc',
|
'libcef_dll/ctocpp/post_data_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/post_data_ctocpp.h',
|
'libcef_dll/ctocpp/post_data_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/post_data_element_ctocpp.cc',
|
'libcef_dll/ctocpp/post_data_element_ctocpp.cc',
|
||||||
|
@ -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
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// 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_menu_handler_t* (CEF_CALLBACK *get_menu_handler)(
|
||||||
struct _cef_client_t* self);
|
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.
|
// Return the handler for printing events.
|
||||||
///
|
///
|
||||||
|
73
include/capi/cef_permission_handler_capi.h
Normal file
73
include/capi/cef_permission_handler_capi.h
Normal 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
|
@ -47,6 +47,7 @@
|
|||||||
#include "cef_life_span_handler.h"
|
#include "cef_life_span_handler.h"
|
||||||
#include "cef_load_handler.h"
|
#include "cef_load_handler.h"
|
||||||
#include "cef_menu_handler.h"
|
#include "cef_menu_handler.h"
|
||||||
|
#include "cef_permission_handler.h"
|
||||||
#include "cef_print_handler.h"
|
#include "cef_print_handler.h"
|
||||||
#include "cef_render_handler.h"
|
#include "cef_render_handler.h"
|
||||||
#include "cef_request_handler.h"
|
#include "cef_request_handler.h"
|
||||||
@ -63,79 +64,127 @@ public:
|
|||||||
// Return the handler for browser life span events.
|
// Return the handler for browser life span events.
|
||||||
///
|
///
|
||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
virtual CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() { return NULL; }
|
virtual CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler()
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for browser load status events.
|
// Return the handler for browser load status events.
|
||||||
///
|
///
|
||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
virtual CefRefPtr<CefLoadHandler> GetLoadHandler() { return NULL; }
|
virtual CefRefPtr<CefLoadHandler> GetLoadHandler()
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for browser request events.
|
// Return the handler for browser request events.
|
||||||
///
|
///
|
||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
virtual CefRefPtr<CefRequestHandler> GetRequestHandler() { return NULL; }
|
virtual CefRefPtr<CefRequestHandler> GetRequestHandler()
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for browser display state events.
|
// Return the handler for browser display state events.
|
||||||
///
|
///
|
||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() { return NULL; }
|
virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler()
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for focus events.
|
// Return the handler for focus events.
|
||||||
///
|
///
|
||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
virtual CefRefPtr<CefFocusHandler> GetFocusHandler() { return NULL; }
|
virtual CefRefPtr<CefFocusHandler> GetFocusHandler()
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for keyboard events.
|
// Return the handler for keyboard events.
|
||||||
///
|
///
|
||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
virtual CefRefPtr<CefKeyboardHandler> GetKeyboardHandler() { return NULL; }
|
virtual CefRefPtr<CefKeyboardHandler> GetKeyboardHandler()
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for context menu events.
|
// Return the handler for context menu events.
|
||||||
///
|
///
|
||||||
/*--cef()--*/
|
/*--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.
|
// Return the handler for printing events.
|
||||||
///
|
///
|
||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
virtual CefRefPtr<CefPrintHandler> GetPrintHandler() { return NULL; }
|
virtual CefRefPtr<CefPrintHandler> GetPrintHandler()
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for find result events.
|
// Return the handler for find result events.
|
||||||
///
|
///
|
||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
virtual CefRefPtr<CefFindHandler> GetFindHandler() { return NULL; }
|
virtual CefRefPtr<CefFindHandler> GetFindHandler()
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for JavaScript dialog events.
|
// Return the handler for JavaScript dialog events.
|
||||||
///
|
///
|
||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
virtual CefRefPtr<CefJSDialogHandler> GetJSDialogHandler() { return NULL; }
|
virtual CefRefPtr<CefJSDialogHandler> GetJSDialogHandler()
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for V8 context events.
|
// Return the handler for V8 context events.
|
||||||
///
|
///
|
||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
virtual CefRefPtr<CefV8ContextHandler> GetV8ContextHandler() { return NULL; }
|
virtual CefRefPtr<CefV8ContextHandler> GetV8ContextHandler()
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for off-screen rendering events.
|
// Return the handler for off-screen rendering events.
|
||||||
///
|
///
|
||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
virtual CefRefPtr<CefRenderHandler> GetRenderHandler() { return NULL; }
|
virtual CefRefPtr<CefRenderHandler> GetRenderHandler()
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for drag events.
|
// Return the handler for drag events.
|
||||||
///
|
///
|
||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
virtual CefRefPtr<CefDragHandler> GetDragHandler() { return NULL; }
|
virtual CefRefPtr<CefDragHandler> GetDragHandler()
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _CEF_CLIENT_H
|
#endif // _CEF_CLIENT_H
|
||||||
|
66
include/cef_permission_handler.h
Normal file
66
include/cef_permission_handler.h
Normal 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
|
@ -475,6 +475,25 @@ int BrowserWebViewDelegate::historyForwardListCount() {
|
|||||||
- current_index - 1;
|
- current_index - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WebPermissionClient -------------------------------------------------------
|
||||||
|
|
||||||
|
bool BrowserWebViewDelegate::allowScriptExtension(
|
||||||
|
WebKit::WebFrame* frame,
|
||||||
|
const WebKit::WebString& extensionName,
|
||||||
|
int extensionGroup) {
|
||||||
|
bool allowExtension = true;
|
||||||
|
CefRefPtr<CefClient> client = browser_->GetClient();
|
||||||
|
if (client.get()) {
|
||||||
|
CefRefPtr<CefPermissionHandler> handler = client->GetPermissionHandler();
|
||||||
|
if (handler.get()) {
|
||||||
|
CefString extensionNameStr = string16(extensionName);
|
||||||
|
allowExtension = !handler->OnBeforeScriptExtensionLoad(
|
||||||
|
browser_, browser_->UIT_GetCefFrame(frame), extensionNameStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return allowExtension;
|
||||||
|
}
|
||||||
|
|
||||||
// WebPluginPageDelegate -----------------------------------------------------
|
// WebPluginPageDelegate -----------------------------------------------------
|
||||||
|
|
||||||
WebCookieJar* BrowserWebViewDelegate::GetCookieJar() {
|
WebCookieJar* BrowserWebViewDelegate::GetCookieJar() {
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams.h"
|
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams.h"
|
||||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFileSystem.h"
|
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFileSystem.h"
|
||||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h"
|
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h"
|
||||||
|
#include "third_party/WebKit/Source/WebKit/chromium/public/WebPermissionClient.h"
|
||||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h"
|
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h"
|
||||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebViewClient.h"
|
#include "third_party/WebKit/Source/WebKit/chromium/public/WebViewClient.h"
|
||||||
#include "webkit/glue/webcursor.h"
|
#include "webkit/glue/webcursor.h"
|
||||||
@ -48,6 +49,7 @@ class FilePath;
|
|||||||
|
|
||||||
class BrowserWebViewDelegate : public WebKit::WebViewClient,
|
class BrowserWebViewDelegate : public WebKit::WebViewClient,
|
||||||
public WebKit::WebFrameClient,
|
public WebKit::WebFrameClient,
|
||||||
|
public WebKit::WebPermissionClient,
|
||||||
public webkit::npapi::WebPluginPageDelegate,
|
public webkit::npapi::WebPluginPageDelegate,
|
||||||
public base::SupportsWeakPtr<BrowserWebViewDelegate> {
|
public base::SupportsWeakPtr<BrowserWebViewDelegate> {
|
||||||
public:
|
public:
|
||||||
@ -195,6 +197,12 @@ class BrowserWebViewDelegate : public WebKit::WebViewClient,
|
|||||||
bool create,
|
bool create,
|
||||||
WebKit::WebFileSystemCallbacks* callbacks) OVERRIDE;
|
WebKit::WebFileSystemCallbacks* callbacks) OVERRIDE;
|
||||||
|
|
||||||
|
// WebKit::WebPermissionClient
|
||||||
|
virtual bool allowScriptExtension(
|
||||||
|
WebKit::WebFrame*,
|
||||||
|
const WebKit::WebString& extensionName,
|
||||||
|
int extensionGroup) OVERRIDE;
|
||||||
|
|
||||||
// webkit_glue::WebPluginPageDelegate
|
// webkit_glue::WebPluginPageDelegate
|
||||||
virtual webkit::npapi::WebPluginDelegate* CreatePluginDelegate(
|
virtual webkit::npapi::WebPluginDelegate* CreatePluginDelegate(
|
||||||
const FilePath& file_path,
|
const FilePath& file_path,
|
||||||
|
@ -40,6 +40,7 @@ WebViewHost* WebViewHost::Create(GtkWidget* parent_view,
|
|||||||
host->webwidget_ = WebView::create(delegate);
|
host->webwidget_ = WebView::create(delegate);
|
||||||
#endif
|
#endif
|
||||||
host->webview()->setDevToolsAgentClient(dev_tools_client);
|
host->webview()->setDevToolsAgentClient(dev_tools_client);
|
||||||
|
host->webview()->setPermissionClient(delegate);
|
||||||
prefs.Apply(host->webview());
|
prefs.Apply(host->webview());
|
||||||
host->webview()->initializeMainFrame(delegate);
|
host->webview()->initializeMainFrame(delegate);
|
||||||
host->webwidget_->layout();
|
host->webwidget_->layout();
|
||||||
|
@ -46,6 +46,7 @@ WebViewHost* WebViewHost::Create(NSView* parent_view,
|
|||||||
host->webwidget_ = WebView::create(delegate);
|
host->webwidget_ = WebView::create(delegate);
|
||||||
#endif
|
#endif
|
||||||
host->webview()->setDevToolsAgentClient(dev_tools_client);
|
host->webview()->setDevToolsAgentClient(dev_tools_client);
|
||||||
|
host->webview()->setPermissionClient(delegate);
|
||||||
prefs.Apply(host->webview());
|
prefs.Apply(host->webview());
|
||||||
host->webview()->initializeMainFrame(delegate);
|
host->webview()->initializeMainFrame(delegate);
|
||||||
host->webwidget_->resize(WebSize(content_rect.size.width,
|
host->webwidget_->resize(WebSize(content_rect.size.width,
|
||||||
|
@ -60,6 +60,7 @@ WebViewHost* WebViewHost::Create(HWND parent_view,
|
|||||||
host->webwidget_ = WebView::create(delegate);
|
host->webwidget_ = WebView::create(delegate);
|
||||||
#endif
|
#endif
|
||||||
host->webview()->setDevToolsAgentClient(dev_tools_client);
|
host->webview()->setDevToolsAgentClient(dev_tools_client);
|
||||||
|
host->webview()->setPermissionClient(delegate);
|
||||||
prefs.Apply(host->webview());
|
prefs.Apply(host->webview());
|
||||||
host->webview()->initializeMainFrame(delegate);
|
host->webview()->initializeMainFrame(delegate);
|
||||||
|
|
||||||
|
@ -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
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
//
|
//
|
||||||
@ -20,6 +20,7 @@
|
|||||||
#include "libcef_dll/cpptoc/life_span_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/life_span_handler_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/load_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/load_handler_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/menu_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/menu_handler_cpptoc.h"
|
||||||
|
#include "libcef_dll/cpptoc/permission_handler_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/print_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/print_handler_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/render_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/render_handler_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/request_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/request_handler_cpptoc.h"
|
||||||
@ -147,6 +148,23 @@ struct _cef_menu_handler_t* CEF_CALLBACK client_get_menu_handler(
|
|||||||
return CefMenuHandlerCppToC::Wrap(_retval);
|
return CefMenuHandlerCppToC::Wrap(_retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct _cef_permission_handler_t* CEF_CALLBACK client_get_permission_handler(
|
||||||
|
struct _cef_client_t* self)
|
||||||
|
{
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefRefPtr<CefPermissionHandler> _retval = CefClientCppToC::Get(
|
||||||
|
self)->GetPermissionHandler();
|
||||||
|
|
||||||
|
// Return type: refptr_same
|
||||||
|
return CefPermissionHandlerCppToC::Wrap(_retval);
|
||||||
|
}
|
||||||
|
|
||||||
struct _cef_print_handler_t* CEF_CALLBACK client_get_print_handler(
|
struct _cef_print_handler_t* CEF_CALLBACK client_get_print_handler(
|
||||||
struct _cef_client_t* self)
|
struct _cef_client_t* self)
|
||||||
{
|
{
|
||||||
@ -262,6 +280,7 @@ CefClientCppToC::CefClientCppToC(CefClient* cls)
|
|||||||
struct_.struct_.get_focus_handler = client_get_focus_handler;
|
struct_.struct_.get_focus_handler = client_get_focus_handler;
|
||||||
struct_.struct_.get_keyboard_handler = client_get_keyboard_handler;
|
struct_.struct_.get_keyboard_handler = client_get_keyboard_handler;
|
||||||
struct_.struct_.get_menu_handler = client_get_menu_handler;
|
struct_.struct_.get_menu_handler = client_get_menu_handler;
|
||||||
|
struct_.struct_.get_permission_handler = client_get_permission_handler;
|
||||||
struct_.struct_.get_print_handler = client_get_print_handler;
|
struct_.struct_.get_print_handler = client_get_print_handler;
|
||||||
struct_.struct_.get_find_handler = client_get_find_handler;
|
struct_.struct_.get_find_handler = client_get_find_handler;
|
||||||
struct_.struct_.get_jsdialog_handler = client_get_jsdialog_handler;
|
struct_.struct_.get_jsdialog_handler = client_get_jsdialog_handler;
|
||||||
|
69
libcef_dll/cpptoc/permission_handler_cpptoc.cc
Normal file
69
libcef_dll/cpptoc/permission_handler_cpptoc.cc
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
// 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<CefPermissionHandlerCppToC, CefPermissionHandler,
|
||||||
|
cef_permission_handler_t>(cls)
|
||||||
|
{
|
||||||
|
struct_.struct_.on_before_script_extension_load =
|
||||||
|
permission_handler_on_before_script_extension_load;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
template<> long CefCppToC<CefPermissionHandlerCppToC, CefPermissionHandler,
|
||||||
|
cef_permission_handler_t>::DebugObjCt = 0;
|
||||||
|
#endif
|
||||||
|
|
41
libcef_dll/cpptoc/permission_handler_cpptoc.h
Normal file
41
libcef_dll/cpptoc/permission_handler_cpptoc.h
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
// 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_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/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<CefPermissionHandlerCppToC, CefPermissionHandler,
|
||||||
|
cef_permission_handler_t>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CefPermissionHandlerCppToC(CefPermissionHandler* cls);
|
||||||
|
virtual ~CefPermissionHandlerCppToC() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // USING_CEF_SHARED
|
||||||
|
#endif // _PERMISSIONHANDLER_CPPTOC_H
|
||||||
|
|
@ -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
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
//
|
//
|
||||||
@ -20,6 +20,7 @@
|
|||||||
#include "libcef_dll/ctocpp/life_span_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/life_span_handler_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/load_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/load_handler_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/menu_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/print_handler_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/render_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/render_handler_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/request_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/request_handler_ctocpp.h"
|
||||||
@ -126,6 +127,20 @@ CefRefPtr<CefMenuHandler> CefClientCToCpp::GetMenuHandler()
|
|||||||
return CefMenuHandlerCToCpp::Wrap(_retval);
|
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()
|
CefRefPtr<CefPrintHandler> CefClientCToCpp::GetPrintHandler()
|
||||||
{
|
{
|
||||||
if (CEF_MEMBER_MISSING(struct_, get_print_handler))
|
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
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
//
|
//
|
||||||
@ -39,6 +39,7 @@ public:
|
|||||||
virtual CefRefPtr<CefFocusHandler> GetFocusHandler() OVERRIDE;
|
virtual CefRefPtr<CefFocusHandler> GetFocusHandler() OVERRIDE;
|
||||||
virtual CefRefPtr<CefKeyboardHandler> GetKeyboardHandler() OVERRIDE;
|
virtual CefRefPtr<CefKeyboardHandler> GetKeyboardHandler() OVERRIDE;
|
||||||
virtual CefRefPtr<CefMenuHandler> GetMenuHandler() OVERRIDE;
|
virtual CefRefPtr<CefMenuHandler> GetMenuHandler() OVERRIDE;
|
||||||
|
virtual CefRefPtr<CefPermissionHandler> GetPermissionHandler() OVERRIDE;
|
||||||
virtual CefRefPtr<CefPrintHandler> GetPrintHandler() OVERRIDE;
|
virtual CefRefPtr<CefPrintHandler> GetPrintHandler() OVERRIDE;
|
||||||
virtual CefRefPtr<CefFindHandler> GetFindHandler() OVERRIDE;
|
virtual CefRefPtr<CefFindHandler> GetFindHandler() OVERRIDE;
|
||||||
virtual CefRefPtr<CefJSDialogHandler> GetJSDialogHandler() 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
|
||||||
|
|
@ -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
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
//
|
//
|
||||||
@ -60,6 +60,7 @@
|
|||||||
#include "libcef_dll/ctocpp/life_span_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/life_span_handler_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/load_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/load_handler_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/menu_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/print_handler_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/proxy_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/proxy_handler_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/read_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/read_handler_ctocpp.h"
|
||||||
@ -132,6 +133,7 @@ CEF_EXPORT void cef_shutdown()
|
|||||||
DCHECK(CefLifeSpanHandlerCToCpp::DebugObjCt == 0);
|
DCHECK(CefLifeSpanHandlerCToCpp::DebugObjCt == 0);
|
||||||
DCHECK(CefLoadHandlerCToCpp::DebugObjCt == 0);
|
DCHECK(CefLoadHandlerCToCpp::DebugObjCt == 0);
|
||||||
DCHECK(CefMenuHandlerCToCpp::DebugObjCt == 0);
|
DCHECK(CefMenuHandlerCToCpp::DebugObjCt == 0);
|
||||||
|
DCHECK(CefPermissionHandlerCToCpp::DebugObjCt == 0);
|
||||||
DCHECK(CefPostDataCppToC::DebugObjCt == 0);
|
DCHECK(CefPostDataCppToC::DebugObjCt == 0);
|
||||||
DCHECK(CefPostDataElementCppToC::DebugObjCt == 0);
|
DCHECK(CefPostDataElementCppToC::DebugObjCt == 0);
|
||||||
DCHECK(CefPrintHandlerCToCpp::DebugObjCt == 0);
|
DCHECK(CefPrintHandlerCToCpp::DebugObjCt == 0);
|
||||||
|
@ -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
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
//
|
//
|
||||||
@ -42,6 +42,7 @@
|
|||||||
#include "libcef_dll/cpptoc/life_span_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/life_span_handler_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/load_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/load_handler_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/menu_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/menu_handler_cpptoc.h"
|
||||||
|
#include "libcef_dll/cpptoc/permission_handler_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/print_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/print_handler_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/proxy_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/proxy_handler_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/read_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/read_handler_cpptoc.h"
|
||||||
@ -134,6 +135,7 @@ CEF_GLOBAL void CefShutdown()
|
|||||||
DCHECK(CefLifeSpanHandlerCppToC::DebugObjCt == 0);
|
DCHECK(CefLifeSpanHandlerCppToC::DebugObjCt == 0);
|
||||||
DCHECK(CefLoadHandlerCppToC::DebugObjCt == 0);
|
DCHECK(CefLoadHandlerCppToC::DebugObjCt == 0);
|
||||||
DCHECK(CefMenuHandlerCppToC::DebugObjCt == 0);
|
DCHECK(CefMenuHandlerCppToC::DebugObjCt == 0);
|
||||||
|
DCHECK(CefPermissionHandlerCppToC::DebugObjCt == 0);
|
||||||
DCHECK(CefPostDataCToCpp::DebugObjCt == 0);
|
DCHECK(CefPostDataCToCpp::DebugObjCt == 0);
|
||||||
DCHECK(CefPostDataElementCToCpp::DebugObjCt == 0);
|
DCHECK(CefPostDataElementCToCpp::DebugObjCt == 0);
|
||||||
DCHECK(CefPrintHandlerCppToC::DebugObjCt == 0);
|
DCHECK(CefPrintHandlerCppToC::DebugObjCt == 0);
|
||||||
|
@ -303,6 +303,13 @@ bool ClientHandler::OnDragEnter(CefRefPtr<CefBrowser> browser,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ClientHandler::OnBeforeScriptExtensionLoad(CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefFrame> frame,
|
||||||
|
const CefString& extensionName)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void ClientHandler::NotifyDownloadComplete(const CefString& fileName)
|
void ClientHandler::NotifyDownloadComplete(const CefString& fileName)
|
||||||
{
|
{
|
||||||
SetLastDownloadFile(fileName);
|
SetLastDownloadFile(fileName);
|
||||||
|
@ -26,6 +26,7 @@ class ClientHandler : public CefClient,
|
|||||||
public CefPrintHandler,
|
public CefPrintHandler,
|
||||||
public CefV8ContextHandler,
|
public CefV8ContextHandler,
|
||||||
public CefDragHandler,
|
public CefDragHandler,
|
||||||
|
public CefPermissionHandler,
|
||||||
public DownloadListener
|
public DownloadListener
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -51,6 +52,8 @@ public:
|
|||||||
{ return this; }
|
{ return this; }
|
||||||
virtual CefRefPtr<CefDragHandler> GetDragHandler() OVERRIDE
|
virtual CefRefPtr<CefDragHandler> GetDragHandler() OVERRIDE
|
||||||
{ return this; }
|
{ return this; }
|
||||||
|
virtual CefRefPtr<CefPermissionHandler> GetPermissionHandler() OVERRIDE
|
||||||
|
{ return this; }
|
||||||
|
|
||||||
// CefLifeSpanHandler methods
|
// CefLifeSpanHandler methods
|
||||||
virtual bool OnBeforePopup(CefRefPtr<CefBrowser> parentBrowser,
|
virtual bool OnBeforePopup(CefRefPtr<CefBrowser> parentBrowser,
|
||||||
@ -144,6 +147,11 @@ public:
|
|||||||
CefRefPtr<CefDragData> dragData,
|
CefRefPtr<CefDragData> dragData,
|
||||||
DragOperationsMask mask) OVERRIDE;
|
DragOperationsMask mask) OVERRIDE;
|
||||||
|
|
||||||
|
// CefPermissionHandler methods.
|
||||||
|
virtual bool OnBeforeScriptExtensionLoad(CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefFrame> frame,
|
||||||
|
const CefString& extensionName) OVERRIDE;
|
||||||
|
|
||||||
// DownloadListener methods
|
// DownloadListener methods
|
||||||
virtual void NotifyDownloadComplete(const CefString& fileName) OVERRIDE;
|
virtual void NotifyDownloadComplete(const CefString& fileName) OVERRIDE;
|
||||||
virtual void NotifyDownloadError(const CefString& fileName) OVERRIDE;
|
virtual void NotifyDownloadError(const CefString& fileName) OVERRIDE;
|
||||||
|
@ -31,7 +31,8 @@ class TestHandler : public CefClient,
|
|||||||
public CefLifeSpanHandler,
|
public CefLifeSpanHandler,
|
||||||
public CefLoadHandler,
|
public CefLoadHandler,
|
||||||
public CefRequestHandler,
|
public CefRequestHandler,
|
||||||
public CefV8ContextHandler
|
public CefV8ContextHandler,
|
||||||
|
public CefPermissionHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TestHandler();
|
TestHandler();
|
||||||
@ -51,6 +52,8 @@ public:
|
|||||||
{ return this; }
|
{ return this; }
|
||||||
virtual CefRefPtr<CefV8ContextHandler> GetV8ContextHandler() OVERRIDE
|
virtual CefRefPtr<CefV8ContextHandler> GetV8ContextHandler() OVERRIDE
|
||||||
{ return this; }
|
{ return this; }
|
||||||
|
virtual CefRefPtr<CefPermissionHandler> GetPermissionHandler() OVERRIDE
|
||||||
|
{ return this; }
|
||||||
|
|
||||||
// CefLifeSpanHandler methods
|
// CefLifeSpanHandler methods
|
||||||
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
||||||
|
@ -1748,3 +1748,52 @@ TEST(V8Test, Exception)
|
|||||||
EXPECT_TRUE(handler->got_exception_[i]) << "test = " << i+1;
|
EXPECT_TRUE(handler->got_exception_[i]) << "test = " << i+1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
class TestPermissionsHandler : public V8TestHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TestPermissionsHandler(bool denyExtensions) : V8TestHandler(false) {
|
||||||
|
deny_extensions_ = denyExtensions;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool OnBeforeScriptExtensionLoad(CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefFrame> frame,
|
||||||
|
const CefString& extensionName)
|
||||||
|
{
|
||||||
|
return deny_extensions_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool deny_extensions_;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Verify extension permissions
|
||||||
|
TEST(V8Test, Permissions)
|
||||||
|
{
|
||||||
|
g_V8TestV8HandlerExecuteCalled = false;
|
||||||
|
|
||||||
|
std::string extensionCode =
|
||||||
|
"var test;"
|
||||||
|
"if (!test)"
|
||||||
|
" test = {};"
|
||||||
|
"(function() {"
|
||||||
|
" test.execute = function(a,b,c,d,e,f,g,h,i) {"
|
||||||
|
" native function execute();"
|
||||||
|
" return execute(a,b,c,d,e,f,g,h,i);"
|
||||||
|
" };"
|
||||||
|
"})();";
|
||||||
|
CefRegisterExtension("v8/test", extensionCode, new V8TestV8Handler(false));
|
||||||
|
|
||||||
|
CefRefPtr<V8TestHandler> deny_handler = new TestPermissionsHandler(true);
|
||||||
|
deny_handler->ExecuteTest();
|
||||||
|
|
||||||
|
ASSERT_FALSE(g_V8TestV8HandlerExecuteCalled);
|
||||||
|
|
||||||
|
CefRefPtr<V8TestHandler> allow_handler = new TestPermissionsHandler(false);
|
||||||
|
allow_handler->ExecuteTest();
|
||||||
|
|
||||||
|
ASSERT_TRUE(g_V8TestV8HandlerExecuteCalled);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
Reference in New Issue
Block a user