diff options
Diffstat (limited to 'include/internal')
23 files changed, 7449 insertions, 0 deletions
diff --git a/include/internal/cef_app_win.h b/include/internal/cef_app_win.h new file mode 100644 index 00000000..3e8a3eeb --- /dev/null +++ b/include/internal/cef_app_win.h @@ -0,0 +1,107 @@ +// Copyright (c) 2022 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. + +#ifndef CEF_INCLUDE_INTERNAL_CEF_APP_WIN_H_ +#define CEF_INCLUDE_INTERNAL_CEF_APP_WIN_H_ +#pragma once + +#include "include/base/cef_build.h" + +#if defined(OS_WIN) + +#if defined(ARCH_CPU_32_BITS) +#include <windows.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(ARCH_CPU_32_BITS) +typedef int(APIENTRY* wWinMainPtr)(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPWSTR lpCmdLine, + int nCmdShow); +typedef int (*mainPtr)(int argc, char* argv[]); + +/// +/// Run the main thread on 32-bit Windows using a fiber with the preferred 4MiB +/// stack size. This function must be called at the top of the executable entry +/// point function (`main()` or `wWinMain()`). It is used in combination with +/// the initial stack size of 0.5MiB configured via the `/STACK:0x80000` linker +/// flag on executable targets. This saves significant memory on threads (like +/// those in the Windows thread pool, and others) whose stack size can only be +/// controlled via the linker flag. +/// +/// CEF's main thread needs at least a 1.5 MiB stack size in order to avoid +/// stack overflow crashes. However, if this is set in the PE file then other +/// threads get this size as well, leading to address-space exhaustion in 32-bit +/// CEF. This function uses fibers to switch the main thread to a 4 MiB stack +/// (roughly the same effective size as the 64-bit build's 8 MiB stack) before +/// running any other code. +/// +/// Choose the function variant that matches the entry point function type used +/// by the executable. Reusing the entry point minimizes confusion when +/// examining call stacks in crash reports. +/// +/// If this function is already running on the fiber it will return -1 +/// immediately, meaning that execution should proceed with the remainder of the +/// entry point function. Otherwise, this function will block until the entry +/// point function has completed execution on the fiber and then return a result +/// >= 0, meaning that the entry point function should return the result +/// immediately without proceeding with execution. +/// +CEF_EXPORT int cef_run_winmain_with_preferred_stack_size(wWinMainPtr wWinMain, + HINSTANCE hInstance, + LPWSTR lpCmdLine, + int nCmdShow); +CEF_EXPORT int cef_run_main_with_preferred_stack_size(mainPtr main, + int argc, + char* argv[]); +#endif // defined(ARCH_CPU_32_BITS) + +/// +/// Call during process startup to enable High-DPI support on Windows 7 or +/// newer. Older versions of Windows should be left DPI-unaware because they do +/// not support DirectWrite and GDI fonts are kerned very badly. +/// +CEF_EXPORT void cef_enable_highdpi_support(void); + +/// +/// Set to true (1) before calling Windows APIs like TrackPopupMenu that enter a +/// modal message loop. Set to false (0) after exiting the modal message loop. +/// +CEF_EXPORT void cef_set_osmodal_loop(int osModalLoop); + +#ifdef __cplusplus +} +#endif + +#endif // defined(OS_WIN) +#endif // CEF_INCLUDE_INTERNAL_CEF_APP_WIN_H_ diff --git a/include/internal/cef_export.h b/include/internal/cef_export.h new file mode 100644 index 00000000..1915f5e5 --- /dev/null +++ b/include/internal/cef_export.h @@ -0,0 +1,59 @@ +// Copyright (c) 2009 The Chromium Embedded Framework Authors. 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. + +#ifndef CEF_INCLUDE_INTERNAL_CEF_EXPORT_H_ +#define CEF_INCLUDE_INTERNAL_CEF_EXPORT_H_ +#pragma once + +#include "include/base/cef_build.h" + +#if defined(COMPILER_MSVC) + +#ifdef BUILDING_CEF_SHARED +#define CEF_EXPORT __declspec(dllexport) +#elif USING_CEF_SHARED +#define CEF_EXPORT __declspec(dllimport) +#else +#define CEF_EXPORT +#endif + +#elif defined(COMPILER_GCC) + +#define CEF_EXPORT __attribute__((visibility("default"))) + +#endif // COMPILER_GCC + +#if defined(OS_WIN) +#define CEF_CALLBACK __stdcall +#else +#define CEF_CALLBACK +#endif + +#endif // CEF_INCLUDE_INTERNAL_CEF_EXPORT_H_ diff --git a/include/internal/cef_linux.h b/include/internal/cef_linux.h new file mode 100644 index 00000000..cebd7f6c --- /dev/null +++ b/include/internal/cef_linux.h @@ -0,0 +1,116 @@ +// Copyright (c) 2010 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. + +#ifndef CEF_INCLUDE_INTERNAL_CEF_LINUX_H_ +#define CEF_INCLUDE_INTERNAL_CEF_LINUX_H_ +#pragma once + +#include "include/internal/cef_types_linux.h" +#include "include/internal/cef_types_wrappers.h" + +// Handle types. +#define CefCursorHandle cef_cursor_handle_t +#define CefEventHandle cef_event_handle_t +#define CefWindowHandle cef_window_handle_t + +/// +/// Class representing CefExecuteProcess arguments. +/// +class CefMainArgs : public cef_main_args_t { + public: + CefMainArgs() : cef_main_args_t{} {} + CefMainArgs(const cef_main_args_t& r) : cef_main_args_t(r) {} + CefMainArgs(int argc_arg, char** argv_arg) + : cef_main_args_t{argc_arg, argv_arg} {} +}; + +struct CefWindowInfoTraits { + typedef cef_window_info_t struct_type; + + static inline void init(struct_type* s) {} + + static inline void clear(struct_type* s) { + cef_string_clear(&s->window_name); + } + + static inline void set(const struct_type* src, + struct_type* target, + bool copy) { + cef_string_set(src->window_name.str, src->window_name.length, + &target->window_name, copy); + target->bounds = src->bounds; + target->parent_window = src->parent_window; + target->windowless_rendering_enabled = src->windowless_rendering_enabled; + target->shared_texture_enabled = src->shared_texture_enabled; + target->external_begin_frame_enabled = src->external_begin_frame_enabled; + target->window = src->window; + } +}; + +/// +/// Class representing window information. +/// +class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> { + public: + typedef CefStructBase<CefWindowInfoTraits> parent; + + CefWindowInfo() : parent() {} + explicit CefWindowInfo(const cef_window_info_t& r) : parent(r) {} + explicit CefWindowInfo(const CefWindowInfo& r) : parent(r) {} + + CefWindowInfo& operator=(const CefWindowInfo&) = default; + CefWindowInfo& operator=(CefWindowInfo&&) = default; + + /// + /// Create the browser as a child window. + /// + void SetAsChild(CefWindowHandle parent, const CefRect& bounds) { + parent_window = parent; + this->bounds = bounds; + } + + /// + /// Create the browser using windowless (off-screen) rendering. No window + /// will be created for the browser and all rendering will occur via the + /// CefRenderHandler interface. The |parent| value will be used to identify + /// monitor info and to act as the parent window for dialogs, context menus, + /// etc. If |parent| is not provided then the main screen monitor will be used + /// and some functionality that requires a parent window may not function + /// correctly. In order to create windowless browsers the + /// CefSettings.windowless_rendering_enabled value must be set to true. + /// Transparent painting is enabled by default but can be disabled by setting + /// CefBrowserSettings.background_color to an opaque value. + /// + void SetAsWindowless(CefWindowHandle parent) { + windowless_rendering_enabled = true; + parent_window = parent; + } +}; + +#endif // CEF_INCLUDE_INTERNAL_CEF_LINUX_H_ diff --git a/include/internal/cef_logging_internal.h b/include/internal/cef_logging_internal.h new file mode 100644 index 00000000..d29cfc86 --- /dev/null +++ b/include/internal/cef_logging_internal.h @@ -0,0 +1,68 @@ +// Copyright (c) 2014 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. + +#ifndef CEF_INCLUDE_INTERNAL_CEF_LOGGING_INTERNAL_H_ +#define CEF_INCLUDE_INTERNAL_CEF_LOGGING_INTERNAL_H_ +#pragma once + +#include <stddef.h> + +#include "include/internal/cef_export.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// See include/base/cef_logging.h for macros and intended usage. + +/// +/// Gets the current log level. +/// +CEF_EXPORT int cef_get_min_log_level(void); + +/// +/// Gets the current vlog level for the given file (usually taken from +/// __FILE__). Note that |N| is the size *with* the null terminator. +/// +CEF_EXPORT int cef_get_vlog_level(const char* file_start, size_t N); + +/// +/// Add a log message. See the LogSeverity defines for supported |severity| +/// values. +/// +CEF_EXPORT void cef_log(const char* file, + int line, + int severity, + const char* message); + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // CEF_INCLUDE_INTERNAL_CEF_LOGGING_INTERNAL_H_ diff --git a/include/internal/cef_mac.h b/include/internal/cef_mac.h new file mode 100644 index 00000000..983eda8c --- /dev/null +++ b/include/internal/cef_mac.h @@ -0,0 +1,118 @@ +// Copyright (c) 2010 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. + +#ifndef CEF_INCLUDE_INTERNAL_CEF_MAC_H_ +#define CEF_INCLUDE_INTERNAL_CEF_MAC_H_ +#pragma once + +#include "include/internal/cef_types_mac.h" +#include "include/internal/cef_types_wrappers.h" + +// Handle types. +#define CefCursorHandle cef_cursor_handle_t +#define CefEventHandle cef_event_handle_t +#define CefWindowHandle cef_window_handle_t + +/// +/// Class representing CefExecuteProcess arguments. +/// +class CefMainArgs : public cef_main_args_t { + public: + CefMainArgs() : cef_main_args_t{} {} + CefMainArgs(const cef_main_args_t& r) : cef_main_args_t(r) {} + CefMainArgs(int argc_arg, char** argv_arg) + : cef_main_args_t{argc_arg, argv_arg} {} +}; + +struct CefWindowInfoTraits { + typedef cef_window_info_t struct_type; + + static inline void init(struct_type* s) {} + + static inline void clear(struct_type* s) { + cef_string_clear(&s->window_name); + } + + static inline void set(const struct_type* src, + struct_type* target, + bool copy) { + cef_string_set(src->window_name.str, src->window_name.length, + &target->window_name, copy); + target->bounds = src->bounds; + target->hidden = src->hidden; + target->parent_view = src->parent_view; + target->windowless_rendering_enabled = src->windowless_rendering_enabled; + target->shared_texture_enabled = src->shared_texture_enabled; + target->external_begin_frame_enabled = src->external_begin_frame_enabled; + target->view = src->view; + } +}; + +/// +/// Class representing window information. +/// +class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> { + public: + typedef CefStructBase<CefWindowInfoTraits> parent; + + CefWindowInfo() : parent() {} + explicit CefWindowInfo(const cef_window_info_t& r) : parent(r) {} + explicit CefWindowInfo(const CefWindowInfo& r) : parent(r) {} + + CefWindowInfo& operator=(const CefWindowInfo&) = default; + CefWindowInfo& operator=(CefWindowInfo&&) = default; + + /// + /// Create the browser as a child view. + /// + void SetAsChild(CefWindowHandle parent, const CefRect& bounds) { + parent_view = parent; + this->bounds = bounds; + hidden = false; + } + + /// + /// Create the browser using windowless (off-screen) rendering. No view + /// will be created for the browser and all rendering will occur via the + /// CefRenderHandler interface. The |parent| value will be used to identify + /// monitor info and to act as the parent view for dialogs, context menus, + /// etc. If |parent| is not provided then the main screen monitor will be used + /// and some functionality that requires a parent view may not function + /// correctly. In order to create windowless browsers the + /// CefSettings.windowless_rendering_enabled value must be set to true. + /// Transparent painting is enabled by default but can be disabled by setting + /// CefBrowserSettings.background_color to an opaque value. + /// + void SetAsWindowless(CefWindowHandle parent) { + windowless_rendering_enabled = true; + parent_view = parent; + } +}; + +#endif // CEF_INCLUDE_INTERNAL_CEF_MAC_H_ diff --git a/include/internal/cef_ptr.h b/include/internal/cef_ptr.h new file mode 100644 index 00000000..855ade53 --- /dev/null +++ b/include/internal/cef_ptr.h @@ -0,0 +1,176 @@ +// Copyright (c) 2014 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. + +#ifndef CEF_INCLUDE_INTERNAL_CEF_PTR_H_ +#define CEF_INCLUDE_INTERNAL_CEF_PTR_H_ +#pragma once + +#include <memory> + +#include "include/base/cef_build.h" +#include "include/base/cef_ref_counted.h" + +/// +/// Smart pointer implementation that is an alias of scoped_refptr from +/// include/base/cef_ref_counted.h. +/// +/// A smart pointer class for reference counted objects. Use this class instead +/// of calling AddRef and Release manually on a reference counted object to +/// avoid common memory leaks caused by forgetting to Release an object +/// reference. Sample usage: +/// +/// <pre> +/// class MyFoo : public CefBaseRefCounted { +/// ... +/// }; +/// +/// void some_function() { +/// // The MyFoo object that |foo| represents starts with a single +/// // reference. +/// CefRefPtr<MyFoo> foo = new MyFoo(); +/// foo->Method(param); +/// // |foo| is released when this function returns +/// } +/// +/// void some_other_function() { +/// CefRefPtr<MyFoo> foo = new MyFoo(); +/// ... +/// foo = NULL; /// explicitly releases |foo| +/// ... +/// if (foo) +/// foo->Method(param); +/// } +/// </pre> +/// +/// The above examples show how CefRefPtr<T> acts like a pointer to T. +/// Given two CefRefPtr<T> classes, it is also possible to exchange +/// references between the two objects, like so: +/// +/// <pre> +/// { +/// CefRefPtr<MyFoo> a = new MyFoo(); +/// CefRefPtr<MyFoo> b; +/// +/// b.swap(a); +/// // now, |b| references the MyFoo object, and |a| references NULL. +/// } +/// </pre> +/// +/// To make both |a| and |b| in the above example reference the same MyFoo +/// object, simply use the assignment operator: +/// +/// <pre> +/// { +/// CefRefPtr<MyFoo> a = new MyFoo(); +/// CefRefPtr<MyFoo> b; +/// +/// b = a; +/// // now, |a| and |b| each own a reference to the same MyFoo object. +/// // the reference count of the underlying MyFoo object will be 2. +/// } +/// </pre> +/// +/// Reference counted objects can also be passed as function parameters and +/// used as function return values: +/// +/// <pre> +/// void some_func_with_param(CefRefPtr<MyFoo> param) { +/// // A reference is added to the MyFoo object that |param| represents +/// // during the scope of some_func_with_param() and released when +/// // some_func_with_param() goes out of scope. +/// } +/// +/// CefRefPtr<MyFoo> some_func_with_retval() { +/// // The MyFoo object that |foox| represents starts with a single +/// // reference. +/// CefRefPtr<MyFoo> foox = new MyFoo(); +/// +/// // Creating the return value adds an additional reference. +/// return foox; +/// +/// // When some_func_with_retval() goes out of scope the original |foox| +/// // reference is released. +/// } +/// +/// void and_another_function() { +/// CefRefPtr<MyFoo> foo = new MyFoo(); +/// +/// // pass |foo| as a parameter. +/// some_function(foo); +/// +/// CefRefPtr<MyFoo> foo2 = some_func_with_retval(); +/// // Now, since we kept a reference to the some_func_with_retval() return +/// // value, |foo2| is the only class pointing to the MyFoo object created +/// in some_func_with_retval(), and it has a reference count of 1. +/// +/// some_func_with_retval(); +/// // Now, since we didn't keep a reference to the some_func_with_retval() +/// // return value, the MyFoo object created in some_func_with_retval() +/// // will automatically be released. +/// } +/// </pre> +/// +/// And in standard containers: +/// +/// <pre> +/// { +/// // Create a vector that holds MyFoo objects. +/// std::vector<CefRefPtr<MyFoo> > MyFooVec; +/// +/// // The MyFoo object that |foo| represents starts with a single +/// // reference. +/// CefRefPtr<MyFoo> foo = new MyFoo(); +/// +/// // When the MyFoo object is added to |MyFooVec| the reference count +/// // is increased to 2. +/// MyFooVec.push_back(foo); +/// } +/// </pre> +/// +template <class T> +using CefRefPtr = scoped_refptr<T>; + +/// +/// A CefOwnPtr<T> is like a T*, except that the destructor of CefOwnPtr<T> +/// automatically deletes the pointer it holds (if any). That is, CefOwnPtr<T> +/// owns the T object that it points to. Like a T*, a CefOwnPtr<T> may hold +/// either NULL or a pointer to a T object. Also like T*, CefOwnPtr<T> is +/// thread-compatible, and once you dereference it, you get the thread safety +/// guarantees of T. +/// +template <class T, class D = std::default_delete<T>> +using CefOwnPtr = std::unique_ptr<T, D>; + +/// +/// A CefRawPtr<T> is the same as T* +/// +template <class T> +using CefRawPtr = T*; + +#endif // CEF_INCLUDE_INTERNAL_CEF_PTR_H_ diff --git a/include/internal/cef_string.h b/include/internal/cef_string.h new file mode 100644 index 00000000..77c8ca3d --- /dev/null +++ b/include/internal/cef_string.h @@ -0,0 +1,112 @@ +// Copyright (c) 2010 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. + +#ifndef CEF_INCLUDE_INTERNAL_CEF_STRING_H_ +#define CEF_INCLUDE_INTERNAL_CEF_STRING_H_ +#pragma once + +// The CEF interface is built with one string type as the default. Comment out +// all but one of the CEF_STRING_TYPE_* defines below to specify the default. +// If you change the default you MUST recompile all of CEF. + +// Build with the UTF8 string type as default. +// #define CEF_STRING_TYPE_UTF8 1 + +// Build with the UTF16 string type as default. +#define CEF_STRING_TYPE_UTF16 1 + +// Build with the wide string type as default. +// #define CEF_STRING_TYPE_WIDE 1 + +#include "include/internal/cef_string_types.h" + +#ifdef __cplusplus +#include "include/internal/cef_string_wrappers.h" +#if defined(CEF_STRING_TYPE_UTF16) +typedef CefStringUTF16 CefString; +#elif defined(CEF_STRING_TYPE_UTF8) +typedef CefStringUTF8 CefString; +#elif defined(CEF_STRING_TYPE_WIDE) +typedef CefStringWide CefString; +#endif +#endif // __cplusplus + +#if defined(CEF_STRING_TYPE_UTF8) +typedef char cef_char_t; +typedef cef_string_utf8_t cef_string_t; +typedef cef_string_userfree_utf8_t cef_string_userfree_t; +#define cef_string_set cef_string_utf8_set +#define cef_string_copy cef_string_utf8_copy +#define cef_string_clear cef_string_utf8_clear +#define cef_string_userfree_alloc cef_string_userfree_utf8_alloc +#define cef_string_userfree_free cef_string_userfree_utf8_free +#define cef_string_from_ascii cef_string_utf8_copy +#define cef_string_to_utf8 cef_string_utf8_copy +#define cef_string_from_utf8 cef_string_utf8_copy +#define cef_string_to_utf16 cef_string_utf8_to_utf16 +#define cef_string_from_utf16 cef_string_utf16_to_utf8 +#define cef_string_to_wide cef_string_utf8_to_wide +#define cef_string_from_wide cef_string_wide_to_utf8 +#elif defined(CEF_STRING_TYPE_UTF16) +typedef char16 cef_char_t; +typedef cef_string_userfree_utf16_t cef_string_userfree_t; +typedef cef_string_utf16_t cef_string_t; +#define cef_string_set cef_string_utf16_set +#define cef_string_copy cef_string_utf16_copy +#define cef_string_clear cef_string_utf16_clear +#define cef_string_userfree_alloc cef_string_userfree_utf16_alloc +#define cef_string_userfree_free cef_string_userfree_utf16_free +#define cef_string_from_ascii cef_string_ascii_to_utf16 +#define cef_string_to_utf8 cef_string_utf16_to_utf8 +#define cef_string_from_utf8 cef_string_utf8_to_utf16 +#define cef_string_to_utf16 cef_string_utf16_copy +#define cef_string_from_utf16 cef_string_utf16_copy +#define cef_string_to_wide cef_string_utf16_to_wide +#define cef_string_from_wide cef_string_wide_to_utf16 +#elif defined(CEF_STRING_TYPE_WIDE) +typedef wchar_t cef_char_t; +typedef cef_string_wide_t cef_string_t; +typedef cef_string_userfree_wide_t cef_string_userfree_t; +#define cef_string_set cef_string_wide_set +#define cef_string_copy cef_string_wide_copy +#define cef_string_clear cef_string_wide_clear +#define cef_string_userfree_alloc cef_string_userfree_wide_alloc +#define cef_string_userfree_free cef_string_userfree_wide_free +#define cef_string_from_ascii cef_string_ascii_to_wide +#define cef_string_to_utf8 cef_string_wide_to_utf8 +#define cef_string_from_utf8 cef_string_utf8_to_wide +#define cef_string_to_utf16 cef_string_wide_to_utf16 +#define cef_string_from_utf16 cef_string_utf16_to_wide +#define cef_string_to_wide cef_string_wide_copy +#define cef_string_from_wide cef_string_wide_copy +#else +#error Please choose a string type. +#endif + +#endif // CEF_INCLUDE_INTERNAL_CEF_STRING_H_ diff --git a/include/internal/cef_string_list.h b/include/internal/cef_string_list.h new file mode 100644 index 00000000..0b6226bc --- /dev/null +++ b/include/internal/cef_string_list.h @@ -0,0 +1,89 @@ +// Copyright (c) 2009 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. + +#ifndef CEF_INCLUDE_INTERNAL_CEF_STRING_LIST_H_ +#define CEF_INCLUDE_INTERNAL_CEF_STRING_LIST_H_ +#pragma once + +#include "include/internal/cef_export.h" +#include "include/internal/cef_string.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// +/// CEF string maps are a set of key/value string pairs. +/// +typedef void* cef_string_list_t; + +/// +/// Allocate a new string map. +/// +CEF_EXPORT cef_string_list_t cef_string_list_alloc(void); + +/// +/// Return the number of elements in the string list. +/// +CEF_EXPORT size_t cef_string_list_size(cef_string_list_t list); + +/// +/// Retrieve the value at the specified zero-based string list index. Returns +/// true (1) if the value was successfully retrieved. +/// +CEF_EXPORT int cef_string_list_value(cef_string_list_t list, + size_t index, + cef_string_t* value); + +/// +/// Append a new value at the end of the string list. +/// +CEF_EXPORT void cef_string_list_append(cef_string_list_t list, + const cef_string_t* value); + +/// +/// Clear the string list. +/// +CEF_EXPORT void cef_string_list_clear(cef_string_list_t list); + +/// +/// Free the string list. +/// +CEF_EXPORT void cef_string_list_free(cef_string_list_t list); + +/// +/// Creates a copy of an existing string list. +/// +CEF_EXPORT cef_string_list_t cef_string_list_copy(cef_string_list_t list); + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_INTERNAL_CEF_STRING_LIST_H_ diff --git a/include/internal/cef_string_map.h b/include/internal/cef_string_map.h new file mode 100644 index 00000000..f3a80835 --- /dev/null +++ b/include/internal/cef_string_map.h @@ -0,0 +1,98 @@ +// Copyright (c) 2009 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. + +#ifndef CEF_INCLUDE_INTERNAL_CEF_STRING_MAP_H_ +#define CEF_INCLUDE_INTERNAL_CEF_STRING_MAP_H_ +#pragma once + +#include "include/internal/cef_export.h" +#include "include/internal/cef_string.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// +/// CEF string maps are a set of key/value string pairs. +/// +typedef void* cef_string_map_t; + +/// +/// Allocate a new string map. +/// +CEF_EXPORT cef_string_map_t cef_string_map_alloc(void); + +/// +/// Return the number of elements in the string map. +/// +CEF_EXPORT size_t cef_string_map_size(cef_string_map_t map); + +/// +/// Return the value assigned to the specified key. +/// +CEF_EXPORT int cef_string_map_find(cef_string_map_t map, + const cef_string_t* key, + cef_string_t* value); + +/// +/// Return the key at the specified zero-based string map index. +/// +CEF_EXPORT int cef_string_map_key(cef_string_map_t map, + size_t index, + cef_string_t* key); + +/// +/// Return the value at the specified zero-based string map index. +/// +CEF_EXPORT int cef_string_map_value(cef_string_map_t map, + size_t index, + cef_string_t* value); + +/// +/// Append a new key/value pair at the end of the string map. +/// +CEF_EXPORT int cef_string_map_append(cef_string_map_t map, + const cef_string_t* key, + const cef_string_t* value); + +/// +/// Clear the string map. +/// +CEF_EXPORT void cef_string_map_clear(cef_string_map_t map); + +/// +/// Free the string map. +/// +CEF_EXPORT void cef_string_map_free(cef_string_map_t map); + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_INTERNAL_CEF_STRING_MAP_H_ diff --git a/include/internal/cef_string_multimap.h b/include/internal/cef_string_multimap.h new file mode 100644 index 00000000..313bd9dc --- /dev/null +++ b/include/internal/cef_string_multimap.h @@ -0,0 +1,106 @@ +// Copyright (c) 2011 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. + +#ifndef CEF_INCLUDE_INTERNAL_CEF_STRING_MULTIMAP_H_ +#define CEF_INCLUDE_INTERNAL_CEF_STRING_MULTIMAP_H_ +#pragma once + +#include "include/internal/cef_export.h" +#include "include/internal/cef_string.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// +/// CEF string multimaps are a set of key/value string pairs. +/// More than one value can be assigned to a single key. +/// +typedef void* cef_string_multimap_t; + +/// +/// Allocate a new string multimap. +/// +CEF_EXPORT cef_string_multimap_t cef_string_multimap_alloc(void); + +/// +/// Return the number of elements in the string multimap. +/// +CEF_EXPORT size_t cef_string_multimap_size(cef_string_multimap_t map); + +/// +/// Return the number of values with the specified key. +/// +CEF_EXPORT size_t cef_string_multimap_find_count(cef_string_multimap_t map, + const cef_string_t* key); + +/// +/// Return the value_index-th value with the specified key. +/// +CEF_EXPORT int cef_string_multimap_enumerate(cef_string_multimap_t map, + const cef_string_t* key, + size_t value_index, + cef_string_t* value); + +/// +/// Return the key at the specified zero-based string multimap index. +/// +CEF_EXPORT int cef_string_multimap_key(cef_string_multimap_t map, + size_t index, + cef_string_t* key); + +/// +/// Return the value at the specified zero-based string multimap index. +/// +CEF_EXPORT int cef_string_multimap_value(cef_string_multimap_t map, + size_t index, + cef_string_t* value); + +/// +/// Append a new key/value pair at the end of the string multimap. +/// +CEF_EXPORT int cef_string_multimap_append(cef_string_multimap_t map, + const cef_string_t* key, + const cef_string_t* value); + +/// +/// Clear the string multimap. +/// +CEF_EXPORT void cef_string_multimap_clear(cef_string_multimap_t map); + +/// +/// Free the string multimap. +/// +CEF_EXPORT void cef_string_multimap_free(cef_string_multimap_t map); + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_INTERNAL_CEF_STRING_MULTIMAP_H_ diff --git a/include/internal/cef_string_types.h b/include/internal/cef_string_types.h new file mode 100644 index 00000000..00a16c70 --- /dev/null +++ b/include/internal/cef_string_types.h @@ -0,0 +1,212 @@ +// Copyright (c) 2010 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. + +#ifndef CEF_INCLUDE_INTERNAL_CEF_STRING_TYPES_H_ +#define CEF_INCLUDE_INTERNAL_CEF_STRING_TYPES_H_ +#pragma once + +#include <stddef.h> + +#include "include/base/cef_basictypes.h" +#include "include/internal/cef_export.h" + +/// +/// \file +/// CEF provides functions for converting between UTF-8, -16 and -32 strings. +/// CEF string types are safe for reading from multiple threads but not for +/// modification. It is the user's responsibility to provide synchronization if +/// modifying CEF strings from multiple threads. +/// + +#ifdef __cplusplus +extern "C" { +#endif + +/// +/// CEF string type definitions. Whomever allocates |str| is responsible for +/// providing an appropriate |dtor| implementation that will free the string in +/// the same memory space. When reusing an existing string structure make sure +/// to call |dtor| for the old value before assigning new |str| and |dtor| +/// values. Static strings will have a NULL |dtor| value. Using the below +/// functions if you want this managed for you. +/// + +typedef struct _cef_string_wide_t { + wchar_t* str; + size_t length; + void (*dtor)(wchar_t* str); +} cef_string_wide_t; + +typedef struct _cef_string_utf8_t { + char* str; + size_t length; + void (*dtor)(char* str); +} cef_string_utf8_t; + +typedef struct _cef_string_utf16_t { + char16* str; + size_t length; + void (*dtor)(char16* str); +} cef_string_utf16_t; + +/// +/// These functions set string values. If |copy| is true (1) the value will be +/// copied instead of referenced. It is up to the user to properly manage +/// the lifespan of references. +/// + +CEF_EXPORT int cef_string_wide_set(const wchar_t* src, + size_t src_len, + cef_string_wide_t* output, + int copy); +CEF_EXPORT int cef_string_utf8_set(const char* src, + size_t src_len, + cef_string_utf8_t* output, + int copy); +CEF_EXPORT int cef_string_utf16_set(const char16* src, + size_t src_len, + cef_string_utf16_t* output, + int copy); + +/// +/// Convenience macros for copying values. +/// + +#define cef_string_wide_copy(src, src_len, output) \ + cef_string_wide_set(src, src_len, output, true) +#define cef_string_utf8_copy(src, src_len, output) \ + cef_string_utf8_set(src, src_len, output, true) +#define cef_string_utf16_copy(src, src_len, output) \ + cef_string_utf16_set(src, src_len, output, true) + +/// +/// These functions clear string values. The structure itself is not freed. +/// + +CEF_EXPORT void cef_string_wide_clear(cef_string_wide_t* str); +CEF_EXPORT void cef_string_utf8_clear(cef_string_utf8_t* str); +CEF_EXPORT void cef_string_utf16_clear(cef_string_utf16_t* str); + +/// +/// These functions compare two string values with the same results as strcmp(). +/// + +CEF_EXPORT int cef_string_wide_cmp(const cef_string_wide_t* str1, + const cef_string_wide_t* str2); +CEF_EXPORT int cef_string_utf8_cmp(const cef_string_utf8_t* str1, + const cef_string_utf8_t* str2); +CEF_EXPORT int cef_string_utf16_cmp(const cef_string_utf16_t* str1, + const cef_string_utf16_t* str2); + +/// +/// These functions convert between UTF-8, -16, and -32 strings. They are +/// potentially slow so unnecessary conversions should be avoided. The best +/// possible result will always be written to |output| with the boolean return +/// value indicating whether the conversion is 100% valid. +/// + +CEF_EXPORT int cef_string_wide_to_utf8(const wchar_t* src, + size_t src_len, + cef_string_utf8_t* output); +CEF_EXPORT int cef_string_utf8_to_wide(const char* src, + size_t src_len, + cef_string_wide_t* output); + +CEF_EXPORT int cef_string_wide_to_utf16(const wchar_t* src, + size_t src_len, + cef_string_utf16_t* output); +CEF_EXPORT int cef_string_utf16_to_wide(const char16* src, + size_t src_len, + cef_string_wide_t* output); + +CEF_EXPORT int cef_string_utf8_to_utf16(const char* src, + size_t src_len, + cef_string_utf16_t* output); +CEF_EXPORT int cef_string_utf16_to_utf8(const char16* src, + size_t src_len, + cef_string_utf8_t* output); + +/// +/// These functions convert an ASCII string, typically a hardcoded constant, to +/// a Wide/UTF16 string. Use instead of the UTF8 conversion routines if you know +/// the string is ASCII. +/// + +CEF_EXPORT int cef_string_ascii_to_wide(const char* src, + size_t src_len, + cef_string_wide_t* output); +CEF_EXPORT int cef_string_ascii_to_utf16(const char* src, + size_t src_len, + cef_string_utf16_t* output); + +/// +/// It is sometimes necessary for the system to allocate string structures with +/// the expectation that the user will free them. The userfree types act as a +/// hint that the user is responsible for freeing the structure. +/// + +typedef cef_string_wide_t* cef_string_userfree_wide_t; +typedef cef_string_utf8_t* cef_string_userfree_utf8_t; +typedef cef_string_utf16_t* cef_string_userfree_utf16_t; + +/// +/// These functions allocate a new string structure. They must be freed by +/// calling the associated free function. +/// + +CEF_EXPORT cef_string_userfree_wide_t cef_string_userfree_wide_alloc(void); +CEF_EXPORT cef_string_userfree_utf8_t cef_string_userfree_utf8_alloc(void); +CEF_EXPORT cef_string_userfree_utf16_t cef_string_userfree_utf16_alloc(void); + +/// +/// These functions free the string structure allocated by the associated +/// alloc function. Any string contents will first be cleared. +/// + +CEF_EXPORT void cef_string_userfree_wide_free(cef_string_userfree_wide_t str); +CEF_EXPORT void cef_string_userfree_utf8_free(cef_string_userfree_utf8_t str); +CEF_EXPORT void cef_string_userfree_utf16_free(cef_string_userfree_utf16_t str); + +/// +/// These functions convert utf16 string case using the current ICU locale. This +/// may change the length of the string in some cases. +/// + +CEF_EXPORT int cef_string_utf16_to_lower(const char16* src, + size_t src_len, + cef_string_utf16_t* output); +CEF_EXPORT int cef_string_utf16_to_upper(const char16* src, + size_t src_len, + cef_string_utf16_t* output); + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_INTERNAL_CEF_STRING_TYPES_H_ diff --git a/include/internal/cef_string_wrappers.h b/include/internal/cef_string_wrappers.h new file mode 100644 index 00000000..44e453f6 --- /dev/null +++ b/include/internal/cef_string_wrappers.h @@ -0,0 +1,865 @@ +// Copyright (c) 2010 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. + +#ifndef CEF_INCLUDE_INTERNAL_CEF_STRING_WRAPPERS_H_ +#define CEF_INCLUDE_INTERNAL_CEF_STRING_WRAPPERS_H_ +#pragma once + +#include <memory.h> +#include <string> + +#include "include/internal/cef_string_types.h" + +#if defined(USING_CHROMIUM_INCLUDES) +#include "base/files/file_path.h" +#endif + +/// +/// Traits implementation for wide character strings. +/// +struct CefStringTraitsWide { + typedef wchar_t char_type; + typedef cef_string_wide_t struct_type; + typedef cef_string_userfree_wide_t userfree_struct_type; + + static inline void clear(struct_type* s) { cef_string_wide_clear(s); } + static inline int set(const char_type* src, + size_t src_size, + struct_type* output, + int copy) { + return cef_string_wide_set(src, src_size, output, copy); + } + static inline int compare(const struct_type* s1, const struct_type* s2) { + return cef_string_wide_cmp(s1, s2); + } + static inline userfree_struct_type userfree_alloc() { + return cef_string_userfree_wide_alloc(); + } + static inline void userfree_free(userfree_struct_type ufs) { + return cef_string_userfree_wide_free(ufs); + } + + // Conversion methods. + static inline bool from_ascii(const char* str, size_t len, struct_type* s) { + return cef_string_ascii_to_wide(str, len, s) ? true : false; + } + static inline std::string to_string(const struct_type* s) { + cef_string_utf8_t cstr; + memset(&cstr, 0, sizeof(cstr)); + cef_string_wide_to_utf8(s->str, s->length, &cstr); + std::string str; + if (cstr.length > 0) { + str = std::string(cstr.str, cstr.length); + } + cef_string_utf8_clear(&cstr); + return str; + } + static inline bool from_string(const std::string::value_type* data, + size_t length, + struct_type* s) { + return cef_string_utf8_to_wide(data, length, s) ? true : false; + } + static inline bool from_string(const std::string& str, struct_type* s) { + return from_string(str.data(), str.length(), s); + } + static inline std::wstring to_wstring(const struct_type* s) { + return std::wstring(s->str, s->length); + } + static inline bool from_wstring(const std::wstring::value_type* data, + size_t length, + struct_type* s) { + return cef_string_wide_set(data, length, s, true) ? true : false; + } + static inline bool from_wstring(const std::wstring& str, struct_type* s) { + return from_wstring(str.data(), str.length(), s); + } +#if defined(WCHAR_T_IS_UTF32) + static inline std::u16string to_string16(const struct_type* s) { + cef_string_utf16_t cstr; + memset(&cstr, 0, sizeof(cstr)); + cef_string_wide_to_utf16(s->str, s->length, &cstr); + std::u16string str; + if (cstr.length > 0) { + str = std::u16string( + reinterpret_cast<std::u16string::value_type*>(cstr.str), cstr.length); + } + cef_string_utf16_clear(&cstr); + return str; + } + static inline bool from_string16(const std::u16string::value_type* data, + size_t length, + struct_type* s) { + return cef_string_utf16_to_wide(reinterpret_cast<const char16*>(data), + length, s) + ? true + : false; + } +#else // WCHAR_T_IS_UTF32 + static inline std::u16string to_string16(const struct_type* s) { + return std::u16string( + reinterpret_cast<const std::u16string::value_type*>(s->str), s->length); + } + static inline bool from_string16(const std::u16string::value_type* data, + size_t length, + struct_type* s) { + return cef_string_wide_set(reinterpret_cast<const wchar_t*>(data), length, + s, true) + ? true + : false; + } +#endif // WCHAR_T_IS_UTF32 + static inline bool from_string16(const std::u16string& str, struct_type* s) { + return from_string16(str.data(), str.length(), s); + } +}; + +/// +/// Traits implementation for utf8 character strings. +/// +struct CefStringTraitsUTF8 { + typedef char char_type; + typedef cef_string_utf8_t struct_type; + typedef cef_string_userfree_utf8_t userfree_struct_type; + + static inline void clear(struct_type* s) { cef_string_utf8_clear(s); } + static inline int set(const char_type* src, + size_t src_size, + struct_type* output, + int copy) { + return cef_string_utf8_set(src, src_size, output, copy); + } + static inline int compare(const struct_type* s1, const struct_type* s2) { + return cef_string_utf8_cmp(s1, s2); + } + static inline userfree_struct_type userfree_alloc() { + return cef_string_userfree_utf8_alloc(); + } + static inline void userfree_free(userfree_struct_type ufs) { + return cef_string_userfree_utf8_free(ufs); + } + + // Conversion methods. + static inline bool from_ascii(const char* str, size_t len, struct_type* s) { + return cef_string_utf8_copy(str, len, s) ? true : false; + } + static inline std::string to_string(const struct_type* s) { + return std::string(s->str, s->length); + } + static inline bool from_string(const std::string::value_type* data, + size_t length, + struct_type* s) { + return cef_string_utf8_copy(data, length, s) ? true : false; + } + static inline bool from_string(const std::string& str, struct_type* s) { + return from_string(str.c_str(), str.length(), s); + } + static inline std::wstring to_wstring(const struct_type* s) { + cef_string_wide_t cstr; + memset(&cstr, 0, sizeof(cstr)); + cef_string_utf8_to_wide(s->str, s->length, &cstr); + std::wstring str; + if (cstr.length > 0) { + str = std::wstring(cstr.str, cstr.length); + } + cef_string_wide_clear(&cstr); + return str; + } + static inline bool from_wstring(const std::wstring::value_type* data, + size_t length, + struct_type* s) { + return cef_string_wide_to_utf8(data, length, s) ? true : false; + } + static inline bool from_wstring(const std::wstring& str, struct_type* s) { + return from_wstring(str.data(), str.length(), s); + } + static inline std::u16string to_string16(const struct_type* s) { + cef_string_utf16_t cstr; + memset(&cstr, 0, sizeof(cstr)); + cef_string_utf8_to_utf16(s->str, s->length, &cstr); + std::u16string str; + if (cstr.length > 0) { + str = std::u16string( + reinterpret_cast<std::u16string::value_type*>(cstr.str), cstr.length); + } + cef_string_utf16_clear(&cstr); + return str; + } + static inline bool from_string16(const std::u16string::value_type* data, + size_t length, + struct_type* s) { + return cef_string_utf16_to_utf8(reinterpret_cast<const char16*>(data), + length, s) + ? true + : false; + } + static inline bool from_string16(const std::u16string& str, struct_type* s) { + return from_string16(str.data(), str.length(), s); + } +}; + +/// +/// Traits implementation for utf16 character strings. +/// +struct CefStringTraitsUTF16 { + typedef char16 char_type; + typedef cef_string_utf16_t struct_type; + typedef cef_string_userfree_utf16_t userfree_struct_type; + + static inline void clear(struct_type* s) { cef_string_utf16_clear(s); } + static inline int set(const char_type* src, + size_t src_size, + struct_type* output, + int copy) { + return cef_string_utf16_set(src, src_size, output, copy); + } + static inline int compare(const struct_type* s1, const struct_type* s2) { + return cef_string_utf16_cmp(s1, s2); + } + static inline userfree_struct_type userfree_alloc() { + return cef_string_userfree_utf16_alloc(); + } + static inline void userfree_free(userfree_struct_type ufs) { + return cef_string_userfree_utf16_free(ufs); + } + + // Conversion methods. + static inline bool from_ascii(const char* str, size_t len, struct_type* s) { + return cef_string_ascii_to_utf16(str, len, s) ? true : false; + } + static inline std::string to_string(const struct_type* s) { + cef_string_utf8_t cstr; + memset(&cstr, 0, sizeof(cstr)); + cef_string_utf16_to_utf8(s->str, s->length, &cstr); + std::string str; + if (cstr.length > 0) { + str = std::string(cstr.str, cstr.length); + } + cef_string_utf8_clear(&cstr); + return str; + } + static inline bool from_string(const std::string::value_type* data, + size_t length, + struct_type* s) { + return cef_string_utf8_to_utf16(data, length, s) ? true : false; + } + static inline bool from_string(const std::string& str, struct_type* s) { + return from_string(str.data(), str.length(), s); + } +#if defined(WCHAR_T_IS_UTF32) + static inline std::wstring to_wstring(const struct_type* s) { + cef_string_wide_t cstr; + memset(&cstr, 0, sizeof(cstr)); + cef_string_utf16_to_wide(s->str, s->length, &cstr); + std::wstring str; + if (cstr.length > 0) { + str = std::wstring(cstr.str, cstr.length); + } + cef_string_wide_clear(&cstr); + return str; + } + static inline bool from_wstring(const std::wstring::value_type* data, + size_t length, + struct_type* s) { + return cef_string_wide_to_utf16(data, length, s) ? true : false; + } +#else // WCHAR_T_IS_UTF32 + static inline std::wstring to_wstring(const struct_type* s) { + return std::wstring(s->str, s->length); + } + static inline bool from_wstring(const std::wstring::value_type* data, + size_t length, + struct_type* s) { + return cef_string_utf16_set(data, length, s, true) ? true : false; + } +#endif // WCHAR_T_IS_UTF32 + static inline bool from_wstring(const std::wstring& str, struct_type* s) { + return from_wstring(str.data(), str.length(), s); + } + static inline std::u16string to_string16(const struct_type* s) { + return std::u16string( + reinterpret_cast<const std::u16string::value_type*>(s->str), s->length); + } + static inline bool from_string16(const std::u16string::value_type* data, + size_t length, + struct_type* s) { + return cef_string_utf16_set(reinterpret_cast<const char16*>(data), length, + s, true) + ? true + : false; + } + static inline bool from_string16(const std::u16string& str, struct_type* s) { + return from_string16(str.data(), str.length(), s); + } +}; + +/// +/// CEF string classes can convert between all supported string types. For +/// example, the CefStringWide class uses wchar_t as the underlying character +/// type and provides two approaches for converting data to/from a UTF8 string +/// (std::string). +/// +/// 1. Implicit conversion using the assignment operator overload. +/// <pre> +/// CefStringWide aCefString; +/// std::string aUTF8String; +/// aCefString = aUTF8String; // Assign std::string to CefStringWide +/// aUTF8String = aCefString; // Assign CefStringWide to std::string +/// </pre> +/// +/// 2. Explicit conversion using the FromString/ToString methods. +/// <pre> +/// CefStringWide aCefString; +/// std::string aUTF8String; +/// aCefString.FromString(aUTF8String); // Assign std::string to CefStringWide +/// aUTF8String = aCefString.ToString(); // Assign CefStringWide to +/// std::string +/// </pre> +/// +/// Conversion will only occur if the assigned value is a different string type. +/// Assigning a std::string to a CefStringUTF8, for example, will copy the data +/// without performing a conversion. +/// +/// CEF string classes are safe for reading from multiple threads but not for +/// modification. It is the user's responsibility to provide synchronization if +/// modifying CEF strings from multiple threads. +/// +template <class traits> +class CefStringBase { + public: + typedef typename traits::char_type char_type; + typedef typename traits::struct_type struct_type; + typedef typename traits::userfree_struct_type userfree_struct_type; + + /// + /// Default constructor. + /// + CefStringBase() : string_(NULL), owner_(false) {} + + /// + /// Create a new string from an existing string. Data will always be copied. + /// + CefStringBase(const CefStringBase& str) : string_(NULL), owner_(false) { + FromString(str.c_str(), str.length(), true); + } + + /// + /// Create a new string from an existing std::string. Data will be always + /// copied. Translation will occur if necessary based on the underlying string + /// type. + /// + CefStringBase(const std::string& src) : string_(NULL), owner_(false) { + FromString(src); + } + CefStringBase(const char* src, size_t length = 0) + : string_(NULL), owner_(false) { + if (src) { + FromString(src, length); + } + } + + /// + /// Create a new string from an existing std::wstring. Data will be always + /// copied. Translation will occur if necessary based on the underlying string + /// type. + /// + CefStringBase(const std::wstring& src) : string_(NULL), owner_(false) { + FromWString(src); + } + CefStringBase(const wchar_t* src, size_t length = 0) + : string_(NULL), owner_(false) { + if (src) { + FromWString(src, length); + } + } + + /// + /// Create a new string from an existing string16. Data will be always + /// copied. Translation will occur if necessary based on the underlying string + /// type. + /// + CefStringBase(const std::u16string& src) : string_(NULL), owner_(false) { + FromString16(src); + } + CefStringBase(const std::u16string::value_type* src, size_t length = 0) + : string_(NULL), owner_(false) { + if (src) { + FromString16(src, length); + } + } +#if defined(WCHAR_T_IS_UTF32) + CefStringBase(const char16* src, size_t length = 0) + : string_(NULL), owner_(false) { + if (src) { + FromString16(reinterpret_cast<const std::u16string::value_type*>(src), + length); + } + } +#endif // WCHAR_T_IS_UTF32 + + /// + /// Create a new string from an existing character array. If |copy| is true + /// this class will copy the data. Otherwise, this class will reference the + /// existing data. Referenced data must exist for the lifetime of this class + /// and will not be freed by this class. + /// + CefStringBase(const char_type* src, size_t src_len, bool copy) + : string_(NULL), owner_(false) { + if (src && src_len > 0) { + FromString(src, src_len, copy); + } + } + + /// + /// Create a new string referencing an existing string structure without + /// taking ownership. Referenced structures must exist for the lifetime of + /// this class and will not be freed by this class. + /// + CefStringBase(const struct_type* src) : string_(NULL), owner_(false) { + if (!src) { + return; + } + // Reference the existing structure without taking ownership. + Attach(const_cast<struct_type*>(src), false); + } + + virtual ~CefStringBase() { ClearAndFree(); } + + /// The following methods are named for compatibility with the standard + /// library string template types. + + /// + /// Return a read-only pointer to the string data. + /// + const char_type* c_str() const { return (string_ ? string_->str : NULL); } + + /// + /// Return the length of the string data. + /// + size_t length() const { return (string_ ? string_->length : 0); } + + /// + /// Return the length of the string data. + /// + inline size_t size() const { return length(); } + + /// + /// Returns true if the string is empty. + /// + bool empty() const { return (string_ == NULL || string_->length == 0); } + + /// + /// Compare this string to the specified string. + /// + int compare(const CefStringBase& str) const { + if (empty() && str.empty()) { + return 0; + } + if (empty()) { + return -1; + } + if (str.empty()) { + return 1; + } + return traits::compare(string_, str.GetStruct()); + } + + /// + /// Clear the string data. + /// + void clear() { + if (string_) { + traits::clear(string_); + } + } + + /// + /// Swap this string's contents with the specified string. + /// + void swap(CefStringBase& str) { + struct_type* tmp_string = string_; + bool tmp_owner = owner_; + string_ = str.string_; + owner_ = str.owner_; + str.string_ = tmp_string; + str.owner_ = tmp_owner; + } + + // The following methods are unique to CEF string template types. + + /// + /// Returns true if this class owns the underlying string structure. + /// + bool IsOwner() const { return owner_; } + + /// + /// Returns a read-only pointer to the underlying string structure. May return + /// NULL if no structure is currently allocated. + /// + const struct_type* GetStruct() const { return string_; } + + /// + /// Returns a writable pointer to the underlying string structure. Will never + /// return NULL. + /// + struct_type* GetWritableStruct() { + AllocIfNeeded(); + return string_; + } + + /// + /// Clear the state of this class. The underlying string structure and data + /// will be freed if this class owns the structure. + /// + void ClearAndFree() { + if (!string_) { + return; + } + if (owner_) { + clear(); + delete string_; + } + string_ = NULL; + owner_ = false; + } + + /// + /// Attach to the specified string structure. If |owner| is true this class + /// will take ownership of the structure. + /// + void Attach(struct_type* str, bool owner) { + // Free the previous structure and data, if any. + ClearAndFree(); + + string_ = str; + owner_ = owner; + } + + /// + /// Take ownership of the specified userfree structure's string data. The + /// userfree structure itself will be freed. Only use this method with + /// userfree structures. + /// + void AttachToUserFree(userfree_struct_type str) { + // Free the previous structure and data, if any. + ClearAndFree(); + + if (!str) { + return; + } + + AllocIfNeeded(); + owner_ = true; + memcpy(string_, str, sizeof(struct_type)); + + /// Free the |str| structure but not the data. + memset(str, 0, sizeof(struct_type)); + traits::userfree_free(str); + } + + /// + /// Detach from the underlying string structure. To avoid memory leaks only + /// use this method if you already hold a pointer to the underlying string + /// structure. + /// + void Detach() { + string_ = NULL; + owner_ = false; + } + + /// + /// Create a userfree structure and give it ownership of this class' string + /// data. This class will be disassociated from the data. May return NULL if + /// this string class currently contains no data. + /// + userfree_struct_type DetachToUserFree() { + if (empty()) { + return NULL; + } + + userfree_struct_type str = traits::userfree_alloc(); + if (owner_) { + // Transfer ownership of the data to |str|. + memcpy(str, string_, sizeof(struct_type)); + // Free this class' structure but not the data. + memset(string_, 0, sizeof(struct_type)); + } else { + // Copy the data to |str|. + traits::set(string_->str, string_->length, str, /*copy=*/true); + } + + ClearAndFree(); + + return str; + } + + /// + /// Set this string's data to the specified character array. If |copy| is true + /// this class will copy the data. Otherwise, this class will reference the + /// existing data. Referenced data must exist for the lifetime of this class + /// and will not be freed by this class. + /// + bool FromString(const char_type* src, size_t src_len, bool copy) { + if (src == NULL || src_len == 0) { + clear(); + return true; + } + AllocIfNeeded(); + return traits::set(src, src_len, string_, copy) ? true : false; + } + + /// + /// Set this string's data from an existing ASCII string. Data will be always + /// copied. Translation will occur if necessary based on the underlying string + /// type. + /// + bool FromASCII(const char* str) { + size_t len = str ? strlen(str) : 0; + if (len == 0) { + clear(); + return true; + } + AllocIfNeeded(); + return traits::from_ascii(str, len, string_); + } + + /// + /// Return this string's data as a std::string. Translation will occur if + /// necessary based on the underlying string type. + /// + std::string ToString() const { + if (empty()) { + return std::string(); + } + return traits::to_string(string_); + } + + /// + /// Set this string's data from an existing std::string. Data will be always + /// copied. Translation will occur if necessary based on the underlying string + /// type. + /// + bool FromString(const std::string& str) { + if (str.empty()) { + clear(); + return true; + } + AllocIfNeeded(); + return traits::from_string(str, string_); + } + + /// + /// Set this string's data from existing |data| and optional |length|. Data + /// will be always copied. Translation will occur if necessary based on the + /// underlying string type. + /// + bool FromString(const std::string::value_type* data, size_t length = 0) { + if (data && length == 0) { + length = std::char_traits<std::string::value_type>::length(data); + } + if (!data || length == 0) { + clear(); + return true; + } + AllocIfNeeded(); + return traits::from_string(data, length, string_); + } + + /// + /// Return this string's data as a std::wstring. Translation will occur if + /// necessary based on the underlying string type. + /// + std::wstring ToWString() const { + if (empty()) { + return std::wstring(); + } + return traits::to_wstring(string_); + } + + /// + /// Set this string's data from an existing std::wstring. Data will be always + /// copied. Translation will occur if necessary based on the underlying string + /// type. + /// + bool FromWString(const std::wstring& str) { + if (str.empty()) { + clear(); + return true; + } + AllocIfNeeded(); + return traits::from_wstring(str, string_); + } + + /// + /// Set this string's data from existing |data| and optional |length|. Data + /// will be always copied. Translation will occur if necessary based on the + /// underlying string type. + /// + bool FromWString(const std::wstring::value_type* data, size_t length = 0) { + if (data && length == 0) { + length = std::char_traits<std::wstring::value_type>::length(data); + } + if (!data || length == 0) { + clear(); + return true; + } + AllocIfNeeded(); + return traits::from_wstring(data, length, string_); + } + + /// + /// Return this string's data as a string16. Translation will occur if + /// necessary based on the underlying string type. + /// + std::u16string ToString16() const { + if (empty()) { + return std::u16string(); + } + return traits::to_string16(string_); + } + + /// + /// Set this string's data from an existing string16. Data will be always + /// copied. Translation will occur if necessary based on the underlying string + /// type. + /// + bool FromString16(const std::u16string& str) { + if (str.empty()) { + clear(); + return true; + } + AllocIfNeeded(); + return traits::from_string16(str, string_); + } + + /// + /// Set this string's data from existing |data| and optional |length|. Data + /// will be always copied. Translation will occur if necessary based on the + /// underlying string type. + /// + bool FromString16(const std::u16string::value_type* data, size_t length = 0) { + if (data && length == 0) { + length = std::char_traits<std::u16string::value_type>::length(data); + } + if (!data || length == 0) { + clear(); + return true; + } + AllocIfNeeded(); + return traits::from_string16(data, length, string_); + } + + /// + /// Comparison operator overloads. + /// + bool operator<(const CefStringBase& str) const { return (compare(str) < 0); } + bool operator<=(const CefStringBase& str) const { + return (compare(str) <= 0); + } + bool operator>(const CefStringBase& str) const { return (compare(str) > 0); } + bool operator>=(const CefStringBase& str) const { + return (compare(str) >= 0); + } + bool operator==(const CefStringBase& str) const { + return (compare(str) == 0); + } + bool operator!=(const CefStringBase& str) const { + return (compare(str) != 0); + } + + /// + /// Assignment operator overloads. + /// + CefStringBase& operator=(const CefStringBase& str) { + FromString(str.c_str(), str.length(), true); + return *this; + } + operator std::string() const { return ToString(); } + CefStringBase& operator=(const std::string& str) { + FromString(str); + return *this; + } + CefStringBase& operator=(const std::string::value_type* str) { + FromString(str); + return *this; + } + operator std::wstring() const { return ToWString(); } + CefStringBase& operator=(const std::wstring& str) { + FromWString(str); + return *this; + } + CefStringBase& operator=(const std::wstring::value_type* str) { + FromWString(str); + return *this; + } + operator std::u16string() const { return ToString16(); } + CefStringBase& operator=(const std::u16string& str) { + FromString16(str); + return *this; + } + CefStringBase& operator=(const std::u16string::value_type* str) { + FromString16(str); + return *this; + } +#if defined(WCHAR_T_IS_UTF32) + CefStringBase& operator=(const char16* str) { + FromString16(reinterpret_cast<const std::u16string::value_type*>(str)); + return *this; + } +#endif // WCHAR_T_IS_UTF32 +#if defined(USING_CHROMIUM_INCLUDES) + // The base::FilePath constructor is marked as explicit so provide the + // conversion here for convenience. + operator base::FilePath() const { +#if defined(OS_WIN) + return base::FilePath(ToWString()); +#else + return base::FilePath(ToString()); +#endif + } +#endif // USING_CHROMIUM_INCLUDES + + private: + /// Allocate the string structure if it doesn't already exist. + void AllocIfNeeded() { + if (string_ == NULL) { + string_ = new struct_type; + memset(string_, 0, sizeof(struct_type)); + owner_ = true; + } + } + + struct_type* string_; + bool owner_; +}; + +typedef CefStringBase<CefStringTraitsWide> CefStringWide; +typedef CefStringBase<CefStringTraitsUTF8> CefStringUTF8; +typedef CefStringBase<CefStringTraitsUTF16> CefStringUTF16; + +#endif // CEF_INCLUDE_INTERNAL_CEF_STRING_WRAPPERS_H_ diff --git a/include/internal/cef_thread_internal.h b/include/internal/cef_thread_internal.h new file mode 100644 index 00000000..7df3be86 --- /dev/null +++ b/include/internal/cef_thread_internal.h @@ -0,0 +1,78 @@ +// Copyright (c) 2014 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. + +#ifndef CEF_INCLUDE_INTERNAL_CEF_THREAD_INTERNAL_H_ +#define CEF_INCLUDE_INTERNAL_CEF_THREAD_INTERNAL_H_ +#pragma once + +#if defined(OS_WIN) +#include <windows.h> +#elif defined(OS_POSIX) +#include <pthread.h> +#include <unistd.h> +#endif + +#include "include/internal/cef_export.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(OS_WIN) +typedef DWORD cef_platform_thread_id_t; +#define kInvalidPlatformThreadId 0U +#elif defined(OS_POSIX) +typedef pid_t cef_platform_thread_id_t; +#define kInvalidPlatformThreadId 0 +#endif + +/// +/// Returns the current platform thread ID. +/// +CEF_EXPORT cef_platform_thread_id_t cef_get_current_platform_thread_id(void); + +#if defined(OS_WIN) +typedef DWORD cef_platform_thread_handle_t; +#define kInvalidPlatformThreadHandle 0U +#elif defined(OS_POSIX) +typedef pthread_t cef_platform_thread_handle_t; +#define kInvalidPlatformThreadHandle 0 +#endif + +/// +/// Returns the current platform thread handle. +/// +CEF_EXPORT cef_platform_thread_handle_t +cef_get_current_platform_thread_handle(void); + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // CEF_INCLUDE_INTERNAL_CEF_THREAD_INTERNAL_H_ diff --git a/include/internal/cef_time.h b/include/internal/cef_time.h new file mode 100644 index 00000000..7d0b4cc7 --- /dev/null +++ b/include/internal/cef_time.h @@ -0,0 +1,152 @@ +// Copyright (c) 2011 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. + +#ifndef CEF_INCLUDE_INTERNAL_CEF_TIME_H_ +#define CEF_INCLUDE_INTERNAL_CEF_TIME_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include <time.h> +#include "include/base/cef_basictypes.h" +#include "include/internal/cef_export.h" + +/// +/// Represents a wall clock time in UTC. Values are not guaranteed to be +/// monotonically non-decreasing and are subject to large amounts of skew. +/// Time is stored internally as microseconds since the Windows epoch (1601). +/// +/// This is equivalent of Chromium `base::Time` (see base/time/time.h). +/// +typedef struct _cef_basetime_t { + int64 val; +} cef_basetime_t; + +/// +/// Time information. Values should always be in UTC. +/// +typedef struct _cef_time_t { + /// + /// Four or five digit year "2007" (1601 to 30827 on Windows, 1970 to 2038 on + /// 32-bit POSIX) + /// + int year; + + /// + /// 1-based month (values 1 = January, etc.) + /// + int month; + + /// + /// 0-based day of week (0 = Sunday, etc.) + /// + int day_of_week; + + /// + /// 1-based day of month (1-31) + /// + int day_of_month; + + /// + /// Hour within the current day (0-23) + /// + int hour; + + /// + /// Minute within the current hour (0-59) + /// + int minute; + + /// + /// Second within the current minute (0-59 plus leap seconds which may take + /// it up to 60). + /// + int second; + + /// + /// Milliseconds within the current second (0-999) + /// + int millisecond; +} cef_time_t; + +/// +/// Converts cef_time_t to/from time_t. Returns true (1) on success and false +/// (0) on failure. +/// +CEF_EXPORT int cef_time_to_timet(const cef_time_t* cef_time, time_t* time); +CEF_EXPORT int cef_time_from_timet(time_t time, cef_time_t* cef_time); + +/// +/// Converts cef_time_t to/from a double which is the number of seconds since +/// epoch (Jan 1, 1970). Webkit uses this format to represent time. A value of 0 +/// means "not initialized". Returns true (1) on success and false (0) on +/// failure. +/// +CEF_EXPORT int cef_time_to_doublet(const cef_time_t* cef_time, double* time); +CEF_EXPORT int cef_time_from_doublet(double time, cef_time_t* cef_time); + +/// +/// Retrieve the current system time. Returns true (1) on success and false (0) +/// on failure. +/// +CEF_EXPORT int cef_time_now(cef_time_t* cef_time); + +/// +/// Retrieve the current system time. +/// +CEF_EXPORT cef_basetime_t cef_basetime_now(void); + +/// +/// Retrieve the delta in milliseconds between two time values. Returns true (1) +/// on success and false (0) on failure. +// +CEF_EXPORT int cef_time_delta(const cef_time_t* cef_time1, + const cef_time_t* cef_time2, + long long* delta); + +/// +/// Converts cef_time_t to cef_basetime_t. Returns true (1) on success and +/// false (0) on failure. +/// +CEF_EXPORT int cef_time_to_basetime(const cef_time_t* from, cef_basetime_t* to); + +/// +/// Converts cef_basetime_t to cef_time_t. Returns true (1) on success and +/// false (0) on failure. +/// +CEF_EXPORT int cef_time_from_basetime(const cef_basetime_t from, + cef_time_t* to); + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_INTERNAL_CEF_TIME_H_ diff --git a/include/internal/cef_time_wrappers.h b/include/internal/cef_time_wrappers.h new file mode 100644 index 00000000..7b5cbfb8 --- /dev/null +++ b/include/internal/cef_time_wrappers.h @@ -0,0 +1,111 @@ +// Copyright (c) 2022 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. + +#ifndef CEF_INCLUDE_INTERNAL_CEF_TIME_WRAPPERS_H_ +#define CEF_INCLUDE_INTERNAL_CEF_TIME_WRAPPERS_H_ +#pragma once + +#include "include/internal/cef_time.h" + +#if defined(USING_CHROMIUM_INCLUDES) +#include "base/time/time.h" +#endif + +/// +/// Represents a wall clock time in UTC. Values are not guaranteed to be +/// monotonically non-decreasing and are subject to large amounts of skew. +/// Time is stored internally as microseconds since the Windows epoch (1601). +/// +/// This is equivalent of Chromium `base::Time` (see base/time/time.h). +/// +class CefBaseTime : public cef_basetime_t { + public: + CefBaseTime() : cef_basetime_t{} {} + CefBaseTime(const cef_basetime_t& value) : cef_basetime_t(value) {} + +#if defined(USING_CHROMIUM_INCLUDES) + CefBaseTime(const base::Time& value) + : cef_basetime_t{value.ToDeltaSinceWindowsEpoch().InMicroseconds()} {} + + operator base::Time() const { + return base::Time::FromDeltaSinceWindowsEpoch(base::Microseconds(val)); + } +#endif + + static CefBaseTime Now() { return cef_basetime_now(); } +}; + +/// +/// Class representing a time. +/// +class CefTime : public cef_time_t { + public: + CefTime() : cef_time_t{} {} + CefTime(const cef_time_t& r) : cef_time_t(r) {} + explicit CefTime(time_t r) { SetTimeT(r); } + explicit CefTime(double r) { SetDoubleT(r); } + + /// + /// Converts to/from time_t. + /// + void SetTimeT(time_t r) { cef_time_from_timet(r, this); } + time_t GetTimeT() const { + time_t time = 0; + cef_time_to_timet(this, &time); + return time; + } + + /// + /// Converts to/from a double which is the number of seconds since epoch + /// (Jan 1, 1970). Webkit uses this format to represent time. A value of 0 + /// means "not initialized". + /// + void SetDoubleT(double r) { cef_time_from_doublet(r, this); } + double GetDoubleT() const { + double time = 0; + cef_time_to_doublet(this, &time); + return time; + } + + /// + /// Set this object to now. + /// + void Now() { cef_time_now(this); } + + /// + /// Return the delta between this object and |other| in milliseconds. + /// + long long Delta(const CefTime& other) { + long long delta = 0; + cef_time_delta(this, &other, &delta); + return delta; + } +}; + +#endif // CEF_INCLUDE_INTERNAL_CEF_TIME_WRAPPERS_H_ diff --git a/include/internal/cef_trace_event_internal.h b/include/internal/cef_trace_event_internal.h new file mode 100644 index 00000000..6df87071 --- /dev/null +++ b/include/internal/cef_trace_event_internal.h @@ -0,0 +1,124 @@ +// Copyright (c) 2014 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. + +#ifndef CEF_INCLUDE_INTERNAL_CEF_TRACE_EVENT_INTERNAL_H_ +#define CEF_INCLUDE_INTERNAL_CEF_TRACE_EVENT_INTERNAL_H_ +#pragma once + +#include "include/internal/cef_export.h" +#include "include/internal/cef_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// See include/base/cef_trace_event.h for macros and intended usage. + +// Functions for tracing counters and functions; called from macros. +// - |category| string must have application lifetime (static or literal). They +// may not include "(quotes) chars. +// - |argX_name|, |argX_val|, |valueX_name|, |valeX_val| are optional parameters +// and represent pairs of name and values of arguments +// - |copy| is used to avoid memory scoping issues with the |name| and +// |arg_name| parameters by copying them +// - |id| is used to disambiguate counters with the same name, or match async +// trace events + +CEF_EXPORT void cef_trace_event_instant(const char* category, + const char* name, + const char* arg1_name, + uint64 arg1_val, + const char* arg2_name, + uint64 arg2_val, + int copy); +CEF_EXPORT void cef_trace_event_begin(const char* category, + const char* name, + const char* arg1_name, + uint64 arg1_val, + const char* arg2_name, + uint64 arg2_val, + int copy); +CEF_EXPORT void cef_trace_event_end(const char* category, + const char* name, + const char* arg1_name, + uint64 arg1_val, + const char* arg2_name, + uint64 arg2_val, + int copy); +CEF_EXPORT void cef_trace_counter(const char* category, + const char* name, + const char* value1_name, + uint64 value1_val, + const char* value2_name, + uint64 value2_val, + int copy); +CEF_EXPORT void cef_trace_counter_id(const char* category, + const char* name, + uint64 id, + const char* value1_name, + uint64 value1_val, + const char* value2_name, + uint64 value2_val, + int copy); +CEF_EXPORT void cef_trace_event_async_begin(const char* category, + const char* name, + uint64 id, + const char* arg1_name, + uint64 arg1_val, + const char* arg2_name, + uint64 arg2_val, + int copy); +CEF_EXPORT void cef_trace_event_async_step_into(const char* category, + const char* name, + uint64 id, + uint64 step, + const char* arg1_name, + uint64 arg1_val, + int copy); +CEF_EXPORT void cef_trace_event_async_step_past(const char* category, + const char* name, + uint64 id, + uint64 step, + const char* arg1_name, + uint64 arg1_val, + int copy); +CEF_EXPORT void cef_trace_event_async_end(const char* category, + const char* name, + uint64 id, + const char* arg1_name, + uint64 arg1_val, + const char* arg2_name, + uint64 arg2_val, + int copy); + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // CEF_INCLUDE_INTERNAL_CEF_TRACE_EVENT_INTERNAL_H_ diff --git a/include/internal/cef_types.h b/include/internal/cef_types.h new file mode 100644 index 00000000..810dc524 --- /dev/null +++ b/include/internal/cef_types.h @@ -0,0 +1,3450 @@ +// Copyright (c) 2014 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. + +#ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_H_ +#define CEF_INCLUDE_INTERNAL_CEF_TYPES_H_ +#pragma once + +#include "include/base/cef_basictypes.h" +#include "include/internal/cef_string.h" +#include "include/internal/cef_string_list.h" +#include "include/internal/cef_time.h" +#include "include/internal/cef_types_geometry.h" + +// Bring in platform-specific definitions. +#if defined(OS_WIN) +#include "include/internal/cef_types_win.h" +#elif defined(OS_MAC) +#include "include/internal/cef_types_mac.h" +#elif defined(OS_LINUX) +#include "include/internal/cef_types_linux.h" +#endif + +// 32-bit ARGB color value, not premultiplied. The color components are always +// in a known order. Equivalent to the SkColor type. +typedef uint32 cef_color_t; + +// Return the alpha byte from a cef_color_t value. +#define CefColorGetA(color) (((color) >> 24) & 0xFF) +// Return the red byte from a cef_color_t value. +#define CefColorGetR(color) (((color) >> 16) & 0xFF) +// Return the green byte from a cef_color_t value. +#define CefColorGetG(color) (((color) >> 8) & 0xFF) +// Return the blue byte from a cef_color_t value. +#define CefColorGetB(color) (((color) >> 0) & 0xFF) + +// Return an cef_color_t value with the specified byte component values. +#define CefColorSetARGB(a, r, g, b) \ + static_cast<cef_color_t>( \ + (static_cast<unsigned>(a) << 24) | (static_cast<unsigned>(r) << 16) | \ + (static_cast<unsigned>(g) << 8) | (static_cast<unsigned>(b) << 0)) + +// Return an int64 value with the specified low and high int32 component values. +#define CefInt64Set(int32_low, int32_high) \ + static_cast<int64>((static_cast<uint32>(int32_low)) | \ + (static_cast<int64>(static_cast<int32>(int32_high))) \ + << 32) + +// Return the low int32 value from an int64 value. +#define CefInt64GetLow(int64_val) static_cast<int32>(int64_val) +// Return the high int32 value from an int64 value. +#define CefInt64GetHigh(int64_val) \ + static_cast<int32>((static_cast<int64>(int64_val) >> 32) & 0xFFFFFFFFL) + +#ifdef __cplusplus +extern "C" { +#endif + +/// +/// Log severity levels. +/// +typedef enum { + /// + /// Default logging (currently INFO logging). + /// + LOGSEVERITY_DEFAULT, + + /// + /// Verbose logging. + /// + LOGSEVERITY_VERBOSE, + + /// + /// DEBUG logging. + /// + LOGSEVERITY_DEBUG = LOGSEVERITY_VERBOSE, + + /// + /// INFO logging. + /// + LOGSEVERITY_INFO, + + /// + /// WARNING logging. + /// + LOGSEVERITY_WARNING, + + /// + /// ERROR logging. + /// + LOGSEVERITY_ERROR, + + /// + /// FATAL logging. + /// + LOGSEVERITY_FATAL, + + /// + /// Disable logging to file for all messages, and to stderr for messages with + /// severity less than FATAL. + /// + LOGSEVERITY_DISABLE = 99 +} cef_log_severity_t; + +/// +/// Represents the state of a setting. +/// +typedef enum { + /// + /// Use the default state for the setting. + /// + STATE_DEFAULT = 0, + + /// + /// Enable or allow the setting. + /// + STATE_ENABLED, + + /// + /// Disable or disallow the setting. + /// + STATE_DISABLED, +} cef_state_t; + +/// +/// Initialization settings. Specify NULL or 0 to get the recommended default +/// values. Many of these and other settings can also configured using command- +/// line switches. +/// +typedef struct _cef_settings_t { + /// + /// Size of this structure. + /// + size_t size; + + /// + /// Set to true (1) to disable the sandbox for sub-processes. See + /// cef_sandbox_win.h for requirements to enable the sandbox on Windows. Also + /// configurable using the "no-sandbox" command-line switch. + /// + int no_sandbox; + + /// + /// The path to a separate executable that will be launched for sub-processes. + /// If this value is empty on Windows or Linux then the main process + /// executable will be used. If this value is empty on macOS then a helper + /// executable must exist at "Contents/Frameworks/<app> + /// Helper.app/Contents/MacOS/<app> Helper" in the top-level app bundle. See + /// the comments on CefExecuteProcess() for details. If this value is + /// non-empty then it must be an absolute path. Also configurable using the + /// "browser-subprocess-path" command-line switch. + /// + cef_string_t browser_subprocess_path; + + /// + /// The path to the CEF framework directory on macOS. If this value is empty + /// then the framework must exist at "Contents/Frameworks/Chromium Embedded + /// Framework.framework" in the top-level app bundle. If this value is + /// non-empty then it must be an absolute path. Also configurable using the + /// "framework-dir-path" command-line switch. + /// + cef_string_t framework_dir_path; + + /// + /// The path to the main bundle on macOS. If this value is empty then it + /// defaults to the top-level app bundle. If this value is non-empty then it + /// must be an absolute path. Also configurable using the "main-bundle-path" + /// command-line switch. + /// + cef_string_t main_bundle_path; + + /// + /// Set to true (1) to enable use of the Chrome runtime in CEF. This feature + /// is considered experimental and is not recommended for most users at this + /// time. See issue #2969 for details. + /// + int chrome_runtime; + + /// + /// Set to true (1) to have the browser process message loop run in a separate + /// thread. If false (0) then the CefDoMessageLoopWork() function must be + /// called from your application message loop. This option is only supported + /// on Windows and Linux. + /// + int multi_threaded_message_loop; + + /// + /// Set to true (1) to control browser process main (UI) thread message pump + /// scheduling via the CefBrowserProcessHandler::OnScheduleMessagePumpWork() + /// callback. This option is recommended for use in combination with the + /// CefDoMessageLoopWork() function in cases where the CEF message loop must + /// be integrated into an existing application message loop (see additional + /// comments and warnings on CefDoMessageLoopWork). Enabling this option is + /// not recommended for most users; leave this option disabled and use either + /// the CefRunMessageLoop() function or multi_threaded_message_loop if + /// possible. + /// + int external_message_pump; + + /// + /// Set to true (1) to enable windowless (off-screen) rendering support. Do + /// not enable this value if the application does not use windowless rendering + /// as it may reduce rendering performance on some systems. + /// + int windowless_rendering_enabled; + + /// + /// Set to true (1) to disable configuration of browser process features using + /// standard CEF and Chromium command-line arguments. Configuration can still + /// be specified using CEF data structures or via the + /// CefApp::OnBeforeCommandLineProcessing() method. + /// + int command_line_args_disabled; + + /// + /// The location where data for the global browser cache will be stored on + /// disk. If this value is non-empty then it must be an absolute path that is + /// either equal to or a child directory of CefSettings.root_cache_path. If + /// this value is empty then browsers will be created in "incognito mode" + /// where in-memory caches are used for storage and no data is persisted to + /// disk. HTML5 databases such as localStorage will only persist across + /// sessions if a cache path is specified. Can be overridden for individual + /// CefRequestContext instances via the CefRequestContextSettings.cache_path + /// value. When using the Chrome runtime the "default" profile will be used if + /// |cache_path| and |root_cache_path| have the same value. + /// + cef_string_t cache_path; + + /// + /// The root directory that all CefSettings.cache_path and + /// CefRequestContextSettings.cache_path values must have in common. If this + /// value is empty and CefSettings.cache_path is non-empty then it will + /// default to the CefSettings.cache_path value. If this value is non-empty + /// then it must be an absolute path. Failure to set this value correctly may + /// result in the sandbox blocking read/write access to the cache_path + /// directory. + /// + cef_string_t root_cache_path; + + /// + /// The location where user data such as the Widevine CDM module and spell + /// checking dictionary files will be stored on disk. If this value is empty + /// then the default platform-specific user data directory will be used + /// ("~/.config/cef_user_data" directory on Linux, "~/Library/Application + /// Support/CEF/User Data" directory on MacOS, "AppData\Local\CEF\User Data" + /// directory under the user profile directory on Windows). If this value is + /// non-empty then it must be an absolute path. When using the Chrome runtime + /// this value will be ignored in favor of the |root_cache_path| value. + /// + cef_string_t user_data_path; + + /// + /// To persist session cookies (cookies without an expiry date or validity + /// interval) by default when using the global cookie manager set this value + /// to true (1). Session cookies are generally intended to be transient and + /// most Web browsers do not persist them. A |cache_path| value must also be + /// specified to enable this feature. Also configurable using the + /// "persist-session-cookies" command-line switch. Can be overridden for + /// individual CefRequestContext instances via the + /// CefRequestContextSettings.persist_session_cookies value. + /// + int persist_session_cookies; + + /// + /// To persist user preferences as a JSON file in the cache path directory set + /// this value to true (1). A |cache_path| value must also be specified + /// to enable this feature. Also configurable using the + /// "persist-user-preferences" command-line switch. Can be overridden for + /// individual CefRequestContext instances via the + /// CefRequestContextSettings.persist_user_preferences value. + /// + int persist_user_preferences; + + /// + /// Value that will be returned as the User-Agent HTTP header. If empty the + /// default User-Agent string will be used. Also configurable using the + /// "user-agent" command-line switch. + /// + cef_string_t user_agent; + + /// + /// Value that will be inserted as the product portion of the default + /// User-Agent string. If empty the Chromium product version will be used. If + /// |userAgent| is specified this value will be ignored. Also configurable + /// using the "user-agent-product" command-line switch. + /// + cef_string_t user_agent_product; + + /// + /// The locale string that will be passed to WebKit. If empty the default + /// locale of "en-US" will be used. This value is ignored on Linux where + /// locale is determined using environment variable parsing with the + /// precedence order: LANGUAGE, LC_ALL, LC_MESSAGES and LANG. Also + /// configurable using the "lang" command-line switch. + /// + cef_string_t locale; + + /// + /// The directory and file name to use for the debug log. If empty a default + /// log file name and location will be used. On Windows and Linux a + /// "debug.log" file will be written in the main executable directory. On + /// MacOS a "~/Library/Logs/[app name]_debug.log" file will be written where + /// [app name] is the name of the main app executable. Also configurable using + /// the "log-file" command-line switch. + /// + cef_string_t log_file; + + /// + /// The log severity. Only messages of this severity level or higher will be + /// logged. When set to DISABLE no messages will be written to the log file, + /// but FATAL messages will still be output to stderr. Also configurable using + /// the "log-severity" command-line switch with a value of "verbose", "info", + /// "warning", "error", "fatal" or "disable". + /// + cef_log_severity_t log_severity; + + /// + /// Custom flags that will be used when initializing the V8 JavaScript engine. + /// The consequences of using custom flags may not be well tested. Also + /// configurable using the "js-flags" command-line switch. + /// + cef_string_t javascript_flags; + + /// + /// The fully qualified path for the resources directory. If this value is + /// empty the *.pak files must be located in the module directory on + /// Windows/Linux or the app bundle Resources directory on MacOS. If this + /// value is non-empty then it must be an absolute path. Also configurable + /// using the "resources-dir-path" command-line switch. + /// + cef_string_t resources_dir_path; + + /// + /// The fully qualified path for the locales directory. If this value is empty + /// the locales directory must be located in the module directory. If this + /// value is non-empty then it must be an absolute path. This value is ignored + /// on MacOS where pack files are always loaded from the app bundle Resources + /// directory. Also configurable using the "locales-dir-path" command-line + /// switch. + /// + cef_string_t locales_dir_path; + + /// + /// Set to true (1) to disable loading of pack files for resources and + /// locales. A resource bundle handler must be provided for the browser and + /// render processes via CefApp::GetResourceBundleHandler() if loading of pack + /// files is disabled. Also configurable using the "disable-pack-loading" + /// command- line switch. + /// + int pack_loading_disabled; + + /// + /// Set to a value between 1024 and 65535 to enable remote debugging on the + /// specified port. Also configurable using the "remote-debugging-port" + /// command-line switch. Remote debugging can be accessed by loading the + /// chrome://inspect page in Google Chrome. Port numbers 9222 and 9229 are + /// discoverable by default. Other port numbers may need to be configured via + /// "Discover network targets" on the Devices tab. + /// + int remote_debugging_port; + + /// + /// The number of stack trace frames to capture for uncaught exceptions. + /// Specify a positive value to enable the + /// CefRenderProcessHandler::OnUncaughtException() callback. Specify 0 + /// (default value) and OnUncaughtException() will not be called. Also + /// configurable using the "uncaught-exception-stack-size" command-line + /// switch. + /// + int uncaught_exception_stack_size; + + /// + /// Background color used for the browser before a document is loaded and when + /// no document color is specified. The alpha component must be either fully + /// opaque (0xFF) or fully transparent (0x00). If the alpha component is fully + /// opaque then the RGB components will be used as the background color. If + /// the alpha component is fully transparent for a windowed browser then the + /// default value of opaque white be used. If the alpha component is fully + /// transparent for a windowless (off-screen) browser then transparent + /// painting will be enabled. + /// + cef_color_t background_color; + + /// + /// Comma delimited ordered list of language codes without any whitespace that + /// will be used in the "Accept-Language" HTTP header. May be overridden on a + /// per-browser basis using the CefBrowserSettings.accept_language_list value. + /// If both values are empty then "en-US,en" will be used. Can be overridden + /// for individual CefRequestContext instances via the + /// CefRequestContextSettings.accept_language_list value. + /// + cef_string_t accept_language_list; + + /// + /// Comma delimited list of schemes supported by the associated + /// CefCookieManager. If |cookieable_schemes_exclude_defaults| is false (0) + /// the default schemes ("http", "https", "ws" and "wss") will also be + /// supported. Not specifying a |cookieable_schemes_list| value and setting + /// |cookieable_schemes_exclude_defaults| to true (1) will disable all loading + /// and saving of cookies. These settings will only impact the global + /// CefRequestContext. Individual CefRequestContext instances can be + /// configured via the CefRequestContextSettings.cookieable_schemes_list and + /// CefRequestContextSettings.cookieable_schemes_exclude_defaults values. + /// + cef_string_t cookieable_schemes_list; + int cookieable_schemes_exclude_defaults; +} cef_settings_t; + +/// +/// Request context initialization settings. Specify NULL or 0 to get the +/// recommended default values. +/// +typedef struct _cef_request_context_settings_t { + /// + /// Size of this structure. + /// + size_t size; + + /// + /// The location where cache data for this request context will be stored on + /// disk. If this value is non-empty then it must be an absolute path that is + /// either equal to or a child directory of CefSettings.root_cache_path. If + /// this value is empty then browsers will be created in "incognito mode" + /// where in-memory caches are used for storage and no data is persisted to + /// disk. HTML5 databases such as localStorage will only persist across + /// sessions if a cache path is specified. To share the global browser cache + /// and related configuration set this value to match the + /// CefSettings.cache_path value. + /// + cef_string_t cache_path; + + /// + /// To persist session cookies (cookies without an expiry date or validity + /// interval) by default when using the global cookie manager set this value + /// to true (1). Session cookies are generally intended to be transient and + /// most Web browsers do not persist them. Can be set globally using the + /// CefSettings.persist_session_cookies value. This value will be ignored if + /// |cache_path| is empty or if it matches the CefSettings.cache_path value. + /// + int persist_session_cookies; + + /// + /// To persist user preferences as a JSON file in the cache path directory set + /// this value to true (1). Can be set globally using the + /// CefSettings.persist_user_preferences value. This value will be ignored if + /// |cache_path| is empty or if it matches the CefSettings.cache_path value. + /// + int persist_user_preferences; + + /// + /// Comma delimited ordered list of language codes without any whitespace that + /// will be used in the "Accept-Language" HTTP header. Can be set globally + /// using the CefSettings.accept_language_list value or overridden on a per- + /// browser basis using the CefBrowserSettings.accept_language_list value. If + /// all values are empty then "en-US,en" will be used. This value will be + /// ignored if |cache_path| matches the CefSettings.cache_path value. + /// + cef_string_t accept_language_list; + + /// + /// Comma delimited list of schemes supported by the associated + /// CefCookieManager. If |cookieable_schemes_exclude_defaults| is false (0) + /// the default schemes ("http", "https", "ws" and "wss") will also be + /// supported. Not specifying a |cookieable_schemes_list| value and setting + /// |cookieable_schemes_exclude_defaults| to true (1) will disable all loading + /// and saving of cookies. These values will be ignored if |cache_path| + /// matches the CefSettings.cache_path value. + /// + cef_string_t cookieable_schemes_list; + int cookieable_schemes_exclude_defaults; +} cef_request_context_settings_t; + +/// +/// Browser initialization settings. Specify NULL or 0 to get the recommended +/// default values. The consequences of using custom values may not be well +/// tested. Many of these and other settings can also configured using command- +/// line switches. +/// +typedef struct _cef_browser_settings_t { + /// + /// Size of this structure. + /// + size_t size; + + /// + /// The maximum rate in frames per second (fps) that CefRenderHandler::OnPaint + /// will be called for a windowless browser. The actual fps may be lower if + /// the browser cannot generate frames at the requested rate. The minimum + /// value is 1 and the maximum value is 60 (default 30). This value can also + /// be changed dynamically via CefBrowserHost::SetWindowlessFrameRate. + /// + int windowless_frame_rate; + + /// BEGIN values that map to WebPreferences settings. + + /// + /// Font settings. + /// + cef_string_t standard_font_family; + cef_string_t fixed_font_family; + cef_string_t serif_font_family; + cef_string_t sans_serif_font_family; + cef_string_t cursive_font_family; + cef_string_t fantasy_font_family; + int default_font_size; + int default_fixed_font_size; + int minimum_font_size; + int minimum_logical_font_size; + + /// + /// Default encoding for Web content. If empty "ISO-8859-1" will be used. Also + /// configurable using the "default-encoding" command-line switch. + /// + cef_string_t default_encoding; + + /// + /// Controls the loading of fonts from remote sources. Also configurable using + /// the "disable-remote-fonts" command-line switch. + /// + cef_state_t remote_fonts; + + /// + /// Controls whether JavaScript can be executed. Also configurable using the + /// "disable-javascript" command-line switch. + /// + cef_state_t javascript; + + /// + /// Controls whether JavaScript can be used to close windows that were not + /// opened via JavaScript. JavaScript can still be used to close windows that + /// were opened via JavaScript or that have no back/forward history. Also + /// configurable using the "disable-javascript-close-windows" command-line + /// switch. + /// + cef_state_t javascript_close_windows; + + /// + /// Controls whether JavaScript can access the clipboard. Also configurable + /// using the "disable-javascript-access-clipboard" command-line switch. + /// + cef_state_t javascript_access_clipboard; + + /// + /// Controls whether DOM pasting is supported in the editor via + /// execCommand("paste"). The |javascript_access_clipboard| setting must also + /// be enabled. Also configurable using the "disable-javascript-dom-paste" + /// command-line switch. + /// + cef_state_t javascript_dom_paste; + + /// + /// Controls whether image URLs will be loaded from the network. A cached + /// image will still be rendered if requested. Also configurable using the + /// "disable-image-loading" command-line switch. + /// + cef_state_t image_loading; + + /// + /// Controls whether standalone images will be shrunk to fit the page. Also + /// configurable using the "image-shrink-standalone-to-fit" command-line + /// switch. + /// + cef_state_t image_shrink_standalone_to_fit; + + /// + /// Controls whether text areas can be resized. Also configurable using the + /// "disable-text-area-resize" command-line switch. + /// + cef_state_t text_area_resize; + + /// + /// Controls whether the tab key can advance focus to links. Also configurable + /// using the "disable-tab-to-links" command-line switch. + /// + cef_state_t tab_to_links; + + /// + /// Controls whether local storage can be used. Also configurable using the + /// "disable-local-storage" command-line switch. + /// + cef_state_t local_storage; + + /// + /// Controls whether databases can be used. Also configurable using the + /// "disable-databases" command-line switch. + /// + cef_state_t databases; + + /// + /// Controls whether WebGL can be used. Note that WebGL requires hardware + /// support and may not work on all systems even when enabled. Also + /// configurable using the "disable-webgl" command-line switch. + /// + cef_state_t webgl; + + /// END values that map to WebPreferences settings. + + /// + /// Background color used for the browser before a document is loaded and when + /// no document color is specified. The alpha component must be either fully + /// opaque (0xFF) or fully transparent (0x00). If the alpha component is fully + /// opaque then the RGB components will be used as the background color. If + /// the alpha component is fully transparent for a windowed browser then the + /// CefSettings.background_color value will be used. If the alpha component is + /// fully transparent for a windowless (off-screen) browser then transparent + /// painting will be enabled. + /// + cef_color_t background_color; + + /// + /// Comma delimited ordered list of language codes without any whitespace that + /// will be used in the "Accept-Language" HTTP header. May be set globally + /// using the CefSettings.accept_language_list value. If both values are + /// empty then "en-US,en" will be used. + /// + cef_string_t accept_language_list; + + /// + /// Controls whether the Chrome status bubble will be used. Only supported + /// with the Chrome runtime. For details about the status bubble see + /// https://www.chromium.org/user-experience/status-bubble/ + /// + cef_state_t chrome_status_bubble; +} cef_browser_settings_t; + +/// +/// Return value types. +/// +typedef enum { + /// + /// Cancel immediately. + /// + RV_CANCEL = 0, + + /// + /// Continue immediately. + /// + RV_CONTINUE, + + /// + /// Continue asynchronously (usually via a callback). + /// + RV_CONTINUE_ASYNC, +} cef_return_value_t; + +/// +/// URL component parts. +/// +typedef struct _cef_urlparts_t { + /// + /// The complete URL specification. + /// + cef_string_t spec; + + /// + /// Scheme component not including the colon (e.g., "http"). + /// + cef_string_t scheme; + + /// + /// User name component. + /// + cef_string_t username; + + /// + /// Password component. + /// + cef_string_t password; + + /// + /// Host component. This may be a hostname, an IPv4 address or an IPv6 literal + /// surrounded by square brackets (e.g., "[2001:db8::1]"). + /// + cef_string_t host; + + /// + /// Port number component. + /// + cef_string_t port; + + /// + /// Origin contains just the scheme, host, and port from a URL. Equivalent to + /// clearing any username and password, replacing the path with a slash, and + /// clearing everything after that. This value will be empty for non-standard + /// URLs. + /// + cef_string_t origin; + + /// + /// Path component including the first slash following the host. + /// + cef_string_t path; + + /// + /// Query string component (i.e., everything following the '?'). + /// + cef_string_t query; + + /// + /// Fragment (hash) identifier component (i.e., the string following the '#'). + /// + cef_string_t fragment; +} cef_urlparts_t; + +/// +/// Cookie priority values. +/// +typedef enum { + CEF_COOKIE_PRIORITY_LOW = -1, + CEF_COOKIE_PRIORITY_MEDIUM = 0, + CEF_COOKIE_PRIORITY_HIGH = 1, +} cef_cookie_priority_t; + +/// +/// Cookie same site values. +/// +typedef enum { + CEF_COOKIE_SAME_SITE_UNSPECIFIED, + CEF_COOKIE_SAME_SITE_NO_RESTRICTION, + CEF_COOKIE_SAME_SITE_LAX_MODE, + CEF_COOKIE_SAME_SITE_STRICT_MODE, +} cef_cookie_same_site_t; + +/// +/// Cookie information. +/// +typedef struct _cef_cookie_t { + /// + /// The cookie name. + /// + cef_string_t name; + + /// + /// The cookie value. + /// + cef_string_t value; + + /// + /// If |domain| is empty a host cookie will be created instead of a domain + /// cookie. Domain cookies are stored with a leading "." and are visible to + /// sub-domains whereas host cookies are not. + /// + cef_string_t domain; + + /// + /// If |path| is non-empty only URLs at or below the path will get the cookie + /// value. + /// + cef_string_t path; + + /// + /// If |secure| is true the cookie will only be sent for HTTPS requests. + /// + int secure; + + /// + /// If |httponly| is true the cookie will only be sent for HTTP requests. + /// + int httponly; + + /// + /// The cookie creation date. This is automatically populated by the system on + /// cookie creation. + /// + cef_basetime_t creation; + + /// + /// The cookie last access date. This is automatically populated by the system + /// on access. + /// + cef_basetime_t last_access; + + /// + /// The cookie expiration date is only valid if |has_expires| is true. + /// + int has_expires; + cef_basetime_t expires; + + /// + /// Same site. + /// + cef_cookie_same_site_t same_site; + + /// + /// Priority. + /// + cef_cookie_priority_t priority; +} cef_cookie_t; + +/// +/// Process termination status values. +/// +typedef enum { + /// + /// Non-zero exit status. + /// + TS_ABNORMAL_TERMINATION, + + /// + /// SIGKILL or task manager kill. + /// + TS_PROCESS_WAS_KILLED, + + /// + /// Segmentation fault. + /// + TS_PROCESS_CRASHED, + + /// + /// Out of memory. Some platforms may use TS_PROCESS_CRASHED instead. + /// + TS_PROCESS_OOM, +} cef_termination_status_t; + +/// +/// Path key values. +/// +typedef enum { + /// + /// Current directory. + /// + PK_DIR_CURRENT, + + /// + /// Directory containing PK_FILE_EXE. + /// + PK_DIR_EXE, + + /// + /// Directory containing PK_FILE_MODULE. + /// + PK_DIR_MODULE, + + /// + /// Temporary directory. + /// + PK_DIR_TEMP, + + /// + /// Path and filename of the current executable. + /// + PK_FILE_EXE, + + /// + /// Path and filename of the module containing the CEF code (usually the + /// libcef module). + /// + PK_FILE_MODULE, + + /// + /// "Local Settings\Application Data" directory under the user profile + /// directory on Windows. + /// + PK_LOCAL_APP_DATA, + + /// + /// "Application Data" directory under the user profile directory on Windows + /// and "~/Library/Application Support" directory on MacOS. + /// + PK_USER_DATA, + + /// + /// Directory containing application resources. Can be configured via + /// CefSettings.resources_dir_path. + /// + PK_DIR_RESOURCES, +} cef_path_key_t; + +/// +/// Storage types. +/// +typedef enum { + ST_LOCALSTORAGE = 0, + ST_SESSIONSTORAGE, +} cef_storage_type_t; + +/// +/// Supported error code values. For the complete list of error values see +/// "include/base/internal/cef_net_error_list.h". +/// +typedef enum { + // No error. + ERR_NONE = 0, + +#define NET_ERROR(label, value) ERR_##label = value, +#include "include/base/internal/cef_net_error_list.h" +#undef NET_ERROR + +} cef_errorcode_t; + +/// +/// Supported certificate status code values. See net\cert\cert_status_flags.h +/// for more information. CERT_STATUS_NONE is new in CEF because we use an +/// enum while cert_status_flags.h uses a typedef and static const variables. +/// +typedef enum { + CERT_STATUS_NONE = 0, + CERT_STATUS_COMMON_NAME_INVALID = 1 << 0, + CERT_STATUS_DATE_INVALID = 1 << 1, + CERT_STATUS_AUTHORITY_INVALID = 1 << 2, + // 1 << 3 is reserved for ERR_CERT_CONTAINS_ERRORS (not useful with WinHTTP). + CERT_STATUS_NO_REVOCATION_MECHANISM = 1 << 4, + CERT_STATUS_UNABLE_TO_CHECK_REVOCATION = 1 << 5, + CERT_STATUS_REVOKED = 1 << 6, + CERT_STATUS_INVALID = 1 << 7, + CERT_STATUS_WEAK_SIGNATURE_ALGORITHM = 1 << 8, + // 1 << 9 was used for CERT_STATUS_NOT_IN_DNS + CERT_STATUS_NON_UNIQUE_NAME = 1 << 10, + CERT_STATUS_WEAK_KEY = 1 << 11, + // 1 << 12 was used for CERT_STATUS_WEAK_DH_KEY + CERT_STATUS_PINNED_KEY_MISSING = 1 << 13, + CERT_STATUS_NAME_CONSTRAINT_VIOLATION = 1 << 14, + CERT_STATUS_VALIDITY_TOO_LONG = 1 << 15, + + // Bits 16 to 31 are for non-error statuses. + CERT_STATUS_IS_EV = 1 << 16, + CERT_STATUS_REV_CHECKING_ENABLED = 1 << 17, + // Bit 18 was CERT_STATUS_IS_DNSSEC + CERT_STATUS_SHA1_SIGNATURE_PRESENT = 1 << 19, + CERT_STATUS_CT_COMPLIANCE_FAILED = 1 << 20, +} cef_cert_status_t; + +/// +/// The manner in which a link click should be opened. These constants match +/// their equivalents in Chromium's window_open_disposition.h and should not be +/// renumbered. +/// +typedef enum { + WOD_UNKNOWN, + + /// + /// Current tab. This is the default in most cases. + /// + WOD_CURRENT_TAB, + + /// + /// Indicates that only one tab with the url should exist in the same window. + /// + WOD_SINGLETON_TAB, + + /// + /// Shift key + Middle mouse button or meta/ctrl key while clicking. + /// + WOD_NEW_FOREGROUND_TAB, + + /// + /// Middle mouse button or meta/ctrl key while clicking. + /// + WOD_NEW_BACKGROUND_TAB, + + /// + /// New popup window. + /// + WOD_NEW_POPUP, + + /// + /// Shift key while clicking. + /// + WOD_NEW_WINDOW, + + /// + /// Alt key while clicking. + /// + WOD_SAVE_TO_DISK, + + /// + /// New off-the-record (incognito) window. + /// + WOD_OFF_THE_RECORD, + + /// + /// Special case error condition from the renderer. + /// + WOD_IGNORE_ACTION, + + /// + /// Activates an existing tab containing the url, rather than navigating. + /// This is similar to SINGLETON_TAB, but searches across all windows from + /// the current profile and anonymity (instead of just the current one); + /// closes the current tab on switching if the current tab was the NTP with + /// no session history; and behaves like CURRENT_TAB instead of + /// NEW_FOREGROUND_TAB when no existing tab is found. + /// + WOD_SWITCH_TO_TAB, + + /// + /// Creates a new document picture-in-picture window showing a child WebView. + /// + WOD_NEW_PICTURE_IN_PICTURE, +} cef_window_open_disposition_t; + +/// +/// "Verb" of a drag-and-drop operation as negotiated between the source and +/// destination. These constants match their equivalents in WebCore's +/// DragActions.h and should not be renumbered. +/// +typedef enum { + DRAG_OPERATION_NONE = 0, + DRAG_OPERATION_COPY = 1, + DRAG_OPERATION_LINK = 2, + DRAG_OPERATION_GENERIC = 4, + DRAG_OPERATION_PRIVATE = 8, + DRAG_OPERATION_MOVE = 16, + DRAG_OPERATION_DELETE = 32, + DRAG_OPERATION_EVERY = UINT_MAX +} cef_drag_operations_mask_t; + +/// +/// Input mode of a virtual keyboard. These constants match their equivalents +/// in Chromium's text_input_mode.h and should not be renumbered. +/// See https://html.spec.whatwg.org/#input-modalities:-the-inputmode-attribute +/// +typedef enum { + CEF_TEXT_INPUT_MODE_DEFAULT, + CEF_TEXT_INPUT_MODE_NONE, + CEF_TEXT_INPUT_MODE_TEXT, + CEF_TEXT_INPUT_MODE_TEL, + CEF_TEXT_INPUT_MODE_URL, + CEF_TEXT_INPUT_MODE_EMAIL, + CEF_TEXT_INPUT_MODE_NUMERIC, + CEF_TEXT_INPUT_MODE_DECIMAL, + CEF_TEXT_INPUT_MODE_SEARCH, + + CEF_TEXT_INPUT_MODE_MAX = CEF_TEXT_INPUT_MODE_SEARCH, +} cef_text_input_mode_t; + +/// +/// V8 access control values. +/// +typedef enum { + V8_ACCESS_CONTROL_DEFAULT = 0, + V8_ACCESS_CONTROL_ALL_CAN_READ = 1, + V8_ACCESS_CONTROL_ALL_CAN_WRITE = 1 << 1, + V8_ACCESS_CONTROL_PROHIBITS_OVERWRITING = 1 << 2 +} cef_v8_accesscontrol_t; + +/// +/// V8 property attribute values. +/// +typedef enum { + /// + /// Writeable, Enumerable, Configurable + /// + V8_PROPERTY_ATTRIBUTE_NONE = 0, + + /// + /// Not writeable + /// + V8_PROPERTY_ATTRIBUTE_READONLY = 1 << 0, + + /// + /// Not enumerable + /// + V8_PROPERTY_ATTRIBUTE_DONTENUM = 1 << 1, + + /// + /// Not configurable + /// + V8_PROPERTY_ATTRIBUTE_DONTDELETE = 1 << 2 +} cef_v8_propertyattribute_t; + +/// +/// Post data elements may represent either bytes or files. +/// +typedef enum { + PDE_TYPE_EMPTY = 0, + PDE_TYPE_BYTES, + PDE_TYPE_FILE, +} cef_postdataelement_type_t; + +/// +/// Resource type for a request. These constants match their equivalents in +/// Chromium's ResourceType and should not be renumbered. +/// +typedef enum { + /// + /// Top level page. + /// + RT_MAIN_FRAME = 0, + + /// + /// Frame or iframe. + /// + RT_SUB_FRAME, + + /// + /// CSS stylesheet. + /// + RT_STYLESHEET, + + /// + /// External script. + /// + RT_SCRIPT, + + /// + /// Image (jpg/gif/png/etc). + /// + RT_IMAGE, + + /// + /// Font. + /// + RT_FONT_RESOURCE, + + /// + /// Some other subresource. This is the default type if the actual type is + /// unknown. + /// + RT_SUB_RESOURCE, + + /// + /// Object (or embed) tag for a plugin, or a resource that a plugin requested. + /// + RT_OBJECT, + + /// + /// Media resource. + /// + RT_MEDIA, + + /// + /// Main resource of a dedicated worker. + /// + RT_WORKER, + + /// + /// Main resource of a shared worker. + /// + RT_SHARED_WORKER, + + /// + /// Explicitly requested prefetch. + /// + RT_PREFETCH, + + /// + /// Favicon. + /// + RT_FAVICON, + + /// + /// XMLHttpRequest. + /// + RT_XHR, + + /// + /// A request for a "<ping>". + /// + RT_PING, + + /// + /// Main resource of a service worker. + /// + RT_SERVICE_WORKER, + + /// + /// A report of Content Security Policy violations. + /// + RT_CSP_REPORT, + + /// + /// A resource that a plugin requested. + /// + RT_PLUGIN_RESOURCE, + + /// + /// A main-frame service worker navigation preload request. + /// + RT_NAVIGATION_PRELOAD_MAIN_FRAME = 19, + + /// + /// A sub-frame service worker navigation preload request. + /// + RT_NAVIGATION_PRELOAD_SUB_FRAME, +} cef_resource_type_t; + +/// +/// Transition type for a request. Made up of one source value and 0 or more +/// qualifiers. +/// +typedef enum { + /// + /// Source is a link click or the JavaScript window.open function. This is + /// also the default value for requests like sub-resource loads that are not + /// navigations. + /// + TT_LINK = 0, + + /// + /// Source is some other "explicit" navigation. This is the default value for + /// navigations where the actual type is unknown. See also + /// TT_DIRECT_LOAD_FLAG. + /// + TT_EXPLICIT = 1, + + /// + /// User got to this page through a suggestion in the UI (for example, via the + /// destinations page). Chrome runtime only. + /// + TT_AUTO_BOOKMARK = 2, + + /// + /// Source is a subframe navigation. This is any content that is automatically + /// loaded in a non-toplevel frame. For example, if a page consists of several + /// frames containing ads, those ad URLs will have this transition type. + /// The user may not even realize the content in these pages is a separate + /// frame, so may not care about the URL. + /// + TT_AUTO_SUBFRAME = 3, + + /// + /// Source is a subframe navigation explicitly requested by the user that will + /// generate new navigation entries in the back/forward list. These are + /// probably more important than frames that were automatically loaded in + /// the background because the user probably cares about the fact that this + /// link was loaded. + /// + TT_MANUAL_SUBFRAME = 4, + + /// + /// User got to this page by typing in the URL bar and selecting an entry + /// that did not look like a URL. For example, a match might have the URL + /// of a Google search result page, but appear like "Search Google for ...". + /// These are not quite the same as EXPLICIT navigations because the user + /// didn't type or see the destination URL. Chrome runtime only. + /// See also TT_KEYWORD. + /// + TT_GENERATED = 5, + + /// + /// This is a toplevel navigation. This is any content that is automatically + /// loaded in a toplevel frame. For example, opening a tab to show the ASH + /// screen saver, opening the devtools window, opening the NTP after the safe + /// browsing warning, opening web-based dialog boxes are examples of + /// AUTO_TOPLEVEL navigations. Chrome runtime only. + /// + TT_AUTO_TOPLEVEL = 6, + + /// + /// Source is a form submission by the user. NOTE: In some situations + /// submitting a form does not result in this transition type. This can happen + /// if the form uses a script to submit the contents. + /// + TT_FORM_SUBMIT = 7, + + /// + /// Source is a "reload" of the page via the Reload function or by re-visiting + /// the same URL. NOTE: This is distinct from the concept of whether a + /// particular load uses "reload semantics" (i.e. bypasses cached data). + /// + TT_RELOAD = 8, + + /// + /// The url was generated from a replaceable keyword other than the default + /// search provider. If the user types a keyword (which also applies to + /// tab-to-search) in the omnibox this qualifier is applied to the transition + /// type of the generated url. TemplateURLModel then may generate an + /// additional visit with a transition type of TT_KEYWORD_GENERATED against + /// the url 'http://' + keyword. For example, if you do a tab-to-search + /// against wikipedia the generated url has a transition qualifer of + /// TT_KEYWORD, and TemplateURLModel generates a visit for 'wikipedia.org' + /// with a transition type of TT_KEYWORD_GENERATED. Chrome runtime only. + /// + TT_KEYWORD = 9, + + /// + /// Corresponds to a visit generated for a keyword. See description of + /// TT_KEYWORD for more details. Chrome runtime only. + /// + TT_KEYWORD_GENERATED = 10, + + /// + /// General mask defining the bits used for the source values. + /// + TT_SOURCE_MASK = 0xFF, + + /// Qualifiers. + /// Any of the core values above can be augmented by one or more qualifiers. + /// These qualifiers further define the transition. + + /// + /// Attempted to visit a URL but was blocked. + /// + TT_BLOCKED_FLAG = 0x00800000, + + /// + /// Used the Forward or Back function to navigate among browsing history. + /// Will be ORed to the transition type for the original load. + /// + TT_FORWARD_BACK_FLAG = 0x01000000, + + /// + /// Loaded a URL directly via CreateBrowser, LoadURL or LoadRequest. + /// + TT_DIRECT_LOAD_FLAG = 0x02000000, + + /// + /// User is navigating to the home page. Chrome runtime only. + /// + TT_HOME_PAGE_FLAG = 0x04000000, + + /// + /// The transition originated from an external application; the exact + /// definition of this is embedder dependent. Chrome runtime and + /// extension system only. + /// + TT_FROM_API_FLAG = 0x08000000, + + /// + /// The beginning of a navigation chain. + /// + TT_CHAIN_START_FLAG = 0x10000000, + + /// + /// The last transition in a redirect chain. + /// + TT_CHAIN_END_FLAG = 0x20000000, + + /// + /// Redirects caused by JavaScript or a meta refresh tag on the page. + /// + TT_CLIENT_REDIRECT_FLAG = 0x40000000, + + /// + /// Redirects sent from the server by HTTP headers. + /// + TT_SERVER_REDIRECT_FLAG = 0x80000000, + + /// + /// Used to test whether a transition involves a redirect. + /// + TT_IS_REDIRECT_MASK = 0xC0000000, + + /// + /// General mask defining the bits used for the qualifiers. + /// + TT_QUALIFIER_MASK = 0xFFFFFF00, +} cef_transition_type_t; + +/// +/// Flags used to customize the behavior of CefURLRequest. +/// +typedef enum { + /// + /// Default behavior. + /// + UR_FLAG_NONE = 0, + + /// + /// If set the cache will be skipped when handling the request. Setting this + /// value is equivalent to specifying the "Cache-Control: no-cache" request + /// header. Setting this value in combination with UR_FLAG_ONLY_FROM_CACHE + /// will cause the request to fail. + /// + UR_FLAG_SKIP_CACHE = 1 << 0, + + /// + /// If set the request will fail if it cannot be served from the cache (or + /// some equivalent local store). Setting this value is equivalent to + /// specifying the "Cache-Control: only-if-cached" request header. Setting + /// this value in combination with UR_FLAG_SKIP_CACHE or UR_FLAG_DISABLE_CACHE + /// will cause the request to fail. + /// + UR_FLAG_ONLY_FROM_CACHE = 1 << 1, + + /// + /// If set the cache will not be used at all. Setting this value is equivalent + /// to specifying the "Cache-Control: no-store" request header. Setting this + /// value in combination with UR_FLAG_ONLY_FROM_CACHE will cause the request + /// to fail. + /// + UR_FLAG_DISABLE_CACHE = 1 << 2, + + /// + /// If set user name, password, and cookies may be sent with the request, and + /// cookies may be saved from the response. + /// + UR_FLAG_ALLOW_STORED_CREDENTIALS = 1 << 3, + + /// + /// If set upload progress events will be generated when a request has a body. + /// + UR_FLAG_REPORT_UPLOAD_PROGRESS = 1 << 4, + + /// + /// If set the CefURLRequestClient::OnDownloadData method will not be called. + /// + UR_FLAG_NO_DOWNLOAD_DATA = 1 << 5, + + /// + /// If set 5XX redirect errors will be propagated to the observer instead of + /// automatically re-tried. This currently only applies for requests + /// originated in the browser process. + /// + UR_FLAG_NO_RETRY_ON_5XX = 1 << 6, + + /// + /// If set 3XX responses will cause the fetch to halt immediately rather than + /// continue through the redirect. + /// + UR_FLAG_STOP_ON_REDIRECT = 1 << 7, +} cef_urlrequest_flags_t; + +/// +/// Flags that represent CefURLRequest status. +/// +typedef enum { + /// + /// Unknown status. + /// + UR_UNKNOWN = 0, + + /// + /// Request succeeded. + /// + UR_SUCCESS, + + /// + /// An IO request is pending, and the caller will be informed when it is + /// completed. + /// + UR_IO_PENDING, + + /// + /// Request was canceled programatically. + /// + UR_CANCELED, + + /// + /// Request failed for some reason. + /// + UR_FAILED, +} cef_urlrequest_status_t; + +/// Structure representing a draggable region. +/// +typedef struct _cef_draggable_region_t { + /// + /// Bounds of the region. + /// + cef_rect_t bounds; + + /// + /// True (1) this this region is draggable and false (0) otherwise. + /// + int draggable; +} cef_draggable_region_t; + +/// +/// Existing process IDs. +/// +typedef enum { + /// + /// Browser process. + /// + PID_BROWSER, + /// + /// Renderer process. + /// + PID_RENDERER, +} cef_process_id_t; + +/// +/// Existing thread IDs. +/// +typedef enum { + // BROWSER PROCESS THREADS -- Only available in the browser process. + + /// + /// The main thread in the browser. This will be the same as the main + /// application thread if CefInitialize() is called with a + /// CefSettings.multi_threaded_message_loop value of false. Do not perform + /// blocking tasks on this thread. All tasks posted after + /// CefBrowserProcessHandler::OnContextInitialized() and before CefShutdown() + /// are guaranteed to run. This thread will outlive all other CEF threads. + /// + TID_UI, + + /// + /// Used for blocking tasks like file system access where the user won't + /// notice if the task takes an arbitrarily long time to complete. All tasks + /// posted after CefBrowserProcessHandler::OnContextInitialized() and before + /// CefShutdown() are guaranteed to run. + /// + TID_FILE_BACKGROUND, + + /// + /// Used for blocking tasks like file system access that affect UI or + /// responsiveness of future user interactions. Do not use if an immediate + /// response to a user interaction is expected. All tasks posted after + /// CefBrowserProcessHandler::OnContextInitialized() and before CefShutdown() + /// are guaranteed to run. + /// Examples: + /// - Updating the UI to reflect progress on a long task. + /// - Loading data that might be shown in the UI after a future user + /// interaction. + /// + TID_FILE_USER_VISIBLE, + + /// + /// Used for blocking tasks like file system access that affect UI + /// immediately after a user interaction. All tasks posted after + /// CefBrowserProcessHandler::OnContextInitialized() and before CefShutdown() + /// are guaranteed to run. + /// Example: Generating data shown in the UI immediately after a click. + /// + TID_FILE_USER_BLOCKING, + + /// + /// Used to launch and terminate browser processes. + /// + TID_PROCESS_LAUNCHER, + + /// + /// Used to process IPC and network messages. Do not perform blocking tasks on + /// this thread. All tasks posted after + /// CefBrowserProcessHandler::OnContextInitialized() and before CefShutdown() + /// are guaranteed to run. + /// + TID_IO, + + // RENDER PROCESS THREADS -- Only available in the render process. + + /// + /// The main thread in the renderer. Used for all WebKit and V8 interaction. + /// Tasks may be posted to this thread after + /// CefRenderProcessHandler::OnWebKitInitialized but are not guaranteed to + /// run before sub-process termination (sub-processes may be killed at any + /// time without warning). + /// + TID_RENDERER, +} cef_thread_id_t; + +/// +/// Thread priority values listed in increasing order of importance. +/// +typedef enum { + /// + /// Suitable for threads that shouldn't disrupt high priority work. + /// + TP_BACKGROUND, + + /// + /// Default priority level. + /// + TP_NORMAL, + + /// + /// Suitable for threads which generate data for the display (at ~60Hz). + /// + TP_DISPLAY, + + /// + /// Suitable for low-latency, glitch-resistant audio. + /// + TP_REALTIME_AUDIO, +} cef_thread_priority_t; + +/// +/// Message loop types. Indicates the set of asynchronous events that a message +/// loop can process. +/// +typedef enum { + /// + /// Supports tasks and timers. + /// + ML_TYPE_DEFAULT, + + /// + /// Supports tasks, timers and native UI events (e.g. Windows messages). + /// + ML_TYPE_UI, + + /// + /// Supports tasks, timers and asynchronous IO events. + /// + ML_TYPE_IO, +} cef_message_loop_type_t; + +/// +/// Windows COM initialization mode. Specifies how COM will be initialized for a +/// new thread. +/// +typedef enum { + /// + /// No COM initialization. + /// + COM_INIT_MODE_NONE, + + /// + /// Initialize COM using single-threaded apartments. + /// + COM_INIT_MODE_STA, + + /// + /// Initialize COM using multi-threaded apartments. + /// + COM_INIT_MODE_MTA, +} cef_com_init_mode_t; + +/// +/// Supported value types. +/// +typedef enum { + VTYPE_INVALID = 0, + VTYPE_NULL, + VTYPE_BOOL, + VTYPE_INT, + VTYPE_DOUBLE, + VTYPE_STRING, + VTYPE_BINARY, + VTYPE_DICTIONARY, + VTYPE_LIST, +} cef_value_type_t; + +/// +/// Supported JavaScript dialog types. +/// +typedef enum { + JSDIALOGTYPE_ALERT = 0, + JSDIALOGTYPE_CONFIRM, + JSDIALOGTYPE_PROMPT, +} cef_jsdialog_type_t; + +/// +/// Screen information used when window rendering is disabled. This structure is +/// passed as a parameter to CefRenderHandler::GetScreenInfo and should be +/// filled in by the client. +/// +typedef struct _cef_screen_info_t { + /// + /// Device scale factor. Specifies the ratio between physical and logical + /// pixels. + /// + float device_scale_factor; + + /// + /// The screen depth in bits per pixel. + /// + int depth; + + /// + /// The bits per color component. This assumes that the colors are balanced + /// equally. + /// + int depth_per_component; + + /// + /// This can be true for black and white printers. + /// + int is_monochrome; + + /// + /// This is set from the rcMonitor member of MONITORINFOEX, to whit: + /// "A RECT structure that specifies the display monitor rectangle, + /// expressed in virtual-screen coordinates. Note that if the monitor + /// is not the primary display monitor, some of the rectangle's + /// coordinates may be negative values." + // + /// The |rect| and |available_rect| properties are used to determine the + /// available surface for rendering popup views. + /// + cef_rect_t rect; + + /// + /// This is set from the rcWork member of MONITORINFOEX, to whit: + /// "A RECT structure that specifies the work area rectangle of the + /// display monitor that can be used by applications, expressed in + /// virtual-screen coordinates. Windows uses this rectangle to + /// maximize an application on the monitor. The rest of the area in + /// rcMonitor contains system windows such as the task bar and side + /// bars. Note that if the monitor is not the primary display monitor, + /// some of the rectangle's coordinates may be negative values". + // + /// The |rect| and |available_rect| properties are used to determine the + /// available surface for rendering popup views. + /// + cef_rect_t available_rect; +} cef_screen_info_t; + +/// +/// Supported menu IDs. Non-English translations can be provided for the +/// IDS_MENU_* strings in CefResourceBundleHandler::GetLocalizedString(). +/// +typedef enum { + // Navigation. + MENU_ID_BACK = 100, + MENU_ID_FORWARD = 101, + MENU_ID_RELOAD = 102, + MENU_ID_RELOAD_NOCACHE = 103, + MENU_ID_STOPLOAD = 104, + + // Editing. + MENU_ID_UNDO = 110, + MENU_ID_REDO = 111, + MENU_ID_CUT = 112, + MENU_ID_COPY = 113, + MENU_ID_PASTE = 114, + MENU_ID_DELETE = 115, + MENU_ID_SELECT_ALL = 116, + + // Miscellaneous. + MENU_ID_FIND = 130, + MENU_ID_PRINT = 131, + MENU_ID_VIEW_SOURCE = 132, + + // Spell checking word correction suggestions. + MENU_ID_SPELLCHECK_SUGGESTION_0 = 200, + MENU_ID_SPELLCHECK_SUGGESTION_1 = 201, + MENU_ID_SPELLCHECK_SUGGESTION_2 = 202, + MENU_ID_SPELLCHECK_SUGGESTION_3 = 203, + MENU_ID_SPELLCHECK_SUGGESTION_4 = 204, + MENU_ID_SPELLCHECK_SUGGESTION_LAST = 204, + MENU_ID_NO_SPELLING_SUGGESTIONS = 205, + MENU_ID_ADD_TO_DICTIONARY = 206, + + // Custom menu items originating from the renderer process. + MENU_ID_CUSTOM_FIRST = 220, + MENU_ID_CUSTOM_LAST = 250, + + // All user-defined menu IDs should come between MENU_ID_USER_FIRST and + // MENU_ID_USER_LAST to avoid overlapping the Chromium and CEF ID ranges + // defined in the tools/gritsettings/resource_ids file. + MENU_ID_USER_FIRST = 26500, + MENU_ID_USER_LAST = 28500, +} cef_menu_id_t; + +/// +/// Mouse button types. +/// +typedef enum { + MBT_LEFT = 0, + MBT_MIDDLE, + MBT_RIGHT, +} cef_mouse_button_type_t; + +/// +/// Structure representing mouse event information. +/// +typedef struct _cef_mouse_event_t { + /// + /// X coordinate relative to the left side of the view. + /// + int x; + + /// + /// Y coordinate relative to the top side of the view. + /// + int y; + + /// + /// Bit flags describing any pressed modifier keys. See + /// cef_event_flags_t for values. + /// + uint32 modifiers; +} cef_mouse_event_t; + +/// +/// Touch points states types. +/// +typedef enum { + CEF_TET_RELEASED = 0, + CEF_TET_PRESSED, + CEF_TET_MOVED, + CEF_TET_CANCELLED +} cef_touch_event_type_t; + +/// +/// The device type that caused the event. +/// +typedef enum { + CEF_POINTER_TYPE_TOUCH = 0, + CEF_POINTER_TYPE_MOUSE, + CEF_POINTER_TYPE_PEN, + CEF_POINTER_TYPE_ERASER, + CEF_POINTER_TYPE_UNKNOWN +} cef_pointer_type_t; + +/// +/// Structure representing touch event information. +/// +typedef struct _cef_touch_event_t { + /// + /// Id of a touch point. Must be unique per touch, can be any number except + /// -1. Note that a maximum of 16 concurrent touches will be tracked; touches + /// beyond that will be ignored. + /// + int id; + + /// + /// X coordinate relative to the left side of the view. + /// + float x; + + /// + /// Y coordinate relative to the top side of the view. + /// + float y; + + /// + /// X radius in pixels. Set to 0 if not applicable. + /// + float radius_x; + + /// + /// Y radius in pixels. Set to 0 if not applicable. + /// + float radius_y; + + /// + /// Rotation angle in radians. Set to 0 if not applicable. + /// + float rotation_angle; + + /// + /// The normalized pressure of the pointer input in the range of [0,1]. + /// Set to 0 if not applicable. + /// + float pressure; + + /// + /// The state of the touch point. Touches begin with one CEF_TET_PRESSED event + /// followed by zero or more CEF_TET_MOVED events and finally one + /// CEF_TET_RELEASED or CEF_TET_CANCELLED event. Events not respecting this + /// order will be ignored. + /// + cef_touch_event_type_t type; + + /// + /// Bit flags describing any pressed modifier keys. See + /// cef_event_flags_t for values. + /// + uint32 modifiers; + + /// + /// The device type that caused the event. + /// + cef_pointer_type_t pointer_type; + +} cef_touch_event_t; + +/// +/// Paint element types. +/// +typedef enum { + PET_VIEW = 0, + PET_POPUP, +} cef_paint_element_type_t; + +/// +/// Supported event bit flags. +/// +typedef enum { + EVENTFLAG_NONE = 0, + EVENTFLAG_CAPS_LOCK_ON = 1 << 0, + EVENTFLAG_SHIFT_DOWN = 1 << 1, + EVENTFLAG_CONTROL_DOWN = 1 << 2, + EVENTFLAG_ALT_DOWN = 1 << 3, + EVENTFLAG_LEFT_MOUSE_BUTTON = 1 << 4, + EVENTFLAG_MIDDLE_MOUSE_BUTTON = 1 << 5, + EVENTFLAG_RIGHT_MOUSE_BUTTON = 1 << 6, + /// Mac OS-X command key. + EVENTFLAG_COMMAND_DOWN = 1 << 7, + EVENTFLAG_NUM_LOCK_ON = 1 << 8, + EVENTFLAG_IS_KEY_PAD = 1 << 9, + EVENTFLAG_IS_LEFT = 1 << 10, + EVENTFLAG_IS_RIGHT = 1 << 11, + EVENTFLAG_ALTGR_DOWN = 1 << 12, + EVENTFLAG_IS_REPEAT = 1 << 13, +} cef_event_flags_t; + +/// +/// Supported menu item types. +/// +typedef enum { + MENUITEMTYPE_NONE, + MENUITEMTYPE_COMMAND, + MENUITEMTYPE_CHECK, + MENUITEMTYPE_RADIO, + MENUITEMTYPE_SEPARATOR, + MENUITEMTYPE_SUBMENU, +} cef_menu_item_type_t; + +/// +/// Supported context menu type flags. +/// +typedef enum { + /// + /// No node is selected. + /// + CM_TYPEFLAG_NONE = 0, + /// + /// The top page is selected. + /// + CM_TYPEFLAG_PAGE = 1 << 0, + /// + /// A subframe page is selected. + /// + CM_TYPEFLAG_FRAME = 1 << 1, + /// + /// A link is selected. + /// + CM_TYPEFLAG_LINK = 1 << 2, + /// + /// A media node is selected. + /// + CM_TYPEFLAG_MEDIA = 1 << 3, + /// + /// There is a textual or mixed selection that is selected. + /// + CM_TYPEFLAG_SELECTION = 1 << 4, + /// + /// An editable element is selected. + /// + CM_TYPEFLAG_EDITABLE = 1 << 5, +} cef_context_menu_type_flags_t; + +/// +/// Supported context menu media types. These constants match their equivalents +/// in Chromium's ContextMenuDataMediaType and should not be renumbered. +/// +typedef enum { + /// + /// No special node is in context. + /// + CM_MEDIATYPE_NONE, + /// + /// An image node is selected. + /// + CM_MEDIATYPE_IMAGE, + /// + /// A video node is selected. + /// + CM_MEDIATYPE_VIDEO, + /// + /// An audio node is selected. + /// + CM_MEDIATYPE_AUDIO, + /// + /// An canvas node is selected. + /// + CM_MEDIATYPE_CANVAS, + /// + /// A file node is selected. + /// + CM_MEDIATYPE_FILE, + /// + /// A plugin node is selected. + /// + CM_MEDIATYPE_PLUGIN, +} cef_context_menu_media_type_t; + +/// +/// Supported context menu media state bit flags. These constants match their +/// equivalents in Chromium's ContextMenuData::MediaFlags and should not be +/// renumbered. +/// +typedef enum { + CM_MEDIAFLAG_NONE = 0, + CM_MEDIAFLAG_IN_ERROR = 1 << 0, + CM_MEDIAFLAG_PAUSED = 1 << 1, + CM_MEDIAFLAG_MUTED = 1 << 2, + CM_MEDIAFLAG_LOOP = 1 << 3, + CM_MEDIAFLAG_CAN_SAVE = 1 << 4, + CM_MEDIAFLAG_HAS_AUDIO = 1 << 5, + CM_MEDIAFLAG_CAN_TOGGLE_CONTROLS = 1 << 6, + CM_MEDIAFLAG_CONTROLS = 1 << 7, + CM_MEDIAFLAG_CAN_PRINT = 1 << 8, + CM_MEDIAFLAG_CAN_ROTATE = 1 << 9, + CM_MEDIAFLAG_CAN_PICTURE_IN_PICTURE = 1 << 10, + CM_MEDIAFLAG_PICTURE_IN_PICTURE = 1 << 11, + CM_MEDIAFLAG_CAN_LOOP = 1 << 12, +} cef_context_menu_media_state_flags_t; + +/// +/// Supported context menu edit state bit flags. These constants match their +/// equivalents in Chromium's ContextMenuDataEditFlags and should not be +/// renumbered. +/// +typedef enum { + CM_EDITFLAG_NONE = 0, + CM_EDITFLAG_CAN_UNDO = 1 << 0, + CM_EDITFLAG_CAN_REDO = 1 << 1, + CM_EDITFLAG_CAN_CUT = 1 << 2, + CM_EDITFLAG_CAN_COPY = 1 << 3, + CM_EDITFLAG_CAN_PASTE = 1 << 4, + CM_EDITFLAG_CAN_DELETE = 1 << 5, + CM_EDITFLAG_CAN_SELECT_ALL = 1 << 6, + CM_EDITFLAG_CAN_TRANSLATE = 1 << 7, + CM_EDITFLAG_CAN_EDIT_RICHLY = 1 << 8, +} cef_context_menu_edit_state_flags_t; + +/// +/// Supported quick menu state bit flags. +/// +typedef enum { + QM_EDITFLAG_NONE = 0, + QM_EDITFLAG_CAN_ELLIPSIS = 1 << 0, + QM_EDITFLAG_CAN_CUT = 1 << 1, + QM_EDITFLAG_CAN_COPY = 1 << 2, + QM_EDITFLAG_CAN_PASTE = 1 << 3, +} cef_quick_menu_edit_state_flags_t; + +/// +/// Key event types. +/// +typedef enum { + /// + /// Notification that a key transitioned from "up" to "down". + /// + KEYEVENT_RAWKEYDOWN = 0, + + /// + /// Notification that a key was pressed. This does not necessarily correspond + /// to a character depending on the key and language. Use KEYEVENT_CHAR for + /// character input. + /// + KEYEVENT_KEYDOWN, + + /// + /// Notification that a key was released. + /// + KEYEVENT_KEYUP, + + /// + /// Notification that a character was typed. Use this for text input. Key + /// down events may generate 0, 1, or more than one character event depending + /// on the key, locale, and operating system. + /// + KEYEVENT_CHAR +} cef_key_event_type_t; + +/// +/// Structure representing keyboard event information. +/// +typedef struct _cef_key_event_t { + /// + /// The type of keyboard event. + /// + cef_key_event_type_t type; + + /// + /// Bit flags describing any pressed modifier keys. See + /// cef_event_flags_t for values. + /// + uint32 modifiers; + + /// + /// The Windows key code for the key event. This value is used by the DOM + /// specification. Sometimes it comes directly from the event (i.e. on + /// Windows) and sometimes it's determined using a mapping function. See + /// WebCore/platform/chromium/KeyboardCodes.h for the list of values. + /// + int windows_key_code; + + /// + /// The actual key code genenerated by the platform. + /// + int native_key_code; + + /// + /// Indicates whether the event is considered a "system key" event (see + /// http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx for details). + /// This value will always be false on non-Windows platforms. + /// + int is_system_key; + + /// + /// The character generated by the keystroke. + /// + char16 character; + + /// + /// Same as |character| but unmodified by any concurrently-held modifiers + /// (except shift). This is useful for working out shortcut keys. + /// + char16 unmodified_character; + + /// + /// True if the focus is currently on an editable field on the page. This is + /// useful for determining if standard key events should be intercepted. + /// + int focus_on_editable_field; +} cef_key_event_t; + +/// +/// Focus sources. +/// +typedef enum { + /// + /// The source is explicit navigation via the API (LoadURL(), etc). + /// + FOCUS_SOURCE_NAVIGATION = 0, + /// + /// The source is a system-generated focus event. + /// + FOCUS_SOURCE_SYSTEM, +} cef_focus_source_t; + +/// +/// Navigation types. +/// +typedef enum { + NAVIGATION_LINK_CLICKED = 0, + NAVIGATION_FORM_SUBMITTED, + NAVIGATION_BACK_FORWARD, + NAVIGATION_RELOAD, + NAVIGATION_FORM_RESUBMITTED, + NAVIGATION_OTHER, +} cef_navigation_type_t; + +/// +/// Supported XML encoding types. The parser supports ASCII, ISO-8859-1, and +/// UTF16 (LE and BE) by default. All other types must be translated to UTF8 +/// before being passed to the parser. If a BOM is detected and the correct +/// decoder is available then that decoder will be used automatically. +/// +typedef enum { + XML_ENCODING_NONE = 0, + XML_ENCODING_UTF8, + XML_ENCODING_UTF16LE, + XML_ENCODING_UTF16BE, + XML_ENCODING_ASCII, +} cef_xml_encoding_type_t; + +/// +/// XML node types. +/// +typedef enum { + XML_NODE_UNSUPPORTED = 0, + XML_NODE_PROCESSING_INSTRUCTION, + XML_NODE_DOCUMENT_TYPE, + XML_NODE_ELEMENT_START, + XML_NODE_ELEMENT_END, + XML_NODE_ATTRIBUTE, + XML_NODE_TEXT, + XML_NODE_CDATA, + XML_NODE_ENTITY_REFERENCE, + XML_NODE_WHITESPACE, + XML_NODE_COMMENT, +} cef_xml_node_type_t; + +/// +/// Popup window features. +/// +typedef struct _cef_popup_features_t { + int x; + int xSet; + int y; + int ySet; + int width; + int widthSet; + int height; + int heightSet; + + /// True (1) if browser interface elements should be hidden. + int isPopup; +} cef_popup_features_t; + +/// +/// DOM document types. +/// +typedef enum { + DOM_DOCUMENT_TYPE_UNKNOWN = 0, + DOM_DOCUMENT_TYPE_HTML, + DOM_DOCUMENT_TYPE_XHTML, + DOM_DOCUMENT_TYPE_PLUGIN, +} cef_dom_document_type_t; + +/// +/// DOM event category flags. +/// +typedef enum { + DOM_EVENT_CATEGORY_UNKNOWN = 0x0, + DOM_EVENT_CATEGORY_UI = 0x1, + DOM_EVENT_CATEGORY_MOUSE = 0x2, + DOM_EVENT_CATEGORY_MUTATION = 0x4, + DOM_EVENT_CATEGORY_KEYBOARD = 0x8, + DOM_EVENT_CATEGORY_TEXT = 0x10, + DOM_EVENT_CATEGORY_COMPOSITION = 0x20, + DOM_EVENT_CATEGORY_DRAG = 0x40, + DOM_EVENT_CATEGORY_CLIPBOARD = 0x80, + DOM_EVENT_CATEGORY_MESSAGE = 0x100, + DOM_EVENT_CATEGORY_WHEEL = 0x200, + DOM_EVENT_CATEGORY_BEFORE_TEXT_INSERTED = 0x400, + DOM_EVENT_CATEGORY_OVERFLOW = 0x800, + DOM_EVENT_CATEGORY_PAGE_TRANSITION = 0x1000, + DOM_EVENT_CATEGORY_POPSTATE = 0x2000, + DOM_EVENT_CATEGORY_PROGRESS = 0x4000, + DOM_EVENT_CATEGORY_XMLHTTPREQUEST_PROGRESS = 0x8000, +} cef_dom_event_category_t; + +/// +/// DOM event processing phases. +/// +typedef enum { + DOM_EVENT_PHASE_UNKNOWN = 0, + DOM_EVENT_PHASE_CAPTURING, + DOM_EVENT_PHASE_AT_TARGET, + DOM_EVENT_PHASE_BUBBLING, +} cef_dom_event_phase_t; + +/// +/// DOM node types. +/// +typedef enum { + DOM_NODE_TYPE_UNSUPPORTED = 0, + DOM_NODE_TYPE_ELEMENT, + DOM_NODE_TYPE_ATTRIBUTE, + DOM_NODE_TYPE_TEXT, + DOM_NODE_TYPE_CDATA_SECTION, + DOM_NODE_TYPE_PROCESSING_INSTRUCTIONS, + DOM_NODE_TYPE_COMMENT, + DOM_NODE_TYPE_DOCUMENT, + DOM_NODE_TYPE_DOCUMENT_TYPE, + DOM_NODE_TYPE_DOCUMENT_FRAGMENT, +} cef_dom_node_type_t; + +/// +/// Supported file dialog modes. +/// +typedef enum { + /// + /// Requires that the file exists before allowing the user to pick it. + /// + FILE_DIALOG_OPEN = 0, + + /// + /// Like Open, but allows picking multiple files to open. + /// + FILE_DIALOG_OPEN_MULTIPLE, + + /// + /// Like Open, but selects a folder to open. + /// + FILE_DIALOG_OPEN_FOLDER, + + /// + /// Allows picking a nonexistent file, and prompts to overwrite if the file + /// already exists. + /// + FILE_DIALOG_SAVE, +} cef_file_dialog_mode_t; + +/// +/// Print job color mode values. +/// +typedef enum { + COLOR_MODEL_UNKNOWN, + COLOR_MODEL_GRAY, + COLOR_MODEL_COLOR, + COLOR_MODEL_CMYK, + COLOR_MODEL_CMY, + COLOR_MODEL_KCMY, + COLOR_MODEL_CMY_K, // CMY_K represents CMY+K. + COLOR_MODEL_BLACK, + COLOR_MODEL_GRAYSCALE, + COLOR_MODEL_RGB, + COLOR_MODEL_RGB16, + COLOR_MODEL_RGBA, + COLOR_MODEL_COLORMODE_COLOR, // Used in samsung printer ppds. + COLOR_MODEL_COLORMODE_MONOCHROME, // Used in samsung printer ppds. + COLOR_MODEL_HP_COLOR_COLOR, // Used in HP color printer ppds. + COLOR_MODEL_HP_COLOR_BLACK, // Used in HP color printer ppds. + COLOR_MODEL_PRINTOUTMODE_NORMAL, // Used in foomatic ppds. + COLOR_MODEL_PRINTOUTMODE_NORMAL_GRAY, // Used in foomatic ppds. + COLOR_MODEL_PROCESSCOLORMODEL_CMYK, // Used in canon printer ppds. + COLOR_MODEL_PROCESSCOLORMODEL_GREYSCALE, // Used in canon printer ppds. + COLOR_MODEL_PROCESSCOLORMODEL_RGB, // Used in canon printer ppds +} cef_color_model_t; + +/// +/// Print job duplex mode values. +/// +typedef enum { + DUPLEX_MODE_UNKNOWN = -1, + DUPLEX_MODE_SIMPLEX, + DUPLEX_MODE_LONG_EDGE, + DUPLEX_MODE_SHORT_EDGE, +} cef_duplex_mode_t; + +/// +/// Cursor type values. +/// +typedef enum { + CT_POINTER = 0, + CT_CROSS, + CT_HAND, + CT_IBEAM, + CT_WAIT, + CT_HELP, + CT_EASTRESIZE, + CT_NORTHRESIZE, + CT_NORTHEASTRESIZE, + CT_NORTHWESTRESIZE, + CT_SOUTHRESIZE, + CT_SOUTHEASTRESIZE, + CT_SOUTHWESTRESIZE, + CT_WESTRESIZE, + CT_NORTHSOUTHRESIZE, + CT_EASTWESTRESIZE, + CT_NORTHEASTSOUTHWESTRESIZE, + CT_NORTHWESTSOUTHEASTRESIZE, + CT_COLUMNRESIZE, + CT_ROWRESIZE, + CT_MIDDLEPANNING, + CT_EASTPANNING, + CT_NORTHPANNING, + CT_NORTHEASTPANNING, + CT_NORTHWESTPANNING, + CT_SOUTHPANNING, + CT_SOUTHEASTPANNING, + CT_SOUTHWESTPANNING, + CT_WESTPANNING, + CT_MOVE, + CT_VERTICALTEXT, + CT_CELL, + CT_CONTEXTMENU, + CT_ALIAS, + CT_PROGRESS, + CT_NODROP, + CT_COPY, + CT_NONE, + CT_NOTALLOWED, + CT_ZOOMIN, + CT_ZOOMOUT, + CT_GRAB, + CT_GRABBING, + CT_MIDDLE_PANNING_VERTICAL, + CT_MIDDLE_PANNING_HORIZONTAL, + CT_CUSTOM, + CT_DND_NONE, + CT_DND_MOVE, + CT_DND_COPY, + CT_DND_LINK, +} cef_cursor_type_t; + +/// +/// Structure representing cursor information. |buffer| will be +/// |size.width|*|size.height|*4 bytes in size and represents a BGRA image with +/// an upper-left origin. +/// +typedef struct _cef_cursor_info_t { + cef_point_t hotspot; + float image_scale_factor; + void* buffer; + cef_size_t size; +} cef_cursor_info_t; + +/// +/// URI unescape rules passed to CefURIDecode(). +/// +typedef enum { + /// + /// Don't unescape anything at all. + /// + UU_NONE = 0, + + /// + /// Don't unescape anything special, but all normal unescaping will happen. + /// This is a placeholder and can't be combined with other flags (since it's + /// just the absence of them). All other unescape rules imply "normal" in + /// addition to their special meaning. Things like escaped letters, digits, + /// and most symbols will get unescaped with this mode. + /// + UU_NORMAL = 1 << 0, + + /// + /// Convert %20 to spaces. In some places where we're showing URLs, we may + /// want this. In places where the URL may be copied and pasted out, then + /// you wouldn't want this since it might not be interpreted in one piece + /// by other applications. + /// + UU_SPACES = 1 << 1, + + /// + /// Unescapes '/' and '\\'. If these characters were unescaped, the resulting + /// URL won't be the same as the source one. Moreover, they are dangerous to + /// unescape in strings that will be used as file paths or names. This value + /// should only be used when slashes don't have special meaning, like data + /// URLs. + /// + UU_PATH_SEPARATORS = 1 << 2, + + /// + /// Unescapes various characters that will change the meaning of URLs, + /// including '%', '+', '&', '#'. Does not unescape path separators. + /// If these characters were unescaped, the resulting URL won't be the same + /// as the source one. This flag is used when generating final output like + /// filenames for URLs where we won't be interpreting as a URL and want to do + /// as much unescaping as possible. + /// + UU_URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS = 1 << 3, + + /// + /// URL queries use "+" for space. This flag controls that replacement. + /// + UU_REPLACE_PLUS_WITH_SPACE = 1 << 4, +} cef_uri_unescape_rule_t; + +/// +/// Options that can be passed to CefParseJSON. +/// +typedef enum { + /// + /// Parses the input strictly according to RFC 4627. See comments in + /// Chromium's base/json/json_reader.h file for known limitations/ + /// deviations from the RFC. + /// + JSON_PARSER_RFC = 0, + + /// + /// Allows commas to exist after the last element in structures. + /// + JSON_PARSER_ALLOW_TRAILING_COMMAS = 1 << 0, +} cef_json_parser_options_t; + +/// +/// Options that can be passed to CefWriteJSON. +/// +typedef enum { + /// + /// Default behavior. + /// + JSON_WRITER_DEFAULT = 0, + + /// + /// This option instructs the writer that if a Binary value is encountered, + /// the value (and key if within a dictionary) will be omitted from the + /// output, and success will be returned. Otherwise, if a binary value is + /// encountered, failure will be returned. + /// + JSON_WRITER_OMIT_BINARY_VALUES = 1 << 0, + + /// + /// This option instructs the writer to write doubles that have no fractional + /// part as a normal integer (i.e., without using exponential notation + /// or appending a '.0') as long as the value is within the range of a + /// 64-bit int. + /// + JSON_WRITER_OMIT_DOUBLE_TYPE_PRESERVATION = 1 << 1, + + /// + /// Return a slightly nicer formatted json string (pads with whitespace to + /// help with readability). + /// + JSON_WRITER_PRETTY_PRINT = 1 << 2, +} cef_json_writer_options_t; + +/// +/// Margin type for PDF printing. +/// +typedef enum { + /// + /// Default margins of 1cm (~0.4 inches). + /// + PDF_PRINT_MARGIN_DEFAULT, + + /// + /// No margins. + /// + PDF_PRINT_MARGIN_NONE, + + /// + /// Custom margins using the |margin_*| values from cef_pdf_print_settings_t. + /// + PDF_PRINT_MARGIN_CUSTOM, +} cef_pdf_print_margin_type_t; + +/// +/// Structure representing PDF print settings. These values match the parameters +/// supported by the DevTools Page.printToPDF function. See +/// https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-printToPDF +/// +typedef struct _cef_pdf_print_settings_t { + /// + /// Set to true (1) for landscape mode or false (0) for portrait mode. + /// + int landscape; + + /// + /// Set to true (1) to print background graphics. + /// + int print_background; + + /// + /// The percentage to scale the PDF by before printing (e.g. .5 is 50%). + /// If this value is less than or equal to zero the default value of 1.0 + /// will be used. + /// + double scale; + + /// + /// Output paper size in inches. If either of these values is less than or + /// equal to zero then the default paper size (letter, 8.5 x 11 inches) will + /// be used. + /// + double paper_width; + double paper_height; + + /// + /// Set to true (1) to prefer page size as defined by css. Defaults to false + /// (0), in which case the content will be scaled to fit the paper size. + /// + int prefer_css_page_size; + + /// + /// Margin type. + /// + cef_pdf_print_margin_type_t margin_type; + + /// + /// Margins in inches. Only used if |margin_type| is set to + /// PDF_PRINT_MARGIN_CUSTOM. + /// + double margin_top; + double margin_right; + double margin_bottom; + double margin_left; + + /// + /// Paper ranges to print, one based, e.g., '1-5, 8, 11-13'. Pages are printed + /// in the document order, not in the order specified, and no more than once. + /// Defaults to empty string, which implies the entire document is printed. + /// The page numbers are quietly capped to actual page count of the document, + /// and ranges beyond the end of the document are ignored. If this results in + /// no pages to print, an error is reported. It is an error to specify a range + /// with start greater than end. + /// + cef_string_t page_ranges; + + /// + /// Set to true (1) to display the header and/or footer. Modify + /// |header_template| and/or |footer_template| to customize the display. + /// + int display_header_footer; + + /// + /// HTML template for the print header. Only displayed if + /// |display_header_footer| is true (1). Should be valid HTML markup with + /// the following classes used to inject printing values into them: + /// + /// - date: formatted print date + /// - title: document title + /// - url: document location + /// - pageNumber: current page number + /// - totalPages: total pages in the document + /// + /// For example, "<span class=title></span>" would generate a span containing + /// the title. + /// + cef_string_t header_template; + + /// + /// HTML template for the print footer. Only displayed if + /// |display_header_footer| is true (1). Uses the same format as + /// |header_template|. + /// + cef_string_t footer_template; +} cef_pdf_print_settings_t; + +/// +/// Supported UI scale factors for the platform. SCALE_FACTOR_NONE is used for +/// density independent resources such as string, html/js files or an image that +/// can be used for any scale factors (such as wallpapers). +/// +typedef enum { + SCALE_FACTOR_NONE = 0, + SCALE_FACTOR_100P, + SCALE_FACTOR_125P, + SCALE_FACTOR_133P, + SCALE_FACTOR_140P, + SCALE_FACTOR_150P, + SCALE_FACTOR_180P, + SCALE_FACTOR_200P, + SCALE_FACTOR_250P, + SCALE_FACTOR_300P, +} cef_scale_factor_t; + +/// +/// Policy for how the Referrer HTTP header value will be sent during +/// navigation. If the `--no-referrers` command-line flag is specified then the +/// policy value will be ignored and the Referrer value will never be sent. Must +/// be kept synchronized with net::URLRequest::ReferrerPolicy from Chromium. +/// +typedef enum { + /// + /// Clear the referrer header if the header value is HTTPS but the request + /// destination is HTTP. This is the default behavior. + /// + REFERRER_POLICY_CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE, + REFERRER_POLICY_DEFAULT = + REFERRER_POLICY_CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE, + + /// + /// A slight variant on CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE: + /// If the request destination is HTTP, an HTTPS referrer will be cleared. If + /// the request's destination is cross-origin with the referrer (but does not + /// downgrade), the referrer's granularity will be stripped down to an origin + /// rather than a full URL. Same-origin requests will send the full referrer. + /// + REFERRER_POLICY_REDUCE_REFERRER_GRANULARITY_ON_TRANSITION_CROSS_ORIGIN, + + /// + /// Strip the referrer down to an origin when the origin of the referrer is + /// different from the destination's origin. + /// + REFERRER_POLICY_ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN, + + /// + /// Never change the referrer. + /// + REFERRER_POLICY_NEVER_CLEAR_REFERRER, + + /// + /// Strip the referrer down to the origin regardless of the redirect location. + /// + REFERRER_POLICY_ORIGIN, + + /// + /// Clear the referrer when the request's referrer is cross-origin with the + /// request's destination. + /// + REFERRER_POLICY_CLEAR_REFERRER_ON_TRANSITION_CROSS_ORIGIN, + + /// + /// Strip the referrer down to the origin, but clear it entirely if the + /// referrer value is HTTPS and the destination is HTTP. + /// + REFERRER_POLICY_ORIGIN_CLEAR_ON_TRANSITION_FROM_SECURE_TO_INSECURE, + + /// + /// Always clear the referrer regardless of the request destination. + /// + REFERRER_POLICY_NO_REFERRER, + + /// Always the last value in this enumeration. + REFERRER_POLICY_LAST_VALUE = REFERRER_POLICY_NO_REFERRER, +} cef_referrer_policy_t; + +/// +/// Return values for CefResponseFilter::Filter(). +/// +typedef enum { + /// + /// Some or all of the pre-filter data was read successfully but more data is + /// needed in order to continue filtering (filtered output is pending). + /// + RESPONSE_FILTER_NEED_MORE_DATA, + + /// + /// Some or all of the pre-filter data was read successfully and all available + /// filtered output has been written. + /// + RESPONSE_FILTER_DONE, + + /// + /// An error occurred during filtering. + /// + RESPONSE_FILTER_ERROR +} cef_response_filter_status_t; + +/// +/// Describes how to interpret the components of a pixel. +/// +typedef enum { + /// + /// RGBA with 8 bits per pixel (32bits total). + /// + CEF_COLOR_TYPE_RGBA_8888, + + /// + /// BGRA with 8 bits per pixel (32bits total). + /// + CEF_COLOR_TYPE_BGRA_8888, +} cef_color_type_t; + +/// +/// Describes how to interpret the alpha component of a pixel. +/// +typedef enum { + /// + /// No transparency. The alpha component is ignored. + /// + CEF_ALPHA_TYPE_OPAQUE, + + /// + /// Transparency with pre-multiplied alpha component. + /// + CEF_ALPHA_TYPE_PREMULTIPLIED, + + /// + /// Transparency with post-multiplied alpha component. + /// + CEF_ALPHA_TYPE_POSTMULTIPLIED, +} cef_alpha_type_t; + +/// +/// Text style types. Should be kepy in sync with gfx::TextStyle. +/// +typedef enum { + CEF_TEXT_STYLE_BOLD, + CEF_TEXT_STYLE_ITALIC, + CEF_TEXT_STYLE_STRIKE, + CEF_TEXT_STYLE_DIAGONAL_STRIKE, + CEF_TEXT_STYLE_UNDERLINE, +} cef_text_style_t; + +/// +/// Specifies where along the main axis the CefBoxLayout child views should be +/// laid out. +/// +typedef enum { + /// + /// Child views will be left-aligned. + /// + CEF_MAIN_AXIS_ALIGNMENT_START, + + /// + /// Child views will be center-aligned. + /// + CEF_MAIN_AXIS_ALIGNMENT_CENTER, + + /// + /// Child views will be right-aligned. + /// + CEF_MAIN_AXIS_ALIGNMENT_END, +} cef_main_axis_alignment_t; + +/// +/// Specifies where along the cross axis the CefBoxLayout child views should be +/// laid out. +/// +typedef enum { + /// + /// Child views will be stretched to fit. + /// + CEF_CROSS_AXIS_ALIGNMENT_STRETCH, + + /// + /// Child views will be left-aligned. + /// + CEF_CROSS_AXIS_ALIGNMENT_START, + + /// + /// Child views will be center-aligned. + /// + CEF_CROSS_AXIS_ALIGNMENT_CENTER, + + /// + /// Child views will be right-aligned. + /// + CEF_CROSS_AXIS_ALIGNMENT_END, +} cef_cross_axis_alignment_t; + +/// +/// Settings used when initializing a CefBoxLayout. +/// +typedef struct _cef_box_layout_settings_t { + /// + /// If true (1) the layout will be horizontal, otherwise the layout will be + /// vertical. + /// + int horizontal; + + /// + /// Adds additional horizontal space between the child view area and the host + /// view border. + /// + int inside_border_horizontal_spacing; + + /// + /// Adds additional vertical space between the child view area and the host + /// view border. + /// + int inside_border_vertical_spacing; + + /// + /// Adds additional space around the child view area. + /// + cef_insets_t inside_border_insets; + + /// + /// Adds additional space between child views. + /// + int between_child_spacing; + + /// + /// Specifies where along the main axis the child views should be laid out. + /// + cef_main_axis_alignment_t main_axis_alignment; + + /// + /// Specifies where along the cross axis the child views should be laid out. + /// + cef_cross_axis_alignment_t cross_axis_alignment; + + /// + /// Minimum cross axis size. + /// + int minimum_cross_axis_size; + + /// + /// Default flex for views when none is specified via CefBoxLayout methods. + /// Using the preferred size as the basis, free space along the main axis is + /// distributed to views in the ratio of their flex weights. Similarly, if the + /// views will overflow the parent, space is subtracted in these ratios. A + /// flex of 0 means this view is not resized. Flex values must not be + /// negative. + /// + int default_flex; +} cef_box_layout_settings_t; + +/// +/// Specifies the button display state. +/// +typedef enum { + CEF_BUTTON_STATE_NORMAL, + CEF_BUTTON_STATE_HOVERED, + CEF_BUTTON_STATE_PRESSED, + CEF_BUTTON_STATE_DISABLED, +} cef_button_state_t; + +/// +/// Specifies the horizontal text alignment mode. +/// +typedef enum { + /// + /// Align the text's left edge with that of its display area. + /// + CEF_HORIZONTAL_ALIGNMENT_LEFT, + + /// + /// Align the text's center with that of its display area. + /// + CEF_HORIZONTAL_ALIGNMENT_CENTER, + + /// + /// Align the text's right edge with that of its display area. + /// + CEF_HORIZONTAL_ALIGNMENT_RIGHT, +} cef_horizontal_alignment_t; + +/// +/// Specifies how a menu will be anchored for non-RTL languages. The opposite +/// position will be used for RTL languages. +/// +typedef enum { + CEF_MENU_ANCHOR_TOPLEFT, + CEF_MENU_ANCHOR_TOPRIGHT, + CEF_MENU_ANCHOR_BOTTOMCENTER, +} cef_menu_anchor_position_t; + +/// +/// Supported color types for menu items. +/// +typedef enum { + CEF_MENU_COLOR_TEXT, + CEF_MENU_COLOR_TEXT_HOVERED, + CEF_MENU_COLOR_TEXT_ACCELERATOR, + CEF_MENU_COLOR_TEXT_ACCELERATOR_HOVERED, + CEF_MENU_COLOR_BACKGROUND, + CEF_MENU_COLOR_BACKGROUND_HOVERED, + CEF_MENU_COLOR_COUNT, +} cef_menu_color_type_t; + +/// Supported SSL version values. See net/ssl/ssl_connection_status_flags.h +/// for more information. +typedef enum { + SSL_CONNECTION_VERSION_UNKNOWN = 0, // Unknown SSL version. + SSL_CONNECTION_VERSION_SSL2 = 1, + SSL_CONNECTION_VERSION_SSL3 = 2, + SSL_CONNECTION_VERSION_TLS1 = 3, + SSL_CONNECTION_VERSION_TLS1_1 = 4, + SSL_CONNECTION_VERSION_TLS1_2 = 5, + SSL_CONNECTION_VERSION_TLS1_3 = 6, + SSL_CONNECTION_VERSION_QUIC = 7, +} cef_ssl_version_t; + +/// Supported SSL content status flags. See content/public/common/ssl_status.h +/// for more information. +typedef enum { + SSL_CONTENT_NORMAL_CONTENT = 0, + SSL_CONTENT_DISPLAYED_INSECURE_CONTENT = 1 << 0, + SSL_CONTENT_RAN_INSECURE_CONTENT = 1 << 1, +} cef_ssl_content_status_t; + +// +/// Configuration options for registering a custom scheme. +/// These values are used when calling AddCustomScheme. +// +typedef enum { + CEF_SCHEME_OPTION_NONE = 0, + + /// + /// If CEF_SCHEME_OPTION_STANDARD is set 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. + /// + CEF_SCHEME_OPTION_STANDARD = 1 << 0, + + /// + /// If CEF_SCHEME_OPTION_LOCAL is set the scheme will be treated 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). + /// + CEF_SCHEME_OPTION_LOCAL = 1 << 1, + + /// + /// If CEF_SCHEME_OPTION_DISPLAY_ISOLATED is set the scheme can only be + /// displayed from other content hosted with the same scheme. For example, + /// pages in other origins cannot create iframes or hyperlinks to URLs with + /// the scheme. For schemes that must be accessible from other schemes don't + /// set this, set CEF_SCHEME_OPTION_CORS_ENABLED, and use CORS + /// "Access-Control-Allow-Origin" headers to further restrict access. + /// + CEF_SCHEME_OPTION_DISPLAY_ISOLATED = 1 << 2, + + /// + /// If CEF_SCHEME_OPTION_SECURE is set the scheme will be treated with the + /// same security rules as those applied to "https" URLs. For example, loading + /// this scheme from other secure schemes will not trigger mixed content + /// warnings. + /// + CEF_SCHEME_OPTION_SECURE = 1 << 3, + + /// + /// If CEF_SCHEME_OPTION_CORS_ENABLED is set the scheme can be sent CORS + /// requests. This value should be set in most cases where + /// CEF_SCHEME_OPTION_STANDARD is set. + /// + CEF_SCHEME_OPTION_CORS_ENABLED = 1 << 4, + + /// + /// If CEF_SCHEME_OPTION_CSP_BYPASSING is set the scheme can bypass Content- + /// Security-Policy (CSP) checks. This value should not be set in most cases + /// where CEF_SCHEME_OPTION_STANDARD is set. + /// + CEF_SCHEME_OPTION_CSP_BYPASSING = 1 << 5, + + /// + /// If CEF_SCHEME_OPTION_FETCH_ENABLED is set the scheme can perform Fetch API + /// requests. + /// + CEF_SCHEME_OPTION_FETCH_ENABLED = 1 << 6, +} cef_scheme_options_t; + +/// +/// Structure representing a range. +/// +typedef struct _cef_range_t { + int from; + int to; +} cef_range_t; + +/// +/// Composition underline style. +/// +typedef enum { + CEF_CUS_SOLID, + CEF_CUS_DOT, + CEF_CUS_DASH, + CEF_CUS_NONE, +} cef_composition_underline_style_t; + +/// +/// Structure representing IME composition underline information. This is a thin +/// wrapper around Blink's WebCompositionUnderline class and should be kept in +/// sync with that. +/// +typedef struct _cef_composition_underline_t { + /// + /// Underline character range. + /// + cef_range_t range; + + /// + /// Text color. + /// + cef_color_t color; + + /// + /// Background color. + /// + cef_color_t background_color; + + /// + /// Set to true (1) for thick underline. + /// + int thick; + + /// + /// Style. + /// + cef_composition_underline_style_t style; +} cef_composition_underline_t; + +/// +/// Enumerates the various representations of the ordering of audio channels. +/// Must be kept synchronized with media::ChannelLayout from Chromium. +/// See media\base\channel_layout.h +/// +typedef enum { + CEF_CHANNEL_LAYOUT_NONE = 0, + CEF_CHANNEL_LAYOUT_UNSUPPORTED = 1, + + /// Front C + CEF_CHANNEL_LAYOUT_MONO = 2, + + /// Front L, Front R + CEF_CHANNEL_LAYOUT_STEREO = 3, + + /// Front L, Front R, Back C + CEF_CHANNEL_LAYOUT_2_1 = 4, + + /// Front L, Front R, Front C + CEF_CHANNEL_LAYOUT_SURROUND = 5, + + /// Front L, Front R, Front C, Back C + CEF_CHANNEL_LAYOUT_4_0 = 6, + + /// Front L, Front R, Side L, Side R + CEF_CHANNEL_LAYOUT_2_2 = 7, + + /// Front L, Front R, Back L, Back R + CEF_CHANNEL_LAYOUT_QUAD = 8, + + /// Front L, Front R, Front C, Side L, Side R + CEF_CHANNEL_LAYOUT_5_0 = 9, + + /// Front L, Front R, Front C, LFE, Side L, Side R + CEF_CHANNEL_LAYOUT_5_1 = 10, + + /// Front L, Front R, Front C, Back L, Back R + CEF_CHANNEL_LAYOUT_5_0_BACK = 11, + + /// Front L, Front R, Front C, LFE, Back L, Back R + CEF_CHANNEL_LAYOUT_5_1_BACK = 12, + + /// Front L, Front R, Front C, Side L, Side R, Back L, Back R + CEF_CHANNEL_LAYOUT_7_0 = 13, + + /// Front L, Front R, Front C, LFE, Side L, Side R, Back L, Back R + CEF_CHANNEL_LAYOUT_7_1 = 14, + + /// Front L, Front R, Front C, LFE, Side L, Side R, Front LofC, Front RofC + CEF_CHANNEL_LAYOUT_7_1_WIDE = 15, + + /// Stereo L, Stereo R + CEF_CHANNEL_LAYOUT_STEREO_DOWNMIX = 16, + + /// Stereo L, Stereo R, LFE + CEF_CHANNEL_LAYOUT_2POINT1 = 17, + + /// Stereo L, Stereo R, Front C, LFE + CEF_CHANNEL_LAYOUT_3_1 = 18, + + /// Stereo L, Stereo R, Front C, Rear C, LFE + CEF_CHANNEL_LAYOUT_4_1 = 19, + + /// Stereo L, Stereo R, Front C, Side L, Side R, Back C + CEF_CHANNEL_LAYOUT_6_0 = 20, + + /// Stereo L, Stereo R, Side L, Side R, Front LofC, Front RofC + CEF_CHANNEL_LAYOUT_6_0_FRONT = 21, + + /// Stereo L, Stereo R, Front C, Rear L, Rear R, Rear C + CEF_CHANNEL_LAYOUT_HEXAGONAL = 22, + + /// Stereo L, Stereo R, Front C, LFE, Side L, Side R, Rear Center + CEF_CHANNEL_LAYOUT_6_1 = 23, + + /// Stereo L, Stereo R, Front C, LFE, Back L, Back R, Rear Center + CEF_CHANNEL_LAYOUT_6_1_BACK = 24, + + /// Stereo L, Stereo R, Side L, Side R, Front LofC, Front RofC, LFE + CEF_CHANNEL_LAYOUT_6_1_FRONT = 25, + + /// Front L, Front R, Front C, Side L, Side R, Front LofC, Front RofC + CEF_CHANNEL_LAYOUT_7_0_FRONT = 26, + + /// Front L, Front R, Front C, LFE, Back L, Back R, Front LofC, Front RofC + CEF_CHANNEL_LAYOUT_7_1_WIDE_BACK = 27, + + /// Front L, Front R, Front C, Side L, Side R, Rear L, Back R, Back C. + CEF_CHANNEL_LAYOUT_OCTAGONAL = 28, + + /// Channels are not explicitly mapped to speakers. + CEF_CHANNEL_LAYOUT_DISCRETE = 29, + + /// Front L, Front R, Front C. Front C contains the keyboard mic audio. This + /// layout is only intended for input for WebRTC. The Front C channel + /// is stripped away in the WebRTC audio input pipeline and never seen outside + /// of that. + CEF_CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC = 30, + + /// Front L, Front R, Side L, Side R, LFE + CEF_CHANNEL_LAYOUT_4_1_QUAD_SIDE = 31, + + /// Actual channel layout is specified in the bitstream and the actual channel + /// count is unknown at Chromium media pipeline level (useful for audio + /// pass-through mode). + CEF_CHANNEL_LAYOUT_BITSTREAM = 32, + + /// Front L, Front R, Front C, LFE, Side L, Side R, + /// Front Height L, Front Height R, Rear Height L, Rear Height R + /// Will be represented as six channels (5.1) due to eight channel limit + /// kMaxConcurrentChannels + CEF_CHANNEL_LAYOUT_5_1_4_DOWNMIX = 33, + + /// Max value, must always equal the largest entry ever logged. + CEF_CHANNEL_LAYOUT_MAX = CEF_CHANNEL_LAYOUT_5_1_4_DOWNMIX +} cef_channel_layout_t; + +/// +/// Structure representing the audio parameters for setting up the audio +/// handler. +/// +typedef struct _cef_audio_parameters_t { + /// + /// Layout of the audio channels + /// + cef_channel_layout_t channel_layout; + + /// + /// Sample rate + // + int sample_rate; + + /// + /// Number of frames per buffer + /// + int frames_per_buffer; +} cef_audio_parameters_t; + +/// +/// Result codes for CefMediaRouter::CreateRoute. Should be kept in sync with +/// Chromium's media_router::mojom::RouteRequestResultCode type. +/// +typedef enum { + CEF_MRCR_UNKNOWN_ERROR = 0, + CEF_MRCR_OK = 1, + CEF_MRCR_TIMED_OUT = 2, + CEF_MRCR_ROUTE_NOT_FOUND = 3, + CEF_MRCR_SINK_NOT_FOUND = 4, + CEF_MRCR_INVALID_ORIGIN = 5, + CEF_MRCR_NO_SUPPORTED_PROVIDER = 7, + CEF_MRCR_CANCELLED = 8, + CEF_MRCR_ROUTE_ALREADY_EXISTS = 9, + CEF_MRCR_ROUTE_ALREADY_TERMINATED = 11, +} cef_media_route_create_result_t; + +/// +/// Connection state for a MediaRoute object. +/// +typedef enum { + CEF_MRCS_UNKNOWN, + CEF_MRCS_CONNECTING, + CEF_MRCS_CONNECTED, + CEF_MRCS_CLOSED, + CEF_MRCS_TERMINATED, +} cef_media_route_connection_state_t; + +/// +/// Icon types for a MediaSink object. Should be kept in sync with Chromium's +/// media_router::SinkIconType type. +/// +typedef enum { + CEF_MSIT_CAST, + CEF_MSIT_CAST_AUDIO_GROUP, + CEF_MSIT_CAST_AUDIO, + CEF_MSIT_MEETING, + CEF_MSIT_HANGOUT, + CEF_MSIT_EDUCATION, + CEF_MSIT_WIRED_DISPLAY, + CEF_MSIT_GENERIC, + + CEF_MSIT_TOTAL_COUNT, // The total number of values. +} cef_media_sink_icon_type_t; + +/// +/// Device information for a MediaSink object. +/// +typedef struct _cef_media_sink_device_info_t { + cef_string_t ip_address; + int port; + cef_string_t model_name; +} cef_media_sink_device_info_t; + +/// +/// Represents commands available to TextField. +/// +typedef enum { + CEF_TFC_CUT = 1, + CEF_TFC_COPY, + CEF_TFC_PASTE, + CEF_TFC_UNDO, + CEF_TFC_DELETE, + CEF_TFC_SELECT_ALL, +} cef_text_field_commands_t; + +/// +/// Supported Chrome toolbar types. +/// +typedef enum { + CEF_CTT_NONE = 1, + CEF_CTT_NORMAL, + CEF_CTT_LOCATION, +} cef_chrome_toolbar_type_t; + +/// +/// Docking modes supported by CefWindow::AddOverlay. +/// +typedef enum { + CEF_DOCKING_MODE_TOP_LEFT = 1, + CEF_DOCKING_MODE_TOP_RIGHT, + CEF_DOCKING_MODE_BOTTOM_LEFT, + CEF_DOCKING_MODE_BOTTOM_RIGHT, + CEF_DOCKING_MODE_CUSTOM, +} cef_docking_mode_t; + +/// +/// Show states supported by CefWindowDelegate::GetInitialShowState. +/// +typedef enum { + CEF_SHOW_STATE_NORMAL = 1, + CEF_SHOW_STATE_MINIMIZED, + CEF_SHOW_STATE_MAXIMIZED, + CEF_SHOW_STATE_FULLSCREEN, +} cef_show_state_t; + +/// +/// Values indicating what state of the touch handle is set. +/// +typedef enum { + CEF_THS_FLAG_NONE = 0, + CEF_THS_FLAG_ENABLED = 1 << 0, + CEF_THS_FLAG_ORIENTATION = 1 << 1, + CEF_THS_FLAG_ORIGIN = 1 << 2, + CEF_THS_FLAG_ALPHA = 1 << 3, +} cef_touch_handle_state_flags_t; + +typedef struct _cef_touch_handle_state_t { + /// + /// Touch handle id. Increments for each new touch handle. + /// + int touch_handle_id; + + /// + /// Combination of cef_touch_handle_state_flags_t values indicating what state + /// is set. + /// + uint32 flags; + + /// + /// Enabled state. Only set if |flags| contains CEF_THS_FLAG_ENABLED. + /// + int enabled; + + /// + /// Orientation state. Only set if |flags| contains CEF_THS_FLAG_ORIENTATION. + /// + cef_horizontal_alignment_t orientation; + int mirror_vertical; + int mirror_horizontal; + + /// + /// Origin state. Only set if |flags| contains CEF_THS_FLAG_ORIGIN. + /// + cef_point_t origin; + + /// + /// Alpha state. Only set if |flags| contains CEF_THS_FLAG_ALPHA. + /// + float alpha; +} cef_touch_handle_state_t; + +/// +/// Media access permissions used by OnRequestMediaAccessPermission. +/// +typedef enum { + /// + /// No permission. + /// + CEF_MEDIA_PERMISSION_NONE = 0, + + /// + /// Device audio capture permission. + /// + CEF_MEDIA_PERMISSION_DEVICE_AUDIO_CAPTURE = 1 << 0, + + /// + /// Device video capture permission. + /// + CEF_MEDIA_PERMISSION_DEVICE_VIDEO_CAPTURE = 1 << 1, + + /// + /// Desktop audio capture permission. + /// + CEF_MEDIA_PERMISSION_DESKTOP_AUDIO_CAPTURE = 1 << 2, + + /// + /// Desktop video capture permission. + /// + CEF_MEDIA_PERMISSION_DESKTOP_VIDEO_CAPTURE = 1 << 3, +} cef_media_access_permission_types_t; + +/// +/// Permission types used with OnShowPermissionPrompt. Some types are +/// platform-specific or only supported with the Chrome runtime. Should be kept +/// in sync with Chromium's permissions::RequestType type. +/// +typedef enum { + CEF_PERMISSION_TYPE_NONE = 0, + CEF_PERMISSION_TYPE_ACCESSIBILITY_EVENTS = 1 << 0, + CEF_PERMISSION_TYPE_AR_SESSION = 1 << 1, + CEF_PERMISSION_TYPE_CAMERA_PAN_TILT_ZOOM = 1 << 2, + CEF_PERMISSION_TYPE_CAMERA_STREAM = 1 << 3, + CEF_PERMISSION_TYPE_CLIPBOARD = 1 << 4, + CEF_PERMISSION_TYPE_TOP_LEVEL_STORAGE_ACCESS = 1 << 5, + CEF_PERMISSION_TYPE_DISK_QUOTA = 1 << 6, + CEF_PERMISSION_TYPE_LOCAL_FONTS = 1 << 7, + CEF_PERMISSION_TYPE_GEOLOCATION = 1 << 8, + CEF_PERMISSION_TYPE_IDLE_DETECTION = 1 << 9, + CEF_PERMISSION_TYPE_MIC_STREAM = 1 << 10, + CEF_PERMISSION_TYPE_MIDI_SYSEX = 1 << 11, + CEF_PERMISSION_TYPE_MULTIPLE_DOWNLOADS = 1 << 12, + CEF_PERMISSION_TYPE_NOTIFICATIONS = 1 << 13, + CEF_PERMISSION_TYPE_PROTECTED_MEDIA_IDENTIFIER = 1 << 14, + CEF_PERMISSION_TYPE_REGISTER_PROTOCOL_HANDLER = 1 << 15, + CEF_PERMISSION_TYPE_SECURITY_ATTESTATION = 1 << 16, + CEF_PERMISSION_TYPE_STORAGE_ACCESS = 1 << 17, + CEF_PERMISSION_TYPE_U2F_API_REQUEST = 1 << 18, + CEF_PERMISSION_TYPE_VR_SESSION = 1 << 19, + CEF_PERMISSION_TYPE_WINDOW_MANAGEMENT = 1 << 20, +} cef_permission_request_types_t; + +/// +/// Permission request results. +/// +typedef enum { + /// + /// Accept the permission request as an explicit user action. + /// + CEF_PERMISSION_RESULT_ACCEPT, + + /// + /// Deny the permission request as an explicit user action. + /// + CEF_PERMISSION_RESULT_DENY, + + /// + /// Dismiss the permission request as an explicit user action. + /// + CEF_PERMISSION_RESULT_DISMISS, + + /// + /// Ignore the permission request. If the prompt remains unhandled (e.g. + /// OnShowPermissionPrompt returns false and there is no default permissions + /// UI) then any related promises may remain unresolved. + /// + CEF_PERMISSION_RESULT_IGNORE, +} cef_permission_request_result_t; + +/// +/// Certificate types supported by CefTestServer::CreateAndStart. The matching +/// certificate file must exist in the "net/data/ssl/certificates" directory. +/// See CefSetDataDirectoryForTests() for related configuration. +/// +typedef enum { + /// Valid certificate using the IP (127.0.0.1). Loads the "ok_cert.pem" file. + CEF_TEST_CERT_OK_IP, + + /// Valid certificate using the domain ("localhost"). Loads the + /// "localhost_cert.pem" file. + CEF_TEST_CERT_OK_DOMAIN, + + /// Expired certificate. Loads the "expired_cert.pem" file. + CEF_TEST_CERT_EXPIRED, +} cef_test_cert_type_t; + +/// +/// Preferences type passed to +/// CefBrowserProcessHandler::OnRegisterCustomPreferences. +/// +typedef enum { + /// Global preferences registered a single time at application startup. + CEF_PREFERENCES_TYPE_GLOBAL, + + /// Request context preferences registered each time a new CefRequestContext + /// is created. + CEF_PREFERENCES_TYPE_REQUEST_CONTEXT, +} cef_preferences_type_t; + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_H_ diff --git a/include/internal/cef_types_geometry.h b/include/internal/cef_types_geometry.h new file mode 100644 index 00000000..7410f15d --- /dev/null +++ b/include/internal/cef_types_geometry.h @@ -0,0 +1,78 @@ +// Copyright (c) 2014 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. + +#ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_GEOMETRY_H_ +#define CEF_INCLUDE_INTERNAL_CEF_TYPES_GEOMETRY_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/// +/// Structure representing a point. +/// +typedef struct _cef_point_t { + int x; + int y; +} cef_point_t; + +/// +/// Structure representing a rectangle. +/// +typedef struct _cef_rect_t { + int x; + int y; + int width; + int height; +} cef_rect_t; + +/// +/// Structure representing a size. +/// +typedef struct _cef_size_t { + int width; + int height; +} cef_size_t; + +/// +/// Structure representing insets. +/// +typedef struct _cef_insets_t { + int top; + int left; + int bottom; + int right; +} cef_insets_t; + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_GEOMETRY_H_ diff --git a/include/internal/cef_types_linux.h b/include/internal/cef_types_linux.h new file mode 100644 index 00000000..171cda32 --- /dev/null +++ b/include/internal/cef_types_linux.h @@ -0,0 +1,146 @@ +// Copyright (c) 2014 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. + +#ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_LINUX_H_ +#define CEF_INCLUDE_INTERNAL_CEF_TYPES_LINUX_H_ +#pragma once + +#include "include/base/cef_build.h" +#include "include/cef_config.h" + +#if defined(OS_LINUX) + +#if defined(CEF_X11) +typedef union _XEvent XEvent; +typedef struct _XDisplay XDisplay; +#endif + +#include "include/internal/cef_export.h" +#include "include/internal/cef_string.h" +#include "include/internal/cef_types_geometry.h" + +// Handle types. +#if defined(CEF_X11) +#define cef_cursor_handle_t unsigned long +#define cef_event_handle_t XEvent* +#else +#define cef_cursor_handle_t void* +#define cef_event_handle_t void* +#endif + +#define cef_window_handle_t unsigned long + +#define kNullCursorHandle 0 +#define kNullEventHandle NULL +#define kNullWindowHandle 0 + +#ifdef __cplusplus +extern "C" { +#endif + +/// +/// Return the singleton X11 display shared with Chromium. The display is not +/// thread-safe and must only be accessed on the browser process UI thread. +/// +#if defined(CEF_X11) +CEF_EXPORT XDisplay* cef_get_xdisplay(void); +#endif + +/// +/// Structure representing CefExecuteProcess arguments. +/// +typedef struct _cef_main_args_t { + int argc; + char** argv; +} cef_main_args_t; + +/// +/// Class representing window information. +/// +typedef struct _cef_window_info_t { + /// + /// The initial title of the window, to be set when the window is created. + /// Some layout managers (e.g., Compiz) can look at the window title + /// in order to decide where to place the window when it is + /// created. When this attribute is not empty, the window title will + /// be set before the window is mapped to the dispay. Otherwise the + /// title will be initially empty. + /// + cef_string_t window_name; + + /// + /// Initial window bounds. + /// + cef_rect_t bounds; + + /// + /// Pointer for the parent window. + /// + cef_window_handle_t parent_window; + + /// + /// Set to true (1) to create the browser using windowless (off-screen) + /// rendering. No window will be created for the browser and all rendering + /// will occur via the CefRenderHandler interface. The |parent_window| value + /// will be used to identify monitor info and to act as the parent window for + /// dialogs, context menus, etc. If |parent_window| is not provided then the + /// main screen monitor will be used and some functionality that requires a + /// parent window may not function correctly. In order to create windowless + /// browsers the CefSettings.windowless_rendering_enabled value must be set to + /// true. Transparent painting is enabled by default but can be disabled by + /// setting CefBrowserSettings.background_color to an opaque value. + /// + int windowless_rendering_enabled; + + /// + /// Set to true (1) to enable shared textures for windowless rendering. Only + /// valid if windowless_rendering_enabled above is also set to true. Currently + /// only supported on Windows (D3D11). + /// + int shared_texture_enabled; + + /// + /// Set to true (1) to enable the ability to issue BeginFrame requests from + /// the client application by calling CefBrowserHost::SendExternalBeginFrame. + /// + int external_begin_frame_enabled; + + /// + /// Pointer for the new browser window. Only used with windowed rendering. + /// + cef_window_handle_t window; +} cef_window_info_t; + +#ifdef __cplusplus +} +#endif + +#endif // OS_LINUX + +#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_LINUX_H_ diff --git a/include/internal/cef_types_mac.h b/include/internal/cef_types_mac.h new file mode 100644 index 00000000..8ee619e6 --- /dev/null +++ b/include/internal/cef_types_mac.h @@ -0,0 +1,145 @@ +// Copyright (c) 2014 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. + +#ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_MAC_H_ +#define CEF_INCLUDE_INTERNAL_CEF_TYPES_MAC_H_ +#pragma once + +#include "include/base/cef_build.h" + +#if defined(OS_MAC) +#include "include/internal/cef_string.h" +#include "include/internal/cef_types_geometry.h" + +// Handle types. +// Actually NSCursor* +#define cef_cursor_handle_t void* +// Acutally NSEvent* +#define cef_event_handle_t void* +// Actually NSView* +#define cef_window_handle_t void* + +#define kNullCursorHandle NULL +#define kNullEventHandle NULL +#define kNullWindowHandle NULL + +#ifdef __OBJC__ +#if __has_feature(objc_arc) +#define CAST_CEF_CURSOR_HANDLE_TO_NSCURSOR(handle) ((__bridge NSCursor*)handle) +#define CAST_CEF_EVENT_HANDLE_TO_NSEVENT(handle) ((__bridge NSEvent*)handle) +#define CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(handle) ((__bridge NSView*)handle) + +#define CAST_NSCURSOR_TO_CEF_CURSOR_HANDLE(cursor) ((__bridge void*)cursor) +#define CAST_NSEVENT_TO_CEF_EVENT_HANDLE(event) ((__bridge void*)event) +#define CAST_NSVIEW_TO_CEF_WINDOW_HANDLE(view) ((__bridge void*)view) +#else // __has_feature(objc_arc) +#define CAST_CEF_CURSOR_HANDLE_TO_NSCURSOR(handle) ((NSCursor*)handle) +#define CAST_CEF_EVENT_HANDLE_TO_NSEVENT(handle) ((NSEvent*)handle) +#define CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(handle) ((NSView*)handle) + +#define CAST_NSCURSOR_TO_CEF_CURSOR_HANDLE(cursor) ((void*)cursor) +#define CAST_NSEVENT_TO_CEF_EVENT_HANDLE(event) ((void*)event) +#define CAST_NSVIEW_TO_CEF_WINDOW_HANDLE(view) ((void*)view) +#endif // __has_feature(objc_arc) +#endif // __OBJC__ + +#ifdef __cplusplus +extern "C" { +#endif + +/// +/// Structure representing CefExecuteProcess arguments. +/// +typedef struct _cef_main_args_t { + int argc; + char** argv; +} cef_main_args_t; + +/// +/// Class representing window information. +/// +typedef struct _cef_window_info_t { + cef_string_t window_name; + + /// + /// Initial window bounds. + /// + cef_rect_t bounds; + + /// + /// Set to true (1) to create the view initially hidden. + /// + int hidden; + + /// + /// NSView pointer for the parent view. + /// + cef_window_handle_t parent_view; + + /// + /// Set to true (1) to create the browser using windowless (off-screen) + /// rendering. No view will be created for the browser and all rendering will + /// occur via the CefRenderHandler interface. The |parent_view| value will be + /// used to identify monitor info and to act as the parent view for dialogs, + /// context menus, etc. If |parent_view| is not provided then the main screen + /// monitor will be used and some functionality that requires a parent view + /// may not function correctly. In order to create windowless browsers the + /// CefSettings.windowless_rendering_enabled value must be set to true. + /// Transparent painting is enabled by default but can be disabled by setting + /// CefBrowserSettings.background_color to an opaque value. + /// + int windowless_rendering_enabled; + + /// + /// Set to true (1) to enable shared textures for windowless rendering. Only + /// valid if windowless_rendering_enabled above is also set to true. Currently + /// only supported on Windows (D3D11). + /// + int shared_texture_enabled; + + /// + /// Set to true (1) to enable the ability to issue BeginFrame from the client + /// application. + /// + int external_begin_frame_enabled; + + /// + /// NSView pointer for the new browser view. Only used with windowed + /// rendering. + /// + cef_window_handle_t view; +} cef_window_info_t; + +#ifdef __cplusplus +} +#endif + +#endif // OS_MAC + +#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_MAC_H_ diff --git a/include/internal/cef_types_win.h b/include/internal/cef_types_win.h new file mode 100644 index 00000000..abf80c7d --- /dev/null +++ b/include/internal/cef_types_win.h @@ -0,0 +1,113 @@ +// Copyright (c) 2009 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. + +#ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_WIN_H_ +#define CEF_INCLUDE_INTERNAL_CEF_TYPES_WIN_H_ +#pragma once + +#include "include/base/cef_build.h" + +#if defined(OS_WIN) +#include <windows.h> + +#include "include/internal/cef_string.h" +#include "include/internal/cef_types_geometry.h" + +// Handle types. +#define cef_cursor_handle_t HCURSOR +#define cef_event_handle_t MSG* +#define cef_window_handle_t HWND + +#define kNullCursorHandle NULL +#define kNullEventHandle NULL +#define kNullWindowHandle NULL + +#ifdef __cplusplus +extern "C" { +#endif + +/// +/// Structure representing CefExecuteProcess arguments. +/// +typedef struct _cef_main_args_t { + HINSTANCE instance; +} cef_main_args_t; + +/// +/// Structure representing window information. +/// +typedef struct _cef_window_info_t { + // Standard parameters required by CreateWindowEx() + DWORD ex_style; + cef_string_t window_name; + DWORD style; + cef_rect_t bounds; + cef_window_handle_t parent_window; + HMENU menu; + + /// + /// Set to true (1) to create the browser using windowless (off-screen) + /// rendering. No window will be created for the browser and all rendering + /// will occur via the CefRenderHandler interface. The |parent_window| value + /// will be used to identify monitor info and to act as the parent window for + /// dialogs, context menus, etc. If |parent_window| is not provided then the + /// main screen monitor will be used and some functionality that requires a + /// parent window may not function correctly. In order to create windowless + /// browsers the CefSettings.windowless_rendering_enabled value must be set to + /// true. Transparent painting is enabled by default but can be disabled by + /// setting CefBrowserSettings.background_color to an opaque value. + /// + int windowless_rendering_enabled; + + /// + /// Set to true (1) to enable shared textures for windowless rendering. Only + /// valid if windowless_rendering_enabled above is also set to true. Currently + /// only supported on Windows (D3D11). + /// + int shared_texture_enabled; + + /// + /// Set to true (1) to enable the ability to issue BeginFrame requests from + /// the client application by calling CefBrowserHost::SendExternalBeginFrame. + /// + int external_begin_frame_enabled; + + /// + /// Handle for the new browser window. Only used with windowed rendering. + /// + cef_window_handle_t window; +} cef_window_info_t; + +#ifdef __cplusplus +} +#endif + +#endif // OS_WIN + +#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_WIN_H_ diff --git a/include/internal/cef_types_wrappers.h b/include/internal/cef_types_wrappers.h new file mode 100644 index 00000000..c1153275 --- /dev/null +++ b/include/internal/cef_types_wrappers.h @@ -0,0 +1,742 @@ +// Copyright (c) 2013 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. + +#ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_ +#define CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_ +#pragma once + +#include "include/internal/cef_string.h" +#include "include/internal/cef_string_list.h" +#include "include/internal/cef_types.h" + +/// +/// Template class that provides common functionality for CEF structure +/// wrapping. Use only with non-POD types that benefit from referencing unowned +/// members. +/// +template <class traits> +class CefStructBase : public traits::struct_type { + public: + using struct_type = typename traits::struct_type; + + CefStructBase() : attached_to_(NULL) { Init(); } + virtual ~CefStructBase() { + // Only clear this object's data if it isn't currently attached to a + // structure. + if (!attached_to_) { + Clear(this); + } + } + + CefStructBase(const CefStructBase& r) { + Init(); + *this = r; + } + CefStructBase(const struct_type& r) { + Init(); + *this = r; + } + + /// + /// Attach to the source structure's existing values. DetachTo() can be called + /// to insert the values back into the existing structure. + /// + void AttachTo(struct_type& source) { + // Only clear this object's data if it isn't currently attached to a + // structure. + if (!attached_to_) { + Clear(this); + } + + // This object is now attached to the new structure. + attached_to_ = &source; + + // Transfer ownership of the values from the source structure. + memcpy(static_cast<struct_type*>(this), &source, sizeof(struct_type)); + } + + /// + /// Relinquish ownership of values to the target structure. + /// + void DetachTo(struct_type& target) { + if (attached_to_ != &target) { + // Clear the target structure's values only if we are not currently + // attached to that structure. + Clear(&target); + } + + // Transfer ownership of the values to the target structure. + memcpy(&target, static_cast<struct_type*>(this), sizeof(struct_type)); + + // Remove the references from this object. + Init(); + } + + /// + /// Set this object's values. If |copy| is true the source structure's values + /// will be copied instead of referenced. + /// + void Set(const struct_type& source, bool copy) { + traits::set(&source, this, copy); + } + + CefStructBase& operator=(const CefStructBase& s) { + return operator=(static_cast<const struct_type&>(s)); + } + + CefStructBase& operator=(const struct_type& s) { + Set(s, true); + return *this; + } + + protected: + void Init() { + memset(static_cast<struct_type*>(this), 0, sizeof(struct_type)); + attached_to_ = NULL; + traits::init(this); + } + + static void Clear(struct_type* s) { traits::clear(s); } + + struct_type* attached_to_; +}; + +/// +/// Class representing a point. +/// +class CefPoint : public cef_point_t { + public: + CefPoint() : cef_point_t{} {} + CefPoint(const cef_point_t& r) : cef_point_t(r) {} + CefPoint(int x, int y) : cef_point_t{x, y} {} + + bool IsEmpty() const { return x <= 0 && y <= 0; } + void Set(int x_val, int y_val) { x = x_val, y = y_val; } +}; + +inline bool operator==(const CefPoint& a, const CefPoint& b) { + return a.x == b.x && a.y == b.y; +} + +inline bool operator!=(const CefPoint& a, const CefPoint& b) { + return !(a == b); +} + +/// +/// Class representing a rectangle. +/// +class CefRect : public cef_rect_t { + public: + CefRect() : cef_rect_t{} {} + CefRect(const cef_rect_t& r) : cef_rect_t(r) {} + CefRect(int x, int y, int width, int height) + : cef_rect_t{x, y, width, height} {} + + bool IsEmpty() const { return width <= 0 || height <= 0; } + void Set(int x_val, int y_val, int width_val, int height_val) { + x = x_val, y = y_val, width = width_val, height = height_val; + } + + /// + /// Returns true if the point identified by point_x and point_y falls inside + /// this rectangle. The point (x, y) is inside the rectangle, but the + /// point (x + width, y + height) is not. + /// + bool Contains(int point_x, int point_y) const { + return (point_x >= x) && (point_x < x + width) && (point_y >= y) && + (point_y < y + height); + } + bool Contains(const CefPoint& point) const { + return Contains(point.x, point.y); + } +}; + +inline bool operator==(const CefRect& a, const CefRect& b) { + return a.x == b.x && a.y == b.y && a.width == b.width && a.height == b.height; +} + +inline bool operator!=(const CefRect& a, const CefRect& b) { + return !(a == b); +} + +/// +/// Class representing a size. +/// +class CefSize : public cef_size_t { + public: + CefSize() : cef_size_t{} {} + CefSize(const cef_size_t& r) : cef_size_t(r) {} + CefSize(int width, int height) : cef_size_t{width, height} {} + + bool IsEmpty() const { return width <= 0 || height <= 0; } + void Set(int width_val, int height_val) { + width = width_val, height = height_val; + } +}; + +inline bool operator==(const CefSize& a, const CefSize& b) { + return a.width == b.width && a.height == b.height; +} + +inline bool operator!=(const CefSize& a, const CefSize& b) { + return !(a == b); +} + +/// +/// Class representing a range. +/// +class CefRange : public cef_range_t { + public: + CefRange() : cef_range_t{} {} + CefRange(const cef_range_t& r) : cef_range_t(r) {} + CefRange(int from, int to) : cef_range_t{from, to} {} + + void Set(int from_val, int to_val) { from = from_val, to = to_val; } +}; + +inline bool operator==(const CefRange& a, const CefRange& b) { + return a.from == b.from && a.to == b.to; +} + +inline bool operator!=(const CefRange& a, const CefRange& b) { + return !(a == b); +} + +/// +/// Class representing insets. +/// +class CefInsets : public cef_insets_t { + public: + CefInsets() : cef_insets_t{} {} + CefInsets(const cef_insets_t& r) : cef_insets_t(r) {} + CefInsets(int top, int left, int bottom, int right) + : cef_insets_t{top, left, bottom, right} {} + + void Set(int top_val, int left_val, int bottom_val, int right_val) { + top = top_val, left = left_val, bottom = bottom_val, right = right_val; + } +}; + +inline bool operator==(const CefInsets& a, const CefInsets& b) { + return a.top == b.top && a.left == b.left && a.bottom == b.bottom && + a.right == b.right; +} + +inline bool operator!=(const CefInsets& a, const CefInsets& b) { + return !(a == b); +} + +/// +/// Class representing a draggable region. +/// +class CefDraggableRegion : public cef_draggable_region_t { + public: + CefDraggableRegion() : cef_draggable_region_t{} {} + CefDraggableRegion(const cef_draggable_region_t& r) + : cef_draggable_region_t(r) {} + CefDraggableRegion(const cef_rect_t& bounds, bool draggable) + : cef_draggable_region_t{bounds, draggable} {} + + void Set(const CefRect& bounds_val, bool draggable_val) { + bounds = bounds_val, draggable = draggable_val; + } +}; + +inline bool operator==(const CefDraggableRegion& a, + const CefDraggableRegion& b) { + return a.bounds == b.bounds && a.draggable == b.draggable; +} + +inline bool operator!=(const CefDraggableRegion& a, + const CefDraggableRegion& b) { + return !(a == b); +} + +/// +/// Class representing the virtual screen information for use when window +/// rendering is disabled. +/// +class CefScreenInfo : public cef_screen_info_t { + public: + CefScreenInfo() : cef_screen_info_t{} {} + CefScreenInfo(const cef_screen_info_t& r) : cef_screen_info_t(r) {} + CefScreenInfo(float device_scale_factor, + int depth, + int depth_per_component, + bool is_monochrome, + const cef_rect_t& rect, + const cef_rect_t& available_rect) + : cef_screen_info_t{device_scale_factor, depth, depth_per_component, + is_monochrome, rect, available_rect} {} + + void Set(float device_scale_factor_val, + int depth_val, + int depth_per_component_val, + bool is_monochrome_val, + const CefRect& rect_val, + const CefRect& available_rect_val) { + device_scale_factor = device_scale_factor_val; + depth = depth_val; + depth_per_component = depth_per_component_val; + is_monochrome = is_monochrome_val; + rect = rect_val; + available_rect = available_rect_val; + } +}; + +/// +/// Class representing a a keyboard event. +/// +class CefKeyEvent : public cef_key_event_t { + public: + CefKeyEvent() : cef_key_event_t{} {} + CefKeyEvent(const cef_key_event_t& r) : cef_key_event_t(r) {} +}; + +/// +/// Class representing a mouse event. +/// +class CefMouseEvent : public cef_mouse_event_t { + public: + CefMouseEvent() : cef_mouse_event_t{} {} + CefMouseEvent(const cef_mouse_event_t& r) : cef_mouse_event_t(r) {} +}; + +/// +/// Class representing a touch event. +/// +class CefTouchEvent : public cef_touch_event_t { + public: + CefTouchEvent() : cef_touch_event_t{} {} + CefTouchEvent(const cef_touch_event_t& r) : cef_touch_event_t(r) {} +}; + +/// +/// Class representing popup window features. +/// +class CefPopupFeatures : public cef_popup_features_t { + public: + CefPopupFeatures() : cef_popup_features_t{} {} + CefPopupFeatures(const cef_popup_features_t& r) : cef_popup_features_t(r) {} +}; + +struct CefSettingsTraits { + using struct_type = cef_settings_t; + + static inline void init(struct_type* s) { s->size = sizeof(struct_type); } + + static inline void clear(struct_type* s) { + cef_string_clear(&s->browser_subprocess_path); + cef_string_clear(&s->framework_dir_path); + cef_string_clear(&s->main_bundle_path); + cef_string_clear(&s->cache_path); + cef_string_clear(&s->root_cache_path); + cef_string_clear(&s->user_data_path); + cef_string_clear(&s->user_agent); + cef_string_clear(&s->user_agent_product); + cef_string_clear(&s->locale); + cef_string_clear(&s->log_file); + cef_string_clear(&s->javascript_flags); + cef_string_clear(&s->resources_dir_path); + cef_string_clear(&s->locales_dir_path); + cef_string_clear(&s->accept_language_list); + cef_string_clear(&s->cookieable_schemes_list); + } + + static inline void set(const struct_type* src, + struct_type* target, + bool copy) { + target->no_sandbox = src->no_sandbox; + cef_string_set(src->browser_subprocess_path.str, + src->browser_subprocess_path.length, + &target->browser_subprocess_path, copy); + cef_string_set(src->framework_dir_path.str, src->framework_dir_path.length, + &target->framework_dir_path, copy); + cef_string_set(src->main_bundle_path.str, src->main_bundle_path.length, + &target->main_bundle_path, copy); + target->chrome_runtime = src->chrome_runtime; + target->multi_threaded_message_loop = src->multi_threaded_message_loop; + target->external_message_pump = src->external_message_pump; + target->windowless_rendering_enabled = src->windowless_rendering_enabled; + target->command_line_args_disabled = src->command_line_args_disabled; + + cef_string_set(src->cache_path.str, src->cache_path.length, + &target->cache_path, copy); + cef_string_set(src->root_cache_path.str, src->root_cache_path.length, + &target->root_cache_path, copy); + cef_string_set(src->user_data_path.str, src->user_data_path.length, + &target->user_data_path, copy); + target->persist_session_cookies = src->persist_session_cookies; + target->persist_user_preferences = src->persist_user_preferences; + + cef_string_set(src->user_agent.str, src->user_agent.length, + &target->user_agent, copy); + cef_string_set(src->user_agent_product.str, src->user_agent_product.length, + &target->user_agent_product, copy); + cef_string_set(src->locale.str, src->locale.length, &target->locale, copy); + + cef_string_set(src->log_file.str, src->log_file.length, &target->log_file, + copy); + target->log_severity = src->log_severity; + cef_string_set(src->javascript_flags.str, src->javascript_flags.length, + &target->javascript_flags, copy); + + cef_string_set(src->resources_dir_path.str, src->resources_dir_path.length, + &target->resources_dir_path, copy); + 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; + target->uncaught_exception_stack_size = src->uncaught_exception_stack_size; + target->background_color = src->background_color; + + cef_string_set(src->accept_language_list.str, + src->accept_language_list.length, + &target->accept_language_list, copy); + + cef_string_set(src->cookieable_schemes_list.str, + src->cookieable_schemes_list.length, + &target->cookieable_schemes_list, copy); + target->cookieable_schemes_exclude_defaults = + src->cookieable_schemes_exclude_defaults; + } +}; + +/// +/// Class representing initialization settings. +/// +using CefSettings = CefStructBase<CefSettingsTraits>; + +struct CefRequestContextSettingsTraits { + using struct_type = cef_request_context_settings_t; + + static inline void init(struct_type* s) { s->size = sizeof(struct_type); } + + static inline void clear(struct_type* s) { + cef_string_clear(&s->cache_path); + cef_string_clear(&s->accept_language_list); + cef_string_clear(&s->cookieable_schemes_list); + } + + static inline void set(const struct_type* src, + struct_type* target, + bool copy) { + cef_string_set(src->cache_path.str, src->cache_path.length, + &target->cache_path, copy); + target->persist_session_cookies = src->persist_session_cookies; + target->persist_user_preferences = src->persist_user_preferences; + cef_string_set(src->accept_language_list.str, + src->accept_language_list.length, + &target->accept_language_list, copy); + + cef_string_set(src->cookieable_schemes_list.str, + src->cookieable_schemes_list.length, + &target->cookieable_schemes_list, copy); + target->cookieable_schemes_exclude_defaults = + src->cookieable_schemes_exclude_defaults; + } +}; + +/// +/// Class representing request context initialization settings. +/// +using CefRequestContextSettings = + CefStructBase<CefRequestContextSettingsTraits>; + +struct CefBrowserSettingsTraits { + using struct_type = cef_browser_settings_t; + + static inline void init(struct_type* s) { s->size = sizeof(struct_type); } + + static inline void clear(struct_type* s) { + cef_string_clear(&s->standard_font_family); + cef_string_clear(&s->fixed_font_family); + cef_string_clear(&s->serif_font_family); + cef_string_clear(&s->sans_serif_font_family); + cef_string_clear(&s->cursive_font_family); + cef_string_clear(&s->fantasy_font_family); + cef_string_clear(&s->default_encoding); + cef_string_clear(&s->accept_language_list); + } + + static inline void set(const struct_type* src, + struct_type* target, + bool copy) { + target->windowless_frame_rate = src->windowless_frame_rate; + + cef_string_set(src->standard_font_family.str, + src->standard_font_family.length, + &target->standard_font_family, copy); + cef_string_set(src->fixed_font_family.str, src->fixed_font_family.length, + &target->fixed_font_family, copy); + cef_string_set(src->serif_font_family.str, src->serif_font_family.length, + &target->serif_font_family, copy); + cef_string_set(src->sans_serif_font_family.str, + src->sans_serif_font_family.length, + &target->sans_serif_font_family, copy); + cef_string_set(src->cursive_font_family.str, + src->cursive_font_family.length, + &target->cursive_font_family, copy); + cef_string_set(src->fantasy_font_family.str, + src->fantasy_font_family.length, + &target->fantasy_font_family, copy); + + target->default_font_size = src->default_font_size; + target->default_fixed_font_size = src->default_fixed_font_size; + target->minimum_font_size = src->minimum_font_size; + target->minimum_logical_font_size = src->minimum_logical_font_size; + + cef_string_set(src->default_encoding.str, src->default_encoding.length, + &target->default_encoding, copy); + + target->remote_fonts = src->remote_fonts; + target->javascript = src->javascript; + target->javascript_close_windows = src->javascript_close_windows; + target->javascript_access_clipboard = src->javascript_access_clipboard; + target->javascript_dom_paste = src->javascript_dom_paste; + target->image_loading = src->image_loading; + target->image_shrink_standalone_to_fit = + src->image_shrink_standalone_to_fit; + target->text_area_resize = src->text_area_resize; + target->tab_to_links = src->tab_to_links; + target->local_storage = src->local_storage; + target->databases = src->databases; + target->webgl = src->webgl; + + target->background_color = src->background_color; + + cef_string_set(src->accept_language_list.str, + src->accept_language_list.length, + &target->accept_language_list, copy); + + target->chrome_status_bubble = src->chrome_status_bubble; + } +}; + +/// +/// Class representing browser initialization settings. +/// +using CefBrowserSettings = CefStructBase<CefBrowserSettingsTraits>; + +struct CefURLPartsTraits { + using struct_type = cef_urlparts_t; + + static inline void init(struct_type* s) {} + + static inline void clear(struct_type* s) { + cef_string_clear(&s->spec); + cef_string_clear(&s->scheme); + cef_string_clear(&s->username); + cef_string_clear(&s->password); + cef_string_clear(&s->host); + cef_string_clear(&s->port); + cef_string_clear(&s->origin); + cef_string_clear(&s->path); + cef_string_clear(&s->query); + cef_string_clear(&s->fragment); + } + + static inline void set(const struct_type* src, + struct_type* target, + bool copy) { + cef_string_set(src->spec.str, src->spec.length, &target->spec, copy); + cef_string_set(src->scheme.str, src->scheme.length, &target->scheme, copy); + cef_string_set(src->username.str, src->username.length, &target->username, + copy); + cef_string_set(src->password.str, src->password.length, &target->password, + copy); + cef_string_set(src->host.str, src->host.length, &target->host, copy); + cef_string_set(src->port.str, src->port.length, &target->port, copy); + cef_string_set(src->origin.str, src->origin.length, &target->origin, copy); + cef_string_set(src->path.str, src->path.length, &target->path, copy); + cef_string_set(src->query.str, src->query.length, &target->query, copy); + cef_string_set(src->fragment.str, src->fragment.length, &target->fragment, + copy); + } +}; + +/// +/// Class representing a URL's component parts. +/// +using CefURLParts = CefStructBase<CefURLPartsTraits>; + +/// +/// Class representing the state of a touch handle. +/// +class CefTouchHandleState : public cef_touch_handle_state_t { + public: + CefTouchHandleState() : cef_touch_handle_state_t{} {} + CefTouchHandleState(const cef_touch_handle_state_t& r) + : cef_touch_handle_state_t(r) {} +}; + +struct CefCookieTraits { + using struct_type = cef_cookie_t; + + static inline void init(struct_type* s) {} + + static inline void clear(struct_type* s) { + cef_string_clear(&s->name); + cef_string_clear(&s->value); + cef_string_clear(&s->domain); + cef_string_clear(&s->path); + } + + static inline void set(const struct_type* src, + struct_type* target, + bool copy) { + cef_string_set(src->name.str, src->name.length, &target->name, copy); + cef_string_set(src->value.str, src->value.length, &target->value, copy); + cef_string_set(src->domain.str, src->domain.length, &target->domain, copy); + cef_string_set(src->path.str, src->path.length, &target->path, copy); + target->secure = src->secure; + target->httponly = src->httponly; + target->creation = src->creation; + target->last_access = src->last_access; + target->has_expires = src->has_expires; + target->expires = src->expires; + target->same_site = src->same_site; + target->priority = src->priority; + } +}; + +/// +/// Class representing a cookie. +/// +using CefCookie = CefStructBase<CefCookieTraits>; + +/// +/// Class representing cursor information. +/// +class CefCursorInfo : public cef_cursor_info_t { + public: + CefCursorInfo() : cef_cursor_info_t{} {} + CefCursorInfo(const cef_cursor_info_t& r) : cef_cursor_info_t(r) {} +}; + +struct CefPdfPrintSettingsTraits { + using struct_type = cef_pdf_print_settings_t; + + static inline void init(struct_type* s) {} + + static inline void clear(struct_type* s) { + cef_string_clear(&s->page_ranges); + cef_string_clear(&s->header_template); + cef_string_clear(&s->footer_template); + } + + static inline void set(const struct_type* src, + struct_type* target, + bool copy) { + target->landscape = src->landscape; + target->print_background = src->print_background; + target->scale = src->scale; + target->paper_width = src->paper_width; + target->paper_height = src->paper_height; + target->prefer_css_page_size = src->prefer_css_page_size; + + target->margin_type = src->margin_type; + target->margin_top = src->margin_top; + target->margin_right = src->margin_right; + target->margin_bottom = src->margin_bottom; + target->margin_left = src->margin_left; + + cef_string_set(src->page_ranges.str, src->page_ranges.length, + &target->page_ranges, copy); + + target->display_header_footer = src->display_header_footer; + cef_string_set(src->header_template.str, src->header_template.length, + &target->header_template, copy); + cef_string_set(src->footer_template.str, src->footer_template.length, + &target->footer_template, copy); + } +}; + +/// +/// Class representing PDF print settings +/// +using CefPdfPrintSettings = CefStructBase<CefPdfPrintSettingsTraits>; + +/// +/// Class representing CefBoxLayout settings. +/// +class CefBoxLayoutSettings : public cef_box_layout_settings_t { + public: + CefBoxLayoutSettings() : cef_box_layout_settings_t{} {} + CefBoxLayoutSettings(const cef_box_layout_settings_t& r) + : cef_box_layout_settings_t(r) {} +}; + +/// +/// Class representing IME composition underline. +/// +class CefCompositionUnderline : public cef_composition_underline_t { + public: + CefCompositionUnderline() : cef_composition_underline_t{} {} + CefCompositionUnderline(const cef_composition_underline_t& r) + : cef_composition_underline_t(r) {} +}; + +/// +/// Class representing CefAudioParameters settings +/// +class CefAudioParameters : public cef_audio_parameters_t { + public: + CefAudioParameters() : cef_audio_parameters_t{} {} + CefAudioParameters(const cef_audio_parameters_t& r) + : cef_audio_parameters_t(r) {} +}; + +struct CefMediaSinkDeviceInfoTraits { + using struct_type = cef_media_sink_device_info_t; + + static inline void init(struct_type* s) {} + + static inline void clear(struct_type* s) { + cef_string_clear(&s->ip_address); + cef_string_clear(&s->model_name); + } + + static inline void set(const struct_type* src, + struct_type* target, + bool copy) { + cef_string_set(src->ip_address.str, src->ip_address.length, + &target->ip_address, copy); + target->port = src->port; + cef_string_set(src->model_name.str, src->model_name.length, + &target->model_name, copy); + } +}; + +/// +/// Class representing MediaSink device info. +/// +using CefMediaSinkDeviceInfo = CefStructBase<CefMediaSinkDeviceInfoTraits>; + +#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_ diff --git a/include/internal/cef_win.h b/include/internal/cef_win.h new file mode 100644 index 00000000..cccc6d52 --- /dev/null +++ b/include/internal/cef_win.h @@ -0,0 +1,184 @@ +// Copyright (c) 2008 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. + +#ifndef CEF_INCLUDE_INTERNAL_CEF_WIN_H_ +#define CEF_INCLUDE_INTERNAL_CEF_WIN_H_ +#pragma once + +#include "include/internal/cef_app_win.h" +#include "include/internal/cef_types_win.h" +#include "include/internal/cef_types_wrappers.h" + +// Handle types. +#define CefCursorHandle cef_cursor_handle_t +#define CefEventHandle cef_event_handle_t +#define CefWindowHandle cef_window_handle_t + +/// +/// Class representing CefExecuteProcess arguments. +/// +class CefMainArgs : public cef_main_args_t { + public: + CefMainArgs() : cef_main_args_t{} {} + CefMainArgs(const cef_main_args_t& r) : cef_main_args_t(r) {} + explicit CefMainArgs(HINSTANCE hInstance) : cef_main_args_t{hInstance} {} +}; + +struct CefWindowInfoTraits { + typedef cef_window_info_t struct_type; + + static inline void init(struct_type* s) {} + + static inline void clear(struct_type* s) { + cef_string_clear(&s->window_name); + } + + static inline void set(const struct_type* src, + struct_type* target, + bool copy) { + target->ex_style = src->ex_style; + cef_string_set(src->window_name.str, src->window_name.length, + &target->window_name, copy); + target->style = src->style; + target->bounds = src->bounds; + target->parent_window = src->parent_window; + target->menu = src->menu; + target->windowless_rendering_enabled = src->windowless_rendering_enabled; + target->shared_texture_enabled = src->shared_texture_enabled; + target->external_begin_frame_enabled = src->external_begin_frame_enabled; + target->window = src->window; + } +}; + +/// +/// Class representing window information. +/// +class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> { + public: + typedef CefStructBase<CefWindowInfoTraits> parent; + + CefWindowInfo() : parent() {} + explicit CefWindowInfo(const cef_window_info_t& r) : parent(r) {} + explicit CefWindowInfo(const CefWindowInfo& r) : parent(r) {} + + CefWindowInfo& operator=(const CefWindowInfo&) = default; + CefWindowInfo& operator=(CefWindowInfo&&) = default; + + /// + /// Create the browser as a child window. + /// + void SetAsChild(CefWindowHandle parent, const CefRect& windowBounds) { + style = + WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_TABSTOP | WS_VISIBLE; + parent_window = parent; + bounds = windowBounds; + } + + /// + /// Create the browser as a popup window. + /// + void SetAsPopup(CefWindowHandle parent, const CefString& windowName) { + style = + WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE; + parent_window = parent; + bounds.x = CW_USEDEFAULT; + bounds.y = CW_USEDEFAULT; + bounds.width = CW_USEDEFAULT; + bounds.height = CW_USEDEFAULT; + + cef_string_copy(windowName.c_str(), windowName.length(), &window_name); + } + + /// + /// Create the browser using windowless (off-screen) rendering. No window + /// will be created for the browser and all rendering will occur via the + /// CefRenderHandler interface. The |parent| value will be used to identify + /// monitor info and to act as the parent window for dialogs, context menus, + /// etc. If |parent| is not provided then the main screen monitor will be used + /// and some functionality that requires a parent window may not function + /// correctly. In order to create windowless browsers the + /// CefSettings.windowless_rendering_enabled value must be set to true. + /// Transparent painting is enabled by default but can be disabled by setting + /// CefBrowserSettings.background_color to an opaque value. + /// + void SetAsWindowless(CefWindowHandle parent) { + windowless_rendering_enabled = TRUE; + parent_window = parent; + } +}; + +#if defined(ARCH_CPU_32_BITS) +/// +/// Run the main thread on 32-bit Windows using a fiber with the preferred 4MiB +/// stack size. This function must be called at the top of the executable entry +/// point function (`main()` or `wWinMain()`). It is used in combination with +/// the initial stack size of 0.5MiB configured via the `/STACK:0x80000` linker +/// flag on executable targets. This saves significant memory on threads (like +/// those in the Windows thread pool, and others) whose stack size can only be +/// controlled via the linker flag. +/// +/// CEF's main thread needs at least a 1.5 MiB stack size in order to avoid +/// stack overflow crashes. However, if this is set in the PE file then other +/// threads get this size as well, leading to address-space exhaustion in 32-bit +/// CEF. This function uses fibers to switch the main thread to a 4 MiB stack +/// (roughly the same effective size as the 64-bit build's 8 MiB stack) before +/// running any other code. +/// +/// Choose the function variant that matches the entry point function type used +/// by the executable. Reusing the entry point minimizes confusion when +/// examining call stacks in crash reports. +/// +/// If this function is already running on the fiber it will return -1 +/// immediately, meaning that execution should proceed with the remainder of the +/// entry point function. Otherwise, this function will block until the entry +/// point function has completed execution on the fiber and then return a result +/// >= 0, meaning that the entry point function should return the result +/// immediately without proceeding with execution. +/// +int CefRunWinMainWithPreferredStackSize(wWinMainPtr wWinMain, + HINSTANCE hInstance, + LPWSTR lpCmdLine, + int nCmdShow); +int CefRunMainWithPreferredStackSize(mainPtr main, int argc, char* argv[]); +#endif // defined(ARCH_CPU_32_BITS) + +/// +/// Call during process startup to enable High-DPI support on Windows 7 or +/// newer. Older versions of Windows should be left DPI-unaware because they do +/// not support DirectWrite and GDI fonts are kerned very badly. +/// +void CefEnableHighDPISupport(); + +/// +/// Set to true before calling Windows APIs like TrackPopupMenu that enter a +/// modal message loop. Set to false after exiting the modal message loop. +/// +void CefSetOSModalLoop(bool osModalLoop); + +#endif // CEF_INCLUDE_INTERNAL_CEF_WIN_H_ |