- Update to Chromium revision 133430.
- Move custom scheme registration to CefApp::OnRegisterCustomSchemes(). This is required by the introduction of ContentClient::AddAdditionalSchemes() and fixes a race condition when registering standard schemes in different processes. - Execute V8 functions using V8Proxy. This is required for inspector instrumentation to work correctly and fixes an assertion in WebCore related to V8RecursionScope. - Enable verbose V8 TryCatch logging. - Mac: Expose UnderlayOpenGLHostingWindow interface that should be used for all CEF windows. - Add CefSettings.remote_debugging_port option. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@602 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
97561ac51a
commit
6c8f4644aa
|
@ -17,5 +17,5 @@
|
|||
|
||||
{
|
||||
'chromium_url': 'http://src.chromium.org/svn/trunk/src',
|
||||
'chromium_revision': '131752',
|
||||
'chromium_revision': '133430',
|
||||
}
|
||||
|
|
11
cef.gyp
11
cef.gyp
|
@ -802,7 +802,6 @@
|
|||
'libcef/browser/resource_request_job.cc',
|
||||
'libcef/browser/resource_request_job.h',
|
||||
'libcef/browser/scheme_impl.cc',
|
||||
'libcef/browser/scheme_impl.h',
|
||||
'libcef/browser/sqlite_diagnostics_stub.cc',
|
||||
'libcef/browser/stream_impl.cc',
|
||||
'libcef/browser/stream_impl.h',
|
||||
|
@ -840,6 +839,8 @@
|
|||
'libcef/common/response_impl.h',
|
||||
'libcef/common/response_manager.cc',
|
||||
'libcef/common/response_manager.h',
|
||||
'libcef/common/scheme_registrar_impl.cc',
|
||||
'libcef/common/scheme_registrar_impl.h',
|
||||
'libcef/common/string_list_impl.cc',
|
||||
'libcef/common/string_map_impl.cc',
|
||||
'libcef/common/string_multimap_impl.cc',
|
||||
|
@ -862,8 +863,6 @@
|
|||
'libcef/renderer/content_renderer_client.h',
|
||||
'libcef/renderer/frame_impl.cc',
|
||||
'libcef/renderer/frame_impl.h',
|
||||
'libcef/renderer/render_message_filter.cc',
|
||||
'libcef/renderer/render_message_filter.h',
|
||||
'libcef/renderer/render_process_observer.cc',
|
||||
'libcef/renderer/render_process_observer.h',
|
||||
'libcef/renderer/thread_util.h',
|
||||
|
@ -1053,11 +1052,17 @@
|
|||
'sources': [
|
||||
'tests/cefclient/client_app.cpp',
|
||||
'tests/cefclient/client_app.h',
|
||||
'tests/cefclient/client_switches.cpp',
|
||||
'tests/cefclient/client_switches.h',
|
||||
'tests/cefclient/process_helper_mac.cpp',
|
||||
'tests/unittests/client_app_delegates.cc',
|
||||
'tests/unittests/cookie_unittest.cc',
|
||||
'tests/unittests/process_message_unittest.cc',
|
||||
'tests/unittests/scheme_handler_unittest.cc',
|
||||
'tests/unittests/test_handler.cc',
|
||||
'tests/unittests/test_handler.h',
|
||||
'tests/unittests/test_suite.cc',
|
||||
'tests/unittests/test_suite.h',
|
||||
'tests/unittests/test_util.cc',
|
||||
'tests/unittests/test_util.h',
|
||||
'tests/unittests/v8_unittest.cc',
|
||||
|
|
|
@ -150,6 +150,8 @@
|
|||
'libcef_dll/cpptoc/response_cpptoc.h',
|
||||
'libcef_dll/ctocpp/scheme_handler_factory_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/scheme_handler_factory_ctocpp.h',
|
||||
'libcef_dll/cpptoc/scheme_registrar_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/scheme_registrar_cpptoc.h',
|
||||
'libcef_dll/cpptoc/stream_reader_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/stream_reader_cpptoc.h',
|
||||
'libcef_dll/cpptoc/stream_writer_cpptoc.cc',
|
||||
|
@ -246,6 +248,8 @@
|
|||
'libcef_dll/ctocpp/response_ctocpp.h',
|
||||
'libcef_dll/cpptoc/scheme_handler_factory_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/scheme_handler_factory_cpptoc.h',
|
||||
'libcef_dll/ctocpp/scheme_registrar_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/scheme_registrar_ctocpp.h',
|
||||
'libcef_dll/ctocpp/stream_reader_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/stream_reader_ctocpp.h',
|
||||
'libcef_dll/ctocpp/stream_writer_ctocpp.cc',
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
'variables': {
|
||||
'includes_common': [
|
||||
'include/cef_base.h',
|
||||
'include/cef_pack_resources.h',
|
||||
'include/cef_pack_strings.h',
|
||||
'include/cef_runnable.h',
|
||||
'include/cef_version.h',
|
||||
'include/internal/cef_build.h',
|
||||
|
@ -130,6 +132,8 @@
|
|||
'tests/cefclient/process_helper_mac.cpp',
|
||||
'tests/cefclient/resource_util.h',
|
||||
'tests/cefclient/resource_util_mac.mm',
|
||||
'tests/cefclient/scheme_test.cpp',
|
||||
'tests/cefclient/scheme_test.h',
|
||||
'tests/cefclient/string_util.cpp',
|
||||
'tests/cefclient/string_util.h',
|
||||
'tests/cefclient/util.h',
|
||||
|
|
|
@ -125,6 +125,15 @@ typedef struct _cef_app_t {
|
|||
struct _cef_app_t* self, const cef_string_t* process_type,
|
||||
struct _cef_command_line_t* command_line);
|
||||
|
||||
///
|
||||
// Provides an opportunity to register custom schemes. Do not keep a reference
|
||||
// to the |registrar| object. This function is called on the main thread for
|
||||
// each process and the registered schemes should be the same across all
|
||||
// processes.
|
||||
///
|
||||
void (CEF_CALLBACK *on_register_custom_schemes)(struct _cef_app_t* self,
|
||||
struct _cef_scheme_registrar_t* registrar);
|
||||
|
||||
///
|
||||
// Return the handler for render process events. This function is called by
|
||||
// the render process main thread.
|
||||
|
|
|
@ -144,8 +144,8 @@ typedef struct _cef_frame_t {
|
|||
// reporting.
|
||||
///
|
||||
void (CEF_CALLBACK *execute_java_script)(struct _cef_frame_t* self,
|
||||
const cef_string_t* jsCode, const cef_string_t* scriptUrl,
|
||||
int startLine);
|
||||
const cef_string_t* code, const cef_string_t* script_url,
|
||||
int start_line);
|
||||
|
||||
///
|
||||
// Returns true (1) if this is the main (top-level) frame.
|
||||
|
|
|
@ -45,53 +45,6 @@ extern "C" {
|
|||
#include "include/capi/cef_base_capi.h"
|
||||
|
||||
|
||||
///
|
||||
// Register a custom scheme. This function should not be called for the built-in
|
||||
// HTTP, HTTPS, FILE, FTP, ABOUT and DATA schemes.
|
||||
//
|
||||
// If |is_standard| is true (1) the scheme will be treated as a standard scheme.
|
||||
// Standard schemes are subject to URL canonicalization and parsing rules as
|
||||
// defined in the Common Internet Scheme Syntax RFC 1738 Section 3.1 available
|
||||
// at http://www.ietf.org/rfc/rfc1738.txt
|
||||
//
|
||||
// In particular, the syntax for standard scheme URLs must be of the form: <pre>
|
||||
// [scheme]://[username]:[password]@[host]:[port]/[url-path]
|
||||
// </pre> Standard scheme URLs must have a host component that is a fully
|
||||
// qualified domain name as defined in Section 3.5 of RFC 1034 [13] and Section
|
||||
// 2.1 of RFC 1123. These URLs will be canonicalized to "scheme://host/path" in
|
||||
// the simplest case and "scheme://username:password@host:port/path" in the most
|
||||
// explicit case. For example, "scheme:host/path" and "scheme:///host/path" will
|
||||
// both be canonicalized to "scheme://host/path". The origin of a standard
|
||||
// scheme URL is the combination of scheme, host and port (i.e.,
|
||||
// "scheme://host:port" in the most explicit case).
|
||||
//
|
||||
// For non-standard scheme URLs only the "scheme:" component is parsed and
|
||||
// canonicalized. The remainder of the URL will be passed to the handler as-is.
|
||||
// For example, "scheme:///some%20text" will remain the same. Non-standard
|
||||
// scheme URLs cannot be used as a target for form submission.
|
||||
//
|
||||
// If |is_local| is true (1) the scheme will be treated as local (i.e., with the
|
||||
// same security rules as those applied to "file" URLs). Normal pages cannot
|
||||
// link to or access local URLs. Also, by default, local URLs can only perform
|
||||
// XMLHttpRequest calls to the same URL (origin + path) that originated the
|
||||
// request. To allow XMLHttpRequest calls from a local URL to other URLs with
|
||||
// the same origin set the CefSettings.file_access_from_file_urls_allowed value
|
||||
// to true (1). To allow XMLHttpRequest calls from a local URL to all origins
|
||||
// set the CefSettings.universal_access_from_file_urls_allowed value to true
|
||||
// (1).
|
||||
//
|
||||
// If |is_display_isolated| is true (1) the scheme will be treated as display-
|
||||
// isolated. This means that pages cannot display these URLs unless they are
|
||||
// from the same scheme. For example, pages in another origin cannot create
|
||||
// iframes or hyperlinks to URLs with this scheme.
|
||||
//
|
||||
// This function may be called on any thread. It should only be called once per
|
||||
// unique |scheme_name| value. If |scheme_name| is already registered or if an
|
||||
// error occurs this function will return false (0).
|
||||
///
|
||||
CEF_EXPORT int cef_register_custom_scheme(const cef_string_t* scheme_name,
|
||||
int is_standard, int is_local, int is_display_isolated);
|
||||
|
||||
///
|
||||
// Register a scheme handler factory for the specified |scheme_name| and
|
||||
// optional |domain_name|. An NULL |domain_name| value for a standard scheme
|
||||
|
@ -99,7 +52,7 @@ CEF_EXPORT int cef_register_custom_scheme(const cef_string_t* scheme_name,
|
|||
// will be ignored for non-standard schemes. If |scheme_name| is a built-in
|
||||
// scheme and no handler is returned by |factory| then the built-in scheme
|
||||
// handler factory will be called. If |scheme_name| is a custom scheme the
|
||||
// cef_register_custom_scheme() function should be called for that scheme. This
|
||||
// CefRegisterCustomScheme() function should be called for that scheme. This
|
||||
// function may be called multiple times to change or remove the factory that
|
||||
// matches the specified |scheme_name| and optional |domain_name|. Returns false
|
||||
// (0) if an error occurs. This function may be called on any thread.
|
||||
|
@ -114,6 +67,67 @@ CEF_EXPORT int cef_register_scheme_handler_factory(
|
|||
///
|
||||
CEF_EXPORT int cef_clear_scheme_handler_factories();
|
||||
|
||||
///
|
||||
// Structure that manages custom scheme registrations.
|
||||
///
|
||||
typedef struct _cef_scheme_registrar_t {
|
||||
///
|
||||
// Base structure.
|
||||
///
|
||||
cef_base_t base;
|
||||
|
||||
///
|
||||
// Register a custom scheme. This function should not be called for the built-
|
||||
// in HTTP, HTTPS, FILE, FTP, ABOUT and DATA schemes.
|
||||
//
|
||||
// If |is_standard| is true (1) the scheme will be treated as a standard
|
||||
// scheme. Standard schemes are subject to URL canonicalization and parsing
|
||||
// rules as defined in the Common Internet Scheme Syntax RFC 1738 Section 3.1
|
||||
// available at http://www.ietf.org/rfc/rfc1738.txt
|
||||
//
|
||||
// In particular, the syntax for standard scheme URLs must be of the form:
|
||||
// <pre>
|
||||
// [scheme]://[username]:[password]@[host]:[port]/[url-path]
|
||||
// </pre> Standard scheme URLs must have a host component that is a fully
|
||||
// qualified domain name as defined in Section 3.5 of RFC 1034 [13] and
|
||||
// Section 2.1 of RFC 1123. These URLs will be canonicalized to
|
||||
// "scheme://host/path" in the simplest case and
|
||||
// "scheme://username:password@host:port/path" in the most explicit case. For
|
||||
// example, "scheme:host/path" and "scheme:///host/path" will both be
|
||||
// canonicalized to "scheme://host/path". The origin of a standard scheme URL
|
||||
// is the combination of scheme, host and port (i.e., "scheme://host:port" in
|
||||
// the most explicit case).
|
||||
//
|
||||
// For non-standard scheme URLs only the "scheme:" component is parsed and
|
||||
// canonicalized. The remainder of the URL will be passed to the handler as-
|
||||
// is. For example, "scheme:///some%20text" will remain the same. Non-standard
|
||||
// scheme URLs cannot be used as a target for form submission.
|
||||
//
|
||||
// If |is_local| is true (1) the scheme will be treated as local (i.e., with
|
||||
// the same security rules as those applied to "file" URLs). Normal pages
|
||||
// cannot link to or access local URLs. Also, by default, local URLs can only
|
||||
// perform XMLHttpRequest calls to the same URL (origin + path) that
|
||||
// originated the request. To allow XMLHttpRequest calls from a local URL to
|
||||
// other URLs with the same origin set the
|
||||
// CefSettings.file_access_from_file_urls_allowed value to true (1). To allow
|
||||
// XMLHttpRequest calls from a local URL to all origins set the
|
||||
// CefSettings.universal_access_from_file_urls_allowed value to true (1).
|
||||
//
|
||||
// If |is_display_isolated| is true (1) the scheme will be treated as display-
|
||||
// isolated. This means that pages cannot display these URLs unless they are
|
||||
// from the same scheme. For example, pages in another origin cannot create
|
||||
// iframes or hyperlinks to URLs with this scheme.
|
||||
//
|
||||
// This function may be called on any thread. It should only be called once
|
||||
// per unique |scheme_name| value. If |scheme_name| is already registered or
|
||||
// if an error occurs this function will return false (0).
|
||||
///
|
||||
int (CEF_CALLBACK *add_custom_scheme)(struct _cef_scheme_registrar_t* self,
|
||||
const cef_string_t* scheme_name, int is_standard, int is_local,
|
||||
int is_display_isolated);
|
||||
} cef_scheme_registrar_t;
|
||||
|
||||
|
||||
///
|
||||
// Structure that creates cef_resource_handler_t instances for handling scheme
|
||||
// requests. The functions of this structure will always be called on the IO
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "include/cef_proxy_handler.h"
|
||||
#include "include/cef_render_process_handler.h"
|
||||
#include "include/cef_resource_bundle_handler.h"
|
||||
#include "include/cef_scheme.h"
|
||||
|
||||
class CefApp;
|
||||
|
||||
|
@ -130,6 +131,17 @@ class CefApp : public virtual CefBase {
|
|||
CefRefPtr<CefCommandLine> command_line) {
|
||||
}
|
||||
|
||||
///
|
||||
// Provides an opportunity to register custom schemes. Do not keep a reference
|
||||
// to the |registrar| object. This method is called on the main thread for
|
||||
// each process and the registered schemes should be the same across all
|
||||
// processes.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void OnRegisterCustomSchemes(
|
||||
CefRefPtr<CefSchemeRegistrar> registrar) {
|
||||
}
|
||||
|
||||
///
|
||||
// Return the handler for render process events. This method is called by the
|
||||
// render process main thread.
|
||||
|
|
|
@ -66,9 +66,10 @@
|
|||
@end
|
||||
|
||||
// Copy of definition from ui/base/cocoa/underlay_opengl_hosting_window.h.
|
||||
@protocol UnderlayableSurface
|
||||
- (void)underlaySurfaceAdded;
|
||||
- (void)underlaySurfaceRemoved;
|
||||
// Common base class for windows that host a OpenGL surface that renders under
|
||||
// the window. Contains methods relating to hole punching so that the OpenGL
|
||||
// surface is visible through the window.
|
||||
@interface UnderlayOpenGLHostingWindow : NSWindow
|
||||
@end
|
||||
|
||||
// The Mac OS X 10.6 SDK introduced new protocols used for delegates. These
|
||||
|
@ -112,11 +113,6 @@ DEFINE_EMPTY_PROTOCOL(NSWindowDelegate)
|
|||
@protocol CefAppProtocol<CrAppControlProtocol>
|
||||
@end
|
||||
|
||||
// All CEF windows should implement this protocol to be informed explicitly
|
||||
// about underlay surfaces.
|
||||
@protocol CefUnderlayableSurface<UnderlayableSurface>
|
||||
@end
|
||||
|
||||
// Controls the state of |isHandlingSendEvent| in the event loop so that it is
|
||||
// reset properly.
|
||||
class CefScopedSendingEvent {
|
||||
|
|
|
@ -151,10 +151,10 @@ class CefFrame : public virtual CefBase {
|
|||
// error. The |start_line| parameter is the base line number to use for error
|
||||
// reporting.
|
||||
///
|
||||
/*--cef(optional_param=scriptUrl)--*/
|
||||
virtual void ExecuteJavaScript(const CefString& jsCode,
|
||||
const CefString& scriptUrl,
|
||||
int startLine) =0;
|
||||
/*--cef(optional_param=script_url)--*/
|
||||
virtual void ExecuteJavaScript(const CefString& code,
|
||||
const CefString& script_url,
|
||||
int start_line) =0;
|
||||
|
||||
///
|
||||
// Returns true if this is the main (top-level) frame.
|
||||
|
|
|
@ -47,56 +47,6 @@
|
|||
|
||||
class CefSchemeHandlerFactory;
|
||||
|
||||
///
|
||||
// Register a custom scheme. This method should not be called for the built-in
|
||||
// HTTP, HTTPS, FILE, FTP, ABOUT and DATA schemes.
|
||||
//
|
||||
// If |is_standard| is true the scheme will be treated as a standard scheme.
|
||||
// Standard schemes are subject to URL canonicalization and parsing rules as
|
||||
// defined in the Common Internet Scheme Syntax RFC 1738 Section 3.1 available
|
||||
// at http://www.ietf.org/rfc/rfc1738.txt
|
||||
//
|
||||
// In particular, the syntax for standard scheme URLs must be of the form:
|
||||
// <pre>
|
||||
// [scheme]://[username]:[password]@[host]:[port]/[url-path]
|
||||
// </pre>
|
||||
// Standard scheme URLs must have a host component that is a fully qualified
|
||||
// domain name as defined in Section 3.5 of RFC 1034 [13] and Section 2.1 of RFC
|
||||
// 1123. These URLs will be canonicalized to "scheme://host/path" in the
|
||||
// simplest case and "scheme://username:password@host:port/path" in the most
|
||||
// explicit case. For example, "scheme:host/path" and "scheme:///host/path" will
|
||||
// both be canonicalized to "scheme://host/path". The origin of a standard
|
||||
// scheme URL is the combination of scheme, host and port (i.e.,
|
||||
// "scheme://host:port" in the most explicit case).
|
||||
//
|
||||
// For non-standard scheme URLs only the "scheme:" component is parsed and
|
||||
// canonicalized. The remainder of the URL will be passed to the handler as-is.
|
||||
// For example, "scheme:///some%20text" will remain the same. Non-standard
|
||||
// scheme URLs cannot be used as a target for form submission.
|
||||
//
|
||||
// If |is_local| is true the scheme will be treated as local (i.e., with the
|
||||
// same security rules as those applied to "file" URLs). Normal pages cannot
|
||||
// link to or access local URLs. Also, by default, local URLs can only perform
|
||||
// XMLHttpRequest calls to the same URL (origin + path) that originated the
|
||||
// request. To allow XMLHttpRequest calls from a local URL to other URLs with
|
||||
// the same origin set the CefSettings.file_access_from_file_urls_allowed value
|
||||
// to true. To allow XMLHttpRequest calls from a local URL to all origins set
|
||||
// the CefSettings.universal_access_from_file_urls_allowed value to true.
|
||||
//
|
||||
// If |is_display_isolated| is true the scheme will be treated as display-
|
||||
// isolated. This means that pages cannot display these URLs unless they are
|
||||
// from the same scheme. For example, pages in another origin cannot create
|
||||
// iframes or hyperlinks to URLs with this scheme.
|
||||
//
|
||||
// This function may be called on any thread. It should only be called once
|
||||
// per unique |scheme_name| value. If |scheme_name| is already registered or if
|
||||
// an error occurs this method will return false.
|
||||
///
|
||||
/*--cef()--*/
|
||||
bool CefRegisterCustomScheme(const CefString& scheme_name,
|
||||
bool is_standard,
|
||||
bool is_local,
|
||||
bool is_display_isolated);
|
||||
|
||||
///
|
||||
// Register a scheme handler factory for the specified |scheme_name| and
|
||||
|
@ -125,15 +75,75 @@ bool CefClearSchemeHandlerFactories();
|
|||
|
||||
|
||||
///
|
||||
// Class that creates CefResourceHandler instances for handling scheme requests. The
|
||||
// methods of this class will always be called on the IO thread.
|
||||
// Class that manages custom scheme registrations.
|
||||
///
|
||||
/*--cef(source=library)--*/
|
||||
class CefSchemeRegistrar : public virtual CefBase {
|
||||
public:
|
||||
///
|
||||
// Register a custom scheme. This method should not be called for the built-in
|
||||
// HTTP, HTTPS, FILE, FTP, ABOUT and DATA schemes.
|
||||
//
|
||||
// If |is_standard| is true the scheme will be treated as a standard scheme.
|
||||
// Standard schemes are subject to URL canonicalization and parsing rules as
|
||||
// defined in the Common Internet Scheme Syntax RFC 1738 Section 3.1 available
|
||||
// at http://www.ietf.org/rfc/rfc1738.txt
|
||||
//
|
||||
// In particular, the syntax for standard scheme URLs must be of the form:
|
||||
// <pre>
|
||||
// [scheme]://[username]:[password]@[host]:[port]/[url-path]
|
||||
// </pre>
|
||||
// Standard scheme URLs must have a host component that is a fully qualified
|
||||
// domain name as defined in Section 3.5 of RFC 1034 [13] and Section 2.1 of
|
||||
// RFC 1123. These URLs will be canonicalized to "scheme://host/path" in the
|
||||
// simplest case and "scheme://username:password@host:port/path" in the most
|
||||
// explicit case. For example, "scheme:host/path" and "scheme:///host/path"
|
||||
// will both be canonicalized to "scheme://host/path". The origin of a
|
||||
// standard scheme URL is the combination of scheme, host and port (i.e.,
|
||||
// "scheme://host:port" in the most explicit case).
|
||||
//
|
||||
// For non-standard scheme URLs only the "scheme:" component is parsed and
|
||||
// canonicalized. The remainder of the URL will be passed to the handler
|
||||
// as-is. For example, "scheme:///some%20text" will remain the same.
|
||||
// Non-standard scheme URLs cannot be used as a target for form submission.
|
||||
//
|
||||
// If |is_local| is true the scheme will be treated as local (i.e., with the
|
||||
// same security rules as those applied to "file" URLs). Normal pages cannot
|
||||
// link to or access local URLs. Also, by default, local URLs can only perform
|
||||
// XMLHttpRequest calls to the same URL (origin + path) that originated the
|
||||
// request. To allow XMLHttpRequest calls from a local URL to other URLs with
|
||||
// the same origin set the CefSettings.file_access_from_file_urls_allowed
|
||||
// value to true. To allow XMLHttpRequest calls from a local URL to all
|
||||
// origins set the CefSettings.universal_access_from_file_urls_allowed value
|
||||
// to true.
|
||||
//
|
||||
// If |is_display_isolated| is true the scheme will be treated as display-
|
||||
// isolated. This means that pages cannot display these URLs unless they are
|
||||
// from the same scheme. For example, pages in another origin cannot create
|
||||
// iframes or hyperlinks to URLs with this scheme.
|
||||
//
|
||||
// This function may be called on any thread. It should only be called once
|
||||
// per unique |scheme_name| value. If |scheme_name| is already registered or
|
||||
// if an error occurs this method will return false.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool AddCustomScheme(const CefString& scheme_name,
|
||||
bool is_standard,
|
||||
bool is_local,
|
||||
bool is_display_isolated) =0;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
// Class that creates CefResourceHandler instances for handling scheme requests.
|
||||
// The methods of this class will always be called on the IO thread.
|
||||
///
|
||||
/*--cef(source=client)--*/
|
||||
class CefSchemeHandlerFactory : public virtual CefBase {
|
||||
public:
|
||||
///
|
||||
// Return a new resource handler instance to handle the request. |browser| will
|
||||
// be the browser window that initiated the request. If the request was
|
||||
// Return a new resource handler instance to handle the request. |browser|
|
||||
// will be the browser window that initiated the request. If the request was
|
||||
// initiated using the CefWebURLRequest API |browser| will be NULL. The
|
||||
// |request| object passed to this method will not contain cookie data.
|
||||
///
|
||||
|
|
|
@ -232,6 +232,14 @@ typedef struct _cef_settings_t {
|
|||
// is disabled.
|
||||
///
|
||||
bool pack_loading_disabled;
|
||||
|
||||
///
|
||||
// Set to a value between 1024 and 65535 to enable remote debugging on the
|
||||
// specified port. For example, if 8080 is specified the remote debugging URL
|
||||
// will be http://localhost:8080. CEF can be remotely debugged from any CEF or
|
||||
// Chrome browser window.
|
||||
///
|
||||
int remote_debugging_port;
|
||||
} cef_settings_t;
|
||||
|
||||
///
|
||||
|
|
|
@ -286,6 +286,7 @@ struct CefSettingsTraits {
|
|||
cef_string_set(src->locales_dir_path.str, src->locales_dir_path.length,
|
||||
&target->locales_dir_path, copy);
|
||||
target->pack_loading_disabled = src->pack_loading_disabled;
|
||||
target->remote_debugging_port = src->remote_debugging_port;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "base/bind_helpers.h"
|
||||
#include "content/browser/renderer_host/render_view_host_impl.h"
|
||||
#include "content/browser/renderer_host/resource_request_info_impl.h"
|
||||
#include "content/browser/tab_contents/tab_contents.h"
|
||||
#include "content/browser/web_contents/web_contents_impl.h"
|
||||
#include "content/public/browser/navigation_controller.h"
|
||||
#include "content/public/browser/navigation_entry.h"
|
||||
#include "content/public/browser/notification_details.h"
|
||||
|
@ -160,9 +160,10 @@ CefRefPtr<CefBrowserHostImpl> CefBrowserHostImpl::GetBrowserForHost(
|
|||
const content::RenderViewHost* host) {
|
||||
DCHECK(host);
|
||||
CEF_REQUIRE_UIT();
|
||||
TabContents* tab_contents = static_cast<TabContents*>(host->GetDelegate());
|
||||
if (tab_contents)
|
||||
return static_cast<CefBrowserHostImpl*>(tab_contents->GetDelegate());
|
||||
WebContentsImpl* web_contents =
|
||||
static_cast<WebContentsImpl*>(host->GetDelegate());
|
||||
if (web_contents)
|
||||
return static_cast<CefBrowserHostImpl*>(web_contents->GetDelegate());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include "libcef/browser/browser_message_filter.h"
|
||||
|
||||
#include "libcef/browser/origin_whitelist_impl.h"
|
||||
#include "libcef/browser/scheme_impl.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/common/cef_messages.h"
|
||||
|
||||
|
@ -49,6 +48,5 @@ void CefBrowserMessageFilter::RegisterOnUIThread() {
|
|||
CEF_REQUIRE_UIT();
|
||||
|
||||
// Send existing registrations to the new render process.
|
||||
RegisterSchemesWithHost(host_);
|
||||
RegisterCrossOriginWhitelistEntriesWithHost(host_);
|
||||
}
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/scheme_impl.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "include/cef_browser.h"
|
||||
|
@ -15,7 +13,6 @@
|
|||
#include "libcef/browser/resource_request_job.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/browser/url_request_context_getter.h"
|
||||
#include "libcef/common/cef_messages.h"
|
||||
#include "libcef/common/request_impl.h"
|
||||
#include "libcef/common/response_impl.h"
|
||||
|
||||
|
@ -25,7 +22,6 @@
|
|||
#include "base/message_loop.h"
|
||||
#include "base/string_util.h"
|
||||
#include "base/synchronization/lock.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "googleurl/src/url_util.h"
|
||||
#include "net/base/completion_callback.h"
|
||||
#include "net/base/io_buffer.h"
|
||||
|
@ -53,13 +49,6 @@ bool IsStandardScheme(const std::string& scheme) {
|
|||
return url_util::IsStandard(scheme.c_str(), scheme_comp);
|
||||
}
|
||||
|
||||
void RegisterStandardScheme(const std::string& scheme) {
|
||||
CEF_REQUIRE_UIT();
|
||||
url_parse::Component scheme_comp(0, scheme.length());
|
||||
if (!url_util::IsStandard(scheme.c_str(), scheme_comp))
|
||||
url_util::AddStandardScheme(scheme.c_str());
|
||||
}
|
||||
|
||||
// Copied from net/url_request/url_request_job_manager.cc.
|
||||
struct SchemeToFactory {
|
||||
const char* scheme;
|
||||
|
@ -200,69 +189,6 @@ class CefUrlRequestManager {
|
|||
handler_map_.clear();
|
||||
}
|
||||
|
||||
// Check if a scheme has already been registered.
|
||||
bool HasRegisteredScheme(const std::string& scheme) {
|
||||
std::string scheme_lower = ToLower(scheme);
|
||||
|
||||
// Don't register builtin schemes.
|
||||
if (IsBuiltinScheme(scheme_lower))
|
||||
return true;
|
||||
|
||||
scheme_map_lock_.Acquire();
|
||||
bool registered = (scheme_map_.find(scheme_lower) != scheme_map_.end());
|
||||
scheme_map_lock_.Release();
|
||||
return registered;
|
||||
}
|
||||
|
||||
// Register a scheme.
|
||||
bool RegisterScheme(const std::string& scheme,
|
||||
bool is_standard,
|
||||
bool is_local,
|
||||
bool is_display_isolated) {
|
||||
if (HasRegisteredScheme(scheme)) {
|
||||
NOTREACHED() << "Scheme already registered: " << scheme;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string scheme_lower = ToLower(scheme);
|
||||
|
||||
SchemeInfo info;
|
||||
info.is_standard = is_standard;
|
||||
info.is_local = is_local;
|
||||
info.is_display_isolated = is_display_isolated;
|
||||
|
||||
scheme_map_lock_.Acquire();
|
||||
scheme_map_.insert(std::make_pair(scheme_lower, info));
|
||||
scheme_map_lock_.Release();
|
||||
|
||||
if (is_standard && !content::RenderProcessHost::run_renderer_in_process()) {
|
||||
// When running in multi-process mode the scheme must be registered with
|
||||
// url_util in the browser process as well.
|
||||
RegisterStandardScheme(scheme_lower);
|
||||
}
|
||||
|
||||
SendRegisterScheme(scheme_lower, is_standard, is_local,
|
||||
is_display_isolated);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Send all existing scheme registrations to the specified host.
|
||||
void RegisterSchemesWithHost(content::RenderProcessHost* host) {
|
||||
base::AutoLock lock_scope(scheme_map_lock_);
|
||||
|
||||
if (scheme_map_.empty())
|
||||
return;
|
||||
|
||||
SchemeMap::const_iterator it = scheme_map_.begin();
|
||||
for (; it != scheme_map_.end(); ++it) {
|
||||
host->Send(
|
||||
new CefProcessMsg_RegisterScheme(it->first, it->second.is_standard,
|
||||
it->second.is_local,
|
||||
it->second.is_display_isolated));
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
// Retrieve the matching handler factory, if any. |scheme| will already be in
|
||||
// lower case.
|
||||
|
@ -328,40 +254,12 @@ class CefUrlRequestManager {
|
|||
return job;
|
||||
}
|
||||
|
||||
// Send the register scheme message to all currently existing hosts.
|
||||
void SendRegisterScheme(const std::string& scheme_name,
|
||||
bool is_standard,
|
||||
bool is_local,
|
||||
bool is_display_isolated) {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
content::RenderProcessHost::iterator i(
|
||||
content::RenderProcessHost::AllHostsIterator());
|
||||
for (; !i.IsAtEnd(); i.Advance()) {
|
||||
i.GetCurrentValue()->Send(
|
||||
new CefProcessMsg_RegisterScheme(scheme_name, is_standard, is_local,
|
||||
is_display_isolated));
|
||||
}
|
||||
}
|
||||
|
||||
// Map (scheme, domain) to factories. This map will only be accessed on the IO
|
||||
// thread.
|
||||
typedef std::map<std::pair<std::string, std::string>,
|
||||
CefRefPtr<CefSchemeHandlerFactory> > HandlerMap;
|
||||
HandlerMap handler_map_;
|
||||
|
||||
struct SchemeInfo {
|
||||
bool is_standard;
|
||||
bool is_local;
|
||||
bool is_display_isolated;
|
||||
};
|
||||
|
||||
// Map of registered schemes. Access to this map must be protected by the
|
||||
// associated lock.
|
||||
typedef std::map<std::string, SchemeInfo> SchemeMap;
|
||||
SchemeMap scheme_map_;
|
||||
base::Lock scheme_map_lock_;
|
||||
|
||||
DISALLOW_EVIL_CONSTRUCTORS(CefUrlRequestManager);
|
||||
};
|
||||
|
||||
|
@ -374,34 +272,6 @@ CefUrlRequestManager* CefUrlRequestManager::GetInstance() {
|
|||
} // namespace
|
||||
|
||||
|
||||
bool CefRegisterCustomScheme(const CefString& scheme_name,
|
||||
bool is_standard,
|
||||
bool is_local,
|
||||
bool is_display_isolated) {
|
||||
// Verify that the context is in a valid state.
|
||||
if (!CONTEXT_STATE_VALID()) {
|
||||
NOTREACHED() << "context not valid";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (CEF_CURRENTLY_ON(CEF_UIT)) {
|
||||
// Must be executed on the UI thread.
|
||||
return CefUrlRequestManager::GetInstance()->RegisterScheme(scheme_name,
|
||||
is_standard, is_local, is_display_isolated);
|
||||
} else {
|
||||
// Verify that the scheme has not already been registered.
|
||||
if (CefUrlRequestManager::GetInstance()->HasRegisteredScheme(scheme_name)) {
|
||||
NOTREACHED() << "Scheme already registered: " << scheme_name;
|
||||
return false;
|
||||
}
|
||||
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(base::IgnoreResult(&CefRegisterCustomScheme), scheme_name,
|
||||
is_standard, is_local, is_display_isolated));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool CefRegisterSchemeHandlerFactory(
|
||||
const CefString& scheme_name,
|
||||
const CefString& domain_name,
|
||||
|
@ -440,8 +310,3 @@ bool CefClearSchemeHandlerFactories() {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
void RegisterSchemesWithHost(content::RenderProcessHost* host) {
|
||||
CEF_REQUIRE_UIT();
|
||||
CefUrlRequestManager::GetInstance()->RegisterSchemesWithHost(host);
|
||||
}
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
// 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.
|
||||
|
||||
#ifndef CEF_LIBCEF_BROWSER_SCHEME_IMPL_H_
|
||||
#define CEF_LIBCEF_BROWSER_SCHEME_IMPL_H_
|
||||
|
||||
namespace content {
|
||||
class RenderProcessHost;
|
||||
}
|
||||
|
||||
// Called when a new RenderProcessHost is created to send existing scheme
|
||||
// registration information.
|
||||
void RegisterSchemesWithHost(content::RenderProcessHost* host);
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_SCHEME_IMPL_H_
|
|
@ -120,13 +120,6 @@ IPC_MESSAGE_ROUTED1(CefMsg_Response,
|
|||
IPC_MESSAGE_ROUTED1(CefMsg_ResponseAck,
|
||||
int /* request_id */)
|
||||
|
||||
// Sent to child processes to register a scheme.
|
||||
IPC_MESSAGE_CONTROL4(CefProcessMsg_RegisterScheme,
|
||||
std::string /* sheme_name */,
|
||||
bool /* is_standard */,
|
||||
bool /* is_local */,
|
||||
bool /* is_display_isolated */)
|
||||
|
||||
// Sent to child processes to add or remove a cross-origin whitelist entry.
|
||||
IPC_MESSAGE_CONTROL5(CefProcessMsg_ModifyCrossOriginWhitelistEntry,
|
||||
bool /* add */,
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "include/cef_stream.h"
|
||||
#include "include/cef_version.h"
|
||||
#include "libcef/common/cef_switches.h"
|
||||
#include "libcef/common/scheme_registrar_impl.h"
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/logging.h"
|
||||
|
@ -42,6 +43,21 @@ void CefContentClient::AddNPAPIPlugins(
|
|||
webkit::npapi::PluginList* plugin_list) {
|
||||
}
|
||||
|
||||
void CefContentClient::AddAdditionalSchemes(
|
||||
std::vector<std::string>* standard_schemes,
|
||||
std::vector<std::string>* savable_schemes) {
|
||||
if (application_.get()) {
|
||||
CefRefPtr<CefSchemeRegistrarImpl> schemeRegistrar(
|
||||
new CefSchemeRegistrarImpl());
|
||||
application_->OnRegisterCustomSchemes(schemeRegistrar.get());
|
||||
schemeRegistrar->GetStandardSchemes(standard_schemes);
|
||||
|
||||
// No references to the registar should be kept.
|
||||
schemeRegistrar->Detach();
|
||||
DCHECK(schemeRegistrar->VerifyRefCount());
|
||||
}
|
||||
}
|
||||
|
||||
bool CefContentClient::HasWebUIScheme(const GURL& url) const {
|
||||
// There are no WebUI URLs in CEF.
|
||||
return false;
|
||||
|
|
|
@ -28,6 +28,9 @@ class CefContentClient : public content::ContentClient {
|
|||
std::vector<content::PepperPluginInfo>* plugins) OVERRIDE;
|
||||
virtual void AddNPAPIPlugins(
|
||||
webkit::npapi::PluginList* plugin_list) OVERRIDE;
|
||||
virtual void AddAdditionalSchemes(
|
||||
std::vector<std::string>* standard_schemes,
|
||||
std::vector<std::string>* savable_schemes) OVERRIDE;
|
||||
virtual bool HasWebUIScheme(const GURL& url) const OVERRIDE;
|
||||
virtual bool CanHandleWhileSwappedOut(const IPC::Message& msg) OVERRIDE;
|
||||
virtual std::string GetUserAgent() const OVERRIDE;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "base/file_path.h"
|
||||
#include "base/file_util.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/string_number_conversions.h"
|
||||
#include "base/synchronization/waitable_event.h"
|
||||
#include "base/threading/thread.h"
|
||||
#include "content/public/browser/browser_main_runner.h"
|
||||
|
@ -197,6 +198,12 @@ bool CefMainDelegate::BasicStartupComplete(int* exit_code) {
|
|||
}
|
||||
}
|
||||
|
||||
if (settings.remote_debugging_port >= 1024 &&
|
||||
settings.remote_debugging_port <= 65535) {
|
||||
command_line->AppendSwitchASCII(switches::kRemoteDebuggingPort,
|
||||
base::IntToString(settings.remote_debugging_port));
|
||||
}
|
||||
|
||||
// TODO(cef): Figure out how to support the sandbox.
|
||||
if (!command_line->HasSwitch(switches::kNoSandbox))
|
||||
command_line->AppendSwitch(switches::kNoSandbox);
|
||||
|
@ -211,6 +218,9 @@ bool CefMainDelegate::BasicStartupComplete(int* exit_code) {
|
|||
commandLinePtr->Detach(NULL);
|
||||
}
|
||||
|
||||
content::SetContentClient(&content_client_);
|
||||
InitializeContentClient(process_type);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -220,12 +230,6 @@ void CefMainDelegate::PreSandboxStartup() {
|
|||
#endif
|
||||
|
||||
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
|
||||
std::string process_type =
|
||||
command_line.GetSwitchValueASCII(switches::kProcessType);
|
||||
|
||||
content::SetContentClient(&content_client_);
|
||||
InitializeContentClient(process_type);
|
||||
|
||||
if (command_line.HasSwitch(switches::kPackLoadingDisabled))
|
||||
content_client_.set_pack_loading_disabled(true);
|
||||
else
|
||||
|
@ -341,6 +345,8 @@ void CefMainDelegate::InitializeContentClient(
|
|||
void CefMainDelegate::InitializeResourceBundle() {
|
||||
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
|
||||
|
||||
// Mac OS-X does not support customization of the pack load paths.
|
||||
#if !defined(OS_MACOSX)
|
||||
FilePath pak_file, locales_dir;
|
||||
|
||||
if (command_line.HasSwitch(switches::kPackFilePath))
|
||||
|
@ -360,6 +366,7 @@ void CefMainDelegate::InitializeResourceBundle() {
|
|||
|
||||
if (!locales_dir.empty())
|
||||
PathService::Override(ui::DIR_LOCALES, locales_dir);
|
||||
#endif // !defined(OS_MACOSX)
|
||||
|
||||
std::string locale = command_line.GetSwitchValueASCII(switches::kLocale);
|
||||
if (locale.empty())
|
||||
|
@ -372,7 +379,7 @@ void CefMainDelegate::InitializeResourceBundle() {
|
|||
#if defined(OS_WIN)
|
||||
// Explicitly load cef.pak on Windows.
|
||||
if (file_util::PathExists(pak_file))
|
||||
ResourceBundle::AddDataPackToSharedInstance(pak_file);
|
||||
ResourceBundle::GetSharedInstance().AddDataPack(pak_file);
|
||||
else
|
||||
NOTREACHED() << "Could not load cef.pak";
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
// 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.
|
||||
|
||||
#include "libcef/common/scheme_registrar_impl.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "libcef/renderer/content_renderer_client.h"
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/logging.h"
|
||||
|
||||
CefSchemeRegistrarImpl::CefSchemeRegistrarImpl()
|
||||
: supported_thread_id_(base::PlatformThread::CurrentId()) {
|
||||
}
|
||||
|
||||
bool CefSchemeRegistrarImpl::AddCustomScheme(
|
||||
const CefString& scheme_name,
|
||||
bool is_standard,
|
||||
bool is_local,
|
||||
bool is_display_isolated) {
|
||||
if (!VerifyContext())
|
||||
return false;
|
||||
|
||||
if (is_standard)
|
||||
standard_schemes_.push_back(scheme_name);
|
||||
|
||||
if (CefContentRendererClient::Get()) {
|
||||
// Register the custom scheme with WebKit.
|
||||
CefContentRendererClient::Get()->AddCustomScheme(scheme_name, is_local,
|
||||
is_display_isolated);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CefSchemeRegistrarImpl::GetStandardSchemes(
|
||||
std::vector<std::string>* standard_schemes) {
|
||||
if (!VerifyContext())
|
||||
return;
|
||||
|
||||
if (standard_schemes_.empty())
|
||||
return;
|
||||
|
||||
standard_schemes->insert(standard_schemes->end(), standard_schemes_.begin(),
|
||||
standard_schemes_.end());
|
||||
}
|
||||
|
||||
bool CefSchemeRegistrarImpl::VerifyRefCount() {
|
||||
return (GetRefCt() == 1);
|
||||
}
|
||||
|
||||
void CefSchemeRegistrarImpl::Detach() {
|
||||
if (VerifyContext())
|
||||
supported_thread_id_ = base::kInvalidThreadId;
|
||||
}
|
||||
|
||||
bool CefSchemeRegistrarImpl::VerifyContext() {
|
||||
if (base::PlatformThread::CurrentId() != supported_thread_id_) {
|
||||
// This object should only be accessed from the thread that created it.
|
||||
NOTREACHED();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
// 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.
|
||||
|
||||
#ifndef CEF_LIBCEF_COMMON_SCHEME_REGISTRAR_IMPL_H_
|
||||
#define CEF_LIBCEF_COMMON_SCHEME_REGISTRAR_IMPL_H_
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "include/cef_scheme.h"
|
||||
|
||||
#include "base/threading/platform_thread.h"
|
||||
|
||||
class CefSchemeRegistrarImpl : public CefSchemeRegistrar {
|
||||
public:
|
||||
CefSchemeRegistrarImpl();
|
||||
|
||||
// CefSchemeRegistrar methods.
|
||||
virtual bool AddCustomScheme(const CefString& scheme_name,
|
||||
bool is_standard,
|
||||
bool is_local,
|
||||
bool is_display_isolated) OVERRIDE;
|
||||
|
||||
void GetStandardSchemes(std::vector<std::string>* standard_schemes);
|
||||
|
||||
// Verify that only a single reference exists to all CefSchemeRegistrarImpl
|
||||
// objects.
|
||||
bool VerifyRefCount();
|
||||
|
||||
void Detach();
|
||||
|
||||
private:
|
||||
// Verify that the object is being accessed from the correct thread.
|
||||
bool VerifyContext();
|
||||
|
||||
base::PlatformThreadId supported_thread_id_;
|
||||
|
||||
std::vector<std::string> standard_schemes_;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(CefSchemeRegistrarImpl);
|
||||
DISALLOW_COPY_AND_ASSIGN(CefSchemeRegistrarImpl);
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_COMMON_SCHEME_REGISTRAR_IMPL_H_
|
|
@ -7,7 +7,6 @@
|
|||
#include "libcef/common/cef_messages.h"
|
||||
#include "libcef/common/content_client.h"
|
||||
#include "libcef/renderer/browser_impl.h"
|
||||
#include "libcef/renderer/render_message_filter.h"
|
||||
#include "libcef/renderer/render_process_observer.h"
|
||||
#include "libcef/renderer/thread_util.h"
|
||||
#include "libcef/renderer/v8_impl.h"
|
||||
|
@ -17,9 +16,18 @@
|
|||
#include "content/public/renderer/render_view.h"
|
||||
#include "ipc/ipc_sync_channel.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
|
||||
#include "v8/include/v8.h"
|
||||
|
||||
|
||||
struct CefContentRendererClient::SchemeInfo {
|
||||
std::string scheme_name;
|
||||
bool is_local;
|
||||
bool is_display_isolated;
|
||||
};
|
||||
|
||||
CefContentRendererClient::CefContentRendererClient() {
|
||||
}
|
||||
|
||||
|
@ -71,13 +79,38 @@ void CefContentRendererClient::OnBrowserDestroyed(CefBrowserImpl* browser) {
|
|||
NOTREACHED();
|
||||
}
|
||||
|
||||
void CefContentRendererClient::AddCustomScheme(
|
||||
const std::string& scheme_name,
|
||||
bool is_local,
|
||||
bool is_display_isolated) {
|
||||
SchemeInfo info = {scheme_name, is_local, is_display_isolated};
|
||||
scheme_info_list_.push_back(info);
|
||||
}
|
||||
|
||||
void CefContentRendererClient::RegisterCustomSchemes() {
|
||||
if (scheme_info_list_.empty())
|
||||
return;
|
||||
|
||||
SchemeInfoList::const_iterator it = scheme_info_list_.begin();
|
||||
for (; it != scheme_info_list_.end(); ++it) {
|
||||
const SchemeInfo& info = *it;
|
||||
if (info.is_local) {
|
||||
WebKit::WebSecurityPolicy::registerURLSchemeAsLocal(
|
||||
WebKit::WebString::fromUTF8(info.scheme_name));
|
||||
}
|
||||
if (info.is_display_isolated) {
|
||||
WebKit::WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(
|
||||
WebKit::WebString::fromUTF8(info.scheme_name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CefContentRendererClient::RenderThreadStarted() {
|
||||
render_loop_ = base::MessageLoopProxy::current();
|
||||
observer_.reset(new CefRenderProcessObserver());
|
||||
|
||||
content::RenderThread* thread = content::RenderThread::Get();
|
||||
thread->AddObserver(observer_.get());
|
||||
thread->GetChannel()->AddFilter(new CefRenderMessageFilter);
|
||||
|
||||
thread->Send(new CefProcessHostMsg_RenderThreadStarted);
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
#define CEF_LIBCEF_RENDERER_CONTENT_RENDERER_CLIENT_H_
|
||||
#pragma once
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#include "libcef/renderer/browser_impl.h"
|
||||
|
@ -37,6 +37,14 @@ class CefContentRendererClient : public content::ContentRendererClient {
|
|||
// Called from CefBrowserImpl::OnDestruct().
|
||||
void OnBrowserDestroyed(CefBrowserImpl* browser);
|
||||
|
||||
// Add a custom scheme registration.
|
||||
void AddCustomScheme(const std::string& scheme_name,
|
||||
bool is_local,
|
||||
bool is_display_isolated);
|
||||
|
||||
// Register the custom schemes with WebKit.
|
||||
void RegisterCustomSchemes();
|
||||
|
||||
// Render thread message loop proxy.
|
||||
base::MessageLoopProxy* render_loop() const { return render_loop_.get(); }
|
||||
|
||||
|
@ -110,6 +118,11 @@ class CefContentRendererClient : public content::ContentRendererClient {
|
|||
// Map of RenderView pointers to CefBrowserImpl references.
|
||||
typedef std::map<content::RenderView*, CefRefPtr<CefBrowserImpl> > BrowserMap;
|
||||
BrowserMap browsers_;
|
||||
|
||||
// Information about custom schemes that need to be registered with WebKit.
|
||||
struct SchemeInfo;
|
||||
typedef std::list<SchemeInfo> SchemeInfoList;
|
||||
SchemeInfoList scheme_info_list_;
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_RENDERER_CONTENT_RENDERER_CLIENT_H_
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
/// Copyright (c) 2012 The Chromium Embedded Framework Authors.
|
||||
// Portions (c) 2011 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "libcef/renderer/render_message_filter.h"
|
||||
#include "libcef/renderer/thread_util.h"
|
||||
#include "libcef/common/cef_messages.h"
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "googleurl/src/gurl.h"
|
||||
#include "googleurl/src/url_util.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
|
||||
|
||||
CefRenderMessageFilter::CefRenderMessageFilter()
|
||||
: channel_(NULL) {
|
||||
}
|
||||
|
||||
CefRenderMessageFilter::~CefRenderMessageFilter() {
|
||||
}
|
||||
|
||||
void CefRenderMessageFilter::OnFilterAdded(IPC::Channel* channel) {
|
||||
channel_ = channel;
|
||||
}
|
||||
|
||||
void CefRenderMessageFilter::OnFilterRemoved() {
|
||||
}
|
||||
|
||||
bool CefRenderMessageFilter::OnMessageReceived(const IPC::Message& message) {
|
||||
bool handled = true;
|
||||
IPC_BEGIN_MESSAGE_MAP(CefRenderMessageFilter, message)
|
||||
IPC_MESSAGE_HANDLER(CefProcessMsg_RegisterScheme, OnRegisterScheme)
|
||||
IPC_MESSAGE_UNHANDLED(handled = false)
|
||||
IPC_END_MESSAGE_MAP()
|
||||
return handled;
|
||||
}
|
||||
|
||||
void CefRenderMessageFilter::OnRegisterScheme(
|
||||
const std::string& scheme_name,
|
||||
bool is_standard,
|
||||
bool is_local,
|
||||
bool is_display_isolated) {
|
||||
if (is_standard) {
|
||||
// Make this registration as early as possible.
|
||||
url_parse::Component scheme_comp(0, scheme_name.length());
|
||||
if (!url_util::IsStandard(scheme_name.c_str(), scheme_comp))
|
||||
url_util::AddStandardScheme(scheme_name.c_str());
|
||||
}
|
||||
|
||||
CEF_POST_TASK_RT(
|
||||
base::Bind(&CefRenderMessageFilter::RegisterSchemeOnRenderThread, this,
|
||||
scheme_name, is_local, is_display_isolated));
|
||||
}
|
||||
|
||||
void CefRenderMessageFilter::RegisterSchemeOnRenderThread(
|
||||
const std::string& scheme_name,
|
||||
bool is_local,
|
||||
bool is_display_isolated) {
|
||||
CEF_REQUIRE_RT();
|
||||
if (is_local) {
|
||||
WebKit::WebSecurityPolicy::registerURLSchemeAsLocal(
|
||||
WebKit::WebString::fromUTF8(scheme_name));
|
||||
}
|
||||
if (is_display_isolated) {
|
||||
WebKit::WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(
|
||||
WebKit::WebString::fromUTF8(scheme_name));
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
// Copyright (c) 2012 The Chromium Embedded Framework Authors.
|
||||
// Portions copyright (c) 2011 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_LIBCEF_RENDERER_RENDER_MESSAGE_FILTER_H_
|
||||
#define CEF_LIBCEF_RENDERER_RENDER_MESSAGE_FILTER_H_
|
||||
|
||||
#include <string>
|
||||
#include "ipc/ipc_channel_proxy.h"
|
||||
|
||||
// This class sends and receives control messages on the renderer process.
|
||||
class CefRenderMessageFilter : public IPC::ChannelProxy::MessageFilter {
|
||||
public:
|
||||
CefRenderMessageFilter();
|
||||
virtual ~CefRenderMessageFilter();
|
||||
|
||||
// IPC::ChannelProxy::MessageFilter implementation.
|
||||
virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE;
|
||||
virtual void OnFilterRemoved() OVERRIDE;
|
||||
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
|
||||
|
||||
private:
|
||||
// Message handlers called on the IO thread.
|
||||
void OnRegisterScheme(const std::string& scheme_name,
|
||||
bool is_standard,
|
||||
bool is_local,
|
||||
bool is_display_isolated);
|
||||
|
||||
void RegisterSchemeOnRenderThread(const std::string& scheme_name,
|
||||
bool is_local,
|
||||
bool is_display_isolated);
|
||||
|
||||
IPC::Channel* channel_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CefRenderMessageFilter);
|
||||
};
|
||||
|
||||
|
||||
#endif // CEF_LIBCEF_RENDERER_RENDER_MESSAGE_FILTER_H_
|
|
@ -6,6 +6,7 @@
|
|||
#include "libcef/renderer/render_process_observer.h"
|
||||
#include "libcef/common/cef_messages.h"
|
||||
#include "libcef/common/content_client.h"
|
||||
#include "libcef/renderer/content_renderer_client.h"
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/path_service.h"
|
||||
|
@ -49,6 +50,9 @@ void CefRenderProcessObserver::WebKitInitialized() {
|
|||
// TODO(cef): Enable these once the implementation supports it.
|
||||
WebKit::WebRuntimeFeatures::enableNotifications(false);
|
||||
|
||||
// Register any custom schemes with WebKit.
|
||||
CefContentRendererClient::Get()->RegisterCustomSchemes();
|
||||
|
||||
// Notify the render process handler.
|
||||
CefRefPtr<CefApp> application = CefContentClient::Get()->application();
|
||||
if (application.get()) {
|
||||
|
|
|
@ -2,10 +2,19 @@
|
|||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include "libcef/renderer/v8_impl.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
|
||||
#include "third_party/WebKit/Source/WebCore/config.h"
|
||||
MSVC_PUSH_WARNING_LEVEL(0);
|
||||
#include "V8Proxy.h" // NOLINT(build/include)
|
||||
#include "V8RecursionScope.h" // NOLINT(build/include)
|
||||
MSVC_POP_WARNING();
|
||||
#undef LOG
|
||||
|
||||
#include "libcef/renderer/v8_impl.h"
|
||||
|
||||
#include "libcef/common/tracker.h"
|
||||
#include "libcef/renderer/browser_impl.h"
|
||||
#include "libcef/renderer/thread_util.h"
|
||||
|
@ -16,7 +25,6 @@
|
|||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptController.h"
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
static const char kCefTrackObject[] = "Cef::TrackObject";
|
||||
|
@ -530,16 +538,27 @@ bool CefV8ContextImpl::Eval(const CefString& code,
|
|||
v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(val);
|
||||
v8::Handle<v8::Value> code_val = GetV8String(code);
|
||||
|
||||
// Execute the eval function.
|
||||
v8::TryCatch try_catch;
|
||||
v8::Local<v8::Value> func_rv = func->Call(obj, 1, &code_val);
|
||||
try_catch.SetVerbose(true);
|
||||
v8::Local<v8::Value> func_rv;
|
||||
|
||||
retval = NULL;
|
||||
exception = NULL;
|
||||
|
||||
// Execute the function call using the V8Proxy so that inspector
|
||||
// instrumentation works.
|
||||
WebCore::V8Proxy* proxy = WebCore::V8Proxy::retrieve();
|
||||
DCHECK(proxy);
|
||||
if (proxy)
|
||||
func_rv = proxy->callFunction(func, obj, 1, &code_val);
|
||||
|
||||
if (try_catch.HasCaught()) {
|
||||
exception = new CefV8ExceptionImpl(try_catch.Message());
|
||||
return false;
|
||||
} else {
|
||||
} else if (!func_rv.IsEmpty()) {
|
||||
retval = new CefV8ValueImpl(func_rv);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
v8::Local<v8::Context> CefV8ContextImpl::GetContext() {
|
||||
|
@ -952,6 +971,7 @@ bool CefV8ValueImpl::DeleteValue(const CefString& key) {
|
|||
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
||||
|
||||
v8::TryCatch try_catch;
|
||||
try_catch.SetVerbose(true);
|
||||
bool del = obj->Delete(GetV8String(key));
|
||||
return (!HasCaught(try_catch) && del);
|
||||
}
|
||||
|
@ -969,6 +989,7 @@ bool CefV8ValueImpl::DeleteValue(int index) {
|
|||
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
||||
|
||||
v8::TryCatch try_catch;
|
||||
try_catch.SetVerbose(true);
|
||||
bool del = obj->Delete(index);
|
||||
return (!HasCaught(try_catch) && del);
|
||||
}
|
||||
|
@ -986,6 +1007,7 @@ CefRefPtr<CefV8Value> CefV8ValueImpl::GetValue(const CefString& key) {
|
|||
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
||||
|
||||
v8::TryCatch try_catch;
|
||||
try_catch.SetVerbose(true);
|
||||
v8::Local<v8::Value> value = obj->Get(GetV8String(key));
|
||||
if (!HasCaught(try_catch) && !value.IsEmpty())
|
||||
return new CefV8ValueImpl(value);
|
||||
|
@ -1005,6 +1027,7 @@ CefRefPtr<CefV8Value> CefV8ValueImpl::GetValue(int index) {
|
|||
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
||||
|
||||
v8::TryCatch try_catch;
|
||||
try_catch.SetVerbose(true);
|
||||
v8::Local<v8::Value> value = obj->Get(v8::Number::New(index));
|
||||
if (!HasCaught(try_catch) && !value.IsEmpty())
|
||||
return new CefV8ValueImpl(value);
|
||||
|
@ -1023,6 +1046,7 @@ bool CefV8ValueImpl::SetValue(const CefString& key,
|
|||
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
||||
|
||||
v8::TryCatch try_catch;
|
||||
try_catch.SetVerbose(true);
|
||||
bool set = obj->Set(GetV8String(key), impl->GetHandle(),
|
||||
static_cast<v8::PropertyAttribute>(attribute));
|
||||
return (!HasCaught(try_catch) && set);
|
||||
|
@ -1047,6 +1071,7 @@ bool CefV8ValueImpl::SetValue(int index, CefRefPtr<CefV8Value> value) {
|
|||
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
||||
|
||||
v8::TryCatch try_catch;
|
||||
try_catch.SetVerbose(true);
|
||||
bool set = obj->Set(index, impl->GetHandle());
|
||||
return (!HasCaught(try_catch) && set);
|
||||
} else {
|
||||
|
@ -1083,6 +1108,7 @@ bool CefV8ValueImpl::SetValue(const CefString& key, AccessControl settings,
|
|||
NULL : AccessorSetterCallbackImpl;
|
||||
|
||||
v8::TryCatch try_catch;
|
||||
try_catch.SetVerbose(true);
|
||||
bool set = obj->SetAccessor(GetV8String(key), getter, setter, obj,
|
||||
static_cast<v8::AccessControl>(settings),
|
||||
static_cast<v8::PropertyAttribute>(attribute));
|
||||
|
@ -1250,10 +1276,21 @@ CefRefPtr<CefV8Value> CefV8ValueImpl::ExecuteFunctionWithContext(
|
|||
|
||||
CefRefPtr<CefV8Value> retval;
|
||||
|
||||
{
|
||||
v8::TryCatch try_catch;
|
||||
v8::Local<v8::Value> func_rv = func->Call(recv, argc, argv);
|
||||
if (!HasCaught(try_catch))
|
||||
try_catch.SetVerbose(true);
|
||||
v8::Local<v8::Value> func_rv;
|
||||
|
||||
// Execute the function call using the V8Proxy so that inspector
|
||||
// instrumentation works.
|
||||
WebCore::V8Proxy* proxy = WebCore::V8Proxy::retrieve();
|
||||
DCHECK(proxy);
|
||||
if (proxy)
|
||||
func_rv = proxy->callFunction(func, recv, argc, argv);
|
||||
|
||||
if (!HasCaught(try_catch) && !func_rv.IsEmpty())
|
||||
retval = new CefV8ValueImpl(func_rv);
|
||||
}
|
||||
|
||||
if (argv)
|
||||
delete [] argv;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "libcef_dll/cpptoc/render_process_handler_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/resource_bundle_handler_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/command_line_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/scheme_registrar_ctocpp.h"
|
||||
|
||||
|
||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||
|
@ -39,6 +40,23 @@ void CEF_CALLBACK app_on_before_command_line_processing(struct _cef_app_t* self,
|
|||
CefCommandLineCToCpp::Wrap(command_line));
|
||||
}
|
||||
|
||||
void CEF_CALLBACK app_on_register_custom_schemes(struct _cef_app_t* self,
|
||||
struct _cef_scheme_registrar_t* registrar) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return;
|
||||
// Verify param: registrar; type: refptr_diff
|
||||
DCHECK(registrar);
|
||||
if (!registrar)
|
||||
return;
|
||||
|
||||
// Execute
|
||||
CefAppCppToC::Get(self)->OnRegisterCustomSchemes(
|
||||
CefSchemeRegistrarCToCpp::Wrap(registrar));
|
||||
}
|
||||
|
||||
struct _cef_render_process_handler_t* CEF_CALLBACK app_get_render_process_handler(
|
||||
struct _cef_app_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
@ -94,6 +112,7 @@ CefAppCppToC::CefAppCppToC(CefApp* cls)
|
|||
: CefCppToC<CefAppCppToC, CefApp, cef_app_t>(cls) {
|
||||
struct_.struct_.on_before_command_line_processing =
|
||||
app_on_before_command_line_processing;
|
||||
struct_.struct_.on_register_custom_schemes = app_on_register_custom_schemes;
|
||||
struct_.struct_.get_render_process_handler = app_get_render_process_handler;
|
||||
struct_.struct_.get_resource_bundle_handler = app_get_resource_bundle_handler;
|
||||
struct_.struct_.get_proxy_handler = app_get_proxy_handler;
|
||||
|
|
|
@ -212,24 +212,24 @@ void CEF_CALLBACK frame_load_string(struct _cef_frame_t* self,
|
|||
}
|
||||
|
||||
void CEF_CALLBACK frame_execute_java_script(struct _cef_frame_t* self,
|
||||
const cef_string_t* jsCode, const cef_string_t* scriptUrl,
|
||||
int startLine) {
|
||||
const cef_string_t* code, const cef_string_t* script_url,
|
||||
int start_line) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return;
|
||||
// Verify param: jsCode; type: string_byref_const
|
||||
DCHECK(jsCode);
|
||||
if (!jsCode)
|
||||
// Verify param: code; type: string_byref_const
|
||||
DCHECK(code);
|
||||
if (!code)
|
||||
return;
|
||||
// Unverified params: scriptUrl
|
||||
// Unverified params: script_url
|
||||
|
||||
// Execute
|
||||
CefFrameCppToC::Get(self)->ExecuteJavaScript(
|
||||
CefString(jsCode),
|
||||
CefString(scriptUrl),
|
||||
startLine);
|
||||
CefString(code),
|
||||
CefString(script_url),
|
||||
start_line);
|
||||
}
|
||||
|
||||
int CEF_CALLBACK frame_is_main(struct _cef_frame_t* self) {
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
// 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/scheme_registrar_cpptoc.h"
|
||||
|
||||
|
||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||
|
||||
int CEF_CALLBACK scheme_registrar_add_custom_scheme(
|
||||
struct _cef_scheme_registrar_t* self, const cef_string_t* scheme_name,
|
||||
int is_standard, int is_local, int is_display_isolated) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
// Verify param: scheme_name; type: string_byref_const
|
||||
DCHECK(scheme_name);
|
||||
if (!scheme_name)
|
||||
return 0;
|
||||
|
||||
// Execute
|
||||
bool _retval = CefSchemeRegistrarCppToC::Get(self)->AddCustomScheme(
|
||||
CefString(scheme_name),
|
||||
is_standard?true:false,
|
||||
is_local?true:false,
|
||||
is_display_isolated?true:false);
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefSchemeRegistrarCppToC::CefSchemeRegistrarCppToC(CefSchemeRegistrar* cls)
|
||||
: CefCppToC<CefSchemeRegistrarCppToC, CefSchemeRegistrar,
|
||||
cef_scheme_registrar_t>(cls) {
|
||||
struct_.struct_.add_custom_scheme = scheme_registrar_add_custom_scheme;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> long CefCppToC<CefSchemeRegistrarCppToC, CefSchemeRegistrar,
|
||||
cef_scheme_registrar_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#ifndef CEF_LIBCEF_DLL_CPPTOC_SCHEME_REGISTRAR_CPPTOC_H_
|
||||
#define CEF_LIBCEF_DLL_CPPTOC_SCHEME_REGISTRAR_CPPTOC_H_
|
||||
#pragma once
|
||||
|
||||
#ifndef BUILDING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
|
||||
#else // BUILDING_CEF_SHARED
|
||||
|
||||
#include "include/cef_scheme.h"
|
||||
#include "include/capi/cef_scheme_capi.h"
|
||||
#include "libcef_dll/cpptoc/cpptoc.h"
|
||||
|
||||
// Wrap a C++ class with a C structure.
|
||||
// This class may be instantiated and accessed DLL-side only.
|
||||
class CefSchemeRegistrarCppToC
|
||||
: public CefCppToC<CefSchemeRegistrarCppToC, CefSchemeRegistrar,
|
||||
cef_scheme_registrar_t> {
|
||||
public:
|
||||
explicit CefSchemeRegistrarCppToC(CefSchemeRegistrar* cls);
|
||||
virtual ~CefSchemeRegistrarCppToC() {}
|
||||
};
|
||||
|
||||
#endif // BUILDING_CEF_SHARED
|
||||
#endif // CEF_LIBCEF_DLL_CPPTOC_SCHEME_REGISTRAR_CPPTOC_H_
|
||||
|
|
@ -11,6 +11,7 @@
|
|||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/command_line_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/scheme_registrar_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/app_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/proxy_handler_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/render_process_handler_ctocpp.h"
|
||||
|
@ -38,6 +39,23 @@ void CefAppCToCpp::OnBeforeCommandLineProcessing(const CefString& process_type,
|
|||
CefCommandLineCppToC::Wrap(command_line));
|
||||
}
|
||||
|
||||
void CefAppCToCpp::OnRegisterCustomSchemes(
|
||||
CefRefPtr<CefSchemeRegistrar> registrar) {
|
||||
if (CEF_MEMBER_MISSING(struct_, on_register_custom_schemes))
|
||||
return;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: registrar; type: refptr_diff
|
||||
DCHECK(registrar.get());
|
||||
if (!registrar.get())
|
||||
return;
|
||||
|
||||
// Execute
|
||||
struct_->on_register_custom_schemes(struct_,
|
||||
CefSchemeRegistrarCppToC::Wrap(registrar));
|
||||
}
|
||||
|
||||
CefRefPtr<CefRenderProcessHandler> CefAppCToCpp::GetRenderProcessHandler() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_render_process_handler))
|
||||
return NULL;
|
||||
|
|
|
@ -34,6 +34,8 @@ class CefAppCToCpp
|
|||
// CefApp methods
|
||||
virtual void OnBeforeCommandLineProcessing(const CefString& process_type,
|
||||
CefRefPtr<CefCommandLine> command_line) OVERRIDE;
|
||||
virtual void OnRegisterCustomSchemes(
|
||||
CefRefPtr<CefSchemeRegistrar> registrar) OVERRIDE;
|
||||
virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() OVERRIDE;
|
||||
virtual CefRefPtr<CefResourceBundleHandler> GetResourceBundleHandler(
|
||||
) OVERRIDE;
|
||||
|
|
|
@ -198,24 +198,24 @@ void CefFrameCToCpp::LoadString(const CefString& string_val,
|
|||
url.GetStruct());
|
||||
}
|
||||
|
||||
void CefFrameCToCpp::ExecuteJavaScript(const CefString& jsCode,
|
||||
const CefString& scriptUrl, int startLine) {
|
||||
void CefFrameCToCpp::ExecuteJavaScript(const CefString& code,
|
||||
const CefString& script_url, int start_line) {
|
||||
if (CEF_MEMBER_MISSING(struct_, execute_java_script))
|
||||
return;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: jsCode; type: string_byref_const
|
||||
DCHECK(!jsCode.empty());
|
||||
if (jsCode.empty())
|
||||
// Verify param: code; type: string_byref_const
|
||||
DCHECK(!code.empty());
|
||||
if (code.empty())
|
||||
return;
|
||||
// Unverified params: scriptUrl
|
||||
// Unverified params: script_url
|
||||
|
||||
// Execute
|
||||
struct_->execute_java_script(struct_,
|
||||
jsCode.GetStruct(),
|
||||
scriptUrl.GetStruct(),
|
||||
startLine);
|
||||
code.GetStruct(),
|
||||
script_url.GetStruct(),
|
||||
start_line);
|
||||
}
|
||||
|
||||
bool CefFrameCToCpp::IsMain() {
|
||||
|
|
|
@ -51,8 +51,8 @@ class CefFrameCToCpp
|
|||
virtual void LoadURL(const CefString& url) OVERRIDE;
|
||||
virtual void LoadString(const CefString& string_val,
|
||||
const CefString& url) OVERRIDE;
|
||||
virtual void ExecuteJavaScript(const CefString& jsCode,
|
||||
const CefString& scriptUrl, int startLine) OVERRIDE;
|
||||
virtual void ExecuteJavaScript(const CefString& code,
|
||||
const CefString& script_url, int start_line) OVERRIDE;
|
||||
virtual bool IsMain() OVERRIDE;
|
||||
virtual bool IsFocused() OVERRIDE;
|
||||
virtual CefString GetName() OVERRIDE;
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
// 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/ctocpp/scheme_registrar_ctocpp.h"
|
||||
|
||||
|
||||
// VIRTUAL METHODS - Body may be edited by hand.
|
||||
|
||||
bool CefSchemeRegistrarCToCpp::AddCustomScheme(const CefString& scheme_name,
|
||||
bool is_standard, bool is_local, bool is_display_isolated) {
|
||||
if (CEF_MEMBER_MISSING(struct_, add_custom_scheme))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: scheme_name; type: string_byref_const
|
||||
DCHECK(!scheme_name.empty());
|
||||
if (scheme_name.empty())
|
||||
return false;
|
||||
|
||||
// Execute
|
||||
int _retval = struct_->add_custom_scheme(struct_,
|
||||
scheme_name.GetStruct(),
|
||||
is_standard,
|
||||
is_local,
|
||||
is_display_isolated);
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
}
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> long CefCToCpp<CefSchemeRegistrarCToCpp, CefSchemeRegistrar,
|
||||
cef_scheme_registrar_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#ifndef CEF_LIBCEF_DLL_CTOCPP_SCHEME_REGISTRAR_CTOCPP_H_
|
||||
#define CEF_LIBCEF_DLL_CTOCPP_SCHEME_REGISTRAR_CTOCPP_H_
|
||||
#pragma once
|
||||
|
||||
#ifndef USING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
|
||||
#else // USING_CEF_SHARED
|
||||
|
||||
#include "include/cef_scheme.h"
|
||||
#include "include/capi/cef_scheme_capi.h"
|
||||
#include "libcef_dll/ctocpp/ctocpp.h"
|
||||
|
||||
// Wrap a C structure with a C++ class.
|
||||
// This class may be instantiated and accessed wrapper-side only.
|
||||
class CefSchemeRegistrarCToCpp
|
||||
: public CefCToCpp<CefSchemeRegistrarCToCpp, CefSchemeRegistrar,
|
||||
cef_scheme_registrar_t> {
|
||||
public:
|
||||
explicit CefSchemeRegistrarCToCpp(cef_scheme_registrar_t* str)
|
||||
: CefCToCpp<CefSchemeRegistrarCToCpp, CefSchemeRegistrar,
|
||||
cef_scheme_registrar_t>(str) {}
|
||||
virtual ~CefSchemeRegistrarCToCpp() {}
|
||||
|
||||
// CefSchemeRegistrar methods
|
||||
virtual bool AddCustomScheme(const CefString& scheme_name, bool is_standard,
|
||||
bool is_local, bool is_display_isolated) OVERRIDE;
|
||||
};
|
||||
|
||||
#endif // USING_CEF_SHARED
|
||||
#endif // CEF_LIBCEF_DLL_CTOCPP_SCHEME_REGISTRAR_CTOCPP_H_
|
||||
|
|
@ -40,6 +40,7 @@
|
|||
#include "libcef_dll/cpptoc/process_message_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/request_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/response_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/scheme_registrar_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/stream_reader_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/stream_writer_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/v8context_cpptoc.h"
|
||||
|
@ -168,6 +169,7 @@ CEF_EXPORT void cef_shutdown() {
|
|||
DCHECK_EQ(CefResourceHandlerCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefResponseCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefSchemeHandlerFactoryCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefSchemeRegistrarCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefStreamReaderCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefStreamWriterCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefStringVisitorCToCpp::DebugObjCt, 0);
|
||||
|
@ -272,26 +274,6 @@ CEF_EXPORT int cef_clear_cross_origin_whitelist() {
|
|||
return _retval;
|
||||
}
|
||||
|
||||
CEF_EXPORT int cef_register_custom_scheme(const cef_string_t* scheme_name,
|
||||
int is_standard, int is_local, int is_display_isolated) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: scheme_name; type: string_byref_const
|
||||
DCHECK(scheme_name);
|
||||
if (!scheme_name)
|
||||
return 0;
|
||||
|
||||
// Execute
|
||||
bool _retval = CefRegisterCustomScheme(
|
||||
CefString(scheme_name),
|
||||
is_standard?true:false,
|
||||
is_local?true:false,
|
||||
is_display_isolated?true:false);
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
CEF_EXPORT int cef_register_scheme_handler_factory(
|
||||
const cef_string_t* scheme_name, const cef_string_t* domain_name,
|
||||
struct _cef_scheme_handler_factory_t* factory) {
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
#include "libcef_dll/ctocpp/process_message_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/request_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/response_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/scheme_registrar_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/stream_reader_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/stream_writer_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/v8context_ctocpp.h"
|
||||
|
@ -160,6 +161,7 @@ CEF_GLOBAL void CefShutdown() {
|
|||
DCHECK_EQ(CefResourceHandlerCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefResponseCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefSchemeHandlerFactoryCppToC::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefSchemeRegistrarCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefStreamReaderCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefStreamWriterCToCpp::DebugObjCt, 0);
|
||||
DCHECK_EQ(CefStringVisitorCppToC::DebugObjCt, 0);
|
||||
|
@ -264,26 +266,6 @@ CEF_GLOBAL bool CefClearCrossOriginWhitelist() {
|
|||
return _retval?true:false;
|
||||
}
|
||||
|
||||
CEF_GLOBAL bool CefRegisterCustomScheme(const CefString& scheme_name,
|
||||
bool is_standard, bool is_local, bool is_display_isolated) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: scheme_name; type: string_byref_const
|
||||
DCHECK(!scheme_name.empty());
|
||||
if (scheme_name.empty())
|
||||
return false;
|
||||
|
||||
// Execute
|
||||
int _retval = cef_register_custom_scheme(
|
||||
scheme_name.GetStruct(),
|
||||
is_standard,
|
||||
is_local,
|
||||
is_display_isolated);
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
}
|
||||
|
||||
CEF_GLOBAL bool CefRegisterSchemeHandlerFactory(const CefString& scheme_name,
|
||||
const CefString& domain_name,
|
||||
CefRefPtr<CefSchemeHandlerFactory> factory) {
|
||||
|
|
|
@ -72,7 +72,7 @@ gboolean XMLHttpRequestActivated(GtkWidget* widget) {
|
|||
// Callback for Debug > Scheme Handler... menu item.
|
||||
gboolean SchemeHandlerActivated(GtkWidget* widget) {
|
||||
if (g_handler.get() && g_handler->GetBrowserId())
|
||||
RunSchemeTest(g_handler->GetBrowser());
|
||||
scheme_test::RunTest(g_handler->GetBrowser());
|
||||
|
||||
return FALSE; // Don't stop this message.
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ int main(int argc, char* argv[]) {
|
|||
CefInitialize(main_args, settings, app.get());
|
||||
|
||||
// Register the scheme handler.
|
||||
InitSchemeTest();
|
||||
scheme_test::InitTest();
|
||||
|
||||
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_default_size(GTK_WINDOW(window), 800, 600);
|
||||
|
|
|
@ -58,43 +58,6 @@ static NSAutoreleasePool* g_autopool = nil;
|
|||
@end
|
||||
|
||||
|
||||
// Common base class for CEF browser windows. Contains methods relating to hole
|
||||
// punching required in order to display OpenGL underlay windows.
|
||||
@interface ClientWindow : NSWindow<CefUnderlayableSurface> {
|
||||
@private
|
||||
int underlaySurfaceCount_;
|
||||
}
|
||||
|
||||
// Informs the window that an underlay surface has been added/removed. The
|
||||
// window is non-opaque while underlay surfaces are present.
|
||||
- (void)underlaySurfaceAdded;
|
||||
- (void)underlaySurfaceRemoved;
|
||||
|
||||
@end
|
||||
|
||||
@implementation ClientWindow
|
||||
|
||||
- (void)underlaySurfaceAdded {
|
||||
ASSERT(underlaySurfaceCount_ >= 0);
|
||||
++underlaySurfaceCount_;
|
||||
|
||||
// We're having the OpenGL surface render under the window, so the window
|
||||
// needs to be not opaque.
|
||||
if (underlaySurfaceCount_ == 1)
|
||||
[self setOpaque:NO];
|
||||
}
|
||||
|
||||
- (void)underlaySurfaceRemoved {
|
||||
--underlaySurfaceCount_;
|
||||
ASSERT(underlaySurfaceCount_ >= 0);
|
||||
|
||||
if (underlaySurfaceCount_ == 0)
|
||||
[self setOpaque:YES];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
// Receives notifications from controls and the browser window. Will delete
|
||||
// itself when done.
|
||||
@interface ClientWindowDelegate : NSObject <NSWindowDelegate>
|
||||
|
@ -307,7 +270,7 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) {
|
|||
NSRect screen_rect = [[NSScreen mainScreen] visibleFrame];
|
||||
NSRect window_rect = { {0, screen_rect.size.height - kWindowHeight},
|
||||
{kWindowWidth, kWindowHeight} };
|
||||
NSWindow* mainWnd = [[ClientWindow alloc]
|
||||
NSWindow* mainWnd = [[UnderlayOpenGLHostingWindow alloc]
|
||||
initWithContentRect:window_rect
|
||||
styleMask:(NSTitledWindowMask |
|
||||
NSClosableWindowMask |
|
||||
|
@ -415,7 +378,7 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) {
|
|||
|
||||
- (IBAction)testSchemeHandler:(id)sender {
|
||||
if (g_handler.get() && g_handler->GetBrowserId())
|
||||
RunSchemeTest(g_handler->GetBrowser());
|
||||
scheme_test::RunTest(g_handler->GetBrowser());
|
||||
}
|
||||
|
||||
- (IBAction)testBinding:(id)sender {
|
||||
|
@ -503,8 +466,8 @@ int main(int argc, char* argv[]) {
|
|||
// Initialize CEF.
|
||||
CefInitialize(main_args, settings, app.get());
|
||||
|
||||
// Initialize tests.
|
||||
InitSchemeTest();
|
||||
// Register the scheme handler.
|
||||
scheme_test::InitTest();
|
||||
|
||||
// Create the application delegate and window.
|
||||
NSObject* delegate = [[ClientAppDelegate alloc] init];
|
||||
|
|
|
@ -77,7 +77,7 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
|
|||
CefInitialize(main_args, settings, app.get());
|
||||
|
||||
// Register the scheme handler.
|
||||
InitSchemeTest();
|
||||
scheme_test::InitTest();
|
||||
|
||||
HACCEL hAccelTable;
|
||||
|
||||
|
@ -371,7 +371,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
|
|||
return 0;
|
||||
case ID_TESTS_SCHEME_HANDLER: // Test the scheme handler
|
||||
if (browser.get())
|
||||
RunSchemeTest(browser);
|
||||
scheme_test::RunTest(browser);
|
||||
return 0;
|
||||
case ID_TESTS_BINDING: // Test JavaScript binding
|
||||
if (browser.get())
|
||||
|
|
|
@ -88,10 +88,17 @@ class ClientApp : public CefApp,
|
|||
// client_app_delegates.
|
||||
static void CreateRenderDelegates(RenderDelegateSet& delegates);
|
||||
|
||||
// Registers custom schemes. Implemented in client_app_delegates.
|
||||
static void RegisterCustomSchemes(CefRefPtr<CefSchemeRegistrar> registrar);
|
||||
|
||||
// CefApp methods.
|
||||
virtual CefRefPtr<CefProxyHandler> GetProxyHandler() OVERRIDE { return this; }
|
||||
virtual void OnRegisterCustomSchemes(
|
||||
CefRefPtr<CefSchemeRegistrar> registrar) OVERRIDE {
|
||||
RegisterCustomSchemes(registrar);
|
||||
}
|
||||
virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler()
|
||||
OVERRIDE { return this; }
|
||||
virtual CefRefPtr<CefProxyHandler> GetProxyHandler() OVERRIDE { return this; }
|
||||
|
||||
// CefProxyHandler methods.
|
||||
virtual void GetProxyForUrl(const CefString& url,
|
||||
|
|
|
@ -3,7 +3,13 @@
|
|||
// can be found in the LICENSE file.
|
||||
|
||||
#include "cefclient/client_app.h"
|
||||
#include "cefclient/scheme_test.h"
|
||||
|
||||
// static
|
||||
void ClientApp::CreateRenderDelegates(RenderDelegateSet& delegates) {
|
||||
}
|
||||
|
||||
// static
|
||||
void ClientApp::RegisterCustomSchemes(CefRefPtr<CefSchemeRegistrar> registrar) {
|
||||
scheme_test::RegisterCustomSchemes(registrar);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,9 @@
|
|||
#include "cefclient/resource.h"
|
||||
#endif
|
||||
|
||||
namespace scheme_test {
|
||||
|
||||
namespace {
|
||||
|
||||
// Implementation of the schema handler for client:// requests.
|
||||
class ClientSchemeHandler : public CefResourceHandler {
|
||||
|
@ -160,12 +163,19 @@ class ClientSchemeHandlerFactory : public CefSchemeHandlerFactory {
|
|||
IMPLEMENT_REFCOUNTING(ClientSchemeHandlerFactory);
|
||||
};
|
||||
|
||||
void InitSchemeTest() {
|
||||
CefRegisterCustomScheme("client", true, false, false);
|
||||
} // namespace
|
||||
|
||||
void RegisterCustomSchemes(CefRefPtr<CefSchemeRegistrar> registrar) {
|
||||
registrar->AddCustomScheme("client", true, false, false);
|
||||
}
|
||||
|
||||
void InitTest() {
|
||||
CefRegisterSchemeHandlerFactory("client", "tests",
|
||||
new ClientSchemeHandlerFactory());
|
||||
}
|
||||
|
||||
void RunSchemeTest(CefRefPtr<CefBrowser> browser) {
|
||||
void RunTest(CefRefPtr<CefBrowser> browser) {
|
||||
browser->GetMainFrame()->LoadURL("client://tests/handler.html");
|
||||
}
|
||||
|
||||
} // namespace scheme_test
|
||||
|
|
|
@ -9,11 +9,19 @@
|
|||
#include "include/cef_base.h"
|
||||
|
||||
class CefBrowser;
|
||||
class CefSchemeRegistrar;
|
||||
|
||||
// Register the scheme handler.
|
||||
void InitSchemeTest();
|
||||
namespace scheme_test {
|
||||
|
||||
// Register the scheme.
|
||||
void RegisterCustomSchemes(CefRefPtr<CefSchemeRegistrar> registrar);
|
||||
|
||||
// Create the scheme handler.
|
||||
void InitTest();
|
||||
|
||||
// Run the test.
|
||||
void RunSchemeTest(CefRefPtr<CefBrowser> browser);
|
||||
void RunTest(CefRefPtr<CefBrowser> browser);
|
||||
|
||||
} // namespace scheme_test
|
||||
|
||||
#endif // CEF_TESTS_CEFCLIENT_SCHEME_TEST_H_
|
||||
|
|
|
@ -15,3 +15,16 @@ void ClientApp::CreateRenderDelegates(RenderDelegateSet& delegates) {
|
|||
extern void CreateV8RendererTests(ClientApp::RenderDelegateSet& delegates);
|
||||
CreateV8RendererTests(delegates);
|
||||
}
|
||||
|
||||
// static
|
||||
void ClientApp::RegisterCustomSchemes(CefRefPtr<CefSchemeRegistrar> registrar) {
|
||||
// Bring in the scheme handler tests.
|
||||
extern void RegisterSchemeHandlerCustomSchemes(
|
||||
CefRefPtr<CefSchemeRegistrar> registrar);
|
||||
RegisterSchemeHandlerCustomSchemes(registrar);
|
||||
|
||||
// Bring in the cookie tests.
|
||||
extern void RegisterCookieCustomSchemes(
|
||||
CefRefPtr<CefSchemeRegistrar> registrar);
|
||||
RegisterCookieCustomSchemes(registrar);
|
||||
}
|
||||
|
|
|
@ -813,8 +813,6 @@ class CookieTestSchemeHandler : public TestHandler {
|
|||
manager2_ = CefCookieManager::CreateManager(CefString());
|
||||
|
||||
if (scheme_ != "http") {
|
||||
CefRegisterCustomScheme(scheme_, true, false, false);
|
||||
|
||||
std::vector<CefString> schemes;
|
||||
schemes.push_back("http");
|
||||
schemes.push_back("https");
|
||||
|
@ -957,3 +955,10 @@ TEST(CookieTest, GetCookieManagerCustom) {
|
|||
EXPECT_TRUE(handler->got_cookie2_);
|
||||
EXPECT_TRUE(handler->got_cookie3_);
|
||||
}
|
||||
|
||||
// Called to register custom schemes.
|
||||
void RegisterCookieCustomSchemes(
|
||||
CefRefPtr<CefSchemeRegistrar> registrar) {
|
||||
// Used by GetCookieManagerCustom test.
|
||||
registrar->AddCustomScheme("ccustom", true, false, false);
|
||||
}
|
||||
|
|
|
@ -325,20 +325,6 @@ TestResults g_TestResults;
|
|||
// If |domain| is empty the scheme will be registered as non-standard.
|
||||
void RegisterTestScheme(const std::string& scheme, const std::string& domain) {
|
||||
g_TestResults.reset();
|
||||
static std::set<std::string> schemes;
|
||||
|
||||
if (schemes.empty()) {
|
||||
// Never register built-in schemes.
|
||||
schemes.insert("http");
|
||||
}
|
||||
|
||||
// Only register custom schemes one time.
|
||||
if (schemes.find(scheme) == schemes.end()) {
|
||||
EXPECT_TRUE(CefRegisterCustomScheme(scheme, domain.empty()?false:true,
|
||||
false, false));
|
||||
WaitForUIThread();
|
||||
schemes.insert(scheme);
|
||||
}
|
||||
|
||||
EXPECT_TRUE(CefRegisterSchemeHandlerFactory(scheme, domain,
|
||||
new ClientSchemeHandlerFactory(&g_TestResults)));
|
||||
|
@ -961,3 +947,12 @@ TEST(SchemeHandlerTest, HttpXSSDifferentOriginWithDomain) {
|
|||
|
||||
ClearTestSchemes();
|
||||
}
|
||||
|
||||
// Called to register custom schemes.
|
||||
void RegisterSchemeHandlerCustomSchemes(
|
||||
CefRefPtr<CefSchemeRegistrar> registrar) {
|
||||
// Add a custom standard scheme.
|
||||
registrar->AddCustomScheme("customstd", true, false, false);
|
||||
// Ad a custom non-standard scheme.
|
||||
registrar->AddCustomScheme("customnonstd", false, false, false);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue