mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Add support for loading extensions (issue #1947)
- Add CefRequestContext::LoadExtension, CefExtension, CefExtensionHandler and related methods/interfaces. - Add chrome://extensions-support that lists supported Chrome APIs. - Add CefBrowserHost::SetAutoResizeEnabled and CefDisplayHandler::OnAutoResize to support browser resize based on preferred web contents size. - views: Add support for custom CefMenuButton popups. - cefclient: Run with `--load-extension=set_page_color` command-line flag for an extension loading example. Add `--use-views` on Windows and Linux for an even better example.
This commit is contained in:
@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=b6308ab5e97eb9f7af95f1f4c371fd6e7edbf852$
|
||||
// $hash=a4831deeb05bc0a022c1a0ee6f1c484b338c741c$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_
|
||||
@ -115,7 +115,8 @@ typedef struct _cef_browser_t {
|
||||
void(CEF_CALLBACK* stop_load)(struct _cef_browser_t* self);
|
||||
|
||||
///
|
||||
// Returns the globally unique identifier for this browser.
|
||||
// Returns the globally unique identifier for this browser. This value is also
|
||||
// used as the tabId for extension APIs.
|
||||
///
|
||||
int(CEF_CALLBACK* get_identifier)(struct _cef_browser_t* self);
|
||||
|
||||
@ -812,6 +813,30 @@ typedef struct _cef_browser_host_t {
|
||||
///
|
||||
void(CEF_CALLBACK* set_accessibility_state)(struct _cef_browser_host_t* self,
|
||||
cef_state_t accessibility_state);
|
||||
|
||||
///
|
||||
// Enable notifications of auto resize via
|
||||
// cef_display_handler_t::OnAutoResize. Notifications are disabled by default.
|
||||
// |min_size| and |max_size| define the range of allowed sizes.
|
||||
///
|
||||
void(CEF_CALLBACK* set_auto_resize_enabled)(struct _cef_browser_host_t* self,
|
||||
int enabled,
|
||||
const cef_size_t* min_size,
|
||||
const cef_size_t* max_size);
|
||||
|
||||
///
|
||||
// Returns the extension hosted in this browser or NULL if no extension is
|
||||
// hosted. See cef_request_tContext::LoadExtension for details.
|
||||
///
|
||||
struct _cef_extension_t*(CEF_CALLBACK* get_extension)(
|
||||
struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
// Returns true (1) if this browser is hosting an extension background script.
|
||||
// Background hosts do not have a window and are not displayable. See
|
||||
// cef_request_tContext::LoadExtension for details.
|
||||
///
|
||||
int(CEF_CALLBACK* is_background_host)(struct _cef_browser_host_t* self);
|
||||
} cef_browser_host_t;
|
||||
|
||||
///
|
||||
|
@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=f0f3fd4cab00c0eb11956e674a111cb30d3af100$
|
||||
// $hash=979968e494e9d7c4d5117a1753acade5d0e79215$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_DISPLAY_HANDLER_CAPI_H_
|
||||
@ -121,6 +121,16 @@ typedef struct _cef_display_handler_t {
|
||||
const cef_string_t* message,
|
||||
const cef_string_t* source,
|
||||
int line);
|
||||
|
||||
///
|
||||
// Called when auto-resize is enabled via
|
||||
// cef_browser_host_t::SetAutoResizeEnabled and the contents have auto-
|
||||
// resized. |new_size| will be the desired size in view coordinates. Return
|
||||
// true (1) if the resize was handled or false (0) for default handling.
|
||||
///
|
||||
int(CEF_CALLBACK* on_auto_resize)(struct _cef_display_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
const cef_size_t* new_size);
|
||||
} cef_display_handler_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
130
include/capi/cef_extension_capi.h
Normal file
130
include/capi/cef_extension_capi.h
Normal file
@ -0,0 +1,130 @@
|
||||
// Copyright (c) 2017 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.
|
||||
//
|
||||
// $hash=aef2f0bc7a2491b5745b5eae8d02e2e8bd7335af$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_EXTENSION_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_EXTENSION_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_values_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct _cef_extension_handler_t;
|
||||
struct _cef_request_context_t;
|
||||
|
||||
///
|
||||
// Object representing an extension. Methods may be called on any thread unless
|
||||
// otherwise indicated.
|
||||
///
|
||||
typedef struct _cef_extension_t {
|
||||
///
|
||||
// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
// Returns the unique extension identifier. This is calculated based on the
|
||||
// extension public key, if available, or on the extension path. See
|
||||
// https://developer.chrome.com/extensions/manifest/key for details.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_identifier)(
|
||||
struct _cef_extension_t* self);
|
||||
|
||||
///
|
||||
// Returns the absolute path to the extension directory on disk. This value
|
||||
// will be prefixed with PK_DIR_RESOURCES if a relative path was passed to
|
||||
// cef_request_tContext::LoadExtension.
|
||||
///
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t(CEF_CALLBACK* get_path)(struct _cef_extension_t* self);
|
||||
|
||||
///
|
||||
// Returns the extension manifest contents as a cef_dictionary_value_t object.
|
||||
// See https://developer.chrome.com/extensions/manifest for details.
|
||||
///
|
||||
struct _cef_dictionary_value_t*(CEF_CALLBACK* get_manifest)(
|
||||
struct _cef_extension_t* self);
|
||||
|
||||
///
|
||||
// Returns true (1) if this object is the same extension as |that| object.
|
||||
// Extensions are considered the same if identifier, path and loader context
|
||||
// match.
|
||||
///
|
||||
int(CEF_CALLBACK* is_same)(struct _cef_extension_t* self,
|
||||
struct _cef_extension_t* that);
|
||||
|
||||
///
|
||||
// Returns the handler for this extension. Will return NULL for internal
|
||||
// extensions or if no handler was passed to
|
||||
// cef_request_tContext::LoadExtension.
|
||||
///
|
||||
struct _cef_extension_handler_t*(CEF_CALLBACK* get_handler)(
|
||||
struct _cef_extension_t* self);
|
||||
|
||||
///
|
||||
// Returns the request context that loaded this extension. Will return NULL
|
||||
// for internal extensions or if the extension has been unloaded. See the
|
||||
// cef_request_tContext::LoadExtension documentation for more information
|
||||
// about loader contexts. Must be called on the browser process UI thread.
|
||||
///
|
||||
struct _cef_request_context_t*(CEF_CALLBACK* get_loader_context)(
|
||||
struct _cef_extension_t* self);
|
||||
|
||||
///
|
||||
// Returns true (1) if this extension is currently loaded. Must be called on
|
||||
// the browser process UI thread.
|
||||
///
|
||||
int(CEF_CALLBACK* is_loaded)(struct _cef_extension_t* self);
|
||||
|
||||
///
|
||||
// Unload this extension if it is not an internal extension and is currently
|
||||
// loaded. Will result in a call to
|
||||
// cef_extension_tHandler::OnExtensionUnloaded on success.
|
||||
///
|
||||
void(CEF_CALLBACK* unload)(struct _cef_extension_t* self);
|
||||
} cef_extension_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_EXTENSION_CAPI_H_
|
183
include/capi/cef_extension_handler_capi.h
Normal file
183
include/capi/cef_extension_handler_capi.h
Normal file
@ -0,0 +1,183 @@
|
||||
// Copyright (c) 2017 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.
|
||||
//
|
||||
// $hash=b49f4c91db8eccdfe9ded503d8bb32ee0e433f60$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_EXTENSION_HANDLER_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_EXTENSION_HANDLER_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_browser_capi.h"
|
||||
#include "include/capi/cef_extension_capi.h"
|
||||
#include "include/capi/cef_stream_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct _cef_client_t;
|
||||
|
||||
///
|
||||
// Callback structure used for asynchronous continuation of
|
||||
// cef_extension_tHandler::GetExtensionResource.
|
||||
///
|
||||
typedef struct _cef_get_extension_resource_callback_t {
|
||||
///
|
||||
// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
// Continue the request. Read the resource contents from |stream|.
|
||||
///
|
||||
void(CEF_CALLBACK* cont)(struct _cef_get_extension_resource_callback_t* self,
|
||||
struct _cef_stream_reader_t* stream);
|
||||
|
||||
///
|
||||
// Cancel the request.
|
||||
///
|
||||
void(CEF_CALLBACK* cancel)(
|
||||
struct _cef_get_extension_resource_callback_t* self);
|
||||
} cef_get_extension_resource_callback_t;
|
||||
|
||||
///
|
||||
// Implement this structure to handle events related to browser extensions. The
|
||||
// functions of this structure will be called on the UI thread. See
|
||||
// cef_request_tContext::LoadExtension for information about extension loading.
|
||||
///
|
||||
typedef struct _cef_extension_handler_t {
|
||||
///
|
||||
// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
// Called if the cef_request_tContext::LoadExtension request fails. |result|
|
||||
// will be the error code.
|
||||
///
|
||||
void(CEF_CALLBACK* on_extension_load_failed)(
|
||||
struct _cef_extension_handler_t* self,
|
||||
cef_errorcode_t result);
|
||||
|
||||
///
|
||||
// Called if the cef_request_tContext::LoadExtension request succeeds.
|
||||
// |extension| is the loaded extension.
|
||||
///
|
||||
void(CEF_CALLBACK* on_extension_loaded)(struct _cef_extension_handler_t* self,
|
||||
struct _cef_extension_t* extension);
|
||||
|
||||
///
|
||||
// Called after the cef_extension_t::Unload request has completed.
|
||||
///
|
||||
void(CEF_CALLBACK* on_extension_unloaded)(
|
||||
struct _cef_extension_handler_t* self,
|
||||
struct _cef_extension_t* extension);
|
||||
|
||||
///
|
||||
// Called when an extension needs a browser to host a background script
|
||||
// specified via the "background" manifest key. The browser will have no
|
||||
// visible window and cannot be displayed. |extension| is the extension that
|
||||
// is loading the background script. |url| is an internally generated
|
||||
// reference to an HTML page that will be used to load the background script
|
||||
// via a <script> src attribute. To allow creation of the browser optionally
|
||||
// modify |client| and |settings| and return false (0). To cancel creation of
|
||||
// the browser (and consequently cancel load of the background script) return
|
||||
// true (1). Successful creation will be indicated by a call to
|
||||
// cef_life_span_handler_t::OnAfterCreated, and
|
||||
// cef_browser_host_t::IsBackgroundHost will return true (1) for the resulting
|
||||
// browser. See https://developer.chrome.com/extensions/event_pages for more
|
||||
// information about extension background script usage.
|
||||
///
|
||||
int(CEF_CALLBACK* on_before_background_browser)(
|
||||
struct _cef_extension_handler_t* self,
|
||||
struct _cef_extension_t* extension,
|
||||
const cef_string_t* url,
|
||||
struct _cef_client_t** client,
|
||||
struct _cef_browser_settings_t* settings);
|
||||
|
||||
///
|
||||
// Called when no tabId is specified to an extension API call that accepts a
|
||||
// tabId parameter (e.g. chrome.tabs.*). |extension| and |browser| are the
|
||||
// source of the API call. Return the browser that will be acted on by the API
|
||||
// call or return NULL to act on |browser|. The returned browser must share
|
||||
// the same cef_request_tContext as |browser|. Incognito browsers should not
|
||||
// be considered unless the source extension has incognito access enabled, in
|
||||
// which case |include_incognito| will be true (1).
|
||||
///
|
||||
struct _cef_browser_t*(CEF_CALLBACK* get_active_browser)(
|
||||
struct _cef_extension_handler_t* self,
|
||||
struct _cef_extension_t* extension,
|
||||
struct _cef_browser_t* browser,
|
||||
int include_incognito);
|
||||
|
||||
///
|
||||
// Called when the tabId associated with |target_browser| is specified to an
|
||||
// extension API call that accepts a tabId parameter (e.g. chrome.tabs.*).
|
||||
// |extension| and |browser| are the source of the API call. Return true (1)
|
||||
// to allow access of false (0) to deny access. Access to incognito browsers
|
||||
// should not be allowed unless the source extension has incognito access
|
||||
// enabled, in which case |include_incognito| will be true (1).
|
||||
///
|
||||
int(CEF_CALLBACK* can_access_browser)(struct _cef_extension_handler_t* self,
|
||||
struct _cef_extension_t* extension,
|
||||
struct _cef_browser_t* browser,
|
||||
int include_incognito,
|
||||
struct _cef_browser_t* target_browser);
|
||||
|
||||
///
|
||||
// Called to retrieve an extension resource that would normally be loaded from
|
||||
// disk (e.g. if a file parameter is specified to chrome.tabs.executeScript).
|
||||
// |extension| and |browser| are the source of the resource request. |file| is
|
||||
// the requested relative file path. To handle the resource request return
|
||||
// true (1) and execute |callback| either synchronously or asynchronously. For
|
||||
// the default behavior which reads the resource from the extension directory
|
||||
// on disk return false (0). Localization substitutions will not be applied to
|
||||
// resources handled via this function.
|
||||
///
|
||||
int(CEF_CALLBACK* get_extension_resource)(
|
||||
struct _cef_extension_handler_t* self,
|
||||
struct _cef_extension_t* extension,
|
||||
struct _cef_browser_t* browser,
|
||||
const cef_string_t* file,
|
||||
struct _cef_get_extension_resource_callback_t* callback);
|
||||
} cef_extension_handler_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_EXTENSION_HANDLER_CAPI_H_
|
@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=791231acc78a2b601257fb0b86d904eace796d63$
|
||||
// $hash=81e857497b1f5e1732af7fca2250edf78c0e5415$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_CONTEXT_CAPI_H_
|
||||
@ -42,6 +42,8 @@
|
||||
|
||||
#include "include/capi/cef_callback_capi.h"
|
||||
#include "include/capi/cef_cookie_capi.h"
|
||||
#include "include/capi/cef_extension_capi.h"
|
||||
#include "include/capi/cef_extension_handler_capi.h"
|
||||
#include "include/capi/cef_request_context_handler_capi.h"
|
||||
#include "include/capi/cef_values_capi.h"
|
||||
|
||||
@ -61,9 +63,9 @@ typedef struct _cef_resolve_callback_t {
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
// Called after the ResolveHost request has completed. |result| will be the
|
||||
// result code. |resolved_ips| will be the list of resolved IP addresses or
|
||||
// NULL if the resolution failed.
|
||||
// Called on the UI thread after the ResolveHost request has completed.
|
||||
// |result| will be the result code. |resolved_ips| will be the list of
|
||||
// resolved IP addresses or NULL if the resolution failed.
|
||||
///
|
||||
void(CEF_CALLBACK* on_resolve_completed)(struct _cef_resolve_callback_t* self,
|
||||
cef_errorcode_t result,
|
||||
@ -267,6 +269,95 @@ typedef struct _cef_request_context_t {
|
||||
struct _cef_request_context_t* self,
|
||||
const cef_string_t* origin,
|
||||
cef_string_list_t resolved_ips);
|
||||
|
||||
///
|
||||
// Load an extension.
|
||||
//
|
||||
// If extension resources will be read from disk using the default load
|
||||
// implementation then |root_directory| should be the absolute path to the
|
||||
// extension resources directory and |manifest| should be NULL. If extension
|
||||
// resources will be provided by the client (e.g. via cef_request_tHandler
|
||||
// and/or cef_extension_tHandler) then |root_directory| should be a path
|
||||
// component unique to the extension (if not absolute this will be internally
|
||||
// prefixed with the PK_DIR_RESOURCES path) and |manifest| should contain the
|
||||
// contents that would otherwise be read from the "manifest.json" file on
|
||||
// disk.
|
||||
//
|
||||
// The loaded extension will be accessible in all contexts sharing the same
|
||||
// storage (HasExtension returns true (1)). However, only the context on which
|
||||
// this function was called is considered the loader (DidLoadExtension returns
|
||||
// true (1)) and only the loader will receive cef_request_tContextHandler
|
||||
// callbacks for the extension.
|
||||
//
|
||||
// cef_extension_tHandler::OnExtensionLoaded will be called on load success or
|
||||
// cef_extension_tHandler::OnExtensionLoadFailed will be called on load
|
||||
// failure.
|
||||
//
|
||||
// If the extension specifies a background script via the "background"
|
||||
// manifest key then cef_extension_tHandler::OnBeforeBackgroundBrowser will be
|
||||
// called to create the background browser. See that function for additional
|
||||
// information about background scripts.
|
||||
//
|
||||
// For visible extension views the client application should evaluate the
|
||||
// manifest to determine the correct extension URL to load and then pass that
|
||||
// URL to the cef_browser_host_t::CreateBrowser* function after the extension
|
||||
// has loaded. For example, the client can look for the "browser_action"
|
||||
// manifest key as documented at
|
||||
// https://developer.chrome.com/extensions/browserAction. Extension URLs take
|
||||
// the form "chrome-extension://<extension_id>/<path>".
|
||||
//
|
||||
// Browsers that host extensions differ from normal browsers as follows:
|
||||
// - Can access chrome.* JavaScript APIs if allowed by the manifest. Visit
|
||||
// chrome://extensions-support for the list of extension APIs currently
|
||||
// supported by CEF.
|
||||
// - Main frame navigation to non-extension content is blocked.
|
||||
// - Pinch-zooming is disabled.
|
||||
// - CefBrowserHost::GetExtension returns the hosted extension.
|
||||
// - CefBrowserHost::IsBackgroundHost returns true for background hosts.
|
||||
//
|
||||
// See https://developer.chrome.com/extensions for extension implementation
|
||||
// and usage documentation.
|
||||
///
|
||||
void(CEF_CALLBACK* load_extension)(struct _cef_request_context_t* self,
|
||||
const cef_string_t* root_directory,
|
||||
struct _cef_dictionary_value_t* manifest,
|
||||
struct _cef_extension_handler_t* handler);
|
||||
|
||||
///
|
||||
// Returns true (1) if this context was used to load the extension identified
|
||||
// by |extension_id|. Other contexts sharing the same storage will also have
|
||||
// access to the extension (see HasExtension). This function must be called on
|
||||
// the browser process UI thread.
|
||||
///
|
||||
int(CEF_CALLBACK* did_load_extension)(struct _cef_request_context_t* self,
|
||||
const cef_string_t* extension_id);
|
||||
|
||||
///
|
||||
// Returns true (1) if this context has access to the extension identified by
|
||||
// |extension_id|. This may not be the context that was used to load the
|
||||
// extension (see DidLoadExtension). This function must be called on the
|
||||
// browser process UI thread.
|
||||
///
|
||||
int(CEF_CALLBACK* has_extension)(struct _cef_request_context_t* self,
|
||||
const cef_string_t* extension_id);
|
||||
|
||||
///
|
||||
// Retrieve the list of all extensions that this context has access to (see
|
||||
// HasExtension). |extension_ids| will be populated with the list of extension
|
||||
// ID values. Returns true (1) on success. This function must be called on the
|
||||
// browser process UI thread.
|
||||
///
|
||||
int(CEF_CALLBACK* get_extensions)(struct _cef_request_context_t* self,
|
||||
cef_string_list_t extension_ids);
|
||||
|
||||
///
|
||||
// Returns the extension matching |extension_id| or NULL if no matching
|
||||
// extension is accessible in this context (see HasExtension). This function
|
||||
// must be called on the browser process UI thread.
|
||||
///
|
||||
struct _cef_extension_t*(CEF_CALLBACK* get_extension)(
|
||||
struct _cef_request_context_t* self,
|
||||
const cef_string_t* extension_id);
|
||||
} cef_request_context_t;
|
||||
|
||||
///
|
||||
|
@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=9359e227c9d534c9c612d2ede790136461836501$
|
||||
// $hash=5a72321dd65325d93c1f920b08fc6bd462e74bdf$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_CONTEXT_HANDLER_CAPI_H_
|
||||
@ -48,6 +48,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct _cef_request_context_t;
|
||||
|
||||
///
|
||||
// Implement this structure to provide handler implementations. The handler
|
||||
// instance will not be released until all objects related to the context have
|
||||
@ -59,6 +61,14 @@ typedef struct _cef_request_context_handler_t {
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
// Called on the browser process UI thread immediately after the request
|
||||
// context has been initialized.
|
||||
///
|
||||
void(CEF_CALLBACK* on_request_context_initialized)(
|
||||
struct _cef_request_context_handler_t* self,
|
||||
struct _cef_request_context_t* request_context);
|
||||
|
||||
///
|
||||
// Called on the browser process IO thread to retrieve the cookie manager. If
|
||||
// this function returns NULL the default cookie manager retrievable via
|
||||
|
@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=a2b3912f8188f19f3d5109aec1b1d03227e31429$
|
||||
// $hash=bf895e77fc8bfc4760c17e2ec32d74a5cd9a91a1$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_MENU_BUTTON_DELEGATE_CAPI_H_
|
||||
@ -48,6 +48,16 @@ extern "C" {
|
||||
|
||||
struct _cef_menu_button_t;
|
||||
|
||||
///
|
||||
// MenuButton pressed lock is released when this object is destroyed.
|
||||
///
|
||||
typedef struct _cef_menu_button_pressed_lock_t {
|
||||
///
|
||||
// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
} cef_menu_button_pressed_lock_t;
|
||||
|
||||
///
|
||||
// Implement this structure to handle MenuButton events. The functions of this
|
||||
// structure will be called on the browser process UI thread unless otherwise
|
||||
@ -61,12 +71,15 @@ typedef struct _cef_menu_button_delegate_t {
|
||||
|
||||
///
|
||||
// Called when |button| is pressed. Call cef_menu_button_t::show_menu() to
|
||||
// show the resulting menu at |screen_point|.
|
||||
// show a popup menu at |screen_point|. When showing a custom popup such as a
|
||||
// window keep a reference to |button_pressed_lock| until the popup is hidden
|
||||
// to maintain the pressed button state.
|
||||
///
|
||||
void(CEF_CALLBACK* on_menu_button_pressed)(
|
||||
struct _cef_menu_button_delegate_t* self,
|
||||
struct _cef_menu_button_t* menu_button,
|
||||
const cef_point_t* screen_point);
|
||||
const cef_point_t* screen_point,
|
||||
struct _cef_menu_button_pressed_lock_t* button_pressed_lock);
|
||||
} cef_menu_button_delegate_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=e4957abc4c3b80b9f324d74d2c8c6aa2632c52d9$
|
||||
// $hash=5664bec47eefda37f8adb7bd153620559116f4a9$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_DELEGATE_CAPI_H_
|
||||
@ -73,6 +73,20 @@ typedef struct _cef_window_delegate_t {
|
||||
void(CEF_CALLBACK* on_window_destroyed)(struct _cef_window_delegate_t* self,
|
||||
struct _cef_window_t* window);
|
||||
|
||||
///
|
||||
// Return the parent for |window| or NULL if the |window| does not have a
|
||||
// parent. Windows with parents will not get a taskbar button. Set |is_menu|
|
||||
// to true (1) if |window| will be displayed as a menu, in which case it will
|
||||
// not be clipped to the parent window bounds. Set |can_activate_menu| to
|
||||
// false (0) if |is_menu| is true (1) and |window| should not be activated
|
||||
// (given keyboard focus) when displayed.
|
||||
///
|
||||
struct _cef_window_t*(CEF_CALLBACK* get_parent_window)(
|
||||
struct _cef_window_delegate_t* self,
|
||||
struct _cef_window_t* window,
|
||||
int* is_menu,
|
||||
int* can_activate_menu);
|
||||
|
||||
///
|
||||
// Return true (1) if |window| should be created without a frame or title bar.
|
||||
// The window will be resizable if can_resize() returns true (1). Use
|
||||
|
@ -115,7 +115,8 @@ class CefBrowser : public virtual CefBaseRefCounted {
|
||||
virtual void StopLoad() = 0;
|
||||
|
||||
///
|
||||
// Returns the globally unique identifier for this browser.
|
||||
// Returns the globally unique identifier for this browser. This value is also
|
||||
// used as the tabId for extension APIs.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual int GetIdentifier() = 0;
|
||||
@ -832,6 +833,31 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void SetAccessibilityState(cef_state_t accessibility_state) = 0;
|
||||
|
||||
///
|
||||
// Enable notifications of auto resize via CefDisplayHandler::OnAutoResize.
|
||||
// Notifications are disabled by default. |min_size| and |max_size| define the
|
||||
// range of allowed sizes.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void SetAutoResizeEnabled(bool enabled,
|
||||
const CefSize& min_size,
|
||||
const CefSize& max_size) = 0;
|
||||
|
||||
///
|
||||
// Returns the extension hosted in this browser or NULL if no extension is
|
||||
// hosted. See CefRequestContext::LoadExtension for details.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefExtension> GetExtension() = 0;
|
||||
|
||||
///
|
||||
// Returns true if this browser is hosting an extension background script.
|
||||
// Background hosts do not have a window and are not displayable. See
|
||||
// CefRequestContext::LoadExtension for details.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsBackgroundHost() = 0;
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_CEF_BROWSER_H_
|
||||
|
@ -114,6 +114,18 @@ class CefDisplayHandler : public virtual CefBaseRefCounted {
|
||||
int line) {
|
||||
return false;
|
||||
}
|
||||
|
||||
///
|
||||
// Called when auto-resize is enabled via CefBrowserHost::SetAutoResizeEnabled
|
||||
// and the contents have auto-resized. |new_size| will be the desired size in
|
||||
// view coordinates. Return true if the resize was handled or false for
|
||||
// default handling.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool OnAutoResize(CefRefPtr<CefBrowser> browser,
|
||||
const CefSize& new_size) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_CEF_DISPLAY_HANDLER_H_
|
||||
|
117
include/cef_extension.h
Normal file
117
include/cef_extension.h
Normal file
@ -0,0 +1,117 @@
|
||||
// Copyright (c) 2017 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_EXTENSION_H_
|
||||
#define CEF_INCLUDE_CEF_EXTENSION_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/cef_base.h"
|
||||
#include "include/cef_values.h"
|
||||
|
||||
class CefExtensionHandler;
|
||||
class CefRequestContext;
|
||||
|
||||
///
|
||||
// Object representing an extension. Methods may be called on any thread unless
|
||||
// otherwise indicated.
|
||||
///
|
||||
/*--cef(source=library)--*/
|
||||
class CefExtension : public CefBaseRefCounted {
|
||||
public:
|
||||
///
|
||||
// Returns the unique extension identifier. This is calculated based on the
|
||||
// extension public key, if available, or on the extension path. See
|
||||
// https://developer.chrome.com/extensions/manifest/key for details.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefString GetIdentifier() = 0;
|
||||
|
||||
///
|
||||
// Returns the absolute path to the extension directory on disk. This value
|
||||
// will be prefixed with PK_DIR_RESOURCES if a relative path was passed to
|
||||
// CefRequestContext::LoadExtension.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefString GetPath() = 0;
|
||||
|
||||
///
|
||||
// Returns the extension manifest contents as a CefDictionaryValue object. See
|
||||
// https://developer.chrome.com/extensions/manifest for details.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefDictionaryValue> GetManifest() = 0;
|
||||
|
||||
///
|
||||
// Returns true if this object is the same extension as |that| object.
|
||||
// Extensions are considered the same if identifier, path and loader context
|
||||
// match.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsSame(CefRefPtr<CefExtension> that) = 0;
|
||||
|
||||
///
|
||||
// Returns the handler for this extension. Will return NULL for internal
|
||||
// extensions or if no handler was passed to CefRequestContext::LoadExtension.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefExtensionHandler> GetHandler() = 0;
|
||||
|
||||
///
|
||||
// Returns the request context that loaded this extension. Will return NULL
|
||||
// for internal extensions or if the extension has been unloaded. See the
|
||||
// CefRequestContext::LoadExtension documentation for more information about
|
||||
// loader contexts. Must be called on the browser process UI thread.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefRequestContext> GetLoaderContext() = 0;
|
||||
|
||||
///
|
||||
// Returns true if this extension is currently loaded. Must be called on the
|
||||
// browser process UI thread.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsLoaded() = 0;
|
||||
|
||||
///
|
||||
// Unload this extension if it is not an internal extension and is currently
|
||||
// loaded. Will result in a call to CefExtensionHandler::OnExtensionUnloaded
|
||||
// on success.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void Unload() = 0;
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_CEF_EXTENSION_H_
|
172
include/cef_extension_handler.h
Normal file
172
include/cef_extension_handler.h
Normal file
@ -0,0 +1,172 @@
|
||||
// Copyright (c) 2017 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_EXTENSION_HANDLER_H_
|
||||
#define CEF_INCLUDE_CEF_EXTENSION_HANDLER_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/cef_base.h"
|
||||
#include "include/cef_browser.h"
|
||||
#include "include/cef_extension.h"
|
||||
#include "include/cef_stream.h"
|
||||
|
||||
class CefClient;
|
||||
|
||||
///
|
||||
// Callback interface used for asynchronous continuation of
|
||||
// CefExtensionHandler::GetExtensionResource.
|
||||
///
|
||||
/*--cef(source=library)--*/
|
||||
class CefGetExtensionResourceCallback : public CefBaseRefCounted {
|
||||
public:
|
||||
///
|
||||
// Continue the request. Read the resource contents from |stream|.
|
||||
///
|
||||
/*--cef(capi_name=cont,optional_param=stream)--*/
|
||||
virtual void Continue(CefRefPtr<CefStreamReader> stream) = 0;
|
||||
|
||||
///
|
||||
// Cancel the request.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void Cancel() = 0;
|
||||
};
|
||||
|
||||
///
|
||||
// Implement this interface to handle events related to browser extensions.
|
||||
// The methods of this class will be called on the UI thread. See
|
||||
// CefRequestContext::LoadExtension for information about extension loading.
|
||||
///
|
||||
/*--cef(source=client)--*/
|
||||
class CefExtensionHandler : public virtual CefBaseRefCounted {
|
||||
public:
|
||||
///
|
||||
// Called if the CefRequestContext::LoadExtension request fails. |result| will
|
||||
// be the error code.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void OnExtensionLoadFailed(cef_errorcode_t result) {}
|
||||
|
||||
///
|
||||
// Called if the CefRequestContext::LoadExtension request succeeds.
|
||||
// |extension| is the loaded extension.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void OnExtensionLoaded(CefRefPtr<CefExtension> extension) {}
|
||||
|
||||
///
|
||||
// Called after the CefExtension::Unload request has completed.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void OnExtensionUnloaded(CefRefPtr<CefExtension> extension) {}
|
||||
|
||||
///
|
||||
// Called when an extension needs a browser to host a background script
|
||||
// specified via the "background" manifest key. The browser will have no
|
||||
// visible window and cannot be displayed. |extension| is the extension that
|
||||
// is loading the background script. |url| is an internally generated
|
||||
// reference to an HTML page that will be used to load the background script
|
||||
// via a <script> src attribute. To allow creation of the browser optionally
|
||||
// modify |client| and |settings| and return false. To cancel creation of the
|
||||
// browser (and consequently cancel load of the background script) return
|
||||
// true. Successful creation will be indicated by a call to
|
||||
// CefLifeSpanHandler::OnAfterCreated, and CefBrowserHost::IsBackgroundHost
|
||||
// will return true for the resulting browser. See
|
||||
// https://developer.chrome.com/extensions/event_pages for more information
|
||||
// about extension background script usage.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool OnBeforeBackgroundBrowser(CefRefPtr<CefExtension> extension,
|
||||
const CefString& url,
|
||||
CefRefPtr<CefClient>& client,
|
||||
CefBrowserSettings& settings) {
|
||||
return false;
|
||||
}
|
||||
|
||||
///
|
||||
// Called when no tabId is specified to an extension API call that accepts a
|
||||
// tabId parameter (e.g. chrome.tabs.*). |extension| and |browser| are the
|
||||
// source of the API call. Return the browser that will be acted on by the API
|
||||
// call or return NULL to act on |browser|. The returned browser must share
|
||||
// the same CefRequestContext as |browser|. Incognito browsers should not be
|
||||
// considered unless the source extension has incognito access enabled, in
|
||||
// which case |include_incognito| will be true.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefBrowser> GetActiveBrowser(
|
||||
CefRefPtr<CefExtension> extension,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
bool include_incognito) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
///
|
||||
// Called when the tabId associated with |target_browser| is specified to an
|
||||
// extension API call that accepts a tabId parameter (e.g. chrome.tabs.*).
|
||||
// |extension| and |browser| are the source of the API call. Return true
|
||||
// to allow access of false to deny access. Access to incognito browsers
|
||||
// should not be allowed unless the source extension has incognito access
|
||||
// enabled, in which case |include_incognito| will be true.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool CanAccessBrowser(CefRefPtr<CefExtension> extension,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
bool include_incognito,
|
||||
CefRefPtr<CefBrowser> target_browser) {
|
||||
return true;
|
||||
}
|
||||
|
||||
///
|
||||
// Called to retrieve an extension resource that would normally be loaded from
|
||||
// disk (e.g. if a file parameter is specified to chrome.tabs.executeScript).
|
||||
// |extension| and |browser| are the source of the resource request. |file| is
|
||||
// the requested relative file path. To handle the resource request return
|
||||
// true and execute |callback| either synchronously or asynchronously. For the
|
||||
// default behavior which reads the resource from the extension directory on
|
||||
// disk return false. Localization substitutions will not be applied to
|
||||
// resources handled via this method.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool GetExtensionResource(
|
||||
CefRefPtr<CefExtension> extension,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
const CefString& file,
|
||||
CefRefPtr<CefGetExtensionResourceCallback> callback) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_CEF_EXTENSION_HANDLER_H_
|
@ -42,6 +42,8 @@
|
||||
|
||||
#include "include/cef_callback.h"
|
||||
#include "include/cef_cookie.h"
|
||||
#include "include/cef_extension.h"
|
||||
#include "include/cef_extension_handler.h"
|
||||
#include "include/cef_request_context_handler.h"
|
||||
#include "include/cef_values.h"
|
||||
|
||||
@ -54,9 +56,9 @@ class CefSchemeHandlerFactory;
|
||||
class CefResolveCallback : public virtual CefBaseRefCounted {
|
||||
public:
|
||||
///
|
||||
// Called after the ResolveHost request has completed. |result| will be the
|
||||
// result code. |resolved_ips| will be the list of resolved IP addresses or
|
||||
// empty if the resolution failed.
|
||||
// Called on the UI thread after the ResolveHost request has completed.
|
||||
// |result| will be the result code. |resolved_ips| will be the list of
|
||||
// resolved IP addresses or empty if the resolution failed.
|
||||
///
|
||||
/*--cef(optional_param=resolved_ips)--*/
|
||||
virtual void OnResolveCompleted(
|
||||
@ -278,6 +280,92 @@ class CefRequestContext : public virtual CefBaseRefCounted {
|
||||
virtual cef_errorcode_t ResolveHostCached(
|
||||
const CefString& origin,
|
||||
std::vector<CefString>& resolved_ips) = 0;
|
||||
|
||||
///
|
||||
// Load an extension.
|
||||
//
|
||||
// If extension resources will be read from disk using the default load
|
||||
// implementation then |root_directory| should be the absolute path to the
|
||||
// extension resources directory and |manifest| should be NULL. If extension
|
||||
// resources will be provided by the client (e.g. via CefRequestHandler and/or
|
||||
// CefExtensionHandler) then |root_directory| should be a path component
|
||||
// unique to the extension (if not absolute this will be internally prefixed
|
||||
// with the PK_DIR_RESOURCES path) and |manifest| should contain the contents
|
||||
// that would otherwise be read from the "manifest.json" file on disk.
|
||||
//
|
||||
// The loaded extension will be accessible in all contexts sharing the same
|
||||
// storage (HasExtension returns true). However, only the context on which
|
||||
// this method was called is considered the loader (DidLoadExtension returns
|
||||
// true) and only the loader will receive CefRequestContextHandler callbacks
|
||||
// for the extension.
|
||||
//
|
||||
// CefExtensionHandler::OnExtensionLoaded will be called on load success or
|
||||
// CefExtensionHandler::OnExtensionLoadFailed will be called on load failure.
|
||||
//
|
||||
// If the extension specifies a background script via the "background"
|
||||
// manifest key then CefExtensionHandler::OnBeforeBackgroundBrowser will be
|
||||
// called to create the background browser. See that method for additional
|
||||
// information about background scripts.
|
||||
//
|
||||
// For visible extension views the client application should evaluate the
|
||||
// manifest to determine the correct extension URL to load and then pass that
|
||||
// URL to the CefBrowserHost::CreateBrowser* function after the extension has
|
||||
// loaded. For example, the client can look for the "browser_action" manifest
|
||||
// key as documented at https://developer.chrome.com/extensions/browserAction.
|
||||
// Extension URLs take the form "chrome-extension://<extension_id>/<path>".
|
||||
//
|
||||
// Browsers that host extensions differ from normal browsers as follows:
|
||||
// - Can access chrome.* JavaScript APIs if allowed by the manifest. Visit
|
||||
// chrome://extensions-support for the list of extension APIs currently
|
||||
// supported by CEF.
|
||||
// - Main frame navigation to non-extension content is blocked.
|
||||
// - Pinch-zooming is disabled.
|
||||
// - CefBrowserHost::GetExtension returns the hosted extension.
|
||||
// - CefBrowserHost::IsBackgroundHost returns true for background hosts.
|
||||
//
|
||||
// See https://developer.chrome.com/extensions for extension implementation
|
||||
// and usage documentation.
|
||||
///
|
||||
/*--cef(optional_param=manifest,optional_param=handler)--*/
|
||||
virtual void LoadExtension(const CefString& root_directory,
|
||||
CefRefPtr<CefDictionaryValue> manifest,
|
||||
CefRefPtr<CefExtensionHandler> handler) = 0;
|
||||
|
||||
///
|
||||
// Returns true if this context was used to load the extension identified by
|
||||
// |extension_id|. Other contexts sharing the same storage will also have
|
||||
// access to the extension (see HasExtension). This method must be called on
|
||||
// the browser process UI thread.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool DidLoadExtension(const CefString& extension_id) = 0;
|
||||
|
||||
///
|
||||
// Returns true if this context has access to the extension identified by
|
||||
// |extension_id|. This may not be the context that was used to load the
|
||||
// extension (see DidLoadExtension). This method must be called on the browser
|
||||
// process UI thread.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool HasExtension(const CefString& extension_id) = 0;
|
||||
|
||||
///
|
||||
// Retrieve the list of all extensions that this context has access to (see
|
||||
// HasExtension). |extension_ids| will be populated with the list of extension
|
||||
// ID values. Returns true on success. This method must be called on the
|
||||
// browser process UI thread.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool GetExtensions(std::vector<CefString>& extension_ids) = 0;
|
||||
|
||||
///
|
||||
// Returns the extension matching |extension_id| or NULL if no matching
|
||||
// extension is accessible in this context (see HasExtension). This method
|
||||
// must be called on the browser process UI thread.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefExtension> GetExtension(
|
||||
const CefString& extension_id) = 0;
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_CEF_REQUEST_CONTEXT_H_
|
||||
|
@ -42,6 +42,8 @@
|
||||
#include "include/cef_cookie.h"
|
||||
#include "include/cef_web_plugin.h"
|
||||
|
||||
class CefRequestContext;
|
||||
|
||||
///
|
||||
// Implement this interface to provide handler implementations. The handler
|
||||
// instance will not be released until all objects related to the context have
|
||||
@ -52,6 +54,14 @@ class CefRequestContextHandler : public virtual CefBaseRefCounted {
|
||||
public:
|
||||
typedef cef_plugin_policy_t PluginPolicy;
|
||||
|
||||
///
|
||||
// Called on the browser process UI thread immediately after the request
|
||||
// context has been initialized.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void OnRequestContextInitialized(
|
||||
CefRefPtr<CefRequestContext> request_context) {}
|
||||
|
||||
///
|
||||
// Called on the browser process IO thread to retrieve the cookie manager. If
|
||||
// this method returns NULL the default cookie manager retrievable via
|
||||
|
@ -840,6 +840,12 @@ typedef enum {
|
||||
// and "~/Library/Application Support" directory on Mac OS X.
|
||||
///
|
||||
PK_USER_DATA,
|
||||
|
||||
///
|
||||
// Directory containing application resources. Can be configured via
|
||||
// CefSettings.resources_dir_path.
|
||||
///
|
||||
PK_DIR_RESOURCES,
|
||||
} cef_path_key_t;
|
||||
|
||||
///
|
||||
|
@ -42,6 +42,12 @@
|
||||
|
||||
class CefMenuButton;
|
||||
|
||||
///
|
||||
// MenuButton pressed lock is released when this object is destroyed.
|
||||
///
|
||||
/*--cef(source=library)--*/
|
||||
class CefMenuButtonPressedLock : public CefBaseRefCounted {};
|
||||
|
||||
///
|
||||
// Implement this interface to handle MenuButton events. The methods of this
|
||||
// class will be called on the browser process UI thread unless otherwise
|
||||
@ -51,12 +57,16 @@ class CefMenuButton;
|
||||
class CefMenuButtonDelegate : public CefButtonDelegate {
|
||||
public:
|
||||
///
|
||||
// Called when |button| is pressed. Call CefMenuButton::ShowMenu() to show the
|
||||
// resulting menu at |screen_point|.
|
||||
// Called when |button| is pressed. Call CefMenuButton::ShowMenu() to show a
|
||||
// popup menu at |screen_point|. When showing a custom popup such as a window
|
||||
// keep a reference to |button_pressed_lock| until the popup is hidden to
|
||||
// maintain the pressed button state.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void OnMenuButtonPressed(CefRefPtr<CefMenuButton> menu_button,
|
||||
const CefPoint& screen_point) = 0;
|
||||
virtual void OnMenuButtonPressed(
|
||||
CefRefPtr<CefMenuButton> menu_button,
|
||||
const CefPoint& screen_point,
|
||||
CefRefPtr<CefMenuButtonPressedLock> button_pressed_lock) = 0;
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_VIEWS_CEF_MENU_BUTTON_DELEGATE_H_
|
||||
|
@ -63,6 +63,21 @@ class CefWindowDelegate : public CefPanelDelegate {
|
||||
/*--cef()--*/
|
||||
virtual void OnWindowDestroyed(CefRefPtr<CefWindow> window) {}
|
||||
|
||||
///
|
||||
// Return the parent for |window| or NULL if the |window| does not have a
|
||||
// parent. Windows with parents will not get a taskbar button. Set |is_menu|
|
||||
// to true if |window| will be displayed as a menu, in which case it will not
|
||||
// be clipped to the parent window bounds. Set |can_activate_menu| to false
|
||||
// if |is_menu| is true and |window| should not be activated (given keyboard
|
||||
// focus) when displayed.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefWindow> GetParentWindow(CefRefPtr<CefWindow> window,
|
||||
bool* is_menu,
|
||||
bool* can_activate_menu) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
///
|
||||
// Return true if |window| should be created without a frame or title bar. The
|
||||
// window will be resizable if CanResize() returns true. Use
|
||||
|
Reference in New Issue
Block a user