mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Add plugin placeholder and policy support (issue #1708)
- Default plugin loading policy can be specified using the new `--plugin-policy=[allow|block|detect]` command-line flag. - Move CefRequestHandler::OnBeforePluginLoad to CefRequestContextHandler and add a new policy argument that supports different actions (allow, block, detect, disable) on a per-plugin-instance basis. - Add CefContextMenuHandler::RunContextMenu for providing a custom context menu implementation. - Add CefResourceBundleHandler::GetDataResourceForScale for returning scaled resources (issue #1272). - Add CefResourceBundle for retrieving resources from the resource bundle (*.pak) files loaded by CEF during startup or via the CefResourceBundleHandler. - Linux: Fix Debug build IO access warning with CefGetMimeType. - cef_unittests: Move the refcounting implementation from TestHandler to subclasses in order to support interface inheritance from subclasses.
This commit is contained in:
@@ -49,6 +49,29 @@ extern "C" {
|
||||
|
||||
struct _cef_context_menu_params_t;
|
||||
|
||||
///
|
||||
// Callback structure used for continuation of custom context menu display.
|
||||
///
|
||||
typedef struct _cef_run_context_menu_callback_t {
|
||||
///
|
||||
// Base structure.
|
||||
///
|
||||
cef_base_t base;
|
||||
|
||||
///
|
||||
// Complete context menu display by selecting the specified |command_id| and
|
||||
// |event_flags|.
|
||||
///
|
||||
void (CEF_CALLBACK *cont)(struct _cef_run_context_menu_callback_t* self,
|
||||
int command_id, cef_event_flags_t event_flags);
|
||||
|
||||
///
|
||||
// Cancel context menu display.
|
||||
///
|
||||
void (CEF_CALLBACK *cancel)(struct _cef_run_context_menu_callback_t* self);
|
||||
} cef_run_context_menu_callback_t;
|
||||
|
||||
|
||||
///
|
||||
// Implement this structure to handle context menu events. The functions of this
|
||||
// structure will be called on the UI thread.
|
||||
@@ -71,6 +94,20 @@ typedef struct _cef_context_menu_handler_t {
|
||||
struct _cef_frame_t* frame, struct _cef_context_menu_params_t* params,
|
||||
struct _cef_menu_model_t* model);
|
||||
|
||||
///
|
||||
// Called to allow custom display of the context menu. |params| provides
|
||||
// information about the context menu state. |model| contains the context menu
|
||||
// model resulting from OnBeforeContextMenu. For custom display return true
|
||||
// (1) and execute |callback| either synchronously or asynchronously with the
|
||||
// selected command ID. For default display return false (0). Do not keep
|
||||
// references to |params| or |model| outside of this callback.
|
||||
///
|
||||
int (CEF_CALLBACK *run_context_menu)(struct _cef_context_menu_handler_t* self,
|
||||
struct _cef_browser_t* browser, struct _cef_frame_t* frame,
|
||||
struct _cef_context_menu_params_t* params,
|
||||
struct _cef_menu_model_t* model,
|
||||
struct _cef_run_context_menu_callback_t* callback);
|
||||
|
||||
///
|
||||
// Called to execute a command selected from the context menu. Return true (1)
|
||||
// if the command was handled or false (0) for the default implementation. See
|
||||
@@ -232,6 +269,18 @@ typedef struct _cef_context_menu_params_t {
|
||||
///
|
||||
cef_context_menu_edit_state_flags_t (CEF_CALLBACK *get_edit_state_flags)(
|
||||
struct _cef_context_menu_params_t* self);
|
||||
|
||||
///
|
||||
// Returns true (1) if the context menu contains items specified by the
|
||||
// renderer process (for example, plugin placeholder or pepper plugin menu
|
||||
// items).
|
||||
///
|
||||
int (CEF_CALLBACK *is_custom_menu)(struct _cef_context_menu_params_t* self);
|
||||
|
||||
///
|
||||
// Returns true (1) if the context menu was invoked from a pepper plugin.
|
||||
///
|
||||
int (CEF_CALLBACK *is_pepper_menu)(struct _cef_context_menu_params_t* self);
|
||||
} cef_context_menu_params_t;
|
||||
|
||||
|
||||
|
@@ -40,6 +40,7 @@
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_cookie_capi.h"
|
||||
#include "include/capi/cef_web_plugin_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -58,12 +59,30 @@ typedef struct _cef_request_context_handler_t {
|
||||
cef_base_t base;
|
||||
|
||||
///
|
||||
// Called on the IO thread to retrieve the cookie manager. If this function
|
||||
// returns NULL the default cookie manager retrievable via
|
||||
// Called on the browser process IO thread to retrieve the cookie manager. If
|
||||
// this function returns NULL the default cookie manager retrievable via
|
||||
// cef_request_tContext::get_default_cookie_manager() will be used.
|
||||
///
|
||||
struct _cef_cookie_manager_t* (CEF_CALLBACK *get_cookie_manager)(
|
||||
struct _cef_request_context_handler_t* self);
|
||||
|
||||
///
|
||||
// Called on the browser process IO thread before a plugin instance is loaded.
|
||||
// |mime_type| is the mime type of the plugin that will be loaded.
|
||||
// |plugin_url| is the content URL that the plugin will load and may be NULL.
|
||||
// |top_origin_url| is the URL for the top-level frame that contains the
|
||||
// plugin. |plugin_info| includes additional information about the plugin that
|
||||
// will be loaded. |plugin_policy| is the recommended policy. Modify
|
||||
// |plugin_policy| and return true (1) to change the policy. Return false (0)
|
||||
// to use the recommended policy. The default plugin policy can be set at
|
||||
// runtime using the `--plugin-policy=[allow|detect|block]` command-line flag.
|
||||
///
|
||||
int (CEF_CALLBACK *on_before_plugin_load)(
|
||||
struct _cef_request_context_handler_t* self,
|
||||
const cef_string_t* mime_type, const cef_string_t* plugin_url,
|
||||
const cef_string_t* top_origin_url,
|
||||
struct _cef_web_plugin_info_t* plugin_info,
|
||||
cef_plugin_policy_t* plugin_policy);
|
||||
} cef_request_context_handler_t;
|
||||
|
||||
|
||||
|
@@ -46,7 +46,6 @@
|
||||
#include "include/capi/cef_resource_handler_capi.h"
|
||||
#include "include/capi/cef_response_capi.h"
|
||||
#include "include/capi/cef_ssl_info_capi.h"
|
||||
#include "include/capi/cef_web_plugin_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -214,14 +213,6 @@ typedef struct _cef_request_handler_t {
|
||||
const cef_string_t* request_url, struct _cef_sslinfo_t* ssl_info,
|
||||
struct _cef_request_callback_t* callback);
|
||||
|
||||
///
|
||||
// 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);
|
||||
|
||||
///
|
||||
// Called on the browser process UI thread when a plugin has crashed.
|
||||
// |plugin_path| is the path of the plugin that crashed.
|
||||
|
107
include/capi/cef_resource_bundle_capi.h
Normal file
107
include/capi/cef_resource_bundle_capi.h
Normal file
@@ -0,0 +1,107 @@
|
||||
// Copyright (c) 2015 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_INCLUDE_CAPI_CEF_RESOURCE_BUNDLE_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_RESOURCE_BUNDLE_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
///
|
||||
// Structure used for retrieving resources from the resource bundle (*.pak)
|
||||
// files loaded by CEF during startup or via the cef_resource_bundle_tHandler
|
||||
// returned from cef_app_t::GetResourceBundleHandler. See CefSettings for
|
||||
// additional options related to resource bundle loading. The functions of this
|
||||
// structure may be called on any thread unless otherwise indicated.
|
||||
///
|
||||
typedef struct _cef_resource_bundle_t {
|
||||
///
|
||||
// Base structure.
|
||||
///
|
||||
cef_base_t base;
|
||||
|
||||
///
|
||||
// Returns the localized string for the specified |string_id| or an NULL
|
||||
// string if the value is not found. Include cef_pack_strings.h for a listing
|
||||
// of valid string ID values.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t (CEF_CALLBACK *get_localized_string)(
|
||||
struct _cef_resource_bundle_t* self, int string_id);
|
||||
|
||||
///
|
||||
// Retrieves the contents of the specified scale independent |resource_id|. If
|
||||
// the value is found then |data| and |data_size| will be populated and this
|
||||
// function will return true (1). If the value is not found then this function
|
||||
// will return false (0). The returned |data| pointer will remain resident in
|
||||
// memory and should not be freed. Include cef_pack_resources.h for a listing
|
||||
// of valid resource ID values.
|
||||
///
|
||||
int (CEF_CALLBACK *get_data_resource)(struct _cef_resource_bundle_t* self,
|
||||
int resource_id, void** data, size_t* data_size);
|
||||
|
||||
///
|
||||
// Retrieves the contents of the specified |resource_id| nearest the scale
|
||||
// factor |scale_factor|. Use a |scale_factor| value of SCALE_FACTOR_NONE for
|
||||
// scale independent resources or call GetDataResource instead. If the value
|
||||
// is found then |data| and |data_size| will be populated and this function
|
||||
// will return true (1). If the value is not found then this function will
|
||||
// return false (0). The returned |data| pointer will remain resident in
|
||||
// memory and should not be freed. Include cef_pack_resources.h for a listing
|
||||
// of valid resource ID values.
|
||||
///
|
||||
int (CEF_CALLBACK *get_data_resource_for_scale)(
|
||||
struct _cef_resource_bundle_t* self, int resource_id,
|
||||
cef_scale_factor_t scale_factor, void** data, size_t* data_size);
|
||||
} cef_resource_bundle_t;
|
||||
|
||||
|
||||
///
|
||||
// Returns the global resource bundle instance.
|
||||
///
|
||||
CEF_EXPORT cef_resource_bundle_t* cef_resource_bundle_get_global();
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_RESOURCE_BUNDLE_CAPI_H_
|
@@ -46,8 +46,9 @@ extern "C" {
|
||||
|
||||
|
||||
///
|
||||
// Structure used to implement a custom resource bundle structure. The functions
|
||||
// of this structure may be called on multiple threads.
|
||||
// Structure used to implement a custom resource bundle structure. See
|
||||
// CefSettings for additional options related to resource bundle loading. The
|
||||
// functions of this structure may be called on multiple threads.
|
||||
///
|
||||
typedef struct _cef_resource_bundle_handler_t {
|
||||
///
|
||||
@@ -56,26 +57,38 @@ typedef struct _cef_resource_bundle_handler_t {
|
||||
cef_base_t base;
|
||||
|
||||
///
|
||||
// Called to retrieve a localized translation for the string specified by
|
||||
// |message_id|. To provide the translation set |string| to the translation
|
||||
// string and return true (1). To use the default translation return false
|
||||
// (0). Supported message IDs are listed in cef_pack_strings.h.
|
||||
// Called to retrieve a localized translation for the specified |string_id|.
|
||||
// To provide the translation set |string| to the translation string and
|
||||
// return true (1). To use the default translation return false (0). Include
|
||||
// cef_pack_strings.h for a listing of valid string ID values.
|
||||
///
|
||||
int (CEF_CALLBACK *get_localized_string)(
|
||||
struct _cef_resource_bundle_handler_t* self, int message_id,
|
||||
struct _cef_resource_bundle_handler_t* self, int string_id,
|
||||
cef_string_t* string);
|
||||
|
||||
///
|
||||
// Called to retrieve data for the resource specified by |resource_id|. To
|
||||
// provide the resource data set |data| and |data_size| to the data pointer
|
||||
// Called to retrieve data for the specified scale independent |resource_id|.
|
||||
// To provide the resource data set |data| and |data_size| to the data pointer
|
||||
// and size respectively and return true (1). To use the default resource data
|
||||
// return false (0). The resource data will not be copied and must remain
|
||||
// resident in memory. Supported resource IDs are listed in
|
||||
// cef_pack_resources.h.
|
||||
// resident in memory. Include cef_pack_resources.h for a listing of valid
|
||||
// resource ID values.
|
||||
///
|
||||
int (CEF_CALLBACK *get_data_resource)(
|
||||
struct _cef_resource_bundle_handler_t* self, int resource_id, void** data,
|
||||
size_t* data_size);
|
||||
|
||||
///
|
||||
// Called to retrieve data for the specified |resource_id| nearest the scale
|
||||
// factor |scale_factor|. To provide the resource data set |data| and
|
||||
// |data_size| to the data pointer and size respectively and return true (1).
|
||||
// To use the default resource data return false (0). The resource data will
|
||||
// not be copied and must remain resident in memory. Include
|
||||
// cef_pack_resources.h for a listing of valid resource ID values.
|
||||
///
|
||||
int (CEF_CALLBACK *get_data_resource_for_scale)(
|
||||
struct _cef_resource_bundle_handler_t* self, int resource_id,
|
||||
cef_scale_factor_t scale_factor, void** data, size_t* data_size);
|
||||
} cef_resource_bundle_handler_t;
|
||||
|
||||
|
||||
|
@@ -39,12 +39,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_browser_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct _cef_browser_t;
|
||||
|
||||
///
|
||||
// Information about a specific web plugin.
|
||||
|
@@ -45,6 +45,30 @@
|
||||
|
||||
class CefContextMenuParams;
|
||||
|
||||
|
||||
///
|
||||
// Callback interface used for continuation of custom context menu display.
|
||||
///
|
||||
/*--cef(source=library)--*/
|
||||
class CefRunContextMenuCallback : public virtual CefBase {
|
||||
public:
|
||||
typedef cef_event_flags_t EventFlags;
|
||||
|
||||
///
|
||||
// Complete context menu display by selecting the specified |command_id| and
|
||||
// |event_flags|.
|
||||
///
|
||||
/*--cef(capi_name=cont)--*/
|
||||
virtual void Continue(int command_id, EventFlags event_flags) =0;
|
||||
|
||||
///
|
||||
// Cancel context menu display.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void Cancel() =0;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
// Implement this interface to handle context menu events. The methods of this
|
||||
// class will be called on the UI thread.
|
||||
@@ -67,6 +91,23 @@ class CefContextMenuHandler : public virtual CefBase {
|
||||
CefRefPtr<CefContextMenuParams> params,
|
||||
CefRefPtr<CefMenuModel> model) {}
|
||||
|
||||
///
|
||||
// Called to allow custom display of the context menu. |params| provides
|
||||
// information about the context menu state. |model| contains the context menu
|
||||
// model resulting from OnBeforeContextMenu. For custom display return true
|
||||
// and execute |callback| either synchronously or asynchronously with the
|
||||
// selected command ID. For default display return false. Do not keep
|
||||
// references to |params| or |model| outside of this callback.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool RunContextMenu(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefContextMenuParams> params,
|
||||
CefRefPtr<CefMenuModel> model,
|
||||
CefRefPtr<CefRunContextMenuCallback> callback) {
|
||||
return false;
|
||||
}
|
||||
|
||||
///
|
||||
// Called to execute a command selected from the context menu. Return true if
|
||||
// the command was handled or false for the default implementation. See
|
||||
@@ -226,6 +267,19 @@ class CefContextMenuParams : public virtual CefBase {
|
||||
///
|
||||
/*--cef(default_retval=CM_EDITFLAG_NONE)--*/
|
||||
virtual EditStateFlags GetEditStateFlags() =0;
|
||||
|
||||
///
|
||||
// Returns true if the context menu contains items specified by the renderer
|
||||
// process (for example, plugin placeholder or pepper plugin menu items).
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsCustomMenu() =0;
|
||||
|
||||
///
|
||||
// Returns true if the context menu was invoked from a pepper plugin.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsPepperMenu() =0;
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_CEF_CONTEXT_MENU_HANDLER_H_
|
||||
|
@@ -40,6 +40,7 @@
|
||||
|
||||
#include "include/cef_base.h"
|
||||
#include "include/cef_cookie.h"
|
||||
#include "include/cef_web_plugin.h"
|
||||
|
||||
///
|
||||
// Implement this interface to provide handler implementations. The handler
|
||||
@@ -49,13 +50,35 @@
|
||||
/*--cef(source=client,no_debugct_check)--*/
|
||||
class CefRequestContextHandler : public virtual CefBase {
|
||||
public:
|
||||
typedef cef_plugin_policy_t PluginPolicy;
|
||||
|
||||
///
|
||||
// Called on the IO thread to retrieve the cookie manager. If this method
|
||||
// returns NULL the default cookie manager retrievable via
|
||||
// Called on the browser process IO thread to retrieve the cookie manager. If
|
||||
// this method returns NULL the default cookie manager retrievable via
|
||||
// CefRequestContext::GetDefaultCookieManager() will be used.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefCookieManager> GetCookieManager() { return NULL; }
|
||||
|
||||
///
|
||||
// Called on the browser process IO thread before a plugin instance is loaded.
|
||||
// |mime_type| is the mime type of the plugin that will be loaded.
|
||||
// |plugin_url| is the content URL that the plugin will load and may be empty.
|
||||
// |top_origin_url| is the URL for the top-level frame that contains the
|
||||
// plugin. |plugin_info| includes additional information about the plugin that
|
||||
// will be loaded. |plugin_policy| is the recommended policy. Modify
|
||||
// |plugin_policy| and return true to change the policy. Return false to use
|
||||
// the recommended policy. The default plugin policy can be set at runtime
|
||||
// using the `--plugin-policy=[allow|detect|block]` command-line flag.
|
||||
///
|
||||
/*--cef(optional_param=plugin_url)--*/
|
||||
virtual bool OnBeforePluginLoad(const CefString& mime_type,
|
||||
const CefString& plugin_url,
|
||||
const CefString& top_origin_url,
|
||||
CefRefPtr<CefWebPluginInfo> plugin_info,
|
||||
PluginPolicy* plugin_policy) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_CEF_REQUEST_CONTEXT_HANDLER_H_
|
||||
|
@@ -46,7 +46,6 @@
|
||||
#include "include/cef_response.h"
|
||||
#include "include/cef_request.h"
|
||||
#include "include/cef_ssl_info.h"
|
||||
#include "include/cef_web_plugin.h"
|
||||
|
||||
|
||||
///
|
||||
@@ -248,18 +247,6 @@ class CefRequestHandler : public virtual CefBase {
|
||||
return false;
|
||||
}
|
||||
|
||||
///
|
||||
// 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;
|
||||
}
|
||||
|
||||
///
|
||||
// Called on the browser process UI thread when a plugin has crashed.
|
||||
// |plugin_path| is the path of the plugin that crashed.
|
||||
|
99
include/cef_resource_bundle.h
Normal file
99
include/cef_resource_bundle.h
Normal file
@@ -0,0 +1,99 @@
|
||||
// Copyright (c) 2015 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_INCLUDE_CEF_RESOURCE_BUNDLE_H_
|
||||
#define CEF_INCLUDE_CEF_RESOURCE_BUNDLE_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/cef_base.h"
|
||||
|
||||
///
|
||||
// Class used for retrieving resources from the resource bundle (*.pak) files
|
||||
// loaded by CEF during startup or via the CefResourceBundleHandler returned
|
||||
// from CefApp::GetResourceBundleHandler. See CefSettings for additional options
|
||||
// related to resource bundle loading. The methods of this class may be called
|
||||
// on any thread unless otherwise indicated.
|
||||
///
|
||||
/*--cef(source=library,no_debugct_check)--*/
|
||||
class CefResourceBundle : public virtual CefBase {
|
||||
public:
|
||||
typedef cef_scale_factor_t ScaleFactor;
|
||||
|
||||
///
|
||||
// Returns the global resource bundle instance.
|
||||
///
|
||||
/*--cef()--*/
|
||||
static CefRefPtr<CefResourceBundle> GetGlobal();
|
||||
|
||||
///
|
||||
// Returns the localized string for the specified |string_id| or an empty
|
||||
// string if the value is not found. Include cef_pack_strings.h for a listing
|
||||
// of valid string ID values.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefString GetLocalizedString(int string_id) =0;
|
||||
|
||||
///
|
||||
// Retrieves the contents of the specified scale independent |resource_id|.
|
||||
// If the value is found then |data| and |data_size| will be populated and
|
||||
// this method will return true. If the value is not found then this method
|
||||
// will return false. The returned |data| pointer will remain resident in
|
||||
// memory and should not be freed. Include cef_pack_resources.h for a listing
|
||||
// of valid resource ID values.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool GetDataResource(int resource_id,
|
||||
void*& data,
|
||||
size_t& data_size) =0;
|
||||
|
||||
///
|
||||
// Retrieves the contents of the specified |resource_id| nearest the scale
|
||||
// factor |scale_factor|. Use a |scale_factor| value of SCALE_FACTOR_NONE for
|
||||
// scale independent resources or call GetDataResource instead. If the value
|
||||
// is found then |data| and |data_size| will be populated and this method will
|
||||
// return true. If the value is not found then this method will return false.
|
||||
// The returned |data| pointer will remain resident in memory and should not
|
||||
// be freed. Include cef_pack_resources.h for a listing of valid resource ID
|
||||
// values.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool GetDataResourceForScale(int resource_id,
|
||||
ScaleFactor scale_factor,
|
||||
void*& data,
|
||||
size_t& data_size) =0;
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_CEF_RESOURCE_BUNDLE_H_
|
@@ -41,33 +41,51 @@
|
||||
#include "include/cef_base.h"
|
||||
|
||||
///
|
||||
// Class used to implement a custom resource bundle interface. The methods of
|
||||
// Class used to implement a custom resource bundle interface. See CefSettings
|
||||
// for additional options related to resource bundle loading. The methods of
|
||||
// this class may be called on multiple threads.
|
||||
///
|
||||
/*--cef(source=client)--*/
|
||||
class CefResourceBundleHandler : public virtual CefBase {
|
||||
public:
|
||||
typedef cef_scale_factor_t ScaleFactor;
|
||||
|
||||
///
|
||||
// Called to retrieve a localized translation for the string specified by
|
||||
// |message_id|. To provide the translation set |string| to the translation
|
||||
// string and return true. To use the default translation return false.
|
||||
// Supported message IDs are listed in cef_pack_strings.h.
|
||||
// Called to retrieve a localized translation for the specified |string_id|.
|
||||
// To provide the translation set |string| to the translation string and
|
||||
// return true. To use the default translation return false. Include
|
||||
// cef_pack_strings.h for a listing of valid string ID values.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool GetLocalizedString(int message_id,
|
||||
virtual bool GetLocalizedString(int string_id,
|
||||
CefString& string) =0;
|
||||
|
||||
///
|
||||
// Called to retrieve data for the resource specified by |resource_id|. To
|
||||
// provide the resource data set |data| and |data_size| to the data pointer
|
||||
// Called to retrieve data for the specified scale independent |resource_id|.
|
||||
// To provide the resource data set |data| and |data_size| to the data pointer
|
||||
// and size respectively and return true. To use the default resource data
|
||||
// return false. The resource data will not be copied and must remain resident
|
||||
// in memory. Supported resource IDs are listed in cef_pack_resources.h.
|
||||
// in memory. Include cef_pack_resources.h for a listing of valid resource ID
|
||||
// values.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool GetDataResource(int resource_id,
|
||||
void*& data,
|
||||
size_t& data_size) =0;
|
||||
|
||||
///
|
||||
// Called to retrieve data for the specified |resource_id| nearest the scale
|
||||
// factor |scale_factor|. To provide the resource data set |data| and
|
||||
// |data_size| to the data pointer and size respectively and return true. To
|
||||
// use the default resource data return false. The resource data will not be
|
||||
// copied and must remain resident in memory. Include cef_pack_resources.h for
|
||||
// a listing of valid resource ID values.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool GetDataResourceForScale(int resource_id,
|
||||
ScaleFactor scale_factor,
|
||||
void*& data,
|
||||
size_t& data_size) =0;
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_CEF_RESOURCE_BUNDLE_HANDLER_H_
|
||||
|
@@ -38,7 +38,8 @@
|
||||
#define CEF_INCLUDE_CEF_WEB_PLUGIN_H_
|
||||
|
||||
#include "include/cef_base.h"
|
||||
#include "include/cef_browser.h"
|
||||
|
||||
class CefBrowser;
|
||||
|
||||
///
|
||||
// Information about a specific web plugin.
|
||||
|
@@ -1423,6 +1423,11 @@ typedef enum {
|
||||
MENU_ID_NO_SPELLING_SUGGESTIONS = 205,
|
||||
MENU_ID_ADD_TO_DICTIONARY = 206,
|
||||
|
||||
// Custom menu items originating from the renderer process. For example,
|
||||
// plugin placeholder menu items or Flash menu items.
|
||||
MENU_ID_CUSTOM_FIRST = 220,
|
||||
MENU_ID_CUSTOM_LAST = 250,
|
||||
|
||||
// All user-defined menu IDs should come between MENU_ID_USER_FIRST and
|
||||
// MENU_ID_USER_LAST to avoid overlapping the Chromium and CEF ID ranges
|
||||
// defined in the tools/gritsettings/resource_ids file.
|
||||
@@ -2241,6 +2246,50 @@ typedef struct _cef_pdf_print_settings_t {
|
||||
|
||||
} cef_pdf_print_settings_t;
|
||||
|
||||
///
|
||||
// Supported UI scale factors for the platform. SCALE_FACTOR_NONE is used for
|
||||
// density independent resources such as string, html/js files or an image that
|
||||
// can be used for any scale factors (such as wallpapers).
|
||||
///
|
||||
typedef enum {
|
||||
SCALE_FACTOR_NONE = 0,
|
||||
SCALE_FACTOR_100P,
|
||||
SCALE_FACTOR_125P,
|
||||
SCALE_FACTOR_133P,
|
||||
SCALE_FACTOR_140P,
|
||||
SCALE_FACTOR_150P,
|
||||
SCALE_FACTOR_180P,
|
||||
SCALE_FACTOR_200P,
|
||||
SCALE_FACTOR_250P,
|
||||
SCALE_FACTOR_300P,
|
||||
} cef_scale_factor_t;
|
||||
|
||||
///
|
||||
// Plugin policies supported by CefRequestContextHandler::OnBeforePluginLoad.
|
||||
///
|
||||
typedef enum {
|
||||
///
|
||||
// Allow the content.
|
||||
///
|
||||
PLUGIN_POLICY_ALLOW,
|
||||
|
||||
///
|
||||
// Allow important content and block unimportant content based on heuristics.
|
||||
// The user can manually load blocked content.
|
||||
///
|
||||
PLUGIN_POLICY_DETECT_IMPORTANT,
|
||||
|
||||
///
|
||||
// Block the content. The user can manually load blocked content.
|
||||
///
|
||||
PLUGIN_POLICY_BLOCK,
|
||||
|
||||
///
|
||||
// Disable the content. The user cannot load disabled content.
|
||||
///
|
||||
PLUGIN_POLICY_DISABLE,
|
||||
} cef_plugin_policy_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user