diff --git a/README.md b/README.md index e1471cf..bfeab35 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ Compatibility Supported platforms: Windows, Linux, Mac OSX. CEF2go was tested and works fine with Go 1.2 / Go 1.3.3. +In the case of Windows (32 and 64 bits) it was tested and works fine with Go 1.8.3. Binary examples @@ -109,24 +110,44 @@ accessible from the outside, it can be accessed only from the machine it is running on. -Getting started on Windows +Getting started on Windows 32-bit -------------------------- -1. Install Go 32-bit. CEF 64-bit binaries are still experimental and - were not tested. +1. Install Go 32-bit. 2. Install mingw 32-bit and add C:\MinGW\bin to PATH. You can install mingw using [mingw-get-setup.exe](http://sourceforge.net/projects/mingw/files/Installer/). Select packages to install: "mingw-developer-toolkit", "mingw32-base", "msys-base". CEF2go was tested and works fine - with GCC 4.8.2. You can check gcc version with "gcc --version". + with GCC 5.3.0. You can check gcc version with "gcc --version". -3. Download CEF 3 branch 1750 revision 1590 binaries: +3. Download CEF 3 branch 3071 revision 1640 binaries: [cef_binary_3.1750.1590_windows32.7z](https://github.com/CzarekTomczak/cef2go/releases/download/cef3-b1750-r1590/cef_binary_3.1750.1590_windows32.7z) Copy Release/* to cef2go/Release Copy Resources/* to cef2go/Release 4. Run build.bat (or "build.bat noconsole" to get rid of the console window when running the final executable) + +5. You might need to help your linker find libcef.dll + +Getting started on Windows 64-bit +-------------------------- +1. Install Go 64-bit. + +2. Install mingw 64-bit and add the bin folder to PATH. You can install mingw + using [mingw-w64-install](https://sourceforge.net/projects/mingw-w64/files/latest/download). + Select x86_64 as your architecture. + CEF2go was tested and works fine with GCC 7.1.0. You can check gcc version with "gcc --version". + +3. Download CEF 3 branch 3071 revision 1640 binaries: + [cef_binary_3.1750.1590_windows32.7z](https://github.com/CzarekTomczak/cef2go/releases/download/cef3-b1750-r1590/cef_binary_3.1750.1590_windows32.7z) + Copy Release/* to cef2go/Release + Copy Resources/* to cef2go/Release + +4. Run build.bat (or "build.bat noconsole" to get rid of the console + window when running the final executable) + +5. You might need to help your linker find libcef.dll Getting started on Linux diff --git a/handlers/cef_app.h b/handlers/cef_app.h index 214edc1..2df20db 100644 --- a/handlers/cef_app.h +++ b/handlers/cef_app.h @@ -61,7 +61,7 @@ struct _cef_resource_bundle_handler_t* // Return the handler for functionality specific to the browser process. This // function is called on multiple threads in the browser process. /// -struct _cef_browser_process_handler_t* +struct _cef_browser_process_handler_t* CEF_CALLBACK get_browser_process_handler(struct _cef_app_t* self) { DEBUG_CALLBACK("get_browser_process_handler\n"); return NULL; @@ -77,10 +77,10 @@ struct _cef_render_process_handler_t* return NULL; } -void initialize_app_handler(cef_app_t* app) { - printf("initialize_app_handler\n"); +void initialize_cef_app(cef_app_t* app) { + printf("initialize_cef_app\n"); app->base.size = sizeof(cef_app_t); - initialize_cef_base((cef_base_t*)app); + initialize_cef_base_ref_counted((cef_base_ref_counted_t*)app); // callbacks app->on_before_command_line_processing = on_before_command_line_processing; app->on_register_custom_schemes = on_register_custom_schemes; diff --git a/handlers/cef_base.h b/handlers/cef_base.h index b083f82..ec9cd5e 100644 --- a/handlers/cef_base.h +++ b/handlers/cef_base.h @@ -4,8 +4,8 @@ #pragma once -#include "include/capi/cef_base_capi.h" #include +#include "include/capi/cef_base_capi.h" // Set to 1 to check if add_ref() and release() // are called and to track the total number of calls. @@ -14,33 +14,39 @@ // Print only the first execution of the callback, // ignore the subsequent. -#define DEBUG_CALLBACK(x) { static int first_call = 1; if (first_call == 1) { first_call = 0; printf(x); } } +#define DEBUG_CALLBACK(x) { \ + static int first_call = 1; \ + if (first_call == 1) { \ + first_call = 0; \ + printf(x); \ + } \ +} // ---------------------------------------------------------------------------- -// cef_base_t +// cef_base_ref_counted_t // ---------------------------------------------------------------------------- /// -// Structure defining the reference count implementation functions. All -// framework structures must include the cef_base_t structure first. +// Structure defining the reference count implementation functions. +// All framework structures must include the cef_base_ref_counted_t +// structure first. /// /// // Increment the reference count. /// -int CEF_CALLBACK add_ref(cef_base_t* self) { - DEBUG_CALLBACK("cef_base_t.add_ref\n"); +void CEF_CALLBACK add_ref(cef_base_ref_counted_t* self) { + DEBUG_CALLBACK("cef_base_ref_counted_t.add_ref\n"); if (DEBUG_REFERENCE_COUNTING) printf("+"); - return 1; } /// // Decrement the reference count. Delete this object when no references // remain. /// -int CEF_CALLBACK release(cef_base_t* self) { - DEBUG_CALLBACK("cef_base_t.release\n"); +int CEF_CALLBACK release(cef_base_ref_counted_t* self) { + DEBUG_CALLBACK("cef_base_ref_counted_t.release\n"); if (DEBUG_REFERENCE_COUNTING) printf("-"); return 1; @@ -49,26 +55,26 @@ int CEF_CALLBACK release(cef_base_t* self) { /// // Returns the current number of references. /// -int CEF_CALLBACK get_refct(cef_base_t* self) { - DEBUG_CALLBACK("cef_base_t.get_refct\n"); +int CEF_CALLBACK has_one_ref(cef_base_ref_counted_t* self) { + DEBUG_CALLBACK("cef_base_ref_counted_t.has_one_ref\n"); if (DEBUG_REFERENCE_COUNTING) printf("="); return 1; } -void initialize_cef_base(cef_base_t* base) { - printf("initialize_cef_base\n"); +void initialize_cef_base_ref_counted(cef_base_ref_counted_t* base) { + printf("initialize_cef_base_ref_counted\n"); // Check if "size" member was set. size_t size = base->size; // Let's print the size in case sizeof was used // on a pointer instead of a structure. In such // case the number will be very high. - printf("cef_base_t.size = %lu\n", (unsigned long)size); + printf("cef_base_ref_counted_t.size = %lu\n", (unsigned long)size); if (size <= 0) { printf("FATAL: initialize_cef_base failed, size member not set\n"); _exit(1); } base->add_ref = add_ref; base->release = release; - base->get_refct = get_refct; + base->has_one_ref = has_one_ref; } diff --git a/handlers/cef_client.h b/handlers/cef_client.h index 645db56..17da4a1 100644 --- a/handlers/cef_client.h +++ b/handlers/cef_client.h @@ -5,10 +5,14 @@ #pragma once #include "handlers/cef_base.h" +#include "handlers/cef_life_span_handler.h" #include "include/capi/cef_client_capi.h" +extern cef_life_span_handler_t g_life_span_handler; + + // ---------------------------------------------------------------------------- -// struct _cef_client_t +// struct cef_client_t // ---------------------------------------------------------------------------- /// @@ -16,8 +20,8 @@ /// /// -// Return the handler for context menus. If no handler is provided the default -// implementation will be used. +// Return the handler for context menus. If no handler is +// provided the default implementation will be used. /// struct _cef_context_menu_handler_t* CEF_CALLBACK get_context_menu_handler( @@ -108,7 +112,8 @@ struct _cef_keyboard_handler_t* CEF_CALLBACK get_keyboard_handler( struct _cef_life_span_handler_t* CEF_CALLBACK get_life_span_handler( struct _cef_client_t* self) { DEBUG_CALLBACK("get_life_span_handler\n"); - return NULL; + // Implemented! + return &g_life_span_handler; } /// @@ -151,10 +156,10 @@ int CEF_CALLBACK on_process_message_received( return 0; } -void initialize_client_handler(struct _cef_client_t* client) { - DEBUG_CALLBACK("initialize_client_handler\n"); +void initialize_cef_client(cef_client_t* client) { + DEBUG_CALLBACK("initialize_cef_client\n"); client->base.size = sizeof(cef_client_t); - initialize_cef_base((cef_base_t*)client); + initialize_cef_base_ref_counted((cef_base_ref_counted_t*)client); // callbacks client->get_context_menu_handler = get_context_menu_handler; client->get_dialog_handler = get_dialog_handler; @@ -165,7 +170,7 @@ void initialize_client_handler(struct _cef_client_t* client) { client->get_geolocation_handler = get_geolocation_handler; client->get_jsdialog_handler = get_jsdialog_handler; client->get_keyboard_handler = get_keyboard_handler; - client->get_life_span_handler = get_life_span_handler; + client->get_life_span_handler = get_life_span_handler; // Implemented! client->get_load_handler = get_load_handler; client->get_render_handler = get_render_handler; client->get_request_handler = get_request_handler; diff --git a/handlers/cef_life_span_handler.h b/handlers/cef_life_span_handler.h new file mode 100644 index 0000000..b5cda03 --- /dev/null +++ b/handlers/cef_life_span_handler.h @@ -0,0 +1,46 @@ +// CEF C API example +// Project website: https://github.com/cztomczak/cefcapi + +#pragma once + +#include "handlers/cef_base.h" +#include "include/capi/cef_app_capi.h" +#include "include/capi/cef_life_span_handler_capi.h" + +// ---------------------------------------------------------------------------- +// struct cef_life_span_handler_t +// ---------------------------------------------------------------------------- + +/// +// Implement this structure to handle events related to browser life span. The +// functions of this structure will be called on the UI thread unless otherwise +// indicated. +/// + +// NOTE: There are many more callbacks in cef_life_span_handler, +// but only on_before_close is implemented here. + +/// +// Called just before a browser is destroyed. Release all references to the +// browser object and do not attempt to execute any functions on the browser +// object after this callback returns. This callback will be the last +// notification that references |browser|. See do_close() documentation for +// additional usage information. +/// +void CEF_CALLBACK on_before_close(struct _cef_life_span_handler_t* self, + struct _cef_browser_t* browser) { + DEBUG_CALLBACK("on_before_close\n"); + // TODO: Check how many browsers do exist and quit message + // loop only when last browser is closed. Otherwise + // closing a popup window will exit app while main + // window shouldn't be closed. + cef_quit_message_loop(); +} + +void initialize_cef_life_span_handler(cef_life_span_handler_t* handler) { + DEBUG_CALLBACK("initialize_cef_life_span_handler\n"); + handler->base.size = sizeof(cef_life_span_handler_t); + initialize_cef_base_ref_counted((cef_base_ref_counted_t*)handler); + // callbacks - there are many, but implementing only one + handler->on_before_close = on_before_close; +} diff --git a/include/base/cef_atomic_ref_count.h b/include/base/cef_atomic_ref_count.h new file mode 100644 index 0000000..755f8a8 --- /dev/null +++ b/include/base/cef_atomic_ref_count.h @@ -0,0 +1,126 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011 +// Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// This is a low level implementation of atomic semantics for reference +// counting. Please use cef_ref_counted.h directly instead. +// +// The Chromium implementation includes annotations to avoid some false +// positives when using data race detection tools. Annotations are not +// currently supported by the CEF implementation. + +#ifndef CEF_INCLUDE_BASE_CEF_ATOMIC_REF_COUNT_H_ +#define CEF_INCLUDE_BASE_CEF_ATOMIC_REF_COUNT_H_ +#pragma once + +#if defined(BASE_ATOMIC_REF_COUNT_H_) +// Do nothing if the Chromium header has already been included. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/atomic_ref_count.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include "include/base/cef_atomicops.h" + +// Annotations are not currently supported. +#define ANNOTATE_HAPPENS_BEFORE(obj) /* empty */ +#define ANNOTATE_HAPPENS_AFTER(obj) /* empty */ + +namespace base { + +typedef subtle::Atomic32 AtomicRefCount; + +// Increment a reference count by "increment", which must exceed 0. +inline void AtomicRefCountIncN(volatile AtomicRefCount* ptr, + AtomicRefCount increment) { + subtle::NoBarrier_AtomicIncrement(ptr, increment); +} + +// Decrement a reference count by "decrement", which must exceed 0, +// and return whether the result is non-zero. +// Insert barriers to ensure that state written before the reference count +// became zero will be visible to a thread that has just made the count zero. +inline bool AtomicRefCountDecN(volatile AtomicRefCount* ptr, + AtomicRefCount decrement) { + ANNOTATE_HAPPENS_BEFORE(ptr); + bool res = (subtle::Barrier_AtomicIncrement(ptr, -decrement) != 0); + if (!res) { + ANNOTATE_HAPPENS_AFTER(ptr); + } + return res; +} + +// Increment a reference count by 1. +inline void AtomicRefCountInc(volatile AtomicRefCount* ptr) { + base::AtomicRefCountIncN(ptr, 1); +} + +// Decrement a reference count by 1 and return whether the result is non-zero. +// Insert barriers to ensure that state written before the reference count +// became zero will be visible to a thread that has just made the count zero. +inline bool AtomicRefCountDec(volatile AtomicRefCount* ptr) { + return base::AtomicRefCountDecN(ptr, 1); +} + +// Return whether the reference count is one. If the reference count is used +// in the conventional way, a refrerence count of 1 implies that the current +// thread owns the reference and no other thread shares it. This call performs +// the test for a reference count of one, and performs the memory barrier +// needed for the owning thread to act on the object, knowing that it has +// exclusive access to the object. +inline bool AtomicRefCountIsOne(volatile AtomicRefCount* ptr) { + bool res = (subtle::Acquire_Load(ptr) == 1); + if (res) { + ANNOTATE_HAPPENS_AFTER(ptr); + } + return res; +} + +// Return whether the reference count is zero. With conventional object +// referencing counting, the object will be destroyed, so the reference count +// should never be zero. Hence this is generally used for a debug check. +inline bool AtomicRefCountIsZero(volatile AtomicRefCount* ptr) { + bool res = (subtle::Acquire_Load(ptr) == 0); + if (res) { + ANNOTATE_HAPPENS_AFTER(ptr); + } + return res; +} + +} // namespace base + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_ATOMIC_REF_COUNT_H_ diff --git a/include/base/cef_atomicops.h b/include/base/cef_atomicops.h new file mode 100644 index 0000000..96aebab --- /dev/null +++ b/include/base/cef_atomicops.h @@ -0,0 +1,199 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012 +// Google Inc. 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. + +// For atomic operations on reference counts, see cef_atomic_ref_count.h. + +// The routines exported by this module are subtle. If you use them, even if +// you get the code right, it will depend on careful reasoning about atomicity +// and memory ordering; it will be less readable, and harder to maintain. If +// you plan to use these routines, you should have a good reason, such as solid +// evidence that performance would otherwise suffer, or there being no +// alternative. You should assume only properties explicitly guaranteed by the +// specifications in this file. You are almost certainly _not_ writing code +// just for the x86; if you assume x86 semantics, x86 hardware bugs and +// implementations on other archtectures will cause your code to break. If you +// do not know what you are doing, avoid these routines, and use a Mutex. +// +// It is incorrect to make direct assignments to/from an atomic variable. +// You should use one of the Load or Store routines. The NoBarrier +// versions are provided when no barriers are needed: +// NoBarrier_Store() +// NoBarrier_Load() +// Although there are currently no compiler enforcement, you are encouraged +// to use these. +// + +#ifndef CEF_INCLUDE_BASE_CEF_ATOMICOPS_H_ +#define CEF_INCLUDE_BASE_CEF_ATOMICOPS_H_ +#pragma once + +#if defined(BASE_ATOMICOPS_H_) +// Do nothing if the Chromium header has already been included. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/atomicops.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include + +#include "include/base/cef_build.h" + +#if defined(OS_WIN) && defined(ARCH_CPU_64_BITS) +// windows.h #defines this (only on x64). This causes problems because the +// public API also uses MemoryBarrier at the public name for this fence. So, on +// X64, undef it, and call its documented +// (http://msdn.microsoft.com/en-us/library/windows/desktop/ms684208.aspx) +// implementation directly. +#undef MemoryBarrier +#endif + +namespace base { +namespace subtle { + +typedef int32_t Atomic32; +#ifdef ARCH_CPU_64_BITS +// We need to be able to go between Atomic64 and AtomicWord implicitly. This +// means Atomic64 and AtomicWord should be the same type on 64-bit. +#if defined(__ILP32__) || defined(OS_NACL) +// NaCl's intptr_t is not actually 64-bits on 64-bit! +// http://code.google.com/p/nativeclient/issues/detail?id=1162 +typedef int64_t Atomic64; +#else +typedef intptr_t Atomic64; +#endif +#endif + +// Use AtomicWord for a machine-sized pointer. It will use the Atomic32 or +// Atomic64 routines below, depending on your architecture. +typedef intptr_t AtomicWord; + +// Atomically execute: +// result = *ptr; +// if (*ptr == old_value) +// *ptr = new_value; +// return result; +// +// I.e., replace "*ptr" with "new_value" if "*ptr" used to be "old_value". +// Always return the old value of "*ptr" +// +// This routine implies no memory barriers. +Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr, + Atomic32 old_value, + Atomic32 new_value); + +// Atomically store new_value into *ptr, returning the previous value held in +// *ptr. This routine implies no memory barriers. +Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr, Atomic32 new_value); + +// Atomically increment *ptr by "increment". Returns the new value of +// *ptr with the increment applied. This routine implies no memory barriers. +Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr, Atomic32 increment); + +Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, Atomic32 increment); + +// These following lower-level operations are typically useful only to people +// implementing higher-level synchronization operations like spinlocks, +// mutexes, and condition-variables. They combine CompareAndSwap(), a load, or +// a store with appropriate memory-ordering instructions. "Acquire" operations +// ensure that no later memory access can be reordered ahead of the operation. +// "Release" operations ensure that no previous memory access can be reordered +// after the operation. "Barrier" operations have both "Acquire" and "Release" +// semantics. A MemoryBarrier() has "Barrier" semantics, but does no memory +// access. +Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, + Atomic32 old_value, + Atomic32 new_value); +Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr, + Atomic32 old_value, + Atomic32 new_value); + +void MemoryBarrier(); +void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value); +void Acquire_Store(volatile Atomic32* ptr, Atomic32 value); +void Release_Store(volatile Atomic32* ptr, Atomic32 value); + +Atomic32 NoBarrier_Load(volatile const Atomic32* ptr); +Atomic32 Acquire_Load(volatile const Atomic32* ptr); +Atomic32 Release_Load(volatile const Atomic32* ptr); + +// 64-bit atomic operations (only available on 64-bit processors). +#ifdef ARCH_CPU_64_BITS +Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr, + Atomic64 old_value, + Atomic64 new_value); +Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr, Atomic64 new_value); +Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr, Atomic64 increment); +Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr, Atomic64 increment); + +Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr, + Atomic64 old_value, + Atomic64 new_value); +Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr, + Atomic64 old_value, + Atomic64 new_value); +void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value); +void Acquire_Store(volatile Atomic64* ptr, Atomic64 value); +void Release_Store(volatile Atomic64* ptr, Atomic64 value); +Atomic64 NoBarrier_Load(volatile const Atomic64* ptr); +Atomic64 Acquire_Load(volatile const Atomic64* ptr); +Atomic64 Release_Load(volatile const Atomic64* ptr); +#endif // ARCH_CPU_64_BITS + +} // namespace subtle +} // namespace base + +// Include our platform specific implementation. +#if defined(OS_WIN) && defined(COMPILER_MSVC) && defined(ARCH_CPU_X86_FAMILY) +#include "include/base/internal/cef_atomicops_x86_msvc.h" +#elif defined(OS_MACOSX) +#include "include/base/internal/cef_atomicops_mac.h" +#elif defined(COMPILER_GCC) && defined(ARCH_CPU_X86_FAMILY) +#include "include/base/internal/cef_atomicops_x86_gcc.h" +#elif defined(COMPILER_GCC) && defined(__ARM_ARCH) +#include "include/base/internal/cef_atomicops_arm_gcc.h" +#else +#error "Atomic operations are not supported on your platform" +#endif + +// On some platforms we need additional declarations to make +// AtomicWord compatible with our other Atomic* types. +#if defined(OS_MACOSX) || defined(OS_OPENBSD) +#include "include/base/internal/cef_atomicops_atomicword_compat.h" +#endif + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_ATOMICOPS_H_ diff --git a/include/base/cef_basictypes.h b/include/base/cef_basictypes.h new file mode 100644 index 0000000..0086a1d --- /dev/null +++ b/include/base/cef_basictypes.h @@ -0,0 +1,77 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012 +// Google Inc. 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_BASE_CEF_BASICTYPES_H_ +#define CEF_INCLUDE_BASE_CEF_BASICTYPES_H_ +#pragma once + +#include // For UINT_MAX +#include // For size_t + +#include "include/base/cef_build.h" + +// The NSPR system headers define 64-bit as |long| when possible, except on +// Mac OS X. In order to not have typedef mismatches, we do the same on LP64. +// +// On Mac OS X, |long long| is used for 64-bit types for compatibility with +// format macros even in the LP64 model. +#if defined(__LP64__) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) +typedef long int64; +typedef unsigned long uint64; +#else +typedef long long int64; +typedef unsigned long long uint64; +#endif + +// TODO: Remove these type guards. These are to avoid conflicts with +// obsolete/protypes.h in the Gecko SDK. +#ifndef _INT32 +#define _INT32 +typedef int int32; +#endif + +// TODO: Remove these type guards. These are to avoid conflicts with +// obsolete/protypes.h in the Gecko SDK. +#ifndef _UINT32 +#define _UINT32 +typedef unsigned int uint32; +#endif + +// UTF-16 character type. +// This should be kept synchronized with base/strings/string16.h +#ifndef char16 +#if defined(WCHAR_T_IS_UTF16) +typedef wchar_t char16; +#elif defined(WCHAR_T_IS_UTF32) +typedef unsigned short char16; +#endif +#endif + +#endif // CEF_INCLUDE_BASE_CEF_BASICTYPES_H_ diff --git a/include/base/cef_bind.h b/include/base/cef_bind.h new file mode 100644 index 0000000..77c9c55 --- /dev/null +++ b/include/base/cef_bind.h @@ -0,0 +1,575 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011 +// Google Inc. 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_BASE_CEF_BIND_H_ +#define CEF_INCLUDE_BASE_CEF_BIND_H_ +#pragma once + +#if defined(BASE_BIND_H_) +// Do nothing if the Chromium header has already been included. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/bind.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include "include/base/internal/cef_bind_internal.h" +#include "include/base/internal/cef_callback_internal.h" + +// ----------------------------------------------------------------------------- +// Usage documentation +// ----------------------------------------------------------------------------- +// +// See base/cef_callback.h for documentation. +// +// +// ----------------------------------------------------------------------------- +// Implementation notes +// ----------------------------------------------------------------------------- +// +// If you're reading the implementation, before proceeding further, you should +// read the top comment of base/bind_internal.h for a definition of common +// terms and concepts. +// +// RETURN TYPES +// +// Though Bind()'s result is meant to be stored in a Callback<> type, it +// cannot actually return the exact type without requiring a large amount +// of extra template specializations. The problem is that in order to +// discern the correct specialization of Callback<>, Bind would need to +// unwrap the function signature to determine the signature's arity, and +// whether or not it is a method. +// +// Each unique combination of (arity, function_type, num_prebound) where +// function_type is one of {function, method, const_method} would require +// one specialization. We eventually have to do a similar number of +// specializations anyways in the implementation (see the Invoker<>, +// classes). However, it is avoidable in Bind if we return the result +// via an indirection like we do below. +// +// TODO(ajwong): We might be able to avoid this now, but need to test. +// +// It is possible to move most of the COMPILE_ASSERT asserts into BindState<>, +// but it feels a little nicer to have the asserts here so people do not +// need to crack open bind_internal.h. On the other hand, it makes Bind() +// harder to read. + +namespace base { + +template +base::Callback::RunnableType, + typename cef_internal::FunctorTraits::RunType, + void()>::UnboundRunType> +Bind(Functor functor) { + // Typedefs for how to store and run the functor. + typedef + typename cef_internal::FunctorTraits::RunnableType RunnableType; + typedef typename cef_internal::FunctorTraits::RunType RunType; + + typedef cef_internal::BindState BindState; + + return Callback( + new BindState(cef_internal::MakeRunnable(functor))); +} + +template +base::Callback::RunnableType, + typename cef_internal::FunctorTraits::RunType, + void(typename cef_internal::CallbackParamTraits::StorageType)>:: + UnboundRunType> +Bind(Functor functor, const P1& p1) { + // Typedefs for how to store and run the functor. + typedef + typename cef_internal::FunctorTraits::RunnableType RunnableType; + typedef typename cef_internal::FunctorTraits::RunType RunType; + + // Use RunnableType::RunType instead of RunType above because our + // checks should below for bound references need to know what the actual + // functor is going to interpret the argument as. + typedef cef_internal::FunctionTraits + BoundFunctorTraits; + + // Do not allow binding a non-const reference parameter. Non-const reference + // parameters are disallowed by the Google style guide. Also, binding a + // non-const reference parameter can make for subtle bugs because the + // invoked function will receive a reference to the stored copy of the + // argument and not the original. + COMPILE_ASSERT( + !(is_non_const_reference::value), + do_not_bind_functions_with_nonconst_ref); + + // For methods, we need to be careful for parameter 1. We do not require + // a scoped_refptr because BindState<> itself takes care of AddRef() for + // methods. We also disallow binding of an array as the method's target + // object. + COMPILE_ASSERT(cef_internal::HasIsMethodTag::value || + !cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p1_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::HasIsMethodTag::value || + !is_array::value, + first_bound_argument_to_method_cannot_be_array); + typedef cef_internal::BindState< + RunnableType, RunType, + void(typename cef_internal::CallbackParamTraits::StorageType)> + BindState; + + return Callback( + new BindState(cef_internal::MakeRunnable(functor), p1)); +} + +template +base::Callback::RunnableType, + typename cef_internal::FunctorTraits::RunType, + void(typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType)>:: + UnboundRunType> +Bind(Functor functor, const P1& p1, const P2& p2) { + // Typedefs for how to store and run the functor. + typedef + typename cef_internal::FunctorTraits::RunnableType RunnableType; + typedef typename cef_internal::FunctorTraits::RunType RunType; + + // Use RunnableType::RunType instead of RunType above because our + // checks should below for bound references need to know what the actual + // functor is going to interpret the argument as. + typedef cef_internal::FunctionTraits + BoundFunctorTraits; + + // Do not allow binding a non-const reference parameter. Non-const reference + // parameters are disallowed by the Google style guide. Also, binding a + // non-const reference parameter can make for subtle bugs because the + // invoked function will receive a reference to the stored copy of the + // argument and not the original. + COMPILE_ASSERT( + !(is_non_const_reference::value || + is_non_const_reference::value), + do_not_bind_functions_with_nonconst_ref); + + // For methods, we need to be careful for parameter 1. We do not require + // a scoped_refptr because BindState<> itself takes care of AddRef() for + // methods. We also disallow binding of an array as the method's target + // object. + COMPILE_ASSERT(cef_internal::HasIsMethodTag::value || + !cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p1_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::HasIsMethodTag::value || + !is_array::value, + first_bound_argument_to_method_cannot_be_array); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p2_is_refcounted_type_and_needs_scoped_refptr); + typedef cef_internal::BindState< + RunnableType, RunType, + void(typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType)> + BindState; + + return Callback( + new BindState(cef_internal::MakeRunnable(functor), p1, p2)); +} + +template +base::Callback::RunnableType, + typename cef_internal::FunctorTraits::RunType, + void(typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType)>:: + UnboundRunType> +Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3) { + // Typedefs for how to store and run the functor. + typedef + typename cef_internal::FunctorTraits::RunnableType RunnableType; + typedef typename cef_internal::FunctorTraits::RunType RunType; + + // Use RunnableType::RunType instead of RunType above because our + // checks should below for bound references need to know what the actual + // functor is going to interpret the argument as. + typedef cef_internal::FunctionTraits + BoundFunctorTraits; + + // Do not allow binding a non-const reference parameter. Non-const reference + // parameters are disallowed by the Google style guide. Also, binding a + // non-const reference parameter can make for subtle bugs because the + // invoked function will receive a reference to the stored copy of the + // argument and not the original. + COMPILE_ASSERT( + !(is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value), + do_not_bind_functions_with_nonconst_ref); + + // For methods, we need to be careful for parameter 1. We do not require + // a scoped_refptr because BindState<> itself takes care of AddRef() for + // methods. We also disallow binding of an array as the method's target + // object. + COMPILE_ASSERT(cef_internal::HasIsMethodTag::value || + !cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p1_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::HasIsMethodTag::value || + !is_array::value, + first_bound_argument_to_method_cannot_be_array); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p2_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p3_is_refcounted_type_and_needs_scoped_refptr); + typedef cef_internal::BindState< + RunnableType, RunType, + void(typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType)> + BindState; + + return Callback( + new BindState(cef_internal::MakeRunnable(functor), p1, p2, p3)); +} + +template +base::Callback::RunnableType, + typename cef_internal::FunctorTraits::RunType, + void(typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType)>:: + UnboundRunType> +Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4) { + // Typedefs for how to store and run the functor. + typedef + typename cef_internal::FunctorTraits::RunnableType RunnableType; + typedef typename cef_internal::FunctorTraits::RunType RunType; + + // Use RunnableType::RunType instead of RunType above because our + // checks should below for bound references need to know what the actual + // functor is going to interpret the argument as. + typedef cef_internal::FunctionTraits + BoundFunctorTraits; + + // Do not allow binding a non-const reference parameter. Non-const reference + // parameters are disallowed by the Google style guide. Also, binding a + // non-const reference parameter can make for subtle bugs because the + // invoked function will receive a reference to the stored copy of the + // argument and not the original. + COMPILE_ASSERT( + !(is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value), + do_not_bind_functions_with_nonconst_ref); + + // For methods, we need to be careful for parameter 1. We do not require + // a scoped_refptr because BindState<> itself takes care of AddRef() for + // methods. We also disallow binding of an array as the method's target + // object. + COMPILE_ASSERT(cef_internal::HasIsMethodTag::value || + !cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p1_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::HasIsMethodTag::value || + !is_array::value, + first_bound_argument_to_method_cannot_be_array); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p2_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p3_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p4_is_refcounted_type_and_needs_scoped_refptr); + typedef cef_internal::BindState< + RunnableType, RunType, + void(typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType)> + BindState; + + return Callback( + new BindState(cef_internal::MakeRunnable(functor), p1, p2, p3, p4)); +} + +template +base::Callback::RunnableType, + typename cef_internal::FunctorTraits::RunType, + void(typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType)>:: + UnboundRunType> +Bind(Functor functor, + const P1& p1, + const P2& p2, + const P3& p3, + const P4& p4, + const P5& p5) { + // Typedefs for how to store and run the functor. + typedef + typename cef_internal::FunctorTraits::RunnableType RunnableType; + typedef typename cef_internal::FunctorTraits::RunType RunType; + + // Use RunnableType::RunType instead of RunType above because our + // checks should below for bound references need to know what the actual + // functor is going to interpret the argument as. + typedef cef_internal::FunctionTraits + BoundFunctorTraits; + + // Do not allow binding a non-const reference parameter. Non-const reference + // parameters are disallowed by the Google style guide. Also, binding a + // non-const reference parameter can make for subtle bugs because the + // invoked function will receive a reference to the stored copy of the + // argument and not the original. + COMPILE_ASSERT( + !(is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value), + do_not_bind_functions_with_nonconst_ref); + + // For methods, we need to be careful for parameter 1. We do not require + // a scoped_refptr because BindState<> itself takes care of AddRef() for + // methods. We also disallow binding of an array as the method's target + // object. + COMPILE_ASSERT(cef_internal::HasIsMethodTag::value || + !cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p1_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::HasIsMethodTag::value || + !is_array::value, + first_bound_argument_to_method_cannot_be_array); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p2_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p3_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p4_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p5_is_refcounted_type_and_needs_scoped_refptr); + typedef cef_internal::BindState< + RunnableType, RunType, + void(typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType)> + BindState; + + return Callback( + new BindState(cef_internal::MakeRunnable(functor), p1, p2, p3, p4, p5)); +} + +template +base::Callback::RunnableType, + typename cef_internal::FunctorTraits::RunType, + void(typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType)>:: + UnboundRunType> +Bind(Functor functor, + const P1& p1, + const P2& p2, + const P3& p3, + const P4& p4, + const P5& p5, + const P6& p6) { + // Typedefs for how to store and run the functor. + typedef + typename cef_internal::FunctorTraits::RunnableType RunnableType; + typedef typename cef_internal::FunctorTraits::RunType RunType; + + // Use RunnableType::RunType instead of RunType above because our + // checks should below for bound references need to know what the actual + // functor is going to interpret the argument as. + typedef cef_internal::FunctionTraits + BoundFunctorTraits; + + // Do not allow binding a non-const reference parameter. Non-const reference + // parameters are disallowed by the Google style guide. Also, binding a + // non-const reference parameter can make for subtle bugs because the + // invoked function will receive a reference to the stored copy of the + // argument and not the original. + COMPILE_ASSERT( + !(is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value), + do_not_bind_functions_with_nonconst_ref); + + // For methods, we need to be careful for parameter 1. We do not require + // a scoped_refptr because BindState<> itself takes care of AddRef() for + // methods. We also disallow binding of an array as the method's target + // object. + COMPILE_ASSERT(cef_internal::HasIsMethodTag::value || + !cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p1_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::HasIsMethodTag::value || + !is_array::value, + first_bound_argument_to_method_cannot_be_array); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p2_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p3_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p4_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p5_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p6_is_refcounted_type_and_needs_scoped_refptr); + typedef cef_internal::BindState< + RunnableType, RunType, + void(typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType)> + BindState; + + return Callback(new BindState( + cef_internal::MakeRunnable(functor), p1, p2, p3, p4, p5, p6)); +} + +template +base::Callback::RunnableType, + typename cef_internal::FunctorTraits::RunType, + void(typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType)>:: + UnboundRunType> +Bind(Functor functor, + const P1& p1, + const P2& p2, + const P3& p3, + const P4& p4, + const P5& p5, + const P6& p6, + const P7& p7) { + // Typedefs for how to store and run the functor. + typedef + typename cef_internal::FunctorTraits::RunnableType RunnableType; + typedef typename cef_internal::FunctorTraits::RunType RunType; + + // Use RunnableType::RunType instead of RunType above because our + // checks should below for bound references need to know what the actual + // functor is going to interpret the argument as. + typedef cef_internal::FunctionTraits + BoundFunctorTraits; + + // Do not allow binding a non-const reference parameter. Non-const reference + // parameters are disallowed by the Google style guide. Also, binding a + // non-const reference parameter can make for subtle bugs because the + // invoked function will receive a reference to the stored copy of the + // argument and not the original. + COMPILE_ASSERT( + !(is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value), + do_not_bind_functions_with_nonconst_ref); + + // For methods, we need to be careful for parameter 1. We do not require + // a scoped_refptr because BindState<> itself takes care of AddRef() for + // methods. We also disallow binding of an array as the method's target + // object. + COMPILE_ASSERT(cef_internal::HasIsMethodTag::value || + !cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p1_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::HasIsMethodTag::value || + !is_array::value, + first_bound_argument_to_method_cannot_be_array); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p2_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p3_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p4_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p5_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p6_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p7_is_refcounted_type_and_needs_scoped_refptr); + typedef cef_internal::BindState< + RunnableType, RunType, + void(typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType)> + BindState; + + return Callback(new BindState( + cef_internal::MakeRunnable(functor), p1, p2, p3, p4, p5, p6, p7)); +} + +} // namespace base + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_BIND_H_ diff --git a/include/base/cef_bind_helpers.h b/include/base/cef_bind_helpers.h new file mode 100644 index 0000000..2b4798b --- /dev/null +++ b/include/base/cef_bind_helpers.h @@ -0,0 +1,579 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011 +// Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// This defines a set of argument wrappers and related factory methods that +// can be used specify the refcounting and reference semantics of arguments +// that are bound by the Bind() function in base/bind.h. +// +// It also defines a set of simple functions and utilities that people want +// when using Callback<> and Bind(). +// +// +// ARGUMENT BINDING WRAPPERS +// +// The wrapper functions are base::Unretained(), base::Owned(), base::Passed(), +// base::ConstRef(), and base::IgnoreResult(). +// +// Unretained() allows Bind() to bind a non-refcounted class, and to disable +// refcounting on arguments that are refcounted objects. +// +// Owned() transfers ownership of an object to the Callback resulting from +// bind; the object will be deleted when the Callback is deleted. +// +// Passed() is for transferring movable-but-not-copyable types (eg. scoped_ptr) +// through a Callback. Logically, this signifies a destructive transfer of +// the state of the argument into the target function. Invoking +// Callback::Run() twice on a Callback that was created with a Passed() +// argument will CHECK() because the first invocation would have already +// transferred ownership to the target function. +// +// ConstRef() allows binding a constant reference to an argument rather +// than a copy. +// +// IgnoreResult() is used to adapt a function or Callback with a return type to +// one with a void return. This is most useful if you have a function with, +// say, a pesky ignorable bool return that you want to use with PostTask or +// something else that expect a Callback with a void return. +// +// EXAMPLE OF Unretained(): +// +// class Foo { +// public: +// void func() { cout << "Foo:f" << endl; } +// }; +// +// // In some function somewhere. +// Foo foo; +// Closure foo_callback = +// Bind(&Foo::func, Unretained(&foo)); +// foo_callback.Run(); // Prints "Foo:f". +// +// Without the Unretained() wrapper on |&foo|, the above call would fail +// to compile because Foo does not support the AddRef() and Release() methods. +// +// +// EXAMPLE OF Owned(): +// +// void foo(int* arg) { cout << *arg << endl } +// +// int* pn = new int(1); +// Closure foo_callback = Bind(&foo, Owned(pn)); +// +// foo_callback.Run(); // Prints "1" +// foo_callback.Run(); // Prints "1" +// *n = 2; +// foo_callback.Run(); // Prints "2" +// +// foo_callback.Reset(); // |pn| is deleted. Also will happen when +// // |foo_callback| goes out of scope. +// +// Without Owned(), someone would have to know to delete |pn| when the last +// reference to the Callback is deleted. +// +// +// EXAMPLE OF ConstRef(): +// +// void foo(int arg) { cout << arg << endl } +// +// int n = 1; +// Closure no_ref = Bind(&foo, n); +// Closure has_ref = Bind(&foo, ConstRef(n)); +// +// no_ref.Run(); // Prints "1" +// has_ref.Run(); // Prints "1" +// +// n = 2; +// no_ref.Run(); // Prints "1" +// has_ref.Run(); // Prints "2" +// +// Note that because ConstRef() takes a reference on |n|, |n| must outlive all +// its bound callbacks. +// +// +// EXAMPLE OF IgnoreResult(): +// +// int DoSomething(int arg) { cout << arg << endl; } +// +// // Assign to a Callback with a void return type. +// Callback cb = Bind(IgnoreResult(&DoSomething)); +// cb->Run(1); // Prints "1". +// +// // Prints "1" on |ml|. +// ml->PostTask(FROM_HERE, Bind(IgnoreResult(&DoSomething), 1); +// +// +// EXAMPLE OF Passed(): +// +// void TakesOwnership(scoped_ptr arg) { } +// scoped_ptr CreateFoo() { return scoped_ptr(new Foo()); } +// +// scoped_ptr f(new Foo()); +// +// // |cb| is given ownership of Foo(). |f| is now NULL. +// // You can use f.Pass() in place of &f, but it's more verbose. +// Closure cb = Bind(&TakesOwnership, Passed(&f)); +// +// // Run was never called so |cb| still owns Foo() and deletes +// // it on Reset(). +// cb.Reset(); +// +// // |cb| is given a new Foo created by CreateFoo(). +// cb = Bind(&TakesOwnership, Passed(CreateFoo())); +// +// // |arg| in TakesOwnership() is given ownership of Foo(). |cb| +// // no longer owns Foo() and, if reset, would not delete Foo(). +// cb.Run(); // Foo() is now transferred to |arg| and deleted. +// cb.Run(); // This CHECK()s since Foo() already been used once. +// +// Passed() is particularly useful with PostTask() when you are transferring +// ownership of an argument into a task, but don't necessarily know if the +// task will always be executed. This can happen if the task is cancellable +// or if it is posted to a MessageLoopProxy. +// +// +// SIMPLE FUNCTIONS AND UTILITIES. +// +// DoNothing() - Useful for creating a Closure that does nothing when called. +// DeletePointer() - Useful for creating a Closure that will delete a +// pointer when invoked. Only use this when necessary. +// In most cases MessageLoop::DeleteSoon() is a better +// fit. + +#ifndef CEF_INCLUDE_BASE_CEF_BIND_HELPERS_H_ +#define CEF_INCLUDE_BASE_CEF_BIND_HELPERS_H_ +#pragma once + +#if defined(BASE_BIND_HELPERS_H_) +// Do nothing if the Chromium header has already been included. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/bind_helpers.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include "include/base/cef_basictypes.h" +#include "include/base/cef_callback.h" +#include "include/base/cef_template_util.h" +#include "include/base/cef_weak_ptr.h" + +namespace base { +namespace cef_internal { + +// Use the Substitution Failure Is Not An Error (SFINAE) trick to inspect T +// for the existence of AddRef() and Release() functions of the correct +// signature. +// +// http://en.wikipedia.org/wiki/Substitution_failure_is_not_an_error +// http://stackoverflow.com/questions/257288/is-it-possible-to-write-a-c-template-to-check-for-a-functions-existence +// http://stackoverflow.com/questions/4358584/sfinae-approach-comparison +// http://stackoverflow.com/questions/1966362/sfinae-to-check-for-inherited-member-functions +// +// The last link in particular show the method used below. +// +// For SFINAE to work with inherited methods, we need to pull some extra tricks +// with multiple inheritance. In the more standard formulation, the overloads +// of Check would be: +// +// template +// Yes NotTheCheckWeWant(Helper<&C::TargetFunc>*); +// +// template +// No NotTheCheckWeWant(...); +// +// static const bool value = sizeof(NotTheCheckWeWant(0)) == sizeof(Yes); +// +// The problem here is that template resolution will not match +// C::TargetFunc if TargetFunc does not exist directly in C. That is, if +// TargetFunc in inherited from an ancestor, &C::TargetFunc will not match, +// |value| will be false. This formulation only checks for whether or +// not TargetFunc exist directly in the class being introspected. +// +// To get around this, we play a dirty trick with multiple inheritance. +// First, We create a class BaseMixin that declares each function that we +// want to probe for. Then we create a class Base that inherits from both T +// (the class we wish to probe) and BaseMixin. Note that the function +// signature in BaseMixin does not need to match the signature of the function +// we are probing for; thus it's easiest to just use void(void). +// +// Now, if TargetFunc exists somewhere in T, then &Base::TargetFunc has an +// ambiguous resolution between BaseMixin and T. This lets us write the +// following: +// +// template +// No GoodCheck(Helper<&C::TargetFunc>*); +// +// template +// Yes GoodCheck(...); +// +// static const bool value = sizeof(GoodCheck(0)) == sizeof(Yes); +// +// Notice here that the variadic version of GoodCheck() returns Yes here +// instead of No like the previous one. Also notice that we calculate |value| +// by specializing GoodCheck() on Base instead of T. +// +// We've reversed the roles of the variadic, and Helper overloads. +// GoodCheck(Helper<&C::TargetFunc>*), when C = Base, fails to be a valid +// substitution if T::TargetFunc exists. Thus GoodCheck(0) will resolve +// to the variadic version if T has TargetFunc. If T::TargetFunc does not +// exist, then &C::TargetFunc is not ambiguous, and the overload resolution +// will prefer GoodCheck(Helper<&C::TargetFunc>*). +// +// This method of SFINAE will correctly probe for inherited names, but it cannot +// typecheck those names. It's still a good enough sanity check though. +// +// Works on gcc-4.2, gcc-4.4, and Visual Studio 2008. +// +// TODO(ajwong): Move to ref_counted.h or template_util.h when we've vetted +// this works well. +// +// TODO(ajwong): Make this check for Release() as well. +// See http://crbug.com/82038. +template +class SupportsAddRefAndRelease { + typedef char Yes[1]; + typedef char No[2]; + + struct BaseMixin { + void AddRef(); + }; + +// MSVC warns when you try to use Base if T has a private destructor, the +// common pattern for refcounted types. It does this even though no attempt to +// instantiate Base is made. We disable the warning for this definition. +#if defined(OS_WIN) +#pragma warning(push) +#pragma warning(disable : 4624) +#endif + struct Base : public T, public BaseMixin {}; +#if defined(OS_WIN) +#pragma warning(pop) +#endif + + template + struct Helper {}; + + template + static No& Check(Helper<&C::AddRef>*); + + template + static Yes& Check(...); + + public: + static const bool value = sizeof(Check(0)) == sizeof(Yes); +}; + +// Helpers to assert that arguments of a recounted type are bound with a +// scoped_refptr. +template +struct UnsafeBindtoRefCountedArgHelper : false_type {}; + +template +struct UnsafeBindtoRefCountedArgHelper + : integral_constant::value> {}; + +template +struct UnsafeBindtoRefCountedArg : false_type {}; + +template +struct UnsafeBindtoRefCountedArg + : UnsafeBindtoRefCountedArgHelper::value, T> {}; + +template +class HasIsMethodTag { + typedef char Yes[1]; + typedef char No[2]; + + template + static Yes& Check(typename U::IsMethod*); + + template + static No& Check(...); + + public: + static const bool value = sizeof(Check(0)) == sizeof(Yes); +}; + +template +class UnretainedWrapper { + public: + explicit UnretainedWrapper(T* o) : ptr_(o) {} + T* get() const { return ptr_; } + + private: + T* ptr_; +}; + +template +class ConstRefWrapper { + public: + explicit ConstRefWrapper(const T& o) : ptr_(&o) {} + const T& get() const { return *ptr_; } + + private: + const T* ptr_; +}; + +template +struct IgnoreResultHelper { + explicit IgnoreResultHelper(T functor) : functor_(functor) {} + + T functor_; +}; + +template +struct IgnoreResultHelper> { + explicit IgnoreResultHelper(const Callback& functor) : functor_(functor) {} + + const Callback& functor_; +}; + +// An alternate implementation is to avoid the destructive copy, and instead +// specialize ParamTraits<> for OwnedWrapper<> to change the StorageType to +// a class that is essentially a scoped_ptr<>. +// +// The current implementation has the benefit though of leaving ParamTraits<> +// fully in callback_internal.h as well as avoiding type conversions during +// storage. +template +class OwnedWrapper { + public: + explicit OwnedWrapper(T* o) : ptr_(o) {} + ~OwnedWrapper() { delete ptr_; } + T* get() const { return ptr_; } + OwnedWrapper(const OwnedWrapper& other) { + ptr_ = other.ptr_; + other.ptr_ = NULL; + } + + private: + mutable T* ptr_; +}; + +// PassedWrapper is a copyable adapter for a scoper that ignores const. +// +// It is needed to get around the fact that Bind() takes a const reference to +// all its arguments. Because Bind() takes a const reference to avoid +// unnecessary copies, it is incompatible with movable-but-not-copyable +// types; doing a destructive "move" of the type into Bind() would violate +// the const correctness. +// +// This conundrum cannot be solved without either C++11 rvalue references or +// a O(2^n) blowup of Bind() templates to handle each combination of regular +// types and movable-but-not-copyable types. Thus we introduce a wrapper type +// that is copyable to transmit the correct type information down into +// BindState<>. Ignoring const in this type makes sense because it is only +// created when we are explicitly trying to do a destructive move. +// +// Two notes: +// 1) PassedWrapper supports any type that has a "Pass()" function. +// This is intentional. The whitelisting of which specific types we +// support is maintained by CallbackParamTraits<>. +// 2) is_valid_ is distinct from NULL because it is valid to bind a "NULL" +// scoper to a Callback and allow the Callback to execute once. +template +class PassedWrapper { + public: + explicit PassedWrapper(T scoper) : is_valid_(true), scoper_(scoper.Pass()) {} + PassedWrapper(const PassedWrapper& other) + : is_valid_(other.is_valid_), scoper_(other.scoper_.Pass()) {} + T Pass() const { + CHECK(is_valid_); + is_valid_ = false; + return scoper_.Pass(); + } + + private: + mutable bool is_valid_; + mutable T scoper_; +}; + +// Unwrap the stored parameters for the wrappers above. +template +struct UnwrapTraits { + typedef const T& ForwardType; + static ForwardType Unwrap(const T& o) { return o; } +}; + +template +struct UnwrapTraits> { + typedef T* ForwardType; + static ForwardType Unwrap(UnretainedWrapper unretained) { + return unretained.get(); + } +}; + +template +struct UnwrapTraits> { + typedef const T& ForwardType; + static ForwardType Unwrap(ConstRefWrapper const_ref) { + return const_ref.get(); + } +}; + +template +struct UnwrapTraits> { + typedef T* ForwardType; + static ForwardType Unwrap(const scoped_refptr& o) { return o.get(); } +}; + +template +struct UnwrapTraits> { + typedef const WeakPtr& ForwardType; + static ForwardType Unwrap(const WeakPtr& o) { return o; } +}; + +template +struct UnwrapTraits> { + typedef T* ForwardType; + static ForwardType Unwrap(const OwnedWrapper& o) { return o.get(); } +}; + +template +struct UnwrapTraits> { + typedef T ForwardType; + static T Unwrap(PassedWrapper& o) { return o.Pass(); } +}; + +// Utility for handling different refcounting semantics in the Bind() +// function. +template +struct MaybeRefcount; + +template +struct MaybeRefcount { + static void AddRef(const T&) {} + static void Release(const T&) {} +}; + +template +struct MaybeRefcount { + static void AddRef(const T*) {} + static void Release(const T*) {} +}; + +template +struct MaybeRefcount { + static void AddRef(const T&) {} + static void Release(const T&) {} +}; + +template +struct MaybeRefcount { + static void AddRef(T* o) { o->AddRef(); } + static void Release(T* o) { o->Release(); } +}; + +// No need to additionally AddRef() and Release() since we are storing a +// scoped_refptr<> inside the storage object already. +template +struct MaybeRefcount> { + static void AddRef(const scoped_refptr& o) {} + static void Release(const scoped_refptr& o) {} +}; + +template +struct MaybeRefcount { + static void AddRef(const T* o) { o->AddRef(); } + static void Release(const T* o) { o->Release(); } +}; + +// IsWeakMethod is a helper that determine if we are binding a WeakPtr<> to a +// method. It is used internally by Bind() to select the correct +// InvokeHelper that will no-op itself in the event the WeakPtr<> for +// the target object is invalidated. +// +// P1 should be the type of the object that will be received of the method. +template +struct IsWeakMethod : public false_type {}; + +template +struct IsWeakMethod> : public true_type {}; + +template +struct IsWeakMethod>> : public true_type {}; + +} // namespace cef_internal + +template +static inline cef_internal::UnretainedWrapper Unretained(T* o) { + return cef_internal::UnretainedWrapper(o); +} + +template +static inline cef_internal::ConstRefWrapper ConstRef(const T& o) { + return cef_internal::ConstRefWrapper(o); +} + +template +static inline cef_internal::OwnedWrapper Owned(T* o) { + return cef_internal::OwnedWrapper(o); +} + +// We offer 2 syntaxes for calling Passed(). The first takes a temporary and +// is best suited for use with the return value of a function. The second +// takes a pointer to the scoper and is just syntactic sugar to avoid having +// to write Passed(scoper.Pass()). +template +static inline cef_internal::PassedWrapper Passed(T scoper) { + return cef_internal::PassedWrapper(scoper.Pass()); +} +template +static inline cef_internal::PassedWrapper Passed(T* scoper) { + return cef_internal::PassedWrapper(scoper->Pass()); +} + +template +static inline cef_internal::IgnoreResultHelper IgnoreResult(T data) { + return cef_internal::IgnoreResultHelper(data); +} + +template +static inline cef_internal::IgnoreResultHelper> IgnoreResult( + const Callback& data) { + return cef_internal::IgnoreResultHelper>(data); +} + +void DoNothing(); + +template +void DeletePointer(T* obj) { + delete obj; +} + +} // namespace base + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_BIND_HELPERS_H_ diff --git a/include/base/cef_build.h b/include/base/cef_build.h new file mode 100644 index 0000000..1e2065c --- /dev/null +++ b/include/base/cef_build.h @@ -0,0 +1,197 @@ +// 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_BASE_CEF_BUILD_H_ +#define CEF_INCLUDE_BASE_CEF_BUILD_H_ +#pragma once + +#if defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/compiler_specific.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#if defined(_WIN32) +#ifndef OS_WIN +#define OS_WIN 1 +#endif +#elif defined(__APPLE__) +#ifndef OS_MACOSX +#define OS_MACOSX 1 +#endif +#elif defined(__linux__) +#ifndef OS_LINUX +#define OS_LINUX 1 +#endif +#else +#error Please add support for your platform in cef_build.h +#endif + +// For access to standard POSIXish features, use OS_POSIX instead of a +// more specific macro. +#if defined(OS_MACOSX) || defined(OS_LINUX) +#ifndef OS_POSIX +#define OS_POSIX 1 +#endif +#endif + +// Compiler detection. +#if defined(__GNUC__) +#ifndef COMPILER_GCC +#define COMPILER_GCC 1 +#endif +#elif defined(_MSC_VER) +#ifndef COMPILER_MSVC +#define COMPILER_MSVC 1 +#endif +#else +#error Please add support for your compiler in cef_build.h +#endif + +// Processor architecture detection. For more info on what's defined, see: +// http://msdn.microsoft.com/en-us/library/b0084kay.aspx +// http://www.agner.org/optimize/calling_conventions.pdf +// or with gcc, run: "echo | gcc -E -dM -" +#if defined(_M_X64) || defined(__x86_64__) +#define ARCH_CPU_X86_FAMILY 1 +#define ARCH_CPU_X86_64 1 +#define ARCH_CPU_64_BITS 1 +#define ARCH_CPU_LITTLE_ENDIAN 1 +#elif defined(_M_IX86) || defined(__i386__) +#define ARCH_CPU_X86_FAMILY 1 +#define ARCH_CPU_X86 1 +#define ARCH_CPU_32_BITS 1 +#define ARCH_CPU_LITTLE_ENDIAN 1 +#elif defined(__ARMEL__) +#define ARCH_CPU_ARM_FAMILY 1 +#define ARCH_CPU_ARMEL 1 +#define ARCH_CPU_32_BITS 1 +#define ARCH_CPU_LITTLE_ENDIAN 1 +#elif defined(__aarch64__) +#define ARCH_CPU_ARM_FAMILY 1 +#define ARCH_CPU_ARM64 1 +#define ARCH_CPU_64_BITS 1 +#define ARCH_CPU_LITTLE_ENDIAN 1 +#elif defined(__pnacl__) +#define ARCH_CPU_32_BITS 1 +#define ARCH_CPU_LITTLE_ENDIAN 1 +#elif defined(__MIPSEL__) +#define ARCH_CPU_MIPS_FAMILY 1 +#define ARCH_CPU_MIPSEL 1 +#define ARCH_CPU_32_BITS 1 +#define ARCH_CPU_LITTLE_ENDIAN 1 +#else +#error Please add support for your architecture in cef_build.h +#endif + +// Type detection for wchar_t. +#if defined(OS_WIN) +#define WCHAR_T_IS_UTF16 +#elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \ + (__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff) +#define WCHAR_T_IS_UTF32 +#elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \ + (__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff) +// On Posix, we'll detect short wchar_t, but projects aren't guaranteed to +// compile in this mode (in particular, Chrome doesn't). This is intended for +// other projects using base who manage their own dependencies and make sure +// short wchar works for them. +#define WCHAR_T_IS_UTF16 +#else +#error Please add support for your compiler in cef_build.h +#endif + +// Annotate a function indicating the caller must examine the return value. +// Use like: +// int foo() WARN_UNUSED_RESULT; +// To explicitly ignore a result, see |ignore_result()| in . +#ifndef WARN_UNUSED_RESULT +#if defined(COMPILER_GCC) +#define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) +#else +#define WARN_UNUSED_RESULT +#endif +#endif // WARN_UNUSED_RESULT + +// Annotate a typedef or function indicating it's ok if it's not used. +// Use like: +// typedef Foo Bar ALLOW_UNUSED_TYPE; +#ifndef ALLOW_UNUSED_TYPE +#if defined(COMPILER_GCC) +#define ALLOW_UNUSED_TYPE __attribute__((unused)) +#else +#define ALLOW_UNUSED_TYPE +#endif +#endif // ALLOW_UNUSED_TYPE + +// Annotate a variable indicating it's ok if the variable is not used. +// (Typically used to silence a compiler warning when the assignment +// is important for some other reason.) +// Use like: +// int x = ...; +// ALLOW_UNUSED_LOCAL(x); +#ifndef ALLOW_UNUSED_LOCAL +#define ALLOW_UNUSED_LOCAL(x) false ? (void)x : (void)0 +#endif + +#endif // !USING_CHROMIUM_INCLUDES + +// Annotate a virtual method indicating it must be overriding a virtual method +// in the parent class. +// Use like: +// void foo() OVERRIDE; +// NOTE: This define should only be used in classes exposed to the client since +// C++11 support may not be enabled in client applications. CEF internal classes +// should use the `override` keyword directly. +#ifndef OVERRIDE +#if defined(__clang__) +#define OVERRIDE override +#elif defined(COMPILER_MSVC) && _MSC_VER >= 1600 +// Visual Studio 2010 and later support override. +#define OVERRIDE override +#elif defined(COMPILER_GCC) && __cplusplus >= 201103 && \ + (__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40700 +// GCC 4.7 supports explicit virtual overrides when C++11 support is enabled. +#define OVERRIDE override +#else +#define OVERRIDE +#endif +#endif // OVERRIDE + +// Check for C++11 template alias support which was added in VS2013 and GCC4.7. +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2258.pdf +#if __cplusplus > 199711L || (defined(_MSC_VER) && _MSC_VER >= 1800) || \ + (defined(__GNUC__) && \ + (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ >= 40700)) +#define HAS_CPP11_TEMPLATE_ALIAS_SUPPORT +#endif + +#endif // CEF_INCLUDE_BASE_CEF_BUILD_H_ diff --git a/include/base/cef_callback.h b/include/base/cef_callback.h new file mode 100644 index 0000000..16e238a --- /dev/null +++ b/include/base/cef_callback.h @@ -0,0 +1,801 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012 +// Google Inc. 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_BASE_CEF_CALLBACK_H_ +#define CEF_INCLUDE_BASE_CEF_CALLBACK_H_ +#pragma once + +#if defined(BASE_CALLBACK_H_) +// Do nothing if the Chromium header has already been included. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/callback.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include "include/base/cef_callback_forward.h" +#include "include/base/cef_template_util.h" +#include "include/base/internal/cef_callback_internal.h" + +// NOTE: Header files that do not require the full definition of Callback or +// Closure should #include "base/cef_callback_forward.h" instead of this file. + +// ----------------------------------------------------------------------------- +// Introduction +// ----------------------------------------------------------------------------- +// +// The templated Callback class is a generalized function object. Together +// with the Bind() function in bind.h, they provide a type-safe method for +// performing partial application of functions. +// +// Partial application (or "currying") is the process of binding a subset of +// a function's arguments to produce another function that takes fewer +// arguments. This can be used to pass around a unit of delayed execution, +// much like lexical closures are used in other languages. For example, it +// is used in Chromium code to schedule tasks on different MessageLoops. +// +// A callback with no unbound input parameters (base::Callback) +// is called a base::Closure. Note that this is NOT the same as what other +// languages refer to as a closure -- it does not retain a reference to its +// enclosing environment. +// +// MEMORY MANAGEMENT AND PASSING +// +// The Callback objects themselves should be passed by const-reference, and +// stored by copy. They internally store their state via a refcounted class +// and thus do not need to be deleted. +// +// The reason to pass via a const-reference is to avoid unnecessary +// AddRef/Release pairs to the internal state. +// +// +// ----------------------------------------------------------------------------- +// Quick reference for basic stuff +// ----------------------------------------------------------------------------- +// +// BINDING A BARE FUNCTION +// +// int Return5() { return 5; } +// base::Callback func_cb = base::Bind(&Return5); +// LOG(INFO) << func_cb.Run(); // Prints 5. +// +// BINDING A CLASS METHOD +// +// The first argument to bind is the member function to call, the second is +// the object on which to call it. +// +// class Ref : public base::RefCountedThreadSafe { +// public: +// int Foo() { return 3; } +// void PrintBye() { LOG(INFO) << "bye."; } +// }; +// scoped_refptr ref = new Ref(); +// base::Callback ref_cb = base::Bind(&Ref::Foo, ref); +// LOG(INFO) << ref_cb.Run(); // Prints out 3. +// +// By default the object must support RefCounted or you will get a compiler +// error. If you're passing between threads, be sure it's +// RefCountedThreadSafe! See "Advanced binding of member functions" below if +// you don't want to use reference counting. +// +// RUNNING A CALLBACK +// +// Callbacks can be run with their "Run" method, which has the same +// signature as the template argument to the callback. +// +// void DoSomething(const base::Callback& callback) { +// callback.Run(5, "hello"); +// } +// +// Callbacks can be run more than once (they don't get deleted or marked when +// run). However, this precludes using base::Passed (see below). +// +// void DoSomething(const base::Callback& callback) { +// double myresult = callback.Run(3.14159); +// myresult += callback.Run(2.71828); +// } +// +// PASSING UNBOUND INPUT PARAMETERS +// +// Unbound parameters are specified at the time a callback is Run(). They are +// specified in the Callback template type: +// +// void MyFunc(int i, const std::string& str) {} +// base::Callback cb = base::Bind(&MyFunc); +// cb.Run(23, "hello, world"); +// +// PASSING BOUND INPUT PARAMETERS +// +// Bound parameters are specified when you create thee callback as arguments +// to Bind(). They will be passed to the function and the Run()ner of the +// callback doesn't see those values or even know that the function it's +// calling. +// +// void MyFunc(int i, const std::string& str) {} +// base::Callback cb = base::Bind(&MyFunc, 23, "hello world"); +// cb.Run(); +// +// A callback with no unbound input parameters (base::Callback) +// is called a base::Closure. So we could have also written: +// +// base::Closure cb = base::Bind(&MyFunc, 23, "hello world"); +// +// When calling member functions, bound parameters just go after the object +// pointer. +// +// base::Closure cb = base::Bind(&MyClass::MyFunc, this, 23, "hello world"); +// +// PARTIAL BINDING OF PARAMETERS +// +// You can specify some parameters when you create the callback, and specify +// the rest when you execute the callback. +// +// void MyFunc(int i, const std::string& str) {} +// base::Callback cb = base::Bind(&MyFunc, 23); +// cb.Run("hello world"); +// +// When calling a function bound parameters are first, followed by unbound +// parameters. +// +// +// ----------------------------------------------------------------------------- +// Quick reference for advanced binding +// ----------------------------------------------------------------------------- +// +// BINDING A CLASS METHOD WITH WEAK POINTERS +// +// base::Bind(&MyClass::Foo, GetWeakPtr()); +// +// The callback will not be run if the object has already been destroyed. +// DANGER: weak pointers are not threadsafe, so don't use this +// when passing between threads! +// +// BINDING A CLASS METHOD WITH MANUAL LIFETIME MANAGEMENT +// +// base::Bind(&MyClass::Foo, base::Unretained(this)); +// +// This disables all lifetime management on the object. You're responsible +// for making sure the object is alive at the time of the call. You break it, +// you own it! +// +// BINDING A CLASS METHOD AND HAVING THE CALLBACK OWN THE CLASS +// +// MyClass* myclass = new MyClass; +// base::Bind(&MyClass::Foo, base::Owned(myclass)); +// +// The object will be deleted when the callback is destroyed, even if it's +// not run (like if you post a task during shutdown). Potentially useful for +// "fire and forget" cases. +// +// IGNORING RETURN VALUES +// +// Sometimes you want to call a function that returns a value in a callback +// that doesn't expect a return value. +// +// int DoSomething(int arg) { cout << arg << endl; } +// base::Callback) cb = +// base::Bind(base::IgnoreResult(&DoSomething)); +// +// +// ----------------------------------------------------------------------------- +// Quick reference for binding parameters to Bind() +// ----------------------------------------------------------------------------- +// +// Bound parameters are specified as arguments to Bind() and are passed to the +// function. A callback with no parameters or no unbound parameters is called a +// Closure (base::Callback and base::Closure are the same thing). +// +// PASSING PARAMETERS OWNED BY THE CALLBACK +// +// void Foo(int* arg) { cout << *arg << endl; } +// int* pn = new int(1); +// base::Closure foo_callback = base::Bind(&foo, base::Owned(pn)); +// +// The parameter will be deleted when the callback is destroyed, even if it's +// not run (like if you post a task during shutdown). +// +// PASSING PARAMETERS AS A scoped_ptr +// +// void TakesOwnership(scoped_ptr arg) {} +// scoped_ptr f(new Foo); +// // f becomes null during the following call. +// base::Closure cb = base::Bind(&TakesOwnership, base::Passed(&f)); +// +// Ownership of the parameter will be with the callback until the it is run, +// when ownership is passed to the callback function. This means the callback +// can only be run once. If the callback is never run, it will delete the +// object when it's destroyed. +// +// PASSING PARAMETERS AS A scoped_refptr +// +// void TakesOneRef(scoped_refptr arg) {} +// scoped_refptr f(new Foo) +// base::Closure cb = base::Bind(&TakesOneRef, f); +// +// This should "just work." The closure will take a reference as long as it +// is alive, and another reference will be taken for the called function. +// +// PASSING PARAMETERS BY REFERENCE +// +// Const references are *copied* unless ConstRef is used. Example: +// +// void foo(const int& arg) { printf("%d %p\n", arg, &arg); } +// int n = 1; +// base::Closure has_copy = base::Bind(&foo, n); +// base::Closure has_ref = base::Bind(&foo, base::ConstRef(n)); +// n = 2; +// foo(n); // Prints "2 0xaaaaaaaaaaaa" +// has_copy.Run(); // Prints "1 0xbbbbbbbbbbbb" +// has_ref.Run(); // Prints "2 0xaaaaaaaaaaaa" +// +// Normally parameters are copied in the closure. DANGER: ConstRef stores a +// const reference instead, referencing the original parameter. This means +// that you must ensure the object outlives the callback! +// +// +// ----------------------------------------------------------------------------- +// Implementation notes +// ----------------------------------------------------------------------------- +// +// WHERE IS THIS DESIGN FROM: +// +// The design Callback and Bind is heavily influenced by C++'s +// tr1::function/tr1::bind, and by the "Google Callback" system used inside +// Google. +// +// +// HOW THE IMPLEMENTATION WORKS: +// +// There are three main components to the system: +// 1) The Callback classes. +// 2) The Bind() functions. +// 3) The arguments wrappers (e.g., Unretained() and ConstRef()). +// +// The Callback classes represent a generic function pointer. Internally, +// it stores a refcounted piece of state that represents the target function +// and all its bound parameters. Each Callback specialization has a templated +// constructor that takes an BindState<>*. In the context of the constructor, +// the static type of this BindState<> pointer uniquely identifies the +// function it is representing, all its bound parameters, and a Run() method +// that is capable of invoking the target. +// +// Callback's constructor takes the BindState<>* that has the full static type +// and erases the target function type as well as the types of the bound +// parameters. It does this by storing a pointer to the specific Run() +// function, and upcasting the state of BindState<>* to a +// BindStateBase*. This is safe as long as this BindStateBase pointer +// is only used with the stored Run() pointer. +// +// To BindState<> objects are created inside the Bind() functions. +// These functions, along with a set of internal templates, are responsible for +// +// - Unwrapping the function signature into return type, and parameters +// - Determining the number of parameters that are bound +// - Creating the BindState storing the bound parameters +// - Performing compile-time asserts to avoid error-prone behavior +// - Returning an Callback<> with an arity matching the number of unbound +// parameters and that knows the correct refcounting semantics for the +// target object if we are binding a method. +// +// The Bind functions do the above using type-inference, and template +// specializations. +// +// By default Bind() will store copies of all bound parameters, and attempt +// to refcount a target object if the function being bound is a class method. +// These copies are created even if the function takes parameters as const +// references. (Binding to non-const references is forbidden, see bind.h.) +// +// To change this behavior, we introduce a set of argument wrappers +// (e.g., Unretained(), and ConstRef()). These are simple container templates +// that are passed by value, and wrap a pointer to argument. See the +// file-level comment in base/bind_helpers.h for more info. +// +// These types are passed to the Unwrap() functions, and the MaybeRefcount() +// functions respectively to modify the behavior of Bind(). The Unwrap() +// and MaybeRefcount() functions change behavior by doing partial +// specialization based on whether or not a parameter is a wrapper type. +// +// ConstRef() is similar to tr1::cref. Unretained() is specific to Chromium. +// +// +// WHY NOT TR1 FUNCTION/BIND? +// +// Direct use of tr1::function and tr1::bind was considered, but ultimately +// rejected because of the number of copy constructors invocations involved +// in the binding of arguments during construction, and the forwarding of +// arguments during invocation. These copies will no longer be an issue in +// C++0x because C++0x will support rvalue reference allowing for the compiler +// to avoid these copies. However, waiting for C++0x is not an option. +// +// Measured with valgrind on gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5), the +// tr1::bind call itself will invoke a non-trivial copy constructor three times +// for each bound parameter. Also, each when passing a tr1::function, each +// bound argument will be copied again. +// +// In addition to the copies taken at binding and invocation, copying a +// tr1::function causes a copy to be made of all the bound parameters and +// state. +// +// Furthermore, in Chromium, it is desirable for the Callback to take a +// reference on a target object when representing a class method call. This +// is not supported by tr1. +// +// Lastly, tr1::function and tr1::bind has a more general and flexible API. +// This includes things like argument reordering by use of +// tr1::bind::placeholder, support for non-const reference parameters, and some +// limited amount of subtyping of the tr1::function object (e.g., +// tr1::function is convertible to tr1::function). +// +// These are not features that are required in Chromium. Some of them, such as +// allowing for reference parameters, and subtyping of functions, may actually +// become a source of errors. Removing support for these features actually +// allows for a simpler implementation, and a terser Currying API. +// +// +// WHY NOT GOOGLE CALLBACKS? +// +// The Google callback system also does not support refcounting. Furthermore, +// its implementation has a number of strange edge cases with respect to type +// conversion of its arguments. In particular, the argument's constness must +// at times match exactly the function signature, or the type-inference might +// break. Given the above, writing a custom solution was easier. +// +// +// MISSING FUNCTIONALITY +// - Invoking the return of Bind. Bind(&foo).Run() does not work; +// - Binding arrays to functions that take a non-const pointer. +// Example: +// void Foo(const char* ptr); +// void Bar(char* ptr); +// Bind(&Foo, "test"); +// Bind(&Bar, "test"); // This fails because ptr is not const. + +namespace base { + +// First, we forward declare the Callback class template. This informs the +// compiler that the template only has 1 type parameter which is the function +// signature that the Callback is representing. +// +// After this, create template specializations for 0-7 parameters. Note that +// even though the template typelist grows, the specialization still +// only has one type: the function signature. +// +// If you are thinking of forward declaring Callback in your own header file, +// please include "base/callback_forward.h" instead. +template +class Callback; + +namespace cef_internal { +template +struct BindState; +} // namespace cef_internal + +template +class Callback : public cef_internal::CallbackBase { + public: + typedef R(RunType)(); + + Callback() : CallbackBase(NULL) {} + + // Note that this constructor CANNOT be explicit, and that Bind() CANNOT + // return the exact Callback<> type. See base/bind.h for details. + template + Callback( + cef_internal::BindState* bind_state) + : CallbackBase(bind_state) { + // Force the assignment to a local variable of PolymorphicInvoke + // so the compiler will typecheck that the passed in Run() method has + // the correct type. + PolymorphicInvoke invoke_func = + &cef_internal::BindState::InvokerType::Run; + polymorphic_invoke_ = reinterpret_cast(invoke_func); + } + + bool Equals(const Callback& other) const { + return CallbackBase::Equals(other); + } + + R Run() const { + PolymorphicInvoke f = + reinterpret_cast(polymorphic_invoke_); + + return f(bind_state_.get()); + } + + private: + typedef R (*PolymorphicInvoke)(cef_internal::BindStateBase*); +}; + +template +class Callback : public cef_internal::CallbackBase { + public: + typedef R(RunType)(A1); + + Callback() : CallbackBase(NULL) {} + + // Note that this constructor CANNOT be explicit, and that Bind() CANNOT + // return the exact Callback<> type. See base/bind.h for details. + template + Callback( + cef_internal::BindState* bind_state) + : CallbackBase(bind_state) { + // Force the assignment to a local variable of PolymorphicInvoke + // so the compiler will typecheck that the passed in Run() method has + // the correct type. + PolymorphicInvoke invoke_func = + &cef_internal::BindState::InvokerType::Run; + polymorphic_invoke_ = reinterpret_cast(invoke_func); + } + + bool Equals(const Callback& other) const { + return CallbackBase::Equals(other); + } + + R Run(typename cef_internal::CallbackParamTraits::ForwardType a1) const { + PolymorphicInvoke f = + reinterpret_cast(polymorphic_invoke_); + + return f(bind_state_.get(), cef_internal::CallbackForward(a1)); + } + + private: + typedef R (*PolymorphicInvoke)( + cef_internal::BindStateBase*, + typename cef_internal::CallbackParamTraits::ForwardType); +}; + +template +class Callback : public cef_internal::CallbackBase { + public: + typedef R(RunType)(A1, A2); + + Callback() : CallbackBase(NULL) {} + + // Note that this constructor CANNOT be explicit, and that Bind() CANNOT + // return the exact Callback<> type. See base/bind.h for details. + template + Callback( + cef_internal::BindState* bind_state) + : CallbackBase(bind_state) { + // Force the assignment to a local variable of PolymorphicInvoke + // so the compiler will typecheck that the passed in Run() method has + // the correct type. + PolymorphicInvoke invoke_func = + &cef_internal::BindState::InvokerType::Run; + polymorphic_invoke_ = reinterpret_cast(invoke_func); + } + + bool Equals(const Callback& other) const { + return CallbackBase::Equals(other); + } + + R Run(typename cef_internal::CallbackParamTraits::ForwardType a1, + typename cef_internal::CallbackParamTraits::ForwardType a2) const { + PolymorphicInvoke f = + reinterpret_cast(polymorphic_invoke_); + + return f(bind_state_.get(), cef_internal::CallbackForward(a1), + cef_internal::CallbackForward(a2)); + } + + private: + typedef R (*PolymorphicInvoke)( + cef_internal::BindStateBase*, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType); +}; + +template +class Callback : public cef_internal::CallbackBase { + public: + typedef R(RunType)(A1, A2, A3); + + Callback() : CallbackBase(NULL) {} + + // Note that this constructor CANNOT be explicit, and that Bind() CANNOT + // return the exact Callback<> type. See base/bind.h for details. + template + Callback( + cef_internal::BindState* bind_state) + : CallbackBase(bind_state) { + // Force the assignment to a local variable of PolymorphicInvoke + // so the compiler will typecheck that the passed in Run() method has + // the correct type. + PolymorphicInvoke invoke_func = + &cef_internal::BindState::InvokerType::Run; + polymorphic_invoke_ = reinterpret_cast(invoke_func); + } + + bool Equals(const Callback& other) const { + return CallbackBase::Equals(other); + } + + R Run(typename cef_internal::CallbackParamTraits::ForwardType a1, + typename cef_internal::CallbackParamTraits::ForwardType a2, + typename cef_internal::CallbackParamTraits::ForwardType a3) const { + PolymorphicInvoke f = + reinterpret_cast(polymorphic_invoke_); + + return f(bind_state_.get(), cef_internal::CallbackForward(a1), + cef_internal::CallbackForward(a2), + cef_internal::CallbackForward(a3)); + } + + private: + typedef R (*PolymorphicInvoke)( + cef_internal::BindStateBase*, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType); +}; + +template +class Callback : public cef_internal::CallbackBase { + public: + typedef R(RunType)(A1, A2, A3, A4); + + Callback() : CallbackBase(NULL) {} + + // Note that this constructor CANNOT be explicit, and that Bind() CANNOT + // return the exact Callback<> type. See base/bind.h for details. + template + Callback( + cef_internal::BindState* bind_state) + : CallbackBase(bind_state) { + // Force the assignment to a local variable of PolymorphicInvoke + // so the compiler will typecheck that the passed in Run() method has + // the correct type. + PolymorphicInvoke invoke_func = + &cef_internal::BindState::InvokerType::Run; + polymorphic_invoke_ = reinterpret_cast(invoke_func); + } + + bool Equals(const Callback& other) const { + return CallbackBase::Equals(other); + } + + R Run(typename cef_internal::CallbackParamTraits::ForwardType a1, + typename cef_internal::CallbackParamTraits::ForwardType a2, + typename cef_internal::CallbackParamTraits::ForwardType a3, + typename cef_internal::CallbackParamTraits::ForwardType a4) const { + PolymorphicInvoke f = + reinterpret_cast(polymorphic_invoke_); + + return f(bind_state_.get(), cef_internal::CallbackForward(a1), + cef_internal::CallbackForward(a2), + cef_internal::CallbackForward(a3), + cef_internal::CallbackForward(a4)); + } + + private: + typedef R (*PolymorphicInvoke)( + cef_internal::BindStateBase*, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType); +}; + +template +class Callback : public cef_internal::CallbackBase { + public: + typedef R(RunType)(A1, A2, A3, A4, A5); + + Callback() : CallbackBase(NULL) {} + + // Note that this constructor CANNOT be explicit, and that Bind() CANNOT + // return the exact Callback<> type. See base/bind.h for details. + template + Callback( + cef_internal::BindState* bind_state) + : CallbackBase(bind_state) { + // Force the assignment to a local variable of PolymorphicInvoke + // so the compiler will typecheck that the passed in Run() method has + // the correct type. + PolymorphicInvoke invoke_func = + &cef_internal::BindState::InvokerType::Run; + polymorphic_invoke_ = reinterpret_cast(invoke_func); + } + + bool Equals(const Callback& other) const { + return CallbackBase::Equals(other); + } + + R Run(typename cef_internal::CallbackParamTraits::ForwardType a1, + typename cef_internal::CallbackParamTraits::ForwardType a2, + typename cef_internal::CallbackParamTraits::ForwardType a3, + typename cef_internal::CallbackParamTraits::ForwardType a4, + typename cef_internal::CallbackParamTraits::ForwardType a5) const { + PolymorphicInvoke f = + reinterpret_cast(polymorphic_invoke_); + + return f( + bind_state_.get(), cef_internal::CallbackForward(a1), + cef_internal::CallbackForward(a2), cef_internal::CallbackForward(a3), + cef_internal::CallbackForward(a4), cef_internal::CallbackForward(a5)); + } + + private: + typedef R (*PolymorphicInvoke)( + cef_internal::BindStateBase*, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType); +}; + +template +class Callback : public cef_internal::CallbackBase { + public: + typedef R(RunType)(A1, A2, A3, A4, A5, A6); + + Callback() : CallbackBase(NULL) {} + + // Note that this constructor CANNOT be explicit, and that Bind() CANNOT + // return the exact Callback<> type. See base/bind.h for details. + template + Callback( + cef_internal::BindState* bind_state) + : CallbackBase(bind_state) { + // Force the assignment to a local variable of PolymorphicInvoke + // so the compiler will typecheck that the passed in Run() method has + // the correct type. + PolymorphicInvoke invoke_func = + &cef_internal::BindState::InvokerType::Run; + polymorphic_invoke_ = reinterpret_cast(invoke_func); + } + + bool Equals(const Callback& other) const { + return CallbackBase::Equals(other); + } + + R Run(typename cef_internal::CallbackParamTraits::ForwardType a1, + typename cef_internal::CallbackParamTraits::ForwardType a2, + typename cef_internal::CallbackParamTraits::ForwardType a3, + typename cef_internal::CallbackParamTraits::ForwardType a4, + typename cef_internal::CallbackParamTraits::ForwardType a5, + typename cef_internal::CallbackParamTraits::ForwardType a6) const { + PolymorphicInvoke f = + reinterpret_cast(polymorphic_invoke_); + + return f( + bind_state_.get(), cef_internal::CallbackForward(a1), + cef_internal::CallbackForward(a2), cef_internal::CallbackForward(a3), + cef_internal::CallbackForward(a4), cef_internal::CallbackForward(a5), + cef_internal::CallbackForward(a6)); + } + + private: + typedef R (*PolymorphicInvoke)( + cef_internal::BindStateBase*, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType); +}; + +template +class Callback + : public cef_internal::CallbackBase { + public: + typedef R(RunType)(A1, A2, A3, A4, A5, A6, A7); + + Callback() : CallbackBase(NULL) {} + + // Note that this constructor CANNOT be explicit, and that Bind() CANNOT + // return the exact Callback<> type. See base/bind.h for details. + template + Callback( + cef_internal::BindState* bind_state) + : CallbackBase(bind_state) { + // Force the assignment to a local variable of PolymorphicInvoke + // so the compiler will typecheck that the passed in Run() method has + // the correct type. + PolymorphicInvoke invoke_func = + &cef_internal::BindState::InvokerType::Run; + polymorphic_invoke_ = reinterpret_cast(invoke_func); + } + + bool Equals(const Callback& other) const { + return CallbackBase::Equals(other); + } + + R Run(typename cef_internal::CallbackParamTraits::ForwardType a1, + typename cef_internal::CallbackParamTraits::ForwardType a2, + typename cef_internal::CallbackParamTraits::ForwardType a3, + typename cef_internal::CallbackParamTraits::ForwardType a4, + typename cef_internal::CallbackParamTraits::ForwardType a5, + typename cef_internal::CallbackParamTraits::ForwardType a6, + typename cef_internal::CallbackParamTraits::ForwardType a7) const { + PolymorphicInvoke f = + reinterpret_cast(polymorphic_invoke_); + + return f( + bind_state_.get(), cef_internal::CallbackForward(a1), + cef_internal::CallbackForward(a2), cef_internal::CallbackForward(a3), + cef_internal::CallbackForward(a4), cef_internal::CallbackForward(a5), + cef_internal::CallbackForward(a6), cef_internal::CallbackForward(a7)); + } + + private: + typedef R (*PolymorphicInvoke)( + cef_internal::BindStateBase*, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType); +}; + +// Syntactic sugar to make Callbacks easier to declare since it +// will be used in a lot of APIs with delayed execution. +typedef Callback Closure; + +} // namespace base + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_CALLBACK_H_ diff --git a/include/base/cef_callback_forward.h b/include/base/cef_callback_forward.h new file mode 100644 index 0000000..d604d7c --- /dev/null +++ b/include/base/cef_callback_forward.h @@ -0,0 +1,59 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011 +// Google Inc. 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 INCLUDE_BASE_CEF_CALLBACK_FORWARD_H_ +#define INCLUDE_BASE_CEF_CALLBACK_FORWARD_H_ +#pragma once + +#if defined(BASE_CALLBACK_FORWARD_H_) +// Do nothing if the Chromium header has already been included. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/callback_forward.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +namespace base { + +template +class Callback; + +typedef Callback Closure; + +} // namespace base + +#endif // !!USING_CHROMIUM_INCLUDES + +#endif // INCLUDE_BASE_CEF_CALLBACK_FORWARD_H_ diff --git a/include/base/cef_callback_helpers.h b/include/base/cef_callback_helpers.h new file mode 100644 index 0000000..ebe074a --- /dev/null +++ b/include/base/cef_callback_helpers.h @@ -0,0 +1,93 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012 +// Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// This defines helpful methods for dealing with Callbacks. Because Callbacks +// are implemented using templates, with a class per callback signature, adding +// methods to Callback<> itself is unattractive (lots of extra code gets +// generated). Instead, consider adding methods here. +// +// ResetAndReturn(&cb) is like cb.Reset() but allows executing a callback (via a +// copy) after the original callback is Reset(). This can be handy if Run() +// reads/writes the variable holding the Callback. + +#ifndef CEF_INCLUDE_BASE_CEF_CALLBACK_HELPERS_H_ +#define CEF_INCLUDE_BASE_CEF_CALLBACK_HELPERS_H_ +#pragma once + +#if defined(BASE_CALLBACK_HELPERS_H_) +// Do nothing if the Chromium header has already been included. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/callback_helpers.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include "include/base/cef_basictypes.h" +#include "include/base/cef_build.h" +#include "include/base/cef_callback.h" +#include "include/base/cef_macros.h" + +namespace base { + +template +base::Callback ResetAndReturn(base::Callback* cb) { + base::Callback ret(*cb); + cb->Reset(); + return ret; +} + +// ScopedClosureRunner is akin to scoped_ptr for Closures. It ensures that the +// Closure is executed and deleted no matter how the current scope exits. +class ScopedClosureRunner { + public: + ScopedClosureRunner(); + explicit ScopedClosureRunner(const Closure& closure); + ~ScopedClosureRunner(); + + void Reset(); + void Reset(const Closure& closure); + Closure Release() WARN_UNUSED_RESULT; + + private: + Closure closure_; + + DISALLOW_COPY_AND_ASSIGN(ScopedClosureRunner); +}; + +} // namespace base + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_CALLBACK_HELPERS_H_ diff --git a/include/base/cef_callback_list.h b/include/base/cef_callback_list.h new file mode 100644 index 0000000..e0ef366 --- /dev/null +++ b/include/base/cef_callback_list.h @@ -0,0 +1,449 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2013 +// Google Inc. 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_BASE_CEF_CALLBACK_LIST_H_ +#define CEF_INCLUDE_BASE_CEF_CALLBACK_LIST_H_ +#pragma once + +#if defined(BASE_CALLBACK_LIST_H_) +// Do nothing if the Chromium header has already been included. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/callback_list.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include + +#include "include/base/cef_basictypes.h" +#include "include/base/cef_build.h" +#include "include/base/cef_callback.h" +#include "include/base/cef_logging.h" +#include "include/base/cef_macros.h" +#include "include/base/cef_scoped_ptr.h" +#include "include/base/internal/cef_callback_internal.h" + +// OVERVIEW: +// +// A container for a list of callbacks. Unlike a normal STL vector or list, +// this container can be modified during iteration without invalidating the +// iterator. It safely handles the case of a callback removing itself +// or another callback from the list while callbacks are being run. +// +// TYPICAL USAGE: +// +// class MyWidget { +// public: +// ... +// +// typedef base::Callback OnFooCallback; +// +// scoped_ptr::Subscription> +// RegisterCallback(const OnFooCallback& cb) { +// return callback_list_.Add(cb); +// } +// +// private: +// void NotifyFoo(const Foo& foo) { +// callback_list_.Notify(foo); +// } +// +// base::CallbackList callback_list_; +// +// DISALLOW_COPY_AND_ASSIGN(MyWidget); +// }; +// +// +// class MyWidgetListener { +// public: +// MyWidgetListener::MyWidgetListener() { +// foo_subscription_ = MyWidget::GetCurrent()->RegisterCallback( +// base::Bind(&MyWidgetListener::OnFoo, this))); +// } +// +// MyWidgetListener::~MyWidgetListener() { +// // Subscription gets deleted automatically and will deregister +// // the callback in the process. +// } +// +// private: +// void OnFoo(const Foo& foo) { +// // Do something. +// } +// +// scoped_ptr::Subscription> +// foo_subscription_; +// +// DISALLOW_COPY_AND_ASSIGN(MyWidgetListener); +// }; + +namespace base { + +namespace cef_internal { + +template +class CallbackListBase { + public: + class Subscription { + public: + Subscription(CallbackListBase* list, + typename std::list::iterator iter) + : list_(list), iter_(iter) {} + + ~Subscription() { + if (list_->active_iterator_count_) { + iter_->Reset(); + } else { + list_->callbacks_.erase(iter_); + if (!list_->removal_callback_.is_null()) + list_->removal_callback_.Run(); + } + } + + private: + CallbackListBase* list_; + typename std::list::iterator iter_; + + DISALLOW_COPY_AND_ASSIGN(Subscription); + }; + + // Add a callback to the list. The callback will remain registered until the + // returned Subscription is destroyed, which must occur before the + // CallbackList is destroyed. + scoped_ptr Add(const CallbackType& cb) WARN_UNUSED_RESULT { + DCHECK(!cb.is_null()); + return scoped_ptr( + new Subscription(this, callbacks_.insert(callbacks_.end(), cb))); + } + + // Sets a callback which will be run when a subscription list is changed. + void set_removal_callback(const Closure& callback) { + removal_callback_ = callback; + } + + // Returns true if there are no subscriptions. This is only valid to call when + // not looping through the list. + bool empty() { + DCHECK_EQ(0, active_iterator_count_); + return callbacks_.empty(); + } + + protected: + // An iterator class that can be used to access the list of callbacks. + class Iterator { + public: + explicit Iterator(CallbackListBase* list) + : list_(list), list_iter_(list_->callbacks_.begin()) { + ++list_->active_iterator_count_; + } + + Iterator(const Iterator& iter) + : list_(iter.list_), list_iter_(iter.list_iter_) { + ++list_->active_iterator_count_; + } + + ~Iterator() { + if (list_ && --list_->active_iterator_count_ == 0) { + list_->Compact(); + } + } + + CallbackType* GetNext() { + while ((list_iter_ != list_->callbacks_.end()) && list_iter_->is_null()) + ++list_iter_; + + CallbackType* cb = NULL; + if (list_iter_ != list_->callbacks_.end()) { + cb = &(*list_iter_); + ++list_iter_; + } + return cb; + } + + private: + CallbackListBase* list_; + typename std::list::iterator list_iter_; + }; + + CallbackListBase() : active_iterator_count_(0) {} + + ~CallbackListBase() { + DCHECK_EQ(0, active_iterator_count_); + DCHECK_EQ(0U, callbacks_.size()); + } + + // Returns an instance of a CallbackListBase::Iterator which can be used + // to run callbacks. + Iterator GetIterator() { return Iterator(this); } + + // Compact the list: remove any entries which were NULLed out during + // iteration. + void Compact() { + typename std::list::iterator it = callbacks_.begin(); + bool updated = false; + while (it != callbacks_.end()) { + if ((*it).is_null()) { + updated = true; + it = callbacks_.erase(it); + } else { + ++it; + } + + if (updated && !removal_callback_.is_null()) + removal_callback_.Run(); + } + } + + private: + std::list callbacks_; + int active_iterator_count_; + Closure removal_callback_; + + DISALLOW_COPY_AND_ASSIGN(CallbackListBase); +}; + +} // namespace cef_internal + +template +class CallbackList; + +template <> +class CallbackList + : public cef_internal::CallbackListBase> { + public: + typedef Callback CallbackType; + + CallbackList() {} + + void Notify() { + cef_internal::CallbackListBase::Iterator it = + this->GetIterator(); + CallbackType* cb; + while ((cb = it.GetNext()) != NULL) { + cb->Run(); + } + } + + private: + DISALLOW_COPY_AND_ASSIGN(CallbackList); +}; + +template +class CallbackList + : public cef_internal::CallbackListBase> { + public: + typedef Callback CallbackType; + + CallbackList() {} + + void Notify(typename cef_internal::CallbackParamTraits::ForwardType a1) { + typename cef_internal::CallbackListBase::Iterator it = + this->GetIterator(); + CallbackType* cb; + while ((cb = it.GetNext()) != NULL) { + cb->Run(a1); + } + } + + private: + DISALLOW_COPY_AND_ASSIGN(CallbackList); +}; + +template +class CallbackList + : public cef_internal::CallbackListBase> { + public: + typedef Callback CallbackType; + + CallbackList() {} + + void Notify(typename cef_internal::CallbackParamTraits::ForwardType a1, + typename cef_internal::CallbackParamTraits::ForwardType a2) { + typename cef_internal::CallbackListBase::Iterator it = + this->GetIterator(); + CallbackType* cb; + while ((cb = it.GetNext()) != NULL) { + cb->Run(a1, a2); + } + } + + private: + DISALLOW_COPY_AND_ASSIGN(CallbackList); +}; + +template +class CallbackList + : public cef_internal::CallbackListBase> { + public: + typedef Callback CallbackType; + + CallbackList() {} + + void Notify(typename cef_internal::CallbackParamTraits::ForwardType a1, + typename cef_internal::CallbackParamTraits::ForwardType a2, + typename cef_internal::CallbackParamTraits::ForwardType a3) { + typename cef_internal::CallbackListBase::Iterator it = + this->GetIterator(); + CallbackType* cb; + while ((cb = it.GetNext()) != NULL) { + cb->Run(a1, a2, a3); + } + } + + private: + DISALLOW_COPY_AND_ASSIGN(CallbackList); +}; + +template +class CallbackList + : public cef_internal::CallbackListBase> { + public: + typedef Callback CallbackType; + + CallbackList() {} + + void Notify(typename cef_internal::CallbackParamTraits::ForwardType a1, + typename cef_internal::CallbackParamTraits::ForwardType a2, + typename cef_internal::CallbackParamTraits::ForwardType a3, + typename cef_internal::CallbackParamTraits::ForwardType a4) { + typename cef_internal::CallbackListBase::Iterator it = + this->GetIterator(); + CallbackType* cb; + while ((cb = it.GetNext()) != NULL) { + cb->Run(a1, a2, a3, a4); + } + } + + private: + DISALLOW_COPY_AND_ASSIGN(CallbackList); +}; + +template +class CallbackList + : public cef_internal::CallbackListBase< + Callback> { + public: + typedef Callback CallbackType; + + CallbackList() {} + + void Notify(typename cef_internal::CallbackParamTraits::ForwardType a1, + typename cef_internal::CallbackParamTraits::ForwardType a2, + typename cef_internal::CallbackParamTraits::ForwardType a3, + typename cef_internal::CallbackParamTraits::ForwardType a4, + typename cef_internal::CallbackParamTraits::ForwardType a5) { + typename cef_internal::CallbackListBase::Iterator it = + this->GetIterator(); + CallbackType* cb; + while ((cb = it.GetNext()) != NULL) { + cb->Run(a1, a2, a3, a4, a5); + } + } + + private: + DISALLOW_COPY_AND_ASSIGN(CallbackList); +}; + +template +class CallbackList + : public cef_internal::CallbackListBase< + Callback> { + public: + typedef Callback CallbackType; + + CallbackList() {} + + void Notify(typename cef_internal::CallbackParamTraits::ForwardType a1, + typename cef_internal::CallbackParamTraits::ForwardType a2, + typename cef_internal::CallbackParamTraits::ForwardType a3, + typename cef_internal::CallbackParamTraits::ForwardType a4, + typename cef_internal::CallbackParamTraits::ForwardType a5, + typename cef_internal::CallbackParamTraits::ForwardType a6) { + typename cef_internal::CallbackListBase::Iterator it = + this->GetIterator(); + CallbackType* cb; + while ((cb = it.GetNext()) != NULL) { + cb->Run(a1, a2, a3, a4, a5, a6); + } + } + + private: + DISALLOW_COPY_AND_ASSIGN(CallbackList); +}; + +template +class CallbackList + : public cef_internal::CallbackListBase< + Callback> { + public: + typedef Callback CallbackType; + + CallbackList() {} + + void Notify(typename cef_internal::CallbackParamTraits::ForwardType a1, + typename cef_internal::CallbackParamTraits::ForwardType a2, + typename cef_internal::CallbackParamTraits::ForwardType a3, + typename cef_internal::CallbackParamTraits::ForwardType a4, + typename cef_internal::CallbackParamTraits::ForwardType a5, + typename cef_internal::CallbackParamTraits::ForwardType a6, + typename cef_internal::CallbackParamTraits::ForwardType a7) { + typename cef_internal::CallbackListBase::Iterator it = + this->GetIterator(); + CallbackType* cb; + while ((cb = it.GetNext()) != NULL) { + cb->Run(a1, a2, a3, a4, a5, a6, a7); + } + } + + private: + DISALLOW_COPY_AND_ASSIGN(CallbackList); +}; + +} // namespace base + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_CALLBACK_LIST_H_ diff --git a/include/base/cef_cancelable_callback.h b/include/base/cef_cancelable_callback.h new file mode 100644 index 0000000..febce3a --- /dev/null +++ b/include/base/cef_cancelable_callback.h @@ -0,0 +1,293 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011 +// Google Inc. 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. +// +// CancelableCallback is a wrapper around base::Callback that allows +// cancellation of a callback. CancelableCallback takes a reference on the +// wrapped callback until this object is destroyed or Reset()/Cancel() are +// called. +// +// NOTE: +// +// Calling CancelableCallback::Cancel() brings the object back to its natural, +// default-constructed state, i.e., CancelableCallback::callback() will return +// a null callback. +// +// THREAD-SAFETY: +// +// CancelableCallback objects must be created on, posted to, cancelled on, and +// destroyed on the same thread. +// +// +// EXAMPLE USAGE: +// +// In the following example, the test is verifying that RunIntensiveTest() +// Quit()s the message loop within 4 seconds. The cancelable callback is posted +// to the message loop, the intensive test runs, the message loop is run, +// then the callback is cancelled. +// +// void TimeoutCallback(const std::string& timeout_message) { +// FAIL() << timeout_message; +// MessageLoop::current()->QuitWhenIdle(); +// } +// +// CancelableClosure timeout(base::Bind(&TimeoutCallback, "Test timed out.")); +// MessageLoop::current()->PostDelayedTask(FROM_HERE, timeout.callback(), +// 4000) // 4 seconds to run. +// RunIntensiveTest(); +// MessageLoop::current()->Run(); +// timeout.Cancel(); // Hopefully this is hit before the timeout callback runs. +// + +#ifndef CEF_INCLUDE_BASE_CEF_CANCELABLE_CALLBACK_H_ +#define CEF_INCLUDE_BASE_CEF_CANCELABLE_CALLBACK_H_ +#pragma once + +#if defined(BASE_CANCELABLE_CALLBACK_H_) +// Do nothing if the Chromium header has already been included. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/cancelable_callback.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include "include/base/cef_bind.h" +#include "include/base/cef_build.h" +#include "include/base/cef_callback.h" +#include "include/base/cef_logging.h" +#include "include/base/cef_macros.h" +#include "include/base/cef_weak_ptr.h" +#include "include/base/internal/cef_callback_internal.h" + +namespace base { + +template +class CancelableCallback; + +template <> +class CancelableCallback { + public: + CancelableCallback() : weak_factory_(this) {} + + // |callback| must not be null. + explicit CancelableCallback(const base::Callback& callback) + : weak_factory_(this), callback_(callback) { + DCHECK(!callback.is_null()); + InitializeForwarder(); + } + + ~CancelableCallback() {} + + // Cancels and drops the reference to the wrapped callback. + void Cancel() { + weak_factory_.InvalidateWeakPtrs(); + forwarder_.Reset(); + callback_.Reset(); + } + + // Returns true if the wrapped callback has been cancelled. + bool IsCancelled() const { return callback_.is_null(); } + + // Sets |callback| as the closure that may be cancelled. |callback| may not + // be null. Outstanding and any previously wrapped callbacks are cancelled. + void Reset(const base::Callback& callback) { + DCHECK(!callback.is_null()); + + // Outstanding tasks (e.g., posted to a message loop) must not be called. + Cancel(); + + // |forwarder_| is no longer valid after Cancel(), so re-bind. + InitializeForwarder(); + + callback_ = callback; + } + + // Returns a callback that can be disabled by calling Cancel(). + const base::Callback& callback() const { return forwarder_; } + + private: + void Forward() { callback_.Run(); } + + // Helper method to bind |forwarder_| using a weak pointer from + // |weak_factory_|. + void InitializeForwarder() { + forwarder_ = base::Bind(&CancelableCallback::Forward, + weak_factory_.GetWeakPtr()); + } + + // Used to ensure Forward() is not run when this object is destroyed. + base::WeakPtrFactory> weak_factory_; + + // The wrapper closure. + base::Callback forwarder_; + + // The stored closure that may be cancelled. + base::Callback callback_; + + DISALLOW_COPY_AND_ASSIGN(CancelableCallback); +}; + +template +class CancelableCallback { + public: + CancelableCallback() : weak_factory_(this) {} + + // |callback| must not be null. + explicit CancelableCallback(const base::Callback& callback) + : weak_factory_(this), callback_(callback) { + DCHECK(!callback.is_null()); + InitializeForwarder(); + } + + ~CancelableCallback() {} + + // Cancels and drops the reference to the wrapped callback. + void Cancel() { + weak_factory_.InvalidateWeakPtrs(); + forwarder_.Reset(); + callback_.Reset(); + } + + // Returns true if the wrapped callback has been cancelled. + bool IsCancelled() const { return callback_.is_null(); } + + // Sets |callback| as the closure that may be cancelled. |callback| may not + // be null. Outstanding and any previously wrapped callbacks are cancelled. + void Reset(const base::Callback& callback) { + DCHECK(!callback.is_null()); + + // Outstanding tasks (e.g., posted to a message loop) must not be called. + Cancel(); + + // |forwarder_| is no longer valid after Cancel(), so re-bind. + InitializeForwarder(); + + callback_ = callback; + } + + // Returns a callback that can be disabled by calling Cancel(). + const base::Callback& callback() const { return forwarder_; } + + private: + void Forward(A1 a1) const { callback_.Run(a1); } + + // Helper method to bind |forwarder_| using a weak pointer from + // |weak_factory_|. + void InitializeForwarder() { + forwarder_ = base::Bind(&CancelableCallback::Forward, + weak_factory_.GetWeakPtr()); + } + + // Used to ensure Forward() is not run when this object is destroyed. + base::WeakPtrFactory> weak_factory_; + + // The wrapper closure. + base::Callback forwarder_; + + // The stored closure that may be cancelled. + base::Callback callback_; + + DISALLOW_COPY_AND_ASSIGN(CancelableCallback); +}; + +template +class CancelableCallback { + public: + CancelableCallback() : weak_factory_(this) {} + + // |callback| must not be null. + explicit CancelableCallback(const base::Callback& callback) + : weak_factory_(this), callback_(callback) { + DCHECK(!callback.is_null()); + InitializeForwarder(); + } + + ~CancelableCallback() {} + + // Cancels and drops the reference to the wrapped callback. + void Cancel() { + weak_factory_.InvalidateWeakPtrs(); + forwarder_.Reset(); + callback_.Reset(); + } + + // Returns true if the wrapped callback has been cancelled. + bool IsCancelled() const { return callback_.is_null(); } + + // Sets |callback| as the closure that may be cancelled. |callback| may not + // be null. Outstanding and any previously wrapped callbacks are cancelled. + void Reset(const base::Callback& callback) { + DCHECK(!callback.is_null()); + + // Outstanding tasks (e.g., posted to a message loop) must not be called. + Cancel(); + + // |forwarder_| is no longer valid after Cancel(), so re-bind. + InitializeForwarder(); + + callback_ = callback; + } + + // Returns a callback that can be disabled by calling Cancel(). + const base::Callback& callback() const { return forwarder_; } + + private: + void Forward(A1 a1, A2 a2) const { callback_.Run(a1, a2); } + + // Helper method to bind |forwarder_| using a weak pointer from + // |weak_factory_|. + void InitializeForwarder() { + forwarder_ = base::Bind(&CancelableCallback::Forward, + weak_factory_.GetWeakPtr()); + } + + // Used to ensure Forward() is not run when this object is destroyed. + base::WeakPtrFactory> weak_factory_; + + // The wrapper closure. + base::Callback forwarder_; + + // The stored closure that may be cancelled. + base::Callback callback_; + + DISALLOW_COPY_AND_ASSIGN(CancelableCallback); +}; + +typedef CancelableCallback CancelableClosure; + +} // namespace base + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_CANCELABLE_CALLBACK_H_ diff --git a/include/base/cef_lock.h b/include/base/cef_lock.h new file mode 100644 index 0000000..6909bd6 --- /dev/null +++ b/include/base/cef_lock.h @@ -0,0 +1,174 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011 +// Google Inc. 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_BASE_CEF_LOCK_H_ +#define CEF_INCLUDE_BASE_CEF_LOCK_H_ +#pragma once + +#if defined(BASE_SYNCHRONIZATION_LOCK_H_) +// Do nothing if the Chromium header has already been included. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/synchronization/lock.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include "include/base/cef_logging.h" +#include "include/base/cef_macros.h" +#include "include/base/cef_platform_thread.h" +#include "include/base/internal/cef_lock_impl.h" + +namespace base { +namespace cef_internal { + +// A convenient wrapper for an OS specific critical section. The only real +// intelligence in this class is in debug mode for the support for the +// AssertAcquired() method. +class Lock { + public: +#if !DCHECK_IS_ON() // Optimized wrapper implementation + Lock() : lock_() {} + ~Lock() {} + void Acquire() { lock_.Lock(); } + void Release() { lock_.Unlock(); } + + // If the lock is not held, take it and return true. If the lock is already + // held by another thread, immediately return false. This must not be called + // by a thread already holding the lock (what happens is undefined and an + // assertion may fail). + bool Try() { return lock_.Try(); } + + // Null implementation if not debug. + void AssertAcquired() const {} +#else + Lock(); + ~Lock(); + + // NOTE: Although windows critical sections support recursive locks, we do not + // allow this, and we will commonly fire a DCHECK() if a thread attempts to + // acquire the lock a second time (while already holding it). + void Acquire() { + lock_.Lock(); + CheckUnheldAndMark(); + } + void Release() { + CheckHeldAndUnmark(); + lock_.Unlock(); + } + + bool Try() { + bool rv = lock_.Try(); + if (rv) { + CheckUnheldAndMark(); + } + return rv; + } + + void AssertAcquired() const; +#endif // !DCHECK_IS_ON() + + private: +#if DCHECK_IS_ON() + // Members and routines taking care of locks assertions. + // Note that this checks for recursive locks and allows them + // if the variable is set. This is allowed by the underlying implementation + // on windows but not on Posix, so we're doing unneeded checks on Posix. + // It's worth it to share the code. + void CheckHeldAndUnmark(); + void CheckUnheldAndMark(); + + // All private data is implicitly protected by lock_. + // Be VERY careful to only access members under that lock. + base::PlatformThreadRef owning_thread_ref_; +#endif // DCHECK_IS_ON() + + // Platform specific underlying lock implementation. + LockImpl lock_; + + DISALLOW_COPY_AND_ASSIGN(Lock); +}; + +// A helper class that acquires the given Lock while the AutoLock is in scope. +class AutoLock { + public: + struct AlreadyAcquired {}; + + explicit AutoLock(Lock& lock) : lock_(lock) { lock_.Acquire(); } + + AutoLock(Lock& lock, const AlreadyAcquired&) : lock_(lock) { + lock_.AssertAcquired(); + } + + ~AutoLock() { + lock_.AssertAcquired(); + lock_.Release(); + } + + private: + Lock& lock_; + DISALLOW_COPY_AND_ASSIGN(AutoLock); +}; + +// AutoUnlock is a helper that will Release() the |lock| argument in the +// constructor, and re-Acquire() it in the destructor. +class AutoUnlock { + public: + explicit AutoUnlock(Lock& lock) : lock_(lock) { + // We require our caller to have the lock. + lock_.AssertAcquired(); + lock_.Release(); + } + + ~AutoUnlock() { lock_.Acquire(); } + + private: + Lock& lock_; + DISALLOW_COPY_AND_ASSIGN(AutoUnlock); +}; + +} // namespace cef_internal + +// Implement classes in the cef_internal namespace and then expose them to the +// base namespace. This avoids conflicts with the base.lib implementation when +// linking sandbox support on Windows. +using cef_internal::Lock; +using cef_internal::AutoLock; +using cef_internal::AutoUnlock; + +} // namespace base + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_LOCK_H_ diff --git a/include/base/cef_logging.h b/include/base/cef_logging.h new file mode 100644 index 0000000..8d8bb88 --- /dev/null +++ b/include/base/cef_logging.h @@ -0,0 +1,760 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012 +// Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file are only available to applications that link +// against the libcef_dll_wrapper target. +// +// WARNING: Logging macros should not be used in the main/browser process before +// calling CefInitialize or in sub-processes before calling CefExecuteProcess. +// +// Instructions +// ------------ +// +// Make a bunch of macros for logging. The way to log things is to stream +// things to LOG(). E.g., +// +// LOG(INFO) << "Found " << num_cookies << " cookies"; +// +// You can also do conditional logging: +// +// LOG_IF(INFO, num_cookies > 10) << "Got lots of cookies"; +// +// The CHECK(condition) macro is active in both debug and release builds and +// effectively performs a LOG(FATAL) which terminates the process and +// generates a crashdump unless a debugger is attached. +// +// There are also "debug mode" logging macros like the ones above: +// +// DLOG(INFO) << "Found cookies"; +// +// DLOG_IF(INFO, num_cookies > 10) << "Got lots of cookies"; +// +// All "debug mode" logging is compiled away to nothing for non-debug mode +// compiles. LOG_IF and development flags also work well together +// because the code can be compiled away sometimes. +// +// We also have +// +// LOG_ASSERT(assertion); +// DLOG_ASSERT(assertion); +// +// which is syntactic sugar for {,D}LOG_IF(FATAL, assert fails) << assertion; +// +// There are "verbose level" logging macros. They look like +// +// VLOG(1) << "I'm printed when you run the program with --v=1 or more"; +// VLOG(2) << "I'm printed when you run the program with --v=2 or more"; +// +// These always log at the INFO log level (when they log at all). +// The verbose logging can also be turned on module-by-module. For instance, +// --vmodule=profile=2,icon_loader=1,browser_*=3,*/chromeos/*=4 --v=0 +// will cause: +// a. VLOG(2) and lower messages to be printed from profile.{h,cc} +// b. VLOG(1) and lower messages to be printed from icon_loader.{h,cc} +// c. VLOG(3) and lower messages to be printed from files prefixed with +// "browser" +// d. VLOG(4) and lower messages to be printed from files under a +// "chromeos" directory. +// e. VLOG(0) and lower messages to be printed from elsewhere +// +// The wildcarding functionality shown by (c) supports both '*' (match +// 0 or more characters) and '?' (match any single character) +// wildcards. Any pattern containing a forward or backward slash will +// be tested against the whole pathname and not just the module. +// E.g., "*/foo/bar/*=2" would change the logging level for all code +// in source files under a "foo/bar" directory. +// +// There's also VLOG_IS_ON(n) "verbose level" condition macro. To be used as +// +// if (VLOG_IS_ON(2)) { +// // do some logging preparation and logging +// // that can't be accomplished with just VLOG(2) << ...; +// } +// +// There is also a VLOG_IF "verbose level" condition macro for sample +// cases, when some extra computation and preparation for logs is not +// needed. +// +// VLOG_IF(1, (size > 1024)) +// << "I'm printed when size is more than 1024 and when you run the " +// "program with --v=1 or more"; +// +// We also override the standard 'assert' to use 'DLOG_ASSERT'. +// +// Lastly, there is: +// +// PLOG(ERROR) << "Couldn't do foo"; +// DPLOG(ERROR) << "Couldn't do foo"; +// PLOG_IF(ERROR, cond) << "Couldn't do foo"; +// DPLOG_IF(ERROR, cond) << "Couldn't do foo"; +// PCHECK(condition) << "Couldn't do foo"; +// DPCHECK(condition) << "Couldn't do foo"; +// +// which append the last system error to the message in string form (taken from +// GetLastError() on Windows and errno on POSIX). +// +// The supported severity levels for macros that allow you to specify one +// are (in increasing order of severity) INFO, WARNING, ERROR, and FATAL. +// +// Very important: logging a message at the FATAL severity level causes +// the program to terminate (after the message is logged). +// +// There is the special severity of DFATAL, which logs FATAL in debug mode, +// ERROR in normal mode. +// + +#ifndef CEF_INCLUDE_BASE_CEF_LOGGING_H_ +#define CEF_INCLUDE_BASE_CEF_LOGGING_H_ +#pragma once + +#if defined(DCHECK) +// Do nothing if the macros provided by this header already exist. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. + +// Always define the DCHECK_IS_ON macro which is used from other CEF headers. +#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) +#define DCHECK_IS_ON() 0 +#else +#define DCHECK_IS_ON() 1 +#endif + +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/logging.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include +#include +#include +#include + +#include "include/base/cef_build.h" +#include "include/base/cef_macros.h" +#include "include/internal/cef_logging_internal.h" + +namespace cef { +namespace logging { + +// Gets the current log level. +inline int GetMinLogLevel() { + return cef_get_min_log_level(); +} + +// Gets the current vlog level for the given file (usually taken from +// __FILE__). Note that |N| is the size *with* the null terminator. +template +int GetVlogLevel(const char (&file)[N]) { + return cef_get_vlog_level(file, N); +} + +typedef int LogSeverity; +const LogSeverity LOG_VERBOSE = -1; // This is level 1 verbosity +// Note: the log severities are used to index into the array of names, +// see log_severity_names. +const LogSeverity LOG_INFO = 0; +const LogSeverity LOG_WARNING = 1; +const LogSeverity LOG_ERROR = 2; +const LogSeverity LOG_FATAL = 3; +const LogSeverity LOG_NUM_SEVERITIES = 4; + +// LOG_DFATAL is LOG_FATAL in debug mode, ERROR in normal mode +#ifdef NDEBUG +const LogSeverity LOG_DFATAL = LOG_ERROR; +#else +const LogSeverity LOG_DFATAL = LOG_FATAL; +#endif + +// A few definitions of macros that don't generate much code. These are used +// by LOG() and LOG_IF, etc. Since these are used all over our code, it's +// better to have compact code for these operations. +#define COMPACT_GOOGLE_LOG_EX_INFO(ClassName, ...) \ + cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_INFO, \ + ##__VA_ARGS__) +#define COMPACT_GOOGLE_LOG_EX_WARNING(ClassName, ...) \ + cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_WARNING, \ + ##__VA_ARGS__) +#define COMPACT_GOOGLE_LOG_EX_ERROR(ClassName, ...) \ + cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_ERROR, \ + ##__VA_ARGS__) +#define COMPACT_GOOGLE_LOG_EX_FATAL(ClassName, ...) \ + cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_FATAL, \ + ##__VA_ARGS__) +#define COMPACT_GOOGLE_LOG_EX_DFATAL(ClassName, ...) \ + cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_DFATAL, \ + ##__VA_ARGS__) + +#define COMPACT_GOOGLE_LOG_INFO COMPACT_GOOGLE_LOG_EX_INFO(LogMessage) +#define COMPACT_GOOGLE_LOG_WARNING COMPACT_GOOGLE_LOG_EX_WARNING(LogMessage) +#define COMPACT_GOOGLE_LOG_ERROR COMPACT_GOOGLE_LOG_EX_ERROR(LogMessage) +#define COMPACT_GOOGLE_LOG_FATAL COMPACT_GOOGLE_LOG_EX_FATAL(LogMessage) +#define COMPACT_GOOGLE_LOG_DFATAL COMPACT_GOOGLE_LOG_EX_DFATAL(LogMessage) + +#if defined(OS_WIN) +// wingdi.h defines ERROR to be 0. When we call LOG(ERROR), it gets +// substituted with 0, and it expands to COMPACT_GOOGLE_LOG_0. To allow us +// to keep using this syntax, we define this macro to do the same thing +// as COMPACT_GOOGLE_LOG_ERROR, and also define ERROR the same way that +// the Windows SDK does for consistency. +#define ERROR 0 +#define COMPACT_GOOGLE_LOG_EX_0(ClassName, ...) \ + COMPACT_GOOGLE_LOG_EX_ERROR(ClassName, ##__VA_ARGS__) +#define COMPACT_GOOGLE_LOG_0 COMPACT_GOOGLE_LOG_ERROR +// Needed for LOG_IS_ON(ERROR). +const LogSeverity LOG_0 = LOG_ERROR; +#endif + +// As special cases, we can assume that LOG_IS_ON(FATAL) always holds. Also, +// LOG_IS_ON(DFATAL) always holds in debug mode. In particular, CHECK()s will +// always fire if they fail. +#define LOG_IS_ON(severity) \ + ((::cef::logging::LOG_##severity) >= ::cef::logging::GetMinLogLevel()) + +// We can't do any caching tricks with VLOG_IS_ON() like the +// google-glog version since it requires GCC extensions. This means +// that using the v-logging functions in conjunction with --vmodule +// may be slow. +#define VLOG_IS_ON(verboselevel) \ + ((verboselevel) <= ::cef::logging::GetVlogLevel(__FILE__)) + +// Helper macro which avoids evaluating the arguments to a stream if +// the condition doesn't hold. +#define LAZY_STREAM(stream, condition) \ + !(condition) ? (void)0 : ::cef::logging::LogMessageVoidify() & (stream) + +// We use the preprocessor's merging operator, "##", so that, e.g., +// LOG(INFO) becomes the token COMPACT_GOOGLE_LOG_INFO. There's some funny +// subtle difference between ostream member streaming functions (e.g., +// ostream::operator<<(int) and ostream non-member streaming functions +// (e.g., ::operator<<(ostream&, string&): it turns out that it's +// impossible to stream something like a string directly to an unnamed +// ostream. We employ a neat hack by calling the stream() member +// function of LogMessage which seems to avoid the problem. +#define LOG_STREAM(severity) COMPACT_GOOGLE_LOG_##severity.stream() + +#define LOG(severity) LAZY_STREAM(LOG_STREAM(severity), LOG_IS_ON(severity)) +#define LOG_IF(severity, condition) \ + LAZY_STREAM(LOG_STREAM(severity), LOG_IS_ON(severity) && (condition)) + +#define SYSLOG(severity) LOG(severity) +#define SYSLOG_IF(severity, condition) LOG_IF(severity, condition) + +// The VLOG macros log with negative verbosities. +#define VLOG_STREAM(verbose_level) \ + cef::logging::LogMessage(__FILE__, __LINE__, -verbose_level).stream() + +#define VLOG(verbose_level) \ + LAZY_STREAM(VLOG_STREAM(verbose_level), VLOG_IS_ON(verbose_level)) + +#define VLOG_IF(verbose_level, condition) \ + LAZY_STREAM(VLOG_STREAM(verbose_level), \ + VLOG_IS_ON(verbose_level) && (condition)) + +#if defined(OS_WIN) +#define VPLOG_STREAM(verbose_level) \ + cef::logging::Win32ErrorLogMessage(__FILE__, __LINE__, -verbose_level, \ + ::cef::logging::GetLastSystemErrorCode()) \ + .stream() +#elif defined(OS_POSIX) +#define VPLOG_STREAM(verbose_level) \ + cef::logging::ErrnoLogMessage(__FILE__, __LINE__, -verbose_level, \ + ::cef::logging::GetLastSystemErrorCode()) \ + .stream() +#endif + +#define VPLOG(verbose_level) \ + LAZY_STREAM(VPLOG_STREAM(verbose_level), VLOG_IS_ON(verbose_level)) + +#define VPLOG_IF(verbose_level, condition) \ + LAZY_STREAM(VPLOG_STREAM(verbose_level), \ + VLOG_IS_ON(verbose_level) && (condition)) + +// TODO(akalin): Add more VLOG variants, e.g. VPLOG. + +#define LOG_ASSERT(condition) \ + LOG_IF(FATAL, !(condition)) << "Assert failed: " #condition ". " +#define SYSLOG_ASSERT(condition) \ + SYSLOG_IF(FATAL, !(condition)) << "Assert failed: " #condition ". " + +#if defined(OS_WIN) +#define PLOG_STREAM(severity) \ + COMPACT_GOOGLE_LOG_EX_##severity(Win32ErrorLogMessage, \ + ::cef::logging::GetLastSystemErrorCode()) \ + .stream() +#elif defined(OS_POSIX) +#define PLOG_STREAM(severity) \ + COMPACT_GOOGLE_LOG_EX_##severity(ErrnoLogMessage, \ + ::cef::logging::GetLastSystemErrorCode()) \ + .stream() +#endif + +#define PLOG(severity) LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity)) + +#define PLOG_IF(severity, condition) \ + LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity) && (condition)) + +// The actual stream used isn't important. +#define EAT_STREAM_PARAMETERS \ + true ? (void)0 : ::cef::logging::LogMessageVoidify() & LOG_STREAM(FATAL) + +// CHECK dies with a fatal error if condition is not true. It is *not* +// controlled by NDEBUG, so the check will be executed regardless of +// compilation mode. +// +// We make sure CHECK et al. always evaluates their arguments, as +// doing CHECK(FunctionWithSideEffect()) is a common idiom. + +#define CHECK(condition) \ + LAZY_STREAM(LOG_STREAM(FATAL), !(condition)) \ + << "Check failed: " #condition ". " + +#define PCHECK(condition) \ + LAZY_STREAM(PLOG_STREAM(FATAL), !(condition)) \ + << "Check failed: " #condition ". " + +// Helper macro for binary operators. +// Don't use this macro directly in your code, use CHECK_EQ et al below. +// +// TODO(akalin): Rewrite this so that constructs like if (...) +// CHECK_EQ(...) else { ... } work properly. +#define CHECK_OP(name, op, val1, val2) \ + if (std::string* _result = cef::logging::Check##name##Impl( \ + (val1), (val2), #val1 " " #op " " #val2)) \ + cef::logging::LogMessage(__FILE__, __LINE__, _result).stream() + +// Build the error message string. This is separate from the "Impl" +// function template because it is not performance critical and so can +// be out of line, while the "Impl" code should be inline. Caller +// takes ownership of the returned string. +template +std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) { + std::ostringstream ss; + ss << names << " (" << v1 << " vs. " << v2 << ")"; + std::string* msg = new std::string(ss.str()); + return msg; +} + +// MSVC doesn't like complex extern templates and DLLs. +#if !defined(COMPILER_MSVC) +// Commonly used instantiations of MakeCheckOpString<>. Explicitly instantiated +// in logging.cc. +extern template std::string* MakeCheckOpString(const int&, + const int&, + const char* names); +extern template std::string* MakeCheckOpString( + const unsigned long&, + const unsigned long&, + const char* names); +extern template std::string* MakeCheckOpString( + const unsigned long&, + const unsigned int&, + const char* names); +extern template std::string* MakeCheckOpString( + const unsigned int&, + const unsigned long&, + const char* names); +extern template std::string* MakeCheckOpString( + const std::string&, + const std::string&, + const char* name); +#endif + +// Helper functions for CHECK_OP macro. +// The (int, int) specialization works around the issue that the compiler +// will not instantiate the template version of the function on values of +// unnamed enum type - see comment below. +#define DEFINE_CHECK_OP_IMPL(name, op) \ + template \ + inline std::string* Check##name##Impl(const t1& v1, const t2& v2, \ + const char* names) { \ + if (v1 op v2) \ + return NULL; \ + else \ + return MakeCheckOpString(v1, v2, names); \ + } \ + inline std::string* Check##name##Impl(int v1, int v2, const char* names) { \ + if (v1 op v2) \ + return NULL; \ + else \ + return MakeCheckOpString(v1, v2, names); \ + } +DEFINE_CHECK_OP_IMPL(EQ, ==) +DEFINE_CHECK_OP_IMPL(NE, !=) +DEFINE_CHECK_OP_IMPL(LE, <=) +DEFINE_CHECK_OP_IMPL(LT, <) +DEFINE_CHECK_OP_IMPL(GE, >=) +DEFINE_CHECK_OP_IMPL(GT, >) +#undef DEFINE_CHECK_OP_IMPL + +#define CHECK_EQ(val1, val2) CHECK_OP(EQ, ==, val1, val2) +#define CHECK_NE(val1, val2) CHECK_OP(NE, !=, val1, val2) +#define CHECK_LE(val1, val2) CHECK_OP(LE, <=, val1, val2) +#define CHECK_LT(val1, val2) CHECK_OP(LT, <, val1, val2) +#define CHECK_GE(val1, val2) CHECK_OP(GE, >=, val1, val2) +#define CHECK_GT(val1, val2) CHECK_OP(GT, >, val1, val2) + +#if defined(NDEBUG) +#define ENABLE_DLOG 0 +#else +#define ENABLE_DLOG 1 +#endif + +#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) +#define DCHECK_IS_ON() 0 +#else +#define DCHECK_IS_ON() 1 +#endif + +// Definitions for DLOG et al. + +#if ENABLE_DLOG + +#define DLOG_IS_ON(severity) LOG_IS_ON(severity) +#define DLOG_IF(severity, condition) LOG_IF(severity, condition) +#define DLOG_ASSERT(condition) LOG_ASSERT(condition) +#define DPLOG_IF(severity, condition) PLOG_IF(severity, condition) +#define DVLOG_IF(verboselevel, condition) VLOG_IF(verboselevel, condition) +#define DVPLOG_IF(verboselevel, condition) VPLOG_IF(verboselevel, condition) + +#else // ENABLE_DLOG + +// If ENABLE_DLOG is off, we want to avoid emitting any references to +// |condition| (which may reference a variable defined only if NDEBUG +// is not defined). Contrast this with DCHECK et al., which has +// different behavior. + +#define DLOG_IS_ON(severity) false +#define DLOG_IF(severity, condition) EAT_STREAM_PARAMETERS +#define DLOG_ASSERT(condition) EAT_STREAM_PARAMETERS +#define DPLOG_IF(severity, condition) EAT_STREAM_PARAMETERS +#define DVLOG_IF(verboselevel, condition) EAT_STREAM_PARAMETERS +#define DVPLOG_IF(verboselevel, condition) EAT_STREAM_PARAMETERS + +#endif // ENABLE_DLOG + +// DEBUG_MODE is for uses like +// if (DEBUG_MODE) foo.CheckThatFoo(); +// instead of +// #ifndef NDEBUG +// foo.CheckThatFoo(); +// #endif +// +// We tie its state to ENABLE_DLOG. +enum { DEBUG_MODE = ENABLE_DLOG }; + +#undef ENABLE_DLOG + +#define DLOG(severity) LAZY_STREAM(LOG_STREAM(severity), DLOG_IS_ON(severity)) + +#define DPLOG(severity) LAZY_STREAM(PLOG_STREAM(severity), DLOG_IS_ON(severity)) + +#define DVLOG(verboselevel) DVLOG_IF(verboselevel, VLOG_IS_ON(verboselevel)) + +#define DVPLOG(verboselevel) DVPLOG_IF(verboselevel, VLOG_IS_ON(verboselevel)) + +// Definitions for DCHECK et al. + +#if DCHECK_IS_ON() + +#define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \ + COMPACT_GOOGLE_LOG_EX_FATAL(ClassName, ##__VA_ARGS__) +#define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_FATAL +const LogSeverity LOG_DCHECK = LOG_FATAL; + +#else // DCHECK_IS_ON() + +// These are just dummy values. +#define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \ + COMPACT_GOOGLE_LOG_EX_INFO(ClassName, ##__VA_ARGS__) +#define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_INFO +const LogSeverity LOG_DCHECK = LOG_INFO; + +#endif // DCHECK_IS_ON() + +// DCHECK et al. make sure to reference |condition| regardless of +// whether DCHECKs are enabled; this is so that we don't get unused +// variable warnings if the only use of a variable is in a DCHECK. +// This behavior is different from DLOG_IF et al. + +#define DCHECK(condition) \ + LAZY_STREAM(LOG_STREAM(DCHECK), DCHECK_IS_ON() && !(condition)) \ + << "Check failed: " #condition ". " + +#define DPCHECK(condition) \ + LAZY_STREAM(PLOG_STREAM(DCHECK), DCHECK_IS_ON() && !(condition)) \ + << "Check failed: " #condition ". " + +// Helper macro for binary operators. +// Don't use this macro directly in your code, use DCHECK_EQ et al below. +#define DCHECK_OP(name, op, val1, val2) \ + if (DCHECK_IS_ON()) \ + if (std::string* _result = cef::logging::Check##name##Impl( \ + (val1), (val2), #val1 " " #op " " #val2)) \ + cef::logging::LogMessage(__FILE__, __LINE__, ::cef::logging::LOG_DCHECK, \ + _result) \ + .stream() + +// Equality/Inequality checks - compare two values, and log a +// LOG_DCHECK message including the two values when the result is not +// as expected. The values must have operator<<(ostream, ...) +// defined. +// +// You may append to the error message like so: +// DCHECK_NE(1, 2) << ": The world must be ending!"; +// +// We are very careful to ensure that each argument is evaluated exactly +// once, and that anything which is legal to pass as a function argument is +// legal here. In particular, the arguments may be temporary expressions +// which will end up being destroyed at the end of the apparent statement, +// for example: +// DCHECK_EQ(string("abc")[1], 'b'); +// +// WARNING: These may not compile correctly if one of the arguments is a pointer +// and the other is NULL. To work around this, simply static_cast NULL to the +// type of the desired pointer. + +#define DCHECK_EQ(val1, val2) DCHECK_OP(EQ, ==, val1, val2) +#define DCHECK_NE(val1, val2) DCHECK_OP(NE, !=, val1, val2) +#define DCHECK_LE(val1, val2) DCHECK_OP(LE, <=, val1, val2) +#define DCHECK_LT(val1, val2) DCHECK_OP(LT, <, val1, val2) +#define DCHECK_GE(val1, val2) DCHECK_OP(GE, >=, val1, val2) +#define DCHECK_GT(val1, val2) DCHECK_OP(GT, >, val1, val2) + +#if defined(NDEBUG) && defined(OS_CHROMEOS) +#define NOTREACHED() \ + LOG(ERROR) << "NOTREACHED() hit in " << __FUNCTION__ << ". " +#else +#define NOTREACHED() DCHECK(false) +#endif + +// Redefine the standard assert to use our nice log files +#undef assert +#define assert(x) DLOG_ASSERT(x) + +// This class more or less represents a particular log message. You +// create an instance of LogMessage and then stream stuff to it. +// When you finish streaming to it, ~LogMessage is called and the +// full message gets streamed to the appropriate destination. +// +// You shouldn't actually use LogMessage's constructor to log things, +// though. You should use the LOG() macro (and variants thereof) +// above. +class LogMessage { + public: + // Used for LOG(severity). + LogMessage(const char* file, int line, LogSeverity severity); + + // Used for CHECK_EQ(), etc. Takes ownership of the given string. + // Implied severity = LOG_FATAL. + LogMessage(const char* file, int line, std::string* result); + + // Used for DCHECK_EQ(), etc. Takes ownership of the given string. + LogMessage(const char* file, + int line, + LogSeverity severity, + std::string* result); + + ~LogMessage(); + + std::ostream& stream() { return stream_; } + + private: + LogSeverity severity_; + std::ostringstream stream_; + + // The file and line information passed in to the constructor. + const char* file_; + const int line_; + +#if defined(OS_WIN) + // Stores the current value of GetLastError in the constructor and restores + // it in the destructor by calling SetLastError. + // This is useful since the LogMessage class uses a lot of Win32 calls + // that will lose the value of GLE and the code that called the log function + // will have lost the thread error value when the log call returns. + class SaveLastError { + public: + SaveLastError(); + ~SaveLastError(); + + unsigned long get_error() const { return last_error_; } + + protected: + unsigned long last_error_; + }; + + SaveLastError last_error_; +#endif + + DISALLOW_COPY_AND_ASSIGN(LogMessage); +}; + +// A non-macro interface to the log facility; (useful +// when the logging level is not a compile-time constant). +inline void LogAtLevel(int const log_level, std::string const& msg) { + LogMessage(__FILE__, __LINE__, log_level).stream() << msg; +} + +// This class is used to explicitly ignore values in the conditional +// logging macros. This avoids compiler warnings like "value computed +// is not used" and "statement has no effect". +class LogMessageVoidify { + public: + LogMessageVoidify() {} + // This has to be an operator with a precedence lower than << but + // higher than ?: + void operator&(std::ostream&) {} +}; + +#if defined(OS_WIN) +typedef unsigned long SystemErrorCode; +#elif defined(OS_POSIX) +typedef int SystemErrorCode; +#endif + +// Alias for ::GetLastError() on Windows and errno on POSIX. Avoids having to +// pull in windows.h just for GetLastError() and DWORD. +SystemErrorCode GetLastSystemErrorCode(); +std::string SystemErrorCodeToString(SystemErrorCode error_code); + +#if defined(OS_WIN) +// Appends a formatted system message of the GetLastError() type. +class Win32ErrorLogMessage { + public: + Win32ErrorLogMessage(const char* file, + int line, + LogSeverity severity, + SystemErrorCode err); + + // Appends the error message before destructing the encapsulated class. + ~Win32ErrorLogMessage(); + + std::ostream& stream() { return log_message_.stream(); } + + private: + SystemErrorCode err_; + LogMessage log_message_; + + DISALLOW_COPY_AND_ASSIGN(Win32ErrorLogMessage); +}; +#elif defined(OS_POSIX) +// Appends a formatted system message of the errno type +class ErrnoLogMessage { + public: + ErrnoLogMessage(const char* file, + int line, + LogSeverity severity, + SystemErrorCode err); + + // Appends the error message before destructing the encapsulated class. + ~ErrnoLogMessage(); + + std::ostream& stream() { return log_message_.stream(); } + + private: + SystemErrorCode err_; + LogMessage log_message_; + + DISALLOW_COPY_AND_ASSIGN(ErrnoLogMessage); +}; +#endif // OS_WIN + +} // namespace logging +} // namespace cef + +// These functions are provided as a convenience for logging, which is where we +// use streams (it is against Google style to use streams in other places). It +// is designed to allow you to emit non-ASCII Unicode strings to the log file, +// which is normally ASCII. It is relatively slow, so try not to use it for +// common cases. Non-ASCII characters will be converted to UTF-8 by these +// operators. +std::ostream& operator<<(std::ostream& out, const wchar_t* wstr); +inline std::ostream& operator<<(std::ostream& out, const std::wstring& wstr) { + return out << wstr.c_str(); +} + +// The NOTIMPLEMENTED() macro annotates codepaths which have +// not been implemented yet. +// +// The implementation of this macro is controlled by NOTIMPLEMENTED_POLICY: +// 0 -- Do nothing (stripped by compiler) +// 1 -- Warn at compile time +// 2 -- Fail at compile time +// 3 -- Fail at runtime (DCHECK) +// 4 -- [default] LOG(ERROR) at runtime +// 5 -- LOG(ERROR) at runtime, only once per call-site + +#ifndef NOTIMPLEMENTED_POLICY +#if defined(OS_ANDROID) && defined(OFFICIAL_BUILD) +#define NOTIMPLEMENTED_POLICY 0 +#else +// Select default policy: LOG(ERROR) +#define NOTIMPLEMENTED_POLICY 4 +#endif +#endif + +#if defined(COMPILER_GCC) +// On Linux, with GCC, we can use __PRETTY_FUNCTION__ to get the demangled name +// of the current function in the NOTIMPLEMENTED message. +#define NOTIMPLEMENTED_MSG "Not implemented reached in " << __PRETTY_FUNCTION__ +#else +#define NOTIMPLEMENTED_MSG "NOT IMPLEMENTED" +#endif + +#if NOTIMPLEMENTED_POLICY == 0 +#define NOTIMPLEMENTED() EAT_STREAM_PARAMETERS +#elif NOTIMPLEMENTED_POLICY == 1 +// TODO, figure out how to generate a warning +#define NOTIMPLEMENTED() COMPILE_ASSERT(false, NOT_IMPLEMENTED) +#elif NOTIMPLEMENTED_POLICY == 2 +#define NOTIMPLEMENTED() COMPILE_ASSERT(false, NOT_IMPLEMENTED) +#elif NOTIMPLEMENTED_POLICY == 3 +#define NOTIMPLEMENTED() NOTREACHED() +#elif NOTIMPLEMENTED_POLICY == 4 +#define NOTIMPLEMENTED() LOG(ERROR) << NOTIMPLEMENTED_MSG +#elif NOTIMPLEMENTED_POLICY == 5 +#define NOTIMPLEMENTED() \ + do { \ + static bool logged_once = false; \ + LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG; \ + logged_once = true; \ + } while (0); \ + EAT_STREAM_PARAMETERS +#endif + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_LOGGING_H_ diff --git a/include/base/cef_macros.h b/include/base/cef_macros.h new file mode 100644 index 0000000..e714529 --- /dev/null +++ b/include/base/cef_macros.h @@ -0,0 +1,220 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012 +// Google Inc. 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_BASE_CEF_MACROS_H_ +#define CEF_INCLUDE_BASE_CEF_MACROS_H_ +#pragma once + +#if defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/macros.h" + +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include // For size_t. +#include "include/base/cef_build.h" // For COMPILER_MSVC + +#if !defined(arraysize) + +// The arraysize(arr) macro returns the # of elements in an array arr. +// The expression is a compile-time constant, and therefore can be +// used in defining new arrays, for example. If you use arraysize on +// a pointer by mistake, you will get a compile-time error. +// +// One caveat is that arraysize() doesn't accept any array of an +// anonymous type or a type defined inside a function. In these rare +// cases, you have to use the unsafe ARRAYSIZE_UNSAFE() macro below. This is +// due to a limitation in C++'s template system. The limitation might +// eventually be removed, but it hasn't happened yet. + +// This template function declaration is used in defining arraysize. +// Note that the function doesn't need an implementation, as we only +// use its type. +template +char (&ArraySizeHelper(T (&array)[N]))[N]; + +// That gcc wants both of these prototypes seems mysterious. VC, for +// its part, can't decide which to use (another mystery). Matching of +// template overloads: the final frontier. +#ifndef _MSC_VER +template +char (&ArraySizeHelper(const T (&array)[N]))[N]; +#endif + +#define arraysize(array) (sizeof(ArraySizeHelper(array))) + +#endif // !arraysize + +#if !defined(DISALLOW_COPY_AND_ASSIGN) + +// A macro to disallow the copy constructor and operator= functions +// This should be used in the private: declarations for a class +#define DISALLOW_COPY_AND_ASSIGN(TypeName) \ + TypeName(const TypeName&); \ + void operator=(const TypeName&) + +#endif // !DISALLOW_COPY_AND_ASSIGN + +#if !defined(DISALLOW_IMPLICIT_CONSTRUCTORS) + +// A macro to disallow all the implicit constructors, namely the +// default constructor, copy constructor and operator= functions. +// +// This should be used in the private: declarations for a class +// that wants to prevent anyone from instantiating it. This is +// especially useful for classes containing only static methods. +#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ + TypeName(); \ + DISALLOW_COPY_AND_ASSIGN(TypeName) + +#endif // !DISALLOW_IMPLICIT_CONSTRUCTORS + +#if !defined(COMPILE_ASSERT) + +// The COMPILE_ASSERT macro can be used to verify that a compile time +// expression is true. For example, you could use it to verify the +// size of a static array: +// +// COMPILE_ASSERT(ARRAYSIZE_UNSAFE(content_type_names) == CONTENT_NUM_TYPES, +// content_type_names_incorrect_size); +// +// or to make sure a struct is smaller than a certain size: +// +// COMPILE_ASSERT(sizeof(foo) < 128, foo_too_large); +// +// The second argument to the macro is the name of the variable. If +// the expression is false, most compilers will issue a warning/error +// containing the name of the variable. + +#if __cplusplus >= 201103L + +// Under C++11, just use static_assert. +#define COMPILE_ASSERT(expr, msg) static_assert(expr, #msg) + +#else + +namespace cef { + +template +struct CompileAssert {}; + +} // namespace cef + +#define COMPILE_ASSERT(expr, msg) \ + typedef cef::CompileAssert<(bool(expr))> \ + msg[bool(expr) ? 1 : -1] ALLOW_UNUSED_TYPE + +// Implementation details of COMPILE_ASSERT: +// +// - COMPILE_ASSERT works by defining an array type that has -1 +// elements (and thus is invalid) when the expression is false. +// +// - The simpler definition +// +// #define COMPILE_ASSERT(expr, msg) typedef char msg[(expr) ? 1 : -1] +// +// does not work, as gcc supports variable-length arrays whose sizes +// are determined at run-time (this is gcc's extension and not part +// of the C++ standard). As a result, gcc fails to reject the +// following code with the simple definition: +// +// int foo; +// COMPILE_ASSERT(foo, msg); // not supposed to compile as foo is +// // not a compile-time constant. +// +// - By using the type CompileAssert<(bool(expr))>, we ensures that +// expr is a compile-time constant. (Template arguments must be +// determined at compile-time.) +// +// - The outer parentheses in CompileAssert<(bool(expr))> are necessary +// to work around a bug in gcc 3.4.4 and 4.0.1. If we had written +// +// CompileAssert +// +// instead, these compilers will refuse to compile +// +// COMPILE_ASSERT(5 > 0, some_message); +// +// (They seem to think the ">" in "5 > 0" marks the end of the +// template argument list.) +// +// - The array size is (bool(expr) ? 1 : -1), instead of simply +// +// ((expr) ? 1 : -1). +// +// This is to avoid running into a bug in MS VC 7.1, which +// causes ((0.0) ? 1 : -1) to incorrectly evaluate to 1. + +#endif // !(__cplusplus >= 201103L) + +#endif // !defined(COMPILE_ASSERT) + +#endif // !USING_CHROMIUM_INCLUDES + +#if !defined(MSVC_PUSH_DISABLE_WARNING) && defined(COMPILER_MSVC) + +// MSVC_PUSH_DISABLE_WARNING pushes |n| onto a stack of warnings to be disabled. +// The warning remains disabled until popped by MSVC_POP_WARNING. +#define MSVC_PUSH_DISABLE_WARNING(n) \ + __pragma(warning(push)) __pragma(warning(disable : n)) + +// MSVC_PUSH_WARNING_LEVEL pushes |n| as the global warning level. The level +// remains in effect until popped by MSVC_POP_WARNING(). Use 0 to disable all +// warnings. +#define MSVC_PUSH_WARNING_LEVEL(n) __pragma(warning(push, n)) + +// Pop effects of innermost MSVC_PUSH_* macro. +#define MSVC_POP_WARNING() __pragma(warning(pop)) + +#endif // !defined(MSVC_PUSH_DISABLE_WARNING) && defined(COMPILER_MSVC) + +#if !defined(ALLOW_THIS_IN_INITIALIZER_LIST) +#if defined(COMPILER_MSVC) +// Allows |this| to be passed as an argument in constructor initializer lists. +// This uses push/pop instead of the seemingly simpler suppress feature to avoid +// having the warning be disabled for more than just |code|. +// +// Example usage: +// Foo::Foo() : x(NULL), ALLOW_THIS_IN_INITIALIZER_LIST(y(this)), z(3) {} +// +// Compiler warning C4355: 'this': used in base member initializer list: +// http://msdn.microsoft.com/en-us/library/3c594ae3(VS.80).aspx +#define ALLOW_THIS_IN_INITIALIZER_LIST(code) \ + MSVC_PUSH_DISABLE_WARNING(4355) \ + code MSVC_POP_WARNING() +#else // !COMPILER_MSVC +#define ALLOW_THIS_IN_INITIALIZER_LIST(code) code +#endif // !COMPILER_MSVC +#endif // !ALLOW_THIS_IN_INITIALIZER_LIST + +#endif // CEF_INCLUDE_BASE_CEF_MACROS_H_ diff --git a/include/base/cef_move.h b/include/base/cef_move.h new file mode 100644 index 0000000..da47d2d --- /dev/null +++ b/include/base/cef_move.h @@ -0,0 +1,261 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012 +// Google Inc. 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_BASE_CEF_MOVE_H_ +#define CEF_INCLUDE_BASE_CEF_MOVE_H_ + +#if defined(MOVE_ONLY_TYPE_FOR_CPP_03) +// Do nothing if the macro in this header has already been defined. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/move.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +// Macro with the boilerplate that makes a type move-only in C++03. +// +// USAGE +// +// This macro should be used instead of DISALLOW_COPY_AND_ASSIGN to create +// a "move-only" type. Unlike DISALLOW_COPY_AND_ASSIGN, this macro should be +// the first line in a class declaration. +// +// A class using this macro must call .Pass() (or somehow be an r-value already) +// before it can be: +// +// * Passed as a function argument +// * Used as the right-hand side of an assignment +// * Returned from a function +// +// Each class will still need to define their own "move constructor" and "move +// operator=" to make this useful. Here's an example of the macro, the move +// constructor, and the move operator= from the scoped_ptr class: +// +// template +// class scoped_ptr { +// MOVE_ONLY_TYPE_FOR_CPP_03(scoped_ptr, RValue) +// public: +// scoped_ptr(RValue& other) : ptr_(other.release()) { } +// scoped_ptr& operator=(RValue& other) { +// swap(other); +// return *this; +// } +// }; +// +// Note that the constructor must NOT be marked explicit. +// +// For consistency, the second parameter to the macro should always be RValue +// unless you have a strong reason to do otherwise. It is only exposed as a +// macro parameter so that the move constructor and move operator= don't look +// like they're using a phantom type. +// +// +// HOW THIS WORKS +// +// For a thorough explanation of this technique, see: +// +// http://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Move_Constructor +// +// The summary is that we take advantage of 2 properties: +// +// 1) non-const references will not bind to r-values. +// 2) C++ can apply one user-defined conversion when initializing a +// variable. +// +// The first lets us disable the copy constructor and assignment operator +// by declaring private version of them with a non-const reference parameter. +// +// For l-values, direct initialization still fails like in +// DISALLOW_COPY_AND_ASSIGN because the copy constructor and assignment +// operators are private. +// +// For r-values, the situation is different. The copy constructor and +// assignment operator are not viable due to (1), so we are trying to call +// a non-existent constructor and non-existing operator= rather than a private +// one. Since we have not committed an error quite yet, we can provide an +// alternate conversion sequence and a constructor. We add +// +// * a private struct named "RValue" +// * a user-defined conversion "operator RValue()" +// * a "move constructor" and "move operator=" that take the RValue& as +// their sole parameter. +// +// Only r-values will trigger this sequence and execute our "move constructor" +// or "move operator=." L-values will match the private copy constructor and +// operator= first giving a "private in this context" error. This combination +// gives us a move-only type. +// +// For signaling a destructive transfer of data from an l-value, we provide a +// method named Pass() which creates an r-value for the current instance +// triggering the move constructor or move operator=. +// +// Other ways to get r-values is to use the result of an expression like a +// function call. +// +// Here's an example with comments explaining what gets triggered where: +// +// class Foo { +// MOVE_ONLY_TYPE_FOR_CPP_03(Foo, RValue); +// +// public: +// ... API ... +// Foo(RValue other); // Move constructor. +// Foo& operator=(RValue rhs); // Move operator= +// }; +// +// Foo MakeFoo(); // Function that returns a Foo. +// +// Foo f; +// Foo f_copy(f); // ERROR: Foo(Foo&) is private in this context. +// Foo f_assign; +// f_assign = f; // ERROR: operator=(Foo&) is private in this context. +// +// +// Foo f(MakeFoo()); // R-value so alternate conversion executed. +// Foo f_copy(f.Pass()); // R-value so alternate conversion executed. +// f = f_copy.Pass(); // R-value so alternate conversion executed. +// +// +// IMPLEMENTATION SUBTLETIES WITH RValue +// +// The RValue struct is just a container for a pointer back to the original +// object. It should only ever be created as a temporary, and no external +// class should ever declare it or use it in a parameter. +// +// It is tempting to want to use the RValue type in function parameters, but +// excluding the limited usage here for the move constructor and move +// operator=, doing so would mean that the function could take both r-values +// and l-values equially which is unexpected. See COMPARED To Boost.Move for +// more details. +// +// An alternate, and incorrect, implementation of the RValue class used by +// Boost.Move makes RValue a fieldless child of the move-only type. RValue& +// is then used in place of RValue in the various operators. The RValue& is +// "created" by doing *reinterpret_cast(this). This has the appeal +// of never creating a temporary RValue struct even with optimizations +// disabled. Also, by virtue of inheritance you can treat the RValue +// reference as if it were the move-only type itself. Unfortunately, +// using the result of this reinterpret_cast<> is actually undefined behavior +// due to C++98 5.2.10.7. In certain compilers (e.g., NaCl) the optimizer +// will generate non-working code. +// +// In optimized builds, both implementations generate the same assembly so we +// choose the one that adheres to the standard. +// +// +// WHY HAVE typedef void MoveOnlyTypeForCPP03 +// +// Callback<>/Bind() needs to understand movable-but-not-copyable semantics +// to call .Pass() appropriately when it is expected to transfer the value. +// The cryptic typedef MoveOnlyTypeForCPP03 is added to make this check +// easy and automatic in helper templates for Callback<>/Bind(). +// See IsMoveOnlyType template and its usage in base/callback_internal.h +// for more details. +// +// +// COMPARED TO C++11 +// +// In C++11, you would implement this functionality using an r-value reference +// and our .Pass() method would be replaced with a call to std::move(). +// +// This emulation also has a deficiency where it uses up the single +// user-defined conversion allowed by C++ during initialization. This can +// cause problems in some API edge cases. For instance, in scoped_ptr, it is +// impossible to make a function "void Foo(scoped_ptr p)" accept a +// value of type scoped_ptr even if you add a constructor to +// scoped_ptr<> that would make it look like it should work. C++11 does not +// have this deficiency. +// +// +// COMPARED TO Boost.Move +// +// Our implementation similar to Boost.Move, but we keep the RValue struct +// private to the move-only type, and we don't use the reinterpret_cast<> hack. +// +// In Boost.Move, RValue is the boost::rv<> template. This type can be used +// when writing APIs like: +// +// void MyFunc(boost::rv& f) +// +// that can take advantage of rv<> to avoid extra copies of a type. However you +// would still be able to call this version of MyFunc with an l-value: +// +// Foo f; +// MyFunc(f); // Uh oh, we probably just destroyed |f| w/o calling Pass(). +// +// unless someone is very careful to also declare a parallel override like: +// +// void MyFunc(const Foo& f) +// +// that would catch the l-values first. This was declared unsafe in C++11 and +// a C++11 compiler will explicitly fail MyFunc(f). Unfortunately, we cannot +// ensure this in C++03. +// +// Since we have no need for writing such APIs yet, our implementation keeps +// RValue private and uses a .Pass() method to do the conversion instead of +// trying to write a version of "std::move()." Writing an API like std::move() +// would require the RValue struct to be public. +// +// +// CAVEATS +// +// If you include a move-only type as a field inside a class that does not +// explicitly declare a copy constructor, the containing class's implicit +// copy constructor will change from Containing(const Containing&) to +// Containing(Containing&). This can cause some unexpected errors. +// +// http://llvm.org/bugs/show_bug.cgi?id=11528 +// +// The workaround is to explicitly declare your copy constructor. +// +#define MOVE_ONLY_TYPE_FOR_CPP_03(type, rvalue_type) \ + private: \ + struct rvalue_type { \ + explicit rvalue_type(type* object) : object(object) {} \ + type* object; \ + }; \ + type(type&); \ + void operator=(type&); \ + \ + public: \ + operator rvalue_type() { return rvalue_type(this); } \ + type Pass() { return type(rvalue_type(this)); } \ + typedef void MoveOnlyTypeForCPP03; \ + \ + private: + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_MOVE_H_ diff --git a/include/base/cef_platform_thread.h b/include/base/cef_platform_thread.h new file mode 100644 index 0000000..d3fdd79 --- /dev/null +++ b/include/base/cef_platform_thread.h @@ -0,0 +1,106 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011 +// Google Inc. 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. + +// WARNING: You should *NOT* be using this class directly. PlatformThread is +// the low-level platform-specific abstraction to the OS's threading interface. +// You should instead be using a message-loop driven Thread, see thread.h. + +#ifndef CEF_INCLUDE_BASE_PLATFORM_THREAD_H_ +#define CEF_INCLUDE_BASE_PLATFORM_THREAD_H_ + +#if defined(BASE_THREADING_PLATFORM_THREAD_H_) +// Do nothing if the Chromium header has already been included. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/threading/platform_thread.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include "include/base/cef_basictypes.h" +#include "include/base/cef_build.h" +#include "include/internal/cef_thread_internal.h" + +namespace base { + +// Used for logging. Always an integer value. +typedef cef_platform_thread_id_t PlatformThreadId; + +// Used for thread checking and debugging. +// Meant to be as fast as possible. +// These are produced by PlatformThread::CurrentRef(), and used to later +// check if we are on the same thread or not by using ==. These are safe +// to copy between threads, but can't be copied to another process as they +// have no meaning there. Also, the internal identifier can be re-used +// after a thread dies, so a PlatformThreadRef cannot be reliably used +// to distinguish a new thread from an old, dead thread. +class PlatformThreadRef { + public: + typedef cef_platform_thread_handle_t RefType; + + PlatformThreadRef() : id_(0) {} + + explicit PlatformThreadRef(RefType id) : id_(id) {} + + bool operator==(PlatformThreadRef other) const { return id_ == other.id_; } + + bool is_null() const { return id_ == 0; } + + private: + RefType id_; +}; + +// A namespace for low-level thread functions. +// Chromium uses a class with static methods but CEF uses an actual namespace +// to avoid linker problems with the sandbox libaries on Windows. +namespace PlatformThread { + +// Gets the current thread id, which may be useful for logging purposes. +inline PlatformThreadId CurrentId() { + return cef_get_current_platform_thread_id(); +} + +// Gets the current thread reference, which can be used to check if +// we're on the right thread quickly. +inline PlatformThreadRef CurrentRef() { + return PlatformThreadRef(cef_get_current_platform_thread_handle()); +} + +} // namespace PlatformThread + +} // namespace base + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_PLATFORM_THREAD_H_ diff --git a/include/base/cef_ref_counted.h b/include/base/cef_ref_counted.h new file mode 100644 index 0000000..480b1ce --- /dev/null +++ b/include/base/cef_ref_counted.h @@ -0,0 +1,378 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012 +// Google Inc. 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_BASE_CEF_REF_COUNTED_H_ +#define CEF_INCLUDE_BASE_CEF_REF_COUNTED_H_ +#pragma once + +#if defined(BASE_MEMORY_REF_COUNTED_H_) +// Do nothing if the Chromium header has already been included. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/memory/ref_counted.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include + +#include "include/base/cef_atomic_ref_count.h" +#include "include/base/cef_build.h" +#include "include/base/cef_logging.h" +#include "include/base/cef_thread_collision_warner.h" + +namespace base { + +namespace cef_subtle { + +class RefCountedBase { + public: + bool HasOneRef() const { return ref_count_ == 1; } + + protected: + RefCountedBase() + : ref_count_(0) +#if DCHECK_IS_ON() + , + in_dtor_(false) +#endif + { + } + + ~RefCountedBase() { +#if DCHECK_IS_ON() + DCHECK(in_dtor_) << "RefCounted object deleted without calling Release()"; +#endif + } + + void AddRef() const { +// TODO(maruel): Add back once it doesn't assert 500 times/sec. +// Current thread books the critical section "AddRelease" +// without release it. +// DFAKE_SCOPED_LOCK_THREAD_LOCKED(add_release_); +#if DCHECK_IS_ON() + DCHECK(!in_dtor_); +#endif + ++ref_count_; + } + + // Returns true if the object should self-delete. + bool Release() const { +// TODO(maruel): Add back once it doesn't assert 500 times/sec. +// Current thread books the critical section "AddRelease" +// without release it. +// DFAKE_SCOPED_LOCK_THREAD_LOCKED(add_release_); +#if DCHECK_IS_ON() + DCHECK(!in_dtor_); +#endif + if (--ref_count_ == 0) { +#if DCHECK_IS_ON() + in_dtor_ = true; +#endif + return true; + } + return false; + } + + private: + mutable int ref_count_; +#if DCHECK_IS_ON() + mutable bool in_dtor_; +#endif + + DFAKE_MUTEX(add_release_); + + DISALLOW_COPY_AND_ASSIGN(RefCountedBase); +}; + +class RefCountedThreadSafeBase { + public: + bool HasOneRef() const; + + protected: + RefCountedThreadSafeBase(); + ~RefCountedThreadSafeBase(); + + void AddRef() const; + + // Returns true if the object should self-delete. + bool Release() const; + + private: + mutable AtomicRefCount ref_count_; +#if DCHECK_IS_ON() + mutable bool in_dtor_; +#endif + + DISALLOW_COPY_AND_ASSIGN(RefCountedThreadSafeBase); +}; + +} // namespace cef_subtle + +// +// A base class for reference counted classes. Otherwise, known as a cheap +// knock-off of WebKit's RefCounted class. To use this guy just extend your +// class from it like so: +// +// class MyFoo : public base::RefCounted { +// ... +// private: +// friend class base::RefCounted; +// ~MyFoo(); +// }; +// +// You should always make your destructor private, to avoid any code deleting +// the object accidently while there are references to it. +template +class RefCounted : public cef_subtle::RefCountedBase { + public: + RefCounted() {} + + void AddRef() const { cef_subtle::RefCountedBase::AddRef(); } + + void Release() const { + if (cef_subtle::RefCountedBase::Release()) { + delete static_cast(this); + } + } + + protected: + ~RefCounted() {} + + private: + DISALLOW_COPY_AND_ASSIGN(RefCounted); +}; + +// Forward declaration. +template +class RefCountedThreadSafe; + +// Default traits for RefCountedThreadSafe. Deletes the object when its ref +// count reaches 0. Overload to delete it on a different thread etc. +template +struct DefaultRefCountedThreadSafeTraits { + static void Destruct(const T* x) { + // Delete through RefCountedThreadSafe to make child classes only need to be + // friend with RefCountedThreadSafe instead of this struct, which is an + // implementation detail. + RefCountedThreadSafe::DeleteInternal( + x); + } +}; + +// +// A thread-safe variant of RefCounted +// +// class MyFoo : public base::RefCountedThreadSafe { +// ... +// }; +// +// If you're using the default trait, then you should add compile time +// asserts that no one else is deleting your object. i.e. +// private: +// friend class base::RefCountedThreadSafe; +// ~MyFoo(); +template > +class RefCountedThreadSafe : public cef_subtle::RefCountedThreadSafeBase { + public: + RefCountedThreadSafe() {} + + void AddRef() const { cef_subtle::RefCountedThreadSafeBase::AddRef(); } + + void Release() const { + if (cef_subtle::RefCountedThreadSafeBase::Release()) { + Traits::Destruct(static_cast(this)); + } + } + + protected: + ~RefCountedThreadSafe() {} + + private: + friend struct DefaultRefCountedThreadSafeTraits; + static void DeleteInternal(const T* x) { delete x; } + + DISALLOW_COPY_AND_ASSIGN(RefCountedThreadSafe); +}; + +// +// A thread-safe wrapper for some piece of data so we can place other +// things in scoped_refptrs<>. +// +template +class RefCountedData + : public base::RefCountedThreadSafe> { + public: + RefCountedData() : data() {} + RefCountedData(const T& in_value) : data(in_value) {} + + T data; + + private: + friend class base::RefCountedThreadSafe>; + ~RefCountedData() {} +}; + +} // namespace base + +// +// 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: +// +// class MyFoo : public RefCounted { +// ... +// }; +// +// void some_function() { +// scoped_refptr foo = new MyFoo(); +// foo->Method(param); +// // |foo| is released when this function returns +// } +// +// void some_other_function() { +// scoped_refptr foo = new MyFoo(); +// ... +// foo = NULL; // explicitly releases |foo| +// ... +// if (foo) +// foo->Method(param); +// } +// +// The above examples show how scoped_refptr acts like a pointer to T. +// Given two scoped_refptr classes, it is also possible to exchange +// references between the two objects, like so: +// +// { +// scoped_refptr a = new MyFoo(); +// scoped_refptr b; +// +// b.swap(a); +// // now, |b| references the MyFoo object, and |a| references NULL. +// } +// +// To make both |a| and |b| in the above example reference the same MyFoo +// object, simply use the assignment operator: +// +// { +// scoped_refptr a = new MyFoo(); +// scoped_refptr b; +// +// b = a; +// // now, |a| and |b| each own a reference to the same MyFoo object. +// } +// +template +class scoped_refptr { + public: + typedef T element_type; + + scoped_refptr() : ptr_(NULL) {} + + scoped_refptr(T* p) : ptr_(p) { + if (ptr_) + ptr_->AddRef(); + } + + scoped_refptr(const scoped_refptr& r) : ptr_(r.ptr_) { + if (ptr_) + ptr_->AddRef(); + } + + template + scoped_refptr(const scoped_refptr& r) : ptr_(r.get()) { + if (ptr_) + ptr_->AddRef(); + } + + ~scoped_refptr() { + if (ptr_) + ptr_->Release(); + } + + T* get() const { return ptr_; } + + // Allow scoped_refptr to be used in boolean expression + // and comparison operations. + operator T*() const { return ptr_; } + + T* operator->() const { + assert(ptr_ != NULL); + return ptr_; + } + + scoped_refptr& operator=(T* p) { + // AddRef first so that self assignment should work + if (p) + p->AddRef(); + T* old_ptr = ptr_; + ptr_ = p; + if (old_ptr) + old_ptr->Release(); + return *this; + } + + scoped_refptr& operator=(const scoped_refptr& r) { + return *this = r.ptr_; + } + + template + scoped_refptr& operator=(const scoped_refptr& r) { + return *this = r.get(); + } + + void swap(T** pp) { + T* p = ptr_; + ptr_ = *pp; + *pp = p; + } + + void swap(scoped_refptr& r) { swap(&r.ptr_); } + + protected: + T* ptr_; +}; + +// Handy utility for creating a scoped_refptr out of a T* explicitly without +// having to retype all the template arguments +template +scoped_refptr make_scoped_refptr(T* t) { + return scoped_refptr(t); +} + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_REF_COUNTED_H_ diff --git a/include/base/cef_scoped_ptr.h b/include/base/cef_scoped_ptr.h new file mode 100644 index 0000000..eb9e0e2 --- /dev/null +++ b/include/base/cef_scoped_ptr.h @@ -0,0 +1,625 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012 +// Google Inc. 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. + +// Scopers help you manage ownership of a pointer, helping you easily manage a +// pointer within a scope, and automatically destroying the pointer at the end +// of a scope. There are two main classes you will use, which correspond to the +// operators new/delete and new[]/delete[]. +// +// Example usage (scoped_ptr): +// { +// scoped_ptr foo(new Foo("wee")); +// } // foo goes out of scope, releasing the pointer with it. +// +// { +// scoped_ptr foo; // No pointer managed. +// foo.reset(new Foo("wee")); // Now a pointer is managed. +// foo.reset(new Foo("wee2")); // Foo("wee") was destroyed. +// foo.reset(new Foo("wee3")); // Foo("wee2") was destroyed. +// foo->Method(); // Foo::Method() called. +// foo.get()->Method(); // Foo::Method() called. +// SomeFunc(foo.release()); // SomeFunc takes ownership, foo no longer +// // manages a pointer. +// foo.reset(new Foo("wee4")); // foo manages a pointer again. +// foo.reset(); // Foo("wee4") destroyed, foo no longer +// // manages a pointer. +// } // foo wasn't managing a pointer, so nothing was destroyed. +// +// Example usage (scoped_ptr): +// { +// scoped_ptr foo(new Foo[100]); +// foo.get()->Method(); // Foo::Method on the 0th element. +// foo[10].Method(); // Foo::Method on the 10th element. +// } +// +// These scopers also implement part of the functionality of C++11 unique_ptr +// in that they are "movable but not copyable." You can use the scopers in +// the parameter and return types of functions to signify ownership transfer +// in to and out of a function. When calling a function that has a scoper +// as the argument type, it must be called with the result of an analogous +// scoper's Pass() function or another function that generates a temporary; +// passing by copy will NOT work. Here is an example using scoped_ptr: +// +// void TakesOwnership(scoped_ptr arg) { +// // Do something with arg +// } +// scoped_ptr CreateFoo() { +// // No need for calling Pass() because we are constructing a temporary +// // for the return value. +// return scoped_ptr(new Foo("new")); +// } +// scoped_ptr PassThru(scoped_ptr arg) { +// return arg.Pass(); +// } +// +// { +// scoped_ptr ptr(new Foo("yay")); // ptr manages Foo("yay"). +// TakesOwnership(ptr.Pass()); // ptr no longer owns Foo("yay"). +// scoped_ptr ptr2 = CreateFoo(); // ptr2 owns the return Foo. +// scoped_ptr ptr3 = // ptr3 now owns what was in ptr2. +// PassThru(ptr2.Pass()); // ptr2 is correspondingly NULL. +// } +// +// Notice that if you do not call Pass() when returning from PassThru(), or +// when invoking TakesOwnership(), the code will not compile because scopers +// are not copyable; they only implement move semantics which require calling +// the Pass() function to signify a destructive transfer of state. CreateFoo() +// is different though because we are constructing a temporary on the return +// line and thus can avoid needing to call Pass(). +// +// Pass() properly handles upcast in initialization, i.e. you can use a +// scoped_ptr to initialize a scoped_ptr: +// +// scoped_ptr foo(new Foo()); +// scoped_ptr parent(foo.Pass()); +// +// PassAs<>() should be used to upcast return value in return statement: +// +// scoped_ptr CreateFoo() { +// scoped_ptr result(new FooChild()); +// return result.PassAs(); +// } +// +// Note that PassAs<>() is implemented only for scoped_ptr, but not for +// scoped_ptr. This is because casting array pointers may not be safe. + +#ifndef CEF_INCLUDE_BASE_CEF_MEMORY_SCOPED_PTR_H_ +#define CEF_INCLUDE_BASE_CEF_MEMORY_SCOPED_PTR_H_ +#pragma once + +#if defined(BASE_MEMORY_SCOPED_PTR_H_) +// Do nothing if the Chromium header has already been included. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(USING_CHROMIUM_INCLUDES) +// Do nothing when building CEF. +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +// This is an implementation designed to match the anticipated future TR2 +// implementation of the scoped_ptr class. + +#include +#include +#include + +#include // For std::swap(). + +#include "include/base/cef_basictypes.h" +#include "include/base/cef_build.h" +#include "include/base/cef_macros.h" +#include "include/base/cef_move.h" +#include "include/base/cef_template_util.h" + +namespace base { + +namespace subtle { +class RefCountedBase; +class RefCountedThreadSafeBase; +} // namespace subtle + +// Function object which deletes its parameter, which must be a pointer. +// If C is an array type, invokes 'delete[]' on the parameter; otherwise, +// invokes 'delete'. The default deleter for scoped_ptr. +template +struct DefaultDeleter { + DefaultDeleter() {} + template + DefaultDeleter(const DefaultDeleter& other) { + // IMPLEMENTATION NOTE: C++11 20.7.1.1.2p2 only provides this constructor + // if U* is implicitly convertible to T* and U is not an array type. + // + // Correct implementation should use SFINAE to disable this + // constructor. However, since there are no other 1-argument constructors, + // using a COMPILE_ASSERT() based on is_convertible<> and requiring + // complete types is simpler and will cause compile failures for equivalent + // misuses. + // + // Note, the is_convertible check also ensures that U is not an + // array. T is guaranteed to be a non-array, so any U* where U is an array + // cannot convert to T*. + enum { T_must_be_complete = sizeof(T) }; + enum { U_must_be_complete = sizeof(U) }; + COMPILE_ASSERT((base::is_convertible::value), + U_ptr_must_implicitly_convert_to_T_ptr); + } + inline void operator()(T* ptr) const { + enum { type_must_be_complete = sizeof(T) }; + delete ptr; + } +}; + +// Specialization of DefaultDeleter for array types. +template +struct DefaultDeleter { + inline void operator()(T* ptr) const { + enum { type_must_be_complete = sizeof(T) }; + delete[] ptr; + } + + private: + // Disable this operator for any U != T because it is undefined to execute + // an array delete when the static type of the array mismatches the dynamic + // type. + // + // References: + // C++98 [expr.delete]p3 + // http://cplusplus.github.com/LWG/lwg-defects.html#938 + template + void operator()(U* array) const; +}; + +template +struct DefaultDeleter { + // Never allow someone to declare something like scoped_ptr. + COMPILE_ASSERT(sizeof(T) == -1, do_not_use_array_with_size_as_type); +}; + +// Function object which invokes 'free' on its parameter, which must be +// a pointer. Can be used to store malloc-allocated pointers in scoped_ptr: +// +// scoped_ptr foo_ptr( +// static_cast(malloc(sizeof(int)))); +struct FreeDeleter { + inline void operator()(void* ptr) const { free(ptr); } +}; + +namespace cef_internal { + +template +struct IsNotRefCounted { + enum { + value = + !base::is_convertible::value && + !base::is_convertible::value + }; +}; + +// Minimal implementation of the core logic of scoped_ptr, suitable for +// reuse in both scoped_ptr and its specializations. +template +class scoped_ptr_impl { + public: + explicit scoped_ptr_impl(T* p) : data_(p) {} + + // Initializer for deleters that have data parameters. + scoped_ptr_impl(T* p, const D& d) : data_(p, d) {} + + // Templated constructor that destructively takes the value from another + // scoped_ptr_impl. + template + scoped_ptr_impl(scoped_ptr_impl* other) + : data_(other->release(), other->get_deleter()) { + // We do not support move-only deleters. We could modify our move + // emulation to have base::subtle::move() and base::subtle::forward() + // functions that are imperfect emulations of their C++11 equivalents, + // but until there's a requirement, just assume deleters are copyable. + } + + template + void TakeState(scoped_ptr_impl* other) { + // See comment in templated constructor above regarding lack of support + // for move-only deleters. + reset(other->release()); + get_deleter() = other->get_deleter(); + } + + ~scoped_ptr_impl() { + if (data_.ptr != NULL) { + // Not using get_deleter() saves one function call in non-optimized + // builds. + static_cast(data_)(data_.ptr); + } + } + + void reset(T* p) { + // This is a self-reset, which is no longer allowed: http://crbug.com/162971 + if (p != NULL && p == data_.ptr) + abort(); + + // Note that running data_.ptr = p can lead to undefined behavior if + // get_deleter()(get()) deletes this. In order to prevent this, reset() + // should update the stored pointer before deleting its old value. + // + // However, changing reset() to use that behavior may cause current code to + // break in unexpected ways. If the destruction of the owned object + // dereferences the scoped_ptr when it is destroyed by a call to reset(), + // then it will incorrectly dispatch calls to |p| rather than the original + // value of |data_.ptr|. + // + // During the transition period, set the stored pointer to NULL while + // deleting the object. Eventually, this safety check will be removed to + // prevent the scenario initially described from occuring and + // http://crbug.com/176091 can be closed. + T* old = data_.ptr; + data_.ptr = NULL; + if (old != NULL) + static_cast(data_)(old); + data_.ptr = p; + } + + T* get() const { return data_.ptr; } + + D& get_deleter() { return data_; } + const D& get_deleter() const { return data_; } + + void swap(scoped_ptr_impl& p2) { + // Standard swap idiom: 'using std::swap' ensures that std::swap is + // present in the overload set, but we call swap unqualified so that + // any more-specific overloads can be used, if available. + using std::swap; + swap(static_cast(data_), static_cast(p2.data_)); + swap(data_.ptr, p2.data_.ptr); + } + + T* release() { + T* old_ptr = data_.ptr; + data_.ptr = NULL; + return old_ptr; + } + + private: + // Needed to allow type-converting constructor. + template + friend class scoped_ptr_impl; + + // Use the empty base class optimization to allow us to have a D + // member, while avoiding any space overhead for it when D is an + // empty class. See e.g. http://www.cantrip.org/emptyopt.html for a good + // discussion of this technique. + struct Data : public D { + explicit Data(T* ptr_in) : ptr(ptr_in) {} + Data(T* ptr_in, const D& other) : D(other), ptr(ptr_in) {} + T* ptr; + }; + + Data data_; + + DISALLOW_COPY_AND_ASSIGN(scoped_ptr_impl); +}; + +} // namespace cef_internal + +} // namespace base + +// A scoped_ptr is like a T*, except that the destructor of scoped_ptr +// automatically deletes the pointer it holds (if any). +// That is, scoped_ptr owns the T object that it points to. +// Like a T*, a scoped_ptr may hold either NULL or a pointer to a T object. +// Also like T*, scoped_ptr is thread-compatible, and once you +// dereference it, you get the thread safety guarantees of T. +// +// The size of scoped_ptr is small. On most compilers, when using the +// DefaultDeleter, sizeof(scoped_ptr) == sizeof(T*). Custom deleters will +// increase the size proportional to whatever state they need to have. See +// comments inside scoped_ptr_impl<> for details. +// +// Current implementation targets having a strict subset of C++11's +// unique_ptr<> features. Known deficiencies include not supporting move-only +// deleteres, function pointers as deleters, and deleters with reference +// types. +template > +class scoped_ptr { + MOVE_ONLY_TYPE_FOR_CPP_03(scoped_ptr, RValue) + + COMPILE_ASSERT(base::cef_internal::IsNotRefCounted::value, + T_is_refcounted_type_and_needs_scoped_refptr); + + public: + // The element and deleter types. + typedef T element_type; + typedef D deleter_type; + + // Constructor. Defaults to initializing with NULL. + scoped_ptr() : impl_(NULL) {} + + // Constructor. Takes ownership of p. + explicit scoped_ptr(element_type* p) : impl_(p) {} + + // Constructor. Allows initialization of a stateful deleter. + scoped_ptr(element_type* p, const D& d) : impl_(p, d) {} + + // Constructor. Allows construction from a scoped_ptr rvalue for a + // convertible type and deleter. + // + // IMPLEMENTATION NOTE: C++11 unique_ptr<> keeps this constructor distinct + // from the normal move constructor. By C++11 20.7.1.2.1.21, this constructor + // has different post-conditions if D is a reference type. Since this + // implementation does not support deleters with reference type, + // we do not need a separate move constructor allowing us to avoid one + // use of SFINAE. You only need to care about this if you modify the + // implementation of scoped_ptr. + template + scoped_ptr(scoped_ptr other) : impl_(&other.impl_) { + COMPILE_ASSERT(!base::is_array::value, U_cannot_be_an_array); + } + + // Constructor. Move constructor for C++03 move emulation of this type. + scoped_ptr(RValue rvalue) : impl_(&rvalue.object->impl_) {} + + // operator=. Allows assignment from a scoped_ptr rvalue for a convertible + // type and deleter. + // + // IMPLEMENTATION NOTE: C++11 unique_ptr<> keeps this operator= distinct from + // the normal move assignment operator. By C++11 20.7.1.2.3.4, this templated + // form has different requirements on for move-only Deleters. Since this + // implementation does not support move-only Deleters, we do not need a + // separate move assignment operator allowing us to avoid one use of SFINAE. + // You only need to care about this if you modify the implementation of + // scoped_ptr. + template + scoped_ptr& operator=(scoped_ptr rhs) { + COMPILE_ASSERT(!base::is_array::value, U_cannot_be_an_array); + impl_.TakeState(&rhs.impl_); + return *this; + } + + // Reset. Deletes the currently owned object, if any. + // Then takes ownership of a new object, if given. + void reset(element_type* p = NULL) { impl_.reset(p); } + + // Accessors to get the owned object. + // operator* and operator-> will assert() if there is no current object. + element_type& operator*() const { + assert(impl_.get() != NULL); + return *impl_.get(); + } + element_type* operator->() const { + assert(impl_.get() != NULL); + return impl_.get(); + } + element_type* get() const { return impl_.get(); } + + // Access to the deleter. + deleter_type& get_deleter() { return impl_.get_deleter(); } + const deleter_type& get_deleter() const { return impl_.get_deleter(); } + + // Allow scoped_ptr to be used in boolean expressions, but not + // implicitly convertible to a real bool (which is dangerous). + // + // Note that this trick is only safe when the == and != operators + // are declared explicitly, as otherwise "scoped_ptr1 == + // scoped_ptr2" will compile but do the wrong thing (i.e., convert + // to Testable and then do the comparison). + private: + typedef base::cef_internal::scoped_ptr_impl + scoped_ptr::*Testable; + + public: + operator Testable() const { return impl_.get() ? &scoped_ptr::impl_ : NULL; } + + // Comparison operators. + // These return whether two scoped_ptr refer to the same object, not just to + // two different but equal objects. + bool operator==(const element_type* p) const { return impl_.get() == p; } + bool operator!=(const element_type* p) const { return impl_.get() != p; } + + // Swap two scoped pointers. + void swap(scoped_ptr& p2) { impl_.swap(p2.impl_); } + + // Release a pointer. + // The return value is the current pointer held by this object. + // If this object holds a NULL pointer, the return value is NULL. + // After this operation, this object will hold a NULL pointer, + // and will not own the object any more. + element_type* release() WARN_UNUSED_RESULT { return impl_.release(); } + + // C++98 doesn't support functions templates with default parameters which + // makes it hard to write a PassAs() that understands converting the deleter + // while preserving simple calling semantics. + // + // Until there is a use case for PassAs() with custom deleters, just ignore + // the custom deleter. + template + scoped_ptr PassAs() { + return scoped_ptr(Pass()); + } + + private: + // Needed to reach into |impl_| in the constructor. + template + friend class scoped_ptr; + base::cef_internal::scoped_ptr_impl impl_; + + // Forbidden for API compatibility with std::unique_ptr. + explicit scoped_ptr(int disallow_construction_from_null); + + // Forbid comparison of scoped_ptr types. If U != T, it totally + // doesn't make sense, and if U == T, it still doesn't make sense + // because you should never have the same object owned by two different + // scoped_ptrs. + template + bool operator==(scoped_ptr const& p2) const; + template + bool operator!=(scoped_ptr const& p2) const; +}; + +template +class scoped_ptr { + MOVE_ONLY_TYPE_FOR_CPP_03(scoped_ptr, RValue) + + public: + // The element and deleter types. + typedef T element_type; + typedef D deleter_type; + + // Constructor. Defaults to initializing with NULL. + scoped_ptr() : impl_(NULL) {} + + // Constructor. Stores the given array. Note that the argument's type + // must exactly match T*. In particular: + // - it cannot be a pointer to a type derived from T, because it is + // inherently unsafe in the general case to access an array through a + // pointer whose dynamic type does not match its static type (eg., if + // T and the derived types had different sizes access would be + // incorrectly calculated). Deletion is also always undefined + // (C++98 [expr.delete]p3). If you're doing this, fix your code. + // - it cannot be NULL, because NULL is an integral expression, not a + // pointer to T. Use the no-argument version instead of explicitly + // passing NULL. + // - it cannot be const-qualified differently from T per unique_ptr spec + // (http://cplusplus.github.com/LWG/lwg-active.html#2118). Users wanting + // to work around this may use implicit_cast(). + // However, because of the first bullet in this comment, users MUST + // NOT use implicit_cast() to upcast the static type of the array. + explicit scoped_ptr(element_type* array) : impl_(array) {} + + // Constructor. Move constructor for C++03 move emulation of this type. + scoped_ptr(RValue rvalue) : impl_(&rvalue.object->impl_) {} + + // operator=. Move operator= for C++03 move emulation of this type. + scoped_ptr& operator=(RValue rhs) { + impl_.TakeState(&rhs.object->impl_); + return *this; + } + + // Reset. Deletes the currently owned array, if any. + // Then takes ownership of a new object, if given. + void reset(element_type* array = NULL) { impl_.reset(array); } + + // Accessors to get the owned array. + element_type& operator[](size_t i) const { + assert(impl_.get() != NULL); + return impl_.get()[i]; + } + element_type* get() const { return impl_.get(); } + + // Access to the deleter. + deleter_type& get_deleter() { return impl_.get_deleter(); } + const deleter_type& get_deleter() const { return impl_.get_deleter(); } + + // Allow scoped_ptr to be used in boolean expressions, but not + // implicitly convertible to a real bool (which is dangerous). + private: + typedef base::cef_internal::scoped_ptr_impl + scoped_ptr::*Testable; + + public: + operator Testable() const { return impl_.get() ? &scoped_ptr::impl_ : NULL; } + + // Comparison operators. + // These return whether two scoped_ptr refer to the same object, not just to + // two different but equal objects. + bool operator==(element_type* array) const { return impl_.get() == array; } + bool operator!=(element_type* array) const { return impl_.get() != array; } + + // Swap two scoped pointers. + void swap(scoped_ptr& p2) { impl_.swap(p2.impl_); } + + // Release a pointer. + // The return value is the current pointer held by this object. + // If this object holds a NULL pointer, the return value is NULL. + // After this operation, this object will hold a NULL pointer, + // and will not own the object any more. + element_type* release() WARN_UNUSED_RESULT { return impl_.release(); } + + private: + // Force element_type to be a complete type. + enum { type_must_be_complete = sizeof(element_type) }; + + // Actually hold the data. + base::cef_internal::scoped_ptr_impl impl_; + + // Disable initialization from any type other than element_type*, by + // providing a constructor that matches such an initialization, but is + // private and has no definition. This is disabled because it is not safe to + // call delete[] on an array whose static type does not match its dynamic + // type. + template + explicit scoped_ptr(U* array); + explicit scoped_ptr(int disallow_construction_from_null); + + // Disable reset() from any type other than element_type*, for the same + // reasons as the constructor above. + template + void reset(U* array); + void reset(int disallow_reset_from_null); + + // Forbid comparison of scoped_ptr types. If U != T, it totally + // doesn't make sense, and if U == T, it still doesn't make sense + // because you should never have the same object owned by two different + // scoped_ptrs. + template + bool operator==(scoped_ptr const& p2) const; + template + bool operator!=(scoped_ptr const& p2) const; +}; + +// Free functions +template +void swap(scoped_ptr& p1, scoped_ptr& p2) { + p1.swap(p2); +} + +template +bool operator==(T* p1, const scoped_ptr& p2) { + return p1 == p2.get(); +} + +template +bool operator!=(T* p1, const scoped_ptr& p2) { + return p1 != p2.get(); +} + +// A function to convert T* into scoped_ptr +// Doing e.g. make_scoped_ptr(new FooBarBaz(arg)) is a shorter notation +// for scoped_ptr >(new FooBarBaz(arg)) +template +scoped_ptr make_scoped_ptr(T* ptr) { + return scoped_ptr(ptr); +} + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_MEMORY_SCOPED_PTR_H_ diff --git a/include/base/cef_string16.h b/include/base/cef_string16.h new file mode 100644 index 0000000..4275640 --- /dev/null +++ b/include/base/cef_string16.h @@ -0,0 +1,214 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2013 +// Google Inc. 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_BASE_CEF_STRING16_H_ +#define CEF_INCLUDE_BASE_CEF_STRING16_H_ +#pragma once + +#if defined(BASE_STRINGS_STRING16_H_) +// Do nothing if the Chromium header has already been included. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/strings/string16.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. +// WHAT: +// A version of std::basic_string that provides 2-byte characters even when +// wchar_t is not implemented as a 2-byte type. You can access this class as +// string16. We also define char16, which string16 is based upon. +// +// WHY: +// On Windows, wchar_t is 2 bytes, and it can conveniently handle UTF-16/UCS-2 +// data. Plenty of existing code operates on strings encoded as UTF-16. +// +// On many other platforms, sizeof(wchar_t) is 4 bytes by default. We can make +// it 2 bytes by using the GCC flag -fshort-wchar. But then std::wstring fails +// at run time, because it calls some functions (like wcslen) that come from +// the system's native C library -- which was built with a 4-byte wchar_t! +// It's wasteful to use 4-byte wchar_t strings to carry UTF-16 data, and it's +// entirely improper on those systems where the encoding of wchar_t is defined +// as UTF-32. +// +// Here, we define string16, which is similar to std::wstring but replaces all +// libc functions with custom, 2-byte-char compatible routines. It is capable +// of carrying UTF-16-encoded data. + +#include +#include + +#include "include/base/cef_basictypes.h" + +#if defined(WCHAR_T_IS_UTF16) + +namespace base { + +typedef wchar_t char16; +typedef std::wstring string16; +typedef std::char_traits string16_char_traits; + +} // namespace base + +#elif defined(WCHAR_T_IS_UTF32) + +#include // For uint16_t + +#include "include/base/cef_macros.h" + +namespace base { + +typedef uint16_t char16; + +// char16 versions of the functions required by string16_char_traits; these +// are based on the wide character functions of similar names ("w" or "wcs" +// instead of "c16"). +int c16memcmp(const char16* s1, const char16* s2, size_t n); +size_t c16len(const char16* s); +const char16* c16memchr(const char16* s, char16 c, size_t n); +char16* c16memmove(char16* s1, const char16* s2, size_t n); +char16* c16memcpy(char16* s1, const char16* s2, size_t n); +char16* c16memset(char16* s, char16 c, size_t n); + +struct string16_char_traits { + typedef char16 char_type; + typedef int int_type; + + // int_type needs to be able to hold each possible value of char_type, and in + // addition, the distinct value of eof(). + COMPILE_ASSERT(sizeof(int_type) > sizeof(char_type), unexpected_type_width); + + typedef std::streamoff off_type; + typedef mbstate_t state_type; + typedef std::fpos pos_type; + + static void assign(char_type& c1, const char_type& c2) { c1 = c2; } + + static bool eq(const char_type& c1, const char_type& c2) { return c1 == c2; } + static bool lt(const char_type& c1, const char_type& c2) { return c1 < c2; } + + static int compare(const char_type* s1, const char_type* s2, size_t n) { + return c16memcmp(s1, s2, n); + } + + static size_t length(const char_type* s) { return c16len(s); } + + static const char_type* find(const char_type* s, + size_t n, + const char_type& a) { + return c16memchr(s, a, n); + } + + static char_type* move(char_type* s1, const char_type* s2, int_type n) { + return c16memmove(s1, s2, n); + } + + static char_type* copy(char_type* s1, const char_type* s2, size_t n) { + return c16memcpy(s1, s2, n); + } + + static char_type* assign(char_type* s, size_t n, char_type a) { + return c16memset(s, a, n); + } + + static int_type not_eof(const int_type& c) { + return eq_int_type(c, eof()) ? 0 : c; + } + + static char_type to_char_type(const int_type& c) { return char_type(c); } + + static int_type to_int_type(const char_type& c) { return int_type(c); } + + static bool eq_int_type(const int_type& c1, const int_type& c2) { + return c1 == c2; + } + + static int_type eof() { return static_cast(EOF); } +}; + +typedef std::basic_string string16; + +extern std::ostream& operator<<(std::ostream& out, const string16& str); + +// This is required by googletest to print a readable output on test failures. +extern void PrintTo(const string16& str, std::ostream* out); + +} // namespace base + +// The string class will be explicitly instantiated only once, in string16.cc. +// +// std::basic_string<> in GNU libstdc++ contains a static data member, +// _S_empty_rep_storage, to represent empty strings. When an operation such +// as assignment or destruction is performed on a string, causing its existing +// data member to be invalidated, it must not be freed if this static data +// member is being used. Otherwise, it counts as an attempt to free static +// (and not allocated) data, which is a memory error. +// +// Generally, due to C++ template magic, _S_empty_rep_storage will be marked +// as a coalesced symbol, meaning that the linker will combine multiple +// instances into a single one when generating output. +// +// If a string class is used by multiple shared libraries, a problem occurs. +// Each library will get its own copy of _S_empty_rep_storage. When strings +// are passed across a library boundary for alteration or destruction, memory +// errors will result. GNU libstdc++ contains a configuration option, +// --enable-fully-dynamic-string (_GLIBCXX_FULLY_DYNAMIC_STRING), which +// disables the static data member optimization, but it's a good optimization +// and non-STL code is generally at the mercy of the system's STL +// configuration. Fully-dynamic strings are not the default for GNU libstdc++ +// libstdc++ itself or for the libstdc++ installations on the systems we care +// about, such as Mac OS X and relevant flavors of Linux. +// +// See also http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24196 . +// +// To avoid problems, string classes need to be explicitly instantiated only +// once, in exactly one library. All other string users see it via an "extern" +// declaration. This is precisely how GNU libstdc++ handles +// std::basic_string (string) and std::basic_string (wstring). +// +// This also works around a Mac OS X linker bug in ld64-85.2.1 (Xcode 3.1.2), +// in which the linker does not fully coalesce symbols when dead code +// stripping is enabled. This bug causes the memory errors described above +// to occur even when a std::basic_string<> does not cross shared library +// boundaries, such as in statically-linked executables. +// +// TODO(mark): File this bug with Apple and update this note with a bug number. + +extern template class std::basic_string; + +#endif // WCHAR_T_IS_UTF32 + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_STRING16_H_ diff --git a/include/base/cef_template_util.h b/include/base/cef_template_util.h new file mode 100644 index 0000000..38fa583 --- /dev/null +++ b/include/base/cef_template_util.h @@ -0,0 +1,214 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011 +// Google Inc. 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_BASE_CEF_TEMPLATE_UTIL_H_ +#define CEF_INCLUDE_BASE_CEF_TEMPLATE_UTIL_H_ +#pragma once + +#if defined(BASE_TEMPLATE_UTIL_H_) +// Do nothing if the Chromium header has already been included. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/template_util.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include // For size_t. + +#include "include/base/cef_build.h" + +namespace base { + +// template definitions from tr1 + +template +struct integral_constant { + static const T value = v; + typedef T value_type; + typedef integral_constant type; +}; + +template +const T integral_constant::value; + +typedef integral_constant true_type; +typedef integral_constant false_type; + +template +struct is_pointer : false_type {}; +template +struct is_pointer : true_type {}; + +// Member function pointer detection up to four params. Add more as needed +// below. This is built-in to C++ 11, and we can remove this when we switch. +template +struct is_member_function_pointer : false_type {}; + +template +struct is_member_function_pointer : true_type {}; +template +struct is_member_function_pointer : true_type {}; + +template +struct is_member_function_pointer : true_type {}; +template +struct is_member_function_pointer : true_type {}; + +template +struct is_member_function_pointer : true_type {}; +template +struct is_member_function_pointer : true_type {}; + +template +struct is_member_function_pointer : true_type {}; +template +struct is_member_function_pointer : true_type {}; + +template +struct is_member_function_pointer : true_type {}; +template +struct is_member_function_pointer : true_type {}; + +template +struct is_same : public false_type {}; +template +struct is_same : true_type {}; + +template +struct is_array : public false_type {}; +template +struct is_array : public true_type {}; +template +struct is_array : public true_type {}; + +template +struct is_non_const_reference : false_type {}; +template +struct is_non_const_reference : true_type {}; +template +struct is_non_const_reference : false_type {}; + +template +struct is_const : false_type {}; +template +struct is_const : true_type {}; + +template +struct is_void : false_type {}; +template <> +struct is_void : true_type {}; + +namespace cef_internal { + +// Types YesType and NoType are guaranteed such that sizeof(YesType) < +// sizeof(NoType). +typedef char YesType; + +struct NoType { + YesType dummy[2]; +}; + +// This class is an implementation detail for is_convertible, and you +// don't need to know how it works to use is_convertible. For those +// who care: we declare two different functions, one whose argument is +// of type To and one with a variadic argument list. We give them +// return types of different size, so we can use sizeof to trick the +// compiler into telling us which function it would have chosen if we +// had called it with an argument of type From. See Alexandrescu's +// _Modern C++ Design_ for more details on this sort of trick. + +struct ConvertHelper { + template + static YesType Test(To); + + template + static NoType Test(...); + + template + static From& Create(); +}; + +// Used to determine if a type is a struct/union/class. Inspired by Boost's +// is_class type_trait implementation. +struct IsClassHelper { + template + static YesType Test(void (C::*)(void)); + + template + static NoType Test(...); +}; + +} // namespace cef_internal + +// Inherits from true_type if From is convertible to To, false_type otherwise. +// +// Note that if the type is convertible, this will be a true_type REGARDLESS +// of whether or not the conversion would emit a warning. +template +struct is_convertible + : integral_constant( + cef_internal::ConvertHelper::Create())) == + sizeof(cef_internal::YesType)> {}; + +template +struct is_class + : integral_constant(0)) == + sizeof(cef_internal::YesType)> {}; + +template +struct enable_if {}; + +template +struct enable_if { + typedef T type; +}; + +} // namespace base + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_TEMPLATE_UTIL_H_ diff --git a/include/base/cef_thread_checker.h b/include/base/cef_thread_checker.h new file mode 100644 index 0000000..e48c8d0 --- /dev/null +++ b/include/base/cef_thread_checker.h @@ -0,0 +1,121 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012 +// Google Inc. 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_BASE_THREAD_CHECKER_H_ +#define CEF_INCLUDE_BASE_THREAD_CHECKER_H_ +#pragma once + +#if defined(BASE_THREADING_THREAD_CHECKER_H_) +// Do nothing if the Chromium header has already been included. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/threading/thread_checker.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include "include/base/cef_logging.h" +#include "include/base/internal/cef_thread_checker_impl.h" + +// Apart from debug builds, we also enable the thread checker in +// builds with DCHECK_ALWAYS_ON so that trybots and waterfall bots +// with this define will get the same level of thread checking as +// debug bots. +#if DCHECK_IS_ON() +#define ENABLE_THREAD_CHECKER 1 +#else +#define ENABLE_THREAD_CHECKER 0 +#endif + +namespace base { + +namespace cef_internal { + +// Do nothing implementation, for use in release mode. +// +// Note: You should almost always use the ThreadChecker class to get the +// right version for your build configuration. +class ThreadCheckerDoNothing { + public: + bool CalledOnValidThread() const { return true; } + + void DetachFromThread() {} +}; + +} // namespace cef_internal + +// ThreadChecker is a helper class used to help verify that some methods of a +// class are called from the same thread. It provides identical functionality to +// base::NonThreadSafe, but it is meant to be held as a member variable, rather +// than inherited from base::NonThreadSafe. +// +// While inheriting from base::NonThreadSafe may give a clear indication about +// the thread-safety of a class, it may also lead to violations of the style +// guide with regard to multiple inheritance. The choice between having a +// ThreadChecker member and inheriting from base::NonThreadSafe should be based +// on whether: +// - Derived classes need to know the thread they belong to, as opposed to +// having that functionality fully encapsulated in the base class. +// - Derived classes should be able to reassign the base class to another +// thread, via DetachFromThread. +// +// If neither of these are true, then having a ThreadChecker member and calling +// CalledOnValidThread is the preferable solution. +// +// Example: +// class MyClass { +// public: +// void Foo() { +// DCHECK(thread_checker_.CalledOnValidThread()); +// ... (do stuff) ... +// } +// +// private: +// ThreadChecker thread_checker_; +// } +// +// In Release mode, CalledOnValidThread will always return true. +#if ENABLE_THREAD_CHECKER +class ThreadChecker : public cef_internal::ThreadCheckerImpl {}; +#else +class ThreadChecker : public cef_internal::ThreadCheckerDoNothing {}; +#endif // ENABLE_THREAD_CHECKER + +#undef ENABLE_THREAD_CHECKER + +} // namespace base + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_THREAD_CHECKER_H_ diff --git a/include/base/cef_thread_collision_warner.h b/include/base/cef_thread_collision_warner.h new file mode 100644 index 0000000..53f6ef6 --- /dev/null +++ b/include/base/cef_thread_collision_warner.h @@ -0,0 +1,276 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012 +// Google Inc. 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_BASE_CEF_THREAD_COLLISION_WARNER_H_ +#define CEF_INCLUDE_BASE_CEF_THREAD_COLLISION_WARNER_H_ +#pragma once + +#if defined(BASE_THREADING_THREAD_COLLISION_WARNER_H_) +// Do nothing if the Chromium header has already been included. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/threading/thread_collision_warner.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include + +#include "include/base/cef_atomicops.h" +#include "include/base/cef_basictypes.h" +#include "include/base/cef_build.h" +#include "include/base/cef_logging.h" +#include "include/base/cef_macros.h" + +// A helper class alongside macros to be used to verify assumptions about thread +// safety of a class. +// +// Example: Queue implementation non thread-safe but still usable if clients +// are synchronized somehow. +// +// In this case the macro DFAKE_SCOPED_LOCK has to be +// used, it checks that if a thread is inside the push/pop then +// noone else is still inside the pop/push +// +// class NonThreadSafeQueue { +// public: +// ... +// void push(int) { DFAKE_SCOPED_LOCK(push_pop_); ... } +// int pop() { DFAKE_SCOPED_LOCK(push_pop_); ... } +// ... +// private: +// DFAKE_MUTEX(push_pop_); +// }; +// +// +// Example: Queue implementation non thread-safe but still usable if clients +// are synchronized somehow, it calls a method to "protect" from +// a "protected" method +// +// In this case the macro DFAKE_SCOPED_RECURSIVE_LOCK +// has to be used, it checks that if a thread is inside the push/pop +// then noone else is still inside the pop/push +// +// class NonThreadSafeQueue { +// public: +// void push(int) { +// DFAKE_SCOPED_LOCK(push_pop_); +// ... +// } +// int pop() { +// DFAKE_SCOPED_RECURSIVE_LOCK(push_pop_); +// bar(); +// ... +// } +// void bar() { DFAKE_SCOPED_RECURSIVE_LOCK(push_pop_); ... } +// ... +// private: +// DFAKE_MUTEX(push_pop_); +// }; +// +// +// Example: Queue implementation not usable even if clients are synchronized, +// so only one thread in the class life cycle can use the two members +// push/pop. +// +// In this case the macro DFAKE_SCOPED_LOCK_THREAD_LOCKED pins the +// specified +// critical section the first time a thread enters push or pop, from +// that time on only that thread is allowed to execute push or pop. +// +// class NonThreadSafeQueue { +// public: +// ... +// void push(int) { DFAKE_SCOPED_LOCK_THREAD_LOCKED(push_pop_); ... } +// int pop() { DFAKE_SCOPED_LOCK_THREAD_LOCKED(push_pop_); ... } +// ... +// private: +// DFAKE_MUTEX(push_pop_); +// }; +// +// +// Example: Class that has to be contructed/destroyed on same thread, it has +// a "shareable" method (with external synchronization) and a not +// shareable method (even with external synchronization). +// +// In this case 3 Critical sections have to be defined +// +// class ExoticClass { +// public: +// ExoticClass() { DFAKE_SCOPED_LOCK_THREAD_LOCKED(ctor_dtor_); ... } +// ~ExoticClass() { DFAKE_SCOPED_LOCK_THREAD_LOCKED(ctor_dtor_); ... } +// +// void Shareable() { DFAKE_SCOPED_LOCK(shareable_section_); ... } +// void NotShareable() { DFAKE_SCOPED_LOCK_THREAD_LOCKED(ctor_dtor_); ... } +// ... +// private: +// DFAKE_MUTEX(ctor_dtor_); +// DFAKE_MUTEX(shareable_section_); +// }; + +#if DCHECK_IS_ON() + +// Defines a class member that acts like a mutex. It is used only as a +// verification tool. +#define DFAKE_MUTEX(obj) mutable base::ThreadCollisionWarner obj +// Asserts the call is never called simultaneously in two threads. Used at +// member function scope. +#define DFAKE_SCOPED_LOCK(obj) \ + base::ThreadCollisionWarner::ScopedCheck s_check_##obj(&obj) +// Asserts the call is never called simultaneously in two threads. Used at +// member function scope. Same as DFAKE_SCOPED_LOCK but allows recursive locks. +#define DFAKE_SCOPED_RECURSIVE_LOCK(obj) \ + base::ThreadCollisionWarner::ScopedRecursiveCheck sr_check_##obj(&obj) +// Asserts the code is always executed in the same thread. +#define DFAKE_SCOPED_LOCK_THREAD_LOCKED(obj) \ + base::ThreadCollisionWarner::Check check_##obj(&obj) + +#else + +#define DFAKE_MUTEX(obj) typedef void InternalFakeMutexType##obj +#define DFAKE_SCOPED_LOCK(obj) ((void)0) +#define DFAKE_SCOPED_RECURSIVE_LOCK(obj) ((void)0) +#define DFAKE_SCOPED_LOCK_THREAD_LOCKED(obj) ((void)0) + +#endif + +namespace base { + +// The class ThreadCollisionWarner uses an Asserter to notify the collision +// AsserterBase is the interfaces and DCheckAsserter is the default asserter +// used. During the unit tests is used another class that doesn't "DCHECK" +// in case of collision (check thread_collision_warner_unittests.cc) +struct AsserterBase { + virtual ~AsserterBase() {} + virtual void warn() = 0; +}; + +struct DCheckAsserter : public AsserterBase { + virtual ~DCheckAsserter() {} + virtual void warn() OVERRIDE; +}; + +class ThreadCollisionWarner { + public: + // The parameter asserter is there only for test purpose + explicit ThreadCollisionWarner(AsserterBase* asserter = new DCheckAsserter()) + : valid_thread_id_(0), counter_(0), asserter_(asserter) {} + + ~ThreadCollisionWarner() { delete asserter_; } + + // This class is meant to be used through the macro + // DFAKE_SCOPED_LOCK_THREAD_LOCKED + // it doesn't leave the critical section, as opposed to ScopedCheck, + // because the critical section being pinned is allowed to be used only + // from one thread + class Check { + public: + explicit Check(ThreadCollisionWarner* warner) : warner_(warner) { + warner_->EnterSelf(); + } + + ~Check() {} + + private: + ThreadCollisionWarner* warner_; + + DISALLOW_COPY_AND_ASSIGN(Check); + }; + + // This class is meant to be used through the macro + // DFAKE_SCOPED_LOCK + class ScopedCheck { + public: + explicit ScopedCheck(ThreadCollisionWarner* warner) : warner_(warner) { + warner_->Enter(); + } + + ~ScopedCheck() { warner_->Leave(); } + + private: + ThreadCollisionWarner* warner_; + + DISALLOW_COPY_AND_ASSIGN(ScopedCheck); + }; + + // This class is meant to be used through the macro + // DFAKE_SCOPED_RECURSIVE_LOCK + class ScopedRecursiveCheck { + public: + explicit ScopedRecursiveCheck(ThreadCollisionWarner* warner) + : warner_(warner) { + warner_->EnterSelf(); + } + + ~ScopedRecursiveCheck() { warner_->Leave(); } + + private: + ThreadCollisionWarner* warner_; + + DISALLOW_COPY_AND_ASSIGN(ScopedRecursiveCheck); + }; + + private: + // This method stores the current thread identifier and does a DCHECK + // if a another thread has already done it, it is safe if same thread + // calls this multiple time (recursion allowed). + void EnterSelf(); + + // Same as EnterSelf but recursion is not allowed. + void Enter(); + + // Removes the thread_id stored in order to allow other threads to + // call EnterSelf or Enter. + void Leave(); + + // This stores the thread id that is inside the critical section, if the + // value is 0 then no thread is inside. + volatile subtle::Atomic32 valid_thread_id_; + + // Counter to trace how many time a critical section was "pinned" + // (when allowed) in order to unpin it when counter_ reaches 0. + volatile subtle::Atomic32 counter_; + + // Here only for class unit tests purpose, during the test I need to not + // DCHECK but notify the collision with something else. + AsserterBase* asserter_; + + DISALLOW_COPY_AND_ASSIGN(ThreadCollisionWarner); +}; + +} // namespace base + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_THREAD_COLLISION_WARNER_H_ diff --git a/include/base/cef_trace_event.h b/include/base/cef_trace_event.h new file mode 100644 index 0000000..1b2cad0 --- /dev/null +++ b/include/base/cef_trace_event.h @@ -0,0 +1,420 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012 +// Google Inc. 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. + +/// +// Trace events are for tracking application performance and resource usage. +// Macros are provided to track: +// Begin and end of function calls +// Counters +// +// Events are issued against categories. Whereas LOG's categories are statically +// defined, TRACE categories are created implicitly with a string. For example: +// TRACE_EVENT_INSTANT0("MY_SUBSYSTEM", "SomeImportantEvent") +// +// Events can be INSTANT, or can be pairs of BEGIN and END in the same scope: +// TRACE_EVENT_BEGIN0("MY_SUBSYSTEM", "SomethingCostly") +// doSomethingCostly() +// TRACE_EVENT_END0("MY_SUBSYSTEM", "SomethingCostly") +// Note: Our tools can't always determine the correct BEGIN/END pairs unless +// these are used in the same scope. Use ASYNC_BEGIN/ASYNC_END macros if you +// need them to be in separate scopes. +// +// A common use case is to trace entire function scopes. This issues a trace +// BEGIN and END automatically: +// void doSomethingCostly() { +// TRACE_EVENT0("MY_SUBSYSTEM", "doSomethingCostly"); +// ... +// } +// +// Additional parameters can be associated with an event: +// void doSomethingCostly2(int howMuch) { +// TRACE_EVENT1("MY_SUBSYSTEM", "doSomethingCostly", +// "howMuch", howMuch); +// ... +// } +// +// The trace system will automatically add to this information the current +// process id, thread id, and a timestamp in microseconds. +// +// To trace an asynchronous procedure such as an IPC send/receive, use +// ASYNC_BEGIN and ASYNC_END: +// [single threaded sender code] +// static int send_count = 0; +// ++send_count; +// TRACE_EVENT_ASYNC_BEGIN0("ipc", "message", send_count); +// Send(new MyMessage(send_count)); +// [receive code] +// void OnMyMessage(send_count) { +// TRACE_EVENT_ASYNC_END0("ipc", "message", send_count); +// } +// The third parameter is a unique ID to match ASYNC_BEGIN/ASYNC_END pairs. +// ASYNC_BEGIN and ASYNC_END can occur on any thread of any traced process. +// Pointers can be used for the ID parameter, and they will be mangled +// internally so that the same pointer on two different processes will not +// match. For example: +// class MyTracedClass { +// public: +// MyTracedClass() { +// TRACE_EVENT_ASYNC_BEGIN0("category", "MyTracedClass", this); +// } +// ~MyTracedClass() { +// TRACE_EVENT_ASYNC_END0("category", "MyTracedClass", this); +// } +// } +// +// The trace event also supports counters, which is a way to track a quantity +// as it varies over time. Counters are created with the following macro: +// TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter", g_myCounterValue); +// +// Counters are process-specific. The macro itself can be issued from any +// thread, however. +// +// Sometimes, you want to track two counters at once. You can do this with two +// counter macros: +// TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter0", g_myCounterValue[0]); +// TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter1", g_myCounterValue[1]); +// Or you can do it with a combined macro: +// TRACE_COUNTER2("MY_SUBSYSTEM", "myCounter", +// "bytesPinned", g_myCounterValue[0], +// "bytesAllocated", g_myCounterValue[1]); +// This indicates to the tracing UI that these counters should be displayed +// in a single graph, as a summed area chart. +// +// Since counters are in a global namespace, you may want to disembiguate with a +// unique ID, by using the TRACE_COUNTER_ID* variations. +// +// By default, trace collection is compiled in, but turned off at runtime. +// Collecting trace data is the responsibility of the embedding application. In +// CEF's case, calling BeginTracing will turn on tracing on all active +// processes. +// +// +// Memory scoping note: +// Tracing copies the pointers, not the string content, of the strings passed +// in for category, name, and arg_names. Thus, the following code will cause +// problems: +// char* str = strdup("impprtantName"); +// TRACE_EVENT_INSTANT0("SUBSYSTEM", str); // BAD! +// free(str); // Trace system now has dangling pointer +// +// To avoid this issue with the |name| and |arg_name| parameters, use the +// TRACE_EVENT_COPY_XXX overloads of the macros at additional runtime +// overhead. +// Notes: The category must always be in a long-lived char* (i.e. static const). +// The |arg_values|, when used, are always deep copied with the _COPY +// macros. +// +// +// Thread Safety: +// All macros are thread safe and can be used from any process. +/// + +#ifndef CEF_INCLUDE_BASE_CEF_TRACE_EVENT_H_ +#define CEF_INCLUDE_BASE_CEF_TRACE_EVENT_H_ +#pragma once + +#if defined(TRACE_EVENT0) +// Do nothing if the macros provided by this header already exist. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/trace_event/trace_event.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include "include/internal/cef_trace_event_internal.h" + +// Records a pair of begin and end events called "name" for the current +// scope, with 0, 1 or 2 associated arguments. If the category is not +// enabled, then this does nothing. +// - category and name strings must have application lifetime (statics or +// literals). They may not include " chars. +#define TRACE_EVENT0(category, name) \ + cef_trace_event_begin(category, name, NULL, 0, NULL, 0, false); \ + CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name) +#define TRACE_EVENT1(category, name, arg1_name, arg1_val) \ + cef_trace_event_begin(category, name, arg1_name, arg1_val, NULL, 0, false); \ + CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name) +#define TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, arg2_val) \ + cef_trace_event_begin(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val, false); \ + CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name) + +// Implementation detail: trace event macros create temporary variable names. +// These macros give each temporary variable a unique name based on the line +// number to prevent name collisions. +#define CEF_INTERNAL_TRACE_EVENT_UID3(a, b) cef_trace_event_unique_##a##b +#define CEF_INTERNAL_TRACE_EVENT_UID2(a, b) CEF_INTERNAL_TRACE_EVENT_UID3(a, b) +#define CEF_INTERNAL_TRACE_EVENT_UID(name_prefix) \ + CEF_INTERNAL_TRACE_EVENT_UID2(name_prefix, __LINE__) + +// Implementation detail: internal macro to end end event when the scope ends. +#define CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name) \ + cef_trace_event::CefTraceEndOnScopeClose CEF_INTERNAL_TRACE_EVENT_UID( \ + profileScope)(category, name) + +// Records a single event called "name" immediately, with 0, 1 or 2 +// associated arguments. If the category is not enabled, then this +// does nothing. +// - category and name strings must have application lifetime (statics or +// literals). They may not include " chars. +#define TRACE_EVENT_INSTANT0(category, name) \ + cef_trace_event_instant(category, name, NULL, 0, NULL, 0, false) +#define TRACE_EVENT_INSTANT1(category, name, arg1_name, arg1_val) \ + cef_trace_event_instant(category, name, arg1_name, arg1_val, NULL, 0, false) +#define TRACE_EVENT_INSTANT2(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val) \ + cef_trace_event_instant(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val, false) +#define TRACE_EVENT_COPY_INSTANT0(category, name) \ + cef_trace_event_instant(category, name, NULL, 0, NULL, 0, true) +#define TRACE_EVENT_COPY_INSTANT1(category, name, arg1_name, arg1_val) \ + cef_trace_event_instant(category, name, arg1_name, arg1_val, NULL, 0, true) +#define TRACE_EVENT_COPY_INSTANT2(category, name, arg1_name, arg1_val, \ + arg2_name, arg2_val) \ + cef_trace_event_instant(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val, true) + +// Records a single BEGIN event called "name" immediately, with 0, 1 or 2 +// associated arguments. If the category is not enabled, then this +// does nothing. +// - category and name strings must have application lifetime (statics or +// literals). They may not include " chars. +#define TRACE_EVENT_BEGIN0(category, name) \ + cef_trace_event_begin(category, name, NULL, 0, NULL, 0, false) +#define TRACE_EVENT_BEGIN1(category, name, arg1_name, arg1_val) \ + cef_trace_event_begin(category, name, arg1_name, arg1_val, NULL, 0, false) +#define TRACE_EVENT_BEGIN2(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val) \ + cef_trace_event_begin(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val, false) +#define TRACE_EVENT_COPY_BEGIN0(category, name) \ + cef_trace_event_begin(category, name, NULL, 0, NULL, 0, true) +#define TRACE_EVENT_COPY_BEGIN1(category, name, arg1_name, arg1_val) \ + cef_trace_event_begin(category, name, arg1_name, arg1_val, NULL, 0, true) +#define TRACE_EVENT_COPY_BEGIN2(category, name, arg1_name, arg1_val, \ + arg2_name, arg2_val) \ + cef_trace_event_begin(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val, true) + +// Records a single END event for "name" immediately. If the category +// is not enabled, then this does nothing. +// - category and name strings must have application lifetime (statics or +// literals). They may not include " chars. +#define TRACE_EVENT_END0(category, name) \ + cef_trace_event_end(category, name, NULL, 0, NULL, 0, false) +#define TRACE_EVENT_END1(category, name, arg1_name, arg1_val) \ + cef_trace_event_end(category, name, arg1_name, arg1_val, NULL, 0, false) +#define TRACE_EVENT_END2(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val) \ + cef_trace_event_end(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val, false) +#define TRACE_EVENT_COPY_END0(category, name) \ + cef_trace_event_end(category, name, NULL, 0, NULL, 0, true) +#define TRACE_EVENT_COPY_END1(category, name, arg1_name, arg1_val) \ + cef_trace_event_end(category, name, arg1_name, arg1_val, NULL, 0, true) +#define TRACE_EVENT_COPY_END2(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val) \ + cef_trace_event_end(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val, true) + +// Records the value of a counter called "name" immediately. Value +// must be representable as a 32 bit integer. +// - category and name strings must have application lifetime (statics or +// literals). They may not include " chars. +#define TRACE_COUNTER1(category, name, value) \ + cef_trace_counter(category, name, NULL, value, NULL, 0, false) +#define TRACE_COPY_COUNTER1(category, name, value) \ + cef_trace_counter(category, name, NULL, value, NULL, 0, true) + +// Records the values of a multi-parted counter called "name" immediately. +// The UI will treat value1 and value2 as parts of a whole, displaying their +// values as a stacked-bar chart. +// - category and name strings must have application lifetime (statics or +// literals). They may not include " chars. +#define TRACE_COUNTER2(category, name, value1_name, value1_val, value2_name, \ + value2_val) \ + cef_trace_counter(category, name, value1_name, value1_val, value2_name, \ + value2_val, false) +#define TRACE_COPY_COUNTER2(category, name, value1_name, value1_val, \ + value2_name, value2_val) \ + cef_trace_counter(category, name, value1_name, value1_val, value2_name, \ + value2_val, true) + +// Records the value of a counter called "name" immediately. Value +// must be representable as a 32 bit integer. +// - category and name strings must have application lifetime (statics or +// literals). They may not include " chars. +// - |id| is used to disambiguate counters with the same name. It must either +// be a pointer or an integer value up to 64 bits. If it's a pointer, the +// bits will be xored with a hash of the process ID so that the same pointer +// on two different processes will not collide. +#define TRACE_COUNTER_ID1(category, name, id, value) \ + cef_trace_counter_id(category, name, id, NULL, value, NULL, 0, false) +#define TRACE_COPY_COUNTER_ID1(category, name, id, value) \ + cef_trace_counter_id(category, name, id, NULL, value, NULL, 0, true) + +// Records the values of a multi-parted counter called "name" immediately. +// The UI will treat value1 and value2 as parts of a whole, displaying their +// values as a stacked-bar chart. +// - category and name strings must have application lifetime (statics or +// literals). They may not include " chars. +// - |id| is used to disambiguate counters with the same name. It must either +// be a pointer or an integer value up to 64 bits. If it's a pointer, the +// bits will be xored with a hash of the process ID so that the same pointer +// on two different processes will not collide. +#define TRACE_COUNTER_ID2(category, name, id, value1_name, value1_val, \ + value2_name, value2_val) \ + cef_trace_counter_id(category, name, id, value1_name, value1_val, \ + value2_name, value2_val, false) +#define TRACE_COPY_COUNTER_ID2(category, name, id, value1_name, value1_val, \ + value2_name, value2_val) \ + cef_trace_counter_id(category, name, id, value1_name, value1_val, \ + value2_name, value2_val, true) + +// Records a single ASYNC_BEGIN event called "name" immediately, with 0, 1 or 2 +// associated arguments. If the category is not enabled, then this +// does nothing. +// - category and name strings must have application lifetime (statics or +// literals). They may not include " chars. +// - |id| is used to match the ASYNC_BEGIN event with the ASYNC_END event. +// ASYNC events are considered to match if their category, name and id values +// all match. |id| must either be a pointer or an integer value up to 64 +// bits. If it's a pointer, the bits will be xored with a hash of the process +// ID sothat the same pointer on two different processes will not collide. +// An asynchronous operation can consist of multiple phases. The first phase is +// defined by the ASYNC_BEGIN calls. Additional phases can be defined using the +// ASYNC_STEP_BEGIN macros. When the operation completes, call ASYNC_END. +// An async operation can span threads and processes, but all events in that +// operation must use the same |name| and |id|. Each event can have its own +// args. +#define TRACE_EVENT_ASYNC_BEGIN0(category, name, id) \ + cef_trace_event_async_begin(category, name, id, NULL, 0, NULL, 0, false) +#define TRACE_EVENT_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val) \ + cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, NULL, \ + 0, false) +#define TRACE_EVENT_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, \ + arg2_name, arg2_val) \ + cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, \ + arg2_name, arg2_val, false) +#define TRACE_EVENT_COPY_ASYNC_BEGIN0(category, name, id) \ + cef_trace_event_async_begin(category, name, id, NULL, 0, NULL, 0, true) +#define TRACE_EVENT_COPY_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val) \ + cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, NULL, \ + 0, true) +#define TRACE_EVENT_COPY_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, \ + arg2_name, arg2_val) \ + cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, \ + arg2_name, arg2_val, true) + +// Records a single ASYNC_STEP_INTO event for |step| immediately. If the +// category is not enabled, then this does nothing. The |name| and |id| must +// match the ASYNC_BEGIN event above. The |step| param identifies this step +// within the async event. This should be called at the beginning of the next +// phase of an asynchronous operation. The ASYNC_BEGIN event must not have any +// ASYNC_STEP_PAST events. +#define TRACE_EVENT_ASYNC_STEP_INTO0(category, name, id, step) \ + cef_trace_event_async_step_into(category, name, id, step, NULL, 0, false) +#define TRACE_EVENT_ASYNC_STEP_INTO1(category, name, id, step, arg1_name, \ + arg1_val) \ + cef_trace_event_async_step_into(category, name, id, step, arg1_name, \ + arg1_val, false) +#define TRACE_EVENT_COPY_ASYNC_STEP_INTO0(category, name, id, step) \ + cef_trace_event_async_step_into(category, name, id, step, NULL, 0, true) +#define TRACE_EVENT_COPY_ASYNC_STEP_INTO1(category, name, id, step, arg1_name, \ + arg1_val) \ + cef_trace_event_async_step_into(category, name, id, step, arg1_name, \ + arg1_val, true) + +// Records a single ASYNC_STEP_PAST event for |step| immediately. If the +// category is not enabled, then this does nothing. The |name| and |id| must +// match the ASYNC_BEGIN event above. The |step| param identifies this step +// within the async event. This should be called at the beginning of the next +// phase of an asynchronous operation. The ASYNC_BEGIN event must not have any +// ASYNC_STEP_INTO events. +#define TRACE_EVENT_ASYNC_STEP_PAST0(category, name, id, step) \ + cef_trace_event_async_step_past(category, name, id, step, NULL, 0, false) +#define TRACE_EVENT_ASYNC_STEP_PAST1(category, name, id, step, arg1_name, \ + arg1_val) \ + cef_trace_event_async_step_past(category, name, id, step, arg1_name, \ + arg1_val, false) +#define TRACE_EVENT_COPY_ASYNC_STEP_PAST0(category, name, id, step) \ + cef_trace_event_async_step_past(category, name, id, step, NULL, 0, true) +#define TRACE_EVENT_COPY_ASYNC_STEP_PAST1(category, name, id, step, arg1_name, \ + arg1_val) \ + cef_trace_event_async_step_past(category, name, id, step, arg1_name, \ + arg1_val, true) + +// Records a single ASYNC_END event for "name" immediately. If the category +// is not enabled, then this does nothing. +#define TRACE_EVENT_ASYNC_END0(category, name, id) \ + cef_trace_event_async_end(category, name, id, NULL, 0, NULL, 0, false) +#define TRACE_EVENT_ASYNC_END1(category, name, id, arg1_name, arg1_val) \ + cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, NULL, 0, \ + false) +#define TRACE_EVENT_ASYNC_END2(category, name, id, arg1_name, arg1_val, \ + arg2_name, arg2_val) \ + cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, \ + arg2_name, arg2_val, false) +#define TRACE_EVENT_COPY_ASYNC_END0(category, name, id) \ + cef_trace_event_async_end(category, name, id, NULL, 0, NULL, 0, true) +#define TRACE_EVENT_COPY_ASYNC_END1(category, name, id, arg1_name, arg1_val) \ + cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, NULL, 0, \ + true) +#define TRACE_EVENT_COPY_ASYNC_END2(category, name, id, arg1_name, arg1_val, \ + arg2_name, arg2_val) \ + cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, \ + arg2_name, arg2_val, true) + +namespace cef_trace_event { + +// Used by TRACE_EVENTx macro. Do not use directly. +class CefTraceEndOnScopeClose { + public: + CefTraceEndOnScopeClose(const char* category, const char* name) + : category_(category), name_(name) {} + ~CefTraceEndOnScopeClose() { + cef_trace_event_end(category_, name_, NULL, 0, NULL, 0, false); + } + + private: + const char* category_; + const char* name_; +}; + +} // cef_trace_event + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_TRACE_EVENT_H_ diff --git a/include/base/cef_tuple.h b/include/base/cef_tuple.h new file mode 100644 index 0000000..aeb6e9c --- /dev/null +++ b/include/base/cef_tuple.h @@ -0,0 +1,1610 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011 +// Google Inc. 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. + +// A Tuple is a generic templatized container, similar in concept to std::pair. +// There are classes Tuple0 to Tuple6, cooresponding to the number of elements +// it contains. The convenient MakeTuple() function takes 0 to 6 arguments, +// and will construct and return the appropriate Tuple object. The functions +// DispatchToMethod and DispatchToFunction take a function pointer or instance +// and method pointer, and unpack a tuple into arguments to the call. +// +// Tuple elements are copied by value, and stored in the tuple. See the unit +// tests for more details of how/when the values are copied. +// +// Example usage: +// // These two methods of creating a Tuple are identical. +// Tuple2 tuple_a(1, "wee"); +// Tuple2 tuple_b = MakeTuple(1, "wee"); +// +// void SomeFunc(int a, const char* b) { } +// DispatchToFunction(&SomeFunc, tuple_a); // SomeFunc(1, "wee") +// DispatchToFunction( +// &SomeFunc, MakeTuple(10, "foo")); // SomeFunc(10, "foo") +// +// struct { void SomeMeth(int a, int b, int c) { } } foo; +// DispatchToMethod(&foo, &Foo::SomeMeth, MakeTuple(1, 2, 3)); +// // foo->SomeMeth(1, 2, 3); + +#ifndef CEF_INCLUDE_BASE_CEF_TUPLE_H_ +#define CEF_INCLUDE_BASE_CEF_TUPLE_H_ +#pragma once + +#if defined(BASE_TUPLE_H_) +// Do nothing if the Chromium header has already been included. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/tuple.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include "include/base/cef_bind_helpers.h" + +namespace base { + +// Traits ---------------------------------------------------------------------- +// +// A simple traits class for tuple arguments. +// +// ValueType: the bare, nonref version of a type (same as the type for nonrefs). +// RefType: the ref version of a type (same as the type for refs). +// ParamType: what type to pass to functions (refs should not be constified). + +template +struct TupleTraits { + typedef P ValueType; + typedef P& RefType; + typedef const P& ParamType; +}; + +template +struct TupleTraits { + typedef P ValueType; + typedef P& RefType; + typedef P& ParamType; +}; + +template +struct TupleTypes {}; + +// Tuple ----------------------------------------------------------------------- +// +// This set of classes is useful for bundling 0 or more heterogeneous data types +// into a single variable. The advantage of this is that it greatly simplifies +// function objects that need to take an arbitrary number of parameters; see +// RunnableMethod and IPC::MessageWithTuple. +// +// Tuple0 is supplied to act as a 'void' type. It can be used, for example, +// when dispatching to a function that accepts no arguments (see the +// Dispatchers below). +// Tuple1 is rarely useful. One such use is when A is non-const ref that you +// want filled by the dispatchee, and the tuple is merely a container for that +// output (a "tier"). See MakeRefTuple and its usages. + +struct Tuple0 { + typedef Tuple0 ValueTuple; + typedef Tuple0 RefTuple; + typedef Tuple0 ParamTuple; +}; + +template +struct Tuple1 { + public: + typedef A TypeA; + + Tuple1() {} + explicit Tuple1(typename TupleTraits::ParamType a) : a(a) {} + + A a; +}; + +template +struct Tuple2 { + public: + typedef A TypeA; + typedef B TypeB; + + Tuple2() {} + Tuple2(typename TupleTraits::ParamType a, + typename TupleTraits::ParamType b) + : a(a), b(b) {} + + A a; + B b; +}; + +template +struct Tuple3 { + public: + typedef A TypeA; + typedef B TypeB; + typedef C TypeC; + + Tuple3() {} + Tuple3(typename TupleTraits::ParamType a, + typename TupleTraits::ParamType b, + typename TupleTraits::ParamType c) + : a(a), b(b), c(c) {} + + A a; + B b; + C c; +}; + +template +struct Tuple4 { + public: + typedef A TypeA; + typedef B TypeB; + typedef C TypeC; + typedef D TypeD; + + Tuple4() {} + Tuple4(typename TupleTraits::ParamType a, + typename TupleTraits::ParamType b, + typename TupleTraits::ParamType c, + typename TupleTraits::ParamType d) + : a(a), b(b), c(c), d(d) {} + + A a; + B b; + C c; + D d; +}; + +template +struct Tuple5 { + public: + typedef A TypeA; + typedef B TypeB; + typedef C TypeC; + typedef D TypeD; + typedef E TypeE; + + Tuple5() {} + Tuple5(typename TupleTraits::ParamType a, + typename TupleTraits::ParamType b, + typename TupleTraits::ParamType c, + typename TupleTraits::ParamType d, + typename TupleTraits::ParamType e) + : a(a), b(b), c(c), d(d), e(e) {} + + A a; + B b; + C c; + D d; + E e; +}; + +template +struct Tuple6 { + public: + typedef A TypeA; + typedef B TypeB; + typedef C TypeC; + typedef D TypeD; + typedef E TypeE; + typedef F TypeF; + + Tuple6() {} + Tuple6(typename TupleTraits::ParamType a, + typename TupleTraits::ParamType b, + typename TupleTraits::ParamType c, + typename TupleTraits::ParamType d, + typename TupleTraits::ParamType e, + typename TupleTraits::ParamType f) + : a(a), b(b), c(c), d(d), e(e), f(f) {} + + A a; + B b; + C c; + D d; + E e; + F f; +}; + +template +struct Tuple7 { + public: + typedef A TypeA; + typedef B TypeB; + typedef C TypeC; + typedef D TypeD; + typedef E TypeE; + typedef F TypeF; + typedef G TypeG; + + Tuple7() {} + Tuple7(typename TupleTraits::ParamType a, + typename TupleTraits::ParamType b, + typename TupleTraits::ParamType c, + typename TupleTraits::ParamType d, + typename TupleTraits::ParamType e, + typename TupleTraits::ParamType f, + typename TupleTraits::ParamType g) + : a(a), b(b), c(c), d(d), e(e), f(f), g(g) {} + + A a; + B b; + C c; + D d; + E e; + F f; + G g; +}; + +template +struct Tuple8 { + public: + typedef A TypeA; + typedef B TypeB; + typedef C TypeC; + typedef D TypeD; + typedef E TypeE; + typedef F TypeF; + typedef G TypeG; + typedef H TypeH; + + Tuple8() {} + Tuple8(typename TupleTraits::ParamType a, + typename TupleTraits::ParamType b, + typename TupleTraits::ParamType c, + typename TupleTraits::ParamType d, + typename TupleTraits::ParamType e, + typename TupleTraits::ParamType f, + typename TupleTraits::ParamType g, + typename TupleTraits::ParamType h) + : a(a), b(b), c(c), d(d), e(e), f(f), g(g), h(h) {} + + A a; + B b; + C c; + D d; + E e; + F f; + G g; + H h; +}; + +// Tuple types ---------------------------------------------------------------- +// +// Allows for selection of ValueTuple/RefTuple/ParamTuple without needing the +// definitions of class types the tuple takes as parameters. + +template <> +struct TupleTypes { + typedef Tuple0 ValueTuple; + typedef Tuple0 RefTuple; + typedef Tuple0 ParamTuple; +}; + +template +struct TupleTypes> { + typedef Tuple1::ValueType> ValueTuple; + typedef Tuple1::RefType> RefTuple; + typedef Tuple1::ParamType> ParamTuple; +}; + +template +struct TupleTypes> { + typedef Tuple2::ValueType, + typename TupleTraits::ValueType> + ValueTuple; + typedef Tuple2::RefType, + typename TupleTraits::RefType> + RefTuple; + typedef Tuple2::ParamType, + typename TupleTraits::ParamType> + ParamTuple; +}; + +template +struct TupleTypes> { + typedef Tuple3::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType> + ValueTuple; + typedef Tuple3::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType> + RefTuple; + typedef Tuple3::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType> + ParamTuple; +}; + +template +struct TupleTypes> { + typedef Tuple4::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType> + ValueTuple; + typedef Tuple4::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType> + RefTuple; + typedef Tuple4::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType> + ParamTuple; +}; + +template +struct TupleTypes> { + typedef Tuple5::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType> + ValueTuple; + typedef Tuple5::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType> + RefTuple; + typedef Tuple5::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType> + ParamTuple; +}; + +template +struct TupleTypes> { + typedef Tuple6::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType> + ValueTuple; + typedef Tuple6::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType> + RefTuple; + typedef Tuple6::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType> + ParamTuple; +}; + +template +struct TupleTypes> { + typedef Tuple7::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType> + ValueTuple; + typedef Tuple7::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType> + RefTuple; + typedef Tuple7::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType> + ParamTuple; +}; + +template +struct TupleTypes> { + typedef Tuple8::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType> + ValueTuple; + typedef Tuple8::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType> + RefTuple; + typedef Tuple8::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType> + ParamTuple; +}; + +// Tuple creators ------------------------------------------------------------- +// +// Helper functions for constructing tuples while inferring the template +// argument types. + +inline Tuple0 MakeTuple() { + return Tuple0(); +} + +template +inline Tuple1 MakeTuple(const A& a) { + return Tuple1(a); +} + +template +inline Tuple2 MakeTuple(const A& a, const B& b) { + return Tuple2(a, b); +} + +template +inline Tuple3 MakeTuple(const A& a, const B& b, const C& c) { + return Tuple3(a, b, c); +} + +template +inline Tuple4 MakeTuple(const A& a, + const B& b, + const C& c, + const D& d) { + return Tuple4(a, b, c, d); +} + +template +inline Tuple5 MakeTuple(const A& a, + const B& b, + const C& c, + const D& d, + const E& e) { + return Tuple5(a, b, c, d, e); +} + +template +inline Tuple6 MakeTuple(const A& a, + const B& b, + const C& c, + const D& d, + const E& e, + const F& f) { + return Tuple6(a, b, c, d, e, f); +} + +template +inline Tuple7 MakeTuple(const A& a, + const B& b, + const C& c, + const D& d, + const E& e, + const F& f, + const G& g) { + return Tuple7(a, b, c, d, e, f, g); +} + +template +inline Tuple8 MakeTuple(const A& a, + const B& b, + const C& c, + const D& d, + const E& e, + const F& f, + const G& g, + const H& h) { + return Tuple8(a, b, c, d, e, f, g, h); +} + +// The following set of helpers make what Boost refers to as "Tiers" - a tuple +// of references. + +template +inline Tuple1 MakeRefTuple(A& a) { + return Tuple1(a); +} + +template +inline Tuple2 MakeRefTuple(A& a, B& b) { + return Tuple2(a, b); +} + +template +inline Tuple3 MakeRefTuple(A& a, B& b, C& c) { + return Tuple3(a, b, c); +} + +template +inline Tuple4 MakeRefTuple(A& a, B& b, C& c, D& d) { + return Tuple4(a, b, c, d); +} + +template +inline Tuple5 MakeRefTuple(A& a, B& b, C& c, D& d, E& e) { + return Tuple5(a, b, c, d, e); +} + +template +inline Tuple6 MakeRefTuple(A& a, + B& b, + C& c, + D& d, + E& e, + F& f) { + return Tuple6(a, b, c, d, e, f); +} + +template +inline Tuple7 +MakeRefTuple(A& a, B& b, C& c, D& d, E& e, F& f, G& g) { + return Tuple7(a, b, c, d, e, f, g); +} + +template +inline Tuple8 +MakeRefTuple(A& a, B& b, C& c, D& d, E& e, F& f, G& g, H& h) { + return Tuple8(a, b, c, d, e, f, g, h); +} + +// Dispatchers ---------------------------------------------------------------- +// +// Helper functions that call the given method on an object, with the unpacked +// tuple arguments. Notice that they all have the same number of arguments, +// so you need only write: +// DispatchToMethod(object, &Object::method, args); +// This is very useful for templated dispatchers, since they don't need to know +// what type |args| is. + +// Non-Static Dispatchers with no out params. + +template +inline void DispatchToMethod(ObjT* obj, Method method, const Tuple0& arg) { + (obj->*method)(); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, const A& arg) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg)); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, const Tuple1& arg) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a)); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple2& arg) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b)); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple3& arg) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b), + base::cef_internal::UnwrapTraits::Unwrap(arg.c)); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple4& arg) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b), + base::cef_internal::UnwrapTraits::Unwrap(arg.c), + base::cef_internal::UnwrapTraits::Unwrap(arg.d)); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple5& arg) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b), + base::cef_internal::UnwrapTraits::Unwrap(arg.c), + base::cef_internal::UnwrapTraits::Unwrap(arg.d), + base::cef_internal::UnwrapTraits::Unwrap(arg.e)); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple6& arg) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b), + base::cef_internal::UnwrapTraits::Unwrap(arg.c), + base::cef_internal::UnwrapTraits::Unwrap(arg.d), + base::cef_internal::UnwrapTraits::Unwrap(arg.e), + base::cef_internal::UnwrapTraits::Unwrap(arg.f)); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple7& arg) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b), + base::cef_internal::UnwrapTraits::Unwrap(arg.c), + base::cef_internal::UnwrapTraits::Unwrap(arg.d), + base::cef_internal::UnwrapTraits::Unwrap(arg.e), + base::cef_internal::UnwrapTraits::Unwrap(arg.f), + base::cef_internal::UnwrapTraits::Unwrap(arg.g)); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple8& arg) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b), + base::cef_internal::UnwrapTraits::Unwrap(arg.c), + base::cef_internal::UnwrapTraits::Unwrap(arg.d), + base::cef_internal::UnwrapTraits::Unwrap(arg.e), + base::cef_internal::UnwrapTraits::Unwrap(arg.f), + base::cef_internal::UnwrapTraits::Unwrap(arg.g), + base::cef_internal::UnwrapTraits::Unwrap(arg.h)); +} + +// Static Dispatchers with no out params. + +template +inline void DispatchToFunction(Function function, const Tuple0& arg) { + (*function)(); +} + +template +inline void DispatchToFunction(Function function, const A& arg) { + (*function)(arg); +} + +template +inline void DispatchToFunction(Function function, const Tuple1& arg) { + (*function)(base::cef_internal::UnwrapTraits::Unwrap(arg.a)); +} + +template +inline void DispatchToFunction(Function function, const Tuple2& arg) { + (*function)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b)); +} + +template +inline void DispatchToFunction(Function function, const Tuple3& arg) { + (*function)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b), + base::cef_internal::UnwrapTraits::Unwrap(arg.c)); +} + +template +inline void DispatchToFunction(Function function, + const Tuple4& arg) { + (*function)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b), + base::cef_internal::UnwrapTraits::Unwrap(arg.c), + base::cef_internal::UnwrapTraits::Unwrap(arg.d)); +} + +template +inline void DispatchToFunction(Function function, + const Tuple5& arg) { + (*function)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b), + base::cef_internal::UnwrapTraits::Unwrap(arg.c), + base::cef_internal::UnwrapTraits::Unwrap(arg.d), + base::cef_internal::UnwrapTraits::Unwrap(arg.e)); +} + +template +inline void DispatchToFunction(Function function, + const Tuple6& arg) { + (*function)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b), + base::cef_internal::UnwrapTraits::Unwrap(arg.c), + base::cef_internal::UnwrapTraits::Unwrap(arg.d), + base::cef_internal::UnwrapTraits::Unwrap(arg.e), + base::cef_internal::UnwrapTraits::Unwrap(arg.f)); +} + +template +inline void DispatchToFunction(Function function, + const Tuple7& arg) { + (*function)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b), + base::cef_internal::UnwrapTraits::Unwrap(arg.c), + base::cef_internal::UnwrapTraits::Unwrap(arg.d), + base::cef_internal::UnwrapTraits::Unwrap(arg.e), + base::cef_internal::UnwrapTraits::Unwrap(arg.f), + base::cef_internal::UnwrapTraits::Unwrap(arg.g)); +} + +template +inline void DispatchToFunction(Function function, + const Tuple8& arg) { + (*function)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b), + base::cef_internal::UnwrapTraits::Unwrap(arg.c), + base::cef_internal::UnwrapTraits::Unwrap(arg.d), + base::cef_internal::UnwrapTraits::Unwrap(arg.e), + base::cef_internal::UnwrapTraits::Unwrap(arg.f), + base::cef_internal::UnwrapTraits::Unwrap(arg.g), + base::cef_internal::UnwrapTraits::Unwrap(arg.h)); +} + +// Dispatchers with 0 out param (as a Tuple0). + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple0& arg, + Tuple0*) { + (obj->*method)(); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, const A& arg, Tuple0*) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg)); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple1& arg, + Tuple0*) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a)); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple2& arg, + Tuple0*) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b)); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple3& arg, + Tuple0*) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b), + base::cef_internal::UnwrapTraits::Unwrap(arg.c)); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple4& arg, + Tuple0*) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b), + base::cef_internal::UnwrapTraits::Unwrap(arg.c), + base::cef_internal::UnwrapTraits::Unwrap(arg.d)); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple5& arg, + Tuple0*) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b), + base::cef_internal::UnwrapTraits::Unwrap(arg.c), + base::cef_internal::UnwrapTraits::Unwrap(arg.d), + base::cef_internal::UnwrapTraits::Unwrap(arg.e)); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple6& arg, + Tuple0*) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b), + base::cef_internal::UnwrapTraits::Unwrap(arg.c), + base::cef_internal::UnwrapTraits::Unwrap(arg.d), + base::cef_internal::UnwrapTraits::Unwrap(arg.e), + base::cef_internal::UnwrapTraits::Unwrap(arg.f)); +} + +// Dispatchers with 1 out param. + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple0& in, + Tuple1* out) { + (obj->*method)(&out->a); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const InA& in, + Tuple1* out) { + (obj->*method)(in, &out->a); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple1& in, + Tuple1* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), &out->a); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple2& in, + Tuple1* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), &out->a); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple3& in, + Tuple1* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), &out->a); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple4& in, + Tuple1* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), + base::cef_internal::UnwrapTraits::Unwrap(in.d), &out->a); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple5& in, + Tuple1* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), + base::cef_internal::UnwrapTraits::Unwrap(in.d), + base::cef_internal::UnwrapTraits::Unwrap(in.e), &out->a); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple6& in, + Tuple1* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), + base::cef_internal::UnwrapTraits::Unwrap(in.d), + base::cef_internal::UnwrapTraits::Unwrap(in.e), + base::cef_internal::UnwrapTraits::Unwrap(in.f), &out->a); +} + +// Dispatchers with 2 out params. + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple0& in, + Tuple2* out) { + (obj->*method)(&out->a, &out->b); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const InA& in, + Tuple2* out) { + (obj->*method)(in, &out->a, &out->b); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple1& in, + Tuple2* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), &out->a, + &out->b); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple2& in, + Tuple2* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), &out->a, + &out->b); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple3& in, + Tuple2* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), &out->a, + &out->b); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple4& in, + Tuple2* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), + base::cef_internal::UnwrapTraits::Unwrap(in.d), &out->a, + &out->b); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple5& in, + Tuple2* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), + base::cef_internal::UnwrapTraits::Unwrap(in.d), + base::cef_internal::UnwrapTraits::Unwrap(in.e), &out->a, + &out->b); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple6& in, + Tuple2* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), + base::cef_internal::UnwrapTraits::Unwrap(in.d), + base::cef_internal::UnwrapTraits::Unwrap(in.e), + base::cef_internal::UnwrapTraits::Unwrap(in.f), &out->a, + &out->b); +} + +// Dispatchers with 3 out params. + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple0& in, + Tuple3* out) { + (obj->*method)(&out->a, &out->b, &out->c); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const InA& in, + Tuple3* out) { + (obj->*method)(in, &out->a, &out->b, &out->c); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple1& in, + Tuple3* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), &out->a, + &out->b, &out->c); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple2& in, + Tuple3* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), &out->a, + &out->b, &out->c); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple3& in, + Tuple3* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), &out->a, + &out->b, &out->c); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple4& in, + Tuple3* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), + base::cef_internal::UnwrapTraits::Unwrap(in.d), &out->a, + &out->b, &out->c); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple5& in, + Tuple3* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), + base::cef_internal::UnwrapTraits::Unwrap(in.d), + base::cef_internal::UnwrapTraits::Unwrap(in.e), &out->a, + &out->b, &out->c); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple6& in, + Tuple3* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), + base::cef_internal::UnwrapTraits::Unwrap(in.d), + base::cef_internal::UnwrapTraits::Unwrap(in.e), + base::cef_internal::UnwrapTraits::Unwrap(in.f), &out->a, + &out->b, &out->c); +} + +// Dispatchers with 4 out params. + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple0& in, + Tuple4* out) { + (obj->*method)(&out->a, &out->b, &out->c, &out->d); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const InA& in, + Tuple4* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in), &out->a, + &out->b, &out->c, &out->d); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple1& in, + Tuple4* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), &out->a, + &out->b, &out->c, &out->d); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple2& in, + Tuple4* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), &out->a, + &out->b, &out->c, &out->d); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple3& in, + Tuple4* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), &out->a, + &out->b, &out->c, &out->d); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple4& in, + Tuple4* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), + base::cef_internal::UnwrapTraits::Unwrap(in.d), &out->a, + &out->b, &out->c, &out->d); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple5& in, + Tuple4* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), + base::cef_internal::UnwrapTraits::Unwrap(in.d), + base::cef_internal::UnwrapTraits::Unwrap(in.e), &out->a, + &out->b, &out->c, &out->d); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple6& in, + Tuple4* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), + base::cef_internal::UnwrapTraits::Unwrap(in.d), + base::cef_internal::UnwrapTraits::Unwrap(in.e), + base::cef_internal::UnwrapTraits::Unwrap(in.f), &out->a, + &out->b, &out->c, &out->d); +} + +// Dispatchers with 5 out params. + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple0& in, + Tuple5* out) { + (obj->*method)(&out->a, &out->b, &out->c, &out->d, &out->e); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const InA& in, + Tuple5* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in), &out->a, + &out->b, &out->c, &out->d, &out->e); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple1& in, + Tuple5* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), &out->a, + &out->b, &out->c, &out->d, &out->e); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple2& in, + Tuple5* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), &out->a, + &out->b, &out->c, &out->d, &out->e); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple3& in, + Tuple5* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), &out->a, + &out->b, &out->c, &out->d, &out->e); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple4& in, + Tuple5* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), + base::cef_internal::UnwrapTraits::Unwrap(in.d), &out->a, + &out->b, &out->c, &out->d, &out->e); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple5& in, + Tuple5* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), + base::cef_internal::UnwrapTraits::Unwrap(in.d), + base::cef_internal::UnwrapTraits::Unwrap(in.e), &out->a, + &out->b, &out->c, &out->d, &out->e); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple6& in, + Tuple5* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), + base::cef_internal::UnwrapTraits::Unwrap(in.d), + base::cef_internal::UnwrapTraits::Unwrap(in.e), + base::cef_internal::UnwrapTraits::Unwrap(in.f), &out->a, + &out->b, &out->c, &out->d, &out->e); +} + +} // namespace base + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_TUPLE_H_ diff --git a/include/base/cef_weak_ptr.h b/include/base/cef_weak_ptr.h new file mode 100644 index 0000000..1ba34b9 --- /dev/null +++ b/include/base/cef_weak_ptr.h @@ -0,0 +1,385 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012 +// Google Inc. 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. + +// Weak pointers are pointers to an object that do not affect its lifetime, +// and which may be invalidated (i.e. reset to NULL) by the object, or its +// owner, at any time, most commonly when the object is about to be deleted. + +// Weak pointers are useful when an object needs to be accessed safely by one +// or more objects other than its owner, and those callers can cope with the +// object vanishing and e.g. tasks posted to it being silently dropped. +// Reference-counting such an object would complicate the ownership graph and +// make it harder to reason about the object's lifetime. + +// EXAMPLE: +// +// class Controller { +// public: +// Controller() : weak_factory_(this) {} +// void SpawnWorker() { Worker::StartNew(weak_factory_.GetWeakPtr()); } +// void WorkComplete(const Result& result) { ... } +// private: +// // Member variables should appear before the WeakPtrFactory, to ensure +// // that any WeakPtrs to Controller are invalidated before its members +// // variable's destructors are executed, rendering them invalid. +// WeakPtrFactory weak_factory_; +// }; +// +// class Worker { +// public: +// static void StartNew(const WeakPtr& controller) { +// Worker* worker = new Worker(controller); +// // Kick off asynchronous processing... +// } +// private: +// Worker(const WeakPtr& controller) +// : controller_(controller) {} +// void DidCompleteAsynchronousProcessing(const Result& result) { +// if (controller_) +// controller_->WorkComplete(result); +// } +// WeakPtr controller_; +// }; +// +// With this implementation a caller may use SpawnWorker() to dispatch multiple +// Workers and subsequently delete the Controller, without waiting for all +// Workers to have completed. + +// ------------------------- IMPORTANT: Thread-safety ------------------------- + +// Weak pointers may be passed safely between threads, but must always be +// dereferenced and invalidated on the same thread otherwise checking the +// pointer would be racey. +// +// To ensure correct use, the first time a WeakPtr issued by a WeakPtrFactory +// is dereferenced, the factory and its WeakPtrs become bound to the calling +// thread, and cannot be dereferenced or invalidated on any other thread. Bound +// WeakPtrs can still be handed off to other threads, e.g. to use to post tasks +// back to object on the bound thread. +// +// If all WeakPtr objects are destroyed or invalidated then the factory is +// unbound from the SequencedTaskRunner/Thread. The WeakPtrFactory may then be +// destroyed, or new WeakPtr objects may be used, from a different sequence. +// +// Thus, at least one WeakPtr object must exist and have been dereferenced on +// the correct thread to enforce that other WeakPtr objects will enforce they +// are used on the desired thread. + +#ifndef CEF_INCLUDE_BASE_CEF_WEAK_PTR_H_ +#define CEF_INCLUDE_BASE_CEF_WEAK_PTR_H_ +#pragma once + +#if defined(BASE_MEMORY_WEAK_PTR_H_) +// Do nothing if the Chromium header has already been included. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/memory/weak_ptr.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include "include/base/cef_basictypes.h" +#include "include/base/cef_logging.h" +#include "include/base/cef_ref_counted.h" +#include "include/base/cef_template_util.h" +#include "include/base/cef_thread_checker.h" + +namespace base { + +template +class SupportsWeakPtr; +template +class WeakPtr; + +namespace cef_internal { +// These classes are part of the WeakPtr implementation. +// DO NOT USE THESE CLASSES DIRECTLY YOURSELF. + +class WeakReference { + public: + // Although Flag is bound to a specific thread, it may be deleted from another + // via base::WeakPtr::~WeakPtr(). + class Flag : public RefCountedThreadSafe { + public: + Flag(); + + void Invalidate(); + bool IsValid() const; + + private: + friend class base::RefCountedThreadSafe; + + ~Flag(); + + // The current Chromium implementation uses SequenceChecker instead of + // ThreadChecker to support SequencedWorkerPools. CEF does not yet expose + // the concept of SequencedWorkerPools. + ThreadChecker thread_checker_; + bool is_valid_; + }; + + WeakReference(); + explicit WeakReference(const Flag* flag); + ~WeakReference(); + + bool is_valid() const; + + private: + scoped_refptr flag_; +}; + +class WeakReferenceOwner { + public: + WeakReferenceOwner(); + ~WeakReferenceOwner(); + + WeakReference GetRef() const; + + bool HasRefs() const { return flag_.get() && !flag_->HasOneRef(); } + + void Invalidate(); + + private: + mutable scoped_refptr flag_; +}; + +// This class simplifies the implementation of WeakPtr's type conversion +// constructor by avoiding the need for a public accessor for ref_. A +// WeakPtr cannot access the private members of WeakPtr, so this +// base class gives us a way to access ref_ in a protected fashion. +class WeakPtrBase { + public: + WeakPtrBase(); + ~WeakPtrBase(); + + protected: + explicit WeakPtrBase(const WeakReference& ref); + + WeakReference ref_; +}; + +// This class provides a common implementation of common functions that would +// otherwise get instantiated separately for each distinct instantiation of +// SupportsWeakPtr<>. +class SupportsWeakPtrBase { + public: + // A safe static downcast of a WeakPtr to WeakPtr. This + // conversion will only compile if there is exists a Base which inherits + // from SupportsWeakPtr. See base::AsWeakPtr() below for a helper + // function that makes calling this easier. + template + static WeakPtr StaticAsWeakPtr(Derived* t) { + typedef is_convertible + convertible; + COMPILE_ASSERT(convertible::value, + AsWeakPtr_argument_inherits_from_SupportsWeakPtr); + return AsWeakPtrImpl(t, *t); + } + + private: + // This template function uses type inference to find a Base of Derived + // which is an instance of SupportsWeakPtr. We can then safely + // static_cast the Base* to a Derived*. + template + static WeakPtr AsWeakPtrImpl(Derived* t, + const SupportsWeakPtr&) { + WeakPtr ptr = t->Base::AsWeakPtr(); + return WeakPtr(ptr.ref_, static_cast(ptr.ptr_)); + } +}; + +} // namespace cef_internal + +template +class WeakPtrFactory; + +// The WeakPtr class holds a weak reference to |T*|. +// +// This class is designed to be used like a normal pointer. You should always +// null-test an object of this class before using it or invoking a method that +// may result in the underlying object being destroyed. +// +// EXAMPLE: +// +// class Foo { ... }; +// WeakPtr foo; +// if (foo) +// foo->method(); +// +template +class WeakPtr : public cef_internal::WeakPtrBase { + public: + WeakPtr() : ptr_(NULL) {} + + // Allow conversion from U to T provided U "is a" T. Note that this + // is separate from the (implicit) copy constructor. + template + WeakPtr(const WeakPtr& other) : WeakPtrBase(other), ptr_(other.ptr_) {} + + T* get() const { return ref_.is_valid() ? ptr_ : NULL; } + + T& operator*() const { + DCHECK(get() != NULL); + return *get(); + } + T* operator->() const { + DCHECK(get() != NULL); + return get(); + } + + // Allow WeakPtr to be used in boolean expressions, but not + // implicitly convertible to a real bool (which is dangerous). + // + // Note that this trick is only safe when the == and != operators + // are declared explicitly, as otherwise "weak_ptr1 == weak_ptr2" + // will compile but do the wrong thing (i.e., convert to Testable + // and then do the comparison). + private: + typedef T* WeakPtr::*Testable; + + public: + operator Testable() const { return get() ? &WeakPtr::ptr_ : NULL; } + + void reset() { + ref_ = cef_internal::WeakReference(); + ptr_ = NULL; + } + + private: + // Explicitly declare comparison operators as required by the bool + // trick, but keep them private. + template + bool operator==(WeakPtr const&) const; + template + bool operator!=(WeakPtr const&) const; + + friend class cef_internal::SupportsWeakPtrBase; + template + friend class WeakPtr; + friend class SupportsWeakPtr; + friend class WeakPtrFactory; + + WeakPtr(const cef_internal::WeakReference& ref, T* ptr) + : WeakPtrBase(ref), ptr_(ptr) {} + + // This pointer is only valid when ref_.is_valid() is true. Otherwise, its + // value is undefined (as opposed to NULL). + T* ptr_; +}; + +// A class may be composed of a WeakPtrFactory and thereby +// control how it exposes weak pointers to itself. This is helpful if you only +// need weak pointers within the implementation of a class. This class is also +// useful when working with primitive types. For example, you could have a +// WeakPtrFactory that is used to pass around a weak reference to a bool. +template +class WeakPtrFactory { + public: + explicit WeakPtrFactory(T* ptr) : ptr_(ptr) {} + + ~WeakPtrFactory() { ptr_ = NULL; } + + WeakPtr GetWeakPtr() { + DCHECK(ptr_); + return WeakPtr(weak_reference_owner_.GetRef(), ptr_); + } + + // Call this method to invalidate all existing weak pointers. + void InvalidateWeakPtrs() { + DCHECK(ptr_); + weak_reference_owner_.Invalidate(); + } + + // Call this method to determine if any weak pointers exist. + bool HasWeakPtrs() const { + DCHECK(ptr_); + return weak_reference_owner_.HasRefs(); + } + + private: + cef_internal::WeakReferenceOwner weak_reference_owner_; + T* ptr_; + DISALLOW_IMPLICIT_CONSTRUCTORS(WeakPtrFactory); +}; + +// A class may extend from SupportsWeakPtr to let others take weak pointers to +// it. This avoids the class itself implementing boilerplate to dispense weak +// pointers. However, since SupportsWeakPtr's destructor won't invalidate +// weak pointers to the class until after the derived class' members have been +// destroyed, its use can lead to subtle use-after-destroy issues. +template +class SupportsWeakPtr : public cef_internal::SupportsWeakPtrBase { + public: + SupportsWeakPtr() {} + + WeakPtr AsWeakPtr() { + return WeakPtr(weak_reference_owner_.GetRef(), static_cast(this)); + } + + protected: + ~SupportsWeakPtr() {} + + private: + cef_internal::WeakReferenceOwner weak_reference_owner_; + DISALLOW_COPY_AND_ASSIGN(SupportsWeakPtr); +}; + +// Helper function that uses type deduction to safely return a WeakPtr +// when Derived doesn't directly extend SupportsWeakPtr, instead it +// extends a Base that extends SupportsWeakPtr. +// +// EXAMPLE: +// class Base : public base::SupportsWeakPtr {}; +// class Derived : public Base {}; +// +// Derived derived; +// base::WeakPtr ptr = base::AsWeakPtr(&derived); +// +// Note that the following doesn't work (invalid type conversion) since +// Derived::AsWeakPtr() is WeakPtr SupportsWeakPtr::AsWeakPtr(), +// and there's no way to safely cast WeakPtr to WeakPtr at +// the caller. +// +// base::WeakPtr ptr = derived.AsWeakPtr(); // Fails. + +template +WeakPtr AsWeakPtr(Derived* t) { + return cef_internal::SupportsWeakPtrBase::StaticAsWeakPtr(t); +} + +} // namespace base + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_WEAK_PTR_H_ diff --git a/include/base/internal/cef_atomicops_arm_gcc.h b/include/base/internal/cef_atomicops_arm_gcc.h new file mode 100644 index 0000000..2e39ce3 --- /dev/null +++ b/include/base/internal/cef_atomicops_arm_gcc.h @@ -0,0 +1,325 @@ +// Copyright (c) 2013 Google Inc. 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. +// +// Do not include this header file directly. Use base/cef_atomicops.h +// instead. +// +// LinuxKernelCmpxchg and Barrier_AtomicIncrement are from Google Gears. + +#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_ARM_GCC_H_ +#define CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_ARM_GCC_H_ + +#if defined(OS_QNX) +#include +#endif + +namespace base { +namespace subtle { + +// Memory barriers on ARM are funky, but the kernel is here to help: +// +// * ARMv5 didn't support SMP, there is no memory barrier instruction at +// all on this architecture, or when targeting its machine code. +// +// * Some ARMv6 CPUs support SMP. A full memory barrier can be produced by +// writing a random value to a very specific coprocessor register. +// +// * On ARMv7, the "dmb" instruction is used to perform a full memory +// barrier (though writing to the co-processor will still work). +// However, on single core devices (e.g. Nexus One, or Nexus S), +// this instruction will take up to 200 ns, which is huge, even though +// it's completely un-needed on these devices. +// +// * There is no easy way to determine at runtime if the device is +// single or multi-core. However, the kernel provides a useful helper +// function at a fixed memory address (0xffff0fa0), which will always +// perform a memory barrier in the most efficient way. I.e. on single +// core devices, this is an empty function that exits immediately. +// On multi-core devices, it implements a full memory barrier. +// +// * This source could be compiled to ARMv5 machine code that runs on a +// multi-core ARMv6 or ARMv7 device. In this case, memory barriers +// are needed for correct execution. Always call the kernel helper, even +// when targeting ARMv5TE. +// + +inline void MemoryBarrier() { +#if defined(OS_LINUX) || defined(OS_ANDROID) + // Note: This is a function call, which is also an implicit compiler barrier. + typedef void (*KernelMemoryBarrierFunc)(); + ((KernelMemoryBarrierFunc)0xffff0fa0)(); +#elif defined(OS_QNX) + __cpu_membarrier(); +#else +#error MemoryBarrier() is not implemented on this platform. +#endif +} + +// An ARM toolchain would only define one of these depending on which +// variant of the target architecture is being used. This tests against +// any known ARMv6 or ARMv7 variant, where it is possible to directly +// use ldrex/strex instructions to implement fast atomic operations. +#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || \ + defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || \ + defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || \ + defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || \ + defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) + +inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr, + Atomic32 old_value, + Atomic32 new_value) { + Atomic32 prev_value; + int reloop; + do { + // The following is equivalent to: + // + // prev_value = LDREX(ptr) + // reloop = 0 + // if (prev_value != old_value) + // reloop = STREX(ptr, new_value) + __asm__ __volatile__( + " ldrex %0, [%3]\n" + " mov %1, #0\n" + " cmp %0, %4\n" +#ifdef __thumb2__ + " it eq\n" +#endif + " strexeq %1, %5, [%3]\n" + : "=&r"(prev_value), "=&r"(reloop), "+m"(*ptr) + : "r"(ptr), "r"(old_value), "r"(new_value) + : "cc", "memory"); + } while (reloop != 0); + return prev_value; +} + +inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, + Atomic32 old_value, + Atomic32 new_value) { + Atomic32 result = NoBarrier_CompareAndSwap(ptr, old_value, new_value); + MemoryBarrier(); + return result; +} + +inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr, + Atomic32 old_value, + Atomic32 new_value) { + MemoryBarrier(); + return NoBarrier_CompareAndSwap(ptr, old_value, new_value); +} + +inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr, + Atomic32 increment) { + Atomic32 value; + int reloop; + do { + // Equivalent to: + // + // value = LDREX(ptr) + // value += increment + // reloop = STREX(ptr, value) + // + __asm__ __volatile__( + " ldrex %0, [%3]\n" + " add %0, %0, %4\n" + " strex %1, %0, [%3]\n" + : "=&r"(value), "=&r"(reloop), "+m"(*ptr) + : "r"(ptr), "r"(increment) + : "cc", "memory"); + } while (reloop); + return value; +} + +inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, + Atomic32 increment) { + // TODO(digit): Investigate if it's possible to implement this with + // a single MemoryBarrier() operation between the LDREX and STREX. + // See http://crbug.com/246514 + MemoryBarrier(); + Atomic32 result = NoBarrier_AtomicIncrement(ptr, increment); + MemoryBarrier(); + return result; +} + +inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr, + Atomic32 new_value) { + Atomic32 old_value; + int reloop; + do { + // old_value = LDREX(ptr) + // reloop = STREX(ptr, new_value) + __asm__ __volatile__( + " ldrex %0, [%3]\n" + " strex %1, %4, [%3]\n" + : "=&r"(old_value), "=&r"(reloop), "+m"(*ptr) + : "r"(ptr), "r"(new_value) + : "cc", "memory"); + } while (reloop != 0); + return old_value; +} + +// This tests against any known ARMv5 variant. +#elif defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) || \ + defined(__ARM_ARCH_5TE__) || defined(__ARM_ARCH_5TEJ__) + +// The kernel also provides a helper function to perform an atomic +// compare-and-swap operation at the hard-wired address 0xffff0fc0. +// On ARMv5, this is implemented by a special code path that the kernel +// detects and treats specially when thread pre-emption happens. +// On ARMv6 and higher, it uses LDREX/STREX instructions instead. +// +// Note that this always perform a full memory barrier, there is no +// need to add calls MemoryBarrier() before or after it. It also +// returns 0 on success, and 1 on exit. +// +// Available and reliable since Linux 2.6.24. Both Android and ChromeOS +// use newer kernel revisions, so this should not be a concern. +namespace { + +inline int LinuxKernelCmpxchg(Atomic32 old_value, + Atomic32 new_value, + volatile Atomic32* ptr) { + typedef int (*KernelCmpxchgFunc)(Atomic32, Atomic32, volatile Atomic32*); + return ((KernelCmpxchgFunc)0xffff0fc0)(old_value, new_value, ptr); +} + +} // namespace + +inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr, + Atomic32 old_value, + Atomic32 new_value) { + Atomic32 prev_value; + for (;;) { + prev_value = *ptr; + if (prev_value != old_value) + return prev_value; + if (!LinuxKernelCmpxchg(old_value, new_value, ptr)) + return old_value; + } +} + +inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr, + Atomic32 new_value) { + Atomic32 old_value; + do { + old_value = *ptr; + } while (LinuxKernelCmpxchg(old_value, new_value, ptr)); + return old_value; +} + +inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr, + Atomic32 increment) { + return Barrier_AtomicIncrement(ptr, increment); +} + +inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, + Atomic32 increment) { + for (;;) { + // Atomic exchange the old value with an incremented one. + Atomic32 old_value = *ptr; + Atomic32 new_value = old_value + increment; + if (!LinuxKernelCmpxchg(old_value, new_value, ptr)) { + // The exchange took place as expected. + return new_value; + } + // Otherwise, *ptr changed mid-loop and we need to retry. + } +} + +inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, + Atomic32 old_value, + Atomic32 new_value) { + Atomic32 prev_value; + for (;;) { + prev_value = *ptr; + if (prev_value != old_value) { + // Always ensure acquire semantics. + MemoryBarrier(); + return prev_value; + } + if (!LinuxKernelCmpxchg(old_value, new_value, ptr)) + return old_value; + } +} + +inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr, + Atomic32 old_value, + Atomic32 new_value) { + // This could be implemented as: + // MemoryBarrier(); + // return NoBarrier_CompareAndSwap(); + // + // But would use 3 barriers per succesful CAS. To save performance, + // use Acquire_CompareAndSwap(). Its implementation guarantees that: + // - A succesful swap uses only 2 barriers (in the kernel helper). + // - An early return due to (prev_value != old_value) performs + // a memory barrier with no store, which is equivalent to the + // generic implementation above. + return Acquire_CompareAndSwap(ptr, old_value, new_value); +} + +#else +#error "Your CPU's ARM architecture is not supported yet" +#endif + +// NOTE: Atomicity of the following load and store operations is only +// guaranteed in case of 32-bit alignement of |ptr| values. + +inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) { + *ptr = value; +} + +inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) { + *ptr = value; + MemoryBarrier(); +} + +inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) { + MemoryBarrier(); + *ptr = value; +} + +inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) { + return *ptr; +} + +inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) { + Atomic32 value = *ptr; + MemoryBarrier(); + return value; +} + +inline Atomic32 Release_Load(volatile const Atomic32* ptr) { + MemoryBarrier(); + return *ptr; +} + +} // namespace base::subtle +} // namespace base + +#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_ARM_GCC_H_ diff --git a/include/base/internal/cef_atomicops_atomicword_compat.h b/include/base/internal/cef_atomicops_atomicword_compat.h new file mode 100644 index 0000000..f905de8 --- /dev/null +++ b/include/base/internal/cef_atomicops_atomicword_compat.h @@ -0,0 +1,124 @@ +// Copyright (c) 2011 Google Inc. 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. + +// Do not include this header file directly. Use base/cef_atomicops.h +// instead. + +#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_ATOMICWORD_COMPAT_H_ +#define CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_ATOMICWORD_COMPAT_H_ + +// AtomicWord is a synonym for intptr_t, and Atomic32 is a synonym for int32, +// which in turn means int. On some LP32 platforms, intptr_t is an int, but +// on others, it's a long. When AtomicWord and Atomic32 are based on different +// fundamental types, their pointers are incompatible. +// +// This file defines function overloads to allow both AtomicWord and Atomic32 +// data to be used with this interface. +// +// On LP64 platforms, AtomicWord and Atomic64 are both always long, +// so this problem doesn't occur. + +#if !defined(ARCH_CPU_64_BITS) + +namespace base { +namespace subtle { + +inline AtomicWord NoBarrier_CompareAndSwap(volatile AtomicWord* ptr, + AtomicWord old_value, + AtomicWord new_value) { + return NoBarrier_CompareAndSwap(reinterpret_cast(ptr), + old_value, new_value); +} + +inline AtomicWord NoBarrier_AtomicExchange(volatile AtomicWord* ptr, + AtomicWord new_value) { + return NoBarrier_AtomicExchange(reinterpret_cast(ptr), + new_value); +} + +inline AtomicWord NoBarrier_AtomicIncrement(volatile AtomicWord* ptr, + AtomicWord increment) { + return NoBarrier_AtomicIncrement(reinterpret_cast(ptr), + increment); +} + +inline AtomicWord Barrier_AtomicIncrement(volatile AtomicWord* ptr, + AtomicWord increment) { + return Barrier_AtomicIncrement(reinterpret_cast(ptr), + increment); +} + +inline AtomicWord Acquire_CompareAndSwap(volatile AtomicWord* ptr, + AtomicWord old_value, + AtomicWord new_value) { + return base::subtle::Acquire_CompareAndSwap( + reinterpret_cast(ptr), old_value, new_value); +} + +inline AtomicWord Release_CompareAndSwap(volatile AtomicWord* ptr, + AtomicWord old_value, + AtomicWord new_value) { + return base::subtle::Release_CompareAndSwap( + reinterpret_cast(ptr), old_value, new_value); +} + +inline void NoBarrier_Store(volatile AtomicWord* ptr, AtomicWord value) { + NoBarrier_Store(reinterpret_cast(ptr), value); +} + +inline void Acquire_Store(volatile AtomicWord* ptr, AtomicWord value) { + return base::subtle::Acquire_Store(reinterpret_cast(ptr), + value); +} + +inline void Release_Store(volatile AtomicWord* ptr, AtomicWord value) { + return base::subtle::Release_Store(reinterpret_cast(ptr), + value); +} + +inline AtomicWord NoBarrier_Load(volatile const AtomicWord* ptr) { + return NoBarrier_Load(reinterpret_cast(ptr)); +} + +inline AtomicWord Acquire_Load(volatile const AtomicWord* ptr) { + return base::subtle::Acquire_Load( + reinterpret_cast(ptr)); +} + +inline AtomicWord Release_Load(volatile const AtomicWord* ptr) { + return base::subtle::Release_Load( + reinterpret_cast(ptr)); +} + +} // namespace base::subtle +} // namespace base + +#endif // !defined(ARCH_CPU_64_BITS) + +#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_ATOMICWORD_COMPAT_H_ diff --git a/include/base/internal/cef_atomicops_mac.h b/include/base/internal/cef_atomicops_mac.h new file mode 100644 index 0000000..374ae35 --- /dev/null +++ b/include/base/internal/cef_atomicops_mac.h @@ -0,0 +1,223 @@ +// Copyright (c) 2012 Google Inc. 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. + +// Do not include this header file directly. Use base/cef_atomicops.h +// instead. + +#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_MAC_H_ +#define CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_MAC_H_ + +#include + +namespace base { +namespace subtle { + +inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr, + Atomic32 old_value, + Atomic32 new_value) { + Atomic32 prev_value; + do { + if (OSAtomicCompareAndSwap32(old_value, new_value, + const_cast(ptr))) { + return old_value; + } + prev_value = *ptr; + } while (prev_value == old_value); + return prev_value; +} + +inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr, + Atomic32 new_value) { + Atomic32 old_value; + do { + old_value = *ptr; + } while (!OSAtomicCompareAndSwap32(old_value, new_value, + const_cast(ptr))); + return old_value; +} + +inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr, + Atomic32 increment) { + return OSAtomicAdd32(increment, const_cast(ptr)); +} + +inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, + Atomic32 increment) { + return OSAtomicAdd32Barrier(increment, const_cast(ptr)); +} + +inline void MemoryBarrier() { + OSMemoryBarrier(); +} + +inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, + Atomic32 old_value, + Atomic32 new_value) { + Atomic32 prev_value; + do { + if (OSAtomicCompareAndSwap32Barrier(old_value, new_value, + const_cast(ptr))) { + return old_value; + } + prev_value = *ptr; + } while (prev_value == old_value); + return prev_value; +} + +inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr, + Atomic32 old_value, + Atomic32 new_value) { + return Acquire_CompareAndSwap(ptr, old_value, new_value); +} + +inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) { + *ptr = value; +} + +inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) { + *ptr = value; + MemoryBarrier(); +} + +inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) { + MemoryBarrier(); + *ptr = value; +} + +inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) { + return *ptr; +} + +inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) { + Atomic32 value = *ptr; + MemoryBarrier(); + return value; +} + +inline Atomic32 Release_Load(volatile const Atomic32* ptr) { + MemoryBarrier(); + return *ptr; +} + +#ifdef __LP64__ + +// 64-bit implementation on 64-bit platform + +inline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr, + Atomic64 old_value, + Atomic64 new_value) { + Atomic64 prev_value; + do { + if (OSAtomicCompareAndSwap64(old_value, new_value, + reinterpret_cast(ptr))) { + return old_value; + } + prev_value = *ptr; + } while (prev_value == old_value); + return prev_value; +} + +inline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr, + Atomic64 new_value) { + Atomic64 old_value; + do { + old_value = *ptr; + } while (!OSAtomicCompareAndSwap64(old_value, new_value, + reinterpret_cast(ptr))); + return old_value; +} + +inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr, + Atomic64 increment) { + return OSAtomicAdd64(increment, reinterpret_cast(ptr)); +} + +inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr, + Atomic64 increment) { + return OSAtomicAdd64Barrier(increment, + reinterpret_cast(ptr)); +} + +inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr, + Atomic64 old_value, + Atomic64 new_value) { + Atomic64 prev_value; + do { + if (OSAtomicCompareAndSwap64Barrier( + old_value, new_value, reinterpret_cast(ptr))) { + return old_value; + } + prev_value = *ptr; + } while (prev_value == old_value); + return prev_value; +} + +inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr, + Atomic64 old_value, + Atomic64 new_value) { + // The lib kern interface does not distinguish between + // Acquire and Release memory barriers; they are equivalent. + return Acquire_CompareAndSwap(ptr, old_value, new_value); +} + +inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) { + *ptr = value; +} + +inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) { + *ptr = value; + MemoryBarrier(); +} + +inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) { + MemoryBarrier(); + *ptr = value; +} + +inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) { + return *ptr; +} + +inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) { + Atomic64 value = *ptr; + MemoryBarrier(); + return value; +} + +inline Atomic64 Release_Load(volatile const Atomic64* ptr) { + MemoryBarrier(); + return *ptr; +} + +#endif // defined(__LP64__) + +} // namespace base::subtle +} // namespace base + +#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_MAC_H_ diff --git a/include/base/internal/cef_atomicops_x86_gcc.h b/include/base/internal/cef_atomicops_x86_gcc.h new file mode 100644 index 0000000..b93df21 --- /dev/null +++ b/include/base/internal/cef_atomicops_x86_gcc.h @@ -0,0 +1,268 @@ +// Copyright (c) 2011 Google Inc. 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. + +// Do not include this header file directly. Use base/cef_atomicops.h +// instead. + +#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_X86_GCC_H_ +#define CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_X86_GCC_H_ + +// This struct is not part of the public API of this module; clients may not +// use it. +// Features of this x86. Values may not be correct before main() is run, +// but are set conservatively. +struct AtomicOps_x86CPUFeatureStruct { + bool has_amd_lock_mb_bug; // Processor has AMD memory-barrier bug; do lfence + // after acquire compare-and-swap. +}; +extern struct AtomicOps_x86CPUFeatureStruct AtomicOps_Internalx86CPUFeatures; + +#define ATOMICOPS_COMPILER_BARRIER() __asm__ __volatile__("" : : : "memory") + +namespace base { +namespace subtle { + +// 32-bit low-level operations on any platform. + +inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr, + Atomic32 old_value, + Atomic32 new_value) { + Atomic32 prev; + __asm__ __volatile__("lock; cmpxchgl %1,%2" + : "=a"(prev) + : "q"(new_value), "m"(*ptr), "0"(old_value) + : "memory"); + return prev; +} + +inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr, + Atomic32 new_value) { + __asm__ __volatile__("xchgl %1,%0" // The lock prefix is implicit for xchg. + : "=r"(new_value) + : "m"(*ptr), "0"(new_value) + : "memory"); + return new_value; // Now it's the previous value. +} + +inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr, + Atomic32 increment) { + Atomic32 temp = increment; + __asm__ __volatile__("lock; xaddl %0,%1" + : "+r"(temp), "+m"(*ptr) + : + : "memory"); + // temp now holds the old value of *ptr + return temp + increment; +} + +inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, + Atomic32 increment) { + Atomic32 temp = increment; + __asm__ __volatile__("lock; xaddl %0,%1" + : "+r"(temp), "+m"(*ptr) + : + : "memory"); + // temp now holds the old value of *ptr + if (AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) { + __asm__ __volatile__("lfence" : : : "memory"); + } + return temp + increment; +} + +inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, + Atomic32 old_value, + Atomic32 new_value) { + Atomic32 x = NoBarrier_CompareAndSwap(ptr, old_value, new_value); + if (AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) { + __asm__ __volatile__("lfence" : : : "memory"); + } + return x; +} + +inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr, + Atomic32 old_value, + Atomic32 new_value) { + return NoBarrier_CompareAndSwap(ptr, old_value, new_value); +} + +inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) { + *ptr = value; +} + +inline void MemoryBarrier() { + __asm__ __volatile__("mfence" : : : "memory"); +} + +inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) { + *ptr = value; + MemoryBarrier(); +} + +inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) { + ATOMICOPS_COMPILER_BARRIER(); + *ptr = value; // An x86 store acts as a release barrier. + // See comments in Atomic64 version of Release_Store(), below. +} + +inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) { + return *ptr; +} + +inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) { + Atomic32 value = *ptr; // An x86 load acts as a acquire barrier. + // See comments in Atomic64 version of Release_Store(), below. + ATOMICOPS_COMPILER_BARRIER(); + return value; +} + +inline Atomic32 Release_Load(volatile const Atomic32* ptr) { + MemoryBarrier(); + return *ptr; +} + +#if defined(__x86_64__) + +// 64-bit low-level operations on 64-bit platform. + +inline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr, + Atomic64 old_value, + Atomic64 new_value) { + Atomic64 prev; + __asm__ __volatile__("lock; cmpxchgq %1,%2" + : "=a"(prev) + : "q"(new_value), "m"(*ptr), "0"(old_value) + : "memory"); + return prev; +} + +inline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr, + Atomic64 new_value) { + __asm__ __volatile__("xchgq %1,%0" // The lock prefix is implicit for xchg. + : "=r"(new_value) + : "m"(*ptr), "0"(new_value) + : "memory"); + return new_value; // Now it's the previous value. +} + +inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr, + Atomic64 increment) { + Atomic64 temp = increment; + __asm__ __volatile__("lock; xaddq %0,%1" + : "+r"(temp), "+m"(*ptr) + : + : "memory"); + // temp now contains the previous value of *ptr + return temp + increment; +} + +inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr, + Atomic64 increment) { + Atomic64 temp = increment; + __asm__ __volatile__("lock; xaddq %0,%1" + : "+r"(temp), "+m"(*ptr) + : + : "memory"); + // temp now contains the previous value of *ptr + if (AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) { + __asm__ __volatile__("lfence" : : : "memory"); + } + return temp + increment; +} + +inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) { + *ptr = value; +} + +inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) { + *ptr = value; + MemoryBarrier(); +} + +inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) { + ATOMICOPS_COMPILER_BARRIER(); + + *ptr = value; // An x86 store acts as a release barrier + // for current AMD/Intel chips as of Jan 2008. + // See also Acquire_Load(), below. + + // When new chips come out, check: + // IA-32 Intel Architecture Software Developer's Manual, Volume 3: + // System Programming Guide, Chatper 7: Multiple-processor management, + // Section 7.2, Memory Ordering. + // Last seen at: + // http://developer.intel.com/design/pentium4/manuals/index_new.htm + // + // x86 stores/loads fail to act as barriers for a few instructions (clflush + // maskmovdqu maskmovq movntdq movnti movntpd movntps movntq) but these are + // not generated by the compiler, and are rare. Users of these instructions + // need to know about cache behaviour in any case since all of these involve + // either flushing cache lines or non-temporal cache hints. +} + +inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) { + return *ptr; +} + +inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) { + Atomic64 value = *ptr; // An x86 load acts as a acquire barrier, + // for current AMD/Intel chips as of Jan 2008. + // See also Release_Store(), above. + ATOMICOPS_COMPILER_BARRIER(); + return value; +} + +inline Atomic64 Release_Load(volatile const Atomic64* ptr) { + MemoryBarrier(); + return *ptr; +} + +inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr, + Atomic64 old_value, + Atomic64 new_value) { + Atomic64 x = NoBarrier_CompareAndSwap(ptr, old_value, new_value); + if (AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) { + __asm__ __volatile__("lfence" : : : "memory"); + } + return x; +} + +inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr, + Atomic64 old_value, + Atomic64 new_value) { + return NoBarrier_CompareAndSwap(ptr, old_value, new_value); +} + +#endif // defined(__x86_64__) + +} // namespace base::subtle +} // namespace base + +#undef ATOMICOPS_COMPILER_BARRIER + +#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_X86_GCC_H_ diff --git a/include/base/internal/cef_atomicops_x86_msvc.h b/include/base/internal/cef_atomicops_x86_msvc.h new file mode 100644 index 0000000..a262c81 --- /dev/null +++ b/include/base/internal/cef_atomicops_x86_msvc.h @@ -0,0 +1,221 @@ +// Copyright (c) 2008 Google Inc. 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. + +// Do not include this header file directly. Use base/cef_atomicops.h +// instead. + +#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_X86_MSVC_H_ +#define CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_X86_MSVC_H_ + +#include + +#include + +#include "include/base/cef_macros.h" + +#if defined(ARCH_CPU_64_BITS) +// windows.h #defines this (only on x64). This causes problems because the +// public API also uses MemoryBarrier at the public name for this fence. So, on +// X64, undef it, and call its documented +// (http://msdn.microsoft.com/en-us/library/windows/desktop/ms684208.aspx) +// implementation directly. +#undef MemoryBarrier +#endif + +namespace base { +namespace subtle { + +inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr, + Atomic32 old_value, + Atomic32 new_value) { + LONG result = _InterlockedCompareExchange( + reinterpret_cast(ptr), static_cast(new_value), + static_cast(old_value)); + return static_cast(result); +} + +inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr, + Atomic32 new_value) { + LONG result = _InterlockedExchange(reinterpret_cast(ptr), + static_cast(new_value)); + return static_cast(result); +} + +inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, + Atomic32 increment) { + return _InterlockedExchangeAdd(reinterpret_cast(ptr), + static_cast(increment)) + + increment; +} + +inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr, + Atomic32 increment) { + return Barrier_AtomicIncrement(ptr, increment); +} + +#if !(defined(_MSC_VER) && _MSC_VER >= 1400) +#error "We require at least vs2005 for MemoryBarrier" +#endif +inline void MemoryBarrier() { +#if defined(ARCH_CPU_64_BITS) + // See #undef and note at the top of this file. + __faststorefence(); +#else + // We use MemoryBarrier from WinNT.h + ::MemoryBarrier(); +#endif +} + +inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, + Atomic32 old_value, + Atomic32 new_value) { + return NoBarrier_CompareAndSwap(ptr, old_value, new_value); +} + +inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr, + Atomic32 old_value, + Atomic32 new_value) { + return NoBarrier_CompareAndSwap(ptr, old_value, new_value); +} + +inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) { + *ptr = value; +} + +inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) { + NoBarrier_AtomicExchange(ptr, value); + // acts as a barrier in this implementation +} + +inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) { + *ptr = value; // works w/o barrier for current Intel chips as of June 2005 + // See comments in Atomic64 version of Release_Store() below. +} + +inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) { + return *ptr; +} + +inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) { + Atomic32 value = *ptr; + return value; +} + +inline Atomic32 Release_Load(volatile const Atomic32* ptr) { + MemoryBarrier(); + return *ptr; +} + +#if defined(_WIN64) + +// 64-bit low-level operations on 64-bit platform. + +COMPILE_ASSERT(sizeof(Atomic64) == sizeof(PVOID), atomic_word_is_atomic); + +inline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr, + Atomic64 old_value, + Atomic64 new_value) { + PVOID result = InterlockedCompareExchangePointer( + reinterpret_cast(ptr), + reinterpret_cast(new_value), reinterpret_cast(old_value)); + return reinterpret_cast(result); +} + +inline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr, + Atomic64 new_value) { + PVOID result = + InterlockedExchangePointer(reinterpret_cast(ptr), + reinterpret_cast(new_value)); + return reinterpret_cast(result); +} + +inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr, + Atomic64 increment) { + return InterlockedExchangeAdd64(reinterpret_cast(ptr), + static_cast(increment)) + + increment; +} + +inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr, + Atomic64 increment) { + return Barrier_AtomicIncrement(ptr, increment); +} + +inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) { + *ptr = value; +} + +inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) { + NoBarrier_AtomicExchange(ptr, value); + // acts as a barrier in this implementation +} + +inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) { + *ptr = value; // works w/o barrier for current Intel chips as of June 2005 + + // When new chips come out, check: + // IA-32 Intel Architecture Software Developer's Manual, Volume 3: + // System Programming Guide, Chatper 7: Multiple-processor management, + // Section 7.2, Memory Ordering. + // Last seen at: + // http://developer.intel.com/design/pentium4/manuals/index_new.htm +} + +inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) { + return *ptr; +} + +inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) { + Atomic64 value = *ptr; + return value; +} + +inline Atomic64 Release_Load(volatile const Atomic64* ptr) { + MemoryBarrier(); + return *ptr; +} + +inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr, + Atomic64 old_value, + Atomic64 new_value) { + return NoBarrier_CompareAndSwap(ptr, old_value, new_value); +} + +inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr, + Atomic64 old_value, + Atomic64 new_value) { + return NoBarrier_CompareAndSwap(ptr, old_value, new_value); +} + +#endif // defined(_WIN64) + +} // namespace base::subtle +} // namespace base + +#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_X86_MSVC_H_ diff --git a/include/base/internal/cef_bind_internal.h b/include/base/internal/cef_bind_internal.h new file mode 100644 index 0000000..64eeb3f --- /dev/null +++ b/include/base/internal/cef_bind_internal.h @@ -0,0 +1,3190 @@ +// Copyright (c) 2011 Google Inc. 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. + +// Do not include this header file directly. Use base/cef_bind.h instead. + +#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_BIND_INTERNAL_H_ +#define CEF_INCLUDE_BASE_INTERNAL_CEF_BIND_INTERNAL_H_ + +#include "include/base/cef_bind_helpers.h" +#include "include/base/cef_build.h" +#include "include/base/cef_template_util.h" +#include "include/base/cef_weak_ptr.h" +#include "include/base/internal/cef_callback_internal.h" +#include "include/base/internal/cef_raw_scoped_refptr_mismatch_checker.h" + +#if defined(OS_WIN) +#include "include/base/internal/cef_bind_internal_win.h" +#endif + +namespace base { +namespace cef_internal { + +// See base/callback.h for user documentation. +// +// +// CONCEPTS: +// Runnable -- A type (really a type class) that has a single Run() method +// and a RunType typedef that corresponds to the type of Run(). +// A Runnable can declare that it should treated like a method +// call by including a typedef named IsMethod. The value of +// this typedef is NOT inspected, only the existence. When a +// Runnable declares itself a method, Bind() will enforce special +// refcounting + WeakPtr handling semantics for the first +// parameter which is expected to be an object. +// Functor -- A copyable type representing something that should be called. +// All function pointers, Callback<>, and Runnables are functors +// even if the invocation syntax differs. +// RunType -- A function type (as opposed to function _pointer_ type) for +// a Run() function. Usually just a convenience typedef. +// (Bound)ArgsType -- A function type that is being (ab)used to store the +// types of set of arguments. The "return" type is always +// void here. We use this hack so that we do not need +// a new type name for each arity of type. (eg., +// BindState1, BindState2). This makes forward +// declarations and friending much much easier. +// +// Types: +// RunnableAdapter<> -- Wraps the various "function" pointer types into an +// object that adheres to the Runnable interface. +// There are |3*ARITY| RunnableAdapter types. +// FunctionTraits<> -- Type traits that unwrap a function signature into a +// a set of easier to use typedefs. Used mainly for +// compile time asserts. +// There are |ARITY| FunctionTraits types. +// ForceVoidReturn<> -- Helper class for translating function signatures to +// equivalent forms with a "void" return type. +// There are |ARITY| ForceVoidReturn types. +// FunctorTraits<> -- Type traits used determine the correct RunType and +// RunnableType for a Functor. This is where function +// signature adapters are applied. +// There are |ARITY| ForceVoidReturn types. +// MakeRunnable<> -- Takes a Functor and returns an object in the Runnable +// type class that represents the underlying Functor. +// There are |O(1)| MakeRunnable types. +// InvokeHelper<> -- Take a Runnable + arguments and actully invokes it. +// Handle the differing syntaxes needed for WeakPtr<> support, +// and for ignoring return values. This is separate from +// Invoker to avoid creating multiple version of Invoker<> +// which grows at O(n^2) with the arity. +// There are |k*ARITY| InvokeHelper types. +// Invoker<> -- Unwraps the curried parameters and executes the Runnable. +// There are |(ARITY^2 + ARITY)/2| Invoketypes. +// BindState<> -- Stores the curried parameters, and is the main entry point +// into the Bind() system, doing most of the type resolution. +// There are ARITY BindState types. + +// RunnableAdapter<> +// +// The RunnableAdapter<> templates provide a uniform interface for invoking +// a function pointer, method pointer, or const method pointer. The adapter +// exposes a Run() method with an appropriate signature. Using this wrapper +// allows for writing code that supports all three pointer types without +// undue repetition. Without it, a lot of code would need to be repeated 3 +// times. +// +// For method pointers and const method pointers the first argument to Run() +// is considered to be the received of the method. This is similar to STL's +// mem_fun(). +// +// This class also exposes a RunType typedef that is the function type of the +// Run() function. +// +// If and only if the wrapper contains a method or const method pointer, an +// IsMethod typedef is exposed. The existence of this typedef (NOT the value) +// marks that the wrapper should be considered a method wrapper. + +template +class RunnableAdapter; + +// Function: Arity 0. +template +class RunnableAdapter { + public: + typedef R(RunType)(); + + explicit RunnableAdapter(R (*function)()) : function_(function) {} + + R Run() { return function_(); } + + private: + R (*function_)(); +}; + +// Method: Arity 0. +template +class RunnableAdapter { + public: + typedef R(RunType)(T*); + typedef true_type IsMethod; + + explicit RunnableAdapter(R (T::*method)()) : method_(method) {} + + R Run(T* object) { return (object->*method_)(); } + + private: + R (T::*method_)(); +}; + +// Const Method: Arity 0. +template +class RunnableAdapter { + public: + typedef R(RunType)(const T*); + typedef true_type IsMethod; + + explicit RunnableAdapter(R (T::*method)() const) : method_(method) {} + + R Run(const T* object) { return (object->*method_)(); } + + private: + R (T::*method_)() const; +}; + +// Function: Arity 1. +template +class RunnableAdapter { + public: + typedef R(RunType)(A1); + + explicit RunnableAdapter(R (*function)(A1)) : function_(function) {} + + R Run(typename CallbackParamTraits::ForwardType a1) { + return function_(CallbackForward(a1)); + } + + private: + R (*function_)(A1); +}; + +// Method: Arity 1. +template +class RunnableAdapter { + public: + typedef R(RunType)(T*, A1); + typedef true_type IsMethod; + + explicit RunnableAdapter(R (T::*method)(A1)) : method_(method) {} + + R Run(T* object, typename CallbackParamTraits::ForwardType a1) { + return (object->*method_)(CallbackForward(a1)); + } + + private: + R (T::*method_)(A1); +}; + +// Const Method: Arity 1. +template +class RunnableAdapter { + public: + typedef R(RunType)(const T*, A1); + typedef true_type IsMethod; + + explicit RunnableAdapter(R (T::*method)(A1) const) : method_(method) {} + + R Run(const T* object, typename CallbackParamTraits::ForwardType a1) { + return (object->*method_)(CallbackForward(a1)); + } + + private: + R (T::*method_)(A1) const; +}; + +// Function: Arity 2. +template +class RunnableAdapter { + public: + typedef R(RunType)(A1, A2); + + explicit RunnableAdapter(R (*function)(A1, A2)) : function_(function) {} + + R Run(typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2) { + return function_(CallbackForward(a1), CallbackForward(a2)); + } + + private: + R (*function_)(A1, A2); +}; + +// Method: Arity 2. +template +class RunnableAdapter { + public: + typedef R(RunType)(T*, A1, A2); + typedef true_type IsMethod; + + explicit RunnableAdapter(R (T::*method)(A1, A2)) : method_(method) {} + + R Run(T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2) { + return (object->*method_)(CallbackForward(a1), CallbackForward(a2)); + } + + private: + R (T::*method_)(A1, A2); +}; + +// Const Method: Arity 2. +template +class RunnableAdapter { + public: + typedef R(RunType)(const T*, A1, A2); + typedef true_type IsMethod; + + explicit RunnableAdapter(R (T::*method)(A1, A2) const) : method_(method) {} + + R Run(const T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2) { + return (object->*method_)(CallbackForward(a1), CallbackForward(a2)); + } + + private: + R (T::*method_)(A1, A2) const; +}; + +// Function: Arity 3. +template +class RunnableAdapter { + public: + typedef R(RunType)(A1, A2, A3); + + explicit RunnableAdapter(R (*function)(A1, A2, A3)) : function_(function) {} + + R Run(typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3) { + return function_(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3)); + } + + private: + R (*function_)(A1, A2, A3); +}; + +// Method: Arity 3. +template +class RunnableAdapter { + public: + typedef R(RunType)(T*, A1, A2, A3); + typedef true_type IsMethod; + + explicit RunnableAdapter(R (T::*method)(A1, A2, A3)) : method_(method) {} + + R Run(T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3) { + return (object->*method_)(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3)); + } + + private: + R (T::*method_)(A1, A2, A3); +}; + +// Const Method: Arity 3. +template +class RunnableAdapter { + public: + typedef R(RunType)(const T*, A1, A2, A3); + typedef true_type IsMethod; + + explicit RunnableAdapter(R (T::*method)(A1, A2, A3) const) + : method_(method) {} + + R Run(const T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3) { + return (object->*method_)(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3)); + } + + private: + R (T::*method_)(A1, A2, A3) const; +}; + +// Function: Arity 4. +template +class RunnableAdapter { + public: + typedef R(RunType)(A1, A2, A3, A4); + + explicit RunnableAdapter(R (*function)(A1, A2, A3, A4)) + : function_(function) {} + + R Run(typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4) { + return function_(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3), CallbackForward(a4)); + } + + private: + R (*function_)(A1, A2, A3, A4); +}; + +// Method: Arity 4. +template +class RunnableAdapter { + public: + typedef R(RunType)(T*, A1, A2, A3, A4); + typedef true_type IsMethod; + + explicit RunnableAdapter(R (T::*method)(A1, A2, A3, A4)) : method_(method) {} + + R Run(T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4) { + return (object->*method_)(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3), CallbackForward(a4)); + } + + private: + R (T::*method_)(A1, A2, A3, A4); +}; + +// Const Method: Arity 4. +template +class RunnableAdapter { + public: + typedef R(RunType)(const T*, A1, A2, A3, A4); + typedef true_type IsMethod; + + explicit RunnableAdapter(R (T::*method)(A1, A2, A3, A4) const) + : method_(method) {} + + R Run(const T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4) { + return (object->*method_)(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3), CallbackForward(a4)); + } + + private: + R (T::*method_)(A1, A2, A3, A4) const; +}; + +// Function: Arity 5. +template +class RunnableAdapter { + public: + typedef R(RunType)(A1, A2, A3, A4, A5); + + explicit RunnableAdapter(R (*function)(A1, A2, A3, A4, A5)) + : function_(function) {} + + R Run(typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5) { + return function_(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5)); + } + + private: + R (*function_)(A1, A2, A3, A4, A5); +}; + +// Method: Arity 5. +template +class RunnableAdapter { + public: + typedef R(RunType)(T*, A1, A2, A3, A4, A5); + typedef true_type IsMethod; + + explicit RunnableAdapter(R (T::*method)(A1, A2, A3, A4, A5)) + : method_(method) {} + + R Run(T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5) { + return (object->*method_)(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5)); + } + + private: + R (T::*method_)(A1, A2, A3, A4, A5); +}; + +// Const Method: Arity 5. +template +class RunnableAdapter { + public: + typedef R(RunType)(const T*, A1, A2, A3, A4, A5); + typedef true_type IsMethod; + + explicit RunnableAdapter(R (T::*method)(A1, A2, A3, A4, A5) const) + : method_(method) {} + + R Run(const T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5) { + return (object->*method_)(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5)); + } + + private: + R (T::*method_)(A1, A2, A3, A4, A5) const; +}; + +// Function: Arity 6. +template +class RunnableAdapter { + public: + typedef R(RunType)(A1, A2, A3, A4, A5, A6); + + explicit RunnableAdapter(R (*function)(A1, A2, A3, A4, A5, A6)) + : function_(function) {} + + R Run(typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5, + typename CallbackParamTraits::ForwardType a6) { + return function_(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5), CallbackForward(a6)); + } + + private: + R (*function_)(A1, A2, A3, A4, A5, A6); +}; + +// Method: Arity 6. +template +class RunnableAdapter { + public: + typedef R(RunType)(T*, A1, A2, A3, A4, A5, A6); + typedef true_type IsMethod; + + explicit RunnableAdapter(R (T::*method)(A1, A2, A3, A4, A5, A6)) + : method_(method) {} + + R Run(T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5, + typename CallbackParamTraits::ForwardType a6) { + return (object->*method_)(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5), CallbackForward(a6)); + } + + private: + R (T::*method_)(A1, A2, A3, A4, A5, A6); +}; + +// Const Method: Arity 6. +template +class RunnableAdapter { + public: + typedef R(RunType)(const T*, A1, A2, A3, A4, A5, A6); + typedef true_type IsMethod; + + explicit RunnableAdapter(R (T::*method)(A1, A2, A3, A4, A5, A6) const) + : method_(method) {} + + R Run(const T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5, + typename CallbackParamTraits::ForwardType a6) { + return (object->*method_)(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5), CallbackForward(a6)); + } + + private: + R (T::*method_)(A1, A2, A3, A4, A5, A6) const; +}; + +// Function: Arity 7. +template +class RunnableAdapter { + public: + typedef R(RunType)(A1, A2, A3, A4, A5, A6, A7); + + explicit RunnableAdapter(R (*function)(A1, A2, A3, A4, A5, A6, A7)) + : function_(function) {} + + R Run(typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5, + typename CallbackParamTraits::ForwardType a6, + typename CallbackParamTraits::ForwardType a7) { + return function_(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5), CallbackForward(a6), + CallbackForward(a7)); + } + + private: + R (*function_)(A1, A2, A3, A4, A5, A6, A7); +}; + +// Method: Arity 7. +template +class RunnableAdapter { + public: + typedef R(RunType)(T*, A1, A2, A3, A4, A5, A6, A7); + typedef true_type IsMethod; + + explicit RunnableAdapter(R (T::*method)(A1, A2, A3, A4, A5, A6, A7)) + : method_(method) {} + + R Run(T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5, + typename CallbackParamTraits::ForwardType a6, + typename CallbackParamTraits::ForwardType a7) { + return (object->*method_)(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5), CallbackForward(a6), + CallbackForward(a7)); + } + + private: + R (T::*method_)(A1, A2, A3, A4, A5, A6, A7); +}; + +// Const Method: Arity 7. +template +class RunnableAdapter { + public: + typedef R(RunType)(const T*, A1, A2, A3, A4, A5, A6, A7); + typedef true_type IsMethod; + + explicit RunnableAdapter(R (T::*method)(A1, A2, A3, A4, A5, A6, A7) const) + : method_(method) {} + + R Run(const T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5, + typename CallbackParamTraits::ForwardType a6, + typename CallbackParamTraits::ForwardType a7) { + return (object->*method_)(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5), CallbackForward(a6), + CallbackForward(a7)); + } + + private: + R (T::*method_)(A1, A2, A3, A4, A5, A6, A7) const; +}; + +// FunctionTraits<> +// +// Breaks a function signature apart into typedefs for easier introspection. +template +struct FunctionTraits; + +template +struct FunctionTraits { + typedef R ReturnType; +}; + +template +struct FunctionTraits { + typedef R ReturnType; + typedef A1 A1Type; +}; + +template +struct FunctionTraits { + typedef R ReturnType; + typedef A1 A1Type; + typedef A2 A2Type; +}; + +template +struct FunctionTraits { + typedef R ReturnType; + typedef A1 A1Type; + typedef A2 A2Type; + typedef A3 A3Type; +}; + +template +struct FunctionTraits { + typedef R ReturnType; + typedef A1 A1Type; + typedef A2 A2Type; + typedef A3 A3Type; + typedef A4 A4Type; +}; + +template +struct FunctionTraits { + typedef R ReturnType; + typedef A1 A1Type; + typedef A2 A2Type; + typedef A3 A3Type; + typedef A4 A4Type; + typedef A5 A5Type; +}; + +template +struct FunctionTraits { + typedef R ReturnType; + typedef A1 A1Type; + typedef A2 A2Type; + typedef A3 A3Type; + typedef A4 A4Type; + typedef A5 A5Type; + typedef A6 A6Type; +}; + +template +struct FunctionTraits { + typedef R ReturnType; + typedef A1 A1Type; + typedef A2 A2Type; + typedef A3 A3Type; + typedef A4 A4Type; + typedef A5 A5Type; + typedef A6 A6Type; + typedef A7 A7Type; +}; + +// ForceVoidReturn<> +// +// Set of templates that support forcing the function return type to void. +template +struct ForceVoidReturn; + +template +struct ForceVoidReturn { + typedef void(RunType)(); +}; + +template +struct ForceVoidReturn { + typedef void(RunType)(A1); +}; + +template +struct ForceVoidReturn { + typedef void(RunType)(A1, A2); +}; + +template +struct ForceVoidReturn { + typedef void(RunType)(A1, A2, A3); +}; + +template +struct ForceVoidReturn { + typedef void(RunType)(A1, A2, A3, A4); +}; + +template +struct ForceVoidReturn { + typedef void(RunType)(A1, A2, A3, A4, A5); +}; + +template +struct ForceVoidReturn { + typedef void(RunType)(A1, A2, A3, A4, A5, A6); +}; + +template +struct ForceVoidReturn { + typedef void(RunType)(A1, A2, A3, A4, A5, A6, A7); +}; + +// FunctorTraits<> +// +// See description at top of file. +template +struct FunctorTraits { + typedef RunnableAdapter RunnableType; + typedef typename RunnableType::RunType RunType; +}; + +template +struct FunctorTraits> { + typedef typename FunctorTraits::RunnableType RunnableType; + typedef + typename ForceVoidReturn::RunType RunType; +}; + +template +struct FunctorTraits> { + typedef Callback RunnableType; + typedef typename Callback::RunType RunType; +}; + +// MakeRunnable<> +// +// Converts a passed in functor to a RunnableType using type inference. + +template +typename FunctorTraits::RunnableType MakeRunnable(const T& t) { + return RunnableAdapter(t); +} + +template +typename FunctorTraits::RunnableType MakeRunnable( + const IgnoreResultHelper& t) { + return MakeRunnable(t.functor_); +} + +template +const typename FunctorTraits>::RunnableType& MakeRunnable( + const Callback& t) { + DCHECK(!t.is_null()); + return t; +} + +// InvokeHelper<> +// +// There are 3 logical InvokeHelper<> specializations: normal, void-return, +// WeakCalls. +// +// The normal type just calls the underlying runnable. +// +// We need a InvokeHelper to handle void return types in order to support +// IgnoreResult(). Normally, if the Runnable's RunType had a void return, +// the template system would just accept "return functor.Run()" ignoring +// the fact that a void function is being used with return. This piece of +// sugar breaks though when the Runnable's RunType is not void. Thus, we +// need a partial specialization to change the syntax to drop the "return" +// from the invocation call. +// +// WeakCalls similarly need special syntax that is applied to the first +// argument to check if they should no-op themselves. +template +struct InvokeHelper; + +template +struct InvokeHelper { + static ReturnType MakeItSo(Runnable runnable) { return runnable.Run(); } +}; + +template +struct InvokeHelper { + static void MakeItSo(Runnable runnable) { runnable.Run(); } +}; + +template +struct InvokeHelper { + static ReturnType MakeItSo(Runnable runnable, A1 a1) { + return runnable.Run(CallbackForward(a1)); + } +}; + +template +struct InvokeHelper { + static void MakeItSo(Runnable runnable, A1 a1) { + runnable.Run(CallbackForward(a1)); + } +}; + +template +struct InvokeHelper { + static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr) { + if (!weak_ptr.get()) { + return; + } + runnable.Run(weak_ptr.get()); + } +}; + +template +struct InvokeHelper { + static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2) { + return runnable.Run(CallbackForward(a1), CallbackForward(a2)); + } +}; + +template +struct InvokeHelper { + static void MakeItSo(Runnable runnable, A1 a1, A2 a2) { + runnable.Run(CallbackForward(a1), CallbackForward(a2)); + } +}; + +template +struct InvokeHelper { + static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, A2 a2) { + if (!weak_ptr.get()) { + return; + } + runnable.Run(weak_ptr.get(), CallbackForward(a2)); + } +}; + +template +struct InvokeHelper { + static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3) { + return runnable.Run(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3)); + } +}; + +template +struct InvokeHelper { + static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3) { + runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3)); + } +}; + +template +struct InvokeHelper { + static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, A2 a2, A3 a3) { + if (!weak_ptr.get()) { + return; + } + runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3)); + } +}; + +template +struct InvokeHelper { + static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4) { + return runnable.Run(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3), CallbackForward(a4)); + } +}; + +template +struct InvokeHelper { + static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4) { + runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3), + CallbackForward(a4)); + } +}; + +template +struct InvokeHelper { + static void MakeItSo(Runnable runnable, + BoundWeakPtr weak_ptr, + A2 a2, + A3 a3, + A4 a4) { + if (!weak_ptr.get()) { + return; + } + runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3), + CallbackForward(a4)); + } +}; + +template +struct InvokeHelper { + static ReturnType MakeItSo(Runnable runnable, + A1 a1, + A2 a2, + A3 a3, + A4 a4, + A5 a5) { + return runnable.Run(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5)); + } +}; + +template +struct InvokeHelper { + static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) { + runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3), + CallbackForward(a4), CallbackForward(a5)); + } +}; + +template +struct InvokeHelper { + static void MakeItSo(Runnable runnable, + BoundWeakPtr weak_ptr, + A2 a2, + A3 a3, + A4 a4, + A5 a5) { + if (!weak_ptr.get()) { + return; + } + runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3), + CallbackForward(a4), CallbackForward(a5)); + } +}; + +template +struct InvokeHelper { + static ReturnType + MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) { + return runnable.Run(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5), CallbackForward(a6)); + } +}; + +template +struct InvokeHelper { + static void + MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) { + runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3), + CallbackForward(a4), CallbackForward(a5), CallbackForward(a6)); + } +}; + +template +struct InvokeHelper { + static void MakeItSo(Runnable runnable, + BoundWeakPtr weak_ptr, + A2 a2, + A3 a3, + A4 a4, + A5 a5, + A6 a6) { + if (!weak_ptr.get()) { + return; + } + runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3), + CallbackForward(a4), CallbackForward(a5), CallbackForward(a6)); + } +}; + +template +struct InvokeHelper { + static ReturnType + MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) { + return runnable.Run(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5), CallbackForward(a6), + CallbackForward(a7)); + } +}; + +template +struct InvokeHelper { + static void + MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) { + runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3), + CallbackForward(a4), CallbackForward(a5), CallbackForward(a6), + CallbackForward(a7)); + } +}; + +template +struct InvokeHelper { + static void MakeItSo(Runnable runnable, + BoundWeakPtr weak_ptr, + A2 a2, + A3 a3, + A4 a4, + A5 a5, + A6 a6, + A7 a7) { + if (!weak_ptr.get()) { + return; + } + runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3), + CallbackForward(a4), CallbackForward(a5), CallbackForward(a6), + CallbackForward(a7)); + } +}; + +#if !defined(_MSC_VER) + +template +struct InvokeHelper { + // WeakCalls are only supported for functions with a void return type. + // Otherwise, the function result would be undefined if the the WeakPtr<> + // is invalidated. + COMPILE_ASSERT(is_void::value, + weak_ptrs_can_only_bind_to_methods_without_return_values); +}; + +#endif + +// Invoker<> +// +// See description at the top of the file. +template +struct Invoker; + +// Arity 0 -> 0. +template +struct Invoker<0, StorageType, R()> { + typedef R(RunType)(BindStateBase*); + + typedef R(UnboundRunType)(); + + static R Run(BindStateBase* base) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + + return InvokeHelper::MakeItSo(storage->runnable_); + } +}; + +// Arity 1 -> 1. +template +struct Invoker<0, StorageType, R(X1)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X1); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x1) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + + return InvokeHelper::ForwardType + x1)>::MakeItSo(storage->runnable_, + CallbackForward(x1)); + } +}; + +// Arity 1 -> 0. +template +struct Invoker<1, StorageType, R(X1)> { + typedef R(RunType)(BindStateBase*); + + typedef R(UnboundRunType)(); + + static R Run(BindStateBase* base) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + return InvokeHelper:: + MakeItSo(storage->runnable_, CallbackForward(x1)); + } +}; + +// Arity 2 -> 2. +template +struct Invoker<0, StorageType, R(X1, X2)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X1, X2); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x1, + typename CallbackParamTraits::ForwardType x2) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + + return InvokeHelper::ForwardType x1, + typename CallbackParamTraits::ForwardType + x2)>::MakeItSo(storage->runnable_, + CallbackForward(x1), + CallbackForward(x2)); + } +}; + +// Arity 2 -> 1. +template +struct Invoker<1, StorageType, R(X1, X2)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X2); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x2) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + return InvokeHelper::ForwardType + x2)>::MakeItSo(storage->runnable_, + CallbackForward(x1), + CallbackForward(x2)); + } +}; + +// Arity 2 -> 0. +template +struct Invoker<2, StorageType, R(X1, X2)> { + typedef R(RunType)(BindStateBase*); + + typedef R(UnboundRunType)(); + + static R Run(BindStateBase* base) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + return InvokeHelper:: + MakeItSo(storage->runnable_, CallbackForward(x1), CallbackForward(x2)); + } +}; + +// Arity 3 -> 3. +template +struct Invoker<0, StorageType, R(X1, X2, X3)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X1, X2, X3); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x1, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + + return InvokeHelper::ForwardType x1, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType + x3)>::MakeItSo(storage->runnable_, + CallbackForward(x1), + CallbackForward(x2), + CallbackForward(x3)); + } +}; + +// Arity 3 -> 2. +template +struct Invoker<1, StorageType, R(X1, X2, X3)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X2, X3); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + return InvokeHelper::ForwardType x2, + typename CallbackParamTraits::ForwardType + x3)>::MakeItSo(storage->runnable_, + CallbackForward(x1), + CallbackForward(x2), + CallbackForward(x3)); + } +}; + +// Arity 3 -> 1. +template +struct Invoker<2, StorageType, R(X1, X2, X3)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X3); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x3) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + return InvokeHelper::ForwardType + x3)>::MakeItSo(storage->runnable_, + CallbackForward(x1), + CallbackForward(x2), + CallbackForward(x3)); + } +}; + +// Arity 3 -> 0. +template +struct Invoker<3, StorageType, R(X1, X2, X3)> { + typedef R(RunType)(BindStateBase*); + + typedef R(UnboundRunType)(); + + static R Run(BindStateBase* base) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + typename Bound3UnwrapTraits::ForwardType x3 = + Bound3UnwrapTraits::Unwrap(storage->p3_); + return InvokeHelper:: + MakeItSo(storage->runnable_, CallbackForward(x1), CallbackForward(x2), + CallbackForward(x3)); + } +}; + +// Arity 4 -> 4. +template +struct Invoker<0, StorageType, R(X1, X2, X3, X4)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X1, X2, X3, X4); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x1, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + + return InvokeHelper::ForwardType x1, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType + x4)>::MakeItSo(storage->runnable_, + CallbackForward(x1), + CallbackForward(x2), + CallbackForward(x3), + CallbackForward(x4)); + } +}; + +// Arity 4 -> 3. +template +struct Invoker<1, StorageType, R(X1, X2, X3, X4)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X2, X3, X4); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + return InvokeHelper::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType + x4)>::MakeItSo(storage->runnable_, + CallbackForward(x1), + CallbackForward(x2), + CallbackForward(x3), + CallbackForward(x4)); + } +}; + +// Arity 4 -> 2. +template +struct Invoker<2, StorageType, R(X1, X2, X3, X4)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X3, X4); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + return InvokeHelper::ForwardType x3, + typename CallbackParamTraits::ForwardType + x4)>::MakeItSo(storage->runnable_, + CallbackForward(x1), + CallbackForward(x2), + CallbackForward(x3), + CallbackForward(x4)); + } +}; + +// Arity 4 -> 1. +template +struct Invoker<3, StorageType, R(X1, X2, X3, X4)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X4); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x4) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + typename Bound3UnwrapTraits::ForwardType x3 = + Bound3UnwrapTraits::Unwrap(storage->p3_); + return InvokeHelper::ForwardType + x4)>::MakeItSo(storage->runnable_, + CallbackForward(x1), + CallbackForward(x2), + CallbackForward(x3), + CallbackForward(x4)); + } +}; + +// Arity 4 -> 0. +template +struct Invoker<4, StorageType, R(X1, X2, X3, X4)> { + typedef R(RunType)(BindStateBase*); + + typedef R(UnboundRunType)(); + + static R Run(BindStateBase* base) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; + typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + typename Bound3UnwrapTraits::ForwardType x3 = + Bound3UnwrapTraits::Unwrap(storage->p3_); + typename Bound4UnwrapTraits::ForwardType x4 = + Bound4UnwrapTraits::Unwrap(storage->p4_); + return InvokeHelper:: + MakeItSo(storage->runnable_, CallbackForward(x1), CallbackForward(x2), + CallbackForward(x3), CallbackForward(x4)); + } +}; + +// Arity 5 -> 5. +template +struct Invoker<0, StorageType, R(X1, X2, X3, X4, X5)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X1, X2, X3, X4, X5); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x1, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename CallbackParamTraits::ForwardType x1, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType + x5)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5)); + } +}; + +// Arity 5 -> 4. +template +struct Invoker<1, StorageType, R(X1, X2, X3, X4, X5)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X2, X3, X4, X5); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType + x5)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5)); + } +}; + +// Arity 5 -> 3. +template +struct Invoker<2, StorageType, R(X1, X2, X3, X4, X5)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X3, X4, X5); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType + x5)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5)); + } +}; + +// Arity 5 -> 2. +template +struct Invoker<3, StorageType, R(X1, X2, X3, X4, X5)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X4, X5); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + typename Bound3UnwrapTraits::ForwardType x3 = + Bound3UnwrapTraits::Unwrap(storage->p3_); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename Bound3UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType + x5)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5)); + } +}; + +// Arity 5 -> 1. +template +struct Invoker<4, StorageType, R(X1, X2, X3, X4, X5)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X5); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x5) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; + typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + typename Bound3UnwrapTraits::ForwardType x3 = + Bound3UnwrapTraits::Unwrap(storage->p3_); + typename Bound4UnwrapTraits::ForwardType x4 = + Bound4UnwrapTraits::Unwrap(storage->p4_); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename Bound3UnwrapTraits::ForwardType, + typename Bound4UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType + x5)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5)); + } +}; + +// Arity 5 -> 0. +template +struct Invoker<5, StorageType, R(X1, X2, X3, X4, X5)> { + typedef R(RunType)(BindStateBase*); + + typedef R(UnboundRunType)(); + + static R Run(BindStateBase* base) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; + typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; + typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + typename Bound3UnwrapTraits::ForwardType x3 = + Bound3UnwrapTraits::Unwrap(storage->p3_); + typename Bound4UnwrapTraits::ForwardType x4 = + Bound4UnwrapTraits::Unwrap(storage->p4_); + typename Bound5UnwrapTraits::ForwardType x5 = + Bound5UnwrapTraits::Unwrap(storage->p5_); + return InvokeHelper:: + MakeItSo(storage->runnable_, CallbackForward(x1), CallbackForward(x2), + CallbackForward(x3), CallbackForward(x4), CallbackForward(x5)); + } +}; + +// Arity 6 -> 6. +template +struct Invoker<0, StorageType, R(X1, X2, X3, X4, X5, X6)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X1, X2, X3, X4, X5, X6); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x1, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename CallbackParamTraits::ForwardType x1, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType + x6)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6)); + } +}; + +// Arity 6 -> 5. +template +struct Invoker<1, StorageType, R(X1, X2, X3, X4, X5, X6)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X2, X3, X4, X5, X6); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType + x6)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6)); + } +}; + +// Arity 6 -> 4. +template +struct Invoker<2, StorageType, R(X1, X2, X3, X4, X5, X6)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X3, X4, X5, X6); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType + x6)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6)); + } +}; + +// Arity 6 -> 3. +template +struct Invoker<3, StorageType, R(X1, X2, X3, X4, X5, X6)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X4, X5, X6); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + typename Bound3UnwrapTraits::ForwardType x3 = + Bound3UnwrapTraits::Unwrap(storage->p3_); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename Bound3UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType + x6)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6)); + } +}; + +// Arity 6 -> 2. +template +struct Invoker<4, StorageType, R(X1, X2, X3, X4, X5, X6)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X5, X6); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; + typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + typename Bound3UnwrapTraits::ForwardType x3 = + Bound3UnwrapTraits::Unwrap(storage->p3_); + typename Bound4UnwrapTraits::ForwardType x4 = + Bound4UnwrapTraits::Unwrap(storage->p4_); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename Bound3UnwrapTraits::ForwardType, + typename Bound4UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType + x6)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6)); + } +}; + +// Arity 6 -> 1. +template +struct Invoker<5, StorageType, R(X1, X2, X3, X4, X5, X6)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X6); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x6) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; + typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; + typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + typename Bound3UnwrapTraits::ForwardType x3 = + Bound3UnwrapTraits::Unwrap(storage->p3_); + typename Bound4UnwrapTraits::ForwardType x4 = + Bound4UnwrapTraits::Unwrap(storage->p4_); + typename Bound5UnwrapTraits::ForwardType x5 = + Bound5UnwrapTraits::Unwrap(storage->p5_); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename Bound3UnwrapTraits::ForwardType, + typename Bound4UnwrapTraits::ForwardType, + typename Bound5UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType + x6)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6)); + } +}; + +// Arity 6 -> 0. +template +struct Invoker<6, StorageType, R(X1, X2, X3, X4, X5, X6)> { + typedef R(RunType)(BindStateBase*); + + typedef R(UnboundRunType)(); + + static R Run(BindStateBase* base) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; + typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; + typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits; + typedef typename StorageType::Bound6UnwrapTraits Bound6UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + typename Bound3UnwrapTraits::ForwardType x3 = + Bound3UnwrapTraits::Unwrap(storage->p3_); + typename Bound4UnwrapTraits::ForwardType x4 = + Bound4UnwrapTraits::Unwrap(storage->p4_); + typename Bound5UnwrapTraits::ForwardType x5 = + Bound5UnwrapTraits::Unwrap(storage->p5_); + typename Bound6UnwrapTraits::ForwardType x6 = + Bound6UnwrapTraits::Unwrap(storage->p6_); + return InvokeHelper:: + MakeItSo(storage->runnable_, CallbackForward(x1), CallbackForward(x2), + CallbackForward(x3), CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6)); + } +}; + +// Arity 7 -> 7. +template +struct Invoker<0, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X1, X2, X3, X4, X5, X6, X7); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x1, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType x7) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename CallbackParamTraits::ForwardType x1, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType + x7)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6), CallbackForward(x7)); + } +}; + +// Arity 7 -> 6. +template +struct Invoker<1, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X2, X3, X4, X5, X6, X7); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType x7) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType + x7)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6), CallbackForward(x7)); + } +}; + +// Arity 7 -> 5. +template +struct Invoker<2, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X3, X4, X5, X6, X7); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType x7) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType + x7)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6), CallbackForward(x7)); + } +}; + +// Arity 7 -> 4. +template +struct Invoker<3, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X4, X5, X6, X7); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType x7) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + typename Bound3UnwrapTraits::ForwardType x3 = + Bound3UnwrapTraits::Unwrap(storage->p3_); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename Bound3UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType + x7)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6), CallbackForward(x7)); + } +}; + +// Arity 7 -> 3. +template +struct Invoker<4, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X5, X6, X7); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType x7) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; + typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + typename Bound3UnwrapTraits::ForwardType x3 = + Bound3UnwrapTraits::Unwrap(storage->p3_); + typename Bound4UnwrapTraits::ForwardType x4 = + Bound4UnwrapTraits::Unwrap(storage->p4_); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename Bound3UnwrapTraits::ForwardType, + typename Bound4UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType + x7)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6), CallbackForward(x7)); + } +}; + +// Arity 7 -> 2. +template +struct Invoker<5, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X6, X7); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType x7) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; + typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; + typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + typename Bound3UnwrapTraits::ForwardType x3 = + Bound3UnwrapTraits::Unwrap(storage->p3_); + typename Bound4UnwrapTraits::ForwardType x4 = + Bound4UnwrapTraits::Unwrap(storage->p4_); + typename Bound5UnwrapTraits::ForwardType x5 = + Bound5UnwrapTraits::Unwrap(storage->p5_); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename Bound3UnwrapTraits::ForwardType, + typename Bound4UnwrapTraits::ForwardType, + typename Bound5UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType + x7)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6), CallbackForward(x7)); + } +}; + +// Arity 7 -> 1. +template +struct Invoker<6, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X7); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x7) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; + typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; + typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits; + typedef typename StorageType::Bound6UnwrapTraits Bound6UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + typename Bound3UnwrapTraits::ForwardType x3 = + Bound3UnwrapTraits::Unwrap(storage->p3_); + typename Bound4UnwrapTraits::ForwardType x4 = + Bound4UnwrapTraits::Unwrap(storage->p4_); + typename Bound5UnwrapTraits::ForwardType x5 = + Bound5UnwrapTraits::Unwrap(storage->p5_); + typename Bound6UnwrapTraits::ForwardType x6 = + Bound6UnwrapTraits::Unwrap(storage->p6_); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename Bound3UnwrapTraits::ForwardType, + typename Bound4UnwrapTraits::ForwardType, + typename Bound5UnwrapTraits::ForwardType, + typename Bound6UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType + x7)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6), CallbackForward(x7)); + } +}; + +// Arity 7 -> 0. +template +struct Invoker<7, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { + typedef R(RunType)(BindStateBase*); + + typedef R(UnboundRunType)(); + + static R Run(BindStateBase* base) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; + typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; + typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits; + typedef typename StorageType::Bound6UnwrapTraits Bound6UnwrapTraits; + typedef typename StorageType::Bound7UnwrapTraits Bound7UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + typename Bound3UnwrapTraits::ForwardType x3 = + Bound3UnwrapTraits::Unwrap(storage->p3_); + typename Bound4UnwrapTraits::ForwardType x4 = + Bound4UnwrapTraits::Unwrap(storage->p4_); + typename Bound5UnwrapTraits::ForwardType x5 = + Bound5UnwrapTraits::Unwrap(storage->p5_); + typename Bound6UnwrapTraits::ForwardType x6 = + Bound6UnwrapTraits::Unwrap(storage->p6_); + typename Bound7UnwrapTraits::ForwardType x7 = + Bound7UnwrapTraits::Unwrap(storage->p7_); + return InvokeHelper:: + MakeItSo(storage->runnable_, CallbackForward(x1), CallbackForward(x2), + CallbackForward(x3), CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6), CallbackForward(x7)); + } +}; + +// BindState<> +// +// This stores all the state passed into Bind() and is also where most +// of the template resolution magic occurs. +// +// Runnable is the functor we are binding arguments to. +// RunType is type of the Run() function that the Invoker<> should use. +// Normally, this is the same as the RunType of the Runnable, but it can +// be different if an adapter like IgnoreResult() has been used. +// +// BoundArgsType contains the storage type for all the bound arguments by +// (ab)using a function type. +template +struct BindState; + +template +struct BindState : public BindStateBase { + typedef Runnable RunnableType; + typedef false_type IsWeakCall; + typedef Invoker<0, BindState, RunType> InvokerType; + typedef typename InvokerType::UnboundRunType UnboundRunType; + explicit BindState(const Runnable& runnable) + : BindStateBase(&Destroy), runnable_(runnable) {} + + ~BindState() {} + + static void Destroy(BindStateBase* self) { + delete static_cast(self); + } + + RunnableType runnable_; +}; + +template +struct BindState : public BindStateBase { + typedef Runnable RunnableType; + typedef IsWeakMethod::value, P1> IsWeakCall; + typedef Invoker<1, BindState, RunType> InvokerType; + typedef typename InvokerType::UnboundRunType UnboundRunType; + + // Convenience typedefs for bound argument types. + typedef UnwrapTraits Bound1UnwrapTraits; + + BindState(const Runnable& runnable, const P1& p1) + : BindStateBase(&Destroy), runnable_(runnable), p1_(p1) { + MaybeRefcount::value, P1>::AddRef(p1_); + } + + ~BindState() { + MaybeRefcount::value, P1>::Release(p1_); + } + + static void Destroy(BindStateBase* self) { + delete static_cast(self); + } + + RunnableType runnable_; + P1 p1_; +}; + +template +struct BindState : public BindStateBase { + typedef Runnable RunnableType; + typedef IsWeakMethod::value, P1> IsWeakCall; + typedef Invoker<2, BindState, RunType> InvokerType; + typedef typename InvokerType::UnboundRunType UnboundRunType; + + // Convenience typedefs for bound argument types. + typedef UnwrapTraits Bound1UnwrapTraits; + typedef UnwrapTraits Bound2UnwrapTraits; + + BindState(const Runnable& runnable, const P1& p1, const P2& p2) + : BindStateBase(&Destroy), runnable_(runnable), p1_(p1), p2_(p2) { + MaybeRefcount::value, P1>::AddRef(p1_); + } + + ~BindState() { + MaybeRefcount::value, P1>::Release(p1_); + } + + static void Destroy(BindStateBase* self) { + delete static_cast(self); + } + + RunnableType runnable_; + P1 p1_; + P2 p2_; +}; + +template +struct BindState : public BindStateBase { + typedef Runnable RunnableType; + typedef IsWeakMethod::value, P1> IsWeakCall; + typedef Invoker<3, BindState, RunType> InvokerType; + typedef typename InvokerType::UnboundRunType UnboundRunType; + + // Convenience typedefs for bound argument types. + typedef UnwrapTraits Bound1UnwrapTraits; + typedef UnwrapTraits Bound2UnwrapTraits; + typedef UnwrapTraits Bound3UnwrapTraits; + + BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3) + : BindStateBase(&Destroy), + runnable_(runnable), + p1_(p1), + p2_(p2), + p3_(p3) { + MaybeRefcount::value, P1>::AddRef(p1_); + } + + ~BindState() { + MaybeRefcount::value, P1>::Release(p1_); + } + + static void Destroy(BindStateBase* self) { + delete static_cast(self); + } + + RunnableType runnable_; + P1 p1_; + P2 p2_; + P3 p3_; +}; + +template +struct BindState + : public BindStateBase { + typedef Runnable RunnableType; + typedef IsWeakMethod::value, P1> IsWeakCall; + typedef Invoker<4, BindState, RunType> InvokerType; + typedef typename InvokerType::UnboundRunType UnboundRunType; + + // Convenience typedefs for bound argument types. + typedef UnwrapTraits Bound1UnwrapTraits; + typedef UnwrapTraits Bound2UnwrapTraits; + typedef UnwrapTraits Bound3UnwrapTraits; + typedef UnwrapTraits Bound4UnwrapTraits; + + BindState(const Runnable& runnable, + const P1& p1, + const P2& p2, + const P3& p3, + const P4& p4) + : BindStateBase(&Destroy), + runnable_(runnable), + p1_(p1), + p2_(p2), + p3_(p3), + p4_(p4) { + MaybeRefcount::value, P1>::AddRef(p1_); + } + + ~BindState() { + MaybeRefcount::value, P1>::Release(p1_); + } + + static void Destroy(BindStateBase* self) { + delete static_cast(self); + } + + RunnableType runnable_; + P1 p1_; + P2 p2_; + P3 p3_; + P4 p4_; +}; + +template +struct BindState + : public BindStateBase { + typedef Runnable RunnableType; + typedef IsWeakMethod::value, P1> IsWeakCall; + typedef Invoker<5, BindState, RunType> InvokerType; + typedef typename InvokerType::UnboundRunType UnboundRunType; + + // Convenience typedefs for bound argument types. + typedef UnwrapTraits Bound1UnwrapTraits; + typedef UnwrapTraits Bound2UnwrapTraits; + typedef UnwrapTraits Bound3UnwrapTraits; + typedef UnwrapTraits Bound4UnwrapTraits; + typedef UnwrapTraits Bound5UnwrapTraits; + + BindState(const Runnable& runnable, + const P1& p1, + const P2& p2, + const P3& p3, + const P4& p4, + const P5& p5) + : BindStateBase(&Destroy), + runnable_(runnable), + p1_(p1), + p2_(p2), + p3_(p3), + p4_(p4), + p5_(p5) { + MaybeRefcount::value, P1>::AddRef(p1_); + } + + ~BindState() { + MaybeRefcount::value, P1>::Release(p1_); + } + + static void Destroy(BindStateBase* self) { + delete static_cast(self); + } + + RunnableType runnable_; + P1 p1_; + P2 p2_; + P3 p3_; + P4 p4_; + P5 p5_; +}; + +template +struct BindState + : public BindStateBase { + typedef Runnable RunnableType; + typedef IsWeakMethod::value, P1> IsWeakCall; + typedef Invoker<6, BindState, RunType> InvokerType; + typedef typename InvokerType::UnboundRunType UnboundRunType; + + // Convenience typedefs for bound argument types. + typedef UnwrapTraits Bound1UnwrapTraits; + typedef UnwrapTraits Bound2UnwrapTraits; + typedef UnwrapTraits Bound3UnwrapTraits; + typedef UnwrapTraits Bound4UnwrapTraits; + typedef UnwrapTraits Bound5UnwrapTraits; + typedef UnwrapTraits Bound6UnwrapTraits; + + BindState(const Runnable& runnable, + const P1& p1, + const P2& p2, + const P3& p3, + const P4& p4, + const P5& p5, + const P6& p6) + : BindStateBase(&Destroy), + runnable_(runnable), + p1_(p1), + p2_(p2), + p3_(p3), + p4_(p4), + p5_(p5), + p6_(p6) { + MaybeRefcount::value, P1>::AddRef(p1_); + } + + ~BindState() { + MaybeRefcount::value, P1>::Release(p1_); + } + + static void Destroy(BindStateBase* self) { + delete static_cast(self); + } + + RunnableType runnable_; + P1 p1_; + P2 p2_; + P3 p3_; + P4 p4_; + P5 p5_; + P6 p6_; +}; + +template +struct BindState + : public BindStateBase { + typedef Runnable RunnableType; + typedef IsWeakMethod::value, P1> IsWeakCall; + typedef Invoker<7, BindState, RunType> InvokerType; + typedef typename InvokerType::UnboundRunType UnboundRunType; + + // Convenience typedefs for bound argument types. + typedef UnwrapTraits Bound1UnwrapTraits; + typedef UnwrapTraits Bound2UnwrapTraits; + typedef UnwrapTraits Bound3UnwrapTraits; + typedef UnwrapTraits Bound4UnwrapTraits; + typedef UnwrapTraits Bound5UnwrapTraits; + typedef UnwrapTraits Bound6UnwrapTraits; + typedef UnwrapTraits Bound7UnwrapTraits; + + BindState(const Runnable& runnable, + const P1& p1, + const P2& p2, + const P3& p3, + const P4& p4, + const P5& p5, + const P6& p6, + const P7& p7) + : BindStateBase(&Destroy), + runnable_(runnable), + p1_(p1), + p2_(p2), + p3_(p3), + p4_(p4), + p5_(p5), + p6_(p6), + p7_(p7) { + MaybeRefcount::value, P1>::AddRef(p1_); + } + + ~BindState() { + MaybeRefcount::value, P1>::Release(p1_); + } + + static void Destroy(BindStateBase* self) { + delete static_cast(self); + } + + RunnableType runnable_; + P1 p1_; + P2 p2_; + P3 p3_; + P4 p4_; + P5 p5_; + P6 p6_; + P7 p7_; +}; + +} // namespace cef_internal +} // namespace base + +#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_BIND_INTERNAL_H_ diff --git a/include/base/internal/cef_bind_internal_win.h b/include/base/internal/cef_bind_internal_win.h new file mode 100644 index 0000000..4a363de --- /dev/null +++ b/include/base/internal/cef_bind_internal_win.h @@ -0,0 +1,396 @@ +// Copyright (c) 2011 Google Inc. 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. + +// Do not include this header file directly. Use base/cef_bind.h instead. + +// Specializations of RunnableAdapter<> for Windows specific calling +// conventions. Please see base/bind_internal.h for more info. + +#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_BIND_INTERNAL_WIN_H_ +#define CEF_INCLUDE_BASE_INTERNAL_CEF_BIND_INTERNAL_WIN_H_ + +// In the x64 architecture in Windows, __fastcall, __stdcall, etc, are all +// the same as __cdecl which would turn the following specializations into +// multiple definitions. +#if !defined(ARCH_CPU_X86_64) + +namespace base { +namespace cef_internal { + +template +class RunnableAdapter; + +// __stdcall Function: Arity 0. +template +class RunnableAdapter { + public: + typedef R(RunType)(); + + explicit RunnableAdapter(R(__stdcall* function)()) : function_(function) {} + + R Run() { return function_(); } + + private: + R(__stdcall* function_)(); +}; + +// __fastcall Function: Arity 0. +template +class RunnableAdapter { + public: + typedef R(RunType)(); + + explicit RunnableAdapter(R(__fastcall* function)()) : function_(function) {} + + R Run() { return function_(); } + + private: + R(__fastcall* function_)(); +}; + +// __stdcall Function: Arity 1. +template +class RunnableAdapter { + public: + typedef R(RunType)(A1); + + explicit RunnableAdapter(R(__stdcall* function)(A1)) : function_(function) {} + + R Run(typename CallbackParamTraits::ForwardType a1) { + return function_(a1); + } + + private: + R(__stdcall* function_)(A1); +}; + +// __fastcall Function: Arity 1. +template +class RunnableAdapter { + public: + typedef R(RunType)(A1); + + explicit RunnableAdapter(R(__fastcall* function)(A1)) : function_(function) {} + + R Run(typename CallbackParamTraits::ForwardType a1) { + return function_(a1); + } + + private: + R(__fastcall* function_)(A1); +}; + +// __stdcall Function: Arity 2. +template +class RunnableAdapter { + public: + typedef R(RunType)(A1, A2); + + explicit RunnableAdapter(R(__stdcall* function)(A1, A2)) + : function_(function) {} + + R Run(typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2) { + return function_(a1, a2); + } + + private: + R(__stdcall* function_)(A1, A2); +}; + +// __fastcall Function: Arity 2. +template +class RunnableAdapter { + public: + typedef R(RunType)(A1, A2); + + explicit RunnableAdapter(R(__fastcall* function)(A1, A2)) + : function_(function) {} + + R Run(typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2) { + return function_(a1, a2); + } + + private: + R(__fastcall* function_)(A1, A2); +}; + +// __stdcall Function: Arity 3. +template +class RunnableAdapter { + public: + typedef R(RunType)(A1, A2, A3); + + explicit RunnableAdapter(R(__stdcall* function)(A1, A2, A3)) + : function_(function) {} + + R Run(typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3) { + return function_(a1, a2, a3); + } + + private: + R(__stdcall* function_)(A1, A2, A3); +}; + +// __fastcall Function: Arity 3. +template +class RunnableAdapter { + public: + typedef R(RunType)(A1, A2, A3); + + explicit RunnableAdapter(R(__fastcall* function)(A1, A2, A3)) + : function_(function) {} + + R Run(typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3) { + return function_(a1, a2, a3); + } + + private: + R(__fastcall* function_)(A1, A2, A3); +}; + +// __stdcall Function: Arity 4. +template +class RunnableAdapter { + public: + typedef R(RunType)(A1, A2, A3, A4); + + explicit RunnableAdapter(R(__stdcall* function)(A1, A2, A3, A4)) + : function_(function) {} + + R Run(typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4) { + return function_(a1, a2, a3, a4); + } + + private: + R(__stdcall* function_)(A1, A2, A3, A4); +}; + +// __fastcall Function: Arity 4. +template +class RunnableAdapter { + public: + typedef R(RunType)(A1, A2, A3, A4); + + explicit RunnableAdapter(R(__fastcall* function)(A1, A2, A3, A4)) + : function_(function) {} + + R Run(typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4) { + return function_(a1, a2, a3, a4); + } + + private: + R(__fastcall* function_)(A1, A2, A3, A4); +}; + +// __stdcall Function: Arity 5. +template +class RunnableAdapter { + public: + typedef R(RunType)(A1, A2, A3, A4, A5); + + explicit RunnableAdapter(R(__stdcall* function)(A1, A2, A3, A4, A5)) + : function_(function) {} + + R Run(typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5) { + return function_(a1, a2, a3, a4, a5); + } + + private: + R(__stdcall* function_)(A1, A2, A3, A4, A5); +}; + +// __fastcall Function: Arity 5. +template +class RunnableAdapter { + public: + typedef R(RunType)(A1, A2, A3, A4, A5); + + explicit RunnableAdapter(R(__fastcall* function)(A1, A2, A3, A4, A5)) + : function_(function) {} + + R Run(typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5) { + return function_(a1, a2, a3, a4, a5); + } + + private: + R(__fastcall* function_)(A1, A2, A3, A4, A5); +}; + +// __stdcall Function: Arity 6. +template +class RunnableAdapter { + public: + typedef R(RunType)(A1, A2, A3, A4, A5, A6); + + explicit RunnableAdapter(R(__stdcall* function)(A1, A2, A3, A4, A5, A6)) + : function_(function) {} + + R Run(typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5, + typename CallbackParamTraits::ForwardType a6) { + return function_(a1, a2, a3, a4, a5, a6); + } + + private: + R(__stdcall* function_)(A1, A2, A3, A4, A5, A6); +}; + +// __fastcall Function: Arity 6. +template +class RunnableAdapter { + public: + typedef R(RunType)(A1, A2, A3, A4, A5, A6); + + explicit RunnableAdapter(R(__fastcall* function)(A1, A2, A3, A4, A5, A6)) + : function_(function) {} + + R Run(typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5, + typename CallbackParamTraits::ForwardType a6) { + return function_(a1, a2, a3, a4, a5, a6); + } + + private: + R(__fastcall* function_)(A1, A2, A3, A4, A5, A6); +}; + +// __stdcall Function: Arity 7. +template +class RunnableAdapter { + public: + typedef R(RunType)(A1, A2, A3, A4, A5, A6, A7); + + explicit RunnableAdapter(R(__stdcall* function)(A1, A2, A3, A4, A5, A6, A7)) + : function_(function) {} + + R Run(typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5, + typename CallbackParamTraits::ForwardType a6, + typename CallbackParamTraits::ForwardType a7) { + return function_(a1, a2, a3, a4, a5, a6, a7); + } + + private: + R(__stdcall* function_)(A1, A2, A3, A4, A5, A6, A7); +}; + +// __fastcall Function: Arity 7. +template +class RunnableAdapter { + public: + typedef R(RunType)(A1, A2, A3, A4, A5, A6, A7); + + explicit RunnableAdapter(R(__fastcall* function)(A1, A2, A3, A4, A5, A6, A7)) + : function_(function) {} + + R Run(typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5, + typename CallbackParamTraits::ForwardType a6, + typename CallbackParamTraits::ForwardType a7) { + return function_(a1, a2, a3, a4, a5, a6, a7); + } + + private: + R(__fastcall* function_)(A1, A2, A3, A4, A5, A6, A7); +}; + +} // namespace cef_internal +} // namespace base + +#endif // !defined(ARCH_CPU_X86_64) + +#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_BIND_INTERNAL_WIN_H_ diff --git a/include/base/internal/cef_callback_internal.h b/include/base/internal/cef_callback_internal.h new file mode 100644 index 0000000..1f2e16c --- /dev/null +++ b/include/base/internal/cef_callback_internal.h @@ -0,0 +1,224 @@ +// Copyright (c) 2012 Google Inc. 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. + +// Do not include this header file directly. Use base/cef_bind.h or +// base/cef_callback.h instead. + +// This file contains utility functions and classes that help the +// implementation, and management of the Callback objects. + +#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_CALLBACK_INTERNAL_H_ +#define CEF_INCLUDE_BASE_INTERNAL_CEF_CALLBACK_INTERNAL_H_ + +#include + +#include "include/base/cef_atomic_ref_count.h" +#include "include/base/cef_macros.h" +#include "include/base/cef_ref_counted.h" +#include "include/base/cef_scoped_ptr.h" +#include "include/base/cef_template_util.h" + +template +class ScopedVector; + +namespace base { +namespace cef_internal { +class CallbackBase; + +// At the base level, the only task is to add reference counting data. Don't use +// RefCountedThreadSafe since it requires the destructor to be a virtual method. +// Creating a vtable for every BindState template instantiation results in a lot +// of bloat. Its only task is to call the destructor which can be done with a +// function pointer. +class BindStateBase { + protected: + explicit BindStateBase(void (*destructor)(BindStateBase*)) + : ref_count_(0), destructor_(destructor) {} + ~BindStateBase() {} + + private: + friend class scoped_refptr; + friend class CallbackBase; + + void AddRef(); + void Release(); + + AtomicRefCount ref_count_; + + // Pointer to a function that will properly destroy |this|. + void (*destructor_)(BindStateBase*); + + DISALLOW_COPY_AND_ASSIGN(BindStateBase); +}; + +// Holds the Callback methods that don't require specialization to reduce +// template bloat. +class CallbackBase { + public: + // Returns true if Callback is null (doesn't refer to anything). + bool is_null() const { return bind_state_.get() == NULL; } + + // Returns the Callback into an uninitialized state. + void Reset(); + + protected: + // In C++, it is safe to cast function pointers to function pointers of + // another type. It is not okay to use void*. We create a InvokeFuncStorage + // that that can store our function pointer, and then cast it back to + // the original type on usage. + typedef void (*InvokeFuncStorage)(void); + + // Returns true if this callback equals |other|. |other| may be null. + bool Equals(const CallbackBase& other) const; + + // Allow initializing of |bind_state_| via the constructor to avoid default + // initialization of the scoped_refptr. We do not also initialize + // |polymorphic_invoke_| here because doing a normal assignment in the + // derived Callback templates makes for much nicer compiler errors. + explicit CallbackBase(BindStateBase* bind_state); + + // Force the destructor to be instantiated inside this translation unit so + // that our subclasses will not get inlined versions. Avoids more template + // bloat. + ~CallbackBase(); + + scoped_refptr bind_state_; + InvokeFuncStorage polymorphic_invoke_; +}; + +// A helper template to determine if given type is non-const move-only-type, +// i.e. if a value of the given type should be passed via .Pass() in a +// destructive way. +template +struct IsMoveOnlyType { + template + static YesType Test(const typename U::MoveOnlyTypeForCPP03*); + + template + static NoType Test(...); + + static const bool value = + sizeof(Test(0)) == sizeof(YesType) && !is_const::value; +}; + +// This is a typetraits object that's used to take an argument type, and +// extract a suitable type for storing and forwarding arguments. +// +// In particular, it strips off references, and converts arrays to +// pointers for storage; and it avoids accidentally trying to create a +// "reference of a reference" if the argument is a reference type. +// +// This array type becomes an issue for storage because we are passing bound +// parameters by const reference. In this case, we end up passing an actual +// array type in the initializer list which C++ does not allow. This will +// break passing of C-string literals. +template ::value> +struct CallbackParamTraits { + typedef const T& ForwardType; + typedef T StorageType; +}; + +// The Storage should almost be impossible to trigger unless someone manually +// specifies type of the bind parameters. However, in case they do, +// this will guard against us accidentally storing a reference parameter. +// +// The ForwardType should only be used for unbound arguments. +template +struct CallbackParamTraits { + typedef T& ForwardType; + typedef T StorageType; +}; + +// Note that for array types, we implicitly add a const in the conversion. This +// means that it is not possible to bind array arguments to functions that take +// a non-const pointer. Trying to specialize the template based on a "const +// T[n]" does not seem to match correctly, so we are stuck with this +// restriction. +template +struct CallbackParamTraits { + typedef const T* ForwardType; + typedef const T* StorageType; +}; + +// See comment for CallbackParamTraits. +template +struct CallbackParamTraits { + typedef const T* ForwardType; + typedef const T* StorageType; +}; + +// Parameter traits for movable-but-not-copyable scopers. +// +// Callback<>/Bind() understands movable-but-not-copyable semantics where +// the type cannot be copied but can still have its state destructively +// transferred (aka. moved) to another instance of the same type by calling a +// helper function. When used with Bind(), this signifies transferal of the +// object's state to the target function. +// +// For these types, the ForwardType must not be a const reference, or a +// reference. A const reference is inappropriate, and would break const +// correctness, because we are implementing a destructive move. A non-const +// reference cannot be used with temporaries which means the result of a +// function or a cast would not be usable with Callback<> or Bind(). +template +struct CallbackParamTraits { + typedef T ForwardType; + typedef T StorageType; +}; + +// CallbackForward() is a very limited simulation of C++11's std::forward() +// used by the Callback/Bind system for a set of movable-but-not-copyable +// types. It is needed because forwarding a movable-but-not-copyable +// argument to another function requires us to invoke the proper move +// operator to create a rvalue version of the type. The supported types are +// whitelisted below as overloads of the CallbackForward() function. The +// default template compiles out to be a no-op. +// +// In C++11, std::forward would replace all uses of this function. However, it +// is impossible to implement a general std::forward with C++11 due to a lack +// of rvalue references. +// +// In addition to Callback/Bind, this is used by PostTaskAndReplyWithResult to +// simulate std::forward() and forward the result of one Callback as a +// parameter to another callback. This is to support Callbacks that return +// the movable-but-not-copyable types whitelisted above. +template +typename enable_if::value, T>::type& CallbackForward(T& t) { + return t; +} + +template +typename enable_if::value, T>::type CallbackForward(T& t) { + return t.Pass(); +} + +} // namespace cef_internal +} // namespace base + +#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_CALLBACK_INTERNAL_H_ diff --git a/include/base/internal/cef_lock_impl.h b/include/base/internal/cef_lock_impl.h new file mode 100644 index 0000000..470547f --- /dev/null +++ b/include/base/internal/cef_lock_impl.h @@ -0,0 +1,87 @@ +// Copyright (c) 2011 Google Inc. 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. + +// Do not include this header file directly. Use base/cef_lock.h instead. + +#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_LOCK_IMPL_H_ +#define CEF_INCLUDE_BASE_INTERNAL_CEF_LOCK_IMPL_H_ + +#include "include/base/cef_build.h" + +#if defined(OS_WIN) +#include +#elif defined(OS_POSIX) +#include +#endif + +#include "include/base/cef_macros.h" + +namespace base { +namespace cef_internal { + +// This class implements the underlying platform-specific spin-lock mechanism +// used for the Lock class. Most users should not use LockImpl directly, but +// should instead use Lock. +class LockImpl { + public: +#if defined(OS_WIN) + typedef CRITICAL_SECTION NativeHandle; +#elif defined(OS_POSIX) + typedef pthread_mutex_t NativeHandle; +#endif + + LockImpl(); + ~LockImpl(); + + // If the lock is not held, take it and return true. If the lock is already + // held by something else, immediately return false. + bool Try(); + + // Take the lock, blocking until it is available if necessary. + void Lock(); + + // Release the lock. This must only be called by the lock's holder: after + // a successful call to Try, or a call to Lock. + void Unlock(); + + // Return the native underlying lock. + // TODO(awalker): refactor lock and condition variables so that this is + // unnecessary. + NativeHandle* native_handle() { return &native_handle_; } + + private: + NativeHandle native_handle_; + + DISALLOW_COPY_AND_ASSIGN(LockImpl); +}; + +} // namespace cef_internal +} // namespace base + +#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_LOCK_IMPL_H_ diff --git a/include/base/internal/cef_raw_scoped_refptr_mismatch_checker.h b/include/base/internal/cef_raw_scoped_refptr_mismatch_checker.h new file mode 100644 index 0000000..9f2f932 --- /dev/null +++ b/include/base/internal/cef_raw_scoped_refptr_mismatch_checker.h @@ -0,0 +1,181 @@ +// Copyright (c) 2011 Google Inc. 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. + +// Do not include this header file directly. Use base/cef_callback.h instead. + +#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_RAW_SCOPED_REFPTR_MISMATCH_CHECKER_H_ +#define CEF_INCLUDE_BASE_INTERNAL_CEF_RAW_SCOPED_REFPTR_MISMATCH_CHECKER_H_ + +#include "include/base/cef_build.h" +#include "include/base/cef_ref_counted.h" +#include "include/base/cef_template_util.h" +#include "include/base/cef_tuple.h" + +// It is dangerous to post a task with a T* argument where T is a subtype of +// RefCounted(Base|ThreadSafeBase), since by the time the parameter is used, the +// object may already have been deleted since it was not held with a +// scoped_refptr. Example: http://crbug.com/27191 +// The following set of traits are designed to generate a compile error +// whenever this antipattern is attempted. + +namespace base { + +namespace cef_internal { + +template +struct NeedsScopedRefptrButGetsRawPtr { +#if defined(OS_WIN) + enum { value = base::false_type::value }; +#else + enum { + // Human readable translation: you needed to be a scoped_refptr if you are a + // raw pointer type and are convertible to a RefCounted(Base|ThreadSafeBase) + // type. + value = (is_pointer::value && + (is_convertible::value || + is_convertible::value)) + }; +#endif +}; + +template +struct ParamsUseScopedRefptrCorrectly { + enum { value = 0 }; +}; + +template <> +struct ParamsUseScopedRefptrCorrectly { + enum { value = 1 }; +}; + +template +struct ParamsUseScopedRefptrCorrectly> { + enum { value = !NeedsScopedRefptrButGetsRawPtr::value }; +}; + +template +struct ParamsUseScopedRefptrCorrectly> { + enum { + value = !(NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value) + }; +}; + +template +struct ParamsUseScopedRefptrCorrectly> { + enum { + value = !(NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value) + }; +}; + +template +struct ParamsUseScopedRefptrCorrectly> { + enum { + value = !(NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value) + }; +}; + +template +struct ParamsUseScopedRefptrCorrectly> { + enum { + value = !(NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value) + }; +}; + +template +struct ParamsUseScopedRefptrCorrectly> { + enum { + value = !(NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value) + }; +}; + +template +struct ParamsUseScopedRefptrCorrectly> { + enum { + value = !(NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value) + }; +}; + +template +struct ParamsUseScopedRefptrCorrectly> { + enum { + value = !(NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value) + }; +}; + +} // namespace cef_internal + +} // namespace base + +#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_RAW_SCOPED_REFPTR_MISMATCH_CHECKER_H_ diff --git a/include/base/internal/cef_thread_checker_impl.h b/include/base/internal/cef_thread_checker_impl.h new file mode 100644 index 0000000..2654698 --- /dev/null +++ b/include/base/internal/cef_thread_checker_impl.h @@ -0,0 +1,72 @@ +// Copyright (c) 2011 Google Inc. 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. + +// Do not include this header file directly. Use base/cef_thread_checker.h +// instead. + +#ifndef CEF_INCLUDE_BASE_INTERNAL_THREAD_CHECKER_IMPL_H_ +#define CEF_INCLUDE_BASE_INTERNAL_THREAD_CHECKER_IMPL_H_ + +#include "include/base/cef_lock.h" +#include "include/base/cef_platform_thread.h" + +namespace base { +namespace cef_internal { + +// Real implementation of ThreadChecker, for use in debug mode, or +// for temporary use in release mode (e.g. to CHECK on a threading issue +// seen only in the wild). +// +// Note: You should almost always use the ThreadChecker class to get the +// right version for your build configuration. +class ThreadCheckerImpl { + public: + ThreadCheckerImpl(); + ~ThreadCheckerImpl(); + + bool CalledOnValidThread() const; + + // Changes the thread that is checked for in CalledOnValidThread. This may + // be useful when an object may be created on one thread and then used + // exclusively on another thread. + void DetachFromThread(); + + private: + void EnsureThreadIdAssigned() const; + + mutable base::Lock lock_; + // This is mutable so that CalledOnValidThread can set it. + // It's guarded by |lock_|. + mutable PlatformThreadRef valid_thread_id_; +}; + +} // namespace cef_internal +} // namespace base + +#endif // CEF_INCLUDE_BASE_INTERNAL_THREAD_CHECKER_IMPL_H_ diff --git a/include/capi/cef_accessibility_handler_capi.h b/include/capi/cef_accessibility_handler_capi.h new file mode 100644 index 0000000..af3f356 --- /dev/null +++ b/include/capi/cef_accessibility_handler_capi.h @@ -0,0 +1,81 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=ade29136d75b33f63cf65db4b91de9cd66114562$ +// + +#ifndef CEF_INCLUDE_CAPI_CEF_ACCESSIBILITY_HANDLER_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_ACCESSIBILITY_HANDLER_CAPI_H_ +#pragma once + +#include "include/capi/cef_values_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// Implement this structure to receive accessibility notification when +// accessibility events have been registered. The functions of this structure +// will be called on the UI thread. +/// +typedef struct _cef_accessibility_handler_t { + /// + // Base structure. + /// + cef_base_ref_counted_t base; + + /// + // Called after renderer process sends accessibility tree changes to the + // browser process. + /// + void(CEF_CALLBACK* on_accessibility_tree_change)( + struct _cef_accessibility_handler_t* self, + struct _cef_value_t* value); + + /// + // Called after renderer process sends accessibility location changes to the + // browser process. + /// + void(CEF_CALLBACK* on_accessibility_location_change)( + struct _cef_accessibility_handler_t* self, + struct _cef_value_t* value); +} cef_accessibility_handler_t; + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_ACCESSIBILITY_HANDLER_CAPI_H_ diff --git a/include/capi/cef_app_capi.h b/include/capi/cef_app_capi.h index 8fdb16a..d5221c2 100644 --- a/include/capi/cef_app_capi.h +++ b/include/capi/cef_app_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,15 +33,13 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=52ce63b881a6e3d2d13a39b81ad2626f366fc130$ +// #ifndef CEF_INCLUDE_CAPI_CEF_APP_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_APP_CAPI_H_ #pragma once -#ifdef __cplusplus -extern "C" { -#endif - #include "include/capi/cef_base_capi.h" #include "include/capi/cef_browser_process_handler_capi.h" #include "include/capi/cef_command_line_capi.h" @@ -49,6 +47,10 @@ extern "C" { #include "include/capi/cef_resource_bundle_handler_capi.h" #include "include/capi/cef_scheme_capi.h" +#ifdef __cplusplus +extern "C" { +#endif + struct _cef_app_t; /// @@ -59,7 +61,7 @@ typedef struct _cef_app_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Provides an opportunity to view and/or modify command-line arguments before @@ -72,8 +74,9 @@ typedef struct _cef_app_t { // modify command-line arguments for non-browser processes as this may result // in undefined behavior including crashes. /// - void (CEF_CALLBACK *on_before_command_line_processing)( - struct _cef_app_t* self, const cef_string_t* process_type, + void(CEF_CALLBACK* on_before_command_line_processing)( + struct _cef_app_t* self, + const cef_string_t* process_type, struct _cef_command_line_t* command_line); /// @@ -82,7 +85,8 @@ typedef struct _cef_app_t { // each process and the registered schemes should be the same across all // processes. /// - void (CEF_CALLBACK *on_register_custom_schemes)(struct _cef_app_t* self, + void(CEF_CALLBACK* on_register_custom_schemes)( + struct _cef_app_t* self, struct _cef_scheme_registrar_t* registrar); /// @@ -91,25 +95,24 @@ typedef struct _cef_app_t { // If no handler is returned resources will be loaded from pack files. This // function is called by the browser and render processes on multiple threads. /// - struct _cef_resource_bundle_handler_t* ( - CEF_CALLBACK *get_resource_bundle_handler)(struct _cef_app_t* self); + struct _cef_resource_bundle_handler_t*( + CEF_CALLBACK* get_resource_bundle_handler)(struct _cef_app_t* self); /// // Return the handler for functionality specific to the browser process. This // function is called on multiple threads in the browser process. /// - struct _cef_browser_process_handler_t* ( - CEF_CALLBACK *get_browser_process_handler)(struct _cef_app_t* self); + struct _cef_browser_process_handler_t*( + CEF_CALLBACK* get_browser_process_handler)(struct _cef_app_t* self); /// // Return the handler for functionality specific to the render process. This // function is called on the render process main thread. /// - struct _cef_render_process_handler_t* ( - CEF_CALLBACK *get_render_process_handler)(struct _cef_app_t* self); + struct _cef_render_process_handler_t*( + CEF_CALLBACK* get_render_process_handler)(struct _cef_app_t* self); } cef_app_t; - /// // This function should be called from the application entry point function to // execute a secondary process. It can be used to run secondary processes from @@ -123,7 +126,8 @@ typedef struct _cef_app_t { // cef_sandbox_win.h for details). /// CEF_EXPORT int cef_execute_process(const struct _cef_main_args_t* args, - cef_app_t* application, void* windows_sandbox_info); + cef_app_t* application, + void* windows_sandbox_info); /// // This function should be called on the main application thread to initialize @@ -133,8 +137,9 @@ CEF_EXPORT int cef_execute_process(const struct _cef_main_args_t* args, // be NULL (see cef_sandbox_win.h for details). /// CEF_EXPORT int cef_initialize(const struct _cef_main_args_t* args, - const struct _cef_settings_t* settings, cef_app_t* application, - void* windows_sandbox_info); + const struct _cef_settings_t* settings, + cef_app_t* application, + void* windows_sandbox_info); /// // This function should be called on the main application thread to shut down @@ -144,11 +149,18 @@ CEF_EXPORT void cef_shutdown(); /// // Perform a single iteration of CEF message loop processing. This function is -// used to integrate the CEF message loop into an existing application message -// loop. Care must be taken to balance performance against excessive CPU usage. -// This function should only be called on the main application thread and only -// if cef_initialize() is called with a CefSettings.multi_threaded_message_loop -// value of false (0). This function will not block. +// provided for cases where the CEF message loop must be integrated into an +// existing application message loop. Use of this function is not recommended +// for most users; use either the cef_run_message_loop() function or +// CefSettings.multi_threaded_message_loop if possible. When using this function +// care must be taken to balance performance against excessive CPU usage. It is +// recommended to enable the CefSettings.external_message_pump option when using +// this function so that +// cef_browser_process_handler_t::on_schedule_message_pump_work() callbacks can +// facilitate the scheduling process. This function should only be called on the +// main application thread and only if cef_initialize() is called with a +// CefSettings.multi_threaded_message_loop value of false (0). This function +// will not block. /// CEF_EXPORT void cef_do_message_loop_work(); @@ -175,6 +187,13 @@ CEF_EXPORT void cef_quit_message_loop(); /// CEF_EXPORT void cef_set_osmodal_loop(int osModalLoop); +/// +// 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(); + #ifdef __cplusplus } #endif diff --git a/include/capi/cef_auth_callback_capi.h b/include/capi/cef_auth_callback_capi.h index d08c1e5..834a6c3 100644 --- a/include/capi/cef_auth_callback_capi.h +++ b/include/capi/cef_auth_callback_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,18 +33,19 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=639d58245ecd39624d39ee8b49e0e4e056d1c4ed$ +// #ifndef CEF_INCLUDE_CAPI_CEF_AUTH_CALLBACK_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_AUTH_CALLBACK_CAPI_H_ #pragma once +#include "include/capi/cef_base_capi.h" + #ifdef __cplusplus extern "C" { #endif -#include "include/capi/cef_base_capi.h" - - /// // Callback structure used for asynchronous continuation of authentication // requests. @@ -53,21 +54,21 @@ typedef struct _cef_auth_callback_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Continue the authentication request. /// - void (CEF_CALLBACK *cont)(struct _cef_auth_callback_t* self, - const cef_string_t* username, const cef_string_t* password); + void(CEF_CALLBACK* cont)(struct _cef_auth_callback_t* self, + const cef_string_t* username, + const cef_string_t* password); /// // Cancel the authentication request. /// - void (CEF_CALLBACK *cancel)(struct _cef_auth_callback_t* self); + void(CEF_CALLBACK* cancel)(struct _cef_auth_callback_t* self); } cef_auth_callback_t; - #ifdef __cplusplus } #endif diff --git a/include/capi/cef_base_capi.h b/include/capi/cef_base_capi.h index 0323520..9af617d 100644 --- a/include/capi/cef_base_capi.h +++ b/include/capi/cef_base_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 Marshall A. Greenblatt. All rights reserved. +// 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 @@ -27,13 +27,10 @@ // (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_CAPI_CEF_BASE_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_BASE_CAPI_H_ -#ifdef __cplusplus -extern "C" { -#endif +#include #include "include/internal/cef_export.h" #include "include/internal/cef_string.h" @@ -42,41 +39,61 @@ extern "C" { #include "include/internal/cef_string_multimap.h" #include "include/internal/cef_types.h" +#ifdef __cplusplus +extern "C" { +#endif + /// -// Structure defining the reference count implementation functions. All -// framework structures must include the cef_base_t structure first. +// All ref-counted framework structures must include this structure first. /// -typedef struct _cef_base_t { +typedef struct _cef_base_ref_counted_t { /// // Size of the data structure. /// size_t size; /// - // Increment the reference count. + // Called to increment the reference count for the object. Should be called + // for every new copy of a pointer to a given object. /// - int (CEF_CALLBACK *add_ref)(struct _cef_base_t* self); + void(CEF_CALLBACK* add_ref)(struct _cef_base_ref_counted_t* self); /// - // Decrement the reference count. Delete this object when no references - // remain. + // Called to decrement the reference count for the object. If the reference + // count falls to 0 the object should self-delete. Returns true (1) if the + // resulting reference count is 0. /// - int (CEF_CALLBACK *release)(struct _cef_base_t* self); + int(CEF_CALLBACK* release)(struct _cef_base_ref_counted_t* self); /// - // Returns the current number of references. + // Returns true (1) if the current reference count is 1. /// - int (CEF_CALLBACK *get_refct)(struct _cef_base_t* self); -} cef_base_t; + int(CEF_CALLBACK* has_one_ref)(struct _cef_base_ref_counted_t* self); +} cef_base_ref_counted_t; +/// +// All scoped framework structures must include this structure first. +/// +typedef struct _cef_base_scoped_t { + /// + // Size of the data structure. + /// + size_t size; + + /// + // Called to delete this object. May be NULL if the object is not owned. + /// + void(CEF_CALLBACK* del)(struct _cef_base_scoped_t* self); -// Check that the structure |s|, which is defined with a cef_base_t member named -// |base|, is large enough to contain the specified member |f|. -#define CEF_MEMBER_EXISTS(s, f) \ - ((intptr_t)&((s)->f) - (intptr_t)(s) + sizeof((s)->f) <= (s)->base.size) +} cef_base_scoped_t; -#define CEF_MEMBER_MISSING(s, f) (!CEF_MEMBER_EXISTS(s, f) || !((s)->f)) +// Check that the structure |s|, which is defined with a size_t member at the +// top, is large enough to contain the specified member |f|. +#define CEF_MEMBER_EXISTS(s, f) \ + ((intptr_t) & \ + ((s)->f) - (intptr_t)(s) + sizeof((s)->f) <= *reinterpret_cast(s)) +#define CEF_MEMBER_MISSING(s, f) (!CEF_MEMBER_EXISTS(s, f) || !((s)->f)) #ifdef __cplusplus } diff --git a/include/capi/cef_browser_capi.h b/include/capi/cef_browser_capi.h index d039903..3c830bc 100644 --- a/include/capi/cef_browser_capi.h +++ b/include/capi/cef_browser_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,20 +33,25 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=b6308ab5e97eb9f7af95f1f4c371fd6e7edbf852$ +// #ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_ #pragma once -#ifdef __cplusplus -extern "C" { -#endif - #include "include/capi/cef_base_capi.h" +#include "include/capi/cef_drag_data_capi.h" #include "include/capi/cef_frame_capi.h" +#include "include/capi/cef_image_capi.h" +#include "include/capi/cef_navigation_entry_capi.h" #include "include/capi/cef_process_message_capi.h" #include "include/capi/cef_request_context_capi.h" +#ifdef __cplusplus +extern "C" { +#endif + struct _cef_browser_host_t; struct _cef_client_t; @@ -60,128 +65,130 @@ typedef struct _cef_browser_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Returns the browser host object. This function can only be called in the // browser process. /// - struct _cef_browser_host_t* (CEF_CALLBACK *get_host)( + struct _cef_browser_host_t*(CEF_CALLBACK* get_host)( struct _cef_browser_t* self); /// // Returns true (1) if the browser can navigate backwards. /// - int (CEF_CALLBACK *can_go_back)(struct _cef_browser_t* self); + int(CEF_CALLBACK* can_go_back)(struct _cef_browser_t* self); /// // Navigate backwards. /// - void (CEF_CALLBACK *go_back)(struct _cef_browser_t* self); + void(CEF_CALLBACK* go_back)(struct _cef_browser_t* self); /// // Returns true (1) if the browser can navigate forwards. /// - int (CEF_CALLBACK *can_go_forward)(struct _cef_browser_t* self); + int(CEF_CALLBACK* can_go_forward)(struct _cef_browser_t* self); /// // Navigate forwards. /// - void (CEF_CALLBACK *go_forward)(struct _cef_browser_t* self); + void(CEF_CALLBACK* go_forward)(struct _cef_browser_t* self); /// // Returns true (1) if the browser is currently loading. /// - int (CEF_CALLBACK *is_loading)(struct _cef_browser_t* self); + int(CEF_CALLBACK* is_loading)(struct _cef_browser_t* self); /// // Reload the current page. /// - void (CEF_CALLBACK *reload)(struct _cef_browser_t* self); + void(CEF_CALLBACK* reload)(struct _cef_browser_t* self); /// // Reload the current page ignoring any cached data. /// - void (CEF_CALLBACK *reload_ignore_cache)(struct _cef_browser_t* self); + void(CEF_CALLBACK* reload_ignore_cache)(struct _cef_browser_t* self); /// // Stop loading the page. /// - void (CEF_CALLBACK *stop_load)(struct _cef_browser_t* self); + void(CEF_CALLBACK* stop_load)(struct _cef_browser_t* self); /// // Returns the globally unique identifier for this browser. /// - int (CEF_CALLBACK *get_identifier)(struct _cef_browser_t* self); + int(CEF_CALLBACK* get_identifier)(struct _cef_browser_t* self); /// // Returns true (1) if this object is pointing to the same handle as |that| // object. /// - int (CEF_CALLBACK *is_same)(struct _cef_browser_t* self, - struct _cef_browser_t* that); + int(CEF_CALLBACK* is_same)(struct _cef_browser_t* self, + struct _cef_browser_t* that); /// // Returns true (1) if the window is a popup window. /// - int (CEF_CALLBACK *is_popup)(struct _cef_browser_t* self); + int(CEF_CALLBACK* is_popup)(struct _cef_browser_t* self); /// // Returns true (1) if a document has been loaded in the browser. /// - int (CEF_CALLBACK *has_document)(struct _cef_browser_t* self); + int(CEF_CALLBACK* has_document)(struct _cef_browser_t* self); /// // Returns the main (top-level) frame for the browser window. /// - struct _cef_frame_t* (CEF_CALLBACK *get_main_frame)( + struct _cef_frame_t*(CEF_CALLBACK* get_main_frame)( struct _cef_browser_t* self); /// // Returns the focused frame for the browser window. /// - struct _cef_frame_t* (CEF_CALLBACK *get_focused_frame)( + struct _cef_frame_t*(CEF_CALLBACK* get_focused_frame)( struct _cef_browser_t* self); /// // Returns the frame with the specified identifier, or NULL if not found. /// - struct _cef_frame_t* (CEF_CALLBACK *get_frame_byident)( - struct _cef_browser_t* self, int64 identifier); + struct _cef_frame_t*(CEF_CALLBACK* get_frame_byident)( + struct _cef_browser_t* self, + int64 identifier); /// // Returns the frame with the specified name, or NULL if not found. /// - struct _cef_frame_t* (CEF_CALLBACK *get_frame)(struct _cef_browser_t* self, - const cef_string_t* name); + struct _cef_frame_t*(CEF_CALLBACK* get_frame)(struct _cef_browser_t* self, + const cef_string_t* name); /// // Returns the number of frames that currently exist. /// - size_t (CEF_CALLBACK *get_frame_count)(struct _cef_browser_t* self); + size_t(CEF_CALLBACK* get_frame_count)(struct _cef_browser_t* self); /// // Returns the identifiers of all existing frames. /// - void (CEF_CALLBACK *get_frame_identifiers)(struct _cef_browser_t* self, - size_t* identifiersCount, int64* identifiers); + void(CEF_CALLBACK* get_frame_identifiers)(struct _cef_browser_t* self, + size_t* identifiersCount, + int64* identifiers); /// // Returns the names of all existing frames. /// - void (CEF_CALLBACK *get_frame_names)(struct _cef_browser_t* self, - cef_string_list_t names); + void(CEF_CALLBACK* get_frame_names)(struct _cef_browser_t* self, + cef_string_list_t names); - // + /// // Send a message to the specified |target_process|. Returns true (1) if the // message was sent successfully. /// - int (CEF_CALLBACK *send_process_message)(struct _cef_browser_t* self, + int(CEF_CALLBACK* send_process_message)( + struct _cef_browser_t* self, cef_process_id_t target_process, struct _cef_process_message_t* message); } cef_browser_t; - /// // Callback structure for cef_browser_host_t::RunFileDialog. The functions of // this structure will be called on the browser process UI thread. @@ -190,18 +197,88 @@ typedef struct _cef_run_file_dialog_callback_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// - // Called asynchronously after the file dialog is dismissed. If the selection - // was successful |file_paths| will be a single value or a list of values - // depending on the dialog mode. If the selection was cancelled |file_paths| - // will be NULL. + // Called asynchronously after the file dialog is dismissed. + // |selected_accept_filter| is the 0-based index of the value selected from + // the accept filters array passed to cef_browser_host_t::RunFileDialog. + // |file_paths| will be a single value or a list of values depending on the + // dialog mode. If the selection was cancelled |file_paths| will be NULL. /// - void (CEF_CALLBACK *cont)(struct _cef_run_file_dialog_callback_t* self, - struct _cef_browser_host_t* browser_host, cef_string_list_t file_paths); + void(CEF_CALLBACK* on_file_dialog_dismissed)( + struct _cef_run_file_dialog_callback_t* self, + int selected_accept_filter, + cef_string_list_t file_paths); } cef_run_file_dialog_callback_t; +/// +// Callback structure for cef_browser_host_t::GetNavigationEntries. The +// functions of this structure will be called on the browser process UI thread. +/// +typedef struct _cef_navigation_entry_visitor_t { + /// + // Base structure. + /// + cef_base_ref_counted_t base; + + /// + // Method that will be executed. Do not keep a reference to |entry| outside of + // this callback. Return true (1) to continue visiting entries or false (0) to + // stop. |current| is true (1) if this entry is the currently loaded + // navigation entry. |index| is the 0-based index of this entry and |total| is + // the total number of entries. + /// + int(CEF_CALLBACK* visit)(struct _cef_navigation_entry_visitor_t* self, + struct _cef_navigation_entry_t* entry, + int current, + int index, + int total); +} cef_navigation_entry_visitor_t; + +/// +// Callback structure for cef_browser_host_t::PrintToPDF. The functions of this +// structure will be called on the browser process UI thread. +/// +typedef struct _cef_pdf_print_callback_t { + /// + // Base structure. + /// + cef_base_ref_counted_t base; + + /// + // Method that will be executed when the PDF printing has completed. |path| is + // the output path. |ok| will be true (1) if the printing completed + // successfully or false (0) otherwise. + /// + void(CEF_CALLBACK* on_pdf_print_finished)( + struct _cef_pdf_print_callback_t* self, + const cef_string_t* path, + int ok); +} cef_pdf_print_callback_t; + +/// +// Callback structure for cef_browser_host_t::DownloadImage. The functions of +// this structure will be called on the browser process UI thread. +/// +typedef struct _cef_download_image_callback_t { + /// + // Base structure. + /// + cef_base_ref_counted_t base; + + /// + // Method that will be executed when the image download has completed. + // |image_url| is the URL that was downloaded and |http_status_code| is the + // resulting HTTP status code. |image| is the resulting image, possibly at + // multiple scale factors, or NULL if the download failed. + /// + void(CEF_CALLBACK* on_download_image_finished)( + struct _cef_download_image_callback_t* self, + const cef_string_t* image_url, + int http_status_code, + struct _cef_image_t* image); +} cef_download_image_callback_t; /// // Structure used to represent the browser process aspects of a browser window. @@ -213,21 +290,12 @@ typedef struct _cef_browser_host_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Returns the hosted browser object. /// - struct _cef_browser_t* (CEF_CALLBACK *get_browser)( - struct _cef_browser_host_t* self); - - /// - // Call this function before destroying a contained browser window. This - // function performs any internal cleanup that may be needed before the - // browser window is destroyed. See cef_life_span_handler_t::do_close() - // documentation for additional usage information. - /// - void (CEF_CALLBACK *parent_window_will_close)( + struct _cef_browser_t*(CEF_CALLBACK* get_browser)( struct _cef_browser_host_t* self); /// @@ -240,130 +308,232 @@ typedef struct _cef_browser_host_t { // cef_life_span_handler_t::do_close() documentation for additional usage // information. /// - void (CEF_CALLBACK *close_browser)(struct _cef_browser_host_t* self, - int force_close); + void(CEF_CALLBACK* close_browser)(struct _cef_browser_host_t* self, + int force_close); + + /// + // Helper for closing a browser. Call this function from the top-level window + // close handler. Internally this calls CloseBrowser(false (0)) if the close + // has not yet been initiated. This function returns false (0) while the close + // is pending and true (1) after the close has completed. See close_browser() + // and cef_life_span_handler_t::do_close() documentation for additional usage + // information. This function must be called on the browser process UI thread. + /// + int(CEF_CALLBACK* try_close_browser)(struct _cef_browser_host_t* self); /// - // Set focus for the browser window. If |enable| is true (1) focus will be set - // to the window. Otherwise, focus will be removed. + // Set whether the browser is focused. /// - void (CEF_CALLBACK *set_focus)(struct _cef_browser_host_t* self, int enable); + void(CEF_CALLBACK* set_focus)(struct _cef_browser_host_t* self, int focus); /// - // Retrieve the window handle for this browser. + // Retrieve the window handle for this browser. If this browser is wrapped in + // a cef_browser_view_t this function should be called on the browser process + // UI thread and it will return the handle for the top-level native window. /// - cef_window_handle_t (CEF_CALLBACK *get_window_handle)( + cef_window_handle_t(CEF_CALLBACK* get_window_handle)( struct _cef_browser_host_t* self); /// // Retrieve the window handle of the browser that opened this browser. Will - // return NULL for non-popup windows. This function can be used in combination - // with custom handling of modal windows. + // return NULL for non-popup windows or if this browser is wrapped in a + // cef_browser_view_t. This function can be used in combination with custom + // handling of modal windows. /// - cef_window_handle_t (CEF_CALLBACK *get_opener_window_handle)( + cef_window_handle_t(CEF_CALLBACK* get_opener_window_handle)( struct _cef_browser_host_t* self); + /// + // Returns true (1) if this browser is wrapped in a cef_browser_view_t. + /// + int(CEF_CALLBACK* has_view)(struct _cef_browser_host_t* self); + /// // Returns the client for this browser. /// - struct _cef_client_t* (CEF_CALLBACK *get_client)( + struct _cef_client_t*(CEF_CALLBACK* get_client)( struct _cef_browser_host_t* self); /// // Returns the request context for this browser. /// - struct _cef_request_context_t* (CEF_CALLBACK *get_request_context)( + struct _cef_request_context_t*(CEF_CALLBACK* get_request_context)( struct _cef_browser_host_t* self); /// // Get the current zoom level. The default zoom level is 0.0. This function // can only be called on the UI thread. /// - double (CEF_CALLBACK *get_zoom_level)(struct _cef_browser_host_t* self); + double(CEF_CALLBACK* get_zoom_level)(struct _cef_browser_host_t* self); /// // Change the zoom level to the specified value. Specify 0.0 to reset the zoom // level. If called on the UI thread the change will be applied immediately. // Otherwise, the change will be applied asynchronously on the UI thread. /// - void (CEF_CALLBACK *set_zoom_level)(struct _cef_browser_host_t* self, - double zoomLevel); + void(CEF_CALLBACK* set_zoom_level)(struct _cef_browser_host_t* self, + double zoomLevel); /// // Call to run a file chooser dialog. Only a single file chooser dialog may be // pending at any given time. |mode| represents the type of dialog to display. // |title| to the title to be used for the dialog and may be NULL to show the - // default title ("Open" or "Save" depending on the mode). |default_file_name| - // is the default file name to select in the dialog. |accept_types| is a list - // of valid lower-cased MIME types or file extensions specified in an input - // element and is used to restrict selectable files to such types. |callback| - // will be executed after the dialog is dismissed or immediately if another - // dialog is already pending. The dialog will be initiated asynchronously on - // the UI thread. - /// - void (CEF_CALLBACK *run_file_dialog)(struct _cef_browser_host_t* self, - cef_file_dialog_mode_t mode, const cef_string_t* title, - const cef_string_t* default_file_name, cef_string_list_t accept_types, + // default title ("Open" or "Save" depending on the mode). |default_file_path| + // is the path with optional directory and/or file name component that will be + // initially selected in the dialog. |accept_filters| are used to restrict the + // selectable file types and may any combination of (a) valid lower-cased MIME + // types (e.g. "text/*" or "image/*"), (b) individual file extensions (e.g. + // ".txt" or ".png"), or (c) combined description and file extension delimited + // using "|" and ";" (e.g. "Image Types|.png;.gif;.jpg"). + // |selected_accept_filter| is the 0-based index of the filter that will be + // selected by default. |callback| will be executed after the dialog is + // dismissed or immediately if another dialog is already pending. The dialog + // will be initiated asynchronously on the UI thread. + /// + void(CEF_CALLBACK* run_file_dialog)( + struct _cef_browser_host_t* self, + cef_file_dialog_mode_t mode, + const cef_string_t* title, + const cef_string_t* default_file_path, + cef_string_list_t accept_filters, + int selected_accept_filter, struct _cef_run_file_dialog_callback_t* callback); /// // Download the file at |url| using cef_download_handler_t. /// - void (CEF_CALLBACK *start_download)(struct _cef_browser_host_t* self, - const cef_string_t* url); + void(CEF_CALLBACK* start_download)(struct _cef_browser_host_t* self, + const cef_string_t* url); + + /// + // Download |image_url| and execute |callback| on completion with the images + // received from the renderer. If |is_favicon| is true (1) then cookies are + // not sent and not accepted during download. Images with density independent + // pixel (DIP) sizes larger than |max_image_size| are filtered out from the + // image results. Versions of the image at different scale factors may be + // downloaded up to the maximum scale factor supported by the system. If there + // are no image results <= |max_image_size| then the smallest image is resized + // to |max_image_size| and is the only result. A |max_image_size| of 0 means + // unlimited. If |bypass_cache| is true (1) then |image_url| is requested from + // the server even if it is present in the browser cache. + /// + void(CEF_CALLBACK* download_image)( + struct _cef_browser_host_t* self, + const cef_string_t* image_url, + int is_favicon, + uint32 max_image_size, + int bypass_cache, + struct _cef_download_image_callback_t* callback); /// // Print the current browser contents. /// - void (CEF_CALLBACK *print)(struct _cef_browser_host_t* self); + void(CEF_CALLBACK* print)(struct _cef_browser_host_t* self); /// - // Search for |searchText|. |identifier| can be used to have multiple searches - // running simultaniously. |forward| indicates whether to search forward or - // backward within the page. |matchCase| indicates whether the search should - // be case-sensitive. |findNext| indicates whether this is the first request - // or a follow-up. + // Print the current browser contents to the PDF file specified by |path| and + // execute |callback| on completion. The caller is responsible for deleting + // |path| when done. For PDF printing to work on Linux you must implement the + // cef_print_handler_t::GetPdfPaperSize function. /// - void (CEF_CALLBACK *find)(struct _cef_browser_host_t* self, int identifier, - const cef_string_t* searchText, int forward, int matchCase, - int findNext); + void(CEF_CALLBACK* print_to_pdf)( + struct _cef_browser_host_t* self, + const cef_string_t* path, + const struct _cef_pdf_print_settings_t* settings, + struct _cef_pdf_print_callback_t* callback); + + /// + // Search for |searchText|. |identifier| must be a unique ID and these IDs + // must strictly increase so that newer requests always have greater IDs than + // older requests. If |identifier| is zero or less than the previous ID value + // then it will be automatically assigned a new valid ID. |forward| indicates + // whether to search forward or backward within the page. |matchCase| + // indicates whether the search should be case-sensitive. |findNext| indicates + // whether this is the first request or a follow-up. The cef_find_handler_t + // instance, if any, returned via cef_client_t::GetFindHandler will be called + // to report find results. + /// + void(CEF_CALLBACK* find)(struct _cef_browser_host_t* self, + int identifier, + const cef_string_t* searchText, + int forward, + int matchCase, + int findNext); /// // Cancel all searches that are currently going on. /// - void (CEF_CALLBACK *stop_finding)(struct _cef_browser_host_t* self, - int clearSelection); + void(CEF_CALLBACK* stop_finding)(struct _cef_browser_host_t* self, + int clearSelection); /// - // Open developer tools in its own window. + // Open developer tools (DevTools) in its own browser. The DevTools browser + // will remain associated with this browser. If the DevTools browser is + // already open then it will be focused, in which case the |windowInfo|, + // |client| and |settings| parameters will be ignored. If |inspect_element_at| + // is non-NULL then the element at the specified (x,y) location will be + // inspected. The |windowInfo| parameter will be ignored if this browser is + // wrapped in a cef_browser_view_t. /// - void (CEF_CALLBACK *show_dev_tools)(struct _cef_browser_host_t* self, + void(CEF_CALLBACK* show_dev_tools)( + struct _cef_browser_host_t* self, const struct _cef_window_info_t* windowInfo, struct _cef_client_t* client, - const struct _cef_browser_settings_t* settings); + const struct _cef_browser_settings_t* settings, + const cef_point_t* inspect_element_at); + + /// + // Explicitly close the associated DevTools browser, if any. + /// + void(CEF_CALLBACK* close_dev_tools)(struct _cef_browser_host_t* self); /// - // Explicitly close the developer tools window if one exists for this browser - // instance. + // Returns true (1) if this browser currently has an associated DevTools + // browser. Must be called on the browser process UI thread. /// - void (CEF_CALLBACK *close_dev_tools)(struct _cef_browser_host_t* self); + int(CEF_CALLBACK* has_dev_tools)(struct _cef_browser_host_t* self); + + /// + // Retrieve a snapshot of current navigation entries as values sent to the + // specified visitor. If |current_only| is true (1) only the current + // navigation entry will be sent, otherwise all navigation entries will be + // sent. + /// + void(CEF_CALLBACK* get_navigation_entries)( + struct _cef_browser_host_t* self, + struct _cef_navigation_entry_visitor_t* visitor, + int current_only); /// // Set whether mouse cursor change is disabled. /// - void (CEF_CALLBACK *set_mouse_cursor_change_disabled)( - struct _cef_browser_host_t* self, int disabled); + void(CEF_CALLBACK* set_mouse_cursor_change_disabled)( + struct _cef_browser_host_t* self, + int disabled); /// // Returns true (1) if mouse cursor change is disabled. /// - int (CEF_CALLBACK *is_mouse_cursor_change_disabled)( + int(CEF_CALLBACK* is_mouse_cursor_change_disabled)( struct _cef_browser_host_t* self); + /// + // If a misspelled word is currently selected in an editable node calling this + // function will replace it with the specified |word|. + /// + void(CEF_CALLBACK* replace_misspelling)(struct _cef_browser_host_t* self, + const cef_string_t* word); + + /// + // Add the specified |word| to the spelling dictionary. + /// + void(CEF_CALLBACK* add_word_to_dictionary)(struct _cef_browser_host_t* self, + const cef_string_t* word); + /// // Returns true (1) if window rendering is disabled. /// - int (CEF_CALLBACK *is_window_rendering_disabled)( + int(CEF_CALLBACK* is_window_rendering_disabled)( struct _cef_browser_host_t* self); /// @@ -372,14 +542,14 @@ typedef struct _cef_browser_host_t { // cef_render_handler_t::OnPaint asynchronously with the updated regions. This // function is only used when window rendering is disabled. /// - void (CEF_CALLBACK *was_resized)(struct _cef_browser_host_t* self); + void(CEF_CALLBACK* was_resized)(struct _cef_browser_host_t* self); /// // Notify the browser that it has been hidden or shown. Layouting and // cef_render_handler_t::OnPaint notification will stop when the browser is // hidden. This function is only used when window rendering is disabled. /// - void (CEF_CALLBACK *was_hidden)(struct _cef_browser_host_t* self, int hidden); + void(CEF_CALLBACK* was_hidden)(struct _cef_browser_host_t* self, int hidden); /// // Send a notification to the browser that the screen info has changed. The @@ -389,37 +559,42 @@ typedef struct _cef_browser_host_t { // current display. This function is only used when window rendering is // disabled. /// - void (CEF_CALLBACK *notify_screen_info_changed)( + void(CEF_CALLBACK* notify_screen_info_changed)( struct _cef_browser_host_t* self); /// - // Invalidate the |dirtyRect| region of the view. The browser will call - // cef_render_handler_t::OnPaint asynchronously with the updated regions. This - // function is only used when window rendering is disabled. + // Invalidate the view. The browser will call cef_render_handler_t::OnPaint + // asynchronously. This function is only used when window rendering is + // disabled. /// - void (CEF_CALLBACK *invalidate)(struct _cef_browser_host_t* self, - const cef_rect_t* dirtyRect, cef_paint_element_type_t type); + void(CEF_CALLBACK* invalidate)(struct _cef_browser_host_t* self, + cef_paint_element_type_t type); /// // Send a key event to the browser. /// - void (CEF_CALLBACK *send_key_event)(struct _cef_browser_host_t* self, - const struct _cef_key_event_t* event); + void(CEF_CALLBACK* send_key_event)(struct _cef_browser_host_t* self, + const struct _cef_key_event_t* event); /// // Send a mouse click event to the browser. The |x| and |y| coordinates are // relative to the upper-left corner of the view. /// - void (CEF_CALLBACK *send_mouse_click_event)(struct _cef_browser_host_t* self, - const struct _cef_mouse_event_t* event, cef_mouse_button_type_t type, - int mouseUp, int clickCount); + void(CEF_CALLBACK* send_mouse_click_event)( + struct _cef_browser_host_t* self, + const struct _cef_mouse_event_t* event, + cef_mouse_button_type_t type, + int mouseUp, + int clickCount); /// // Send a mouse move event to the browser. The |x| and |y| coordinates are // relative to the upper-left corner of the view. /// - void (CEF_CALLBACK *send_mouse_move_event)(struct _cef_browser_host_t* self, - const struct _cef_mouse_event_t* event, int mouseLeave); + void(CEF_CALLBACK* send_mouse_move_event)( + struct _cef_browser_host_t* self, + const struct _cef_mouse_event_t* event, + int mouseLeave); /// // Send a mouse wheel event to the browser. The |x| and |y| coordinates are @@ -428,42 +603,216 @@ typedef struct _cef_browser_host_t { // In order to scroll inside select popups with window rendering disabled // cef_render_handler_t::GetScreenPoint should be implemented properly. /// - void (CEF_CALLBACK *send_mouse_wheel_event)(struct _cef_browser_host_t* self, - const struct _cef_mouse_event_t* event, int deltaX, int deltaY); + void(CEF_CALLBACK* send_mouse_wheel_event)( + struct _cef_browser_host_t* self, + const struct _cef_mouse_event_t* event, + int deltaX, + int deltaY); /// // Send a focus event to the browser. /// - void (CEF_CALLBACK *send_focus_event)(struct _cef_browser_host_t* self, - int setFocus); + void(CEF_CALLBACK* send_focus_event)(struct _cef_browser_host_t* self, + int setFocus); /// // Send a capture lost event to the browser. /// - void (CEF_CALLBACK *send_capture_lost_event)( + void(CEF_CALLBACK* send_capture_lost_event)(struct _cef_browser_host_t* self); + + /// + // Notify the browser that the window hosting it is about to be moved or + // resized. This function is only used on Windows and Linux. + /// + void(CEF_CALLBACK* notify_move_or_resize_started)( struct _cef_browser_host_t* self); /// - // Get the NSTextInputContext implementation for enabling IME on Mac when - // window rendering is disabled. + // Returns the maximum rate in frames per second (fps) that + // cef_render_handler_t:: 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 function can only be called on the UI thread. /// - cef_text_input_context_t (CEF_CALLBACK *get_nstext_input_context)( + int(CEF_CALLBACK* get_windowless_frame_rate)( struct _cef_browser_host_t* self); /// - // Handles a keyDown event prior to passing it through the NSTextInputClient - // machinery. + // Set the maximum rate in frames per second (fps) that cef_render_handler_t:: + // 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). Can also be + // set at browser creation via cef_browser_tSettings.windowless_frame_rate. + /// + void(CEF_CALLBACK* set_windowless_frame_rate)( + struct _cef_browser_host_t* self, + int frame_rate); + + /// + // Begins a new composition or updates the existing composition. Blink has a + // special node (a composition node) that allows the input function to change + // text without affecting other DOM nodes. |text| is the optional text that + // will be inserted into the composition node. |underlines| is an optional set + // of ranges that will be underlined in the resulting text. + // |replacement_range| is an optional range of the existing text that will be + // replaced. |selection_range| is an optional range of the resulting text that + // will be selected after insertion or replacement. The |replacement_range| + // value is only used on OS X. + // + // This function may be called multiple times as the composition changes. When + // the client is done making changes the composition should either be canceled + // or completed. To cancel the composition call ImeCancelComposition. To + // complete the composition call either ImeCommitText or + // ImeFinishComposingText. Completion is usually signaled when: + // A. The client receives a WM_IME_COMPOSITION message with a GCS_RESULTSTR + // flag (on Windows), or; + // B. The client receives a "commit" signal of GtkIMContext (on Linux), or; + // C. insertText of NSTextInput is called (on Mac). + // + // This function is only used when window rendering is disabled. + /// + void(CEF_CALLBACK* ime_set_composition)( + struct _cef_browser_host_t* self, + const cef_string_t* text, + size_t underlinesCount, + cef_composition_underline_t const* underlines, + const cef_range_t* replacement_range, + const cef_range_t* selection_range); + + /// + // Completes the existing composition by optionally inserting the specified + // |text| into the composition node. |replacement_range| is an optional range + // of the existing text that will be replaced. |relative_cursor_pos| is where + // the cursor will be positioned relative to the current cursor position. See + // comments on ImeSetComposition for usage. The |replacement_range| and + // |relative_cursor_pos| values are only used on OS X. This function is only + // used when window rendering is disabled. + /// + void(CEF_CALLBACK* ime_commit_text)(struct _cef_browser_host_t* self, + const cef_string_t* text, + const cef_range_t* replacement_range, + int relative_cursor_pos); + + /// + // Completes the existing composition by applying the current composition node + // contents. If |keep_selection| is false (0) the current selection, if any, + // will be discarded. See comments on ImeSetComposition for usage. This + // function is only used when window rendering is disabled. /// - void (CEF_CALLBACK *handle_key_event_before_text_input_client)( - struct _cef_browser_host_t* self, cef_event_handle_t keyEvent); + void(CEF_CALLBACK* ime_finish_composing_text)( + struct _cef_browser_host_t* self, + int keep_selection); /// - // Performs any additional actions after NSTextInputClient handles the event. + // Cancels the existing composition and discards the composition node contents + // without applying them. See comments on ImeSetComposition for usage. This + // function is only used when window rendering is disabled. /// - void (CEF_CALLBACK *handle_key_event_after_text_input_client)( - struct _cef_browser_host_t* self, cef_event_handle_t keyEvent); -} cef_browser_host_t; + void(CEF_CALLBACK* ime_cancel_composition)(struct _cef_browser_host_t* self); + + /// + // Call this function when the user drags the mouse into the web view (before + // calling DragTargetDragOver/DragTargetLeave/DragTargetDrop). |drag_data| + // should not contain file contents as this type of data is not allowed to be + // dragged into the web view. File contents can be removed using + // cef_drag_data_t::ResetFileContents (for example, if |drag_data| comes from + // cef_render_handler_t::StartDragging). This function is only used when + // window rendering is disabled. + /// + void(CEF_CALLBACK* drag_target_drag_enter)( + struct _cef_browser_host_t* self, + struct _cef_drag_data_t* drag_data, + const struct _cef_mouse_event_t* event, + cef_drag_operations_mask_t allowed_ops); + + /// + // Call this function each time the mouse is moved across the web view during + // a drag operation (after calling DragTargetDragEnter and before calling + // DragTargetDragLeave/DragTargetDrop). This function is only used when window + // rendering is disabled. + /// + void(CEF_CALLBACK* drag_target_drag_over)( + struct _cef_browser_host_t* self, + const struct _cef_mouse_event_t* event, + cef_drag_operations_mask_t allowed_ops); + + /// + // Call this function when the user drags the mouse out of the web view (after + // calling DragTargetDragEnter). This function is only used when window + // rendering is disabled. + /// + void(CEF_CALLBACK* drag_target_drag_leave)(struct _cef_browser_host_t* self); + + /// + // Call this function when the user completes the drag operation by dropping + // the object onto the web view (after calling DragTargetDragEnter). The + // object being dropped is |drag_data|, given as an argument to the previous + // DragTargetDragEnter call. This function is only used when window rendering + // is disabled. + /// + void(CEF_CALLBACK* drag_target_drop)(struct _cef_browser_host_t* self, + const struct _cef_mouse_event_t* event); + + /// + // Call this function when the drag operation started by a + // cef_render_handler_t::StartDragging call has ended either in a drop or by + // being cancelled. |x| and |y| are mouse coordinates relative to the upper- + // left corner of the view. If the web view is both the drag source and the + // drag target then all DragTarget* functions should be called before + // DragSource* mthods. This function is only used when window rendering is + // disabled. + /// + void(CEF_CALLBACK* drag_source_ended_at)(struct _cef_browser_host_t* self, + int x, + int y, + cef_drag_operations_mask_t op); + + /// + // Call this function when the drag operation started by a + // cef_render_handler_t::StartDragging call has completed. This function may + // be called immediately without first calling DragSourceEndedAt to cancel a + // drag operation. If the web view is both the drag source and the drag target + // then all DragTarget* functions should be called before DragSource* mthods. + // This function is only used when window rendering is disabled. + /// + void(CEF_CALLBACK* drag_source_system_drag_ended)( + struct _cef_browser_host_t* self); + + /// + // Returns the current visible navigation entry for this browser. This + // function can only be called on the UI thread. + /// + struct _cef_navigation_entry_t*(CEF_CALLBACK* get_visible_navigation_entry)( + struct _cef_browser_host_t* self); + /// + // Set accessibility state for all frames. |accessibility_state| may be + // default, enabled or disabled. If |accessibility_state| is STATE_DEFAULT + // then accessibility will be disabled by default and the state may be further + // controlled with the "force-renderer-accessibility" and "disable-renderer- + // accessibility" command-line switches. If |accessibility_state| is + // STATE_ENABLED then accessibility will be enabled. If |accessibility_state| + // is STATE_DISABLED then accessibility will be completely disabled. + // + // For windowed browsers accessibility will be enabled in Complete mode (which + // corresponds to kAccessibilityModeComplete in Chromium). In this mode all + // platform accessibility objects will be created and managed by Chromium's + // internal implementation. The client needs only to detect the screen reader + // and call this function appropriately. For example, on macOS the client can + // handle the @"AXEnhancedUserStructure" accessibility attribute to detect + // VoiceOver state changes and on Windows the client can handle WM_GETOBJECT + // with OBJID_CLIENT to detect accessibility readers. + // + // For windowless browsers accessibility will be enabled in TreeOnly mode + // (which corresponds to kAccessibilityModeWebContentsOnly in Chromium). In + // this mode renderer accessibility is enabled, the full tree is computed, and + // events are passed to CefAccessibiltyHandler, but platform accessibility + // objects are not created. The client may implement platform accessibility + // objects using CefAccessibiltyHandler callbacks if desired. + /// + void(CEF_CALLBACK* set_accessibility_state)(struct _cef_browser_host_t* self, + cef_state_t accessibility_state); +} cef_browser_host_t; /// // Create a new browser window using the window parameters specified by @@ -473,8 +822,10 @@ typedef struct _cef_browser_host_t { // thread and will not block. /// CEF_EXPORT int cef_browser_host_create_browser( - const cef_window_info_t* windowInfo, struct _cef_client_t* client, - const cef_string_t* url, const struct _cef_browser_settings_t* settings, + const cef_window_info_t* windowInfo, + struct _cef_client_t* client, + const cef_string_t* url, + const struct _cef_browser_settings_t* settings, struct _cef_request_context_t* request_context); /// @@ -483,11 +834,12 @@ CEF_EXPORT int cef_browser_host_create_browser( // used. This function can only be called on the browser process UI thread. /// CEF_EXPORT cef_browser_t* cef_browser_host_create_browser_sync( - const cef_window_info_t* windowInfo, struct _cef_client_t* client, - const cef_string_t* url, const struct _cef_browser_settings_t* settings, + const cef_window_info_t* windowInfo, + struct _cef_client_t* client, + const cef_string_t* url, + const struct _cef_browser_settings_t* settings, struct _cef_request_context_t* request_context); - #ifdef __cplusplus } #endif diff --git a/include/capi/cef_browser_process_handler_capi.h b/include/capi/cef_browser_process_handler_capi.h index c9f683d..6a9d712 100644 --- a/include/capi/cef_browser_process_handler_capi.h +++ b/include/capi/cef_browser_process_handler_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,19 +33,21 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=0868c7d129e35c38b207b1066fd5eba0c1eef45c$ +// #ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_ #pragma once -#ifdef __cplusplus -extern "C" { -#endif - #include "include/capi/cef_base_capi.h" #include "include/capi/cef_command_line_capi.h" +#include "include/capi/cef_print_handler_capi.h" #include "include/capi/cef_values_capi.h" +#ifdef __cplusplus +extern "C" { +#endif /// // Structure used to implement browser process callbacks. The functions of this @@ -56,13 +58,13 @@ typedef struct _cef_browser_process_handler_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Called on the browser process UI thread immediately after the CEF context // has been initialized. /// - void (CEF_CALLBACK *on_context_initialized)( + void(CEF_CALLBACK* on_context_initialized)( struct _cef_browser_process_handler_t* self); /// @@ -72,7 +74,7 @@ typedef struct _cef_browser_process_handler_t { // opportunity to modify the child process command line. Do not keep a // reference to |command_line| outside of this function. /// - void (CEF_CALLBACK *on_before_child_process_launch)( + void(CEF_CALLBACK* on_before_child_process_launch)( struct _cef_browser_process_handler_t* self, struct _cef_command_line_t* command_line); @@ -83,11 +85,34 @@ typedef struct _cef_browser_process_handler_t { // cef_render_process_handler_t::on_render_thread_created() in the render // process. Do not keep a reference to |extra_info| outside of this function. /// - void (CEF_CALLBACK *on_render_process_thread_created)( + void(CEF_CALLBACK* on_render_process_thread_created)( struct _cef_browser_process_handler_t* self, struct _cef_list_value_t* extra_info); -} cef_browser_process_handler_t; + /// + // Return the handler for printing on Linux. If a print handler is not + // provided then printing will not be supported on the Linux platform. + /// + struct _cef_print_handler_t*(CEF_CALLBACK* get_print_handler)( + struct _cef_browser_process_handler_t* self); + + /// + // Called from any thread when work has been scheduled for the browser process + // main (UI) thread. This callback is used in combination with CefSettings. + // external_message_pump and cef_do_message_loop_work() in cases where the CEF + // message loop must be integrated into an existing application message loop + // (see additional comments and warnings on CefDoMessageLoopWork). This + // callback should schedule a cef_do_message_loop_work() call to happen on the + // main (UI) thread. |delay_ms| is the requested delay in milliseconds. If + // |delay_ms| is <= 0 then the call should happen reasonably soon. If + // |delay_ms| is > 0 then the call should be scheduled to happen after the + // specified delay and any currently pending scheduled call should be + // cancelled. + /// + void(CEF_CALLBACK* on_schedule_message_pump_work)( + struct _cef_browser_process_handler_t* self, + int64 delay_ms); +} cef_browser_process_handler_t; #ifdef __cplusplus } diff --git a/include/capi/cef_callback_capi.h b/include/capi/cef_callback_capi.h index 7a0ed06..14e9c28 100644 --- a/include/capi/cef_callback_capi.h +++ b/include/capi/cef_callback_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,18 +33,19 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=68de2255fd429696d62115786fc480f1d5f9882b$ +// #ifndef CEF_INCLUDE_CAPI_CEF_CALLBACK_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_CALLBACK_CAPI_H_ #pragma once +#include "include/capi/cef_base_capi.h" + #ifdef __cplusplus extern "C" { #endif -#include "include/capi/cef_base_capi.h" - - /// // Generic callback structure used for asynchronous continuation. /// @@ -52,35 +53,33 @@ typedef struct _cef_callback_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Continue processing. /// - void (CEF_CALLBACK *cont)(struct _cef_callback_t* self); + void(CEF_CALLBACK* cont)(struct _cef_callback_t* self); /// // Cancel processing. /// - void (CEF_CALLBACK *cancel)(struct _cef_callback_t* self); + void(CEF_CALLBACK* cancel)(struct _cef_callback_t* self); } cef_callback_t; - /// // Generic callback structure used for asynchronous completion. /// -typedef struct _cef_completion_handler_t { +typedef struct _cef_completion_callback_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Method that will be called once the task is complete. /// - void (CEF_CALLBACK *on_complete)(struct _cef_completion_handler_t* self); -} cef_completion_handler_t; - + void(CEF_CALLBACK* on_complete)(struct _cef_completion_callback_t* self); +} cef_completion_callback_t; #ifdef __cplusplus } diff --git a/include/capi/cef_client_capi.h b/include/capi/cef_client_capi.h index e7e2e73..93339d2 100644 --- a/include/capi/cef_client_capi.h +++ b/include/capi/cef_client_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,21 +33,20 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=7f554250e73537ece3f8f67310c23e718f91d41b$ +// #ifndef CEF_INCLUDE_CAPI_CEF_CLIENT_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_CLIENT_CAPI_H_ #pragma once -#ifdef __cplusplus -extern "C" { -#endif - #include "include/capi/cef_base_capi.h" #include "include/capi/cef_context_menu_handler_capi.h" #include "include/capi/cef_dialog_handler_capi.h" #include "include/capi/cef_display_handler_capi.h" #include "include/capi/cef_download_handler_capi.h" #include "include/capi/cef_drag_handler_capi.h" +#include "include/capi/cef_find_handler_capi.h" #include "include/capi/cef_focus_handler_capi.h" #include "include/capi/cef_geolocation_handler_capi.h" #include "include/capi/cef_jsdialog_handler_capi.h" @@ -58,6 +57,9 @@ extern "C" { #include "include/capi/cef_render_handler_capi.h" #include "include/capi/cef_request_handler_capi.h" +#ifdef __cplusplus +extern "C" { +#endif /// // Implement this structure to provide handler implementations. @@ -66,89 +68,95 @@ typedef struct _cef_client_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Return the handler for context menus. If no handler is provided the default // implementation will be used. /// - struct _cef_context_menu_handler_t* (CEF_CALLBACK *get_context_menu_handler)( + struct _cef_context_menu_handler_t*(CEF_CALLBACK* get_context_menu_handler)( struct _cef_client_t* self); /// // Return the handler for dialogs. If no handler is provided the default // implementation will be used. /// - struct _cef_dialog_handler_t* (CEF_CALLBACK *get_dialog_handler)( + struct _cef_dialog_handler_t*(CEF_CALLBACK* get_dialog_handler)( struct _cef_client_t* self); /// // Return the handler for browser display state events. /// - struct _cef_display_handler_t* (CEF_CALLBACK *get_display_handler)( + struct _cef_display_handler_t*(CEF_CALLBACK* get_display_handler)( struct _cef_client_t* self); /// // Return the handler for download events. If no handler is returned downloads // will not be allowed. /// - struct _cef_download_handler_t* (CEF_CALLBACK *get_download_handler)( + struct _cef_download_handler_t*(CEF_CALLBACK* get_download_handler)( struct _cef_client_t* self); /// // Return the handler for drag events. /// - struct _cef_drag_handler_t* (CEF_CALLBACK *get_drag_handler)( + struct _cef_drag_handler_t*(CEF_CALLBACK* get_drag_handler)( + struct _cef_client_t* self); + + /// + // Return the handler for find result events. + /// + struct _cef_find_handler_t*(CEF_CALLBACK* get_find_handler)( struct _cef_client_t* self); /// // Return the handler for focus events. /// - struct _cef_focus_handler_t* (CEF_CALLBACK *get_focus_handler)( + struct _cef_focus_handler_t*(CEF_CALLBACK* get_focus_handler)( struct _cef_client_t* self); /// // Return the handler for geolocation permissions requests. If no handler is // provided geolocation access will be denied by default. /// - struct _cef_geolocation_handler_t* (CEF_CALLBACK *get_geolocation_handler)( + struct _cef_geolocation_handler_t*(CEF_CALLBACK* get_geolocation_handler)( struct _cef_client_t* self); /// // Return the handler for JavaScript dialogs. If no handler is provided the // default implementation will be used. /// - struct _cef_jsdialog_handler_t* (CEF_CALLBACK *get_jsdialog_handler)( + struct _cef_jsdialog_handler_t*(CEF_CALLBACK* get_jsdialog_handler)( struct _cef_client_t* self); /// // Return the handler for keyboard events. /// - struct _cef_keyboard_handler_t* (CEF_CALLBACK *get_keyboard_handler)( + struct _cef_keyboard_handler_t*(CEF_CALLBACK* get_keyboard_handler)( struct _cef_client_t* self); /// // Return the handler for browser life span events. /// - struct _cef_life_span_handler_t* (CEF_CALLBACK *get_life_span_handler)( + struct _cef_life_span_handler_t*(CEF_CALLBACK* get_life_span_handler)( struct _cef_client_t* self); /// // Return the handler for browser load status events. /// - struct _cef_load_handler_t* (CEF_CALLBACK *get_load_handler)( + struct _cef_load_handler_t*(CEF_CALLBACK* get_load_handler)( struct _cef_client_t* self); /// // Return the handler for off-screen rendering events. /// - struct _cef_render_handler_t* (CEF_CALLBACK *get_render_handler)( + struct _cef_render_handler_t*(CEF_CALLBACK* get_render_handler)( struct _cef_client_t* self); /// // Return the handler for browser request events. /// - struct _cef_request_handler_t* (CEF_CALLBACK *get_request_handler)( + struct _cef_request_handler_t*(CEF_CALLBACK* get_request_handler)( struct _cef_client_t* self); /// @@ -156,12 +164,13 @@ typedef struct _cef_client_t { // (1) if the message was handled or false (0) otherwise. Do not keep a // reference to or attempt to access the message outside of this callback. /// - int (CEF_CALLBACK *on_process_message_received)(struct _cef_client_t* self, - struct _cef_browser_t* browser, cef_process_id_t source_process, + int(CEF_CALLBACK* on_process_message_received)( + struct _cef_client_t* self, + struct _cef_browser_t* browser, + cef_process_id_t source_process, struct _cef_process_message_t* message); } cef_client_t; - #ifdef __cplusplus } #endif diff --git a/include/capi/cef_command_line_capi.h b/include/capi/cef_command_line_capi.h index 7e31771..9a1eed8 100644 --- a/include/capi/cef_command_line_capi.h +++ b/include/capi/cef_command_line_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,18 +33,19 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=b917030321dc11ddfc8d8939239dda7952d2f955$ +// #ifndef CEF_INCLUDE_CAPI_CEF_COMMAND_LINE_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_COMMAND_LINE_CAPI_H_ #pragma once +#include "include/capi/cef_base_capi.h" + #ifdef __cplusplus extern "C" { #endif -#include "include/capi/cef_base_capi.h" - - /// // Structure used to create and/or parse command line arguments. Arguments with // '--', '-' and, on Windows, '/' prefixes are considered switches. Switches @@ -59,24 +60,24 @@ typedef struct _cef_command_line_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Returns true (1) if this object is valid. Do not call any other functions // if this function returns false (0). /// - int (CEF_CALLBACK *is_valid)(struct _cef_command_line_t* self); + int(CEF_CALLBACK* is_valid)(struct _cef_command_line_t* self); /// // Returns true (1) if the values of this object are read-only. Some APIs may // expose read-only objects. /// - int (CEF_CALLBACK *is_read_only)(struct _cef_command_line_t* self); + int(CEF_CALLBACK* is_read_only)(struct _cef_command_line_t* self); /// // Returns a writable copy of this object. /// - struct _cef_command_line_t* (CEF_CALLBACK *copy)( + struct _cef_command_line_t*(CEF_CALLBACK* copy)( struct _cef_command_line_t* self); /// @@ -84,116 +85,117 @@ typedef struct _cef_command_line_t { // The first argument must be the name of the program. This function is only // supported on non-Windows platforms. /// - void (CEF_CALLBACK *init_from_argv)(struct _cef_command_line_t* self, - int argc, const char* const* argv); + void(CEF_CALLBACK* init_from_argv)(struct _cef_command_line_t* self, + int argc, + const char* const* argv); /// // Initialize the command line with the string returned by calling // GetCommandLineW(). This function is only supported on Windows. /// - void (CEF_CALLBACK *init_from_string)(struct _cef_command_line_t* self, - const cef_string_t* command_line); + void(CEF_CALLBACK* init_from_string)(struct _cef_command_line_t* self, + const cef_string_t* command_line); /// // Reset the command-line switches and arguments but leave the program // component unchanged. /// - void (CEF_CALLBACK *reset)(struct _cef_command_line_t* self); + void(CEF_CALLBACK* reset)(struct _cef_command_line_t* self); /// // Retrieve the original command line string as a vector of strings. The argv // array: { program, [(--|-|/)switch[=value]]*, [--], [argument]* } /// - void (CEF_CALLBACK *get_argv)(struct _cef_command_line_t* self, - cef_string_list_t argv); + void(CEF_CALLBACK* get_argv)(struct _cef_command_line_t* self, + cef_string_list_t argv); /// // Constructs and returns the represented command line string. Use this // function cautiously because quoting behavior is unclear. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_command_line_string)( + cef_string_userfree_t(CEF_CALLBACK* get_command_line_string)( struct _cef_command_line_t* self); /// // Get the program part of the command line string (the first item). /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_program)( + cef_string_userfree_t(CEF_CALLBACK* get_program)( struct _cef_command_line_t* self); /// // Set the program part of the command line string (the first item). /// - void (CEF_CALLBACK *set_program)(struct _cef_command_line_t* self, - const cef_string_t* program); + void(CEF_CALLBACK* set_program)(struct _cef_command_line_t* self, + const cef_string_t* program); /// // Returns true (1) if the command line has switches. /// - int (CEF_CALLBACK *has_switches)(struct _cef_command_line_t* self); + int(CEF_CALLBACK* has_switches)(struct _cef_command_line_t* self); /// // Returns true (1) if the command line contains the given switch. /// - int (CEF_CALLBACK *has_switch)(struct _cef_command_line_t* self, - const cef_string_t* name); + int(CEF_CALLBACK* has_switch)(struct _cef_command_line_t* self, + const cef_string_t* name); /// // Returns the value associated with the given switch. If the switch has no // value or isn't present this function returns the NULL string. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_switch_value)( - struct _cef_command_line_t* self, const cef_string_t* name); + cef_string_userfree_t(CEF_CALLBACK* get_switch_value)( + struct _cef_command_line_t* self, + const cef_string_t* name); /// // Returns the map of switch names and values. If a switch has no value an // NULL string is returned. /// - void (CEF_CALLBACK *get_switches)(struct _cef_command_line_t* self, - cef_string_map_t switches); + void(CEF_CALLBACK* get_switches)(struct _cef_command_line_t* self, + cef_string_map_t switches); /// // Add a switch to the end of the command line. If the switch has no value // pass an NULL value string. /// - void (CEF_CALLBACK *append_switch)(struct _cef_command_line_t* self, - const cef_string_t* name); + void(CEF_CALLBACK* append_switch)(struct _cef_command_line_t* self, + const cef_string_t* name); /// // Add a switch with the specified value to the end of the command line. /// - void (CEF_CALLBACK *append_switch_with_value)( - struct _cef_command_line_t* self, const cef_string_t* name, - const cef_string_t* value); + void(CEF_CALLBACK* append_switch_with_value)(struct _cef_command_line_t* self, + const cef_string_t* name, + const cef_string_t* value); /// // True if there are remaining command line arguments. /// - int (CEF_CALLBACK *has_arguments)(struct _cef_command_line_t* self); + int(CEF_CALLBACK* has_arguments)(struct _cef_command_line_t* self); /// // Get the remaining command line arguments. /// - void (CEF_CALLBACK *get_arguments)(struct _cef_command_line_t* self, - cef_string_list_t arguments); + void(CEF_CALLBACK* get_arguments)(struct _cef_command_line_t* self, + cef_string_list_t arguments); /// // Add an argument to the end of the command line. /// - void (CEF_CALLBACK *append_argument)(struct _cef_command_line_t* self, - const cef_string_t* argument); + void(CEF_CALLBACK* append_argument)(struct _cef_command_line_t* self, + const cef_string_t* argument); /// // Insert a command before the current command. Common for debuggers, like // "valgrind" or "gdb --args". /// - void (CEF_CALLBACK *prepend_wrapper)(struct _cef_command_line_t* self, - const cef_string_t* wrapper); + void(CEF_CALLBACK* prepend_wrapper)(struct _cef_command_line_t* self, + const cef_string_t* wrapper); } cef_command_line_t; - /// // Create a new cef_command_line_t instance. /// @@ -205,7 +207,6 @@ CEF_EXPORT cef_command_line_t* cef_command_line_create(); /// CEF_EXPORT cef_command_line_t* cef_command_line_get_global(); - #ifdef __cplusplus } #endif diff --git a/include/capi/cef_context_menu_handler_capi.h b/include/capi/cef_context_menu_handler_capi.h index 1bb16ed..344dc9d 100644 --- a/include/capi/cef_context_menu_handler_capi.h +++ b/include/capi/cef_context_menu_handler_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,22 +33,47 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=2e295ba277083061103147a400bc30f78e6a94f5$ +// #ifndef CEF_INCLUDE_CAPI_CEF_CONTEXT_MENU_HANDLER_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_CONTEXT_MENU_HANDLER_CAPI_H_ #pragma once -#ifdef __cplusplus -extern "C" { -#endif - #include "include/capi/cef_base_capi.h" #include "include/capi/cef_browser_capi.h" #include "include/capi/cef_frame_capi.h" #include "include/capi/cef_menu_model_capi.h" +#ifdef __cplusplus +extern "C" { +#endif + struct _cef_context_menu_params_t; +/// +// Callback structure used for continuation of custom context menu display. +/// +typedef struct _cef_run_context_menu_callback_t { + /// + // Base structure. + /// + cef_base_ref_counted_t base; + + /// + // Complete context menu display by selecting the specified |command_id| and + // |event_flags|. + /// + void(CEF_CALLBACK* cont)(struct _cef_run_context_menu_callback_t* self, + int command_id, + cef_event_flags_t event_flags); + + /// + // Cancel context menu display. + /// + void(CEF_CALLBACK* cancel)(struct _cef_run_context_menu_callback_t* self); +} cef_run_context_menu_callback_t; + /// // Implement this structure to handle context menu events. The functions of this // structure will be called on the UI thread. @@ -57,7 +82,7 @@ typedef struct _cef_context_menu_handler_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Called before a context menu is displayed. |params| provides information @@ -66,11 +91,29 @@ typedef struct _cef_context_menu_handler_t { // modified to show a custom menu. Do not keep references to |params| or // |model| outside of this callback. /// - void (CEF_CALLBACK *on_before_context_menu)( - struct _cef_context_menu_handler_t* self, struct _cef_browser_t* browser, - struct _cef_frame_t* frame, struct _cef_context_menu_params_t* params, + void(CEF_CALLBACK* on_before_context_menu)( + struct _cef_context_menu_handler_t* self, + struct _cef_browser_t* browser, + struct _cef_frame_t* frame, + struct _cef_context_menu_params_t* params, struct _cef_menu_model_t* model); + /// + // Called to allow custom display of the context menu. |params| provides + // information about the context menu state. |model| contains the context menu + // model resulting from OnBeforeContextMenu. For custom display return true + // (1) and execute |callback| either synchronously or asynchronously with the + // selected command ID. For default display return false (0). Do not keep + // references to |params| or |model| outside of this callback. + /// + int(CEF_CALLBACK* run_context_menu)( + struct _cef_context_menu_handler_t* self, + struct _cef_browser_t* browser, + struct _cef_frame_t* frame, + struct _cef_context_menu_params_t* params, + struct _cef_menu_model_t* model, + struct _cef_run_context_menu_callback_t* callback); + /// // Called to execute a command selected from the context menu. Return true (1) // if the command was handled or false (0) for the default implementation. See @@ -80,21 +123,24 @@ typedef struct _cef_context_menu_handler_t { // on_before_context_menu(). Do not keep a reference to |params| outside of // this callback. /// - int (CEF_CALLBACK *on_context_menu_command)( - struct _cef_context_menu_handler_t* self, struct _cef_browser_t* browser, - struct _cef_frame_t* frame, struct _cef_context_menu_params_t* params, - int command_id, cef_event_flags_t event_flags); + int(CEF_CALLBACK* on_context_menu_command)( + struct _cef_context_menu_handler_t* self, + struct _cef_browser_t* browser, + struct _cef_frame_t* frame, + struct _cef_context_menu_params_t* params, + int command_id, + cef_event_flags_t event_flags); /// // Called when the context menu is dismissed irregardless of whether the menu // was NULL or a command was selected. /// - void (CEF_CALLBACK *on_context_menu_dismissed)( - struct _cef_context_menu_handler_t* self, struct _cef_browser_t* browser, + void(CEF_CALLBACK* on_context_menu_dismissed)( + struct _cef_context_menu_handler_t* self, + struct _cef_browser_t* browser, struct _cef_frame_t* frame); } cef_context_menu_handler_t; - /// // Provides information about the context menu state. The ethods of this // structure can only be accessed on browser process the UI thread. @@ -103,25 +149,25 @@ typedef struct _cef_context_menu_params_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Returns the X coordinate of the mouse where the context menu was invoked. // Coords are relative to the associated RenderView's origin. /// - int (CEF_CALLBACK *get_xcoord)(struct _cef_context_menu_params_t* self); + int(CEF_CALLBACK* get_xcoord)(struct _cef_context_menu_params_t* self); /// // Returns the Y coordinate of the mouse where the context menu was invoked. // Coords are relative to the associated RenderView's origin. /// - int (CEF_CALLBACK *get_ycoord)(struct _cef_context_menu_params_t* self); + int(CEF_CALLBACK* get_ycoord)(struct _cef_context_menu_params_t* self); /// // Returns flags representing the type of node that the context menu was // invoked on. /// - cef_context_menu_type_flags_t (CEF_CALLBACK *get_type_flags)( + cef_context_menu_type_flags_t(CEF_CALLBACK* get_type_flags)( struct _cef_context_menu_params_t* self); /// @@ -129,7 +175,7 @@ typedef struct _cef_context_menu_params_t { // context menu was invoked on. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_link_url)( + cef_string_userfree_t(CEF_CALLBACK* get_link_url)( struct _cef_context_menu_params_t* self); /// @@ -137,7 +183,7 @@ typedef struct _cef_context_menu_params_t { // don't validate this field in the frontend process. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_unfiltered_link_url)( + cef_string_userfree_t(CEF_CALLBACK* get_unfiltered_link_url)( struct _cef_context_menu_params_t* self); /// @@ -145,28 +191,36 @@ typedef struct _cef_context_menu_params_t { // invoked on. Example of elements with source URLs are img, audio, and video. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_source_url)( + cef_string_userfree_t(CEF_CALLBACK* get_source_url)( struct _cef_context_menu_params_t* self); /// // Returns true (1) if the context menu was invoked on an image which has non- // NULL contents. /// - int (CEF_CALLBACK *has_image_contents)( + int(CEF_CALLBACK* has_image_contents)( + struct _cef_context_menu_params_t* self); + + /// + // Returns the title text or the alt text if the context menu was invoked on + // an image. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t(CEF_CALLBACK* get_title_text)( struct _cef_context_menu_params_t* self); /// // Returns the URL of the top level page that the context menu was invoked on. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_page_url)( + cef_string_userfree_t(CEF_CALLBACK* get_page_url)( struct _cef_context_menu_params_t* self); /// // Returns the URL of the subframe that the context menu was invoked on. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_frame_url)( + cef_string_userfree_t(CEF_CALLBACK* get_frame_url)( struct _cef_context_menu_params_t* self); /// @@ -174,20 +228,20 @@ typedef struct _cef_context_menu_params_t { // invoked on. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_frame_charset)( + cef_string_userfree_t(CEF_CALLBACK* get_frame_charset)( struct _cef_context_menu_params_t* self); /// // Returns the type of context node that the context menu was invoked on. /// - cef_context_menu_media_type_t (CEF_CALLBACK *get_media_type)( + cef_context_menu_media_type_t(CEF_CALLBACK* get_media_type)( struct _cef_context_menu_params_t* self); /// // Returns flags representing the actions supported by the media element, if // any, that the context menu was invoked on. /// - cef_context_menu_media_state_flags_t (CEF_CALLBACK *get_media_state_flags)( + cef_context_menu_media_state_flags_t(CEF_CALLBACK* get_media_state_flags)( struct _cef_context_menu_params_t* self); /// @@ -195,29 +249,57 @@ typedef struct _cef_context_menu_params_t { // invoked on. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_selection_text)( + cef_string_userfree_t(CEF_CALLBACK* get_selection_text)( + struct _cef_context_menu_params_t* self); + + /// + // Returns the text of the misspelled word, if any, that the context menu was + // invoked on. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t(CEF_CALLBACK* get_misspelled_word)( struct _cef_context_menu_params_t* self); + /// + // Returns true (1) if suggestions exist, false (0) otherwise. Fills in + // |suggestions| from the spell check service for the misspelled word if there + // is one. + /// + int(CEF_CALLBACK* get_dictionary_suggestions)( + struct _cef_context_menu_params_t* self, + cef_string_list_t suggestions); + /// // Returns true (1) if the context menu was invoked on an editable node. /// - int (CEF_CALLBACK *is_editable)(struct _cef_context_menu_params_t* self); + int(CEF_CALLBACK* is_editable)(struct _cef_context_menu_params_t* self); /// // Returns true (1) if the context menu was invoked on an editable node where - // speech-input is enabled. + // spell-check is enabled. /// - int (CEF_CALLBACK *is_speech_input_enabled)( + int(CEF_CALLBACK* is_spell_check_enabled)( struct _cef_context_menu_params_t* self); /// // Returns flags representing the actions supported by the editable node, if // any, that the context menu was invoked on. /// - cef_context_menu_edit_state_flags_t (CEF_CALLBACK *get_edit_state_flags)( + cef_context_menu_edit_state_flags_t(CEF_CALLBACK* get_edit_state_flags)( struct _cef_context_menu_params_t* self); -} cef_context_menu_params_t; + /// + // Returns true (1) if the context menu contains items specified by the + // renderer process (for example, plugin placeholder or pepper plugin menu + // items). + /// + int(CEF_CALLBACK* is_custom_menu)(struct _cef_context_menu_params_t* self); + + /// + // Returns true (1) if the context menu was invoked from a pepper plugin. + /// + int(CEF_CALLBACK* is_pepper_menu)(struct _cef_context_menu_params_t* self); +} cef_context_menu_params_t; #ifdef __cplusplus } diff --git a/include/capi/cef_cookie_capi.h b/include/capi/cef_cookie_capi.h index 2031a77..99cc66e 100644 --- a/include/capi/cef_cookie_capi.h +++ b/include/capi/cef_cookie_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,19 +33,23 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=c2bf8084385f3c795ae7494da6970a0a61b96ac6$ +// #ifndef CEF_INCLUDE_CAPI_CEF_COOKIE_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_COOKIE_CAPI_H_ #pragma once +#include "include/capi/cef_base_capi.h" +#include "include/capi/cef_callback_capi.h" + #ifdef __cplusplus extern "C" { #endif -#include "include/capi/cef_base_capi.h" -#include "include/capi/cef_callback_capi.h" - struct _cef_cookie_visitor_t; +struct _cef_delete_cookies_callback_t; +struct _cef_set_cookie_callback_t; /// // Structure used for managing cookies. The functions of this structure may be @@ -55,56 +59,69 @@ typedef struct _cef_cookie_manager_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// - // Set the schemes supported by this manager. By default only "http" and - // "https" schemes are supported. Must be called before any cookies are - // accessed. + // Set the schemes supported by this manager. The default schemes ("http", + // "https", "ws" and "wss") will always be supported. If |callback| is non- + // NULL it will be executed asnychronously on the IO thread after the change + // has been applied. Must be called before any cookies are accessed. /// - void (CEF_CALLBACK *set_supported_schemes)(struct _cef_cookie_manager_t* self, - cef_string_list_t schemes); + void(CEF_CALLBACK* set_supported_schemes)( + struct _cef_cookie_manager_t* self, + cef_string_list_t schemes, + struct _cef_completion_callback_t* callback); /// - // Visit all cookies. The returned cookies are ordered by longest path, then - // by earliest creation date. Returns false (0) if cookies cannot be accessed. + // Visit all cookies on the IO thread. The returned cookies are ordered by + // longest path, then by earliest creation date. Returns false (0) if cookies + // cannot be accessed. /// - int (CEF_CALLBACK *visit_all_cookies)(struct _cef_cookie_manager_t* self, - struct _cef_cookie_visitor_t* visitor); + int(CEF_CALLBACK* visit_all_cookies)(struct _cef_cookie_manager_t* self, + struct _cef_cookie_visitor_t* visitor); /// - // Visit a subset of cookies. The results are filtered by the given url - // scheme, host, domain and path. If |includeHttpOnly| is true (1) HTTP-only - // cookies will also be included in the results. The returned cookies are - // ordered by longest path, then by earliest creation date. Returns false (0) - // if cookies cannot be accessed. + // Visit a subset of cookies on the IO thread. The results are filtered by the + // given url scheme, host, domain and path. If |includeHttpOnly| is true (1) + // HTTP-only cookies will also be included in the results. The returned + // cookies are ordered by longest path, then by earliest creation date. + // Returns false (0) if cookies cannot be accessed. /// - int (CEF_CALLBACK *visit_url_cookies)(struct _cef_cookie_manager_t* self, - const cef_string_t* url, int includeHttpOnly, - struct _cef_cookie_visitor_t* visitor); + int(CEF_CALLBACK* visit_url_cookies)(struct _cef_cookie_manager_t* self, + const cef_string_t* url, + int includeHttpOnly, + struct _cef_cookie_visitor_t* visitor); /// // Sets a cookie given a valid URL and explicit user-provided cookie // attributes. This function expects each attribute to be well-formed. It will // check for disallowed characters (e.g. the ';' character is disallowed - // within the cookie value attribute) and will return false (0) without - // setting the cookie if such characters are found. This function must be - // called on the IO thread. + // within the cookie value attribute) and fail without setting the cookie if + // such characters are found. If |callback| is non-NULL it will be executed + // asnychronously on the IO thread after the cookie has been set. Returns + // false (0) if an invalid URL is specified or if cookies cannot be accessed. /// - int (CEF_CALLBACK *set_cookie)(struct _cef_cookie_manager_t* self, - const cef_string_t* url, const struct _cef_cookie_t* cookie); + int(CEF_CALLBACK* set_cookie)(struct _cef_cookie_manager_t* self, + const cef_string_t* url, + const struct _cef_cookie_t* cookie, + struct _cef_set_cookie_callback_t* callback); /// // Delete all cookies that match the specified parameters. If both |url| and - // values |cookie_name| are specified all host and domain cookies matching + // |cookie_name| values are specified all host and domain cookies matching // both will be deleted. If only |url| is specified all host cookies (but not // domain cookies) irrespective of path will be deleted. If |url| is NULL all - // cookies for all hosts and domains will be deleted. Returns false (0) if a - // non- NULL invalid URL is specified or if cookies cannot be accessed. This - // function must be called on the IO thread. + // cookies for all hosts and domains will be deleted. If |callback| is non- + // NULL it will be executed asnychronously on the IO thread after the cookies + // have been deleted. Returns false (0) if a non-NULL invalid URL is specified + // or if cookies cannot be accessed. Cookies can alternately be deleted using + // the Visit*Cookies() functions. /// - int (CEF_CALLBACK *delete_cookies)(struct _cef_cookie_manager_t* self, - const cef_string_t* url, const cef_string_t* cookie_name); + int(CEF_CALLBACK* delete_cookies)( + struct _cef_cookie_manager_t* self, + const cef_string_t* url, + const cef_string_t* cookie_name, + struct _cef_delete_cookies_callback_t* callback); /// // Sets the directory path that will be used for storing cookie data. If @@ -112,39 +129,49 @@ typedef struct _cef_cookie_manager_t { // stored at the specified |path|. To persist session cookies (cookies without // an expiry date or validity interval) set |persist_session_cookies| to true // (1). Session cookies are generally intended to be transient and most Web - // browsers do not persist them. Returns false (0) if cookies cannot be - // accessed. + // browsers do not persist them. If |callback| is non-NULL it will be executed + // asnychronously on the IO thread after the manager's storage has been + // initialized. Returns false (0) if cookies cannot be accessed. /// - int (CEF_CALLBACK *set_storage_path)(struct _cef_cookie_manager_t* self, - const cef_string_t* path, int persist_session_cookies); + int(CEF_CALLBACK* set_storage_path)( + struct _cef_cookie_manager_t* self, + const cef_string_t* path, + int persist_session_cookies, + struct _cef_completion_callback_t* callback); /// - // Flush the backing store (if any) to disk and execute the specified - // |handler| on the IO thread when done. Returns false (0) if cookies cannot - // be accessed. + // Flush the backing store (if any) to disk. If |callback| is non-NULL it will + // be executed asnychronously on the IO thread after the flush is complete. + // Returns false (0) if cookies cannot be accessed. /// - int (CEF_CALLBACK *flush_store)(struct _cef_cookie_manager_t* self, - struct _cef_completion_handler_t* handler); + int(CEF_CALLBACK* flush_store)(struct _cef_cookie_manager_t* self, + struct _cef_completion_callback_t* callback); } cef_cookie_manager_t; - /// // Returns the global cookie manager. By default data will be stored at -// CefSettings.cache_path if specified or in memory otherwise. +// CefSettings.cache_path if specified or in memory otherwise. If |callback| is +// non-NULL it will be executed asnychronously on the IO thread after the +// manager's storage has been initialized. Using this function is equivalent to +// calling cef_request_tContext::cef_request_context_get_global_context()->get_d +// efault_cookie_manager(). /// -CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_get_global_manager(); +CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_get_global_manager( + struct _cef_completion_callback_t* callback); /// // Creates a new cookie manager. If |path| is NULL data will be stored in memory // only. Otherwise, data will be stored at the specified |path|. To persist // session cookies (cookies without an expiry date or validity interval) set // |persist_session_cookies| to true (1). Session cookies are generally intended -// to be transient and most Web browsers do not persist them. Returns NULL if -// creation fails. +// to be transient and most Web browsers do not persist them. If |callback| is +// non-NULL it will be executed asnychronously on the IO thread after the +// manager's storage has been initialized. /// CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_create_manager( - const cef_string_t* path, int persist_session_cookies); - + const cef_string_t* path, + int persist_session_cookies, + struct _cef_completion_callback_t* callback); /// // Structure to implement for visiting cookie values. The functions of this @@ -154,7 +181,7 @@ typedef struct _cef_cookie_visitor_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Method that will be called once for each cookie. |count| is the 0-based @@ -163,11 +190,48 @@ typedef struct _cef_cookie_visitor_t { // Return false (0) to stop visiting cookies. This function may never be // called if no cookies are found. /// - int (CEF_CALLBACK *visit)(struct _cef_cookie_visitor_t* self, - const struct _cef_cookie_t* cookie, int count, int total, - int* deleteCookie); + int(CEF_CALLBACK* visit)(struct _cef_cookie_visitor_t* self, + const struct _cef_cookie_t* cookie, + int count, + int total, + int* deleteCookie); } cef_cookie_visitor_t; +/// +// Structure to implement to be notified of asynchronous completion via +// cef_cookie_manager_t::set_cookie(). +/// +typedef struct _cef_set_cookie_callback_t { + /// + // Base structure. + /// + cef_base_ref_counted_t base; + + /// + // Method that will be called upon completion. |success| will be true (1) if + // the cookie was set successfully. + /// + void(CEF_CALLBACK* on_complete)(struct _cef_set_cookie_callback_t* self, + int success); +} cef_set_cookie_callback_t; + +/// +// Structure to implement to be notified of asynchronous completion via +// cef_cookie_manager_t::delete_cookies(). +/// +typedef struct _cef_delete_cookies_callback_t { + /// + // Base structure. + /// + cef_base_ref_counted_t base; + + /// + // Method that will be called upon completion. |num_deleted| will be the + // number of cookies that were deleted or -1 if unknown. + /// + void(CEF_CALLBACK* on_complete)(struct _cef_delete_cookies_callback_t* self, + int num_deleted); +} cef_delete_cookies_callback_t; #ifdef __cplusplus } diff --git a/include/capi/cef_crash_util_capi.h b/include/capi/cef_crash_util_capi.h new file mode 100644 index 0000000..d52ecaa --- /dev/null +++ b/include/capi/cef_crash_util_capi.h @@ -0,0 +1,153 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=8b7354f5a1ad6b255d77e477c64374b927f4fe28$ +// + +#ifndef CEF_INCLUDE_CAPI_CEF_CRASH_UTIL_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_CRASH_UTIL_CAPI_H_ +#pragma once + +#include "include/capi/cef_base_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// Crash reporting is configured using an INI-style config file named +// "crash_reporter.cfg". On Windows and Linux this file must be placed next to +// the main application executable. On macOS this file must be placed in the +// top-level app bundle Resources directory (e.g. +// ".app/Contents/Resources"). File contents are as follows: +// +// # Comments start with a hash character and must be on their own line. +// +// [Config] +// ProductName= +// ProductVersion= +// AppName= +// ExternalHandler= +// BrowserCrashForwardingEnabled= +// ServerURL= +// RateLimitEnabled= +// MaxUploadsPerDay= +// MaxDatabaseSizeInMb= +// MaxDatabaseAgeInDays= +// +// [CrashKeys] +// my_key1= +// my_key2= +// +// Config section: +// +// If "ProductName" and/or "ProductVersion" are set then the specified values +// will be included in the crash dump metadata. On macOS if these values are set +// to NULL then they will be retrieved from the Info.plist file using the +// "CFBundleName" and "CFBundleShortVersionString" keys respectively. +// +// If "AppName" is set on Windows then crash report information (metrics, +// database and dumps) will be stored locally on disk under the +// "C:\Users\[CurrentUser]\AppData\Local\[AppName]\User Data" folder. On other +// platforms the CefSettings.user_data_path value will be used. +// +// If "ExternalHandler" is set on Windows then the specified exe will be +// launched as the crashpad-handler instead of re-launching the main process +// exe. The value can be an absolute path or a path relative to the main exe +// directory. On Linux the CefSettings.browser_subprocess_path value will be +// used. On macOS the existing subprocess app bundle will be used. +// +// If "BrowserCrashForwardingEnabled" is set to true (1) on macOS then browser +// process crashes will be forwarded to the system crash reporter. This results +// in the crash UI dialog being displayed to the user and crash reports being +// logged under "~/Library/Logs/DiagnosticReports". Forwarding of crash reports +// from non-browser processes and Debug builds is always disabled. +// +// If "ServerURL" is set then crashes will be uploaded as a multi-part POST +// request to the specified URL. Otherwise, reports will only be stored locally +// on disk. +// +// If "RateLimitEnabled" is set to true (1) then crash report uploads will be +// rate limited as follows: +// 1. If "MaxUploadsPerDay" is set to a positive value then at most the +// specified number of crashes will be uploaded in each 24 hour period. +// 2. If crash upload fails due to a network or server error then an +// incremental backoff delay up to a maximum of 24 hours will be applied for +// retries. +// 3. If a backoff delay is applied and "MaxUploadsPerDay" is > 1 then the +// "MaxUploadsPerDay" value will be reduced to 1 until the client is +// restarted. This helps to avoid an upload flood when the network or +// server error is resolved. +// Rate limiting is not supported on Linux. +// +// If "MaxDatabaseSizeInMb" is set to a positive value then crash report storage +// on disk will be limited to that size in megabytes. For example, on Windows +// each dump is about 600KB so a "MaxDatabaseSizeInMb" value of 20 equates to +// about 34 crash reports stored on disk. Not supported on Linux. +// +// If "MaxDatabaseAgeInDays" is set to a positive value then crash reports older +// than the specified age in days will be deleted. Not supported on Linux. +// +// CrashKeys section: +// +// Any number of crash keys can be specified for use by the application. Crash +// key values will be truncated based on the specified size (small = 63 bytes, +// medium = 252 bytes, large = 1008 bytes). The value of crash keys can be set +// from any thread or process using the CefSetCrashKeyValue function. These +// key/value pairs will be sent to the crash server along with the crash dump +// file. Medium and large values will be chunked for submission. For example, if +// your key is named "mykey" then the value will be broken into ordered chunks +// and submitted using keys named "mykey-1", "mykey-2", etc. +/// +CEF_EXPORT int cef_crash_reporting_enabled(); + +/// +// Sets or clears a specific key-value pair from the crash metadata. +/// +CEF_EXPORT void cef_set_crash_key_value(const cef_string_t* key, + const cef_string_t* value); + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_CRASH_UTIL_CAPI_H_ diff --git a/include/capi/cef_dialog_handler_capi.h b/include/capi/cef_dialog_handler_capi.h index dd3215c..35d33ea 100644 --- a/include/capi/cef_dialog_handler_capi.h +++ b/include/capi/cef_dialog_handler_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,18 +33,19 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=b8a44f4f624ba51107d06ff3d1a7934e83765786$ +// #ifndef CEF_INCLUDE_CAPI_CEF_DIALOG_HANDLER_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_DIALOG_HANDLER_CAPI_H_ #pragma once -#ifdef __cplusplus -extern "C" { -#endif - #include "include/capi/cef_base_capi.h" #include "include/capi/cef_browser_capi.h" +#ifdef __cplusplus +extern "C" { +#endif /// // Callback structure for asynchronous continuation of file dialog requests. @@ -53,23 +54,25 @@ typedef struct _cef_file_dialog_callback_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// - // Continue the file selection with the specified |file_paths|. This may be a - // single value or a list of values depending on the dialog mode. An NULL + // Continue the file selection. |selected_accept_filter| should be the 0-based + // index of the value selected from the accept filters array passed to + // cef_dialog_handler_t::OnFileDialog. |file_paths| should be a single value + // or a list of values depending on the dialog mode. An NULL |file_paths| // value is treated the same as calling cancel(). /// - void (CEF_CALLBACK *cont)(struct _cef_file_dialog_callback_t* self, - cef_string_list_t file_paths); + void(CEF_CALLBACK* cont)(struct _cef_file_dialog_callback_t* self, + int selected_accept_filter, + cef_string_list_t file_paths); /// // Cancel the file selection. /// - void (CEF_CALLBACK *cancel)(struct _cef_file_dialog_callback_t* self); + void(CEF_CALLBACK* cancel)(struct _cef_file_dialog_callback_t* self); } cef_file_dialog_callback_t; - /// // Implement this structure to handle dialog events. The functions of this // structure will be called on the browser process UI thread. @@ -78,27 +81,34 @@ typedef struct _cef_dialog_handler_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Called to run a file chooser dialog. |mode| represents the type of dialog // to display. |title| to the title to be used for the dialog and may be NULL // to show the default title ("Open" or "Save" depending on the mode). - // |default_file_name| is the default file name to select in the dialog. - // |accept_types| is a list of valid lower-cased MIME types or file extensions - // specified in an input element and is used to restrict selectable files to - // such types. To display a custom dialog return true (1) and execute - // |callback| either inline or at a later time. To display the default dialog - // return false (0). + // |default_file_path| is the path with optional directory and/or file name + // component that should be initially selected in the dialog. |accept_filters| + // are used to restrict the selectable file types and may any combination of + // (a) valid lower-cased MIME types (e.g. "text/*" or "image/*"), (b) + // individual file extensions (e.g. ".txt" or ".png"), or (c) combined + // description and file extension delimited using "|" and ";" (e.g. "Image + // Types|.png;.gif;.jpg"). |selected_accept_filter| is the 0-based index of + // the filter that should be selected by default. To display a custom dialog + // return true (1) and execute |callback| either inline or at a later time. To + // display the default dialog return false (0). /// - int (CEF_CALLBACK *on_file_dialog)(struct _cef_dialog_handler_t* self, - struct _cef_browser_t* browser, cef_file_dialog_mode_t mode, - const cef_string_t* title, const cef_string_t* default_file_name, - cef_string_list_t accept_types, + int(CEF_CALLBACK* on_file_dialog)( + struct _cef_dialog_handler_t* self, + struct _cef_browser_t* browser, + cef_file_dialog_mode_t mode, + const cef_string_t* title, + const cef_string_t* default_file_path, + cef_string_list_t accept_filters, + int selected_accept_filter, struct _cef_file_dialog_callback_t* callback); } cef_dialog_handler_t; - #ifdef __cplusplus } #endif diff --git a/include/capi/cef_display_handler_capi.h b/include/capi/cef_display_handler_capi.h index 9993d65..4a99076 100644 --- a/include/capi/cef_display_handler_capi.h +++ b/include/capi/cef_display_handler_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,19 +33,20 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=f0f3fd4cab00c0eb11956e674a111cb30d3af100$ +// #ifndef CEF_INCLUDE_CAPI_CEF_DISPLAY_HANDLER_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_DISPLAY_HANDLER_CAPI_H_ #pragma once -#ifdef __cplusplus -extern "C" { -#endif - #include "include/capi/cef_base_capi.h" #include "include/capi/cef_browser_capi.h" #include "include/capi/cef_frame_capi.h" +#ifdef __cplusplus +extern "C" { +#endif /// // Implement this structure to handle events related to browser display state. @@ -55,20 +56,41 @@ typedef struct _cef_display_handler_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Called when a frame's address has changed. /// - void (CEF_CALLBACK *on_address_change)(struct _cef_display_handler_t* self, - struct _cef_browser_t* browser, struct _cef_frame_t* frame, - const cef_string_t* url); + void(CEF_CALLBACK* on_address_change)(struct _cef_display_handler_t* self, + struct _cef_browser_t* browser, + struct _cef_frame_t* frame, + const cef_string_t* url); /// // Called when the page title changes. /// - void (CEF_CALLBACK *on_title_change)(struct _cef_display_handler_t* self, - struct _cef_browser_t* browser, const cef_string_t* title); + void(CEF_CALLBACK* on_title_change)(struct _cef_display_handler_t* self, + struct _cef_browser_t* browser, + const cef_string_t* title); + + /// + // Called when the page icon changes. + /// + void(CEF_CALLBACK* on_favicon_urlchange)(struct _cef_display_handler_t* self, + struct _cef_browser_t* browser, + cef_string_list_t icon_urls); + + /// + // Called when web content in the page has toggled fullscreen mode. If + // |fullscreen| is true (1) the content will automatically be sized to fill + // the browser content area. If |fullscreen| is false (0) the content will + // automatically return to its original size and position. The client is + // responsible for resizing the browser if desired. + /// + void(CEF_CALLBACK* on_fullscreen_mode_change)( + struct _cef_display_handler_t* self, + struct _cef_browser_t* browser, + int fullscreen); /// // Called when the browser is about to display a tooltip. |text| contains the @@ -78,27 +100,29 @@ typedef struct _cef_display_handler_t { // tooltip. When window rendering is disabled the application is responsible // for drawing tooltips and the return value is ignored. /// - int (CEF_CALLBACK *on_tooltip)(struct _cef_display_handler_t* self, - struct _cef_browser_t* browser, cef_string_t* text); + int(CEF_CALLBACK* on_tooltip)(struct _cef_display_handler_t* self, + struct _cef_browser_t* browser, + cef_string_t* text); /// - // Called when the browser receives a status message. |text| contains the text - // that will be displayed in the status message and |type| indicates the - // status message type. + // Called when the browser receives a status message. |value| contains the + // text that will be displayed in the status message. /// - void (CEF_CALLBACK *on_status_message)(struct _cef_display_handler_t* self, - struct _cef_browser_t* browser, const cef_string_t* value); + void(CEF_CALLBACK* on_status_message)(struct _cef_display_handler_t* self, + struct _cef_browser_t* browser, + const cef_string_t* value); /// // Called to display a console message. Return true (1) to stop the message // from being output to the console. /// - int (CEF_CALLBACK *on_console_message)(struct _cef_display_handler_t* self, - struct _cef_browser_t* browser, const cef_string_t* message, - const cef_string_t* source, int line); + int(CEF_CALLBACK* on_console_message)(struct _cef_display_handler_t* self, + struct _cef_browser_t* browser, + const cef_string_t* message, + const cef_string_t* source, + int line); } cef_display_handler_t; - #ifdef __cplusplus } #endif diff --git a/include/capi/cef_dom_capi.h b/include/capi/cef_dom_capi.h index 9f00a86..3ed6f7e 100644 --- a/include/capi/cef_dom_capi.h +++ b/include/capi/cef_dom_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,19 +33,20 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=db82ff508cb1b4a03001b8b30bc5126186ee1bd2$ +// #ifndef CEF_INCLUDE_CAPI_CEF_DOM_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_DOM_CAPI_H_ #pragma once +#include "include/capi/cef_base_capi.h" + #ifdef __cplusplus extern "C" { #endif -#include "include/capi/cef_base_capi.h" - struct _cef_domdocument_t; -struct _cef_domevent_listener_t; struct _cef_domnode_t; /// @@ -56,7 +57,7 @@ typedef struct _cef_domvisitor_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Method executed for visiting the DOM. The document object passed to this @@ -65,11 +66,10 @@ typedef struct _cef_domvisitor_t { // keep references to or attempt to access any DOM objects outside the scope // of this function. /// - void (CEF_CALLBACK *visit)(struct _cef_domvisitor_t* self, - struct _cef_domdocument_t* document); + void(CEF_CALLBACK* visit)(struct _cef_domvisitor_t* self, + struct _cef_domdocument_t* document); } cef_domvisitor_t; - /// // Structure used to represent a DOM document. The functions of this structure // should only be called on the render process main thread thread. @@ -78,98 +78,87 @@ typedef struct _cef_domdocument_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Returns the document type. /// - cef_dom_document_type_t (CEF_CALLBACK *get_type)( + cef_dom_document_type_t(CEF_CALLBACK* get_type)( struct _cef_domdocument_t* self); /// // Returns the root document node. /// - struct _cef_domnode_t* (CEF_CALLBACK *get_document)( + struct _cef_domnode_t*(CEF_CALLBACK* get_document)( struct _cef_domdocument_t* self); /// // Returns the BODY node of an HTML document. /// - struct _cef_domnode_t* (CEF_CALLBACK *get_body)( + struct _cef_domnode_t*(CEF_CALLBACK* get_body)( struct _cef_domdocument_t* self); /// // Returns the HEAD node of an HTML document. /// - struct _cef_domnode_t* (CEF_CALLBACK *get_head)( + struct _cef_domnode_t*(CEF_CALLBACK* get_head)( struct _cef_domdocument_t* self); /// // Returns the title of an HTML document. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_title)( + cef_string_userfree_t(CEF_CALLBACK* get_title)( struct _cef_domdocument_t* self); /// // Returns the document element with the specified ID value. /// - struct _cef_domnode_t* (CEF_CALLBACK *get_element_by_id)( - struct _cef_domdocument_t* self, const cef_string_t* id); + struct _cef_domnode_t*(CEF_CALLBACK* get_element_by_id)( + struct _cef_domdocument_t* self, + const cef_string_t* id); /// // Returns the node that currently has keyboard focus. /// - struct _cef_domnode_t* (CEF_CALLBACK *get_focused_node)( + struct _cef_domnode_t*(CEF_CALLBACK* get_focused_node)( struct _cef_domdocument_t* self); /// // Returns true (1) if a portion of the document is selected. /// - int (CEF_CALLBACK *has_selection)(struct _cef_domdocument_t* self); - - /// - // Returns the selection start node. - /// - struct _cef_domnode_t* (CEF_CALLBACK *get_selection_start_node)( - struct _cef_domdocument_t* self); + int(CEF_CALLBACK* has_selection)(struct _cef_domdocument_t* self); /// // Returns the selection offset within the start node. /// - int (CEF_CALLBACK *get_selection_start_offset)( - struct _cef_domdocument_t* self); - - /// - // Returns the selection end node. - /// - struct _cef_domnode_t* (CEF_CALLBACK *get_selection_end_node)( + int(CEF_CALLBACK* get_selection_start_offset)( struct _cef_domdocument_t* self); /// // Returns the selection offset within the end node. /// - int (CEF_CALLBACK *get_selection_end_offset)(struct _cef_domdocument_t* self); + int(CEF_CALLBACK* get_selection_end_offset)(struct _cef_domdocument_t* self); /// // Returns the contents of this selection as markup. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_selection_as_markup)( + cef_string_userfree_t(CEF_CALLBACK* get_selection_as_markup)( struct _cef_domdocument_t* self); /// // Returns the contents of this selection as text. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_selection_as_text)( + cef_string_userfree_t(CEF_CALLBACK* get_selection_as_text)( struct _cef_domdocument_t* self); /// // Returns the base URL for the document. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_base_url)( + cef_string_userfree_t(CEF_CALLBACK* get_base_url)( struct _cef_domdocument_t* self); /// @@ -177,11 +166,11 @@ typedef struct _cef_domdocument_t { // partial URL. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_complete_url)( - struct _cef_domdocument_t* self, const cef_string_t* partialURL); + cef_string_userfree_t(CEF_CALLBACK* get_complete_url)( + struct _cef_domdocument_t* self, + const cef_string_t* partialURL); } cef_domdocument_t; - /// // Structure used to represent a DOM node. The functions of this structure // should only be called on the render process main thread. @@ -190,255 +179,166 @@ typedef struct _cef_domnode_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Returns the type for this node. /// - cef_dom_node_type_t (CEF_CALLBACK *get_type)(struct _cef_domnode_t* self); + cef_dom_node_type_t(CEF_CALLBACK* get_type)(struct _cef_domnode_t* self); /// // Returns true (1) if this is a text node. /// - int (CEF_CALLBACK *is_text)(struct _cef_domnode_t* self); + int(CEF_CALLBACK* is_text)(struct _cef_domnode_t* self); /// // Returns true (1) if this is an element node. /// - int (CEF_CALLBACK *is_element)(struct _cef_domnode_t* self); + int(CEF_CALLBACK* is_element)(struct _cef_domnode_t* self); /// // Returns true (1) if this is an editable node. /// - int (CEF_CALLBACK *is_editable)(struct _cef_domnode_t* self); + int(CEF_CALLBACK* is_editable)(struct _cef_domnode_t* self); /// // Returns true (1) if this is a form control element node. /// - int (CEF_CALLBACK *is_form_control_element)(struct _cef_domnode_t* self); + int(CEF_CALLBACK* is_form_control_element)(struct _cef_domnode_t* self); /// // Returns the type of this form control element node. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_form_control_element_type)( + cef_string_userfree_t(CEF_CALLBACK* get_form_control_element_type)( struct _cef_domnode_t* self); /// // Returns true (1) if this object is pointing to the same handle as |that| // object. /// - int (CEF_CALLBACK *is_same)(struct _cef_domnode_t* self, - struct _cef_domnode_t* that); + int(CEF_CALLBACK* is_same)(struct _cef_domnode_t* self, + struct _cef_domnode_t* that); /// // Returns the name of this node. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_name)(struct _cef_domnode_t* self); + cef_string_userfree_t(CEF_CALLBACK* get_name)(struct _cef_domnode_t* self); /// // Returns the value of this node. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_value)(struct _cef_domnode_t* self); + cef_string_userfree_t(CEF_CALLBACK* get_value)(struct _cef_domnode_t* self); /// // Set the value of this node. Returns true (1) on success. /// - int (CEF_CALLBACK *set_value)(struct _cef_domnode_t* self, - const cef_string_t* value); + int(CEF_CALLBACK* set_value)(struct _cef_domnode_t* self, + const cef_string_t* value); /// // Returns the contents of this node as markup. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_as_markup)( + cef_string_userfree_t(CEF_CALLBACK* get_as_markup)( struct _cef_domnode_t* self); /// // Returns the document associated with this node. /// - struct _cef_domdocument_t* (CEF_CALLBACK *get_document)( + struct _cef_domdocument_t*(CEF_CALLBACK* get_document)( struct _cef_domnode_t* self); /// // Returns the parent node. /// - struct _cef_domnode_t* (CEF_CALLBACK *get_parent)( - struct _cef_domnode_t* self); + struct _cef_domnode_t*(CEF_CALLBACK* get_parent)(struct _cef_domnode_t* self); /// // Returns the previous sibling node. /// - struct _cef_domnode_t* (CEF_CALLBACK *get_previous_sibling)( + struct _cef_domnode_t*(CEF_CALLBACK* get_previous_sibling)( struct _cef_domnode_t* self); /// // Returns the next sibling node. /// - struct _cef_domnode_t* (CEF_CALLBACK *get_next_sibling)( + struct _cef_domnode_t*(CEF_CALLBACK* get_next_sibling)( struct _cef_domnode_t* self); /// // Returns true (1) if this node has child nodes. /// - int (CEF_CALLBACK *has_children)(struct _cef_domnode_t* self); + int(CEF_CALLBACK* has_children)(struct _cef_domnode_t* self); /// // Return the first child node. /// - struct _cef_domnode_t* (CEF_CALLBACK *get_first_child)( + struct _cef_domnode_t*(CEF_CALLBACK* get_first_child)( struct _cef_domnode_t* self); /// // Returns the last child node. /// - struct _cef_domnode_t* (CEF_CALLBACK *get_last_child)( + struct _cef_domnode_t*(CEF_CALLBACK* get_last_child)( struct _cef_domnode_t* self); - /// - // Add an event listener to this node for the specified event type. If - // |useCapture| is true (1) then this listener will be considered a capturing - // listener. Capturing listeners will recieve all events of the specified type - // before the events are dispatched to any other event targets beneath the - // current node in the tree. Events which are bubbling upwards through the - // tree will not trigger a capturing listener. Separate calls to this function - // can be used to register the same listener with and without capture. See - // WebCore/dom/EventNames.h for the list of supported event types. - /// - void (CEF_CALLBACK *add_event_listener)(struct _cef_domnode_t* self, - const cef_string_t* eventType, struct _cef_domevent_listener_t* listener, - int useCapture); - - // The following functions are valid only for element nodes. /// // Returns the tag name of this element. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_element_tag_name)( + cef_string_userfree_t(CEF_CALLBACK* get_element_tag_name)( struct _cef_domnode_t* self); /// // Returns true (1) if this element has attributes. /// - int (CEF_CALLBACK *has_element_attributes)(struct _cef_domnode_t* self); + int(CEF_CALLBACK* has_element_attributes)(struct _cef_domnode_t* self); /// // Returns true (1) if this element has an attribute named |attrName|. /// - int (CEF_CALLBACK *has_element_attribute)(struct _cef_domnode_t* self, - const cef_string_t* attrName); + int(CEF_CALLBACK* has_element_attribute)(struct _cef_domnode_t* self, + const cef_string_t* attrName); /// // Returns the element attribute named |attrName|. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_element_attribute)( - struct _cef_domnode_t* self, const cef_string_t* attrName); + cef_string_userfree_t(CEF_CALLBACK* get_element_attribute)( + struct _cef_domnode_t* self, + const cef_string_t* attrName); /// // Returns a map of all element attributes. /// - void (CEF_CALLBACK *get_element_attributes)(struct _cef_domnode_t* self, - cef_string_map_t attrMap); + void(CEF_CALLBACK* get_element_attributes)(struct _cef_domnode_t* self, + cef_string_map_t attrMap); /// // Set the value for the element attribute named |attrName|. Returns true (1) // on success. /// - int (CEF_CALLBACK *set_element_attribute)(struct _cef_domnode_t* self, - const cef_string_t* attrName, const cef_string_t* value); + int(CEF_CALLBACK* set_element_attribute)(struct _cef_domnode_t* self, + const cef_string_t* attrName, + const cef_string_t* value); /// // Returns the inner text of the element. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_element_inner_text)( + cef_string_userfree_t(CEF_CALLBACK* get_element_inner_text)( struct _cef_domnode_t* self); -} cef_domnode_t; - - -/// -// Structure used to represent a DOM event. The functions of this structure -// should only be called on the render process main thread. -/// -typedef struct _cef_domevent_t { - /// - // Base structure. - /// - cef_base_t base; /// - // Returns the event type. + // Returns the bounds of the element. /// - // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_type)(struct _cef_domevent_t* self); - - /// - // Returns the event category. - /// - cef_dom_event_category_t (CEF_CALLBACK *get_category)( - struct _cef_domevent_t* self); - - /// - // Returns the event processing phase. - /// - cef_dom_event_phase_t (CEF_CALLBACK *get_phase)(struct _cef_domevent_t* self); - - /// - // Returns true (1) if the event can bubble up the tree. - /// - int (CEF_CALLBACK *can_bubble)(struct _cef_domevent_t* self); - - /// - // Returns true (1) if the event can be canceled. - /// - int (CEF_CALLBACK *can_cancel)(struct _cef_domevent_t* self); - - /// - // Returns the document associated with this event. - /// - struct _cef_domdocument_t* (CEF_CALLBACK *get_document)( - struct _cef_domevent_t* self); - - /// - // Returns the target of the event. - /// - struct _cef_domnode_t* (CEF_CALLBACK *get_target)( - struct _cef_domevent_t* self); - - /// - // Returns the current target of the event. - /// - struct _cef_domnode_t* (CEF_CALLBACK *get_current_target)( - struct _cef_domevent_t* self); -} cef_domevent_t; - - -/// -// Structure to implement for handling DOM events. The functions of this -// structure will be called on the render process main thread. -/// -typedef struct _cef_domevent_listener_t { - /// - // Base structure. - /// - cef_base_t base; - - /// - // Called when an event is received. The event object passed to this function - // contains a snapshot of the DOM at the time this function is executed. DOM - // objects are only valid for the scope of this function. Do not keep - // references to or attempt to access any DOM objects outside the scope of - // this function. - /// - void (CEF_CALLBACK *handle_event)(struct _cef_domevent_listener_t* self, - struct _cef_domevent_t* event); -} cef_domevent_listener_t; - + cef_rect_t(CEF_CALLBACK* get_element_bounds)(struct _cef_domnode_t* self); +} cef_domnode_t; #ifdef __cplusplus } diff --git a/include/capi/cef_download_handler_capi.h b/include/capi/cef_download_handler_capi.h index 35a4242..f247a6c 100644 --- a/include/capi/cef_download_handler_capi.h +++ b/include/capi/cef_download_handler_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,19 +33,20 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=4475f7e48898bdef8051c849873fb2528320cd9c$ +// #ifndef CEF_INCLUDE_CAPI_CEF_DOWNLOAD_HANDLER_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_DOWNLOAD_HANDLER_CAPI_H_ #pragma once -#ifdef __cplusplus -extern "C" { -#endif - #include "include/capi/cef_base_capi.h" #include "include/capi/cef_browser_capi.h" #include "include/capi/cef_download_item_capi.h" +#ifdef __cplusplus +extern "C" { +#endif /// // Callback structure used to asynchronously continue a download. @@ -54,7 +55,7 @@ typedef struct _cef_before_download_callback_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Call to continue the download. Set |download_path| to the full file path @@ -62,11 +63,11 @@ typedef struct _cef_before_download_callback_t { // suggested name and the default temp directory. Set |show_dialog| to true // (1) if you do wish to show the default "Save As" dialog. /// - void (CEF_CALLBACK *cont)(struct _cef_before_download_callback_t* self, - const cef_string_t* download_path, int show_dialog); + void(CEF_CALLBACK* cont)(struct _cef_before_download_callback_t* self, + const cef_string_t* download_path, + int show_dialog); } cef_before_download_callback_t; - /// // Callback structure used to asynchronously cancel a download. /// @@ -74,14 +75,23 @@ typedef struct _cef_download_item_callback_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Call to cancel the download. /// - void (CEF_CALLBACK *cancel)(struct _cef_download_item_callback_t* self); -} cef_download_item_callback_t; + void(CEF_CALLBACK* cancel)(struct _cef_download_item_callback_t* self); + + /// + // Call to pause the download. + /// + void(CEF_CALLBACK* pause)(struct _cef_download_item_callback_t* self); + /// + // Call to resume the download. + /// + void(CEF_CALLBACK* resume)(struct _cef_download_item_callback_t* self); +} cef_download_item_callback_t; /// // Structure used to handle file downloads. The functions of this structure will @@ -91,7 +101,7 @@ typedef struct _cef_download_handler_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Called before a download begins. |suggested_name| is the suggested name for @@ -100,7 +110,8 @@ typedef struct _cef_download_handler_t { // download if desired. Do not keep a reference to |download_item| outside of // this function. /// - void (CEF_CALLBACK *on_before_download)(struct _cef_download_handler_t* self, + void(CEF_CALLBACK* on_before_download)( + struct _cef_download_handler_t* self, struct _cef_browser_t* browser, struct _cef_download_item_t* download_item, const cef_string_t* suggested_name, @@ -113,13 +124,13 @@ typedef struct _cef_download_handler_t { // download if desired. Do not keep a reference to |download_item| outside of // this function. /// - void (CEF_CALLBACK *on_download_updated)(struct _cef_download_handler_t* self, + void(CEF_CALLBACK* on_download_updated)( + struct _cef_download_handler_t* self, struct _cef_browser_t* browser, struct _cef_download_item_t* download_item, struct _cef_download_item_callback_t* callback); } cef_download_handler_t; - #ifdef __cplusplus } #endif diff --git a/include/capi/cef_download_item_capi.h b/include/capi/cef_download_item_capi.h index 239ee29..afeae31 100644 --- a/include/capi/cef_download_item_capi.h +++ b/include/capi/cef_download_item_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,18 +33,19 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=cc669703d613f5a6a5bae95030835dc99f55a6fa$ +// #ifndef CEF_INCLUDE_CAPI_CEF_DOWNLOAD_ITEM_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_DOWNLOAD_ITEM_CAPI_H_ #pragma once +#include "include/capi/cef_base_capi.h" + #ifdef __cplusplus extern "C" { #endif -#include "include/capi/cef_base_capi.h" - - /// // Structure used to represent a download item. /// @@ -52,102 +53,108 @@ typedef struct _cef_download_item_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Returns true (1) if this object is valid. Do not call any other functions // if this function returns false (0). /// - int (CEF_CALLBACK *is_valid)(struct _cef_download_item_t* self); + int(CEF_CALLBACK* is_valid)(struct _cef_download_item_t* self); /// // Returns true (1) if the download is in progress. /// - int (CEF_CALLBACK *is_in_progress)(struct _cef_download_item_t* self); + int(CEF_CALLBACK* is_in_progress)(struct _cef_download_item_t* self); /// // Returns true (1) if the download is complete. /// - int (CEF_CALLBACK *is_complete)(struct _cef_download_item_t* self); + int(CEF_CALLBACK* is_complete)(struct _cef_download_item_t* self); /// // Returns true (1) if the download has been canceled or interrupted. /// - int (CEF_CALLBACK *is_canceled)(struct _cef_download_item_t* self); + int(CEF_CALLBACK* is_canceled)(struct _cef_download_item_t* self); /// // Returns a simple speed estimate in bytes/s. /// - int64 (CEF_CALLBACK *get_current_speed)(struct _cef_download_item_t* self); + int64(CEF_CALLBACK* get_current_speed)(struct _cef_download_item_t* self); /// // Returns the rough percent complete or -1 if the receive total size is // unknown. /// - int (CEF_CALLBACK *get_percent_complete)(struct _cef_download_item_t* self); + int(CEF_CALLBACK* get_percent_complete)(struct _cef_download_item_t* self); /// // Returns the total number of bytes. /// - int64 (CEF_CALLBACK *get_total_bytes)(struct _cef_download_item_t* self); + int64(CEF_CALLBACK* get_total_bytes)(struct _cef_download_item_t* self); /// // Returns the number of received bytes. /// - int64 (CEF_CALLBACK *get_received_bytes)(struct _cef_download_item_t* self); + int64(CEF_CALLBACK* get_received_bytes)(struct _cef_download_item_t* self); /// // Returns the time that the download started. /// - cef_time_t (CEF_CALLBACK *get_start_time)(struct _cef_download_item_t* self); + cef_time_t(CEF_CALLBACK* get_start_time)(struct _cef_download_item_t* self); /// // Returns the time that the download ended. /// - cef_time_t (CEF_CALLBACK *get_end_time)(struct _cef_download_item_t* self); + cef_time_t(CEF_CALLBACK* get_end_time)(struct _cef_download_item_t* self); /// // Returns the full path to the downloaded or downloading file. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_full_path)( + cef_string_userfree_t(CEF_CALLBACK* get_full_path)( struct _cef_download_item_t* self); /// // Returns the unique identifier for this download. /// - uint32 (CEF_CALLBACK *get_id)(struct _cef_download_item_t* self); + uint32(CEF_CALLBACK* get_id)(struct _cef_download_item_t* self); /// // Returns the URL. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_url)( + cef_string_userfree_t(CEF_CALLBACK* get_url)( + struct _cef_download_item_t* self); + + /// + // Returns the original URL before any redirections. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t(CEF_CALLBACK* get_original_url)( struct _cef_download_item_t* self); /// // Returns the suggested file name. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_suggested_file_name)( + cef_string_userfree_t(CEF_CALLBACK* get_suggested_file_name)( struct _cef_download_item_t* self); /// // Returns the content disposition. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_content_disposition)( + cef_string_userfree_t(CEF_CALLBACK* get_content_disposition)( struct _cef_download_item_t* self); /// // Returns the mime type. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_mime_type)( + cef_string_userfree_t(CEF_CALLBACK* get_mime_type)( struct _cef_download_item_t* self); } cef_download_item_t; - #ifdef __cplusplus } #endif diff --git a/include/capi/cef_drag_data_capi.h b/include/capi/cef_drag_data_capi.h index 6daa1a2..7381acb 100644 --- a/include/capi/cef_drag_data_capi.h +++ b/include/capi/cef_drag_data_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,18 +33,21 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=a4b5264c1e685cad86203772631460684ee7820d$ +// #ifndef CEF_INCLUDE_CAPI_CEF_DRAG_DATA_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_DRAG_DATA_CAPI_H_ #pragma once +#include "include/capi/cef_base_capi.h" +#include "include/capi/cef_image_capi.h" +#include "include/capi/cef_stream_capi.h" + #ifdef __cplusplus extern "C" { #endif -#include "include/capi/cef_base_capi.h" - - /// // Structure used to represent drag data. The functions of this structure may be // called on any thread. @@ -53,56 +56,66 @@ typedef struct _cef_drag_data_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; + + /// + // Returns a copy of the current object. + /// + struct _cef_drag_data_t*(CEF_CALLBACK* clone)(struct _cef_drag_data_t* self); + + /// + // Returns true (1) if this object is read-only. + /// + int(CEF_CALLBACK* is_read_only)(struct _cef_drag_data_t* self); /// // Returns true (1) if the drag data is a link. /// - int (CEF_CALLBACK *is_link)(struct _cef_drag_data_t* self); + int(CEF_CALLBACK* is_link)(struct _cef_drag_data_t* self); /// // Returns true (1) if the drag data is a text or html fragment. /// - int (CEF_CALLBACK *is_fragment)(struct _cef_drag_data_t* self); + int(CEF_CALLBACK* is_fragment)(struct _cef_drag_data_t* self); /// // Returns true (1) if the drag data is a file. /// - int (CEF_CALLBACK *is_file)(struct _cef_drag_data_t* self); + int(CEF_CALLBACK* is_file)(struct _cef_drag_data_t* self); /// // Return the link URL that is being dragged. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_link_url)( + cef_string_userfree_t(CEF_CALLBACK* get_link_url)( struct _cef_drag_data_t* self); /// // Return the title associated with the link being dragged. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_link_title)( + cef_string_userfree_t(CEF_CALLBACK* get_link_title)( struct _cef_drag_data_t* self); /// // Return the metadata, if any, associated with the link being dragged. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_link_metadata)( + cef_string_userfree_t(CEF_CALLBACK* get_link_metadata)( struct _cef_drag_data_t* self); /// // Return the plain text fragment that is being dragged. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_fragment_text)( + cef_string_userfree_t(CEF_CALLBACK* get_fragment_text)( struct _cef_drag_data_t* self); /// // Return the text/html fragment that is being dragged. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_fragment_html)( + cef_string_userfree_t(CEF_CALLBACK* get_fragment_html)( struct _cef_drag_data_t* self); /// @@ -110,24 +123,103 @@ typedef struct _cef_drag_data_t { // resolving relative URLs and may be NULL. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_fragment_base_url)( + cef_string_userfree_t(CEF_CALLBACK* get_fragment_base_url)( struct _cef_drag_data_t* self); /// // Return the name of the file being dragged out of the browser window. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_file_name)( + cef_string_userfree_t(CEF_CALLBACK* get_file_name)( struct _cef_drag_data_t* self); + /// + // Write the contents of the file being dragged out of the web view into + // |writer|. Returns the number of bytes sent to |writer|. If |writer| is NULL + // this function will return the size of the file contents in bytes. Call + // get_file_name() to get a suggested name for the file. + /// + size_t(CEF_CALLBACK* get_file_contents)(struct _cef_drag_data_t* self, + struct _cef_stream_writer_t* writer); + /// // Retrieve the list of file names that are being dragged into the browser // window. /// - int (CEF_CALLBACK *get_file_names)(struct _cef_drag_data_t* self, - cef_string_list_t names); + int(CEF_CALLBACK* get_file_names)(struct _cef_drag_data_t* self, + cef_string_list_t names); + + /// + // Set the link URL that is being dragged. + /// + void(CEF_CALLBACK* set_link_url)(struct _cef_drag_data_t* self, + const cef_string_t* url); + + /// + // Set the title associated with the link being dragged. + /// + void(CEF_CALLBACK* set_link_title)(struct _cef_drag_data_t* self, + const cef_string_t* title); + + /// + // Set the metadata associated with the link being dragged. + /// + void(CEF_CALLBACK* set_link_metadata)(struct _cef_drag_data_t* self, + const cef_string_t* data); + + /// + // Set the plain text fragment that is being dragged. + /// + void(CEF_CALLBACK* set_fragment_text)(struct _cef_drag_data_t* self, + const cef_string_t* text); + + /// + // Set the text/html fragment that is being dragged. + /// + void(CEF_CALLBACK* set_fragment_html)(struct _cef_drag_data_t* self, + const cef_string_t* html); + + /// + // Set the base URL that the fragment came from. + /// + void(CEF_CALLBACK* set_fragment_base_url)(struct _cef_drag_data_t* self, + const cef_string_t* base_url); + + /// + // Reset the file contents. You should do this before calling + // cef_browser_host_t::DragTargetDragEnter as the web view does not allow us + // to drag in this kind of data. + /// + void(CEF_CALLBACK* reset_file_contents)(struct _cef_drag_data_t* self); + + /// + // Add a file that is being dragged into the webview. + /// + void(CEF_CALLBACK* add_file)(struct _cef_drag_data_t* self, + const cef_string_t* path, + const cef_string_t* display_name); + + /// + // Get the image representation of drag data. May return NULL if no image + // representation is available. + /// + struct _cef_image_t*(CEF_CALLBACK* get_image)(struct _cef_drag_data_t* self); + + /// + // Get the image hotspot (drag start location relative to image dimensions). + /// + cef_point_t(CEF_CALLBACK* get_image_hotspot)(struct _cef_drag_data_t* self); + + /// + // Returns true (1) if an image representation of drag data is available. + /// + int(CEF_CALLBACK* has_image)(struct _cef_drag_data_t* self); } cef_drag_data_t; +/// +// Create a new cef_drag_data_t object. +/// +CEF_EXPORT cef_drag_data_t* cef_drag_data_create(); #ifdef __cplusplus } diff --git a/include/capi/cef_drag_handler_capi.h b/include/capi/cef_drag_handler_capi.h index d3ef55a..3893d0b 100644 --- a/include/capi/cef_drag_handler_capi.h +++ b/include/capi/cef_drag_handler_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,19 +33,20 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=c557dad9522f4bd4c6b3295d149c6b893fc18d52$ +// #ifndef CEF_INCLUDE_CAPI_CEF_DRAG_HANDLER_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_DRAG_HANDLER_CAPI_H_ #pragma once -#ifdef __cplusplus -extern "C" { -#endif - #include "include/capi/cef_base_capi.h" #include "include/capi/cef_browser_capi.h" #include "include/capi/cef_drag_data_capi.h" +#ifdef __cplusplus +extern "C" { +#endif /// // Implement this structure to handle events related to dragging. The functions @@ -55,7 +56,7 @@ typedef struct _cef_drag_handler_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Called when an external drag event enters the browser window. |dragData| @@ -63,11 +64,24 @@ typedef struct _cef_drag_handler_t { // operation. Return false (0) for default drag handling behavior or true (1) // to cancel the drag event. /// - int (CEF_CALLBACK *on_drag_enter)(struct _cef_drag_handler_t* self, - struct _cef_browser_t* browser, struct _cef_drag_data_t* dragData, - cef_drag_operations_mask_t mask); -} cef_drag_handler_t; + int(CEF_CALLBACK* on_drag_enter)(struct _cef_drag_handler_t* self, + struct _cef_browser_t* browser, + struct _cef_drag_data_t* dragData, + cef_drag_operations_mask_t mask); + /// + // Called whenever draggable regions for the browser window change. These can + // be specified using the '-webkit-app-region: drag/no-drag' CSS-property. If + // draggable regions are never defined in a document this function will also + // never be called. If the last draggable region is removed from a document + // this function will be called with an NULL vector. + /// + void(CEF_CALLBACK* on_draggable_regions_changed)( + struct _cef_drag_handler_t* self, + struct _cef_browser_t* browser, + size_t regionsCount, + cef_draggable_region_t const* regions); +} cef_drag_handler_t; #ifdef __cplusplus } diff --git a/include/capi/cef_file_util_capi.h b/include/capi/cef_file_util_capi.h new file mode 100644 index 0000000..4602492 --- /dev/null +++ b/include/capi/cef_file_util_capi.h @@ -0,0 +1,121 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=4601edefadfafea031f2c5df498262fc2142252b$ +// + +#ifndef CEF_INCLUDE_CAPI_CEF_FILE_UTIL_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_FILE_UTIL_CAPI_H_ +#pragma once + +#include "include/capi/cef_base_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// Creates a directory and all parent directories if they don't already exist. +// Returns true (1) on successful creation or if the directory already exists. +// The directory is only readable by the current user. Calling this function on +// the browser process UI or IO threads is not allowed. +/// +CEF_EXPORT int cef_create_directory(const cef_string_t* full_path); + +/// +// Get the temporary directory provided by the system. +// +// WARNING: In general, you should use the temp directory variants below instead +// of this function. Those variants will ensure that the proper permissions are +// set so that other users on the system can't edit them while they're open +// (which could lead to security issues). +/// +CEF_EXPORT int cef_get_temp_directory(cef_string_t* temp_dir); + +/// +// Creates a new directory. On Windows if |prefix| is provided the new directory +// name is in the format of "prefixyyyy". Returns true (1) on success and sets +// |new_temp_path| to the full path of the directory that was created. The +// directory is only readable by the current user. Calling this function on the +// browser process UI or IO threads is not allowed. +/// +CEF_EXPORT int cef_create_new_temp_directory(const cef_string_t* prefix, + cef_string_t* new_temp_path); + +/// +// Creates a directory within another directory. Extra characters will be +// appended to |prefix| to ensure that the new directory does not have the same +// name as an existing directory. Returns true (1) on success and sets |new_dir| +// to the full path of the directory that was created. The directory is only +// readable by the current user. Calling this function on the browser process UI +// or IO threads is not allowed. +/// +CEF_EXPORT int cef_create_temp_directory_in_directory( + const cef_string_t* base_dir, + const cef_string_t* prefix, + cef_string_t* new_dir); + +/// +// Returns true (1) if the given path exists and is a directory. Calling this +// function on the browser process UI or IO threads is not allowed. +/// +CEF_EXPORT int cef_directory_exists(const cef_string_t* path); + +/// +// Deletes the given path whether it's a file or a directory. If |path| is a +// directory all contents will be deleted. If |recursive| is true (1) any sub- +// directories and their contents will also be deleted (equivalent to executing +// "rm -rf", so use with caution). On POSIX environments if |path| is a symbolic +// link then only the symlink will be deleted. Returns true (1) on successful +// deletion or if |path| does not exist. Calling this function on the browser +// process UI or IO threads is not allowed. +/// +CEF_EXPORT int cef_delete_file(const cef_string_t* path, int recursive); + +/// +// Writes the contents of |src_dir| into a zip archive at |dest_file|. If +// |include_hidden_files| is true (1) files starting with "." will be included. +// Returns true (1) on success. Calling this function on the browser process UI +// or IO threads is not allowed. +/// +CEF_EXPORT int cef_zip_directory(const cef_string_t* src_dir, + const cef_string_t* dest_file, + int include_hidden_files); + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_FILE_UTIL_CAPI_H_ diff --git a/include/capi/cef_find_handler_capi.h b/include/capi/cef_find_handler_capi.h new file mode 100644 index 0000000..892d5ea --- /dev/null +++ b/include/capi/cef_find_handler_capi.h @@ -0,0 +1,81 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=975114b079fa271fecbf31ef160974941faed8a4$ +// + +#ifndef CEF_INCLUDE_CAPI_CEF_FIND_HANDLER_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_FIND_HANDLER_CAPI_H_ +#pragma once + +#include "include/capi/cef_base_capi.h" +#include "include/capi/cef_browser_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// Implement this structure to handle events related to find results. The +// functions of this structure will be called on the UI thread. +/// +typedef struct _cef_find_handler_t { + /// + // Base structure. + /// + cef_base_ref_counted_t base; + + /// + // Called to report find results returned by cef_browser_host_t::find(). + // |identifer| is the identifier passed to find(), |count| is the number of + // matches currently identified, |selectionRect| is the location of where the + // match was found (in window coordinates), |activeMatchOrdinal| is the + // current position in the search results, and |finalUpdate| is true (1) if + // this is the last find notification. + /// + void(CEF_CALLBACK* on_find_result)(struct _cef_find_handler_t* self, + struct _cef_browser_t* browser, + int identifier, + int count, + const cef_rect_t* selectionRect, + int activeMatchOrdinal, + int finalUpdate); +} cef_find_handler_t; + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_FIND_HANDLER_CAPI_H_ diff --git a/include/capi/cef_focus_handler_capi.h b/include/capi/cef_focus_handler_capi.h index 16f3aa7..896e0c6 100644 --- a/include/capi/cef_focus_handler_capi.h +++ b/include/capi/cef_focus_handler_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,20 +33,21 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=bed1f7b94e060b83e3f22eb84ce1274f2d10b3e6$ +// #ifndef CEF_INCLUDE_CAPI_CEF_FOCUS_HANDLER_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_FOCUS_HANDLER_CAPI_H_ #pragma once -#ifdef __cplusplus -extern "C" { -#endif - #include "include/capi/cef_base_capi.h" #include "include/capi/cef_browser_capi.h" #include "include/capi/cef_dom_capi.h" #include "include/capi/cef_frame_capi.h" +#ifdef __cplusplus +extern "C" { +#endif /// // Implement this structure to handle events related to focus. The functions of @@ -56,7 +57,7 @@ typedef struct _cef_focus_handler_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Called when the browser component is about to loose focus. For instance, if @@ -64,25 +65,26 @@ typedef struct _cef_focus_handler_t { // will be true (1) if the browser is giving focus to the next component and // false (0) if the browser is giving focus to the previous component. /// - void (CEF_CALLBACK *on_take_focus)(struct _cef_focus_handler_t* self, - struct _cef_browser_t* browser, int next); + void(CEF_CALLBACK* on_take_focus)(struct _cef_focus_handler_t* self, + struct _cef_browser_t* browser, + int next); /// // Called when the browser component is requesting focus. |source| indicates // where the focus request is originating from. Return false (0) to allow the // focus to be set or true (1) to cancel setting the focus. /// - int (CEF_CALLBACK *on_set_focus)(struct _cef_focus_handler_t* self, - struct _cef_browser_t* browser, cef_focus_source_t source); + int(CEF_CALLBACK* on_set_focus)(struct _cef_focus_handler_t* self, + struct _cef_browser_t* browser, + cef_focus_source_t source); /// // Called when the browser component has received focus. /// - void (CEF_CALLBACK *on_got_focus)(struct _cef_focus_handler_t* self, - struct _cef_browser_t* browser); + void(CEF_CALLBACK* on_got_focus)(struct _cef_focus_handler_t* self, + struct _cef_browser_t* browser); } cef_focus_handler_t; - #ifdef __cplusplus } #endif diff --git a/include/capi/cef_frame_capi.h b/include/capi/cef_frame_capi.h index 2d4c61c..4dc49a7 100644 --- a/include/capi/cef_frame_capi.h +++ b/include/capi/cef_frame_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,21 +33,23 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=c1457ef21c14c40422b19b681121283eae3e9d70$ +// #ifndef CEF_INCLUDE_CAPI_CEF_FRAME_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_FRAME_CAPI_H_ #pragma once -#ifdef __cplusplus -extern "C" { -#endif - #include "include/capi/cef_base_capi.h" #include "include/capi/cef_dom_capi.h" #include "include/capi/cef_request_capi.h" #include "include/capi/cef_stream_capi.h" #include "include/capi/cef_string_visitor_capi.h" +#ifdef __cplusplus +extern "C" { +#endif + struct _cef_browser_t; struct _cef_v8context_t; @@ -61,88 +63,89 @@ typedef struct _cef_frame_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // True if this object is currently attached to a valid frame. /// - int (CEF_CALLBACK *is_valid)(struct _cef_frame_t* self); + int(CEF_CALLBACK* is_valid)(struct _cef_frame_t* self); /// // Execute undo in this frame. /// - void (CEF_CALLBACK *undo)(struct _cef_frame_t* self); + void(CEF_CALLBACK* undo)(struct _cef_frame_t* self); /// // Execute redo in this frame. /// - void (CEF_CALLBACK *redo)(struct _cef_frame_t* self); + void(CEF_CALLBACK* redo)(struct _cef_frame_t* self); /// // Execute cut in this frame. /// - void (CEF_CALLBACK *cut)(struct _cef_frame_t* self); + void(CEF_CALLBACK* cut)(struct _cef_frame_t* self); /// // Execute copy in this frame. /// - void (CEF_CALLBACK *copy)(struct _cef_frame_t* self); + void(CEF_CALLBACK* copy)(struct _cef_frame_t* self); /// // Execute paste in this frame. /// - void (CEF_CALLBACK *paste)(struct _cef_frame_t* self); + void(CEF_CALLBACK* paste)(struct _cef_frame_t* self); /// // Execute delete in this frame. /// - void (CEF_CALLBACK *del)(struct _cef_frame_t* self); + void(CEF_CALLBACK* del)(struct _cef_frame_t* self); /// // Execute select all in this frame. /// - void (CEF_CALLBACK *select_all)(struct _cef_frame_t* self); + void(CEF_CALLBACK* select_all)(struct _cef_frame_t* self); /// // Save this frame's HTML source to a temporary file and open it in the // default text viewing application. This function can only be called from the // browser process. /// - void (CEF_CALLBACK *view_source)(struct _cef_frame_t* self); + void(CEF_CALLBACK* view_source)(struct _cef_frame_t* self); /// // Retrieve this frame's HTML source as a string sent to the specified // visitor. /// - void (CEF_CALLBACK *get_source)(struct _cef_frame_t* self, - struct _cef_string_visitor_t* visitor); + void(CEF_CALLBACK* get_source)(struct _cef_frame_t* self, + struct _cef_string_visitor_t* visitor); /// // Retrieve this frame's display text as a string sent to the specified // visitor. /// - void (CEF_CALLBACK *get_text)(struct _cef_frame_t* self, - struct _cef_string_visitor_t* visitor); + void(CEF_CALLBACK* get_text)(struct _cef_frame_t* self, + struct _cef_string_visitor_t* visitor); /// // Load the request represented by the |request| object. /// - void (CEF_CALLBACK *load_request)(struct _cef_frame_t* self, - struct _cef_request_t* request); + void(CEF_CALLBACK* load_request)(struct _cef_frame_t* self, + struct _cef_request_t* request); /// // Load the specified |url|. /// - void (CEF_CALLBACK *load_url)(struct _cef_frame_t* self, - const cef_string_t* url); + void(CEF_CALLBACK* load_url)(struct _cef_frame_t* self, + const cef_string_t* url); /// // Load the contents of |string_val| with the specified dummy |url|. |url| // should have a standard scheme (for example, http scheme) or behaviors like // link clicks and web security restrictions may not behave as expected. /// - void (CEF_CALLBACK *load_string)(struct _cef_frame_t* self, - const cef_string_t* string_val, const cef_string_t* url); + void(CEF_CALLBACK* load_string)(struct _cef_frame_t* self, + const cef_string_t* string_val, + const cef_string_t* url); /// // Execute a string of JavaScript code in this frame. The |script_url| @@ -151,19 +154,20 @@ typedef struct _cef_frame_t { // error. The |start_line| parameter is the base line number to use for error // reporting. /// - void (CEF_CALLBACK *execute_java_script)(struct _cef_frame_t* self, - const cef_string_t* code, const cef_string_t* script_url, - int start_line); + void(CEF_CALLBACK* execute_java_script)(struct _cef_frame_t* self, + const cef_string_t* code, + const cef_string_t* script_url, + int start_line); /// // Returns true (1) if this is the main (top-level) frame. /// - int (CEF_CALLBACK *is_main)(struct _cef_frame_t* self); + int(CEF_CALLBACK* is_main)(struct _cef_frame_t* self); /// // Returns true (1) if this is the focused frame. /// - int (CEF_CALLBACK *is_focused)(struct _cef_frame_t* self); + int(CEF_CALLBACK* is_focused)(struct _cef_frame_t* self); /// // Returns the name for this frame. If the frame has an assigned name (for @@ -173,46 +177,46 @@ typedef struct _cef_frame_t { // value. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_name)(struct _cef_frame_t* self); + cef_string_userfree_t(CEF_CALLBACK* get_name)(struct _cef_frame_t* self); /// - // Returns the globally unique identifier for this frame. + // Returns the globally unique identifier for this frame or < 0 if the + // underlying frame does not yet exist. /// - int64 (CEF_CALLBACK *get_identifier)(struct _cef_frame_t* self); + int64(CEF_CALLBACK* get_identifier)(struct _cef_frame_t* self); /// // Returns the parent of this frame or NULL if this is the main (top-level) // frame. /// - struct _cef_frame_t* (CEF_CALLBACK *get_parent)(struct _cef_frame_t* self); + struct _cef_frame_t*(CEF_CALLBACK* get_parent)(struct _cef_frame_t* self); /// // Returns the URL currently loaded in this frame. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_url)(struct _cef_frame_t* self); + cef_string_userfree_t(CEF_CALLBACK* get_url)(struct _cef_frame_t* self); /// // Returns the browser that this frame belongs to. /// - struct _cef_browser_t* (CEF_CALLBACK *get_browser)(struct _cef_frame_t* self); + struct _cef_browser_t*(CEF_CALLBACK* get_browser)(struct _cef_frame_t* self); /// // Get the V8 context associated with the frame. This function can only be // called from the render process. /// - struct _cef_v8context_t* (CEF_CALLBACK *get_v8context)( + struct _cef_v8context_t*(CEF_CALLBACK* get_v8context)( struct _cef_frame_t* self); /// // Visit the DOM document. This function can only be called from the render // process. /// - void (CEF_CALLBACK *visit_dom)(struct _cef_frame_t* self, - struct _cef_domvisitor_t* visitor); + void(CEF_CALLBACK* visit_dom)(struct _cef_frame_t* self, + struct _cef_domvisitor_t* visitor); } cef_frame_t; - #ifdef __cplusplus } #endif diff --git a/include/capi/cef_geolocation_capi.h b/include/capi/cef_geolocation_capi.h index 15f8520..bc934e4 100644 --- a/include/capi/cef_geolocation_capi.h +++ b/include/capi/cef_geolocation_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,18 +33,19 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=3ae57ba897d73f3fcccc955c827379746b6203af$ +// #ifndef CEF_INCLUDE_CAPI_CEF_GEOLOCATION_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_GEOLOCATION_CAPI_H_ #pragma once +#include "include/capi/cef_base_capi.h" + #ifdef __cplusplus extern "C" { #endif -#include "include/capi/cef_base_capi.h" - - /// // Implement this structure to receive geolocation updates. The functions of // this structure will be called on the browser process UI thread. @@ -53,18 +54,17 @@ typedef struct _cef_get_geolocation_callback_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Called with the 'best available' location information or, if the location // update failed, with error information. /// - void (CEF_CALLBACK *on_location_update)( + void(CEF_CALLBACK* on_location_update)( struct _cef_get_geolocation_callback_t* self, const struct _cef_geoposition_t* position); } cef_get_geolocation_callback_t; - /// // Request a one-time geolocation update. This function bypasses any user // permission checks so should only be used by code that is allowed to access diff --git a/include/capi/cef_geolocation_handler_capi.h b/include/capi/cef_geolocation_handler_capi.h index fab6055..8975169 100644 --- a/include/capi/cef_geolocation_handler_capi.h +++ b/include/capi/cef_geolocation_handler_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,18 +33,19 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=ec60811fcefbe02348f14ecddbe5778ce836bf53$ +// #ifndef CEF_INCLUDE_CAPI_CEF_GEOLOCATION_HANDLER_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_GEOLOCATION_HANDLER_CAPI_H_ #pragma once -#ifdef __cplusplus -extern "C" { -#endif - #include "include/capi/cef_base_capi.h" #include "include/capi/cef_browser_capi.h" +#ifdef __cplusplus +extern "C" { +#endif /// // Callback structure used for asynchronous continuation of geolocation @@ -54,50 +55,50 @@ typedef struct _cef_geolocation_callback_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Call to allow or deny geolocation access. /// - void (CEF_CALLBACK *cont)(struct _cef_geolocation_callback_t* self, - int allow); + void(CEF_CALLBACK* cont)(struct _cef_geolocation_callback_t* self, int allow); } cef_geolocation_callback_t; - /// // Implement this structure to handle events related to geolocation permission // requests. The functions of this structure will be called on the browser -// process IO thread. +// process UI thread. /// typedef struct _cef_geolocation_handler_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Called when a page requests permission to access geolocation information. // |requesting_url| is the URL requesting permission and |request_id| is the - // unique ID for the permission request. Call - // cef_geolocation_callback_t::Continue to allow or deny the permission - // request. + // unique ID for the permission request. Return true (1) and call + // cef_geolocation_callback_t::cont() either in this function or at a later + // time to continue or cancel the request. Return false (0) to cancel the + // request immediately. /// - void (CEF_CALLBACK *on_request_geolocation_permission)( - struct _cef_geolocation_handler_t* self, struct _cef_browser_t* browser, - const cef_string_t* requesting_url, int request_id, + int(CEF_CALLBACK* on_request_geolocation_permission)( + struct _cef_geolocation_handler_t* self, + struct _cef_browser_t* browser, + const cef_string_t* requesting_url, + int request_id, struct _cef_geolocation_callback_t* callback); /// - // Called when a geolocation access request is canceled. |requesting_url| is - // the URL that originally requested permission and |request_id| is the unique - // ID for the permission request. + // Called when a geolocation access request is canceled. |request_id| is the + // unique ID for the permission request. /// - void (CEF_CALLBACK *on_cancel_geolocation_permission)( - struct _cef_geolocation_handler_t* self, struct _cef_browser_t* browser, - const cef_string_t* requesting_url, int request_id); + void(CEF_CALLBACK* on_cancel_geolocation_permission)( + struct _cef_geolocation_handler_t* self, + struct _cef_browser_t* browser, + int request_id); } cef_geolocation_handler_t; - #ifdef __cplusplus } #endif diff --git a/include/capi/cef_image_capi.h b/include/capi/cef_image_capi.h new file mode 100644 index 0000000..ed31200 --- /dev/null +++ b/include/capi/cef_image_capi.h @@ -0,0 +1,205 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=60f904f2f77ce6d89f9fceeeda0050273a3c9e6d$ +// + +#ifndef CEF_INCLUDE_CAPI_CEF_IMAGE_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_IMAGE_CAPI_H_ +#pragma once + +#include "include/capi/cef_base_capi.h" +#include "include/capi/cef_values_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// Container for a single image represented at different scale factors. All +// image representations should be the same size in density independent pixel +// (DIP) units. For example, if the image at scale factor 1.0 is 100x100 pixels +// then the image at scale factor 2.0 should be 200x200 pixels -- both images +// will display with a DIP size of 100x100 units. The functions of this +// structure must be called on the browser process UI thread. +/// +typedef struct _cef_image_t { + /// + // Base structure. + /// + cef_base_ref_counted_t base; + + /// + // Returns true (1) if this Image is NULL. + /// + int(CEF_CALLBACK* is_empty)(struct _cef_image_t* self); + + /// + // Returns true (1) if this Image and |that| Image share the same underlying + // storage. Will also return true (1) if both images are NULL. + /// + int(CEF_CALLBACK* is_same)(struct _cef_image_t* self, + struct _cef_image_t* that); + + /// + // Add a bitmap image representation for |scale_factor|. Only 32-bit RGBA/BGRA + // formats are supported. |pixel_width| and |pixel_height| are the bitmap + // representation size in pixel coordinates. |pixel_data| is the array of + // pixel data and should be |pixel_width| x |pixel_height| x 4 bytes in size. + // |color_type| and |alpha_type| values specify the pixel format. + /// + int(CEF_CALLBACK* add_bitmap)(struct _cef_image_t* self, + float scale_factor, + int pixel_width, + int pixel_height, + cef_color_type_t color_type, + cef_alpha_type_t alpha_type, + const void* pixel_data, + size_t pixel_data_size); + + /// + // Add a PNG image representation for |scale_factor|. |png_data| is the image + // data of size |png_data_size|. Any alpha transparency in the PNG data will + // be maintained. + /// + int(CEF_CALLBACK* add_png)(struct _cef_image_t* self, + float scale_factor, + const void* png_data, + size_t png_data_size); + + /// + // Create a JPEG image representation for |scale_factor|. |jpeg_data| is the + // image data of size |jpeg_data_size|. The JPEG format does not support + // transparency so the alpha byte will be set to 0xFF for all pixels. + /// + int(CEF_CALLBACK* add_jpeg)(struct _cef_image_t* self, + float scale_factor, + const void* jpeg_data, + size_t jpeg_data_size); + + /// + // Returns the image width in density independent pixel (DIP) units. + /// + size_t(CEF_CALLBACK* get_width)(struct _cef_image_t* self); + + /// + // Returns the image height in density independent pixel (DIP) units. + /// + size_t(CEF_CALLBACK* get_height)(struct _cef_image_t* self); + + /// + // Returns true (1) if this image contains a representation for + // |scale_factor|. + /// + int(CEF_CALLBACK* has_representation)(struct _cef_image_t* self, + float scale_factor); + + /// + // Removes the representation for |scale_factor|. Returns true (1) on success. + /// + int(CEF_CALLBACK* remove_representation)(struct _cef_image_t* self, + float scale_factor); + + /// + // Returns information for the representation that most closely matches + // |scale_factor|. |actual_scale_factor| is the actual scale factor for the + // representation. |pixel_width| and |pixel_height| are the representation + // size in pixel coordinates. Returns true (1) on success. + /// + int(CEF_CALLBACK* get_representation_info)(struct _cef_image_t* self, + float scale_factor, + float* actual_scale_factor, + int* pixel_width, + int* pixel_height); + + /// + // Returns the bitmap representation that most closely matches |scale_factor|. + // Only 32-bit RGBA/BGRA formats are supported. |color_type| and |alpha_type| + // values specify the desired output pixel format. |pixel_width| and + // |pixel_height| are the output representation size in pixel coordinates. + // Returns a cef_binary_value_t containing the pixel data on success or NULL + // on failure. + /// + struct _cef_binary_value_t*(CEF_CALLBACK* get_as_bitmap)( + struct _cef_image_t* self, + float scale_factor, + cef_color_type_t color_type, + cef_alpha_type_t alpha_type, + int* pixel_width, + int* pixel_height); + + /// + // Returns the PNG representation that most closely matches |scale_factor|. If + // |with_transparency| is true (1) any alpha transparency in the image will be + // represented in the resulting PNG data. |pixel_width| and |pixel_height| are + // the output representation size in pixel coordinates. Returns a + // cef_binary_value_t containing the PNG image data on success or NULL on + // failure. + /// + struct _cef_binary_value_t*(CEF_CALLBACK* get_as_png)( + struct _cef_image_t* self, + float scale_factor, + int with_transparency, + int* pixel_width, + int* pixel_height); + + /// + // Returns the JPEG representation that most closely matches |scale_factor|. + // |quality| determines the compression level with 0 == lowest and 100 == + // highest. The JPEG format does not support alpha transparency and the alpha + // channel, if any, will be discarded. |pixel_width| and |pixel_height| are + // the output representation size in pixel coordinates. Returns a + // cef_binary_value_t containing the JPEG image data on success or NULL on + // failure. + /// + struct _cef_binary_value_t*(CEF_CALLBACK* get_as_jpeg)( + struct _cef_image_t* self, + float scale_factor, + int quality, + int* pixel_width, + int* pixel_height); +} cef_image_t; + +/// +// Create a new cef_image_t. It will initially be NULL. Use the Add*() functions +// to add representations at different scale factors. +/// +CEF_EXPORT cef_image_t* cef_image_create(); + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_IMAGE_CAPI_H_ diff --git a/include/capi/cef_jsdialog_handler_capi.h b/include/capi/cef_jsdialog_handler_capi.h index 92473c6..267bc4b 100644 --- a/include/capi/cef_jsdialog_handler_capi.h +++ b/include/capi/cef_jsdialog_handler_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,18 +33,19 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=351cff5a52f29b54d1854d5dfbb1733c8a62797d$ +// #ifndef CEF_INCLUDE_CAPI_CEF_JSDIALOG_HANDLER_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_JSDIALOG_HANDLER_CAPI_H_ #pragma once -#ifdef __cplusplus -extern "C" { -#endif - #include "include/capi/cef_base_capi.h" #include "include/capi/cef_browser_capi.h" +#ifdef __cplusplus +extern "C" { +#endif /// // Callback structure used for asynchronous continuation of JavaScript dialog @@ -54,17 +55,17 @@ typedef struct _cef_jsdialog_callback_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Continue the JS dialog request. Set |success| to true (1) if the OK button // was pressed. The |user_input| value should be specified for prompt dialogs. /// - void (CEF_CALLBACK *cont)(struct _cef_jsdialog_callback_t* self, int success, - const cef_string_t* user_input); + void(CEF_CALLBACK* cont)(struct _cef_jsdialog_callback_t* self, + int success, + const cef_string_t* user_input); } cef_jsdialog_callback_t; - /// // Implement this structure to handle events related to JavaScript dialogs. The // functions of this structure will be called on the UI thread. @@ -73,10 +74,12 @@ typedef struct _cef_jsdialog_handler_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// - // Called to run a JavaScript dialog. The |default_prompt_text| value will be + // Called to run a JavaScript dialog. If |origin_url| is non-NULL it can be + // passed to the CefFormatUrlForSecurityDisplay function to retrieve a secure + // and user-friendly display string. The |default_prompt_text| value will be // specified for prompt dialogs only. Set |suppress_message| to true (1) and // return false (0) to suppress the message (suppressing messages is // preferable to immediately executing the callback as this is used to detect @@ -90,12 +93,14 @@ typedef struct _cef_jsdialog_handler_t { // the application must execute |callback| once the custom dialog is // dismissed. /// - int (CEF_CALLBACK *on_jsdialog)(struct _cef_jsdialog_handler_t* self, - struct _cef_browser_t* browser, const cef_string_t* origin_url, - const cef_string_t* accept_lang, cef_jsdialog_type_t dialog_type, - const cef_string_t* message_text, - const cef_string_t* default_prompt_text, - struct _cef_jsdialog_callback_t* callback, int* suppress_message); + int(CEF_CALLBACK* on_jsdialog)(struct _cef_jsdialog_handler_t* self, + struct _cef_browser_t* browser, + const cef_string_t* origin_url, + cef_jsdialog_type_t dialog_type, + const cef_string_t* message_text, + const cef_string_t* default_prompt_text, + struct _cef_jsdialog_callback_t* callback, + int* suppress_message); /// // Called to run a dialog asking the user if they want to leave a page. Return @@ -105,9 +110,11 @@ typedef struct _cef_jsdialog_handler_t { // dialog is used the application must execute |callback| once the custom // dialog is dismissed. /// - int (CEF_CALLBACK *on_before_unload_dialog)( - struct _cef_jsdialog_handler_t* self, struct _cef_browser_t* browser, - const cef_string_t* message_text, int is_reload, + int(CEF_CALLBACK* on_before_unload_dialog)( + struct _cef_jsdialog_handler_t* self, + struct _cef_browser_t* browser, + const cef_string_t* message_text, + int is_reload, struct _cef_jsdialog_callback_t* callback); /// @@ -115,17 +122,17 @@ typedef struct _cef_jsdialog_handler_t { // be called due to events like page navigation irregardless of whether any // dialogs are currently pending. /// - void (CEF_CALLBACK *on_reset_dialog_state)( - struct _cef_jsdialog_handler_t* self, struct _cef_browser_t* browser); + void(CEF_CALLBACK* on_reset_dialog_state)( + struct _cef_jsdialog_handler_t* self, + struct _cef_browser_t* browser); /// // Called when the default implementation dialog is closed. /// - void (CEF_CALLBACK *on_dialog_closed)(struct _cef_jsdialog_handler_t* self, - struct _cef_browser_t* browser); + void(CEF_CALLBACK* on_dialog_closed)(struct _cef_jsdialog_handler_t* self, + struct _cef_browser_t* browser); } cef_jsdialog_handler_t; - #ifdef __cplusplus } #endif diff --git a/include/capi/cef_keyboard_handler_capi.h b/include/capi/cef_keyboard_handler_capi.h index c106037..31b6d98 100644 --- a/include/capi/cef_keyboard_handler_capi.h +++ b/include/capi/cef_keyboard_handler_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,18 +33,19 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=07c2a01bb9975fa52fdb287712f8f369557ba755$ +// #ifndef CEF_INCLUDE_CAPI_CEF_KEYBOARD_HANDLER_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_KEYBOARD_HANDLER_CAPI_H_ #pragma once -#ifdef __cplusplus -extern "C" { -#endif - #include "include/capi/cef_base_capi.h" #include "include/capi/cef_browser_capi.h" +#ifdef __cplusplus +extern "C" { +#endif /// // Implement this structure to handle events related to keyboard input. The @@ -54,16 +55,20 @@ typedef struct _cef_keyboard_handler_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; + /// // Called before a keyboard event is sent to the renderer. |event| contains // information about the keyboard event. |os_event| is the operating system // event message, if any. Return true (1) if the event was handled or false // (0) otherwise. If the event will be handled in on_key_event() as a keyboard // shortcut set |is_keyboard_shortcut| to true (1) and return false (0). - int (CEF_CALLBACK *on_pre_key_event)(struct _cef_keyboard_handler_t* self, - struct _cef_browser_t* browser, const struct _cef_key_event_t* event, - cef_event_handle_t os_event, int* is_keyboard_shortcut); + /// + int(CEF_CALLBACK* on_pre_key_event)(struct _cef_keyboard_handler_t* self, + struct _cef_browser_t* browser, + const struct _cef_key_event_t* event, + cef_event_handle_t os_event, + int* is_keyboard_shortcut); /// // Called after the renderer and JavaScript in the page has had a chance to @@ -71,12 +76,12 @@ typedef struct _cef_keyboard_handler_t { // |os_event| is the operating system event message, if any. Return true (1) // if the keyboard event was handled or false (0) otherwise. /// - int (CEF_CALLBACK *on_key_event)(struct _cef_keyboard_handler_t* self, - struct _cef_browser_t* browser, const struct _cef_key_event_t* event, - cef_event_handle_t os_event); + int(CEF_CALLBACK* on_key_event)(struct _cef_keyboard_handler_t* self, + struct _cef_browser_t* browser, + const struct _cef_key_event_t* event, + cef_event_handle_t os_event); } cef_keyboard_handler_t; - #ifdef __cplusplus } #endif diff --git a/include/capi/cef_life_span_handler_capi.h b/include/capi/cef_life_span_handler_capi.h index d75bcab..8f836aa 100644 --- a/include/capi/cef_life_span_handler_capi.h +++ b/include/capi/cef_life_span_handler_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,18 +33,20 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=7894d507f337ebe5f9296770e10773a4e6458f00$ +// #ifndef CEF_INCLUDE_CAPI_CEF_LIFE_SPAN_HANDLER_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_LIFE_SPAN_HANDLER_CAPI_H_ #pragma once +#include "include/capi/cef_base_capi.h" +#include "include/capi/cef_browser_capi.h" + #ifdef __cplusplus extern "C" { #endif -#include "include/capi/cef_base_capi.h" -#include "include/capi/cef_browser_capi.h" - struct _cef_client_t; /// @@ -56,77 +58,120 @@ typedef struct _cef_life_span_handler_t { /// // Base structure. /// - cef_base_t base; - - /// - // Called on the IO thread before a new popup window is created. The |browser| - // and |frame| parameters represent the source of the popup request. The - // |target_url| and |target_frame_name| values may be NULL if none were - // specified with the request. The |popupFeatures| structure contains - // information about the requested popup window. To allow creation of the - // popup window optionally modify |windowInfo|, |client|, |settings| and - // |no_javascript_access| and return false (0). To cancel creation of the - // popup window return true (1). The |client| and |settings| values will - // default to the source browser's values. The |no_javascript_access| value - // indicates whether the new browser window should be scriptable and in the - // same process as the source browser. - int (CEF_CALLBACK *on_before_popup)(struct _cef_life_span_handler_t* self, - struct _cef_browser_t* browser, struct _cef_frame_t* frame, - const cef_string_t* target_url, const cef_string_t* target_frame_name, - const struct _cef_popup_features_t* popupFeatures, - struct _cef_window_info_t* windowInfo, struct _cef_client_t** client, - struct _cef_browser_settings_t* settings, int* no_javascript_access); + cef_base_ref_counted_t base; /// - // Called after a new browser is created. + // Called on the IO thread before a new popup browser is created. The + // |browser| and |frame| values represent the source of the popup request. The + // |target_url| and |target_frame_name| values indicate where the popup + // browser should navigate and may be NULL if not specified with the request. + // The |target_disposition| value indicates where the user intended to open + // the popup (e.g. current tab, new tab, etc). The |user_gesture| value will + // be true (1) if the popup was opened via explicit user gesture (e.g. + // clicking a link) or false (0) if the popup opened automatically (e.g. via + // the DomContentLoaded event). The |popupFeatures| structure contains + // additional information about the requested popup window. To allow creation + // of the popup browser optionally modify |windowInfo|, |client|, |settings| + // and |no_javascript_access| and return false (0). To cancel creation of the + // popup browser return true (1). The |client| and |settings| values will + // default to the source browser's values. If the |no_javascript_access| value + // is set to false (0) the new browser will not be scriptable and may not be + // hosted in the same renderer process as the source browser. Any + // modifications to |windowInfo| will be ignored if the parent browser is + // wrapped in a cef_browser_view_t. Popup browser creation will be canceled if + // the parent browser is destroyed before the popup browser creation completes + // (indicated by a call to OnAfterCreated for the popup browser). /// - void (CEF_CALLBACK *on_after_created)(struct _cef_life_span_handler_t* self, - struct _cef_browser_t* browser); + int(CEF_CALLBACK* on_before_popup)( + struct _cef_life_span_handler_t* self, + struct _cef_browser_t* browser, + struct _cef_frame_t* frame, + const cef_string_t* target_url, + const cef_string_t* target_frame_name, + cef_window_open_disposition_t target_disposition, + int user_gesture, + const struct _cef_popup_features_t* popupFeatures, + struct _cef_window_info_t* windowInfo, + struct _cef_client_t** client, + struct _cef_browser_settings_t* settings, + int* no_javascript_access); /// - // Called when a modal window is about to display and the modal loop should - // begin running. Return false (0) to use the default modal loop - // implementation or true (1) to use a custom implementation. + // Called after a new browser is created. This callback will be the first + // notification that references |browser|. /// - int (CEF_CALLBACK *run_modal)(struct _cef_life_span_handler_t* self, - struct _cef_browser_t* browser); + void(CEF_CALLBACK* on_after_created)(struct _cef_life_span_handler_t* self, + struct _cef_browser_t* browser); /// // Called when a browser has recieved a request to close. This may result - // directly from a call to cef_browser_host_t::close_browser() or indirectly - // if the browser is a top-level OS window created by CEF and the user - // attempts to close the window. This function will be called after the - // JavaScript 'onunload' event has been fired. It will not be called for - // browsers after the associated OS window has been destroyed (for those - // browsers it is no longer possible to cancel the close). - // - // If CEF created an OS window for the browser returning false (0) will send - // an OS close notification to the browser window's top-level owner (e.g. - // WM_CLOSE on Windows, performClose: on OS-X and "delete_event" on Linux). If - // no OS window exists (window rendering disabled) returning false (0) will - // cause the browser object to be destroyed immediately. Return true (1) if - // the browser is parented to another window and that other window needs to - // receive close notification via some non-standard technique. + // directly from a call to cef_browser_host_t::*close_browser() or indirectly + // if the browser is parented to a top-level window created by CEF and the + // user attempts to close that window (by clicking the 'X', for example). The + // do_close() function will be called after the JavaScript 'onunload' event + // has been fired. // - // If an application provides its own top-level window it should handle OS - // close notifications by calling cef_browser_host_t::CloseBrowser(false (0)) - // instead of immediately closing (see the example below). This gives CEF an + // An application should handle top-level owner window close notifications by + // calling cef_browser_host_t::try_close_browser() or + // cef_browser_host_t::CloseBrowser(false (0)) instead of allowing the window + // to close immediately (see the examples below). This gives CEF an // opportunity to process the 'onbeforeunload' event and optionally cancel the // close before do_close() is called. // - // The cef_life_span_handler_t::OnBeforeclose() function will be called - // immediately before the browser object is destroyed. The application should - // only exit after OnBeforeclose() has been called for all existing browsers. + // When windowed rendering is enabled CEF will internally create a window or + // view to host the browser. In that case returning false (0) from do_close() + // will send the standard close notification to the browser's top-level owner + // window (e.g. WM_CLOSE on Windows, performClose: on OS X, "delete_event" on + // Linux or cef_window_delegate_t::can_close() callback from Views). If the + // browser's host window/view has already been destroyed (via view hierarchy + // tear-down, for example) then do_close() will not be called for that browser + // since is no longer possible to cancel the close. // - // If the browser represents a modal window and a custom modal loop - // implementation was provided in cef_life_span_handler_t::run_modal() this - // callback should be used to restore the opener window to a usable state. + // When windowed rendering is disabled returning false (0) from do_close() + // will cause the browser object to be destroyed immediately. // - // By way of example consider what should happen during window close when the - // browser is parented to an application-provided top-level OS window. 1. - // User clicks the window close button which sends an OS close - // notification (e.g. WM_CLOSE on Windows, performClose: on OS-X and - // "delete_event" on Linux). + // If the browser's top-level owner window requires a non-standard close + // notification then send that notification from do_close() and return true + // (1). + // + // The cef_life_span_handler_t::on_before_close() function will be called + // after do_close() (if do_close() is called) and immediately before the + // browser object is destroyed. The application should only exit after + // on_before_close() has been called for all existing browsers. + // + // The below examples describe what should happen during window close when the + // browser is parented to an application-provided top-level window. + // + // Example 1: Using cef_browser_host_t::try_close_browser(). This is + // recommended for clients using standard close handling and windows created + // on the browser process UI thread. 1. User clicks the window close button + // which sends a close notification to + // the application's top-level window. + // 2. Application's top-level window receives the close notification and + // calls TryCloseBrowser() (which internally calls CloseBrowser(false)). + // TryCloseBrowser() returns false so the client cancels the window close. + // 3. JavaScript 'onbeforeunload' handler executes and shows the close + // confirmation dialog (which can be overridden via + // CefJSDialogHandler::OnBeforeUnloadDialog()). + // 4. User approves the close. 5. JavaScript 'onunload' handler executes. 6. + // CEF sends a close notification to the application's top-level window + // (because DoClose() returned false by default). + // 7. Application's top-level window receives the close notification and + // calls TryCloseBrowser(). TryCloseBrowser() returns true so the client + // allows the window close. + // 8. Application's top-level window is destroyed. 9. Application's + // on_before_close() handler is called and the browser object + // is destroyed. + // 10. Application exits by calling cef_quit_message_loop() if no other + // browsers + // exist. + // + // Example 2: Using cef_browser_host_t::CloseBrowser(false (0)) and + // implementing the do_close() callback. This is recommended for clients using + // non-standard close handling or windows that were not created on the browser + // process UI thread. 1. User clicks the window close button which sends a + // close notification to + // the application's top-level window. // 2. Application's top-level window receives the close notification and: // A. Calls CefBrowserHost::CloseBrowser(false). // B. Cancels the window close. @@ -135,36 +180,32 @@ typedef struct _cef_life_span_handler_t { // CefJSDialogHandler::OnBeforeUnloadDialog()). // 4. User approves the close. 5. JavaScript 'onunload' handler executes. 6. // Application's do_close() handler is called. Application will: - // A. Call CefBrowserHost::ParentWindowWillClose() to notify CEF that the - // parent window will be closing. - // B. Set a flag to indicate that the next close attempt will be allowed. - // C. Return false. - // 7. CEF sends an OS close notification. 8. Application's top-level window - // receives the OS close notification and + // A. Set a flag to indicate that the next close attempt will be allowed. + // B. Return false. + // 7. CEF sends an close notification to the application's top-level window. + // 8. Application's top-level window receives the close notification and // allows the window to close based on the flag from #6B. - // 9. Browser OS window is destroyed. 10. Application's - // cef_life_span_handler_t::OnBeforeclose() handler is called and - // the browser object is destroyed. + // 9. Application's top-level window is destroyed. 10. Application's + // on_before_close() handler is called and the browser object + // is destroyed. // 11. Application exits by calling cef_quit_message_loop() if no other // browsers // exist. /// - int (CEF_CALLBACK *do_close)(struct _cef_life_span_handler_t* self, - struct _cef_browser_t* browser); + int(CEF_CALLBACK* do_close)(struct _cef_life_span_handler_t* self, + struct _cef_browser_t* browser); /// // Called just before a browser is destroyed. Release all references to the // browser object and do not attempt to execute any functions on the browser - // object after this callback returns. If this is a modal window and a custom - // modal loop implementation was provided in run_modal() this callback should - // be used to exit the custom modal loop. See do_close() documentation for + // object after this callback returns. This callback will be the last + // notification that references |browser|. See do_close() documentation for // additional usage information. /// - void (CEF_CALLBACK *on_before_close)(struct _cef_life_span_handler_t* self, - struct _cef_browser_t* browser); + void(CEF_CALLBACK* on_before_close)(struct _cef_life_span_handler_t* self, + struct _cef_browser_t* browser); } cef_life_span_handler_t; - #ifdef __cplusplus } #endif diff --git a/include/capi/cef_load_handler_capi.h b/include/capi/cef_load_handler_capi.h index 679bc0d..c46b252 100644 --- a/include/capi/cef_load_handler_capi.h +++ b/include/capi/cef_load_handler_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,19 +33,20 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=d8fa87bb47ec889cab864fe96f94e07bf1deb0f6$ +// #ifndef CEF_INCLUDE_CAPI_CEF_LOAD_HANDLER_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_LOAD_HANDLER_CAPI_H_ #pragma once -#ifdef __cplusplus -extern "C" { -#endif - #include "include/capi/cef_base_capi.h" #include "include/capi/cef_browser_capi.h" #include "include/capi/cef_frame_capi.h" +#ifdef __cplusplus +extern "C" { +#endif /// // Implement this structure to handle events related to browser load status. The @@ -56,55 +57,68 @@ typedef struct _cef_load_handler_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Called when the loading state has changed. This callback will be executed // twice -- once when loading is initiated either programmatically or by user // action, and once when loading is terminated due to completion, cancellation - // of failure. + // of failure. It will be called before any calls to OnLoadStart and after all + // calls to OnLoadError and/or OnLoadEnd. /// - void (CEF_CALLBACK *on_loading_state_change)(struct _cef_load_handler_t* self, - struct _cef_browser_t* browser, int isLoading, int canGoBack, - int canGoForward); + void(CEF_CALLBACK* on_loading_state_change)(struct _cef_load_handler_t* self, + struct _cef_browser_t* browser, + int isLoading, + int canGoBack, + int canGoForward); /// - // Called when the browser begins loading a frame. The |frame| value will - // never be NULL -- call the is_main() function to check if this frame is the - // main frame. Multiple frames may be loading at the same time. Sub-frames may - // start or continue loading after the main frame load has ended. This - // function may not be called for a particular frame if the load request for - // that frame fails. For notification of overall browser load status use - // OnLoadingStateChange instead. + // Called after a navigation has been committed and before the browser begins + // loading contents in the frame. The |frame| value will never be NULL -- call + // the is_main() function to check if this frame is the main frame. + // |transition_type| provides information about the source of the navigation + // and an accurate value is only available in the browser process. Multiple + // frames may be loading at the same time. Sub-frames may start or continue + // loading after the main frame load has ended. This function will not be + // called for same page navigations (fragments, history state, etc.) or for + // navigations that fail or are canceled before commit. For notification of + // overall browser load status use OnLoadingStateChange instead. /// - void (CEF_CALLBACK *on_load_start)(struct _cef_load_handler_t* self, - struct _cef_browser_t* browser, struct _cef_frame_t* frame); + void(CEF_CALLBACK* on_load_start)(struct _cef_load_handler_t* self, + struct _cef_browser_t* browser, + struct _cef_frame_t* frame, + cef_transition_type_t transition_type); /// // Called when the browser is done loading a frame. The |frame| value will // never be NULL -- call the is_main() function to check if this frame is the // main frame. Multiple frames may be loading at the same time. Sub-frames may // start or continue loading after the main frame load has ended. This - // function will always be called for all frames irrespective of whether the - // request completes successfully. + // function will not be called for same page navigations (fragments, history + // state, etc.) or for navigations that fail or are canceled before commit. + // For notification of overall browser load status use OnLoadingStateChange + // instead. /// - void (CEF_CALLBACK *on_load_end)(struct _cef_load_handler_t* self, - struct _cef_browser_t* browser, struct _cef_frame_t* frame, - int httpStatusCode); + void(CEF_CALLBACK* on_load_end)(struct _cef_load_handler_t* self, + struct _cef_browser_t* browser, + struct _cef_frame_t* frame, + int httpStatusCode); /// - // Called when the resource load for a navigation fails or is canceled. - // |errorCode| is the error code number, |errorText| is the error text and - // |failedUrl| is the URL that failed to load. See net\base\net_error_list.h - // for complete descriptions of the error codes. + // Called when a navigation fails or is canceled. This function may be called + // by itself if before commit or in combination with OnLoadStart/OnLoadEnd if + // after commit. |errorCode| is the error code number, |errorText| is the + // error text and |failedUrl| is the URL that failed to load. See + // net\base\net_error_list.h for complete descriptions of the error codes. /// - void (CEF_CALLBACK *on_load_error)(struct _cef_load_handler_t* self, - struct _cef_browser_t* browser, struct _cef_frame_t* frame, - cef_errorcode_t errorCode, const cef_string_t* errorText, - const cef_string_t* failedUrl); + void(CEF_CALLBACK* on_load_error)(struct _cef_load_handler_t* self, + struct _cef_browser_t* browser, + struct _cef_frame_t* frame, + cef_errorcode_t errorCode, + const cef_string_t* errorText, + const cef_string_t* failedUrl); } cef_load_handler_t; - #ifdef __cplusplus } #endif diff --git a/include/capi/cef_menu_model_capi.h b/include/capi/cef_menu_model_capi.h index bd253a4..8c29500 100644 --- a/include/capi/cef_menu_model_capi.h +++ b/include/capi/cef_menu_model_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,18 +33,20 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=295f7f55ebe6d548aba1476e67efb2c88ab10ca5$ +// #ifndef CEF_INCLUDE_CAPI_CEF_MENU_MODEL_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_MENU_MODEL_CAPI_H_ #pragma once +#include "include/capi/cef_base_capi.h" +#include "include/capi/cef_menu_model_delegate_capi.h" + #ifdef __cplusplus extern "C" { #endif -#include "include/capi/cef_base_capi.h" - - /// // Supports creation and modification of menus. See cef_menu_id_t for the // command ids that have default implementations. All user-defined command ids @@ -55,331 +57,452 @@ typedef struct _cef_menu_model_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; + + /// + // Returns true (1) if this menu is a submenu. + /// + int(CEF_CALLBACK* is_sub_menu)(struct _cef_menu_model_t* self); /// // Clears the menu. Returns true (1) on success. /// - int (CEF_CALLBACK *clear)(struct _cef_menu_model_t* self); + int(CEF_CALLBACK* clear)(struct _cef_menu_model_t* self); /// // Returns the number of items in this menu. /// - int (CEF_CALLBACK *get_count)(struct _cef_menu_model_t* self); + int(CEF_CALLBACK* get_count)(struct _cef_menu_model_t* self); - // + /// // Add a separator to the menu. Returns true (1) on success. /// - int (CEF_CALLBACK *add_separator)(struct _cef_menu_model_t* self); + int(CEF_CALLBACK* add_separator)(struct _cef_menu_model_t* self); - // + /// // Add an item to the menu. Returns true (1) on success. /// - int (CEF_CALLBACK *add_item)(struct _cef_menu_model_t* self, int command_id, - const cef_string_t* label); + int(CEF_CALLBACK* add_item)(struct _cef_menu_model_t* self, + int command_id, + const cef_string_t* label); - // + /// // Add a check item to the menu. Returns true (1) on success. /// - int (CEF_CALLBACK *add_check_item)(struct _cef_menu_model_t* self, - int command_id, const cef_string_t* label); + int(CEF_CALLBACK* add_check_item)(struct _cef_menu_model_t* self, + int command_id, + const cef_string_t* label); - // + /// // Add a radio item to the menu. Only a single item with the specified // |group_id| can be checked at a time. Returns true (1) on success. /// - int (CEF_CALLBACK *add_radio_item)(struct _cef_menu_model_t* self, - int command_id, const cef_string_t* label, int group_id); + int(CEF_CALLBACK* add_radio_item)(struct _cef_menu_model_t* self, + int command_id, + const cef_string_t* label, + int group_id); - // + /// // Add a sub-menu to the menu. The new sub-menu is returned. /// - struct _cef_menu_model_t* (CEF_CALLBACK *add_sub_menu)( - struct _cef_menu_model_t* self, int command_id, + struct _cef_menu_model_t*(CEF_CALLBACK* add_sub_menu)( + struct _cef_menu_model_t* self, + int command_id, const cef_string_t* label); - // + /// // Insert a separator in the menu at the specified |index|. Returns true (1) // on success. /// - int (CEF_CALLBACK *insert_separator_at)(struct _cef_menu_model_t* self, - int index); + int(CEF_CALLBACK* insert_separator_at)(struct _cef_menu_model_t* self, + int index); - // + /// // Insert an item in the menu at the specified |index|. Returns true (1) on // success. /// - int (CEF_CALLBACK *insert_item_at)(struct _cef_menu_model_t* self, int index, - int command_id, const cef_string_t* label); + int(CEF_CALLBACK* insert_item_at)(struct _cef_menu_model_t* self, + int index, + int command_id, + const cef_string_t* label); - // + /// // Insert a check item in the menu at the specified |index|. Returns true (1) // on success. /// - int (CEF_CALLBACK *insert_check_item_at)(struct _cef_menu_model_t* self, - int index, int command_id, const cef_string_t* label); + int(CEF_CALLBACK* insert_check_item_at)(struct _cef_menu_model_t* self, + int index, + int command_id, + const cef_string_t* label); - // + /// // Insert a radio item in the menu at the specified |index|. Only a single // item with the specified |group_id| can be checked at a time. Returns true // (1) on success. /// - int (CEF_CALLBACK *insert_radio_item_at)(struct _cef_menu_model_t* self, - int index, int command_id, const cef_string_t* label, int group_id); + int(CEF_CALLBACK* insert_radio_item_at)(struct _cef_menu_model_t* self, + int index, + int command_id, + const cef_string_t* label, + int group_id); - // + /// // Insert a sub-menu in the menu at the specified |index|. The new sub-menu is // returned. /// - struct _cef_menu_model_t* (CEF_CALLBACK *insert_sub_menu_at)( - struct _cef_menu_model_t* self, int index, int command_id, + struct _cef_menu_model_t*(CEF_CALLBACK* insert_sub_menu_at)( + struct _cef_menu_model_t* self, + int index, + int command_id, const cef_string_t* label); /// // Removes the item with the specified |command_id|. Returns true (1) on // success. /// - int (CEF_CALLBACK *remove)(struct _cef_menu_model_t* self, int command_id); + int(CEF_CALLBACK* remove)(struct _cef_menu_model_t* self, int command_id); /// // Removes the item at the specified |index|. Returns true (1) on success. /// - int (CEF_CALLBACK *remove_at)(struct _cef_menu_model_t* self, int index); + int(CEF_CALLBACK* remove_at)(struct _cef_menu_model_t* self, int index); /// // Returns the index associated with the specified |command_id| or -1 if not // found due to the command id not existing in the menu. /// - int (CEF_CALLBACK *get_index_of)(struct _cef_menu_model_t* self, - int command_id); + int(CEF_CALLBACK* get_index_of)(struct _cef_menu_model_t* self, + int command_id); /// // Returns the command id at the specified |index| or -1 if not found due to // invalid range or the index being a separator. /// - int (CEF_CALLBACK *get_command_id_at)(struct _cef_menu_model_t* self, - int index); + int(CEF_CALLBACK* get_command_id_at)(struct _cef_menu_model_t* self, + int index); /// // Sets the command id at the specified |index|. Returns true (1) on success. /// - int (CEF_CALLBACK *set_command_id_at)(struct _cef_menu_model_t* self, - int index, int command_id); + int(CEF_CALLBACK* set_command_id_at)(struct _cef_menu_model_t* self, + int index, + int command_id); /// // Returns the label for the specified |command_id| or NULL if not found. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_label)( - struct _cef_menu_model_t* self, int command_id); + cef_string_userfree_t(CEF_CALLBACK* get_label)(struct _cef_menu_model_t* self, + int command_id); /// // Returns the label at the specified |index| or NULL if not found due to // invalid range or the index being a separator. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_label_at)( - struct _cef_menu_model_t* self, int index); + cef_string_userfree_t( + CEF_CALLBACK* get_label_at)(struct _cef_menu_model_t* self, int index); /// // Sets the label for the specified |command_id|. Returns true (1) on success. /// - int (CEF_CALLBACK *set_label)(struct _cef_menu_model_t* self, int command_id, - const cef_string_t* label); + int(CEF_CALLBACK* set_label)(struct _cef_menu_model_t* self, + int command_id, + const cef_string_t* label); /// // Set the label at the specified |index|. Returns true (1) on success. /// - int (CEF_CALLBACK *set_label_at)(struct _cef_menu_model_t* self, int index, - const cef_string_t* label); + int(CEF_CALLBACK* set_label_at)(struct _cef_menu_model_t* self, + int index, + const cef_string_t* label); /// // Returns the item type for the specified |command_id|. /// - cef_menu_item_type_t (CEF_CALLBACK *get_type)(struct _cef_menu_model_t* self, - int command_id); + cef_menu_item_type_t(CEF_CALLBACK* get_type)(struct _cef_menu_model_t* self, + int command_id); /// // Returns the item type at the specified |index|. /// - cef_menu_item_type_t (CEF_CALLBACK *get_type_at)( - struct _cef_menu_model_t* self, int index); + cef_menu_item_type_t( + CEF_CALLBACK* get_type_at)(struct _cef_menu_model_t* self, int index); /// // Returns the group id for the specified |command_id| or -1 if invalid. /// - int (CEF_CALLBACK *get_group_id)(struct _cef_menu_model_t* self, - int command_id); + int(CEF_CALLBACK* get_group_id)(struct _cef_menu_model_t* self, + int command_id); /// // Returns the group id at the specified |index| or -1 if invalid. /// - int (CEF_CALLBACK *get_group_id_at)(struct _cef_menu_model_t* self, - int index); + int(CEF_CALLBACK* get_group_id_at)(struct _cef_menu_model_t* self, int index); /// // Sets the group id for the specified |command_id|. Returns true (1) on // success. /// - int (CEF_CALLBACK *set_group_id)(struct _cef_menu_model_t* self, - int command_id, int group_id); + int(CEF_CALLBACK* set_group_id)(struct _cef_menu_model_t* self, + int command_id, + int group_id); /// // Sets the group id at the specified |index|. Returns true (1) on success. /// - int (CEF_CALLBACK *set_group_id_at)(struct _cef_menu_model_t* self, int index, - int group_id); + int(CEF_CALLBACK* set_group_id_at)(struct _cef_menu_model_t* self, + int index, + int group_id); /// // Returns the submenu for the specified |command_id| or NULL if invalid. /// - struct _cef_menu_model_t* (CEF_CALLBACK *get_sub_menu)( - struct _cef_menu_model_t* self, int command_id); + struct _cef_menu_model_t*(CEF_CALLBACK* get_sub_menu)( + struct _cef_menu_model_t* self, + int command_id); /// // Returns the submenu at the specified |index| or NULL if invalid. /// - struct _cef_menu_model_t* (CEF_CALLBACK *get_sub_menu_at)( - struct _cef_menu_model_t* self, int index); + struct _cef_menu_model_t*( + CEF_CALLBACK* get_sub_menu_at)(struct _cef_menu_model_t* self, int index); - // + /// // Returns true (1) if the specified |command_id| is visible. /// - int (CEF_CALLBACK *is_visible)(struct _cef_menu_model_t* self, - int command_id); + int(CEF_CALLBACK* is_visible)(struct _cef_menu_model_t* self, int command_id); - // + /// // Returns true (1) if the specified |index| is visible. /// - int (CEF_CALLBACK *is_visible_at)(struct _cef_menu_model_t* self, int index); + int(CEF_CALLBACK* is_visible_at)(struct _cef_menu_model_t* self, int index); - // + /// // Change the visibility of the specified |command_id|. Returns true (1) on // success. /// - int (CEF_CALLBACK *set_visible)(struct _cef_menu_model_t* self, - int command_id, int visible); + int(CEF_CALLBACK* set_visible)(struct _cef_menu_model_t* self, + int command_id, + int visible); - // + /// // Change the visibility at the specified |index|. Returns true (1) on // success. /// - int (CEF_CALLBACK *set_visible_at)(struct _cef_menu_model_t* self, int index, - int visible); + int(CEF_CALLBACK* set_visible_at)(struct _cef_menu_model_t* self, + int index, + int visible); - // + /// // Returns true (1) if the specified |command_id| is enabled. /// - int (CEF_CALLBACK *is_enabled)(struct _cef_menu_model_t* self, - int command_id); + int(CEF_CALLBACK* is_enabled)(struct _cef_menu_model_t* self, int command_id); - // + /// // Returns true (1) if the specified |index| is enabled. /// - int (CEF_CALLBACK *is_enabled_at)(struct _cef_menu_model_t* self, int index); + int(CEF_CALLBACK* is_enabled_at)(struct _cef_menu_model_t* self, int index); - // + /// // Change the enabled status of the specified |command_id|. Returns true (1) // on success. /// - int (CEF_CALLBACK *set_enabled)(struct _cef_menu_model_t* self, - int command_id, int enabled); + int(CEF_CALLBACK* set_enabled)(struct _cef_menu_model_t* self, + int command_id, + int enabled); - // + /// // Change the enabled status at the specified |index|. Returns true (1) on // success. /// - int (CEF_CALLBACK *set_enabled_at)(struct _cef_menu_model_t* self, int index, - int enabled); + int(CEF_CALLBACK* set_enabled_at)(struct _cef_menu_model_t* self, + int index, + int enabled); - // + /// // Returns true (1) if the specified |command_id| is checked. Only applies to // check and radio items. /// - int (CEF_CALLBACK *is_checked)(struct _cef_menu_model_t* self, - int command_id); + int(CEF_CALLBACK* is_checked)(struct _cef_menu_model_t* self, int command_id); - // + /// // Returns true (1) if the specified |index| is checked. Only applies to check // and radio items. /// - int (CEF_CALLBACK *is_checked_at)(struct _cef_menu_model_t* self, int index); + int(CEF_CALLBACK* is_checked_at)(struct _cef_menu_model_t* self, int index); - // + /// // Check the specified |command_id|. Only applies to check and radio items. // Returns true (1) on success. /// - int (CEF_CALLBACK *set_checked)(struct _cef_menu_model_t* self, - int command_id, int checked); + int(CEF_CALLBACK* set_checked)(struct _cef_menu_model_t* self, + int command_id, + int checked); - // + /// // Check the specified |index|. Only applies to check and radio items. Returns // true (1) on success. /// - int (CEF_CALLBACK *set_checked_at)(struct _cef_menu_model_t* self, int index, - int checked); + int(CEF_CALLBACK* set_checked_at)(struct _cef_menu_model_t* self, + int index, + int checked); - // + /// // Returns true (1) if the specified |command_id| has a keyboard accelerator // assigned. /// - int (CEF_CALLBACK *has_accelerator)(struct _cef_menu_model_t* self, - int command_id); + int(CEF_CALLBACK* has_accelerator)(struct _cef_menu_model_t* self, + int command_id); - // + /// // Returns true (1) if the specified |index| has a keyboard accelerator // assigned. /// - int (CEF_CALLBACK *has_accelerator_at)(struct _cef_menu_model_t* self, - int index); + int(CEF_CALLBACK* has_accelerator_at)(struct _cef_menu_model_t* self, + int index); - // + /// // Set the keyboard accelerator for the specified |command_id|. |key_code| can // be any virtual key or character value. Returns true (1) on success. /// - int (CEF_CALLBACK *set_accelerator)(struct _cef_menu_model_t* self, - int command_id, int key_code, int shift_pressed, int ctrl_pressed, - int alt_pressed); + int(CEF_CALLBACK* set_accelerator)(struct _cef_menu_model_t* self, + int command_id, + int key_code, + int shift_pressed, + int ctrl_pressed, + int alt_pressed); - // + /// // Set the keyboard accelerator at the specified |index|. |key_code| can be // any virtual key or character value. Returns true (1) on success. /// - int (CEF_CALLBACK *set_accelerator_at)(struct _cef_menu_model_t* self, - int index, int key_code, int shift_pressed, int ctrl_pressed, - int alt_pressed); + int(CEF_CALLBACK* set_accelerator_at)(struct _cef_menu_model_t* self, + int index, + int key_code, + int shift_pressed, + int ctrl_pressed, + int alt_pressed); - // + /// // Remove the keyboard accelerator for the specified |command_id|. Returns // true (1) on success. /// - int (CEF_CALLBACK *remove_accelerator)(struct _cef_menu_model_t* self, - int command_id); + int(CEF_CALLBACK* remove_accelerator)(struct _cef_menu_model_t* self, + int command_id); - // + /// // Remove the keyboard accelerator at the specified |index|. Returns true (1) // on success. /// - int (CEF_CALLBACK *remove_accelerator_at)(struct _cef_menu_model_t* self, - int index); + int(CEF_CALLBACK* remove_accelerator_at)(struct _cef_menu_model_t* self, + int index); - // + /// // Retrieves the keyboard accelerator for the specified |command_id|. Returns // true (1) on success. /// - int (CEF_CALLBACK *get_accelerator)(struct _cef_menu_model_t* self, - int command_id, int* key_code, int* shift_pressed, int* ctrl_pressed, - int* alt_pressed); + int(CEF_CALLBACK* get_accelerator)(struct _cef_menu_model_t* self, + int command_id, + int* key_code, + int* shift_pressed, + int* ctrl_pressed, + int* alt_pressed); - // + /// // Retrieves the keyboard accelerator for the specified |index|. Returns true // (1) on success. /// - int (CEF_CALLBACK *get_accelerator_at)(struct _cef_menu_model_t* self, - int index, int* key_code, int* shift_pressed, int* ctrl_pressed, - int* alt_pressed); + int(CEF_CALLBACK* get_accelerator_at)(struct _cef_menu_model_t* self, + int index, + int* key_code, + int* shift_pressed, + int* ctrl_pressed, + int* alt_pressed); + + /// + // Set the explicit color for |command_id| and |color_type| to |color|. + // Specify a |color| value of 0 to remove the explicit color. If no explicit + // color or default color is set for |color_type| then the system color will + // be used. Returns true (1) on success. + /// + int(CEF_CALLBACK* set_color)(struct _cef_menu_model_t* self, + int command_id, + cef_menu_color_type_t color_type, + cef_color_t color); + + /// + // Set the explicit color for |command_id| and |index| to |color|. Specify a + // |color| value of 0 to remove the explicit color. Specify an |index| value + // of -1 to set the default color for items that do not have an explicit color + // set. If no explicit color or default color is set for |color_type| then the + // system color will be used. Returns true (1) on success. + /// + int(CEF_CALLBACK* set_color_at)(struct _cef_menu_model_t* self, + int index, + cef_menu_color_type_t color_type, + cef_color_t color); + + /// + // Returns in |color| the color that was explicitly set for |command_id| and + // |color_type|. If a color was not set then 0 will be returned in |color|. + // Returns true (1) on success. + /// + int(CEF_CALLBACK* get_color)(struct _cef_menu_model_t* self, + int command_id, + cef_menu_color_type_t color_type, + cef_color_t* color); + + /// + // Returns in |color| the color that was explicitly set for |command_id| and + // |color_type|. Specify an |index| value of -1 to return the default color in + // |color|. If a color was not set then 0 will be returned in |color|. Returns + // true (1) on success. + /// + int(CEF_CALLBACK* get_color_at)(struct _cef_menu_model_t* self, + int index, + cef_menu_color_type_t color_type, + cef_color_t* color); + + /// + // Sets the font list for the specified |command_id|. If |font_list| is NULL + // the system font will be used. Returns true (1) on success. The format is + // ",[STYLES] ", where: - FONT_FAMILY_LIST is a comma- + // separated list of font family names, - STYLES is an optional space- + // separated list of style names (case-sensitive + // "Bold" and "Italic" are supported), and + // - SIZE is an integer font size in pixels with the suffix "px". + // + // Here are examples of valid font description strings: - "Arial, Helvetica, + // Bold Italic 14px" - "Arial, 14px" + /// + int(CEF_CALLBACK* set_font_list)(struct _cef_menu_model_t* self, + int command_id, + const cef_string_t* font_list); + + /// + // Sets the font list for the specified |index|. Specify an |index| value of + // -1 to set the default font. If |font_list| is NULL the system font will be + // used. Returns true (1) on success. The format is + // ",[STYLES] ", where: - FONT_FAMILY_LIST is a comma- + // separated list of font family names, - STYLES is an optional space- + // separated list of style names (case-sensitive + // "Bold" and "Italic" are supported), and + // - SIZE is an integer font size in pixels with the suffix "px". + // + // Here are examples of valid font description strings: - "Arial, Helvetica, + // Bold Italic 14px" - "Arial, 14px" + /// + int(CEF_CALLBACK* set_font_list_at)(struct _cef_menu_model_t* self, + int index, + const cef_string_t* font_list); } cef_menu_model_t; +/// +// Create a new MenuModel with the specified |delegate|. +/// +CEF_EXPORT cef_menu_model_t* cef_menu_model_create( + struct _cef_menu_model_delegate_t* delegate); #ifdef __cplusplus } diff --git a/include/capi/cef_menu_model_delegate_capi.h b/include/capi/cef_menu_model_delegate_capi.h new file mode 100644 index 0000000..e9b8cc3 --- /dev/null +++ b/include/capi/cef_menu_model_delegate_capi.h @@ -0,0 +1,123 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=74f40f20f94ce3a6e7f3c879a3834a7108099ed4$ +// + +#ifndef CEF_INCLUDE_CAPI_CEF_MENU_MODEL_DELEGATE_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_MENU_MODEL_DELEGATE_CAPI_H_ +#pragma once + +#include "include/capi/cef_base_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct _cef_menu_model_t; + +/// +// Implement this structure to handle menu model events. The functions of this +// structure will be called on the browser process UI thread unless otherwise +// indicated. +/// +typedef struct _cef_menu_model_delegate_t { + /// + // Base structure. + /// + cef_base_ref_counted_t base; + + /// + // Perform the action associated with the specified |command_id| and optional + // |event_flags|. + /// + void(CEF_CALLBACK* execute_command)(struct _cef_menu_model_delegate_t* self, + struct _cef_menu_model_t* menu_model, + int command_id, + cef_event_flags_t event_flags); + + /// + // Called when the user moves the mouse outside the menu and over the owning + // window. + /// + void(CEF_CALLBACK* mouse_outside_menu)( + struct _cef_menu_model_delegate_t* self, + struct _cef_menu_model_t* menu_model, + const cef_point_t* screen_point); + + /// + // Called on unhandled open submenu keyboard commands. |is_rtl| will be true + // (1) if the menu is displaying a right-to-left language. + /// + void(CEF_CALLBACK* unhandled_open_submenu)( + struct _cef_menu_model_delegate_t* self, + struct _cef_menu_model_t* menu_model, + int is_rtl); + + /// + // Called on unhandled close submenu keyboard commands. |is_rtl| will be true + // (1) if the menu is displaying a right-to-left language. + /// + void(CEF_CALLBACK* unhandled_close_submenu)( + struct _cef_menu_model_delegate_t* self, + struct _cef_menu_model_t* menu_model, + int is_rtl); + + /// + // The menu is about to show. + /// + void(CEF_CALLBACK* menu_will_show)(struct _cef_menu_model_delegate_t* self, + struct _cef_menu_model_t* menu_model); + + /// + // The menu has closed. + /// + void(CEF_CALLBACK* menu_closed)(struct _cef_menu_model_delegate_t* self, + struct _cef_menu_model_t* menu_model); + + /// + // Optionally modify a menu item label. Return true (1) if |label| was + // modified. + /// + int(CEF_CALLBACK* format_label)(struct _cef_menu_model_delegate_t* self, + struct _cef_menu_model_t* menu_model, + cef_string_t* label); +} cef_menu_model_delegate_t; + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_MENU_MODEL_DELEGATE_CAPI_H_ diff --git a/include/capi/cef_navigation_entry_capi.h b/include/capi/cef_navigation_entry_capi.h new file mode 100644 index 0000000..e889220 --- /dev/null +++ b/include/capi/cef_navigation_entry_capi.h @@ -0,0 +1,132 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=a862d0004de2a1bdf4c214fe87278badd90562a7$ +// + +#ifndef CEF_INCLUDE_CAPI_CEF_NAVIGATION_ENTRY_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_NAVIGATION_ENTRY_CAPI_H_ +#pragma once + +#include "include/capi/cef_base_capi.h" +#include "include/capi/cef_ssl_status_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// Structure used to represent an entry in navigation history. +/// +typedef struct _cef_navigation_entry_t { + /// + // Base structure. + /// + cef_base_ref_counted_t base; + + /// + // Returns true (1) if this object is valid. Do not call any other functions + // if this function returns false (0). + /// + int(CEF_CALLBACK* is_valid)(struct _cef_navigation_entry_t* self); + + /// + // Returns the actual URL of the page. For some pages this may be data: URL or + // similar. Use get_display_url() to return a display-friendly version. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t(CEF_CALLBACK* get_url)( + struct _cef_navigation_entry_t* self); + + /// + // Returns a display-friendly version of the URL. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t(CEF_CALLBACK* get_display_url)( + struct _cef_navigation_entry_t* self); + + /// + // Returns the original URL that was entered by the user before any redirects. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t(CEF_CALLBACK* get_original_url)( + struct _cef_navigation_entry_t* self); + + /// + // Returns the title set by the page. This value may be NULL. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t(CEF_CALLBACK* get_title)( + struct _cef_navigation_entry_t* self); + + /// + // Returns the transition type which indicates what the user did to move to + // this page from the previous page. + /// + cef_transition_type_t(CEF_CALLBACK* get_transition_type)( + struct _cef_navigation_entry_t* self); + + /// + // Returns true (1) if this navigation includes post data. + /// + int(CEF_CALLBACK* has_post_data)(struct _cef_navigation_entry_t* self); + + /// + // Returns the time for the last known successful navigation completion. A + // navigation may be completed more than once if the page is reloaded. May be + // 0 if the navigation has not yet completed. + /// + cef_time_t(CEF_CALLBACK* get_completion_time)( + struct _cef_navigation_entry_t* self); + + /// + // Returns the HTTP status code for the last known successful navigation + // response. May be 0 if the response has not yet been received or if the + // navigation has not yet completed. + /// + int(CEF_CALLBACK* get_http_status_code)(struct _cef_navigation_entry_t* self); + + /// + // Returns the SSL information for this navigation entry. + /// + struct _cef_sslstatus_t*(CEF_CALLBACK* get_sslstatus)( + struct _cef_navigation_entry_t* self); +} cef_navigation_entry_t; + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_NAVIGATION_ENTRY_CAPI_H_ diff --git a/include/capi/cef_origin_whitelist_capi.h b/include/capi/cef_origin_whitelist_capi.h index 3b56a5c..7b252aa 100644 --- a/include/capi/cef_origin_whitelist_capi.h +++ b/include/capi/cef_origin_whitelist_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,18 +33,19 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=2e5afff3277384ea9f3f74ef509c018f6d307dc4$ +// #ifndef CEF_INCLUDE_CAPI_CEF_ORIGIN_WHITELIST_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_ORIGIN_WHITELIST_CAPI_H_ #pragma once +#include "include/capi/cef_base_capi.h" + #ifdef __cplusplus extern "C" { #endif -#include "include/capi/cef_base_capi.h" - - /// // Add an entry to the cross-origin access whitelist. // @@ -82,16 +83,20 @@ extern "C" { // |source_origin| is invalid or the whitelist cannot be accessed. /// CEF_EXPORT int cef_add_cross_origin_whitelist_entry( - const cef_string_t* source_origin, const cef_string_t* target_protocol, - const cef_string_t* target_domain, int allow_target_subdomains); + const cef_string_t* source_origin, + const cef_string_t* target_protocol, + const cef_string_t* target_domain, + int allow_target_subdomains); /// // Remove an entry from the cross-origin access whitelist. Returns false (0) if // |source_origin| is invalid or the whitelist cannot be accessed. /// CEF_EXPORT int cef_remove_cross_origin_whitelist_entry( - const cef_string_t* source_origin, const cef_string_t* target_protocol, - const cef_string_t* target_domain, int allow_target_subdomains); + const cef_string_t* source_origin, + const cef_string_t* target_protocol, + const cef_string_t* target_domain, + int allow_target_subdomains); /// // Remove all entries from the cross-origin access whitelist. Returns false (0) diff --git a/include/capi/cef_parser_capi.h b/include/capi/cef_parser_capi.h new file mode 100644 index 0000000..0ac640b --- /dev/null +++ b/include/capi/cef_parser_capi.h @@ -0,0 +1,168 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=d2f01fbfc3ae72a86c03399606088054b3a9337f$ +// + +#ifndef CEF_INCLUDE_CAPI_CEF_PARSER_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_PARSER_CAPI_H_ +#pragma once + +#include "include/capi/cef_base_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// Parse the specified |url| into its component parts. Returns false (0) if the +// URL is NULL or invalid. +/// +CEF_EXPORT int cef_parse_url(const cef_string_t* url, + struct _cef_urlparts_t* parts); + +/// +// Creates a URL from the specified |parts|, which must contain a non-NULL spec +// or a non-NULL host and path (at a minimum), but not both. Returns false (0) +// if |parts| isn't initialized as described. +/// +CEF_EXPORT int cef_create_url(const struct _cef_urlparts_t* parts, + cef_string_t* url); + +/// +// This is a convenience function for formatting a URL in a concise and human- +// friendly way to help users make security-related decisions (or in other +// circumstances when people need to distinguish sites, origins, or otherwise- +// simplified URLs from each other). Internationalized domain names (IDN) may be +// presented in Unicode if the conversion is considered safe. The returned value +// will (a) omit the path for standard schemes, excepting file and filesystem, +// and (b) omit the port if it is the default for the scheme. Do not use this +// for URLs which will be parsed or sent to other applications. +/// +// The resulting string must be freed by calling cef_string_userfree_free(). +CEF_EXPORT cef_string_userfree_t +cef_format_url_for_security_display(const cef_string_t* origin_url); + +/// +// Returns the mime type for the specified file extension or an NULL string if +// unknown. +/// +// The resulting string must be freed by calling cef_string_userfree_free(). +CEF_EXPORT cef_string_userfree_t +cef_get_mime_type(const cef_string_t* extension); + +/// +// Get the extensions associated with the given mime type. This should be passed +// in lower case. There could be multiple extensions for a given mime type, like +// "html,htm" for "text/html", or "txt,text,html,..." for "text/*". Any existing +// elements in the provided vector will not be erased. +/// +CEF_EXPORT void cef_get_extensions_for_mime_type(const cef_string_t* mime_type, + cef_string_list_t extensions); + +/// +// Encodes |data| as a base64 string. +/// +// The resulting string must be freed by calling cef_string_userfree_free(). +CEF_EXPORT cef_string_userfree_t cef_base64encode(const void* data, + size_t data_size); + +/// +// Decodes the base64 encoded string |data|. The returned value will be NULL if +// the decoding fails. +/// +CEF_EXPORT struct _cef_binary_value_t* cef_base64decode( + const cef_string_t* data); + +/// +// Escapes characters in |text| which are unsuitable for use as a query +// parameter value. Everything except alphanumerics and -_.!~*'() will be +// converted to "%XX". If |use_plus| is true (1) spaces will change to "+". The +// result is basically the same as encodeURIComponent in Javacript. +/// +// The resulting string must be freed by calling cef_string_userfree_free(). +CEF_EXPORT cef_string_userfree_t cef_uriencode(const cef_string_t* text, + int use_plus); + +/// +// Unescapes |text| and returns the result. Unescaping consists of looking for +// the exact pattern "%XX" where each X is a hex digit and converting to the +// character with the numerical value of those digits (e.g. "i%20=%203%3b" +// unescapes to "i = 3;"). If |convert_to_utf8| is true (1) this function will +// attempt to interpret the initial decoded result as UTF-8. If the result is +// convertable into UTF-8 it will be returned as converted. Otherwise the +// initial decoded result will be returned. The |unescape_rule| parameter +// supports further customization the decoding process. +/// +// The resulting string must be freed by calling cef_string_userfree_free(). +CEF_EXPORT cef_string_userfree_t +cef_uridecode(const cef_string_t* text, + int convert_to_utf8, + cef_uri_unescape_rule_t unescape_rule); + +/// +// Parses the specified |json_string| and returns a dictionary or list +// representation. If JSON parsing fails this function returns NULL. +/// +CEF_EXPORT struct _cef_value_t* cef_parse_json( + const cef_string_t* json_string, + cef_json_parser_options_t options); + +/// +// Parses the specified |json_string| and returns a dictionary or list +// representation. If JSON parsing fails this function returns NULL and +// populates |error_code_out| and |error_msg_out| with an error code and a +// formatted error message respectively. +/// +CEF_EXPORT struct _cef_value_t* cef_parse_jsonand_return_error( + const cef_string_t* json_string, + cef_json_parser_options_t options, + cef_json_parser_error_t* error_code_out, + cef_string_t* error_msg_out); + +/// +// Generates a JSON string from the specified root |node| which should be a +// dictionary or list value. Returns an NULL string on failure. This function +// requires exclusive access to |node| including any underlying data. +/// +// The resulting string must be freed by calling cef_string_userfree_free(). +CEF_EXPORT cef_string_userfree_t +cef_write_json(struct _cef_value_t* node, cef_json_writer_options_t options); + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_PARSER_CAPI_H_ diff --git a/include/capi/cef_path_util_capi.h b/include/capi/cef_path_util_capi.h index ff04860..849bcb9 100644 --- a/include/capi/cef_path_util_capi.h +++ b/include/capi/cef_path_util_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,18 +33,19 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=fbb817705137a12b4718950ff696396c30057007$ +// #ifndef CEF_INCLUDE_CAPI_CEF_PATH_UTIL_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_PATH_UTIL_CAPI_H_ #pragma once +#include "include/capi/cef_base_capi.h" + #ifdef __cplusplus extern "C" { #endif -#include "include/capi/cef_base_capi.h" - - /// // Retrieve the path associated with the specified |key|. Returns true (1) on // success. Can be called on any thread in the browser process. diff --git a/include/capi/cef_print_handler_capi.h b/include/capi/cef_print_handler_capi.h new file mode 100644 index 0000000..fbafd6e --- /dev/null +++ b/include/capi/cef_print_handler_capi.h @@ -0,0 +1,158 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=897f5b1ec6ed7430fff156f47b4ce6371d5db6f2$ +// + +#ifndef CEF_INCLUDE_CAPI_CEF_PRINT_HANDLER_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_PRINT_HANDLER_CAPI_H_ +#pragma once + +#include "include/capi/cef_base_capi.h" +#include "include/capi/cef_browser_capi.h" +#include "include/capi/cef_print_settings_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// Callback structure for asynchronous continuation of print dialog requests. +/// +typedef struct _cef_print_dialog_callback_t { + /// + // Base structure. + /// + cef_base_ref_counted_t base; + + /// + // Continue printing with the specified |settings|. + /// + void(CEF_CALLBACK* cont)(struct _cef_print_dialog_callback_t* self, + struct _cef_print_settings_t* settings); + + /// + // Cancel the printing. + /// + void(CEF_CALLBACK* cancel)(struct _cef_print_dialog_callback_t* self); +} cef_print_dialog_callback_t; + +/// +// Callback structure for asynchronous continuation of print job requests. +/// +typedef struct _cef_print_job_callback_t { + /// + // Base structure. + /// + cef_base_ref_counted_t base; + + /// + // Indicate completion of the print job. + /// + void(CEF_CALLBACK* cont)(struct _cef_print_job_callback_t* self); +} cef_print_job_callback_t; + +/// +// Implement this structure to handle printing on Linux. Each browser will have +// only one print job in progress at a time. The functions of this structure +// will be called on the browser process UI thread. +/// +typedef struct _cef_print_handler_t { + /// + // Base structure. + /// + cef_base_ref_counted_t base; + + /// + // Called when printing has started for the specified |browser|. This function + // will be called before the other OnPrint*() functions and irrespective of + // how printing was initiated (e.g. cef_browser_host_t::print(), JavaScript + // window.print() or PDF extension print button). + /// + void(CEF_CALLBACK* on_print_start)(struct _cef_print_handler_t* self, + struct _cef_browser_t* browser); + + /// + // Synchronize |settings| with client state. If |get_defaults| is true (1) + // then populate |settings| with the default print settings. Do not keep a + // reference to |settings| outside of this callback. + /// + void(CEF_CALLBACK* on_print_settings)(struct _cef_print_handler_t* self, + struct _cef_browser_t* browser, + struct _cef_print_settings_t* settings, + int get_defaults); + + /// + // Show the print dialog. Execute |callback| once the dialog is dismissed. + // Return true (1) if the dialog will be displayed or false (0) to cancel the + // printing immediately. + /// + int(CEF_CALLBACK* on_print_dialog)( + struct _cef_print_handler_t* self, + struct _cef_browser_t* browser, + int has_selection, + struct _cef_print_dialog_callback_t* callback); + + /// + // Send the print job to the printer. Execute |callback| once the job is + // completed. Return true (1) if the job will proceed or false (0) to cancel + // the job immediately. + /// + int(CEF_CALLBACK* on_print_job)(struct _cef_print_handler_t* self, + struct _cef_browser_t* browser, + const cef_string_t* document_name, + const cef_string_t* pdf_file_path, + struct _cef_print_job_callback_t* callback); + + /// + // Reset client state related to printing. + /// + void(CEF_CALLBACK* on_print_reset)(struct _cef_print_handler_t* self, + struct _cef_browser_t* browser); + + /// + // Return the PDF paper size in device units. Used in combination with + // cef_browser_host_t::print_to_pdf(). + /// + cef_size_t(CEF_CALLBACK* get_pdf_paper_size)( + struct _cef_print_handler_t* self, + int device_units_per_inch); +} cef_print_handler_t; + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_PRINT_HANDLER_CAPI_H_ diff --git a/include/capi/cef_print_settings_capi.h b/include/capi/cef_print_settings_capi.h new file mode 100644 index 0000000..580e436 --- /dev/null +++ b/include/capi/cef_print_settings_capi.h @@ -0,0 +1,208 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=5b26ebd2d8e1e65a25fa0c08317b8994887c0498$ +// + +#ifndef CEF_INCLUDE_CAPI_CEF_PRINT_SETTINGS_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_PRINT_SETTINGS_CAPI_H_ +#pragma once + +#include "include/capi/cef_base_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// Structure representing print settings. +/// +typedef struct _cef_print_settings_t { + /// + // Base structure. + /// + cef_base_ref_counted_t base; + + /// + // Returns true (1) if this object is valid. Do not call any other functions + // if this function returns false (0). + /// + int(CEF_CALLBACK* is_valid)(struct _cef_print_settings_t* self); + + /// + // Returns true (1) if the values of this object are read-only. Some APIs may + // expose read-only objects. + /// + int(CEF_CALLBACK* is_read_only)(struct _cef_print_settings_t* self); + + /// + // Returns a writable copy of this object. + /// + struct _cef_print_settings_t*(CEF_CALLBACK* copy)( + struct _cef_print_settings_t* self); + + /// + // Set the page orientation. + /// + void(CEF_CALLBACK* set_orientation)(struct _cef_print_settings_t* self, + int landscape); + + /// + // Returns true (1) if the orientation is landscape. + /// + int(CEF_CALLBACK* is_landscape)(struct _cef_print_settings_t* self); + + /// + // Set the printer printable area in device units. Some platforms already + // provide flipped area. Set |landscape_needs_flip| to false (0) on those + // platforms to avoid double flipping. + /// + void(CEF_CALLBACK* set_printer_printable_area)( + struct _cef_print_settings_t* self, + const cef_size_t* physical_size_device_units, + const cef_rect_t* printable_area_device_units, + int landscape_needs_flip); + + /// + // Set the device name. + /// + void(CEF_CALLBACK* set_device_name)(struct _cef_print_settings_t* self, + const cef_string_t* name); + + /// + // Get the device name. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t(CEF_CALLBACK* get_device_name)( + struct _cef_print_settings_t* self); + + /// + // Set the DPI (dots per inch). + /// + void(CEF_CALLBACK* set_dpi)(struct _cef_print_settings_t* self, int dpi); + + /// + // Get the DPI (dots per inch). + /// + int(CEF_CALLBACK* get_dpi)(struct _cef_print_settings_t* self); + + /// + // Set the page ranges. + /// + void(CEF_CALLBACK* set_page_ranges)(struct _cef_print_settings_t* self, + size_t rangesCount, + cef_range_t const* ranges); + + /// + // Returns the number of page ranges that currently exist. + /// + size_t(CEF_CALLBACK* get_page_ranges_count)( + struct _cef_print_settings_t* self); + + /// + // Retrieve the page ranges. + /// + void(CEF_CALLBACK* get_page_ranges)(struct _cef_print_settings_t* self, + size_t* rangesCount, + cef_range_t* ranges); + + /// + // Set whether only the selection will be printed. + /// + void(CEF_CALLBACK* set_selection_only)(struct _cef_print_settings_t* self, + int selection_only); + + /// + // Returns true (1) if only the selection will be printed. + /// + int(CEF_CALLBACK* is_selection_only)(struct _cef_print_settings_t* self); + + /// + // Set whether pages will be collated. + /// + void(CEF_CALLBACK* set_collate)(struct _cef_print_settings_t* self, + int collate); + + /// + // Returns true (1) if pages will be collated. + /// + int(CEF_CALLBACK* will_collate)(struct _cef_print_settings_t* self); + + /// + // Set the color model. + /// + void(CEF_CALLBACK* set_color_model)(struct _cef_print_settings_t* self, + cef_color_model_t model); + + /// + // Get the color model. + /// + cef_color_model_t(CEF_CALLBACK* get_color_model)( + struct _cef_print_settings_t* self); + + /// + // Set the number of copies. + /// + void(CEF_CALLBACK* set_copies)(struct _cef_print_settings_t* self, + int copies); + + /// + // Get the number of copies. + /// + int(CEF_CALLBACK* get_copies)(struct _cef_print_settings_t* self); + + /// + // Set the duplex mode. + /// + void(CEF_CALLBACK* set_duplex_mode)(struct _cef_print_settings_t* self, + cef_duplex_mode_t mode); + + /// + // Get the duplex mode. + /// + cef_duplex_mode_t(CEF_CALLBACK* get_duplex_mode)( + struct _cef_print_settings_t* self); +} cef_print_settings_t; + +/// +// Create a new cef_print_settings_t object. +/// +CEF_EXPORT cef_print_settings_t* cef_print_settings_create(); + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_PRINT_SETTINGS_CAPI_H_ diff --git a/include/capi/cef_process_message_capi.h b/include/capi/cef_process_message_capi.h index ba167d1..ff76d33 100644 --- a/include/capi/cef_process_message_capi.h +++ b/include/capi/cef_process_message_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,18 +33,19 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=c2ee22474637f9aed7673670fb10c960ae621535$ +// #ifndef CEF_INCLUDE_CAPI_CEF_PROCESS_MESSAGE_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_PROCESS_MESSAGE_CAPI_H_ #pragma once -#ifdef __cplusplus -extern "C" { -#endif - #include "include/capi/cef_base_capi.h" #include "include/capi/cef_values_capi.h" +#ifdef __cplusplus +extern "C" { +#endif /// // Structure representing a message. Can be used on any process and thread. @@ -53,48 +54,46 @@ typedef struct _cef_process_message_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Returns true (1) if this object is valid. Do not call any other functions // if this function returns false (0). /// - int (CEF_CALLBACK *is_valid)(struct _cef_process_message_t* self); + int(CEF_CALLBACK* is_valid)(struct _cef_process_message_t* self); /// // Returns true (1) if the values of this object are read-only. Some APIs may // expose read-only objects. /// - int (CEF_CALLBACK *is_read_only)(struct _cef_process_message_t* self); + int(CEF_CALLBACK* is_read_only)(struct _cef_process_message_t* self); /// // Returns a writable copy of this object. /// - struct _cef_process_message_t* (CEF_CALLBACK *copy)( + struct _cef_process_message_t*(CEF_CALLBACK* copy)( struct _cef_process_message_t* self); /// // Returns the message name. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_name)( + cef_string_userfree_t(CEF_CALLBACK* get_name)( struct _cef_process_message_t* self); /// // Returns the list of arguments. /// - struct _cef_list_value_t* (CEF_CALLBACK *get_argument_list)( + struct _cef_list_value_t*(CEF_CALLBACK* get_argument_list)( struct _cef_process_message_t* self); } cef_process_message_t; - /// // Create a new cef_process_message_t object with the specified name. /// CEF_EXPORT cef_process_message_t* cef_process_message_create( const cef_string_t* name); - #ifdef __cplusplus } #endif diff --git a/include/capi/cef_process_util_capi.h b/include/capi/cef_process_util_capi.h index 1c3ca06..f138eb4 100644 --- a/include/capi/cef_process_util_capi.h +++ b/include/capi/cef_process_util_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,18 +33,19 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=aad07da2d500b8d31e02a75331bdb68f16d4c662$ +// #ifndef CEF_INCLUDE_CAPI_CEF_PROCESS_UTIL_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_PROCESS_UTIL_CAPI_H_ #pragma once +#include "include/capi/cef_base_capi.h" + #ifdef __cplusplus extern "C" { #endif -#include "include/capi/cef_base_capi.h" - - /// // Launches the process specified via |command_line|. Returns true (1) upon // success. Must be called on the browser process TID_PROCESS_LAUNCHER thread. diff --git a/include/capi/cef_render_handler_capi.h b/include/capi/cef_render_handler_capi.h index 63794ba..7469585 100644 --- a/include/capi/cef_render_handler_capi.h +++ b/include/capi/cef_render_handler_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,18 +33,21 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=5d20fc88dea8dad8691f05bfb7e8c1ce5cf2bbc1$ +// #ifndef CEF_INCLUDE_CAPI_CEF_RENDER_HANDLER_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_RENDER_HANDLER_CAPI_H_ #pragma once -#ifdef __cplusplus -extern "C" { -#endif - +#include "include/capi/cef_accessibility_handler_capi.h" #include "include/capi/cef_base_capi.h" #include "include/capi/cef_browser_capi.h" +#include "include/capi/cef_drag_data_capi.h" +#ifdef __cplusplus +extern "C" { +#endif /// // Implement this structure to handle events when window rendering is disabled. @@ -54,29 +57,41 @@ typedef struct _cef_render_handler_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; + + /// + // Return the handler for accessibility notifications. If no handler is + // provided the default implementation will be used. + /// + struct _cef_accessibility_handler_t*(CEF_CALLBACK* get_accessibility_handler)( + struct _cef_render_handler_t* self); /// // Called to retrieve the root window rectangle in screen coordinates. Return // true (1) if the rectangle was provided. /// - int (CEF_CALLBACK *get_root_screen_rect)(struct _cef_render_handler_t* self, - struct _cef_browser_t* browser, cef_rect_t* rect); + int(CEF_CALLBACK* get_root_screen_rect)(struct _cef_render_handler_t* self, + struct _cef_browser_t* browser, + cef_rect_t* rect); /// // Called to retrieve the view rectangle which is relative to screen // coordinates. Return true (1) if the rectangle was provided. /// - int (CEF_CALLBACK *get_view_rect)(struct _cef_render_handler_t* self, - struct _cef_browser_t* browser, cef_rect_t* rect); + int(CEF_CALLBACK* get_view_rect)(struct _cef_render_handler_t* self, + struct _cef_browser_t* browser, + cef_rect_t* rect); /// // Called to retrieve the translation from view coordinates to actual screen // coordinates. Return true (1) if the screen coordinates were provided. /// - int (CEF_CALLBACK *get_screen_point)(struct _cef_render_handler_t* self, - struct _cef_browser_t* browser, int viewX, int viewY, int* screenX, - int* screenY); + int(CEF_CALLBACK* get_screen_point)(struct _cef_render_handler_t* self, + struct _cef_browser_t* browser, + int viewX, + int viewY, + int* screenX, + int* screenY); /// // Called to allow the client to fill in the CefScreenInfo object with @@ -87,49 +102,108 @@ typedef struct _cef_render_handler_t { // will be used. If the rectangle is still NULL or invalid popups may not be // drawn correctly. /// - int (CEF_CALLBACK *get_screen_info)(struct _cef_render_handler_t* self, - struct _cef_browser_t* browser, struct _cef_screen_info_t* screen_info); + int(CEF_CALLBACK* get_screen_info)(struct _cef_render_handler_t* self, + struct _cef_browser_t* browser, + struct _cef_screen_info_t* screen_info); /// // Called when the browser wants to show or hide the popup widget. The popup // should be shown if |show| is true (1) and hidden if |show| is false (0). /// - void (CEF_CALLBACK *on_popup_show)(struct _cef_render_handler_t* self, - struct _cef_browser_t* browser, int show); + void(CEF_CALLBACK* on_popup_show)(struct _cef_render_handler_t* self, + struct _cef_browser_t* browser, + int show); /// // Called when the browser wants to move or resize the popup widget. |rect| - // contains the new location and size. + // contains the new location and size in view coordinates. + /// + void(CEF_CALLBACK* on_popup_size)(struct _cef_render_handler_t* self, + struct _cef_browser_t* browser, + const cef_rect_t* rect); + + /// + // Called when an element should be painted. Pixel values passed to this + // function are scaled relative to view coordinates based on the value of + // CefScreenInfo.device_scale_factor returned from GetScreenInfo. |type| + // indicates whether the element is the view or the popup widget. |buffer| + // contains the pixel data for the whole image. |dirtyRects| contains the set + // of rectangles in pixel coordinates that need to be repainted. |buffer| will + // be |width|*|height|*4 bytes in size and represents a BGRA image with an + // upper-left origin. + /// + void(CEF_CALLBACK* on_paint)(struct _cef_render_handler_t* self, + struct _cef_browser_t* browser, + cef_paint_element_type_t type, + size_t dirtyRectsCount, + cef_rect_t const* dirtyRects, + const void* buffer, + int width, + int height); + + /// + // Called when the browser's cursor has changed. If |type| is CT_CUSTOM then + // |custom_cursor_info| will be populated with the custom cursor information. + /// + void(CEF_CALLBACK* on_cursor_change)( + struct _cef_render_handler_t* self, + struct _cef_browser_t* browser, + cef_cursor_handle_t cursor, + cef_cursor_type_t type, + const struct _cef_cursor_info_t* custom_cursor_info); + + /// + // Called when the user starts dragging content in the web view. Contextual + // information about the dragged content is supplied by |drag_data|. (|x|, + // |y|) is the drag start location in screen coordinates. OS APIs that run a + // system message loop may be used within the StartDragging call. + // + // Return false (0) to abort the drag operation. Don't call any of + // cef_browser_host_t::DragSource*Ended* functions after returning false (0). + // + // Return true (1) to handle the drag operation. Call + // cef_browser_host_t::DragSourceEndedAt and DragSourceSystemDragEnded either + // synchronously or asynchronously to inform the web view that the drag + // operation has ended. /// - void (CEF_CALLBACK *on_popup_size)(struct _cef_render_handler_t* self, - struct _cef_browser_t* browser, const cef_rect_t* rect); + int(CEF_CALLBACK* start_dragging)(struct _cef_render_handler_t* self, + struct _cef_browser_t* browser, + struct _cef_drag_data_t* drag_data, + cef_drag_operations_mask_t allowed_ops, + int x, + int y); /// - // Called when an element should be painted. |type| indicates whether the - // element is the view or the popup widget. |buffer| contains the pixel data - // for the whole image. |dirtyRects| contains the set of rectangles that need - // to be repainted. On Windows |buffer| will be |width|*|height|*4 bytes in - // size and represents a BGRA image with an upper-left origin. + // Called when the web view wants to update the mouse cursor during a drag & + // drop operation. |operation| describes the allowed operation (none, move, + // copy, link). /// - void (CEF_CALLBACK *on_paint)(struct _cef_render_handler_t* self, - struct _cef_browser_t* browser, cef_paint_element_type_t type, - size_t dirtyRectsCount, cef_rect_t const* dirtyRects, const void* buffer, - int width, int height); + void(CEF_CALLBACK* update_drag_cursor)(struct _cef_render_handler_t* self, + struct _cef_browser_t* browser, + cef_drag_operations_mask_t operation); /// - // Called when the browser window's cursor has changed. + // Called when the scroll offset has changed. /// - void (CEF_CALLBACK *on_cursor_change)(struct _cef_render_handler_t* self, - struct _cef_browser_t* browser, cef_cursor_handle_t cursor); + void(CEF_CALLBACK* on_scroll_offset_changed)( + struct _cef_render_handler_t* self, + struct _cef_browser_t* browser, + double x, + double y); /// - // Called when the scroll offset has changed. + // Called when the IME composition range has changed. |selected_range| is the + // range of characters that have been selected. |character_bounds| is the + // bounds of each character in view coordinates. /// - void (CEF_CALLBACK *on_scroll_offset_changed)( - struct _cef_render_handler_t* self, struct _cef_browser_t* browser); + void(CEF_CALLBACK* on_ime_composition_range_changed)( + struct _cef_render_handler_t* self, + struct _cef_browser_t* browser, + const cef_range_t* selected_range, + size_t character_boundsCount, + cef_rect_t const* character_bounds); } cef_render_handler_t; - #ifdef __cplusplus } #endif diff --git a/include/capi/cef_render_process_handler_capi.h b/include/capi/cef_render_process_handler_capi.h index a56eb53..bb2a889 100644 --- a/include/capi/cef_render_process_handler_capi.h +++ b/include/capi/cef_render_process_handler_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,15 +33,13 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=04ddf8c8cc5e09610a6cd6dbee96194eb6567b41$ +// #ifndef CEF_INCLUDE_CAPI_CEF_RENDER_PROCESS_HANDLER_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_RENDER_PROCESS_HANDLER_CAPI_H_ #pragma once -#ifdef __cplusplus -extern "C" { -#endif - #include "include/capi/cef_base_capi.h" #include "include/capi/cef_browser_capi.h" #include "include/capi/cef_dom_capi.h" @@ -51,6 +49,9 @@ extern "C" { #include "include/capi/cef_v8_capi.h" #include "include/capi/cef_values_capi.h" +#ifdef __cplusplus +extern "C" { +#endif /// // Structure used to implement render process callbacks. The functions of this @@ -61,7 +62,7 @@ typedef struct _cef_render_process_handler_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Called after the render process main thread has been created. |extra_info| @@ -69,14 +70,14 @@ typedef struct _cef_render_process_handler_t { // cef_browser_process_handler_t::on_render_process_thread_created(). Do not // keep a reference to |extra_info| outside of this function. /// - void (CEF_CALLBACK *on_render_thread_created)( + void(CEF_CALLBACK* on_render_thread_created)( struct _cef_render_process_handler_t* self, struct _cef_list_value_t* extra_info); /// // Called after WebKit has been initialized. /// - void (CEF_CALLBACK *on_web_kit_initialized)( + void(CEF_CALLBACK* on_web_kit_initialized)( struct _cef_render_process_handler_t* self); /// @@ -84,21 +85,21 @@ typedef struct _cef_render_process_handler_t { // browser will be created before the old browser with the same identifier is // destroyed. /// - void (CEF_CALLBACK *on_browser_created)( + void(CEF_CALLBACK* on_browser_created)( struct _cef_render_process_handler_t* self, struct _cef_browser_t* browser); /// // Called before a browser is destroyed. /// - void (CEF_CALLBACK *on_browser_destroyed)( + void(CEF_CALLBACK* on_browser_destroyed)( struct _cef_render_process_handler_t* self, struct _cef_browser_t* browser); /// // Return the handler for browser load status events. /// - struct _cef_load_handler_t* (CEF_CALLBACK *get_load_handler)( + struct _cef_load_handler_t*(CEF_CALLBACK* get_load_handler)( struct _cef_render_process_handler_t* self); /// @@ -106,10 +107,12 @@ typedef struct _cef_render_process_handler_t { // or false (0) to allow the navigation to proceed. The |request| object // cannot be modified in this callback. /// - int (CEF_CALLBACK *on_before_navigation)( + int(CEF_CALLBACK* on_before_navigation)( struct _cef_render_process_handler_t* self, - struct _cef_browser_t* browser, struct _cef_frame_t* frame, - struct _cef_request_t* request, cef_navigation_type_t navigation_type, + struct _cef_browser_t* browser, + struct _cef_frame_t* frame, + struct _cef_request_t* request, + cef_navigation_type_t navigation_type, int is_redirect); /// @@ -120,18 +123,20 @@ typedef struct _cef_render_process_handler_t { // on the associated thread can be retrieved via the // cef_v8context_t::get_task_runner() function. /// - void (CEF_CALLBACK *on_context_created)( + void(CEF_CALLBACK* on_context_created)( struct _cef_render_process_handler_t* self, - struct _cef_browser_t* browser, struct _cef_frame_t* frame, + struct _cef_browser_t* browser, + struct _cef_frame_t* frame, struct _cef_v8context_t* context); /// // Called immediately before the V8 context for a frame is released. No // references to the context should be kept after this function is called. /// - void (CEF_CALLBACK *on_context_released)( + void(CEF_CALLBACK* on_context_released)( struct _cef_render_process_handler_t* self, - struct _cef_browser_t* browser, struct _cef_frame_t* frame, + struct _cef_browser_t* browser, + struct _cef_frame_t* frame, struct _cef_v8context_t* context); /// @@ -139,10 +144,12 @@ typedef struct _cef_render_process_handler_t { // callback is disabled by default. To enable set // CefSettings.uncaught_exception_stack_size > 0. /// - void (CEF_CALLBACK *on_uncaught_exception)( + void(CEF_CALLBACK* on_uncaught_exception)( struct _cef_render_process_handler_t* self, - struct _cef_browser_t* browser, struct _cef_frame_t* frame, - struct _cef_v8context_t* context, struct _cef_v8exception_t* exception, + struct _cef_browser_t* browser, + struct _cef_frame_t* frame, + struct _cef_v8context_t* context, + struct _cef_v8exception_t* exception, struct _cef_v8stack_trace_t* stackTrace); /// @@ -153,9 +160,10 @@ typedef struct _cef_render_process_handler_t { // keep references to or attempt to access any DOM objects outside the scope // of this function. /// - void (CEF_CALLBACK *on_focused_node_changed)( + void(CEF_CALLBACK* on_focused_node_changed)( struct _cef_render_process_handler_t* self, - struct _cef_browser_t* browser, struct _cef_frame_t* frame, + struct _cef_browser_t* browser, + struct _cef_frame_t* frame, struct _cef_domnode_t* node); /// @@ -163,13 +171,13 @@ typedef struct _cef_render_process_handler_t { // (1) if the message was handled or false (0) otherwise. Do not keep a // reference to or attempt to access the message outside of this callback. /// - int (CEF_CALLBACK *on_process_message_received)( + int(CEF_CALLBACK* on_process_message_received)( struct _cef_render_process_handler_t* self, - struct _cef_browser_t* browser, cef_process_id_t source_process, + struct _cef_browser_t* browser, + cef_process_id_t source_process, struct _cef_process_message_t* message); } cef_render_process_handler_t; - #ifdef __cplusplus } #endif diff --git a/include/capi/cef_request_capi.h b/include/capi/cef_request_capi.h index 4e4748b..0d75412 100644 --- a/include/capi/cef_request_capi.h +++ b/include/capi/cef_request_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,17 +33,19 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=e4d28f171862beea61f00e46d7acb8ee4154b077$ +// #ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_REQUEST_CAPI_H_ #pragma once +#include "include/capi/cef_base_capi.h" + #ifdef __cplusplus extern "C" { #endif -#include "include/capi/cef_base_capi.h" - struct _cef_post_data_element_t; struct _cef_post_data_t; @@ -55,101 +57,126 @@ typedef struct _cef_request_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Returns true (1) if this object is read-only. /// - int (CEF_CALLBACK *is_read_only)(struct _cef_request_t* self); + int(CEF_CALLBACK* is_read_only)(struct _cef_request_t* self); /// // Get the fully qualified URL. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_url)(struct _cef_request_t* self); + cef_string_userfree_t(CEF_CALLBACK* get_url)(struct _cef_request_t* self); /// // Set the fully qualified URL. /// - void (CEF_CALLBACK *set_url)(struct _cef_request_t* self, - const cef_string_t* url); + void(CEF_CALLBACK* set_url)(struct _cef_request_t* self, + const cef_string_t* url); /// // Get the request function type. The value will default to POST if post data // is provided and GET otherwise. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_method)(struct _cef_request_t* self); + cef_string_userfree_t(CEF_CALLBACK* get_method)(struct _cef_request_t* self); /// // Set the request function type. /// - void (CEF_CALLBACK *set_method)(struct _cef_request_t* self, - const cef_string_t* method); + void(CEF_CALLBACK* set_method)(struct _cef_request_t* self, + const cef_string_t* method); + + /// + // Set the referrer URL and policy. If non-NULL the referrer URL must be fully + // qualified with an HTTP or HTTPS scheme component. Any username, password or + // ref component will be removed. + /// + void(CEF_CALLBACK* set_referrer)(struct _cef_request_t* self, + const cef_string_t* referrer_url, + cef_referrer_policy_t policy); + + /// + // Get the referrer URL. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t(CEF_CALLBACK* get_referrer_url)( + struct _cef_request_t* self); + + /// + // Get the referrer policy. + /// + cef_referrer_policy_t(CEF_CALLBACK* get_referrer_policy)( + struct _cef_request_t* self); /// // Get the post data. /// - struct _cef_post_data_t* (CEF_CALLBACK *get_post_data)( + struct _cef_post_data_t*(CEF_CALLBACK* get_post_data)( struct _cef_request_t* self); /// // Set the post data. /// - void (CEF_CALLBACK *set_post_data)(struct _cef_request_t* self, - struct _cef_post_data_t* postData); + void(CEF_CALLBACK* set_post_data)(struct _cef_request_t* self, + struct _cef_post_data_t* postData); /// - // Get the header values. + // Get the header values. Will not include the Referer value if any. /// - void (CEF_CALLBACK *get_header_map)(struct _cef_request_t* self, - cef_string_multimap_t headerMap); + void(CEF_CALLBACK* get_header_map)(struct _cef_request_t* self, + cef_string_multimap_t headerMap); /// - // Set the header values. + // Set the header values. If a Referer value exists in the header map it will + // be removed and ignored. /// - void (CEF_CALLBACK *set_header_map)(struct _cef_request_t* self, - cef_string_multimap_t headerMap); + void(CEF_CALLBACK* set_header_map)(struct _cef_request_t* self, + cef_string_multimap_t headerMap); /// // Set all values at one time. /// - void (CEF_CALLBACK *set)(struct _cef_request_t* self, const cef_string_t* url, - const cef_string_t* method, struct _cef_post_data_t* postData, - cef_string_multimap_t headerMap); + void(CEF_CALLBACK* set)(struct _cef_request_t* self, + const cef_string_t* url, + const cef_string_t* method, + struct _cef_post_data_t* postData, + cef_string_multimap_t headerMap); /// // Get the flags used in combination with cef_urlrequest_t. See // cef_urlrequest_flags_t for supported values. /// - int (CEF_CALLBACK *get_flags)(struct _cef_request_t* self); + int(CEF_CALLBACK* get_flags)(struct _cef_request_t* self); /// // Set the flags used in combination with cef_urlrequest_t. See // cef_urlrequest_flags_t for supported values. /// - void (CEF_CALLBACK *set_flags)(struct _cef_request_t* self, int flags); + void(CEF_CALLBACK* set_flags)(struct _cef_request_t* self, int flags); /// // Set the URL to the first party for cookies used in combination with // cef_urlrequest_t. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_first_party_for_cookies)( + cef_string_userfree_t(CEF_CALLBACK* get_first_party_for_cookies)( struct _cef_request_t* self); /// // Get the URL to the first party for cookies used in combination with // cef_urlrequest_t. /// - void (CEF_CALLBACK *set_first_party_for_cookies)(struct _cef_request_t* self, - const cef_string_t* url); + void(CEF_CALLBACK* set_first_party_for_cookies)(struct _cef_request_t* self, + const cef_string_t* url); /// - // Get the resource type for this request. Accurate resource type information - // may only be available in the browser process. + // Get the resource type for this request. Only available in the browser + // process. /// - cef_resource_type_t (CEF_CALLBACK *get_resource_type)( + cef_resource_type_t(CEF_CALLBACK* get_resource_type)( struct _cef_request_t* self); /// @@ -157,17 +184,22 @@ typedef struct _cef_request_t { // process and only applies to requests that represent a main frame or sub- // frame navigation. /// - cef_transition_type_t (CEF_CALLBACK *get_transition_type)( + cef_transition_type_t(CEF_CALLBACK* get_transition_type)( struct _cef_request_t* self); -} cef_request_t; + /// + // Returns the globally unique identifier for this request or 0 if not + // specified. Can be used by cef_request_tHandler implementations in the + // browser process to track a single request across multiple callbacks. + /// + uint64(CEF_CALLBACK* get_identifier)(struct _cef_request_t* self); +} cef_request_t; /// // Create a new cef_request_t object. /// CEF_EXPORT cef_request_t* cef_request_create(); - /// // Structure used to represent post data for a web request. The functions of // this structure may be called on any thread. @@ -176,50 +208,57 @@ typedef struct _cef_post_data_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Returns true (1) if this object is read-only. /// - int (CEF_CALLBACK *is_read_only)(struct _cef_post_data_t* self); + int(CEF_CALLBACK* is_read_only)(struct _cef_post_data_t* self); + + /// + // Returns true (1) if the underlying POST data includes elements that are not + // represented by this cef_post_data_t object (for example, multi-part file + // upload data). Modifying cef_post_data_t objects with excluded elements may + // result in the request failing. + /// + int(CEF_CALLBACK* has_excluded_elements)(struct _cef_post_data_t* self); /// // Returns the number of existing post data elements. /// - size_t (CEF_CALLBACK *get_element_count)(struct _cef_post_data_t* self); + size_t(CEF_CALLBACK* get_element_count)(struct _cef_post_data_t* self); /// // Retrieve the post data elements. /// - void (CEF_CALLBACK *get_elements)(struct _cef_post_data_t* self, - size_t* elementsCount, struct _cef_post_data_element_t** elements); + void(CEF_CALLBACK* get_elements)(struct _cef_post_data_t* self, + size_t* elementsCount, + struct _cef_post_data_element_t** elements); /// // Remove the specified post data element. Returns true (1) if the removal // succeeds. /// - int (CEF_CALLBACK *remove_element)(struct _cef_post_data_t* self, - struct _cef_post_data_element_t* element); + int(CEF_CALLBACK* remove_element)(struct _cef_post_data_t* self, + struct _cef_post_data_element_t* element); /// // Add the specified post data element. Returns true (1) if the add succeeds. /// - int (CEF_CALLBACK *add_element)(struct _cef_post_data_t* self, - struct _cef_post_data_element_t* element); + int(CEF_CALLBACK* add_element)(struct _cef_post_data_t* self, + struct _cef_post_data_element_t* element); /// // Remove all existing post data elements. /// - void (CEF_CALLBACK *remove_elements)(struct _cef_post_data_t* self); + void(CEF_CALLBACK* remove_elements)(struct _cef_post_data_t* self); } cef_post_data_t; - /// // Create a new cef_post_data_t object. /// CEF_EXPORT cef_post_data_t* cef_post_data_create(); - /// // Structure used to represent a single element in the request post data. The // functions of this structure may be called on any thread. @@ -228,64 +267,64 @@ typedef struct _cef_post_data_element_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Returns true (1) if this object is read-only. /// - int (CEF_CALLBACK *is_read_only)(struct _cef_post_data_element_t* self); + int(CEF_CALLBACK* is_read_only)(struct _cef_post_data_element_t* self); /// // Remove all contents from the post data element. /// - void (CEF_CALLBACK *set_to_empty)(struct _cef_post_data_element_t* self); + void(CEF_CALLBACK* set_to_empty)(struct _cef_post_data_element_t* self); /// // The post data element will represent a file. /// - void (CEF_CALLBACK *set_to_file)(struct _cef_post_data_element_t* self, - const cef_string_t* fileName); + void(CEF_CALLBACK* set_to_file)(struct _cef_post_data_element_t* self, + const cef_string_t* fileName); /// // The post data element will represent bytes. The bytes passed in will be // copied. /// - void (CEF_CALLBACK *set_to_bytes)(struct _cef_post_data_element_t* self, - size_t size, const void* bytes); + void(CEF_CALLBACK* set_to_bytes)(struct _cef_post_data_element_t* self, + size_t size, + const void* bytes); /// // Return the type of this post data element. /// - cef_postdataelement_type_t (CEF_CALLBACK *get_type)( + cef_postdataelement_type_t(CEF_CALLBACK* get_type)( struct _cef_post_data_element_t* self); /// // Return the file name. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_file)( + cef_string_userfree_t(CEF_CALLBACK* get_file)( struct _cef_post_data_element_t* self); /// // Return the number of bytes. /// - size_t (CEF_CALLBACK *get_bytes_count)(struct _cef_post_data_element_t* self); + size_t(CEF_CALLBACK* get_bytes_count)(struct _cef_post_data_element_t* self); /// // Read up to |size| bytes into |bytes| and return the number of bytes // actually read. /// - size_t (CEF_CALLBACK *get_bytes)(struct _cef_post_data_element_t* self, - size_t size, void* bytes); + size_t(CEF_CALLBACK* get_bytes)(struct _cef_post_data_element_t* self, + size_t size, + void* bytes); } cef_post_data_element_t; - /// // Create a new cef_post_data_element_t object. /// CEF_EXPORT cef_post_data_element_t* cef_post_data_element_create(); - #ifdef __cplusplus } #endif diff --git a/include/capi/cef_request_context_capi.h b/include/capi/cef_request_context_capi.h index 7d09653..a2ed8cc 100644 --- a/include/capi/cef_request_context_capi.h +++ b/include/capi/cef_request_context_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,58 +33,241 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=791231acc78a2b601257fb0b86d904eace796d63$ +// #ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_CONTEXT_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_REQUEST_CONTEXT_CAPI_H_ #pragma once +#include "include/capi/cef_callback_capi.h" +#include "include/capi/cef_cookie_capi.h" +#include "include/capi/cef_request_context_handler_capi.h" +#include "include/capi/cef_values_capi.h" + #ifdef __cplusplus extern "C" { #endif -#include "include/capi/cef_request_context_handler_capi.h" +struct _cef_scheme_handler_factory_t; + +/// +// Callback structure for cef_request_tContext::ResolveHost. +/// +typedef struct _cef_resolve_callback_t { + /// + // Base structure. + /// + cef_base_ref_counted_t base; + /// + // Called after the ResolveHost request has completed. |result| will be the + // result code. |resolved_ips| will be the list of resolved IP addresses or + // NULL if the resolution failed. + /// + void(CEF_CALLBACK* on_resolve_completed)(struct _cef_resolve_callback_t* self, + cef_errorcode_t result, + cef_string_list_t resolved_ips); +} cef_resolve_callback_t; /// -// A request context provides request handling for a set of related browser -// objects. A request context is specified when creating a new browser object -// via the cef_browser_host_t static factory functions. Browser objects with -// different request contexts will never be hosted in the same render process. -// Browser objects with the same request context may or may not be hosted in the -// same render process depending on the process model. Browser objects created -// indirectly via the JavaScript window.open function or targeted links will -// share the same render process and the same request context as the source -// browser. When running in single-process mode there is only a single render -// process (the main process) and so all browsers created in single-process mode -// will share the same request context. This will be the first request context -// passed into a cef_browser_host_t static factory function and all other -// request context objects will be ignored. +// A request context provides request handling for a set of related browser or +// URL request objects. A request context can be specified when creating a new +// browser via the cef_browser_host_t static factory functions or when creating +// a new URL request via the cef_urlrequest_t static factory functions. Browser +// objects with different request contexts will never be hosted in the same +// render process. Browser objects with the same request context may or may not +// be hosted in the same render process depending on the process model. Browser +// objects created indirectly via the JavaScript window.open function or +// targeted links will share the same render process and the same request +// context as the source browser. When running in single-process mode there is +// only a single render process (the main process) and so all browsers created +// in single-process mode will share the same request context. This will be the +// first request context passed into a cef_browser_host_t static factory +// function and all other request context objects will be ignored. /// typedef struct _cef_request_context_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Returns true (1) if this object is pointing to the same context as |that| // object. /// - int (CEF_CALLBACK *is_same)(struct _cef_request_context_t* self, - struct _cef_request_context_t* other); + int(CEF_CALLBACK* is_same)(struct _cef_request_context_t* self, + struct _cef_request_context_t* other); + + /// + // Returns true (1) if this object is sharing the same storage as |that| + // object. + /// + int(CEF_CALLBACK* is_sharing_with)(struct _cef_request_context_t* self, + struct _cef_request_context_t* other); /// - // Returns true (1) if this object is the global context. + // Returns true (1) if this object is the global context. The global context + // is used by default when creating a browser or URL request with a NULL + // context argument. /// - int (CEF_CALLBACK *is_global)(struct _cef_request_context_t* self); + int(CEF_CALLBACK* is_global)(struct _cef_request_context_t* self); /// // Returns the handler for this context if any. /// - struct _cef_request_context_handler_t* (CEF_CALLBACK *get_handler)( + struct _cef_request_context_handler_t*(CEF_CALLBACK* get_handler)( struct _cef_request_context_t* self); -} cef_request_context_t; + /// + // Returns the cache path for this object. If NULL an "incognito mode" in- + // memory cache is being used. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t(CEF_CALLBACK* get_cache_path)( + struct _cef_request_context_t* self); + + /// + // Returns the default cookie manager for this object. This will be the global + // cookie manager if this object is the global request context. Otherwise, + // this will be the default cookie manager used when this request context does + // not receive a value via cef_request_tContextHandler::get_cookie_manager(). + // If |callback| is non-NULL it will be executed asnychronously on the IO + // thread after the manager's storage has been initialized. + /// + struct _cef_cookie_manager_t*(CEF_CALLBACK* get_default_cookie_manager)( + struct _cef_request_context_t* self, + struct _cef_completion_callback_t* callback); + + /// + // Register a scheme handler factory for the specified |scheme_name| and + // optional |domain_name|. An NULL |domain_name| value for a standard scheme + // will cause the factory to match all domain names. The |domain_name| value + // will be ignored for non-standard schemes. If |scheme_name| is a built-in + // scheme and no handler is returned by |factory| then the built-in scheme + // handler factory will be called. If |scheme_name| is a custom scheme then + // you must also implement the cef_app_t::on_register_custom_schemes() + // function in all processes. This function may be called multiple times to + // change or remove the factory that matches the specified |scheme_name| and + // optional |domain_name|. Returns false (0) if an error occurs. This function + // may be called on any thread in the browser process. + /// + int(CEF_CALLBACK* register_scheme_handler_factory)( + struct _cef_request_context_t* self, + const cef_string_t* scheme_name, + const cef_string_t* domain_name, + struct _cef_scheme_handler_factory_t* factory); + + /// + // Clear all registered scheme handler factories. Returns false (0) on error. + // This function may be called on any thread in the browser process. + /// + int(CEF_CALLBACK* clear_scheme_handler_factories)( + struct _cef_request_context_t* self); + + /// + // Tells all renderer processes associated with this context to throw away + // their plugin list cache. If |reload_pages| is true (1) they will also + // reload all pages with plugins. + // cef_request_tContextHandler::OnBeforePluginLoad may be called to rebuild + // the plugin list cache. + /// + void(CEF_CALLBACK* purge_plugin_list_cache)( + struct _cef_request_context_t* self, + int reload_pages); + + /// + // Returns true (1) if a preference with the specified |name| exists. This + // function must be called on the browser process UI thread. + /// + int(CEF_CALLBACK* has_preference)(struct _cef_request_context_t* self, + const cef_string_t* name); + + /// + // Returns the value for the preference with the specified |name|. Returns + // NULL if the preference does not exist. The returned object contains a copy + // of the underlying preference value and modifications to the returned object + // will not modify the underlying preference value. This function must be + // called on the browser process UI thread. + /// + struct _cef_value_t*(CEF_CALLBACK* get_preference)( + struct _cef_request_context_t* self, + const cef_string_t* name); + + /// + // Returns all preferences as a dictionary. If |include_defaults| is true (1) + // then preferences currently at their default value will be included. The + // returned object contains a copy of the underlying preference values and + // modifications to the returned object will not modify the underlying + // preference values. This function must be called on the browser process UI + // thread. + /// + struct _cef_dictionary_value_t*(CEF_CALLBACK* get_all_preferences)( + struct _cef_request_context_t* self, + int include_defaults); + + /// + // Returns true (1) if the preference with the specified |name| can be + // modified using SetPreference. As one example preferences set via the + // command-line usually cannot be modified. This function must be called on + // the browser process UI thread. + /// + int(CEF_CALLBACK* can_set_preference)(struct _cef_request_context_t* self, + const cef_string_t* name); + + /// + // Set the |value| associated with preference |name|. Returns true (1) if the + // value is set successfully and false (0) otherwise. If |value| is NULL the + // preference will be restored to its default value. If setting the preference + // fails then |error| will be populated with a detailed description of the + // problem. This function must be called on the browser process UI thread. + /// + int(CEF_CALLBACK* set_preference)(struct _cef_request_context_t* self, + const cef_string_t* name, + struct _cef_value_t* value, + cef_string_t* error); + + /// + // Clears all certificate exceptions that were added as part of handling + // cef_request_tHandler::on_certificate_error(). If you call this it is + // recommended that you also call close_all_connections() or you risk not + // being prompted again for server certificates if you reconnect quickly. If + // |callback| is non-NULL it will be executed on the UI thread after + // completion. + /// + void(CEF_CALLBACK* clear_certificate_exceptions)( + struct _cef_request_context_t* self, + struct _cef_completion_callback_t* callback); + + /// + // Clears all active and idle connections that Chromium currently has. This is + // only recommended if you have released all other CEF objects but don't yet + // want to call cef_shutdown(). If |callback| is non-NULL it will be executed + // on the UI thread after completion. + /// + void(CEF_CALLBACK* close_all_connections)( + struct _cef_request_context_t* self, + struct _cef_completion_callback_t* callback); + + /// + // Attempts to resolve |origin| to a list of associated IP addresses. + // |callback| will be executed on the UI thread after completion. + /// + void(CEF_CALLBACK* resolve_host)(struct _cef_request_context_t* self, + const cef_string_t* origin, + struct _cef_resolve_callback_t* callback); + + /// + // Attempts to resolve |origin| to a list of associated IP addresses using + // cached data. |resolved_ips| will be populated with the list of resolved IP + // addresses or NULL if no cached data is available. Returns ERR_NONE on + // success. This function must be called on the browser process IO thread. + /// + cef_errorcode_t(CEF_CALLBACK* resolve_host_cached)( + struct _cef_request_context_t* self, + const cef_string_t* origin, + cef_string_list_t resolved_ips); +} cef_request_context_t; /// // Returns the global context object. @@ -92,11 +275,20 @@ typedef struct _cef_request_context_t { CEF_EXPORT cef_request_context_t* cef_request_context_get_global_context(); /// -// Creates a new context object with the specified handler. +// Creates a new context object with the specified |settings| and optional +// |handler|. /// CEF_EXPORT cef_request_context_t* cef_request_context_create_context( + const struct _cef_request_context_settings_t* settings, struct _cef_request_context_handler_t* handler); +/// +// Creates a new context object that shares storage with |other| and uses an +// optional |handler|. +/// +CEF_EXPORT cef_request_context_t* cef_create_context_shared( + cef_request_context_t* other, + struct _cef_request_context_handler_t* handler); #ifdef __cplusplus } diff --git a/include/capi/cef_request_context_handler_capi.h b/include/capi/cef_request_context_handler_capi.h index cfddf79..12937f7 100644 --- a/include/capi/cef_request_context_handler_capi.h +++ b/include/capi/cef_request_context_handler_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,36 +33,68 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=9359e227c9d534c9c612d2ede790136461836501$ +// #ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_CONTEXT_HANDLER_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_REQUEST_CONTEXT_HANDLER_CAPI_H_ #pragma once -#ifdef __cplusplus -extern "C" { -#endif - #include "include/capi/cef_base_capi.h" #include "include/capi/cef_cookie_capi.h" +#include "include/capi/cef_web_plugin_capi.h" +#ifdef __cplusplus +extern "C" { +#endif /// -// Implement this structure to provide handler implementations. +// Implement this structure to provide handler implementations. The handler +// instance will not be released until all objects related to the context have +// been destroyed. /// typedef struct _cef_request_context_handler_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// - // Called on the IO thread to retrieve the cookie manager. The global cookie - // manager will be used if this function returns NULL. + // Called on the browser process IO thread to retrieve the cookie manager. If + // this function returns NULL the default cookie manager retrievable via + // cef_request_tContext::get_default_cookie_manager() will be used. /// - struct _cef_cookie_manager_t* (CEF_CALLBACK *get_cookie_manager)( + struct _cef_cookie_manager_t*(CEF_CALLBACK* get_cookie_manager)( struct _cef_request_context_handler_t* self); -} cef_request_context_handler_t; + /// + // Called on multiple browser process threads before a plugin instance is + // loaded. |mime_type| is the mime type of the plugin that will be loaded. + // |plugin_url| is the content URL that the plugin will load and may be NULL. + // |is_main_frame| will be true (1) if the plugin is being loaded in the main + // (top-level) frame, |top_origin_url| is the URL for the top-level frame that + // contains the plugin when loading a specific plugin instance or NULL when + // building the initial list of enabled plugins for 'navigator.plugins' + // JavaScript state. |plugin_info| includes additional information about the + // plugin that will be loaded. |plugin_policy| is the recommended policy. + // Modify |plugin_policy| and return true (1) to change the policy. Return + // false (0) to use the recommended policy. The default plugin policy can be + // set at runtime using the `--plugin-policy=[allow|detect|block]` command- + // line flag. Decisions to mark a plugin as disabled by setting + // |plugin_policy| to PLUGIN_POLICY_DISABLED may be cached when + // |top_origin_url| is NULL. To purge the plugin list cache and potentially + // trigger new calls to this function call + // cef_request_tContext::PurgePluginListCache. + /// + int(CEF_CALLBACK* on_before_plugin_load)( + struct _cef_request_context_handler_t* self, + const cef_string_t* mime_type, + const cef_string_t* plugin_url, + int is_main_frame, + const cef_string_t* top_origin_url, + struct _cef_web_plugin_info_t* plugin_info, + cef_plugin_policy_t* plugin_policy); +} cef_request_context_handler_t; #ifdef __cplusplus } diff --git a/include/capi/cef_request_handler_capi.h b/include/capi/cef_request_handler_capi.h index 715e253..5ae1b78 100644 --- a/include/capi/cef_request_handler_capi.h +++ b/include/capi/cef_request_handler_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,15 +33,13 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=b6cbe39a8124a961036205864e7e6b2e1eb0bf6b$ +// #ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_HANDLER_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_REQUEST_HANDLER_CAPI_H_ #pragma once -#ifdef __cplusplus -extern "C" { -#endif - #include "include/capi/cef_auth_callback_capi.h" #include "include/capi/cef_base_capi.h" #include "include/capi/cef_browser_capi.h" @@ -49,49 +47,52 @@ extern "C" { #include "include/capi/cef_request_capi.h" #include "include/capi/cef_resource_handler_capi.h" #include "include/capi/cef_response_capi.h" -#include "include/capi/cef_web_plugin_capi.h" +#include "include/capi/cef_response_filter_capi.h" +#include "include/capi/cef_ssl_info_capi.h" +#include "include/capi/cef_x509_certificate_capi.h" +#ifdef __cplusplus +extern "C" { +#endif /// -// Callback structure used for asynchronous continuation of quota requests. +// Callback structure used for asynchronous continuation of url requests. /// -typedef struct _cef_quota_callback_t { +typedef struct _cef_request_callback_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// - // Continue the quota request. If |allow| is true (1) the request will be - // allowed. Otherwise, the request will be denied. + // Continue the url request. If |allow| is true (1) the request will be + // continued. Otherwise, the request will be canceled. /// - void (CEF_CALLBACK *cont)(struct _cef_quota_callback_t* self, int allow); + void(CEF_CALLBACK* cont)(struct _cef_request_callback_t* self, int allow); /// - // Cancel the quota request. + // Cancel the url request. /// - void (CEF_CALLBACK *cancel)(struct _cef_quota_callback_t* self); -} cef_quota_callback_t; - + void(CEF_CALLBACK* cancel)(struct _cef_request_callback_t* self); +} cef_request_callback_t; /// -// Callback structure used for asynchronous continuation of url requests when -// invalid SSL certificates are encountered. +// Callback structure used to select a client certificate for authentication. /// -typedef struct _cef_allow_certificate_error_callback_t { +typedef struct _cef_select_client_certificate_callback_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// - // Continue the url request. If |allow| is true (1) the request will be - // continued. Otherwise, the request will be canceled. + // Chooses the specified certificate for client certificate authentication. + // NULL value means that no client certificate should be used. /// - void (CEF_CALLBACK *cont)( - struct _cef_allow_certificate_error_callback_t* self, int allow); -} cef_allow_certificate_error_callback_t; - + void(CEF_CALLBACK* select)( + struct _cef_select_client_certificate_callback_t* self, + struct _cef_x509certificate_t* cert); +} cef_select_client_certificate_callback_t; /// // Implement this structure to handle events related to browser requests. The @@ -101,7 +102,7 @@ typedef struct _cef_request_handler_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Called on the UI thread before browser navigation. Return true (1) to @@ -113,18 +114,50 @@ typedef struct _cef_request_handler_t { // cef_load_handler_t::OnLoadError will be called with an |errorCode| value of // ERR_ABORTED. /// - int (CEF_CALLBACK *on_before_browse)(struct _cef_request_handler_t* self, - struct _cef_browser_t* browser, struct _cef_frame_t* frame, - struct _cef_request_t* request, int is_redirect); + int(CEF_CALLBACK* on_before_browse)(struct _cef_request_handler_t* self, + struct _cef_browser_t* browser, + struct _cef_frame_t* frame, + struct _cef_request_t* request, + int is_redirect); /// - // Called on the IO thread before a resource request is loaded. The |request| - // object may be modified. To cancel the request return true (1) otherwise - // return false (0). + // Called on the UI thread before OnBeforeBrowse in certain limited cases + // where navigating a new or different browser might be desirable. This + // includes user-initiated navigation that might open in a special way (e.g. + // links clicked via middle-click or ctrl + left-click) and certain types of + // cross-origin navigation initiated from the renderer process (e.g. + // navigating the top-level frame to/from a file URL). The |browser| and + // |frame| values represent the source of the navigation. The + // |target_disposition| value indicates where the user intended to navigate + // the browser based on standard Chromium behaviors (e.g. current tab, new + // tab, etc). The |user_gesture| value will be true (1) if the browser + // navigated via explicit user gesture (e.g. clicking a link) or false (0) if + // it navigated automatically (e.g. via the DomContentLoaded event). Return + // true (1) to cancel the navigation or false (0) to allow the navigation to + // proceed in the source browser's top-level frame. + /// + int(CEF_CALLBACK* on_open_urlfrom_tab)( + struct _cef_request_handler_t* self, + struct _cef_browser_t* browser, + struct _cef_frame_t* frame, + const cef_string_t* target_url, + cef_window_open_disposition_t target_disposition, + int user_gesture); + /// - int (CEF_CALLBACK *on_before_resource_load)( - struct _cef_request_handler_t* self, struct _cef_browser_t* browser, - struct _cef_frame_t* frame, struct _cef_request_t* request); + // Called on the IO thread before a resource request is loaded. The |request| + // object may be modified. Return RV_CONTINUE to continue the request + // immediately. Return RV_CONTINUE_ASYNC and call cef_request_tCallback:: + // cont() at a later time to continue or cancel the request asynchronously. + // Return RV_CANCEL to cancel the request immediately. + // + /// + cef_return_value_t(CEF_CALLBACK* on_before_resource_load)( + struct _cef_request_handler_t* self, + struct _cef_browser_t* browser, + struct _cef_frame_t* frame, + struct _cef_request_t* request, + struct _cef_request_callback_t* callback); /// // Called on the IO thread before a resource is loaded. To allow the resource @@ -132,42 +165,102 @@ typedef struct _cef_request_handler_t { // a cef_resource_handler_t object. The |request| object should not be // modified in this callback. /// - struct _cef_resource_handler_t* (CEF_CALLBACK *get_resource_handler)( - struct _cef_request_handler_t* self, struct _cef_browser_t* browser, - struct _cef_frame_t* frame, struct _cef_request_t* request); + struct _cef_resource_handler_t*(CEF_CALLBACK* get_resource_handler)( + struct _cef_request_handler_t* self, + struct _cef_browser_t* browser, + struct _cef_frame_t* frame, + struct _cef_request_t* request); + + /// + // Called on the IO thread when a resource load is redirected. The |request| + // parameter will contain the old URL and other request-related information. + // The |response| parameter will contain the response that resulted in the + // redirect. The |new_url| parameter will contain the new URL and can be + // changed if desired. The |request| object cannot be modified in this + // callback. + /// + void(CEF_CALLBACK* on_resource_redirect)(struct _cef_request_handler_t* self, + struct _cef_browser_t* browser, + struct _cef_frame_t* frame, + struct _cef_request_t* request, + struct _cef_response_t* response, + cef_string_t* new_url); + + /// + // Called on the IO thread when a resource response is received. To allow the + // resource to load normally return false (0). To redirect or retry the + // resource modify |request| (url, headers or post body) and return true (1). + // The |response| object cannot be modified in this callback. + /// + int(CEF_CALLBACK* on_resource_response)(struct _cef_request_handler_t* self, + struct _cef_browser_t* browser, + struct _cef_frame_t* frame, + struct _cef_request_t* request, + struct _cef_response_t* response); /// - // Called on the IO thread when a resource load is redirected. The |old_url| - // parameter will contain the old URL. The |new_url| parameter will contain - // the new URL and can be changed if desired. + // Called on the IO thread to optionally filter resource response content. + // |request| and |response| represent the request and response respectively + // and cannot be modified in this callback. + /// + struct _cef_response_filter_t*(CEF_CALLBACK* get_resource_response_filter)( + struct _cef_request_handler_t* self, + struct _cef_browser_t* browser, + struct _cef_frame_t* frame, + struct _cef_request_t* request, + struct _cef_response_t* response); + /// - void (CEF_CALLBACK *on_resource_redirect)(struct _cef_request_handler_t* self, - struct _cef_browser_t* browser, struct _cef_frame_t* frame, - const cef_string_t* old_url, cef_string_t* new_url); + // Called on the IO thread when a resource load has completed. |request| and + // |response| represent the request and response respectively and cannot be + // modified in this callback. |status| indicates the load completion status. + // |received_content_length| is the number of response bytes actually read. + /// + void(CEF_CALLBACK* on_resource_load_complete)( + struct _cef_request_handler_t* self, + struct _cef_browser_t* browser, + struct _cef_frame_t* frame, + struct _cef_request_t* request, + struct _cef_response_t* response, + cef_urlrequest_status_t status, + int64 received_content_length); /// // Called on the IO thread when the browser needs credentials from the user. // |isProxy| indicates whether the host is a proxy server. |host| contains the - // hostname and |port| contains the port number. Return true (1) to continue - // the request and call cef_auth_callback_t::cont() when the authentication - // information is available. Return false (0) to cancel the request. - /// - int (CEF_CALLBACK *get_auth_credentials)(struct _cef_request_handler_t* self, - struct _cef_browser_t* browser, struct _cef_frame_t* frame, int isProxy, - const cef_string_t* host, int port, const cef_string_t* realm, - const cef_string_t* scheme, struct _cef_auth_callback_t* callback); + // hostname and |port| contains the port number. |realm| is the realm of the + // challenge and may be NULL. |scheme| is the authentication scheme used, such + // as "basic" or "digest", and will be NULL if the source of the request is an + // FTP server. Return true (1) to continue the request and call + // cef_auth_callback_t::cont() either in this function or at a later time when + // the authentication information is available. Return false (0) to cancel the + // request immediately. + /// + int(CEF_CALLBACK* get_auth_credentials)( + struct _cef_request_handler_t* self, + struct _cef_browser_t* browser, + struct _cef_frame_t* frame, + int isProxy, + const cef_string_t* host, + int port, + const cef_string_t* realm, + const cef_string_t* scheme, + struct _cef_auth_callback_t* callback); /// // Called on the IO thread when JavaScript requests a specific storage quota // size via the webkitStorageInfo.requestQuota function. |origin_url| is the // origin of the page making the request. |new_size| is the requested quota - // size in bytes. Return true (1) and call cef_quota_callback_t::cont() either - // in this function or at a later time to grant or deny the request. Return - // false (0) to cancel the request. - /// - int (CEF_CALLBACK *on_quota_request)(struct _cef_request_handler_t* self, - struct _cef_browser_t* browser, const cef_string_t* origin_url, - int64 new_size, struct _cef_quota_callback_t* callback); + // size in bytes. Return true (1) to continue the request and call + // cef_request_tCallback::cont() either in this function or at a later time to + // grant or deny the request. Return false (0) to cancel the request + // immediately. + /// + int(CEF_CALLBACK* on_quota_request)(struct _cef_request_handler_t* self, + struct _cef_browser_t* browser, + const cef_string_t* origin_url, + int64 new_size, + struct _cef_request_callback_t* callback); /// // Called on the UI thread to handle requests for URLs with an unknown @@ -176,49 +269,76 @@ typedef struct _cef_request_handler_t { // YOU SHOULD USE THIS METHOD TO ENFORCE RESTRICTIONS BASED ON SCHEME, HOST OR // OTHER URL ANALYSIS BEFORE ALLOWING OS EXECUTION. /// - void (CEF_CALLBACK *on_protocol_execution)( - struct _cef_request_handler_t* self, struct _cef_browser_t* browser, - const cef_string_t* url, int* allow_os_execution); + void(CEF_CALLBACK* on_protocol_execution)(struct _cef_request_handler_t* self, + struct _cef_browser_t* browser, + const cef_string_t* url, + int* allow_os_execution); /// // Called on the UI thread to handle requests for URLs with an invalid SSL - // certificate. Return true (1) and call - // cef_allow_certificate_error_callback_t:: cont() either in this function or - // at a later time to continue or cancel the request. Return false (0) to - // cancel the request immediately. If |callback| is NULL the error cannot be - // recovered from and the request will be canceled automatically. If + // certificate. Return true (1) and call cef_request_tCallback::cont() either + // in this function or at a later time to continue or cancel the request. + // Return false (0) to cancel the request immediately. If // CefSettings.ignore_certificate_errors is set all invalid certificates will // be accepted without calling this function. /// - int (CEF_CALLBACK *on_certificate_error)(struct _cef_request_handler_t* self, - cef_errorcode_t cert_error, const cef_string_t* request_url, - struct _cef_allow_certificate_error_callback_t* callback); + int(CEF_CALLBACK* on_certificate_error)( + struct _cef_request_handler_t* self, + struct _cef_browser_t* browser, + cef_errorcode_t cert_error, + const cef_string_t* request_url, + struct _cef_sslinfo_t* ssl_info, + struct _cef_request_callback_t* callback); /// - // Called on the browser process IO thread before a plugin is loaded. Return - // true (1) to block loading of the plugin. - /// - int (CEF_CALLBACK *on_before_plugin_load)(struct _cef_request_handler_t* self, - struct _cef_browser_t* browser, const cef_string_t* url, - const cef_string_t* policy_url, struct _cef_web_plugin_info_t* info); + // Called on the UI thread when a client certificate is being requested for + // authentication. Return false (0) to use the default behavior and + // automatically select the first certificate available. Return true (1) and + // call cef_select_client_certificate_callback_t::Select either in this + // function or at a later time to select a certificate. Do not call Select or + // call it with NULL to continue without using any certificate. |isProxy| + // indicates whether the host is an HTTPS proxy or the origin server. |host| + // and |port| contains the hostname and port of the SSL server. |certificates| + // is the list of certificates to choose from; this list has already been + // pruned by Chromium so that it only contains certificates from issuers that + // the server trusts. + /// + int(CEF_CALLBACK* on_select_client_certificate)( + struct _cef_request_handler_t* self, + struct _cef_browser_t* browser, + int isProxy, + const cef_string_t* host, + int port, + size_t certificatesCount, + struct _cef_x509certificate_t* const* certificates, + struct _cef_select_client_certificate_callback_t* callback); /// // Called on the browser process UI thread when a plugin has crashed. // |plugin_path| is the path of the plugin that crashed. /// - void (CEF_CALLBACK *on_plugin_crashed)(struct _cef_request_handler_t* self, - struct _cef_browser_t* browser, const cef_string_t* plugin_path); + void(CEF_CALLBACK* on_plugin_crashed)(struct _cef_request_handler_t* self, + struct _cef_browser_t* browser, + const cef_string_t* plugin_path); + + /// + // Called on the browser process UI thread when the render view associated + // with |browser| is ready to receive/handle IPC messages in the render + // process. + /// + void(CEF_CALLBACK* on_render_view_ready)(struct _cef_request_handler_t* self, + struct _cef_browser_t* browser); /// // Called on the browser process UI thread when the render process terminates // unexpectedly. |status| indicates how the process terminated. /// - void (CEF_CALLBACK *on_render_process_terminated)( - struct _cef_request_handler_t* self, struct _cef_browser_t* browser, + void(CEF_CALLBACK* on_render_process_terminated)( + struct _cef_request_handler_t* self, + struct _cef_browser_t* browser, cef_termination_status_t status); } cef_request_handler_t; - #ifdef __cplusplus } #endif diff --git a/include/capi/cef_resource_bundle_capi.h b/include/capi/cef_resource_bundle_capi.h new file mode 100644 index 0000000..7a2d567 --- /dev/null +++ b/include/capi/cef_resource_bundle_capi.h @@ -0,0 +1,112 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=82f2ce6f2ea3a8268ac69e33d304ace1a0e192b2$ +// + +#ifndef CEF_INCLUDE_CAPI_CEF_RESOURCE_BUNDLE_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_RESOURCE_BUNDLE_CAPI_H_ +#pragma once + +#include "include/capi/cef_base_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// Structure used for retrieving resources from the resource bundle (*.pak) +// files loaded by CEF during startup or via the cef_resource_bundle_tHandler +// returned from cef_app_t::GetResourceBundleHandler. See CefSettings for +// additional options related to resource bundle loading. The functions of this +// structure may be called on any thread unless otherwise indicated. +/// +typedef struct _cef_resource_bundle_t { + /// + // Base structure. + /// + cef_base_ref_counted_t base; + + /// + // Returns the localized string for the specified |string_id| or an NULL + // string if the value is not found. Include cef_pack_strings.h for a listing + // of valid string ID values. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t(CEF_CALLBACK* get_localized_string)( + struct _cef_resource_bundle_t* self, + int string_id); + + /// + // Retrieves the contents of the specified scale independent |resource_id|. If + // the value is found then |data| and |data_size| will be populated and this + // function will return true (1). If the value is not found then this function + // will return false (0). The returned |data| pointer will remain resident in + // memory and should not be freed. Include cef_pack_resources.h for a listing + // of valid resource ID values. + /// + int(CEF_CALLBACK* get_data_resource)(struct _cef_resource_bundle_t* self, + int resource_id, + void** data, + size_t* data_size); + + /// + // Retrieves the contents of the specified |resource_id| nearest the scale + // factor |scale_factor|. Use a |scale_factor| value of SCALE_FACTOR_NONE for + // scale independent resources or call GetDataResource instead. If the value + // is found then |data| and |data_size| will be populated and this function + // will return true (1). If the value is not found then this function will + // return false (0). The returned |data| pointer will remain resident in + // memory and should not be freed. Include cef_pack_resources.h for a listing + // of valid resource ID values. + /// + int(CEF_CALLBACK* get_data_resource_for_scale)( + struct _cef_resource_bundle_t* self, + int resource_id, + cef_scale_factor_t scale_factor, + void** data, + size_t* data_size); +} cef_resource_bundle_t; + +/// +// Returns the global resource bundle instance. +/// +CEF_EXPORT cef_resource_bundle_t* cef_resource_bundle_get_global(); + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_RESOURCE_BUNDLE_CAPI_H_ diff --git a/include/capi/cef_resource_bundle_handler_capi.h b/include/capi/cef_resource_bundle_handler_capi.h index 1a72632..bca2370 100644 --- a/include/capi/cef_resource_bundle_handler_capi.h +++ b/include/capi/cef_resource_bundle_handler_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,51 +33,70 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=cd94d8670c26bf17082629e5297407a716f01503$ +// #ifndef CEF_INCLUDE_CAPI_CEF_RESOURCE_BUNDLE_HANDLER_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_RESOURCE_BUNDLE_HANDLER_CAPI_H_ #pragma once +#include "include/capi/cef_base_capi.h" + #ifdef __cplusplus extern "C" { #endif -#include "include/capi/cef_base_capi.h" - - /// -// Structure used to implement a custom resource bundle structure. The functions -// of this structure may be called on multiple threads. +// Structure used to implement a custom resource bundle structure. See +// CefSettings for additional options related to resource bundle loading. The +// functions of this structure may be called on multiple threads. /// typedef struct _cef_resource_bundle_handler_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// - // Called to retrieve a localized translation for the string specified by - // |message_id|. To provide the translation set |string| to the translation - // string and return true (1). To use the default translation return false - // (0). Supported message IDs are listed in cef_pack_strings.h. + // Called to retrieve a localized translation for the specified |string_id|. + // To provide the translation set |string| to the translation string and + // return true (1). To use the default translation return false (0). Include + // cef_pack_strings.h for a listing of valid string ID values. /// - int (CEF_CALLBACK *get_localized_string)( - struct _cef_resource_bundle_handler_t* self, int message_id, + int(CEF_CALLBACK* get_localized_string)( + struct _cef_resource_bundle_handler_t* self, + int string_id, cef_string_t* string); /// - // Called to retrieve data for the resource specified by |resource_id|. To - // provide the resource data set |data| and |data_size| to the data pointer + // Called to retrieve data for the specified scale independent |resource_id|. + // To provide the resource data set |data| and |data_size| to the data pointer // and size respectively and return true (1). To use the default resource data // return false (0). The resource data will not be copied and must remain - // resident in memory. Supported resource IDs are listed in - // cef_pack_resources.h. + // resident in memory. Include cef_pack_resources.h for a listing of valid + // resource ID values. /// - int (CEF_CALLBACK *get_data_resource)( - struct _cef_resource_bundle_handler_t* self, int resource_id, void** data, + int(CEF_CALLBACK* get_data_resource)( + struct _cef_resource_bundle_handler_t* self, + int resource_id, + void** data, size_t* data_size); -} cef_resource_bundle_handler_t; + /// + // Called to retrieve data for the specified |resource_id| nearest the scale + // factor |scale_factor|. To provide the resource data set |data| and + // |data_size| to the data pointer and size respectively and return true (1). + // To use the default resource data return false (0). The resource data will + // not be copied and must remain resident in memory. Include + // cef_pack_resources.h for a listing of valid resource ID values. + /// + int(CEF_CALLBACK* get_data_resource_for_scale)( + struct _cef_resource_bundle_handler_t* self, + int resource_id, + cef_scale_factor_t scale_factor, + void** data, + size_t* data_size); +} cef_resource_bundle_handler_t; #ifdef __cplusplus } diff --git a/include/capi/cef_resource_handler_capi.h b/include/capi/cef_resource_handler_capi.h index d845f7f..7997495 100644 --- a/include/capi/cef_resource_handler_capi.h +++ b/include/capi/cef_resource_handler_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,15 +33,13 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=cd9c4ed153ad4425ff43d640a81693e3c83817d2$ +// #ifndef CEF_INCLUDE_CAPI_CEF_RESOURCE_HANDLER_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_RESOURCE_HANDLER_CAPI_H_ #pragma once -#ifdef __cplusplus -extern "C" { -#endif - #include "include/capi/cef_base_capi.h" #include "include/capi/cef_browser_capi.h" #include "include/capi/cef_callback_capi.h" @@ -49,6 +47,9 @@ extern "C" { #include "include/capi/cef_request_capi.h" #include "include/capi/cef_response_capi.h" +#ifdef __cplusplus +extern "C" { +#endif /// // Structure used to implement a custom request handler structure. The functions @@ -58,7 +59,7 @@ typedef struct _cef_resource_handler_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Begin processing the request. To handle the request return true (1) and @@ -67,8 +68,9 @@ typedef struct _cef_resource_handler_t { // function if header information is available immediately). To cancel the // request return false (0). /// - int (CEF_CALLBACK *process_request)(struct _cef_resource_handler_t* self, - struct _cef_request_t* request, struct _cef_callback_t* callback); + int(CEF_CALLBACK* process_request)(struct _cef_resource_handler_t* self, + struct _cef_request_t* request, + struct _cef_callback_t* callback); /// // Retrieve response header information. If the response length is not known @@ -78,11 +80,13 @@ typedef struct _cef_resource_handler_t { // (0) or the specified number of bytes have been read. Use the |response| // object to set the mime type, http status code and other optional header // values. To redirect the request to a new URL set |redirectUrl| to the new - // URL. + // URL. If an error occured while setting up the request you can call + // set_error() on |response| to indicate the error condition. /// - void (CEF_CALLBACK *get_response_headers)( - struct _cef_resource_handler_t* self, struct _cef_response_t* response, - int64* response_length, cef_string_t* redirectUrl); + void(CEF_CALLBACK* get_response_headers)(struct _cef_resource_handler_t* self, + struct _cef_response_t* response, + int64* response_length, + cef_string_t* redirectUrl); /// // Read response data. If data is available immediately copy up to @@ -91,32 +95,33 @@ typedef struct _cef_resource_handler_t { // |bytes_read| to 0, return true (1) and call cef_callback_t::cont() when the // data is available. To indicate response completion return false (0). /// - int (CEF_CALLBACK *read_response)(struct _cef_resource_handler_t* self, - void* data_out, int bytes_to_read, int* bytes_read, - struct _cef_callback_t* callback); + int(CEF_CALLBACK* read_response)(struct _cef_resource_handler_t* self, + void* data_out, + int bytes_to_read, + int* bytes_read, + struct _cef_callback_t* callback); /// // Return true (1) if the specified cookie can be sent with the request or // false (0) otherwise. If false (0) is returned for any cookie then no // cookies will be sent with the request. /// - int (CEF_CALLBACK *can_get_cookie)(struct _cef_resource_handler_t* self, - const struct _cef_cookie_t* cookie); + int(CEF_CALLBACK* can_get_cookie)(struct _cef_resource_handler_t* self, + const struct _cef_cookie_t* cookie); /// // Return true (1) if the specified cookie returned with the response can be // set or false (0) otherwise. /// - int (CEF_CALLBACK *can_set_cookie)(struct _cef_resource_handler_t* self, - const struct _cef_cookie_t* cookie); + int(CEF_CALLBACK* can_set_cookie)(struct _cef_resource_handler_t* self, + const struct _cef_cookie_t* cookie); /// // Request processing has been canceled. /// - void (CEF_CALLBACK *cancel)(struct _cef_resource_handler_t* self); + void(CEF_CALLBACK* cancel)(struct _cef_resource_handler_t* self); } cef_resource_handler_t; - #ifdef __cplusplus } #endif diff --git a/include/capi/cef_response_capi.h b/include/capi/cef_response_capi.h index c04ea01..8e68cd5 100644 --- a/include/capi/cef_response_capi.h +++ b/include/capi/cef_response_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,18 +33,19 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=3f0ed89d2320677780c2fd526be7fe6312580cd8$ +// #ifndef CEF_INCLUDE_CAPI_CEF_RESPONSE_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_RESPONSE_CAPI_H_ #pragma once +#include "include/capi/cef_base_capi.h" + #ifdef __cplusplus extern "C" { #endif -#include "include/capi/cef_base_capi.h" - - /// // Structure used to represent a web response. The functions of this structure // may be called on any thread. @@ -53,76 +54,86 @@ typedef struct _cef_response_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Returns true (1) if this object is read-only. /// - int (CEF_CALLBACK *is_read_only)(struct _cef_response_t* self); + int(CEF_CALLBACK* is_read_only)(struct _cef_response_t* self); + + /// + // Get the response error code. Returns ERR_NONE if there was no error. + /// + cef_errorcode_t(CEF_CALLBACK* get_error)(struct _cef_response_t* self); + + /// + // Set the response error code. This can be used by custom scheme handlers to + // return errors during initial request processing. + /// + void(CEF_CALLBACK* set_error)(struct _cef_response_t* self, + cef_errorcode_t error); /// // Get the response status code. /// - int (CEF_CALLBACK *get_status)(struct _cef_response_t* self); + int(CEF_CALLBACK* get_status)(struct _cef_response_t* self); /// // Set the response status code. /// - void (CEF_CALLBACK *set_status)(struct _cef_response_t* self, int status); + void(CEF_CALLBACK* set_status)(struct _cef_response_t* self, int status); /// // Get the response status text. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_status_text)( + cef_string_userfree_t(CEF_CALLBACK* get_status_text)( struct _cef_response_t* self); /// // Set the response status text. /// - void (CEF_CALLBACK *set_status_text)(struct _cef_response_t* self, - const cef_string_t* statusText); + void(CEF_CALLBACK* set_status_text)(struct _cef_response_t* self, + const cef_string_t* statusText); /// // Get the response mime type. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_mime_type)( + cef_string_userfree_t(CEF_CALLBACK* get_mime_type)( struct _cef_response_t* self); /// // Set the response mime type. /// - void (CEF_CALLBACK *set_mime_type)(struct _cef_response_t* self, - const cef_string_t* mimeType); + void(CEF_CALLBACK* set_mime_type)(struct _cef_response_t* self, + const cef_string_t* mimeType); /// // Get the value for the specified response header field. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_header)(struct _cef_response_t* self, - const cef_string_t* name); + cef_string_userfree_t(CEF_CALLBACK* get_header)(struct _cef_response_t* self, + const cef_string_t* name); /// // Get all response header fields. /// - void (CEF_CALLBACK *get_header_map)(struct _cef_response_t* self, - cef_string_multimap_t headerMap); + void(CEF_CALLBACK* get_header_map)(struct _cef_response_t* self, + cef_string_multimap_t headerMap); /// // Set all response header fields. /// - void (CEF_CALLBACK *set_header_map)(struct _cef_response_t* self, - cef_string_multimap_t headerMap); + void(CEF_CALLBACK* set_header_map)(struct _cef_response_t* self, + cef_string_multimap_t headerMap); } cef_response_t; - /// // Create a new cef_response_t object. /// CEF_EXPORT cef_response_t* cef_response_create(); - #ifdef __cplusplus } #endif diff --git a/include/capi/cef_response_filter_capi.h b/include/capi/cef_response_filter_capi.h new file mode 100644 index 0000000..d46ebcc --- /dev/null +++ b/include/capi/cef_response_filter_capi.h @@ -0,0 +1,110 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=c7126418fc448f9f75e770fda8434613eed0930d$ +// + +#ifndef CEF_INCLUDE_CAPI_CEF_RESPONSE_FILTER_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_RESPONSE_FILTER_CAPI_H_ +#pragma once + +#include "include/capi/cef_base_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// Implement this structure to filter resource response content. The functions +// of this structure will be called on the browser process IO thread. +/// +typedef struct _cef_response_filter_t { + /// + // Base structure. + /// + cef_base_ref_counted_t base; + + /// + // Initialize the response filter. Will only be called a single time. The + // filter will not be installed if this function returns false (0). + /// + int(CEF_CALLBACK* init_filter)(struct _cef_response_filter_t* self); + + /// + // Called to filter a chunk of data. Expected usage is as follows: + // + // A. Read input data from |data_in| and set |data_in_read| to the number of + // bytes that were read up to a maximum of |data_in_size|. |data_in| will + // be NULL if |data_in_size| is zero. + // B. Write filtered output data to |data_out| and set |data_out_written| to + // the number of bytes that were written up to a maximum of + // |data_out_size|. If no output data was written then all data must be + // read from |data_in| (user must set |data_in_read| = |data_in_size|). + // C. Return RESPONSE_FILTER_DONE if all output data was written or + // RESPONSE_FILTER_NEED_MORE_DATA if output data is still pending. + // + // This function will be called repeatedly until the input buffer has been + // fully read (user sets |data_in_read| = |data_in_size|) and there is no more + // input data to filter (the resource response is complete). This function may + // then be called an additional time with an NULL input buffer if the user + // filled the output buffer (set |data_out_written| = |data_out_size|) and + // returned RESPONSE_FILTER_NEED_MORE_DATA to indicate that output data is + // still pending. + // + // Calls to this function will stop when one of the following conditions is + // met: + // + // A. There is no more input data to filter (the resource response is + // complete) and the user sets |data_out_written| = 0 or returns + // RESPONSE_FILTER_DONE to indicate that all data has been written, or; + // B. The user returns RESPONSE_FILTER_ERROR to indicate an error. + // + // Do not keep a reference to the buffers passed to this function. + /// + cef_response_filter_status_t(CEF_CALLBACK* filter)( + struct _cef_response_filter_t* self, + void* data_in, + size_t data_in_size, + size_t* data_in_read, + void* data_out, + size_t data_out_size, + size_t* data_out_written); +} cef_response_filter_t; + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_RESPONSE_FILTER_CAPI_H_ diff --git a/include/capi/cef_scheme_capi.h b/include/capi/cef_scheme_capi.h index 0129ae1..e746395 100644 --- a/include/capi/cef_scheme_capi.h +++ b/include/capi/cef_scheme_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,15 +33,13 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=a920e25c5ca348dcc45965d53389c16a8a29b0ed$ +// #ifndef CEF_INCLUDE_CAPI_CEF_SCHEME_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_SCHEME_CAPI_H_ #pragma once -#ifdef __cplusplus -extern "C" { -#endif - #include "include/capi/cef_base_capi.h" #include "include/capi/cef_browser_capi.h" #include "include/capi/cef_frame_capi.h" @@ -49,6 +47,10 @@ extern "C" { #include "include/capi/cef_resource_handler_capi.h" #include "include/capi/cef_response_capi.h" +#ifdef __cplusplus +extern "C" { +#endif + struct _cef_scheme_handler_factory_t; /// @@ -58,7 +60,7 @@ typedef struct _cef_scheme_registrar_t { /// // Base structure. /// - cef_base_t base; + cef_base_scoped_t base; /// // Register a custom scheme. This function should not be called for the built- @@ -87,31 +89,48 @@ typedef struct _cef_scheme_registrar_t { // is. For example, "scheme:///some%20text" will remain the same. Non-standard // scheme URLs cannot be used as a target for form submission. // - // If |is_local| is true (1) the scheme will be treated as local (i.e., with - // the same security rules as those applied to "file" URLs). Normal pages - // cannot link to or access local URLs. Also, by default, local URLs can only - // perform XMLHttpRequest calls to the same URL (origin + path) that - // originated the request. To allow XMLHttpRequest calls from a local URL to - // other URLs with the same origin set the - // CefSettings.file_access_from_file_urls_allowed value to true (1). To allow - // XMLHttpRequest calls from a local URL to all origins set the - // CefSettings.universal_access_from_file_urls_allowed value to true (1). + // If |is_local| is true (1) 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). + // + // If |is_display_isolated| is true (1) 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 set this value to false + // (0), set |is_cors_enabled| to true (1), and use CORS "Access-Control-Allow- + // Origin" headers to further restrict access. + // + // If |is_secure| is true (1) 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. // - // If |is_display_isolated| is true (1) the scheme will be treated as display- - // isolated. This means that pages cannot display these URLs unless they are - // from the same scheme. For example, pages in another origin cannot create - // iframes or hyperlinks to URLs with this scheme. + // If |is_cors_enabled| is true (1) the scheme can be sent CORS requests. This + // value should be true (1) in most cases where |is_standard| is true (1). + // + // If |is_csp_bypassing| is true (1) the scheme can bypass Content-Security- + // Policy (CSP) checks. This value should be false (0) in most cases where + // |is_standard| is true (1). // // This function may be called on any thread. It should only be called once // per unique |scheme_name| value. If |scheme_name| is already registered or // if an error occurs this function will return false (0). /// - int (CEF_CALLBACK *add_custom_scheme)(struct _cef_scheme_registrar_t* self, - const cef_string_t* scheme_name, int is_standard, int is_local, - int is_display_isolated); + int(CEF_CALLBACK* add_custom_scheme)(struct _cef_scheme_registrar_t* self, + const cef_string_t* scheme_name, + int is_standard, + int is_local, + int is_display_isolated, + int is_secure, + int is_cors_enabled, + int is_csp_bypassing); } cef_scheme_registrar_t; - /// // Structure that creates cef_resource_handler_t instances for handling scheme // requests. The functions of this structure will always be called on the IO @@ -121,7 +140,7 @@ typedef struct _cef_scheme_handler_factory_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Return a new resource handler instance to handle the request or an NULL @@ -131,33 +150,40 @@ typedef struct _cef_scheme_handler_factory_t { // example, if the request came from cef_urlrequest_t). The |request| object // passed to this function will not contain cookie data. /// - struct _cef_resource_handler_t* (CEF_CALLBACK *create)( + struct _cef_resource_handler_t*(CEF_CALLBACK* create)( struct _cef_scheme_handler_factory_t* self, - struct _cef_browser_t* browser, struct _cef_frame_t* frame, - const cef_string_t* scheme_name, struct _cef_request_t* request); + struct _cef_browser_t* browser, + struct _cef_frame_t* frame, + const cef_string_t* scheme_name, + struct _cef_request_t* request); } cef_scheme_handler_factory_t; - /// -// Register a scheme handler factory for the specified |scheme_name| and -// optional |domain_name|. An NULL |domain_name| value for a standard scheme -// will cause the factory to match all domain names. The |domain_name| value -// will be ignored for non-standard schemes. If |scheme_name| is a built-in -// scheme and no handler is returned by |factory| then the built-in scheme -// handler factory will be called. If |scheme_name| is a custom scheme then also -// implement the cef_app_t::on_register_custom_schemes() function in all -// processes. This function may be called multiple times to change or remove the -// factory that matches the specified |scheme_name| and optional |domain_name|. -// Returns false (0) if an error occurs. This function may be called on any -// thread in the browser process. +// Register a scheme handler factory with the global request context. An NULL +// |domain_name| value for a standard scheme will cause the factory to match all +// domain names. The |domain_name| value will be ignored for non-standard +// schemes. If |scheme_name| is a built-in scheme and no handler is returned by +// |factory| then the built-in scheme handler factory will be called. If +// |scheme_name| is a custom scheme then you must also implement the +// cef_app_t::on_register_custom_schemes() function in all processes. This +// function may be called multiple times to change or remove the factory that +// matches the specified |scheme_name| and optional |domain_name|. Returns false +// (0) if an error occurs. This function may be called on any thread in the +// browser process. Using this function is equivalent to calling cef_request_tCo +// ntext::cef_request_context_get_global_context()->register_scheme_handler_fact +// ory(). /// CEF_EXPORT int cef_register_scheme_handler_factory( - const cef_string_t* scheme_name, const cef_string_t* domain_name, + const cef_string_t* scheme_name, + const cef_string_t* domain_name, cef_scheme_handler_factory_t* factory); /// -// Clear all registered scheme handler factories. Returns false (0) on error. -// This function may be called on any thread in the browser process. +// Clear all scheme handler factories registered with the global request +// context. Returns false (0) on error. This function may be called on any +// thread in the browser process. Using this function is equivalent to calling c +// ef_request_tContext::cef_request_context_get_global_context()->clear_scheme_h +// andler_factories(). /// CEF_EXPORT int cef_clear_scheme_handler_factories(); diff --git a/include/capi/cef_ssl_info_capi.h b/include/capi/cef_ssl_info_capi.h new file mode 100644 index 0000000..e924a3b --- /dev/null +++ b/include/capi/cef_ssl_info_capi.h @@ -0,0 +1,88 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=7489f3078e15407c3984f0b2393df3b0ddc045b0$ +// + +#ifndef CEF_INCLUDE_CAPI_CEF_SSL_INFO_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_SSL_INFO_CAPI_H_ +#pragma once + +#include "include/capi/cef_base_capi.h" +#include "include/capi/cef_values_capi.h" +#include "include/capi/cef_x509_certificate_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// Structure representing SSL information. +/// +typedef struct _cef_sslinfo_t { + /// + // Base structure. + /// + cef_base_ref_counted_t base; + + /// + // Returns a bitmask containing any and all problems verifying the server + // certificate. + /// + cef_cert_status_t(CEF_CALLBACK* get_cert_status)(struct _cef_sslinfo_t* self); + + /// + // Returns the X.509 certificate. + /// + struct _cef_x509certificate_t*(CEF_CALLBACK* get_x509certificate)( + struct _cef_sslinfo_t* self); +} cef_sslinfo_t; + +/// +// Returns true (1) if the certificate status has any error, major or minor. +/// +CEF_EXPORT int cef_is_cert_status_error(cef_cert_status_t status); + +/// +// Returns true (1) if the certificate status represents only minor errors (e.g. +// failure to verify certificate revocation). +/// +CEF_EXPORT int cef_is_cert_status_minor_error(cef_cert_status_t status); + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_SSL_INFO_CAPI_H_ diff --git a/include/capi/cef_ssl_status_capi.h b/include/capi/cef_ssl_status_capi.h new file mode 100644 index 0000000..c82f9ad --- /dev/null +++ b/include/capi/cef_ssl_status_capi.h @@ -0,0 +1,95 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=2aa604a0520a802ae3b10f5922d4a7ca48078785$ +// + +#ifndef CEF_INCLUDE_CAPI_CEF_SSL_STATUS_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_SSL_STATUS_CAPI_H_ +#pragma once + +#include "include/capi/cef_base_capi.h" +#include "include/capi/cef_values_capi.h" +#include "include/capi/cef_x509_certificate_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// Structure representing the SSL information for a navigation entry. +/// +typedef struct _cef_sslstatus_t { + /// + // Base structure. + /// + cef_base_ref_counted_t base; + + /// + // Returns true (1) if the status is related to a secure SSL/TLS connection. + /// + int(CEF_CALLBACK* is_secure_connection)(struct _cef_sslstatus_t* self); + + /// + // Returns a bitmask containing any and all problems verifying the server + // certificate. + /// + cef_cert_status_t(CEF_CALLBACK* get_cert_status)( + struct _cef_sslstatus_t* self); + + /// + // Returns the SSL version used for the SSL connection. + /// + cef_ssl_version_t(CEF_CALLBACK* get_sslversion)( + struct _cef_sslstatus_t* self); + + /// + // Returns a bitmask containing the page security content status. + /// + cef_ssl_content_status_t(CEF_CALLBACK* get_content_status)( + struct _cef_sslstatus_t* self); + + /// + // Returns the X.509 certificate. + /// + struct _cef_x509certificate_t*(CEF_CALLBACK* get_x509certificate)( + struct _cef_sslstatus_t* self); +} cef_sslstatus_t; + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_SSL_STATUS_CAPI_H_ diff --git a/include/capi/cef_stream_capi.h b/include/capi/cef_stream_capi.h index 84830c8..13fcadd 100644 --- a/include/capi/cef_stream_capi.h +++ b/include/capi/cef_stream_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,18 +33,19 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=4e127106e9b5fada6bf05ea6e29bc502bb2a1e0d$ +// #ifndef CEF_INCLUDE_CAPI_CEF_STREAM_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_STREAM_CAPI_H_ #pragma once +#include "include/capi/cef_base_capi.h" + #ifdef __cplusplus extern "C" { #endif -#include "include/capi/cef_base_capi.h" - - /// // Structure the client can implement to provide a custom stream reader. The // functions of this structure may be called on any thread. @@ -53,40 +54,42 @@ typedef struct _cef_read_handler_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Read raw binary data. /// - size_t (CEF_CALLBACK *read)(struct _cef_read_handler_t* self, void* ptr, - size_t size, size_t n); + size_t(CEF_CALLBACK* read)(struct _cef_read_handler_t* self, + void* ptr, + size_t size, + size_t n); /// // Seek to the specified offset position. |whence| may be any one of SEEK_CUR, // SEEK_END or SEEK_SET. Return zero on success and non-zero on failure. /// - int (CEF_CALLBACK *seek)(struct _cef_read_handler_t* self, int64 offset, - int whence); + int(CEF_CALLBACK* seek)(struct _cef_read_handler_t* self, + int64 offset, + int whence); /// // Return the current offset position. /// - int64 (CEF_CALLBACK *tell)(struct _cef_read_handler_t* self); + int64(CEF_CALLBACK* tell)(struct _cef_read_handler_t* self); /// // Return non-zero if at end of file. /// - int (CEF_CALLBACK *eof)(struct _cef_read_handler_t* self); + int(CEF_CALLBACK* eof)(struct _cef_read_handler_t* self); /// // Return true (1) if this handler performs work like accessing the file // system which may block. Used as a hint for determining the thread to access // the handler from. /// - int (CEF_CALLBACK *may_block)(struct _cef_read_handler_t* self); + int(CEF_CALLBACK* may_block)(struct _cef_read_handler_t* self); } cef_read_handler_t; - /// // Structure used to read data from a stream. The functions of this structure // may be called on any thread. @@ -95,40 +98,42 @@ typedef struct _cef_stream_reader_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Read raw binary data. /// - size_t (CEF_CALLBACK *read)(struct _cef_stream_reader_t* self, void* ptr, - size_t size, size_t n); + size_t(CEF_CALLBACK* read)(struct _cef_stream_reader_t* self, + void* ptr, + size_t size, + size_t n); /// // Seek to the specified offset position. |whence| may be any one of SEEK_CUR, // SEEK_END or SEEK_SET. Returns zero on success and non-zero on failure. /// - int (CEF_CALLBACK *seek)(struct _cef_stream_reader_t* self, int64 offset, - int whence); + int(CEF_CALLBACK* seek)(struct _cef_stream_reader_t* self, + int64 offset, + int whence); /// // Return the current offset position. /// - int64 (CEF_CALLBACK *tell)(struct _cef_stream_reader_t* self); + int64(CEF_CALLBACK* tell)(struct _cef_stream_reader_t* self); /// // Return non-zero if at end of file. /// - int (CEF_CALLBACK *eof)(struct _cef_stream_reader_t* self); + int(CEF_CALLBACK* eof)(struct _cef_stream_reader_t* self); /// // Returns true (1) if this reader performs work like accessing the file // system which may block. Used as a hint for determining the thread to access // the reader from. /// - int (CEF_CALLBACK *may_block)(struct _cef_stream_reader_t* self); + int(CEF_CALLBACK* may_block)(struct _cef_stream_reader_t* self); } cef_stream_reader_t; - /// // Create a new cef_stream_reader_t object from a file. /// @@ -139,7 +144,7 @@ CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_file( // Create a new cef_stream_reader_t object from data. /// CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_data(void* data, - size_t size); + size_t size); /// // Create a new cef_stream_reader_t object from a custom handler. @@ -147,7 +152,6 @@ CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_data(void* data, CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_handler( cef_read_handler_t* handler); - /// // Structure the client can implement to provide a custom stream writer. The // functions of this structure may be called on any thread. @@ -156,40 +160,42 @@ typedef struct _cef_write_handler_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Write raw binary data. /// - size_t (CEF_CALLBACK *write)(struct _cef_write_handler_t* self, - const void* ptr, size_t size, size_t n); + size_t(CEF_CALLBACK* write)(struct _cef_write_handler_t* self, + const void* ptr, + size_t size, + size_t n); /// // Seek to the specified offset position. |whence| may be any one of SEEK_CUR, // SEEK_END or SEEK_SET. Return zero on success and non-zero on failure. /// - int (CEF_CALLBACK *seek)(struct _cef_write_handler_t* self, int64 offset, - int whence); + int(CEF_CALLBACK* seek)(struct _cef_write_handler_t* self, + int64 offset, + int whence); /// // Return the current offset position. /// - int64 (CEF_CALLBACK *tell)(struct _cef_write_handler_t* self); + int64(CEF_CALLBACK* tell)(struct _cef_write_handler_t* self); /// // Flush the stream. /// - int (CEF_CALLBACK *flush)(struct _cef_write_handler_t* self); + int(CEF_CALLBACK* flush)(struct _cef_write_handler_t* self); /// // Return true (1) if this handler performs work like accessing the file // system which may block. Used as a hint for determining the thread to access // the handler from. /// - int (CEF_CALLBACK *may_block)(struct _cef_write_handler_t* self); + int(CEF_CALLBACK* may_block)(struct _cef_write_handler_t* self); } cef_write_handler_t; - /// // Structure used to write data to a stream. The functions of this structure may // be called on any thread. @@ -198,40 +204,42 @@ typedef struct _cef_stream_writer_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Write raw binary data. /// - size_t (CEF_CALLBACK *write)(struct _cef_stream_writer_t* self, - const void* ptr, size_t size, size_t n); + size_t(CEF_CALLBACK* write)(struct _cef_stream_writer_t* self, + const void* ptr, + size_t size, + size_t n); /// // Seek to the specified offset position. |whence| may be any one of SEEK_CUR, // SEEK_END or SEEK_SET. Returns zero on success and non-zero on failure. /// - int (CEF_CALLBACK *seek)(struct _cef_stream_writer_t* self, int64 offset, - int whence); + int(CEF_CALLBACK* seek)(struct _cef_stream_writer_t* self, + int64 offset, + int whence); /// // Return the current offset position. /// - int64 (CEF_CALLBACK *tell)(struct _cef_stream_writer_t* self); + int64(CEF_CALLBACK* tell)(struct _cef_stream_writer_t* self); /// // Flush the stream. /// - int (CEF_CALLBACK *flush)(struct _cef_stream_writer_t* self); + int(CEF_CALLBACK* flush)(struct _cef_stream_writer_t* self); /// // Returns true (1) if this writer performs work like accessing the file // system which may block. Used as a hint for determining the thread to access // the writer from. /// - int (CEF_CALLBACK *may_block)(struct _cef_stream_writer_t* self); + int(CEF_CALLBACK* may_block)(struct _cef_stream_writer_t* self); } cef_stream_writer_t; - /// // Create a new cef_stream_writer_t object for a file. /// @@ -244,7 +252,6 @@ CEF_EXPORT cef_stream_writer_t* cef_stream_writer_create_for_file( CEF_EXPORT cef_stream_writer_t* cef_stream_writer_create_for_handler( cef_write_handler_t* handler); - #ifdef __cplusplus } #endif diff --git a/include/capi/cef_string_visitor_capi.h b/include/capi/cef_string_visitor_capi.h index 93351b4..7d4c3df 100644 --- a/include/capi/cef_string_visitor_capi.h +++ b/include/capi/cef_string_visitor_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,18 +33,19 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=2e8edddfd49aea615c7adf8d0d092a4865b79229$ +// #ifndef CEF_INCLUDE_CAPI_CEF_STRING_VISITOR_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_STRING_VISITOR_CAPI_H_ #pragma once +#include "include/capi/cef_base_capi.h" + #ifdef __cplusplus extern "C" { #endif -#include "include/capi/cef_base_capi.h" - - /// // Implement this structure to receive string values asynchronously. /// @@ -52,16 +53,15 @@ typedef struct _cef_string_visitor_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Method that will be executed. /// - void (CEF_CALLBACK *visit)(struct _cef_string_visitor_t* self, - const cef_string_t* string); + void(CEF_CALLBACK* visit)(struct _cef_string_visitor_t* self, + const cef_string_t* string); } cef_string_visitor_t; - #ifdef __cplusplus } #endif diff --git a/include/capi/cef_task_capi.h b/include/capi/cef_task_capi.h index ce79f3d..ad48c70 100644 --- a/include/capi/cef_task_capi.h +++ b/include/capi/cef_task_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,18 +33,19 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=344ba415349b4cc305f51cb9e22563b232433e25$ +// #ifndef CEF_INCLUDE_CAPI_CEF_TASK_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_TASK_CAPI_H_ #pragma once +#include "include/capi/cef_base_capi.h" + #ifdef __cplusplus extern "C" { #endif -#include "include/capi/cef_base_capi.h" - - /// // Implement this structure for asynchronous task execution. If the task is // posted successfully and if the associated message loop is still running then @@ -57,15 +58,14 @@ typedef struct _cef_task_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Method that will be executed on the target thread. /// - void (CEF_CALLBACK *execute)(struct _cef_task_t* self); + void(CEF_CALLBACK* execute)(struct _cef_task_t* self); } cef_task_t; - /// // Structure that asynchronously executes tasks on the associated thread. It is // safe to call the functions of this structure on any thread. @@ -79,33 +79,32 @@ typedef struct _cef_task_runner_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Returns true (1) if this object is pointing to the same task runner as // |that| object. /// - int (CEF_CALLBACK *is_same)(struct _cef_task_runner_t* self, - struct _cef_task_runner_t* that); + int(CEF_CALLBACK* is_same)(struct _cef_task_runner_t* self, + struct _cef_task_runner_t* that); /// // Returns true (1) if this task runner belongs to the current thread. /// - int (CEF_CALLBACK *belongs_to_current_thread)( - struct _cef_task_runner_t* self); + int(CEF_CALLBACK* belongs_to_current_thread)(struct _cef_task_runner_t* self); /// // Returns true (1) if this task runner is for the specified CEF thread. /// - int (CEF_CALLBACK *belongs_to_thread)(struct _cef_task_runner_t* self, - cef_thread_id_t threadId); + int(CEF_CALLBACK* belongs_to_thread)(struct _cef_task_runner_t* self, + cef_thread_id_t threadId); /// // Post a task for execution on the thread associated with this task runner. // Execution will occur asynchronously. /// - int (CEF_CALLBACK *post_task)(struct _cef_task_runner_t* self, - struct _cef_task_t* task); + int(CEF_CALLBACK* post_task)(struct _cef_task_runner_t* self, + struct _cef_task_t* task); /// // Post a task for delayed execution on the thread associated with this task @@ -113,11 +112,11 @@ typedef struct _cef_task_runner_t { // supported on V8 WebWorker threads and will be executed without the // specified delay. /// - int (CEF_CALLBACK *post_delayed_task)(struct _cef_task_runner_t* self, - struct _cef_task_t* task, int64 delay_ms); + int(CEF_CALLBACK* post_delayed_task)(struct _cef_task_runner_t* self, + struct _cef_task_t* task, + int64 delay_ms); } cef_task_runner_t; - /// // Returns the task runner for the current thread. Only CEF threads will have // task runners. An NULL reference will be returned if this function is called @@ -131,26 +130,26 @@ CEF_EXPORT cef_task_runner_t* cef_task_runner_get_for_current_thread(); CEF_EXPORT cef_task_runner_t* cef_task_runner_get_for_thread( cef_thread_id_t threadId); - /// // Returns true (1) if called on the specified thread. Equivalent to using -// cef_task_runner_t::GetForThread(threadId)->belongs_to_current_thread(). +// cef_task_tRunner::GetForThread(threadId)->belongs_to_current_thread(). /// CEF_EXPORT int cef_currently_on(cef_thread_id_t threadId); /// // Post a task for execution on the specified thread. Equivalent to using -// cef_task_runner_t::GetForThread(threadId)->PostTask(task). +// cef_task_tRunner::GetForThread(threadId)->PostTask(task). /// CEF_EXPORT int cef_post_task(cef_thread_id_t threadId, cef_task_t* task); /// // Post a task for delayed execution on the specified thread. Equivalent to -// using cef_task_runner_t::GetForThread(threadId)->PostDelayedTask(task, +// using cef_task_tRunner::GetForThread(threadId)->PostDelayedTask(task, // delay_ms). /// -CEF_EXPORT int cef_post_delayed_task(cef_thread_id_t threadId, cef_task_t* task, - int64 delay_ms); +CEF_EXPORT int cef_post_delayed_task(cef_thread_id_t threadId, + cef_task_t* task, + int64 delay_ms); #ifdef __cplusplus } diff --git a/include/capi/cef_thread_capi.h b/include/capi/cef_thread_capi.h new file mode 100644 index 0000000..0932437 --- /dev/null +++ b/include/capi/cef_thread_capi.h @@ -0,0 +1,117 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=d844086fc675680bfae12c3fa12a6886cc804816$ +// + +#ifndef CEF_INCLUDE_CAPI_CEF_THREAD_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_THREAD_CAPI_H_ +#pragma once + +#include "include/capi/cef_task_capi.h" +#include "include/internal/cef_thread_internal.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// A simple thread abstraction that establishes a message loop on a new thread. +// The consumer uses cef_task_tRunner to execute code on the thread's message +// loop. The thread is terminated when the cef_thread_t object is destroyed or +// stop() is called. All pending tasks queued on the thread's message loop will +// run to completion before the thread is terminated. cef_thread_create() can be +// called on any valid CEF thread in either the browser or render process. This +// structure should only be used for tasks that require a dedicated thread. In +// most cases you can post tasks to an existing CEF thread instead of creating a +// new one; see cef_task.h for details. +/// +typedef struct _cef_thread_t { + /// + // Base structure. + /// + cef_base_ref_counted_t base; + + /// + // Returns the cef_task_tRunner that will execute code on this thread's + // message loop. This function is safe to call from any thread. + /// + struct _cef_task_runner_t*(CEF_CALLBACK* get_task_runner)( + struct _cef_thread_t* self); + + /// + // Returns the platform thread ID. It will return the same value after stop() + // is called. This function is safe to call from any thread. + /// + cef_platform_thread_id_t(CEF_CALLBACK* get_platform_thread_id)( + struct _cef_thread_t* self); + + /// + // Stop and join the thread. This function must be called from the same thread + // that called cef_thread_create(). Do not call this function if + // cef_thread_create() was called with a |stoppable| value of false (0). + /// + void(CEF_CALLBACK* stop)(struct _cef_thread_t* self); + + /// + // Returns true (1) if the thread is currently running. This function must be + // called from the same thread that called cef_thread_create(). + /// + int(CEF_CALLBACK* is_running)(struct _cef_thread_t* self); +} cef_thread_t; + +/// +// Create and start a new thread. This function does not block waiting for the +// thread to run initialization. |display_name| is the name that will be used to +// identify the thread. |priority| is the thread execution priority. +// |message_loop_type| indicates the set of asynchronous events that the thread +// can process. If |stoppable| is true (1) the thread will stopped and joined on +// destruction or when stop() is called; otherwise, the the thread cannot be +// stopped and will be leaked on shutdown. On Windows the |com_init_mode| value +// specifies how COM will be initialized for the thread. If |com_init_mode| is +// set to COM_INIT_MODE_STA then |message_loop_type| must be set to ML_TYPE_UI. +/// +CEF_EXPORT cef_thread_t* cef_thread_create( + const cef_string_t* display_name, + cef_thread_priority_t priority, + cef_message_loop_type_t message_loop_type, + int stoppable, + cef_com_init_mode_t com_init_mode); + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_THREAD_CAPI_H_ diff --git a/include/capi/cef_trace_capi.h b/include/capi/cef_trace_capi.h index 0ac4898..b3179d4 100644 --- a/include/capi/cef_trace_capi.h +++ b/include/capi/cef_trace_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,18 +33,20 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=2684497985a960a8699e6c24aeb17370cf318e88$ +// #ifndef CEF_INCLUDE_CAPI_CEF_TRACE_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_TRACE_CAPI_H_ #pragma once +#include "include/capi/cef_base_capi.h" +#include "include/capi/cef_callback_capi.h" + #ifdef __cplusplus extern "C" { #endif -#include "include/capi/cef_base_capi.h" - - /// // Implement this structure to receive notification when tracing has completed. // The functions of this structure will be called on the browser process UI @@ -54,23 +56,22 @@ typedef struct _cef_end_tracing_callback_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Called after all processes have sent their trace data. |tracing_file| is // the path at which tracing data was written. The client is responsible for // deleting |tracing_file|. /// - void (CEF_CALLBACK *on_end_tracing_complete)( + void(CEF_CALLBACK* on_end_tracing_complete)( struct _cef_end_tracing_callback_t* self, const cef_string_t* tracing_file); } cef_end_tracing_callback_t; - /// -// Start tracing events on all processes. Tracing begins immediately locally, -// and asynchronously on child processes as soon as they receive the -// BeginTracing request. +// Start tracing events on all processes. Tracing is initialized asynchronously +// and |callback| will be executed on the UI thread after initialization is +// complete. // // If CefBeginTracing was called previously, or if a CefEndTracingAsync call is // pending, CefBeginTracing will fail and return false (0). @@ -84,7 +85,8 @@ typedef struct _cef_end_tracing_callback_t { // // This function must be called on the browser process UI thread. /// -CEF_EXPORT int cef_begin_tracing(const cef_string_t* categories); +CEF_EXPORT int cef_begin_tracing(const cef_string_t* categories, + struct _cef_completion_callback_t* callback); /// // Stop tracing events on all processes. @@ -99,8 +101,8 @@ CEF_EXPORT int cef_begin_tracing(const cef_string_t* categories); // // This function must be called on the browser process UI thread. /// -CEF_EXPORT int cef_end_tracing_async(const cef_string_t* tracing_file, - cef_end_tracing_callback_t* callback); +CEF_EXPORT int cef_end_tracing(const cef_string_t* tracing_file, + cef_end_tracing_callback_t* callback); /// // Returns the current system trace time or, if none is defined, the current diff --git a/include/capi/cef_urlrequest_capi.h b/include/capi/cef_urlrequest_capi.h index 6157841..28714d7 100644 --- a/include/capi/cef_urlrequest_capi.h +++ b/include/capi/cef_urlrequest_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,20 +33,23 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=d0ac53d1df275f9ea9cf19a6a07f8dce88f2b151$ +// #ifndef CEF_INCLUDE_CAPI_CEF_URLREQUEST_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_URLREQUEST_CAPI_H_ #pragma once -#ifdef __cplusplus -extern "C" { -#endif - #include "include/capi/cef_auth_callback_capi.h" #include "include/capi/cef_base_capi.h" #include "include/capi/cef_request_capi.h" +#include "include/capi/cef_request_context_capi.h" #include "include/capi/cef_response_capi.h" +#ifdef __cplusplus +extern "C" { +#endif + struct _cef_urlrequest_client_t; /// @@ -60,32 +63,32 @@ typedef struct _cef_urlrequest_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Returns the request object used to create this URL request. The returned // object is read-only and should not be modified. /// - struct _cef_request_t* (CEF_CALLBACK *get_request)( + struct _cef_request_t*(CEF_CALLBACK* get_request)( struct _cef_urlrequest_t* self); /// // Returns the client. /// - struct _cef_urlrequest_client_t* (CEF_CALLBACK *get_client)( + struct _cef_urlrequest_client_t*(CEF_CALLBACK* get_client)( struct _cef_urlrequest_t* self); /// // Returns the request status. /// - cef_urlrequest_status_t (CEF_CALLBACK *get_request_status)( + cef_urlrequest_status_t(CEF_CALLBACK* get_request_status)( struct _cef_urlrequest_t* self); /// // Returns the request error if status is UR_CANCELED or UR_FAILED, or 0 // otherwise. /// - cef_errorcode_t (CEF_CALLBACK *get_request_error)( + cef_errorcode_t(CEF_CALLBACK* get_request_error)( struct _cef_urlrequest_t* self); /// @@ -93,16 +96,15 @@ typedef struct _cef_urlrequest_t { // Response information will only be available after the upload has completed. // The returned object is read-only and should not be modified. /// - struct _cef_response_t* (CEF_CALLBACK *get_response)( + struct _cef_response_t*(CEF_CALLBACK* get_response)( struct _cef_urlrequest_t* self); /// // Cancel the request. /// - void (CEF_CALLBACK *cancel)(struct _cef_urlrequest_t* self); + void(CEF_CALLBACK* cancel)(struct _cef_urlrequest_t* self); } cef_urlrequest_t; - /// // Create a new URL request. Only GET, POST, HEAD, DELETE and PUT request // functions are supported. Multiple post data elements are not supported and @@ -113,11 +115,15 @@ typedef struct _cef_urlrequest_t { // not normally be rendered then the response may receive special handling // inside the browser (for example, via the file download code path instead of // the URL request code path). The |request| object will be marked as read-only -// after calling this function. +// after calling this function. In the browser process if |request_context| is +// NULL the global request context will be used. In the render process +// |request_context| must be NULL and the context associated with the current +// renderer process' browser will be used. /// CEF_EXPORT cef_urlrequest_t* cef_urlrequest_create( - struct _cef_request_t* request, struct _cef_urlrequest_client_t* client); - + struct _cef_request_t* request, + struct _cef_urlrequest_client_t* client, + struct _cef_request_context_t* request_context); /// // Structure that should be implemented by the cef_urlrequest_t client. The @@ -128,16 +134,15 @@ typedef struct _cef_urlrequest_client_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Notifies the client that the request has completed. Use the // cef_urlrequest_t::GetRequestStatus function to determine if the request was // successful or not. /// - void (CEF_CALLBACK *on_request_complete)( - struct _cef_urlrequest_client_t* self, - struct _cef_urlrequest_t* request); + void(CEF_CALLBACK* on_request_complete)(struct _cef_urlrequest_client_t* self, + struct _cef_urlrequest_t* request); /// // Notifies the client of upload progress. |current| denotes the number of @@ -145,26 +150,31 @@ typedef struct _cef_urlrequest_client_t { // chunked upload is enabled). This function will only be called if the // UR_FLAG_REPORT_UPLOAD_PROGRESS flag is set on the request. /// - void (CEF_CALLBACK *on_upload_progress)(struct _cef_urlrequest_client_t* self, - struct _cef_urlrequest_t* request, uint64 current, uint64 total); + void(CEF_CALLBACK* on_upload_progress)(struct _cef_urlrequest_client_t* self, + struct _cef_urlrequest_t* request, + int64 current, + int64 total); /// // Notifies the client of download progress. |current| denotes the number of // bytes received up to the call and |total| is the expected total size of the // response (or -1 if not determined). /// - void (CEF_CALLBACK *on_download_progress)( - struct _cef_urlrequest_client_t* self, struct _cef_urlrequest_t* request, - uint64 current, uint64 total); + void(CEF_CALLBACK* on_download_progress)( + struct _cef_urlrequest_client_t* self, + struct _cef_urlrequest_t* request, + int64 current, + int64 total); /// // Called when some part of the response is read. |data| contains the current // bytes received since the last call. This function will not be called if the // UR_FLAG_NO_DOWNLOAD_DATA flag is set on the request. /// - void (CEF_CALLBACK *on_download_data)(struct _cef_urlrequest_client_t* self, - struct _cef_urlrequest_t* request, const void* data, - size_t data_length); + void(CEF_CALLBACK* on_download_data)(struct _cef_urlrequest_client_t* self, + struct _cef_urlrequest_t* request, + const void* data, + size_t data_length); /// // Called on the IO thread when the browser needs credentials from the user. @@ -175,13 +185,16 @@ typedef struct _cef_urlrequest_client_t { // function will only be called for requests initiated from the browser // process. /// - int (CEF_CALLBACK *get_auth_credentials)( - struct _cef_urlrequest_client_t* self, int isProxy, - const cef_string_t* host, int port, const cef_string_t* realm, - const cef_string_t* scheme, struct _cef_auth_callback_t* callback); + int(CEF_CALLBACK* get_auth_credentials)( + struct _cef_urlrequest_client_t* self, + int isProxy, + const cef_string_t* host, + int port, + const cef_string_t* realm, + const cef_string_t* scheme, + struct _cef_auth_callback_t* callback); } cef_urlrequest_client_t; - #ifdef __cplusplus } #endif diff --git a/include/capi/cef_v8_capi.h b/include/capi/cef_v8_capi.h index af004ee..d62a204 100644 --- a/include/capi/cef_v8_capi.h +++ b/include/capi/cef_v8_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,20 +33,22 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=aecaacd4f1b5294258f4e78883bcfec0a5c5677f$ +// #ifndef CEF_INCLUDE_CAPI_CEF_V8_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_V8_CAPI_H_ #pragma once -#ifdef __cplusplus -extern "C" { -#endif - #include "include/capi/cef_base_capi.h" #include "include/capi/cef_browser_capi.h" #include "include/capi/cef_frame_capi.h" #include "include/capi/cef_task_capi.h" +#ifdef __cplusplus +extern "C" { +#endif + struct _cef_v8exception_t; struct _cef_v8handler_t; struct _cef_v8stack_frame_t; @@ -63,14 +65,14 @@ typedef struct _cef_v8context_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Returns the task runner associated with this context. V8 handles can only // be accessed from the thread on which they are created. This function can be // called on any render process thread. /// - struct _cef_task_runner_t* (CEF_CALLBACK *get_task_runner)( + struct _cef_task_runner_t*(CEF_CALLBACK* get_task_runner)( struct _cef_v8context_t* self); /// @@ -78,26 +80,26 @@ typedef struct _cef_v8context_t { // on the current thread. Do not call any other functions if this function // returns false (0). /// - int (CEF_CALLBACK *is_valid)(struct _cef_v8context_t* self); + int(CEF_CALLBACK* is_valid)(struct _cef_v8context_t* self); /// // Returns the browser for this context. This function will return an NULL // reference for WebWorker contexts. /// - struct _cef_browser_t* (CEF_CALLBACK *get_browser)( + struct _cef_browser_t*(CEF_CALLBACK* get_browser)( struct _cef_v8context_t* self); /// // Returns the frame for this context. This function will return an NULL // reference for WebWorker contexts. /// - struct _cef_frame_t* (CEF_CALLBACK *get_frame)(struct _cef_v8context_t* self); + struct _cef_frame_t*(CEF_CALLBACK* get_frame)(struct _cef_v8context_t* self); /// // Returns the global object for this context. The context must be entered // before calling this function. /// - struct _cef_v8value_t* (CEF_CALLBACK *get_global)( + struct _cef_v8value_t*(CEF_CALLBACK* get_global)( struct _cef_v8context_t* self); /// @@ -107,33 +109,37 @@ typedef struct _cef_v8context_t { // objects belong to the context in which they are created. Returns true (1) // if the scope was entered successfully. /// - int (CEF_CALLBACK *enter)(struct _cef_v8context_t* self); + int(CEF_CALLBACK* enter)(struct _cef_v8context_t* self); /// // Exit this context. Call this function only after calling enter(). Returns // true (1) if the scope was exited successfully. /// - int (CEF_CALLBACK *exit)(struct _cef_v8context_t* self); + int(CEF_CALLBACK* exit)(struct _cef_v8context_t* self); /// // Returns true (1) if this object is pointing to the same handle as |that| // object. /// - int (CEF_CALLBACK *is_same)(struct _cef_v8context_t* self, - struct _cef_v8context_t* that); + int(CEF_CALLBACK* is_same)(struct _cef_v8context_t* self, + struct _cef_v8context_t* that); /// - // Evaluates the specified JavaScript code using this context's global object. + // Execute a string of JavaScript code in this V8 context. The |script_url| + // parameter is the URL where the script in question can be found, if any. The + // |start_line| parameter is the base line number to use for error reporting. // On success |retval| will be set to the return value, if any, and the // function will return true (1). On failure |exception| will be set to the // exception, if any, and the function will return false (0). /// - int (CEF_CALLBACK *eval)(struct _cef_v8context_t* self, - const cef_string_t* code, struct _cef_v8value_t** retval, - struct _cef_v8exception_t** exception); + int(CEF_CALLBACK* eval)(struct _cef_v8context_t* self, + const cef_string_t* code, + const cef_string_t* script_url, + int start_line, + struct _cef_v8value_t** retval, + struct _cef_v8exception_t** exception); } cef_v8context_t; - /// // Returns the current (top) context object in the V8 context stack. /// @@ -149,7 +155,6 @@ CEF_EXPORT cef_v8context_t* cef_v8context_get_entered_context(); /// CEF_EXPORT int cef_v8context_in_context(); - /// // Structure that should be implemented to handle V8 function calls. The // functions of this structure will be called on the thread associated with the @@ -159,7 +164,7 @@ typedef struct _cef_v8handler_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Handle execution of the function identified by |name|. |object| is the @@ -168,24 +173,26 @@ typedef struct _cef_v8handler_t { // function return value. If execution fails set |exception| to the exception // that will be thrown. Return true (1) if execution was handled. /// - int (CEF_CALLBACK *execute)(struct _cef_v8handler_t* self, - const cef_string_t* name, struct _cef_v8value_t* object, - size_t argumentsCount, struct _cef_v8value_t* const* arguments, - struct _cef_v8value_t** retval, cef_string_t* exception); + int(CEF_CALLBACK* execute)(struct _cef_v8handler_t* self, + const cef_string_t* name, + struct _cef_v8value_t* object, + size_t argumentsCount, + struct _cef_v8value_t* const* arguments, + struct _cef_v8value_t** retval, + cef_string_t* exception); } cef_v8handler_t; - /// // Structure that should be implemented to handle V8 accessor calls. Accessor -// identifiers are registered by calling cef_v8value_t::set_value_byaccessor(). -// The functions of this structure will be called on the thread associated with -// the V8 accessor. +// identifiers are registered by calling cef_v8value_t::set_value(). The +// functions of this structure will be called on the thread associated with the +// V8 accessor. /// typedef struct _cef_v8accessor_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Handle retrieval the accessor value identified by |name|. |object| is the @@ -194,9 +201,11 @@ typedef struct _cef_v8accessor_t { // exception that will be thrown. Return true (1) if accessor retrieval was // handled. /// - int (CEF_CALLBACK *get)(struct _cef_v8accessor_t* self, - const cef_string_t* name, struct _cef_v8value_t* object, - struct _cef_v8value_t** retval, cef_string_t* exception); + int(CEF_CALLBACK* get)(struct _cef_v8accessor_t* self, + const cef_string_t* name, + struct _cef_v8value_t* object, + struct _cef_v8value_t** retval, + cef_string_t* exception); /// // Handle assignment of the accessor value identified by |name|. |object| is @@ -205,11 +214,83 @@ typedef struct _cef_v8accessor_t { // exception that will be thrown. Return true (1) if accessor assignment was // handled. /// - int (CEF_CALLBACK *set)(struct _cef_v8accessor_t* self, - const cef_string_t* name, struct _cef_v8value_t* object, - struct _cef_v8value_t* value, cef_string_t* exception); + int(CEF_CALLBACK* set)(struct _cef_v8accessor_t* self, + const cef_string_t* name, + struct _cef_v8value_t* object, + struct _cef_v8value_t* value, + cef_string_t* exception); } cef_v8accessor_t; +/// +// Structure that should be implemented to handle V8 interceptor calls. The +// functions of this structure will be called on the thread associated with the +// V8 interceptor. Interceptor's named property handlers (with first argument of +// type CefString) are called when object is indexed by string. Indexed property +// handlers (with first argument of type int) are called when object is indexed +// by integer. +/// +typedef struct _cef_v8interceptor_t { + /// + // Base structure. + /// + cef_base_ref_counted_t base; + + /// + // Handle retrieval of the interceptor value identified by |name|. |object| is + // the receiver ('this' object) of the interceptor. If retrieval succeeds, set + // |retval| to the return value. If the requested value does not exist, don't + // set either |retval| or |exception|. If retrieval fails, set |exception| to + // the exception that will be thrown. If the property has an associated + // accessor, it will be called only if you don't set |retval|. Return true (1) + // if interceptor retrieval was handled, false (0) otherwise. + /// + int(CEF_CALLBACK* get_byname)(struct _cef_v8interceptor_t* self, + const cef_string_t* name, + struct _cef_v8value_t* object, + struct _cef_v8value_t** retval, + cef_string_t* exception); + + /// + // Handle retrieval of the interceptor value identified by |index|. |object| + // is the receiver ('this' object) of the interceptor. If retrieval succeeds, + // set |retval| to the return value. If the requested value does not exist, + // don't set either |retval| or |exception|. If retrieval fails, set + // |exception| to the exception that will be thrown. Return true (1) if + // interceptor retrieval was handled, false (0) otherwise. + /// + int(CEF_CALLBACK* get_byindex)(struct _cef_v8interceptor_t* self, + int index, + struct _cef_v8value_t* object, + struct _cef_v8value_t** retval, + cef_string_t* exception); + + /// + // Handle assignment of the interceptor value identified by |name|. |object| + // is the receiver ('this' object) of the interceptor. |value| is the new + // value being assigned to the interceptor. If assignment fails, set + // |exception| to the exception that will be thrown. This setter will always + // be called, even when the property has an associated accessor. Return true + // (1) if interceptor assignment was handled, false (0) otherwise. + /// + int(CEF_CALLBACK* set_byname)(struct _cef_v8interceptor_t* self, + const cef_string_t* name, + struct _cef_v8value_t* object, + struct _cef_v8value_t* value, + cef_string_t* exception); + + /// + // Handle assignment of the interceptor value identified by |index|. |object| + // is the receiver ('this' object) of the interceptor. |value| is the new + // value being assigned to the interceptor. If assignment fails, set + // |exception| to the exception that will be thrown. Return true (1) if + // interceptor assignment was handled, false (0) otherwise. + /// + int(CEF_CALLBACK* set_byindex)(struct _cef_v8interceptor_t* self, + int index, + struct _cef_v8value_t* object, + struct _cef_v8value_t* value, + cef_string_t* exception); +} cef_v8interceptor_t; /// // Structure representing a V8 exception. The functions of this structure may be @@ -219,20 +300,20 @@ typedef struct _cef_v8exception_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Returns the exception message. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_message)( + cef_string_userfree_t(CEF_CALLBACK* get_message)( struct _cef_v8exception_t* self); /// // Returns the line of source code that the exception occurred within. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_source_line)( + cef_string_userfree_t(CEF_CALLBACK* get_source_line)( struct _cef_v8exception_t* self); /// @@ -240,41 +321,40 @@ typedef struct _cef_v8exception_t { // the error originates. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_script_resource_name)( + cef_string_userfree_t(CEF_CALLBACK* get_script_resource_name)( struct _cef_v8exception_t* self); /// // Returns the 1-based number of the line where the error occurred or 0 if the // line number is unknown. /// - int (CEF_CALLBACK *get_line_number)(struct _cef_v8exception_t* self); + int(CEF_CALLBACK* get_line_number)(struct _cef_v8exception_t* self); /// // Returns the index within the script of the first character where the error // occurred. /// - int (CEF_CALLBACK *get_start_position)(struct _cef_v8exception_t* self); + int(CEF_CALLBACK* get_start_position)(struct _cef_v8exception_t* self); /// // Returns the index within the script of the last character where the error // occurred. /// - int (CEF_CALLBACK *get_end_position)(struct _cef_v8exception_t* self); + int(CEF_CALLBACK* get_end_position)(struct _cef_v8exception_t* self); /// // Returns the index within the line of the first character where the error // occurred. /// - int (CEF_CALLBACK *get_start_column)(struct _cef_v8exception_t* self); + int(CEF_CALLBACK* get_start_column)(struct _cef_v8exception_t* self); /// // Returns the index within the line of the last character where the error // occurred. /// - int (CEF_CALLBACK *get_end_column)(struct _cef_v8exception_t* self); + int(CEF_CALLBACK* get_end_column)(struct _cef_v8exception_t* self); } cef_v8exception_t; - /// // Structure representing a V8 value handle. V8 handles can only be accessed // from the thread on which they are created. Valid threads for creating a V8 @@ -286,116 +366,109 @@ typedef struct _cef_v8value_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Returns true (1) if the underlying handle is valid and it can be accessed // on the current thread. Do not call any other functions if this function // returns false (0). /// - int (CEF_CALLBACK *is_valid)(struct _cef_v8value_t* self); + int(CEF_CALLBACK* is_valid)(struct _cef_v8value_t* self); /// // True if the value type is undefined. /// - int (CEF_CALLBACK *is_undefined)(struct _cef_v8value_t* self); + int(CEF_CALLBACK* is_undefined)(struct _cef_v8value_t* self); /// // True if the value type is null. /// - int (CEF_CALLBACK *is_null)(struct _cef_v8value_t* self); + int(CEF_CALLBACK* is_null)(struct _cef_v8value_t* self); /// // True if the value type is bool. /// - int (CEF_CALLBACK *is_bool)(struct _cef_v8value_t* self); + int(CEF_CALLBACK* is_bool)(struct _cef_v8value_t* self); /// // True if the value type is int. /// - int (CEF_CALLBACK *is_int)(struct _cef_v8value_t* self); + int(CEF_CALLBACK* is_int)(struct _cef_v8value_t* self); /// // True if the value type is unsigned int. /// - int (CEF_CALLBACK *is_uint)(struct _cef_v8value_t* self); + int(CEF_CALLBACK* is_uint)(struct _cef_v8value_t* self); /// // True if the value type is double. /// - int (CEF_CALLBACK *is_double)(struct _cef_v8value_t* self); + int(CEF_CALLBACK* is_double)(struct _cef_v8value_t* self); /// // True if the value type is Date. /// - int (CEF_CALLBACK *is_date)(struct _cef_v8value_t* self); + int(CEF_CALLBACK* is_date)(struct _cef_v8value_t* self); /// // True if the value type is string. /// - int (CEF_CALLBACK *is_string)(struct _cef_v8value_t* self); + int(CEF_CALLBACK* is_string)(struct _cef_v8value_t* self); /// // True if the value type is object. /// - int (CEF_CALLBACK *is_object)(struct _cef_v8value_t* self); + int(CEF_CALLBACK* is_object)(struct _cef_v8value_t* self); /// // True if the value type is array. /// - int (CEF_CALLBACK *is_array)(struct _cef_v8value_t* self); + int(CEF_CALLBACK* is_array)(struct _cef_v8value_t* self); /// // True if the value type is function. /// - int (CEF_CALLBACK *is_function)(struct _cef_v8value_t* self); + int(CEF_CALLBACK* is_function)(struct _cef_v8value_t* self); /// // Returns true (1) if this object is pointing to the same handle as |that| // object. /// - int (CEF_CALLBACK *is_same)(struct _cef_v8value_t* self, - struct _cef_v8value_t* that); + int(CEF_CALLBACK* is_same)(struct _cef_v8value_t* self, + struct _cef_v8value_t* that); /// - // Return a bool value. The underlying data will be converted to if - // necessary. + // Return a bool value. /// - int (CEF_CALLBACK *get_bool_value)(struct _cef_v8value_t* self); + int(CEF_CALLBACK* get_bool_value)(struct _cef_v8value_t* self); /// - // Return an int value. The underlying data will be converted to if - // necessary. + // Return an int value. /// - int32 (CEF_CALLBACK *get_int_value)(struct _cef_v8value_t* self); + int32(CEF_CALLBACK* get_int_value)(struct _cef_v8value_t* self); /// - // Return an unisgned int value. The underlying data will be converted to if - // necessary. + // Return an unsigned int value. /// - uint32 (CEF_CALLBACK *get_uint_value)(struct _cef_v8value_t* self); + uint32(CEF_CALLBACK* get_uint_value)(struct _cef_v8value_t* self); /// - // Return a double value. The underlying data will be converted to if - // necessary. + // Return a double value. /// - double (CEF_CALLBACK *get_double_value)(struct _cef_v8value_t* self); + double(CEF_CALLBACK* get_double_value)(struct _cef_v8value_t* self); /// - // Return a Date value. The underlying data will be converted to if - // necessary. + // Return a Date value. /// - cef_time_t (CEF_CALLBACK *get_date_value)(struct _cef_v8value_t* self); + cef_time_t(CEF_CALLBACK* get_date_value)(struct _cef_v8value_t* self); /// - // Return a string value. The underlying data will be converted to if - // necessary. + // Return a string value. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_string_value)( + cef_string_userfree_t(CEF_CALLBACK* get_string_value)( struct _cef_v8value_t* self); - // OBJECT METHODS - These functions are only available on objects. Arrays and // functions are also objects. String- and integer-based keys can be used // interchangably with the framework converting between them as necessary. @@ -403,31 +476,31 @@ typedef struct _cef_v8value_t { /// // Returns true (1) if this is a user created object. /// - int (CEF_CALLBACK *is_user_created)(struct _cef_v8value_t* self); + int(CEF_CALLBACK* is_user_created)(struct _cef_v8value_t* self); /// // Returns true (1) if the last function call resulted in an exception. This // attribute exists only in the scope of the current CEF value object. /// - int (CEF_CALLBACK *has_exception)(struct _cef_v8value_t* self); + int(CEF_CALLBACK* has_exception)(struct _cef_v8value_t* self); /// // Returns the exception resulting from the last function call. This attribute // exists only in the scope of the current CEF value object. /// - struct _cef_v8exception_t* (CEF_CALLBACK *get_exception)( + struct _cef_v8exception_t*(CEF_CALLBACK* get_exception)( struct _cef_v8value_t* self); /// // Clears the last exception and returns true (1) on success. /// - int (CEF_CALLBACK *clear_exception)(struct _cef_v8value_t* self); + int(CEF_CALLBACK* clear_exception)(struct _cef_v8value_t* self); /// // Returns true (1) if this object will re-throw future exceptions. This // attribute exists only in the scope of the current CEF value object. /// - int (CEF_CALLBACK *will_rethrow_exceptions)(struct _cef_v8value_t* self); + int(CEF_CALLBACK* will_rethrow_exceptions)(struct _cef_v8value_t* self); /// // Set whether this object will re-throw future exceptions. By default @@ -436,19 +509,19 @@ typedef struct _cef_v8value_t { // caught and not re-thrown. Returns true (1) on success. This attribute // exists only in the scope of the current CEF value object. /// - int (CEF_CALLBACK *set_rethrow_exceptions)(struct _cef_v8value_t* self, - int rethrow); + int(CEF_CALLBACK* set_rethrow_exceptions)(struct _cef_v8value_t* self, + int rethrow); /// // Returns true (1) if the object has a value with the specified identifier. /// - int (CEF_CALLBACK *has_value_bykey)(struct _cef_v8value_t* self, - const cef_string_t* key); + int(CEF_CALLBACK* has_value_bykey)(struct _cef_v8value_t* self, + const cef_string_t* key); /// // Returns true (1) if the object has a value with the specified identifier. /// - int (CEF_CALLBACK *has_value_byindex)(struct _cef_v8value_t* self, int index); + int(CEF_CALLBACK* has_value_byindex)(struct _cef_v8value_t* self, int index); /// // Deletes the value with the specified identifier and returns true (1) on @@ -456,8 +529,8 @@ typedef struct _cef_v8value_t { // exception is thrown. For read-only and don't-delete values this function // will return true (1) even though deletion failed. /// - int (CEF_CALLBACK *delete_value_bykey)(struct _cef_v8value_t* self, - const cef_string_t* key); + int(CEF_CALLBACK* delete_value_bykey)(struct _cef_v8value_t* self, + const cef_string_t* key); /// // Deletes the value with the specified identifier and returns true (1) on @@ -465,22 +538,23 @@ typedef struct _cef_v8value_t { // fails or an exception is thrown. For read-only and don't-delete values this // function will return true (1) even though deletion failed. /// - int (CEF_CALLBACK *delete_value_byindex)(struct _cef_v8value_t* self, - int index); + int(CEF_CALLBACK* delete_value_byindex)(struct _cef_v8value_t* self, + int index); /// // Returns the value with the specified identifier on success. Returns NULL if // this function is called incorrectly or an exception is thrown. /// - struct _cef_v8value_t* (CEF_CALLBACK *get_value_bykey)( - struct _cef_v8value_t* self, const cef_string_t* key); + struct _cef_v8value_t*(CEF_CALLBACK* get_value_bykey)( + struct _cef_v8value_t* self, + const cef_string_t* key); /// // Returns the value with the specified identifier on success. Returns NULL if // this function is called incorrectly or an exception is thrown. /// - struct _cef_v8value_t* (CEF_CALLBACK *get_value_byindex)( - struct _cef_v8value_t* self, int index); + struct _cef_v8value_t*( + CEF_CALLBACK* get_value_byindex)(struct _cef_v8value_t* self, int index); /// // Associates a value with the specified identifier and returns true (1) on @@ -488,9 +562,10 @@ typedef struct _cef_v8value_t { // exception is thrown. For read-only values this function will return true // (1) even though assignment failed. /// - int (CEF_CALLBACK *set_value_bykey)(struct _cef_v8value_t* self, - const cef_string_t* key, struct _cef_v8value_t* value, - cef_v8_propertyattribute_t attribute); + int(CEF_CALLBACK* set_value_bykey)(struct _cef_v8value_t* self, + const cef_string_t* key, + struct _cef_v8value_t* value, + cef_v8_propertyattribute_t attribute); /// // Associates a value with the specified identifier and returns true (1) on @@ -498,8 +573,9 @@ typedef struct _cef_v8value_t { // exception is thrown. For read-only values this function will return true // (1) even though assignment failed. /// - int (CEF_CALLBACK *set_value_byindex)(struct _cef_v8value_t* self, int index, - struct _cef_v8value_t* value); + int(CEF_CALLBACK* set_value_byindex)(struct _cef_v8value_t* self, + int index, + struct _cef_v8value_t* value); /// // Registers an identifier and returns true (1) on success. Access to the @@ -508,36 +584,37 @@ typedef struct _cef_v8value_t { // function is called incorrectly or an exception is thrown. For read-only // values this function will return true (1) even though assignment failed. /// - int (CEF_CALLBACK *set_value_byaccessor)(struct _cef_v8value_t* self, - const cef_string_t* key, cef_v8_accesscontrol_t settings, - cef_v8_propertyattribute_t attribute); + int(CEF_CALLBACK* set_value_byaccessor)(struct _cef_v8value_t* self, + const cef_string_t* key, + cef_v8_accesscontrol_t settings, + cef_v8_propertyattribute_t attribute); /// // Read the keys for the object's values into the specified vector. Integer- // based keys will also be returned as strings. /// - int (CEF_CALLBACK *get_keys)(struct _cef_v8value_t* self, - cef_string_list_t keys); + int(CEF_CALLBACK* get_keys)(struct _cef_v8value_t* self, + cef_string_list_t keys); /// // Sets the user data for this object and returns true (1) on success. Returns // false (0) if this function is called incorrectly. This function can only be // called on user created objects. /// - int (CEF_CALLBACK *set_user_data)(struct _cef_v8value_t* self, - struct _cef_base_t* user_data); + int(CEF_CALLBACK* set_user_data)(struct _cef_v8value_t* self, + struct _cef_base_ref_counted_t* user_data); /// // Returns the user data, if any, assigned to this object. /// - struct _cef_base_t* (CEF_CALLBACK *get_user_data)( + struct _cef_base_ref_counted_t*(CEF_CALLBACK* get_user_data)( struct _cef_v8value_t* self); /// // Returns the amount of externally allocated memory registered for the // object. /// - int (CEF_CALLBACK *get_externally_allocated_memory)( + int(CEF_CALLBACK* get_externally_allocated_memory)( struct _cef_v8value_t* self); /// @@ -551,17 +628,16 @@ typedef struct _cef_v8value_t { // returns the number of bytes associated with the object after the // adjustment. This function can only be called on user created objects. /// - int (CEF_CALLBACK *adjust_externally_allocated_memory)( - struct _cef_v8value_t* self, int change_in_bytes); - + int(CEF_CALLBACK* adjust_externally_allocated_memory)( + struct _cef_v8value_t* self, + int change_in_bytes); // ARRAY METHODS - These functions are only available on arrays. /// // Returns the number of elements in the array. /// - int (CEF_CALLBACK *get_array_length)(struct _cef_v8value_t* self); - + int(CEF_CALLBACK* get_array_length)(struct _cef_v8value_t* self); // FUNCTION METHODS - These functions are only available on functions. @@ -569,13 +645,13 @@ typedef struct _cef_v8value_t { // Returns the function name. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_function_name)( + cef_string_userfree_t(CEF_CALLBACK* get_function_name)( struct _cef_v8value_t* self); /// // Returns the function handler or NULL if not a CEF-created function. /// - struct _cef_v8handler_t* (CEF_CALLBACK *get_function_handler)( + struct _cef_v8handler_t*(CEF_CALLBACK* get_function_handler)( struct _cef_v8value_t* self); /// @@ -589,9 +665,11 @@ typedef struct _cef_v8value_t { // Returns NULL if this function is called incorrectly or an exception is // thrown. /// - struct _cef_v8value_t* (CEF_CALLBACK *execute_function)( - struct _cef_v8value_t* self, struct _cef_v8value_t* object, - size_t argumentsCount, struct _cef_v8value_t* const* arguments); + struct _cef_v8value_t*(CEF_CALLBACK* execute_function)( + struct _cef_v8value_t* self, + struct _cef_v8value_t* object, + size_t argumentsCount, + struct _cef_v8value_t* const* arguments); /// // Execute the function using the specified V8 context. |object| is the @@ -601,13 +679,14 @@ typedef struct _cef_v8value_t { // success. Returns NULL if this function is called incorrectly or an // exception is thrown. /// - struct _cef_v8value_t* (CEF_CALLBACK *execute_function_with_context)( - struct _cef_v8value_t* self, struct _cef_v8context_t* context, - struct _cef_v8value_t* object, size_t argumentsCount, + struct _cef_v8value_t*(CEF_CALLBACK* execute_function_with_context)( + struct _cef_v8value_t* self, + struct _cef_v8context_t* context, + struct _cef_v8value_t* object, + size_t argumentsCount, struct _cef_v8value_t* const* arguments); } cef_v8value_t; - /// // Create a new cef_v8value_t object of type undefined. /// @@ -640,9 +719,9 @@ CEF_EXPORT cef_v8value_t* cef_v8value_create_double(double value); /// // Create a new cef_v8value_t object of type Date. This function should only be -// called from within the scope of a cef_v8context_tHandler, cef_v8handler_t or -// cef_v8accessor_t callback, or in combination with calling enter() and exit() -// on a stored cef_v8context_t reference. +// called from within the scope of a cef_render_process_handler_t, +// cef_v8handler_t or cef_v8accessor_t callback, or in combination with calling +// enter() and exit() on a stored cef_v8context_t reference. /// CEF_EXPORT cef_v8value_t* cef_v8value_create_date(const cef_time_t* date); @@ -652,32 +731,34 @@ CEF_EXPORT cef_v8value_t* cef_v8value_create_date(const cef_time_t* date); CEF_EXPORT cef_v8value_t* cef_v8value_create_string(const cef_string_t* value); /// -// Create a new cef_v8value_t object of type object with optional accessor. This -// function should only be called from within the scope of a -// cef_v8context_tHandler, cef_v8handler_t or cef_v8accessor_t callback, or in -// combination with calling enter() and exit() on a stored cef_v8context_t -// reference. +// Create a new cef_v8value_t object of type object with optional accessor +// and/or interceptor. This function should only be called from within the scope +// of a cef_render_process_handler_t, cef_v8handler_t or cef_v8accessor_t +// callback, or in combination with calling enter() and exit() on a stored +// cef_v8context_t reference. /// -CEF_EXPORT cef_v8value_t* cef_v8value_create_object(cef_v8accessor_t* accessor); +CEF_EXPORT cef_v8value_t* cef_v8value_create_object( + cef_v8accessor_t* accessor, + cef_v8interceptor_t* interceptor); /// // Create a new cef_v8value_t object of type array with the specified |length|. // If |length| is negative the returned array will have length 0. This function -// should only be called from within the scope of a cef_v8context_tHandler, -// cef_v8handler_t or cef_v8accessor_t callback, or in combination with calling -// enter() and exit() on a stored cef_v8context_t reference. +// should only be called from within the scope of a +// cef_render_process_handler_t, cef_v8handler_t or cef_v8accessor_t callback, +// or in combination with calling enter() and exit() on a stored cef_v8context_t +// reference. /// CEF_EXPORT cef_v8value_t* cef_v8value_create_array(int length); /// // Create a new cef_v8value_t object of type function. This function should only -// be called from within the scope of a cef_v8context_tHandler, cef_v8handler_t -// or cef_v8accessor_t callback, or in combination with calling enter() and -// exit() on a stored cef_v8context_t reference. +// be called from within the scope of a cef_render_process_handler_t, +// cef_v8handler_t or cef_v8accessor_t callback, or in combination with calling +// enter() and exit() on a stored cef_v8context_t reference. /// CEF_EXPORT cef_v8value_t* cef_v8value_create_function(const cef_string_t* name, - cef_v8handler_t* handler); - + cef_v8handler_t* handler); /// // Structure representing a V8 stack trace handle. V8 handles can only be @@ -690,35 +771,33 @@ typedef struct _cef_v8stack_trace_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Returns true (1) if the underlying handle is valid and it can be accessed // on the current thread. Do not call any other functions if this function // returns false (0). /// - int (CEF_CALLBACK *is_valid)(struct _cef_v8stack_trace_t* self); + int(CEF_CALLBACK* is_valid)(struct _cef_v8stack_trace_t* self); /// // Returns the number of stack frames. /// - int (CEF_CALLBACK *get_frame_count)(struct _cef_v8stack_trace_t* self); + int(CEF_CALLBACK* get_frame_count)(struct _cef_v8stack_trace_t* self); /// // Returns the stack frame at the specified 0-based index. /// - struct _cef_v8stack_frame_t* (CEF_CALLBACK *get_frame)( - struct _cef_v8stack_trace_t* self, int index); + struct _cef_v8stack_frame_t*( + CEF_CALLBACK* get_frame)(struct _cef_v8stack_trace_t* self, int index); } cef_v8stack_trace_t; - /// // Returns the stack trace for the currently active context. |frame_limit| is // the maximum number of frames that will be captured. /// CEF_EXPORT cef_v8stack_trace_t* cef_v8stack_trace_get_current(int frame_limit); - /// // Structure representing a V8 stack frame handle. V8 handles can only be // accessed from the thread on which they are created. Valid threads for @@ -730,20 +809,20 @@ typedef struct _cef_v8stack_frame_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Returns true (1) if the underlying handle is valid and it can be accessed // on the current thread. Do not call any other functions if this function // returns false (0). /// - int (CEF_CALLBACK *is_valid)(struct _cef_v8stack_frame_t* self); + int(CEF_CALLBACK* is_valid)(struct _cef_v8stack_frame_t* self); /// // Returns the name of the resource script that contains the function. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_script_name)( + cef_string_userfree_t(CEF_CALLBACK* get_script_name)( struct _cef_v8stack_frame_t* self); /// @@ -752,39 +831,38 @@ typedef struct _cef_v8stack_frame_t { // "//@ sourceURL=..." string. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_script_name_or_source_url)( + cef_string_userfree_t(CEF_CALLBACK* get_script_name_or_source_url)( struct _cef_v8stack_frame_t* self); /// // Returns the name of the function. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_function_name)( + cef_string_userfree_t(CEF_CALLBACK* get_function_name)( struct _cef_v8stack_frame_t* self); /// // Returns the 1-based line number for the function call or 0 if unknown. /// - int (CEF_CALLBACK *get_line_number)(struct _cef_v8stack_frame_t* self); + int(CEF_CALLBACK* get_line_number)(struct _cef_v8stack_frame_t* self); /// // Returns the 1-based column offset on the line for the function call or 0 if // unknown. /// - int (CEF_CALLBACK *get_column)(struct _cef_v8stack_frame_t* self); + int(CEF_CALLBACK* get_column)(struct _cef_v8stack_frame_t* self); /// // Returns true (1) if the function was compiled using eval(). /// - int (CEF_CALLBACK *is_eval)(struct _cef_v8stack_frame_t* self); + int(CEF_CALLBACK* is_eval)(struct _cef_v8stack_frame_t* self); /// // Returns true (1) if the function was called as a constructor via "new". /// - int (CEF_CALLBACK *is_constructor)(struct _cef_v8stack_frame_t* self); + int(CEF_CALLBACK* is_constructor)(struct _cef_v8stack_frame_t* self); } cef_v8stack_frame_t; - /// // Register a new V8 extension with the specified JavaScript extension code and // handler. Functions implemented by the handler are prototyped using the @@ -842,7 +920,8 @@ typedef struct _cef_v8stack_frame_t { // /// CEF_EXPORT int cef_register_extension(const cef_string_t* extension_name, - const cef_string_t* javascript_code, cef_v8handler_t* handler); + const cef_string_t* javascript_code, + cef_v8handler_t* handler); #ifdef __cplusplus } diff --git a/include/capi/cef_values_capi.h b/include/capi/cef_values_capi.h index d0dc310..8a22d09 100644 --- a/include/capi/cef_values_capi.h +++ b/include/capi/cef_values_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,20 +33,194 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=4119ecd62e8c308a5876e6a7ac92cf3ff7df6425$ +// #ifndef CEF_INCLUDE_CAPI_CEF_VALUES_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_VALUES_CAPI_H_ #pragma once +#include "include/capi/cef_base_capi.h" + #ifdef __cplusplus extern "C" { #endif -#include "include/capi/cef_base_capi.h" - +struct _cef_binary_value_t; struct _cef_dictionary_value_t; struct _cef_list_value_t; +/// +// Structure that wraps other data value types. Complex types (binary, +// dictionary and list) will be referenced but not owned by this object. Can be +// used on any process and thread. +/// +typedef struct _cef_value_t { + /// + // Base structure. + /// + cef_base_ref_counted_t base; + + /// + // Returns true (1) if the underlying data is valid. This will always be true + // (1) for simple types. For complex types (binary, dictionary and list) the + // underlying data may become invalid if owned by another object (e.g. list or + // dictionary) and that other object is then modified or destroyed. This value + // object can be re-used by calling Set*() even if the underlying data is + // invalid. + /// + int(CEF_CALLBACK* is_valid)(struct _cef_value_t* self); + + /// + // Returns true (1) if the underlying data is owned by another object. + /// + int(CEF_CALLBACK* is_owned)(struct _cef_value_t* self); + + /// + // Returns true (1) if the underlying data is read-only. Some APIs may expose + // read-only objects. + /// + int(CEF_CALLBACK* is_read_only)(struct _cef_value_t* self); + + /// + // Returns true (1) if this object and |that| object have the same underlying + // data. If true (1) modifications to this object will also affect |that| + // object and vice-versa. + /// + int(CEF_CALLBACK* is_same)(struct _cef_value_t* self, + struct _cef_value_t* that); + + /// + // Returns true (1) if this object and |that| object have an equivalent + // underlying value but are not necessarily the same object. + /// + int(CEF_CALLBACK* is_equal)(struct _cef_value_t* self, + struct _cef_value_t* that); + + /// + // Returns a copy of this object. The underlying data will also be copied. + /// + struct _cef_value_t*(CEF_CALLBACK* copy)(struct _cef_value_t* self); + + /// + // Returns the underlying value type. + /// + cef_value_type_t(CEF_CALLBACK* get_type)(struct _cef_value_t* self); + + /// + // Returns the underlying value as type bool. + /// + int(CEF_CALLBACK* get_bool)(struct _cef_value_t* self); + + /// + // Returns the underlying value as type int. + /// + int(CEF_CALLBACK* get_int)(struct _cef_value_t* self); + + /// + // Returns the underlying value as type double. + /// + double(CEF_CALLBACK* get_double)(struct _cef_value_t* self); + + /// + // Returns the underlying value as type string. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t(CEF_CALLBACK* get_string)(struct _cef_value_t* self); + + /// + // Returns the underlying value as type binary. The returned reference may + // become invalid if the value is owned by another object or if ownership is + // transferred to another object in the future. To maintain a reference to the + // value after assigning ownership to a dictionary or list pass this object to + // the set_value() function instead of passing the returned reference to + // set_binary(). + /// + struct _cef_binary_value_t*(CEF_CALLBACK* get_binary)( + struct _cef_value_t* self); + + /// + // Returns the underlying value as type dictionary. The returned reference may + // become invalid if the value is owned by another object or if ownership is + // transferred to another object in the future. To maintain a reference to the + // value after assigning ownership to a dictionary or list pass this object to + // the set_value() function instead of passing the returned reference to + // set_dictionary(). + /// + struct _cef_dictionary_value_t*(CEF_CALLBACK* get_dictionary)( + struct _cef_value_t* self); + + /// + // Returns the underlying value as type list. The returned reference may + // become invalid if the value is owned by another object or if ownership is + // transferred to another object in the future. To maintain a reference to the + // value after assigning ownership to a dictionary or list pass this object to + // the set_value() function instead of passing the returned reference to + // set_list(). + /// + struct _cef_list_value_t*(CEF_CALLBACK* get_list)(struct _cef_value_t* self); + + /// + // Sets the underlying value as type null. Returns true (1) if the value was + // set successfully. + /// + int(CEF_CALLBACK* set_null)(struct _cef_value_t* self); + + /// + // Sets the underlying value as type bool. Returns true (1) if the value was + // set successfully. + /// + int(CEF_CALLBACK* set_bool)(struct _cef_value_t* self, int value); + + /// + // Sets the underlying value as type int. Returns true (1) if the value was + // set successfully. + /// + int(CEF_CALLBACK* set_int)(struct _cef_value_t* self, int value); + + /// + // Sets the underlying value as type double. Returns true (1) if the value was + // set successfully. + /// + int(CEF_CALLBACK* set_double)(struct _cef_value_t* self, double value); + + /// + // Sets the underlying value as type string. Returns true (1) if the value was + // set successfully. + /// + int(CEF_CALLBACK* set_string)(struct _cef_value_t* self, + const cef_string_t* value); + + /// + // Sets the underlying value as type binary. Returns true (1) if the value was + // set successfully. This object keeps a reference to |value| and ownership of + // the underlying data remains unchanged. + /// + int(CEF_CALLBACK* set_binary)(struct _cef_value_t* self, + struct _cef_binary_value_t* value); + + /// + // Sets the underlying value as type dict. Returns true (1) if the value was + // set successfully. This object keeps a reference to |value| and ownership of + // the underlying data remains unchanged. + /// + int(CEF_CALLBACK* set_dictionary)(struct _cef_value_t* self, + struct _cef_dictionary_value_t* value); + + /// + // Sets the underlying value as type list. Returns true (1) if the value was + // set successfully. This object keeps a reference to |value| and ownership of + // the underlying data remains unchanged. + /// + int(CEF_CALLBACK* set_list)(struct _cef_value_t* self, + struct _cef_list_value_t* value); +} cef_value_t; + +/// +// Creates a new object. +/// +CEF_EXPORT cef_value_t* cef_value_create(); + /// // Structure representing a binary value. Can be used on any process and thread. /// @@ -54,46 +228,62 @@ typedef struct _cef_binary_value_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// - // Returns true (1) if this object is valid. Do not call any other functions - // if this function returns false (0). + // Returns true (1) if this object is valid. This object may become invalid if + // the underlying data is owned by another object (e.g. list or dictionary) + // and that other object is then modified or destroyed. Do not call any other + // functions if this function returns false (0). /// - int (CEF_CALLBACK *is_valid)(struct _cef_binary_value_t* self); + int(CEF_CALLBACK* is_valid)(struct _cef_binary_value_t* self); /// // Returns true (1) if this object is currently owned by another object. /// - int (CEF_CALLBACK *is_owned)(struct _cef_binary_value_t* self); + int(CEF_CALLBACK* is_owned)(struct _cef_binary_value_t* self); + + /// + // Returns true (1) if this object and |that| object have the same underlying + // data. + /// + int(CEF_CALLBACK* is_same)(struct _cef_binary_value_t* self, + struct _cef_binary_value_t* that); + + /// + // Returns true (1) if this object and |that| object have an equivalent + // underlying value but are not necessarily the same object. + /// + int(CEF_CALLBACK* is_equal)(struct _cef_binary_value_t* self, + struct _cef_binary_value_t* that); /// // Returns a copy of this object. The data in this object will also be copied. /// - struct _cef_binary_value_t* (CEF_CALLBACK *copy)( + struct _cef_binary_value_t*(CEF_CALLBACK* copy)( struct _cef_binary_value_t* self); /// // Returns the data size. /// - size_t (CEF_CALLBACK *get_size)(struct _cef_binary_value_t* self); + size_t(CEF_CALLBACK* get_size)(struct _cef_binary_value_t* self); /// // Read up to |buffer_size| number of bytes into |buffer|. Reading begins at // the specified byte |data_offset|. Returns the number of bytes read. /// - size_t (CEF_CALLBACK *get_data)(struct _cef_binary_value_t* self, - void* buffer, size_t buffer_size, size_t data_offset); + size_t(CEF_CALLBACK* get_data)(struct _cef_binary_value_t* self, + void* buffer, + size_t buffer_size, + size_t data_offset); } cef_binary_value_t; - /// // Creates a new object that is not owned by any other object. The specified // |data| will be copied. /// CEF_EXPORT cef_binary_value_t* cef_binary_value_create(const void* data, - size_t data_size); - + size_t data_size); /// // Structure representing a dictionary value. Can be used on any process and @@ -103,144 +293,198 @@ typedef struct _cef_dictionary_value_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// - // Returns true (1) if this object is valid. Do not call any other functions - // if this function returns false (0). + // Returns true (1) if this object is valid. This object may become invalid if + // the underlying data is owned by another object (e.g. list or dictionary) + // and that other object is then modified or destroyed. Do not call any other + // functions if this function returns false (0). /// - int (CEF_CALLBACK *is_valid)(struct _cef_dictionary_value_t* self); + int(CEF_CALLBACK* is_valid)(struct _cef_dictionary_value_t* self); /// // Returns true (1) if this object is currently owned by another object. /// - int (CEF_CALLBACK *is_owned)(struct _cef_dictionary_value_t* self); + int(CEF_CALLBACK* is_owned)(struct _cef_dictionary_value_t* self); /// // Returns true (1) if the values of this object are read-only. Some APIs may // expose read-only objects. /// - int (CEF_CALLBACK *is_read_only)(struct _cef_dictionary_value_t* self); + int(CEF_CALLBACK* is_read_only)(struct _cef_dictionary_value_t* self); + + /// + // Returns true (1) if this object and |that| object have the same underlying + // data. If true (1) modifications to this object will also affect |that| + // object and vice-versa. + /// + int(CEF_CALLBACK* is_same)(struct _cef_dictionary_value_t* self, + struct _cef_dictionary_value_t* that); + + /// + // Returns true (1) if this object and |that| object have an equivalent + // underlying value but are not necessarily the same object. + /// + int(CEF_CALLBACK* is_equal)(struct _cef_dictionary_value_t* self, + struct _cef_dictionary_value_t* that); /// // Returns a writable copy of this object. If |exclude_NULL_children| is true // (1) any NULL dictionaries or lists will be excluded from the copy. /// - struct _cef_dictionary_value_t* (CEF_CALLBACK *copy)( - struct _cef_dictionary_value_t* self, int exclude_empty_children); + struct _cef_dictionary_value_t*(CEF_CALLBACK* copy)( + struct _cef_dictionary_value_t* self, + int exclude_empty_children); /// // Returns the number of values. /// - size_t (CEF_CALLBACK *get_size)(struct _cef_dictionary_value_t* self); + size_t(CEF_CALLBACK* get_size)(struct _cef_dictionary_value_t* self); /// // Removes all values. Returns true (1) on success. /// - int (CEF_CALLBACK *clear)(struct _cef_dictionary_value_t* self); + int(CEF_CALLBACK* clear)(struct _cef_dictionary_value_t* self); /// // Returns true (1) if the current dictionary has a value for the given key. /// - int (CEF_CALLBACK *has_key)(struct _cef_dictionary_value_t* self, - const cef_string_t* key); + int(CEF_CALLBACK* has_key)(struct _cef_dictionary_value_t* self, + const cef_string_t* key); /// // Reads all keys for this dictionary into the specified vector. /// - int (CEF_CALLBACK *get_keys)(struct _cef_dictionary_value_t* self, - cef_string_list_t keys); + int(CEF_CALLBACK* get_keys)(struct _cef_dictionary_value_t* self, + cef_string_list_t keys); /// // Removes the value at the specified key. Returns true (1) is the value was // removed successfully. /// - int (CEF_CALLBACK *remove)(struct _cef_dictionary_value_t* self, - const cef_string_t* key); + int(CEF_CALLBACK* remove)(struct _cef_dictionary_value_t* self, + const cef_string_t* key); /// // Returns the value type for the specified key. /// - cef_value_type_t (CEF_CALLBACK *get_type)( - struct _cef_dictionary_value_t* self, const cef_string_t* key); + cef_value_type_t(CEF_CALLBACK* get_type)(struct _cef_dictionary_value_t* self, + const cef_string_t* key); /// - // Returns the value at the specified key as type bool. + // Returns the value at the specified key. For simple types the returned value + // will copy existing data and modifications to the value will not modify this + // object. For complex types (binary, dictionary and list) the returned value + // will reference existing data and modifications to the value will modify + // this object. /// - int (CEF_CALLBACK *get_bool)(struct _cef_dictionary_value_t* self, + struct _cef_value_t*(CEF_CALLBACK* get_value)( + struct _cef_dictionary_value_t* self, const cef_string_t* key); + /// + // Returns the value at the specified key as type bool. + /// + int(CEF_CALLBACK* get_bool)(struct _cef_dictionary_value_t* self, + const cef_string_t* key); + /// // Returns the value at the specified key as type int. /// - int (CEF_CALLBACK *get_int)(struct _cef_dictionary_value_t* self, - const cef_string_t* key); + int(CEF_CALLBACK* get_int)(struct _cef_dictionary_value_t* self, + const cef_string_t* key); /// // Returns the value at the specified key as type double. /// - double (CEF_CALLBACK *get_double)(struct _cef_dictionary_value_t* self, - const cef_string_t* key); + double(CEF_CALLBACK* get_double)(struct _cef_dictionary_value_t* self, + const cef_string_t* key); /// // Returns the value at the specified key as type string. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_string)( - struct _cef_dictionary_value_t* self, const cef_string_t* key); + cef_string_userfree_t(CEF_CALLBACK* get_string)( + struct _cef_dictionary_value_t* self, + const cef_string_t* key); /// - // Returns the value at the specified key as type binary. + // Returns the value at the specified key as type binary. The returned value + // will reference existing data. /// - struct _cef_binary_value_t* (CEF_CALLBACK *get_binary)( - struct _cef_dictionary_value_t* self, const cef_string_t* key); + struct _cef_binary_value_t*(CEF_CALLBACK* get_binary)( + struct _cef_dictionary_value_t* self, + const cef_string_t* key); /// - // Returns the value at the specified key as type dictionary. + // Returns the value at the specified key as type dictionary. The returned + // value will reference existing data and modifications to the value will + // modify this object. /// - struct _cef_dictionary_value_t* (CEF_CALLBACK *get_dictionary)( - struct _cef_dictionary_value_t* self, const cef_string_t* key); + struct _cef_dictionary_value_t*(CEF_CALLBACK* get_dictionary)( + struct _cef_dictionary_value_t* self, + const cef_string_t* key); /// - // Returns the value at the specified key as type list. + // Returns the value at the specified key as type list. The returned value + // will reference existing data and modifications to the value will modify + // this object. /// - struct _cef_list_value_t* (CEF_CALLBACK *get_list)( - struct _cef_dictionary_value_t* self, const cef_string_t* key); + struct _cef_list_value_t*(CEF_CALLBACK* get_list)( + struct _cef_dictionary_value_t* self, + const cef_string_t* key); + + /// + // Sets the value at the specified key. Returns true (1) if the value was set + // successfully. If |value| represents simple data then the underlying data + // will be copied and modifications to |value| will not modify this object. If + // |value| represents complex data (binary, dictionary or list) then the + // underlying data will be referenced and modifications to |value| will modify + // this object. + /// + int(CEF_CALLBACK* set_value)(struct _cef_dictionary_value_t* self, + const cef_string_t* key, + struct _cef_value_t* value); /// // Sets the value at the specified key as type null. Returns true (1) if the // value was set successfully. /// - int (CEF_CALLBACK *set_null)(struct _cef_dictionary_value_t* self, - const cef_string_t* key); + int(CEF_CALLBACK* set_null)(struct _cef_dictionary_value_t* self, + const cef_string_t* key); /// // Sets the value at the specified key as type bool. Returns true (1) if the // value was set successfully. /// - int (CEF_CALLBACK *set_bool)(struct _cef_dictionary_value_t* self, - const cef_string_t* key, int value); + int(CEF_CALLBACK* set_bool)(struct _cef_dictionary_value_t* self, + const cef_string_t* key, + int value); /// // Sets the value at the specified key as type int. Returns true (1) if the // value was set successfully. /// - int (CEF_CALLBACK *set_int)(struct _cef_dictionary_value_t* self, - const cef_string_t* key, int value); + int(CEF_CALLBACK* set_int)(struct _cef_dictionary_value_t* self, + const cef_string_t* key, + int value); /// // Sets the value at the specified key as type double. Returns true (1) if the // value was set successfully. /// - int (CEF_CALLBACK *set_double)(struct _cef_dictionary_value_t* self, - const cef_string_t* key, double value); + int(CEF_CALLBACK* set_double)(struct _cef_dictionary_value_t* self, + const cef_string_t* key, + double value); /// // Sets the value at the specified key as type string. Returns true (1) if the // value was set successfully. /// - int (CEF_CALLBACK *set_string)(struct _cef_dictionary_value_t* self, - const cef_string_t* key, const cef_string_t* value); + int(CEF_CALLBACK* set_string)(struct _cef_dictionary_value_t* self, + const cef_string_t* key, + const cef_string_t* value); /// // Sets the value at the specified key as type binary. Returns true (1) if the @@ -249,39 +493,38 @@ typedef struct _cef_dictionary_value_t { // Otherwise, ownership will be transferred to this object and the |value| // reference will be invalidated. /// - int (CEF_CALLBACK *set_binary)(struct _cef_dictionary_value_t* self, - const cef_string_t* key, struct _cef_binary_value_t* value); + int(CEF_CALLBACK* set_binary)(struct _cef_dictionary_value_t* self, + const cef_string_t* key, + struct _cef_binary_value_t* value); /// // Sets the value at the specified key as type dict. Returns true (1) if the - // value was set successfully. After calling this function the |value| object - // will no longer be valid. If |value| is currently owned by another object + // value was set successfully. If |value| is currently owned by another object // then the value will be copied and the |value| reference will not change. // Otherwise, ownership will be transferred to this object and the |value| // reference will be invalidated. /// - int (CEF_CALLBACK *set_dictionary)(struct _cef_dictionary_value_t* self, - const cef_string_t* key, struct _cef_dictionary_value_t* value); + int(CEF_CALLBACK* set_dictionary)(struct _cef_dictionary_value_t* self, + const cef_string_t* key, + struct _cef_dictionary_value_t* value); /// // Sets the value at the specified key as type list. Returns true (1) if the - // value was set successfully. After calling this function the |value| object - // will no longer be valid. If |value| is currently owned by another object + // value was set successfully. If |value| is currently owned by another object // then the value will be copied and the |value| reference will not change. // Otherwise, ownership will be transferred to this object and the |value| // reference will be invalidated. /// - int (CEF_CALLBACK *set_list)(struct _cef_dictionary_value_t* self, - const cef_string_t* key, struct _cef_list_value_t* value); + int(CEF_CALLBACK* set_list)(struct _cef_dictionary_value_t* self, + const cef_string_t* key, + struct _cef_list_value_t* value); } cef_dictionary_value_t; - /// // Creates a new object that is not owned by any other object. /// CEF_EXPORT cef_dictionary_value_t* cef_dictionary_value_create(); - /// // Structure representing a list value. Can be used on any process and thread. /// @@ -289,173 +532,220 @@ typedef struct _cef_list_value_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// - // Returns true (1) if this object is valid. Do not call any other functions - // if this function returns false (0). + // Returns true (1) if this object is valid. This object may become invalid if + // the underlying data is owned by another object (e.g. list or dictionary) + // and that other object is then modified or destroyed. Do not call any other + // functions if this function returns false (0). /// - int (CEF_CALLBACK *is_valid)(struct _cef_list_value_t* self); + int(CEF_CALLBACK* is_valid)(struct _cef_list_value_t* self); /// // Returns true (1) if this object is currently owned by another object. /// - int (CEF_CALLBACK *is_owned)(struct _cef_list_value_t* self); + int(CEF_CALLBACK* is_owned)(struct _cef_list_value_t* self); /// // Returns true (1) if the values of this object are read-only. Some APIs may // expose read-only objects. /// - int (CEF_CALLBACK *is_read_only)(struct _cef_list_value_t* self); + int(CEF_CALLBACK* is_read_only)(struct _cef_list_value_t* self); + + /// + // Returns true (1) if this object and |that| object have the same underlying + // data. If true (1) modifications to this object will also affect |that| + // object and vice-versa. + /// + int(CEF_CALLBACK* is_same)(struct _cef_list_value_t* self, + struct _cef_list_value_t* that); + + /// + // Returns true (1) if this object and |that| object have an equivalent + // underlying value but are not necessarily the same object. + /// + int(CEF_CALLBACK* is_equal)(struct _cef_list_value_t* self, + struct _cef_list_value_t* that); /// // Returns a writable copy of this object. /// - struct _cef_list_value_t* (CEF_CALLBACK *copy)( - struct _cef_list_value_t* self); + struct _cef_list_value_t*(CEF_CALLBACK* copy)(struct _cef_list_value_t* self); /// // Sets the number of values. If the number of values is expanded all new // value slots will default to type null. Returns true (1) on success. /// - int (CEF_CALLBACK *set_size)(struct _cef_list_value_t* self, size_t size); + int(CEF_CALLBACK* set_size)(struct _cef_list_value_t* self, size_t size); /// // Returns the number of values. /// - size_t (CEF_CALLBACK *get_size)(struct _cef_list_value_t* self); + size_t(CEF_CALLBACK* get_size)(struct _cef_list_value_t* self); /// // Removes all values. Returns true (1) on success. /// - int (CEF_CALLBACK *clear)(struct _cef_list_value_t* self); + int(CEF_CALLBACK* clear)(struct _cef_list_value_t* self); /// // Removes the value at the specified index. /// - int (CEF_CALLBACK *remove)(struct _cef_list_value_t* self, int index); + int(CEF_CALLBACK* remove)(struct _cef_list_value_t* self, size_t index); /// // Returns the value type at the specified index. /// - cef_value_type_t (CEF_CALLBACK *get_type)(struct _cef_list_value_t* self, - int index); + cef_value_type_t(CEF_CALLBACK* get_type)(struct _cef_list_value_t* self, + size_t index); + + /// + // Returns the value at the specified index. For simple types the returned + // value will copy existing data and modifications to the value will not + // modify this object. For complex types (binary, dictionary and list) the + // returned value will reference existing data and modifications to the value + // will modify this object. + /// + struct _cef_value_t*(CEF_CALLBACK* get_value)(struct _cef_list_value_t* self, + size_t index); /// // Returns the value at the specified index as type bool. /// - int (CEF_CALLBACK *get_bool)(struct _cef_list_value_t* self, int index); + int(CEF_CALLBACK* get_bool)(struct _cef_list_value_t* self, size_t index); /// // Returns the value at the specified index as type int. /// - int (CEF_CALLBACK *get_int)(struct _cef_list_value_t* self, int index); + int(CEF_CALLBACK* get_int)(struct _cef_list_value_t* self, size_t index); /// // Returns the value at the specified index as type double. /// - double (CEF_CALLBACK *get_double)(struct _cef_list_value_t* self, int index); + double(CEF_CALLBACK* get_double)(struct _cef_list_value_t* self, + size_t index); /// // Returns the value at the specified index as type string. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_string)( - struct _cef_list_value_t* self, int index); + cef_string_userfree_t( + CEF_CALLBACK* get_string)(struct _cef_list_value_t* self, size_t index); + + /// + // Returns the value at the specified index as type binary. The returned value + // will reference existing data. + /// + struct _cef_binary_value_t*( + CEF_CALLBACK* get_binary)(struct _cef_list_value_t* self, size_t index); /// - // Returns the value at the specified index as type binary. + // Returns the value at the specified index as type dictionary. The returned + // value will reference existing data and modifications to the value will + // modify this object. /// - struct _cef_binary_value_t* (CEF_CALLBACK *get_binary)( - struct _cef_list_value_t* self, int index); + struct _cef_dictionary_value_t*(CEF_CALLBACK* get_dictionary)( + struct _cef_list_value_t* self, + size_t index); /// - // Returns the value at the specified index as type dictionary. + // Returns the value at the specified index as type list. The returned value + // will reference existing data and modifications to the value will modify + // this object. /// - struct _cef_dictionary_value_t* (CEF_CALLBACK *get_dictionary)( - struct _cef_list_value_t* self, int index); + struct _cef_list_value_t*( + CEF_CALLBACK* get_list)(struct _cef_list_value_t* self, size_t index); /// - // Returns the value at the specified index as type list. + // Sets the value at the specified index. Returns true (1) if the value was + // set successfully. If |value| represents simple data then the underlying + // data will be copied and modifications to |value| will not modify this + // object. If |value| represents complex data (binary, dictionary or list) + // then the underlying data will be referenced and modifications to |value| + // will modify this object. /// - struct _cef_list_value_t* (CEF_CALLBACK *get_list)( - struct _cef_list_value_t* self, int index); + int(CEF_CALLBACK* set_value)(struct _cef_list_value_t* self, + size_t index, + struct _cef_value_t* value); /// // Sets the value at the specified index as type null. Returns true (1) if the // value was set successfully. /// - int (CEF_CALLBACK *set_null)(struct _cef_list_value_t* self, int index); + int(CEF_CALLBACK* set_null)(struct _cef_list_value_t* self, size_t index); /// // Sets the value at the specified index as type bool. Returns true (1) if the // value was set successfully. /// - int (CEF_CALLBACK *set_bool)(struct _cef_list_value_t* self, int index, - int value); + int(CEF_CALLBACK* set_bool)(struct _cef_list_value_t* self, + size_t index, + int value); /// // Sets the value at the specified index as type int. Returns true (1) if the // value was set successfully. /// - int (CEF_CALLBACK *set_int)(struct _cef_list_value_t* self, int index, - int value); + int(CEF_CALLBACK* set_int)(struct _cef_list_value_t* self, + size_t index, + int value); /// // Sets the value at the specified index as type double. Returns true (1) if // the value was set successfully. /// - int (CEF_CALLBACK *set_double)(struct _cef_list_value_t* self, int index, - double value); + int(CEF_CALLBACK* set_double)(struct _cef_list_value_t* self, + size_t index, + double value); /// // Sets the value at the specified index as type string. Returns true (1) if // the value was set successfully. /// - int (CEF_CALLBACK *set_string)(struct _cef_list_value_t* self, int index, - const cef_string_t* value); + int(CEF_CALLBACK* set_string)(struct _cef_list_value_t* self, + size_t index, + const cef_string_t* value); /// // Sets the value at the specified index as type binary. Returns true (1) if - // the value was set successfully. After calling this function the |value| - // object will no longer be valid. If |value| is currently owned by another + // the value was set successfully. If |value| is currently owned by another // object then the value will be copied and the |value| reference will not // change. Otherwise, ownership will be transferred to this object and the // |value| reference will be invalidated. /// - int (CEF_CALLBACK *set_binary)(struct _cef_list_value_t* self, int index, - struct _cef_binary_value_t* value); + int(CEF_CALLBACK* set_binary)(struct _cef_list_value_t* self, + size_t index, + struct _cef_binary_value_t* value); /// // Sets the value at the specified index as type dict. Returns true (1) if the - // value was set successfully. After calling this function the |value| object - // will no longer be valid. If |value| is currently owned by another object + // value was set successfully. If |value| is currently owned by another object // then the value will be copied and the |value| reference will not change. // Otherwise, ownership will be transferred to this object and the |value| // reference will be invalidated. /// - int (CEF_CALLBACK *set_dictionary)(struct _cef_list_value_t* self, int index, - struct _cef_dictionary_value_t* value); + int(CEF_CALLBACK* set_dictionary)(struct _cef_list_value_t* self, + size_t index, + struct _cef_dictionary_value_t* value); /// // Sets the value at the specified index as type list. Returns true (1) if the - // value was set successfully. After calling this function the |value| object - // will no longer be valid. If |value| is currently owned by another object + // value was set successfully. If |value| is currently owned by another object // then the value will be copied and the |value| reference will not change. // Otherwise, ownership will be transferred to this object and the |value| // reference will be invalidated. /// - int (CEF_CALLBACK *set_list)(struct _cef_list_value_t* self, int index, - struct _cef_list_value_t* value); + int(CEF_CALLBACK* set_list)(struct _cef_list_value_t* self, + size_t index, + struct _cef_list_value_t* value); } cef_list_value_t; - /// // Creates a new object that is not owned by any other object. /// CEF_EXPORT cef_list_value_t* cef_list_value_create(); - #ifdef __cplusplus } #endif diff --git a/include/capi/cef_waitable_event_capi.h b/include/capi/cef_waitable_event_capi.h new file mode 100644 index 0000000..d02733a --- /dev/null +++ b/include/capi/cef_waitable_event_capi.h @@ -0,0 +1,117 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=a8fdbd327fff7769353b0aba47c74cba61333144$ +// + +#ifndef CEF_INCLUDE_CAPI_CEF_WAITABLE_EVENT_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_WAITABLE_EVENT_CAPI_H_ +#pragma once + +#include "include/capi/cef_base_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// WaitableEvent is a thread synchronization tool that allows one thread to wait +// for another thread to finish some work. This is equivalent to using a +// Lock+ConditionVariable to protect a simple boolean value. However, using +// WaitableEvent in conjunction with a Lock to wait for a more complex state +// change (e.g., for an item to be added to a queue) is not recommended. In that +// case consider using a ConditionVariable instead of a WaitableEvent. It is +// safe to create and/or signal a WaitableEvent from any thread. Blocking on a +// WaitableEvent by calling the *wait() functions is not allowed on the browser +// process UI or IO threads. +/// +typedef struct _cef_waitable_event_t { + /// + // Base structure. + /// + cef_base_ref_counted_t base; + + /// + // Put the event in the un-signaled state. + /// + void(CEF_CALLBACK* reset)(struct _cef_waitable_event_t* self); + + /// + // Put the event in the signaled state. This causes any thread blocked on Wait + // to be woken up. + /// + void(CEF_CALLBACK* signal)(struct _cef_waitable_event_t* self); + + /// + // Returns true (1) if the event is in the signaled state, else false (0). If + // the event was created with |automatic_reset| set to true (1) then calling + // this function will also cause a reset. + /// + int(CEF_CALLBACK* is_signaled)(struct _cef_waitable_event_t* self); + + /// + // Wait indefinitely for the event to be signaled. This function will not + // return until after the call to signal() has completed. This function cannot + // be called on the browser process UI or IO threads. + /// + void(CEF_CALLBACK* wait)(struct _cef_waitable_event_t* self); + + /// + // Wait up to |max_ms| milliseconds for the event to be signaled. Returns true + // (1) if the event was signaled. A return value of false (0) does not + // necessarily mean that |max_ms| was exceeded. This function will not return + // until after the call to signal() has completed. This function cannot be + // called on the browser process UI or IO threads. + /// + int(CEF_CALLBACK* timed_wait)(struct _cef_waitable_event_t* self, + int64 max_ms); +} cef_waitable_event_t; + +/// +// Create a new waitable event. If |automatic_reset| is true (1) then the event +// state is automatically reset to un-signaled after a single waiting thread has +// been released; otherwise, the state remains signaled until reset() is called +// manually. If |initially_signaled| is true (1) then the event will start in +// the signaled state. +/// +CEF_EXPORT cef_waitable_event_t* cef_waitable_event_create( + int automatic_reset, + int initially_signaled); + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_WAITABLE_EVENT_CAPI_H_ diff --git a/include/capi/cef_web_plugin_capi.h b/include/capi/cef_web_plugin_capi.h index 953f7ca..12461e6 100644 --- a/include/capi/cef_web_plugin_capi.h +++ b/include/capi/cef_web_plugin_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,18 +33,20 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=95dbecaa1c2b67c99e32d29e7bcd3aff4d126baf$ +// #ifndef CEF_INCLUDE_CAPI_CEF_WEB_PLUGIN_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_WEB_PLUGIN_CAPI_H_ #pragma once +#include "include/capi/cef_base_capi.h" + #ifdef __cplusplus extern "C" { #endif -#include "include/capi/cef_base_capi.h" -#include "include/capi/cef_browser_capi.h" - +struct _cef_browser_t; /// // Information about a specific web plugin. @@ -53,38 +55,37 @@ typedef struct _cef_web_plugin_info_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Returns the plugin name (i.e. Flash). /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_name)( + cef_string_userfree_t(CEF_CALLBACK* get_name)( struct _cef_web_plugin_info_t* self); /// // Returns the plugin file path (DLL/bundle/library). /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_path)( + cef_string_userfree_t(CEF_CALLBACK* get_path)( struct _cef_web_plugin_info_t* self); /// // Returns the version of the plugin (may be OS-specific). /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_version)( + cef_string_userfree_t(CEF_CALLBACK* get_version)( struct _cef_web_plugin_info_t* self); /// // Returns a description of the plugin from the version information. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_description)( + cef_string_userfree_t(CEF_CALLBACK* get_description)( struct _cef_web_plugin_info_t* self); } cef_web_plugin_info_t; - /// // Structure to implement for visiting web plugin information. The functions of // this structure will be called on the browser process UI thread. @@ -93,7 +94,7 @@ typedef struct _cef_web_plugin_info_visitor_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Method that will be called once for each plugin. |count| is the 0-based @@ -101,11 +102,12 @@ typedef struct _cef_web_plugin_info_visitor_t { // Return false (0) to stop visiting plugins. This function may never be // called if no plugins are found. /// - int (CEF_CALLBACK *visit)(struct _cef_web_plugin_info_visitor_t* self, - struct _cef_web_plugin_info_t* info, int count, int total); + int(CEF_CALLBACK* visit)(struct _cef_web_plugin_info_visitor_t* self, + struct _cef_web_plugin_info_t* info, + int count, + int total); } cef_web_plugin_info_visitor_t; - /// // Structure to implement for receiving unstable plugin information. The // functions of this structure will be called on the browser process IO thread. @@ -114,18 +116,41 @@ typedef struct _cef_web_plugin_unstable_callback_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Method that will be called for the requested plugin. |unstable| will be // true (1) if the plugin has reached the crash count threshold of 3 times in // 120 seconds. /// - void (CEF_CALLBACK *is_unstable)( + void(CEF_CALLBACK* is_unstable)( struct _cef_web_plugin_unstable_callback_t* self, - const cef_string_t* path, int unstable); + const cef_string_t* path, + int unstable); } cef_web_plugin_unstable_callback_t; +/// +// Implement this structure to receive notification when CDM registration is +// complete. The functions of this structure will be called on the browser +// process UI thread. +/// +typedef struct _cef_register_cdm_callback_t { + /// + // Base structure. + /// + cef_base_ref_counted_t base; + + /// + // Method that will be called when CDM registration is complete. |result| will + // be CEF_CDM_REGISTRATION_ERROR_NONE if registration completed successfully. + // Otherwise, |result| and |error_message| will contain additional information + // about why registration failed. + /// + void(CEF_CALLBACK* on_cdm_registration_complete)( + struct _cef_register_cdm_callback_t* self, + cef_cdm_registration_error_t result, + const cef_string_t* error_message); +} cef_register_cdm_callback_t; /// // Visit web plugin information. Can be called on any thread in the browser @@ -141,27 +166,6 @@ CEF_EXPORT void cef_visit_web_plugin_info( /// CEF_EXPORT void cef_refresh_web_plugins(); -/// -// Add a plugin path (directory + file). This change may not take affect until -// after cef_refresh_web_plugins() is called. Can be called on any thread in the -// browser process. -/// -CEF_EXPORT void cef_add_web_plugin_path(const cef_string_t* path); - -/// -// Add a plugin directory. This change may not take affect until after -// cef_refresh_web_plugins() is called. Can be called on any thread in the -// browser process. -/// -CEF_EXPORT void cef_add_web_plugin_directory(const cef_string_t* dir); - -/// -// Remove a plugin path (directory + file). This change may not take affect -// until after cef_refresh_web_plugins() is called. Can be called on any thread -// in the browser process. -/// -CEF_EXPORT void cef_remove_web_plugin_path(const cef_string_t* path); - /// // Unregister an internal plugin. This may be undone the next time // cef_refresh_web_plugins() is called. Can be called on any thread in the @@ -169,12 +173,6 @@ CEF_EXPORT void cef_remove_web_plugin_path(const cef_string_t* path); /// CEF_EXPORT void cef_unregister_internal_web_plugin(const cef_string_t* path); -/// -// Force a plugin to shutdown. Can be called on any thread in the browser -// process but will be executed on the IO thread. -/// -CEF_EXPORT void cef_force_web_plugin_shutdown(const cef_string_t* path); - /// // Register a plugin crash. Can be called on any thread in the browser process // but will be executed on the IO thread. @@ -185,9 +183,59 @@ CEF_EXPORT void cef_register_web_plugin_crash(const cef_string_t* path); // Query if a plugin is unstable. Can be called on any thread in the browser // process. /// -CEF_EXPORT void cef_is_web_plugin_unstable(const cef_string_t* path, +CEF_EXPORT void cef_is_web_plugin_unstable( + const cef_string_t* path, cef_web_plugin_unstable_callback_t* callback); +/// +// Register the Widevine CDM plugin. +// +// The client application is responsible for downloading an appropriate +// platform-specific CDM binary distribution from Google, extracting the +// contents, and building the required directory structure on the local machine. +// The cef_browser_host_t::StartDownload function and CefZipArchive structure +// can be used to implement this functionality in CEF. Contact Google via +// https://www.widevine.com/contact.html for details on CDM download. +// +// |path| is a directory that must contain the following files: +// 1. manifest.json file from the CDM binary distribution (see below). +// 2. widevinecdm file from the CDM binary distribution (e.g. +// widevinecdm.dll on on Windows, libwidevinecdm.dylib on OS X, +// libwidevinecdm.so on Linux). +// 3. widevidecdmadapter file from the CEF binary distribution (e.g. +// widevinecdmadapter.dll on Windows, widevinecdmadapter.plugin on OS X, +// libwidevinecdmadapter.so on Linux). +// +// If any of these files are missing or if the manifest file has incorrect +// contents the registration will fail and |callback| will receive a |result| +// value of CEF_CDM_REGISTRATION_ERROR_INCORRECT_CONTENTS. +// +// The manifest.json file must contain the following keys: +// A. "os": Supported OS (e.g. "mac", "win" or "linux"). +// B. "arch": Supported architecture (e.g. "ia32" or "x64"). +// C. "x-cdm-module-versions": Module API version (e.g. "4"). +// D. "x-cdm-interface-versions": Interface API version (e.g. "8"). +// E. "x-cdm-host-versions": Host API version (e.g. "8"). +// F. "version": CDM version (e.g. "1.4.8.903"). +// G. "x-cdm-codecs": List of supported codecs (e.g. "vp8,vp9.0,avc1"). +// +// A through E are used to verify compatibility with the current Chromium +// version. If the CDM is not compatible the registration will fail and +// |callback| will receive a |result| value of +// CEF_CDM_REGISTRATION_ERROR_INCOMPATIBLE. +// +// |callback| will be executed asynchronously once registration is complete. +// +// On Linux this function must be called before cef_initialize() and the +// registration cannot be changed during runtime. If registration is not +// supported at the time that cef_register_widevine_cdm() is called then +// |callback| will receive a |result| value of +// CEF_CDM_REGISTRATION_ERROR_NOT_SUPPORTED. +/// +CEF_EXPORT void cef_register_widevine_cdm( + const cef_string_t* path, + cef_register_cdm_callback_t* callback); + #ifdef __cplusplus } #endif diff --git a/include/capi/cef_x509_certificate_capi.h b/include/capi/cef_x509_certificate_capi.h new file mode 100644 index 0000000..4ea148f --- /dev/null +++ b/include/capi/cef_x509_certificate_capi.h @@ -0,0 +1,213 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=9eccfa7e4ebd9ccd0d3d7e0424a9595053e6febe$ +// + +#ifndef CEF_INCLUDE_CAPI_CEF_X509_CERTIFICATE_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_X509_CERTIFICATE_CAPI_H_ +#pragma once + +#include "include/capi/cef_base_capi.h" +#include "include/capi/cef_values_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// Structure representing the issuer or subject field of an X.509 certificate. +/// +typedef struct _cef_x509cert_principal_t { + /// + // Base structure. + /// + cef_base_ref_counted_t base; + + /// + // Returns a name that can be used to represent the issuer. It tries in this + // order: Common Name (CN), Organization Name (O) and Organizational Unit Name + // (OU) and returns the first non-NULL one found. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t(CEF_CALLBACK* get_display_name)( + struct _cef_x509cert_principal_t* self); + + /// + // Returns the common name. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t(CEF_CALLBACK* get_common_name)( + struct _cef_x509cert_principal_t* self); + + /// + // Returns the locality name. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t(CEF_CALLBACK* get_locality_name)( + struct _cef_x509cert_principal_t* self); + + /// + // Returns the state or province name. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t(CEF_CALLBACK* get_state_or_province_name)( + struct _cef_x509cert_principal_t* self); + + /// + // Returns the country name. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t(CEF_CALLBACK* get_country_name)( + struct _cef_x509cert_principal_t* self); + + /// + // Retrieve the list of street addresses. + /// + void(CEF_CALLBACK* get_street_addresses)( + struct _cef_x509cert_principal_t* self, + cef_string_list_t addresses); + + /// + // Retrieve the list of organization names. + /// + void(CEF_CALLBACK* get_organization_names)( + struct _cef_x509cert_principal_t* self, + cef_string_list_t names); + + /// + // Retrieve the list of organization unit names. + /// + void(CEF_CALLBACK* get_organization_unit_names)( + struct _cef_x509cert_principal_t* self, + cef_string_list_t names); + + /// + // Retrieve the list of domain components. + /// + void(CEF_CALLBACK* get_domain_components)( + struct _cef_x509cert_principal_t* self, + cef_string_list_t components); +} cef_x509cert_principal_t; + +/// +// Structure representing a X.509 certificate. +/// +typedef struct _cef_x509certificate_t { + /// + // Base structure. + /// + cef_base_ref_counted_t base; + + /// + // Returns the subject of the X.509 certificate. For HTTPS server certificates + // this represents the web server. The common name of the subject should + // match the host name of the web server. + /// + struct _cef_x509cert_principal_t*(CEF_CALLBACK* get_subject)( + struct _cef_x509certificate_t* self); + + /// + // Returns the issuer of the X.509 certificate. + /// + struct _cef_x509cert_principal_t*(CEF_CALLBACK* get_issuer)( + struct _cef_x509certificate_t* self); + + /// + // Returns the DER encoded serial number for the X.509 certificate. The value + // possibly includes a leading 00 byte. + /// + struct _cef_binary_value_t*(CEF_CALLBACK* get_serial_number)( + struct _cef_x509certificate_t* self); + + /// + // Returns the date before which the X.509 certificate is invalid. + // CefTime.GetTimeT() will return 0 if no date was specified. + /// + cef_time_t(CEF_CALLBACK* get_valid_start)( + struct _cef_x509certificate_t* self); + + /// + // Returns the date after which the X.509 certificate is invalid. + // CefTime.GetTimeT() will return 0 if no date was specified. + /// + cef_time_t(CEF_CALLBACK* get_valid_expiry)( + struct _cef_x509certificate_t* self); + + /// + // Returns the DER encoded data for the X.509 certificate. + /// + struct _cef_binary_value_t*(CEF_CALLBACK* get_derencoded)( + struct _cef_x509certificate_t* self); + + /// + // Returns the PEM encoded data for the X.509 certificate. + /// + struct _cef_binary_value_t*(CEF_CALLBACK* get_pemencoded)( + struct _cef_x509certificate_t* self); + + /// + // Returns the number of certificates in the issuer chain. If 0, the + // certificate is self-signed. + /// + size_t(CEF_CALLBACK* get_issuer_chain_size)( + struct _cef_x509certificate_t* self); + + /// + // Returns the DER encoded data for the certificate issuer chain. If we failed + // to encode a certificate in the chain it is still present in the array but + // is an NULL string. + /// + void(CEF_CALLBACK* get_derencoded_issuer_chain)( + struct _cef_x509certificate_t* self, + size_t* chainCount, + struct _cef_binary_value_t** chain); + + /// + // Returns the PEM encoded data for the certificate issuer chain. If we failed + // to encode a certificate in the chain it is still present in the array but + // is an NULL string. + /// + void(CEF_CALLBACK* get_pemencoded_issuer_chain)( + struct _cef_x509certificate_t* self, + size_t* chainCount, + struct _cef_binary_value_t** chain); +} cef_x509certificate_t; + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_X509_CERTIFICATE_CAPI_H_ diff --git a/include/capi/cef_xml_reader_capi.h b/include/capi/cef_xml_reader_capi.h index 8c6a814..84071a8 100644 --- a/include/capi/cef_xml_reader_capi.h +++ b/include/capi/cef_xml_reader_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,18 +33,19 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=8356c87c40363434391cc18f509b580860db4404$ +// #ifndef CEF_INCLUDE_CAPI_CEF_XML_READER_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_XML_READER_CAPI_H_ #pragma once -#ifdef __cplusplus -extern "C" { -#endif - #include "include/capi/cef_base_capi.h" #include "include/capi/cef_stream_capi.h" +#ifdef __cplusplus +extern "C" { +#endif /// // Structure that supports the reading of XML data via the libxml streaming API. @@ -55,53 +56,52 @@ typedef struct _cef_xml_reader_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Moves the cursor to the next node in the document. This function must be // called at least once to set the current cursor position. Returns true (1) // if the cursor position was set successfully. /// - int (CEF_CALLBACK *move_to_next_node)(struct _cef_xml_reader_t* self); + int(CEF_CALLBACK* move_to_next_node)(struct _cef_xml_reader_t* self); /// // Close the document. This should be called directly to ensure that cleanup // occurs on the correct thread. /// - int (CEF_CALLBACK *close)(struct _cef_xml_reader_t* self); + int(CEF_CALLBACK* close)(struct _cef_xml_reader_t* self); /// // Returns true (1) if an error has been reported by the XML parser. /// - int (CEF_CALLBACK *has_error)(struct _cef_xml_reader_t* self); + int(CEF_CALLBACK* has_error)(struct _cef_xml_reader_t* self); /// // Returns the error string. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_error)( + cef_string_userfree_t(CEF_CALLBACK* get_error)( struct _cef_xml_reader_t* self); - // The below functions retrieve data for the node at the current cursor // position. /// // Returns the node type. /// - cef_xml_node_type_t (CEF_CALLBACK *get_type)(struct _cef_xml_reader_t* self); + cef_xml_node_type_t(CEF_CALLBACK* get_type)(struct _cef_xml_reader_t* self); /// // Returns the node depth. Depth starts at 0 for the root node. /// - int (CEF_CALLBACK *get_depth)(struct _cef_xml_reader_t* self); + int(CEF_CALLBACK* get_depth)(struct _cef_xml_reader_t* self); /// // Returns the local name. See http://www.w3.org/TR/REC-xml-names/#NT- // LocalPart for additional details. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_local_name)( + cef_string_userfree_t(CEF_CALLBACK* get_local_name)( struct _cef_xml_reader_t* self); /// @@ -109,7 +109,7 @@ typedef struct _cef_xml_reader_t { // additional details. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_prefix)( + cef_string_userfree_t(CEF_CALLBACK* get_prefix)( struct _cef_xml_reader_t* self); /// @@ -117,7 +117,7 @@ typedef struct _cef_xml_reader_t { // http://www.w3.org/TR/REC-xml-names/#ns-qualnames for additional details. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_qualified_name)( + cef_string_userfree_t(CEF_CALLBACK* get_qualified_name)( struct _cef_xml_reader_t* self); /// @@ -125,7 +125,7 @@ typedef struct _cef_xml_reader_t { // http://www.w3.org/TR/REC-xml-names/ for additional details. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_namespace_uri)( + cef_string_userfree_t(CEF_CALLBACK* get_namespace_uri)( struct _cef_xml_reader_t* self); /// @@ -133,7 +133,7 @@ typedef struct _cef_xml_reader_t { // additional details. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_base_uri)( + cef_string_userfree_t(CEF_CALLBACK* get_base_uri)( struct _cef_xml_reader_t* self); /// @@ -141,79 +141,81 @@ typedef struct _cef_xml_reader_t { // http://www.w3.org/TR/REC-xml/#sec-lang-tag for additional details. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_xml_lang)( + cef_string_userfree_t(CEF_CALLBACK* get_xml_lang)( struct _cef_xml_reader_t* self); /// // Returns true (1) if the node represents an NULL element. is considered // NULL but is not. /// - int (CEF_CALLBACK *is_empty_element)(struct _cef_xml_reader_t* self); + int(CEF_CALLBACK* is_empty_element)(struct _cef_xml_reader_t* self); /// // Returns true (1) if the node has a text value. /// - int (CEF_CALLBACK *has_value)(struct _cef_xml_reader_t* self); + int(CEF_CALLBACK* has_value)(struct _cef_xml_reader_t* self); /// // Returns the text value. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_value)( + cef_string_userfree_t(CEF_CALLBACK* get_value)( struct _cef_xml_reader_t* self); /// // Returns true (1) if the node has attributes. /// - int (CEF_CALLBACK *has_attributes)(struct _cef_xml_reader_t* self); + int(CEF_CALLBACK* has_attributes)(struct _cef_xml_reader_t* self); /// // Returns the number of attributes. /// - size_t (CEF_CALLBACK *get_attribute_count)(struct _cef_xml_reader_t* self); + size_t(CEF_CALLBACK* get_attribute_count)(struct _cef_xml_reader_t* self); /// // Returns the value of the attribute at the specified 0-based index. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_attribute_byindex)( - struct _cef_xml_reader_t* self, int index); + cef_string_userfree_t(CEF_CALLBACK* get_attribute_byindex)( + struct _cef_xml_reader_t* self, + int index); /// // Returns the value of the attribute with the specified qualified name. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_attribute_byqname)( - struct _cef_xml_reader_t* self, const cef_string_t* qualifiedName); + cef_string_userfree_t(CEF_CALLBACK* get_attribute_byqname)( + struct _cef_xml_reader_t* self, + const cef_string_t* qualifiedName); /// // Returns the value of the attribute with the specified local name and // namespace URI. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_attribute_bylname)( - struct _cef_xml_reader_t* self, const cef_string_t* localName, + cef_string_userfree_t(CEF_CALLBACK* get_attribute_bylname)( + struct _cef_xml_reader_t* self, + const cef_string_t* localName, const cef_string_t* namespaceURI); /// // Returns an XML representation of the current node's children. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_inner_xml)( + cef_string_userfree_t(CEF_CALLBACK* get_inner_xml)( struct _cef_xml_reader_t* self); /// // Returns an XML representation of the current node including its children. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_outer_xml)( + cef_string_userfree_t(CEF_CALLBACK* get_outer_xml)( struct _cef_xml_reader_t* self); /// // Returns the line number for the current node. /// - int (CEF_CALLBACK *get_line_number)(struct _cef_xml_reader_t* self); - + int(CEF_CALLBACK* get_line_number)(struct _cef_xml_reader_t* self); // Attribute nodes are not traversed by default. The below functions can be // used to move the cursor to an attribute node. move_to_carrying_element() @@ -224,14 +226,15 @@ typedef struct _cef_xml_reader_t { // Moves the cursor to the attribute at the specified 0-based index. Returns // true (1) if the cursor position was set successfully. /// - int (CEF_CALLBACK *move_to_attribute_byindex)(struct _cef_xml_reader_t* self, - int index); + int(CEF_CALLBACK* move_to_attribute_byindex)(struct _cef_xml_reader_t* self, + int index); /// // Moves the cursor to the attribute with the specified qualified name. // Returns true (1) if the cursor position was set successfully. /// - int (CEF_CALLBACK *move_to_attribute_byqname)(struct _cef_xml_reader_t* self, + int(CEF_CALLBACK* move_to_attribute_byqname)( + struct _cef_xml_reader_t* self, const cef_string_t* qualifiedName); /// @@ -239,38 +242,39 @@ typedef struct _cef_xml_reader_t { // namespace URI. Returns true (1) if the cursor position was set // successfully. /// - int (CEF_CALLBACK *move_to_attribute_bylname)(struct _cef_xml_reader_t* self, - const cef_string_t* localName, const cef_string_t* namespaceURI); + int(CEF_CALLBACK* move_to_attribute_bylname)( + struct _cef_xml_reader_t* self, + const cef_string_t* localName, + const cef_string_t* namespaceURI); /// // Moves the cursor to the first attribute in the current element. Returns // true (1) if the cursor position was set successfully. /// - int (CEF_CALLBACK *move_to_first_attribute)(struct _cef_xml_reader_t* self); + int(CEF_CALLBACK* move_to_first_attribute)(struct _cef_xml_reader_t* self); /// // Moves the cursor to the next attribute in the current element. Returns true // (1) if the cursor position was set successfully. /// - int (CEF_CALLBACK *move_to_next_attribute)(struct _cef_xml_reader_t* self); + int(CEF_CALLBACK* move_to_next_attribute)(struct _cef_xml_reader_t* self); /// // Moves the cursor back to the carrying element. Returns true (1) if the // cursor position was set successfully. /// - int (CEF_CALLBACK *move_to_carrying_element)(struct _cef_xml_reader_t* self); + int(CEF_CALLBACK* move_to_carrying_element)(struct _cef_xml_reader_t* self); } cef_xml_reader_t; - /// // Create a new cef_xml_reader_t object. The returned object's functions can // only be called from the thread that created the object. /// CEF_EXPORT cef_xml_reader_t* cef_xml_reader_create( - struct _cef_stream_reader_t* stream, cef_xml_encoding_type_t encodingType, + struct _cef_stream_reader_t* stream, + cef_xml_encoding_type_t encodingType, const cef_string_t* URI); - #ifdef __cplusplus } #endif diff --git a/include/capi/cef_zip_reader_capi.h b/include/capi/cef_zip_reader_capi.h index 02de8cd..743cc59 100644 --- a/include/capi/cef_zip_reader_capi.h +++ b/include/capi/cef_zip_reader_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,18 +33,19 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=fec66a36497e467f3da1d2b86d0ae66b8cf709b7$ +// #ifndef CEF_INCLUDE_CAPI_CEF_ZIP_READER_CAPI_H_ #define CEF_INCLUDE_CAPI_CEF_ZIP_READER_CAPI_H_ #pragma once -#ifdef __cplusplus -extern "C" { -#endif - #include "include/capi/cef_base_capi.h" #include "include/capi/cef_stream_capi.h" +#ifdef __cplusplus +extern "C" { +#endif /// // Structure that supports the reading of zip archives via the zlib unzip API. @@ -55,34 +56,34 @@ typedef struct _cef_zip_reader_t { /// // Base structure. /// - cef_base_t base; + cef_base_ref_counted_t base; /// // Moves the cursor to the first file in the archive. Returns true (1) if the // cursor position was set successfully. /// - int (CEF_CALLBACK *move_to_first_file)(struct _cef_zip_reader_t* self); + int(CEF_CALLBACK* move_to_first_file)(struct _cef_zip_reader_t* self); /// // Moves the cursor to the next file in the archive. Returns true (1) if the // cursor position was set successfully. /// - int (CEF_CALLBACK *move_to_next_file)(struct _cef_zip_reader_t* self); + int(CEF_CALLBACK* move_to_next_file)(struct _cef_zip_reader_t* self); /// // Moves the cursor to the specified file in the archive. If |caseSensitive| // is true (1) then the search will be case sensitive. Returns true (1) if the // cursor position was set successfully. /// - int (CEF_CALLBACK *move_to_file)(struct _cef_zip_reader_t* self, - const cef_string_t* fileName, int caseSensitive); + int(CEF_CALLBACK* move_to_file)(struct _cef_zip_reader_t* self, + const cef_string_t* fileName, + int caseSensitive); /// // Closes the archive. This should be called directly to ensure that cleanup // occurs on the correct thread. /// - int (CEF_CALLBACK *close)(struct _cef_zip_reader_t* self); - + int(CEF_CALLBACK* close)(struct _cef_zip_reader_t* self); // The below functions act on the file at the current cursor position. @@ -90,50 +91,51 @@ typedef struct _cef_zip_reader_t { // Returns the name of the file. /// // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_file_name)( + cef_string_userfree_t(CEF_CALLBACK* get_file_name)( struct _cef_zip_reader_t* self); /// // Returns the uncompressed size of the file. /// - int64 (CEF_CALLBACK *get_file_size)(struct _cef_zip_reader_t* self); + int64(CEF_CALLBACK* get_file_size)(struct _cef_zip_reader_t* self); /// // Returns the last modified timestamp for the file. /// - time_t (CEF_CALLBACK *get_file_last_modified)(struct _cef_zip_reader_t* self); + cef_time_t(CEF_CALLBACK* get_file_last_modified)( + struct _cef_zip_reader_t* self); /// // Opens the file for reading of uncompressed data. A read password may // optionally be specified. /// - int (CEF_CALLBACK *open_file)(struct _cef_zip_reader_t* self, - const cef_string_t* password); + int(CEF_CALLBACK* open_file)(struct _cef_zip_reader_t* self, + const cef_string_t* password); /// // Closes the file. /// - int (CEF_CALLBACK *close_file)(struct _cef_zip_reader_t* self); + int(CEF_CALLBACK* close_file)(struct _cef_zip_reader_t* self); /// // Read uncompressed file contents into the specified buffer. Returns < 0 if // an error occurred, 0 if at the end of file, or the number of bytes read. /// - int (CEF_CALLBACK *read_file)(struct _cef_zip_reader_t* self, void* buffer, - size_t bufferSize); + int(CEF_CALLBACK* read_file)(struct _cef_zip_reader_t* self, + void* buffer, + size_t bufferSize); /// // Returns the current offset in the uncompressed file contents. /// - int64 (CEF_CALLBACK *tell)(struct _cef_zip_reader_t* self); + int64(CEF_CALLBACK* tell)(struct _cef_zip_reader_t* self); /// // Returns true (1) if at end of the file contents. /// - int (CEF_CALLBACK *eof)(struct _cef_zip_reader_t* self); + int(CEF_CALLBACK* eof)(struct _cef_zip_reader_t* self); } cef_zip_reader_t; - /// // Create a new cef_zip_reader_t object. The returned object's functions can // only be called from the thread that created the object. @@ -141,7 +143,6 @@ typedef struct _cef_zip_reader_t { CEF_EXPORT cef_zip_reader_t* cef_zip_reader_create( struct _cef_stream_reader_t* stream); - #ifdef __cplusplus } #endif diff --git a/include/capi/test/cef_translator_test_capi.h b/include/capi/test/cef_translator_test_capi.h new file mode 100644 index 0000000..194245b --- /dev/null +++ b/include/capi/test/cef_translator_test_capi.h @@ -0,0 +1,781 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=ec043910c391a84dda3b85cf01ea11cd44f37c1f$ +// + +#ifndef CEF_INCLUDE_CAPI_TEST_CEF_TRANSLATOR_TEST_CAPI_H_ +#define CEF_INCLUDE_CAPI_TEST_CEF_TRANSLATOR_TEST_CAPI_H_ +#pragma once + +#if !defined(BUILDING_CEF_SHARED) && !defined(WRAPPING_CEF_SHARED) && \ + !defined(UNIT_TEST) +#error This file can be included for unit tests only +#endif + +#include "include/capi/cef_base_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct _cef_translator_test_ref_ptr_client_child_t; +struct _cef_translator_test_ref_ptr_client_t; +struct _cef_translator_test_ref_ptr_library_child_t; +struct _cef_translator_test_ref_ptr_library_t; +struct _cef_translator_test_scoped_client_child_t; +struct _cef_translator_test_scoped_client_t; +struct _cef_translator_test_scoped_library_child_t; +struct _cef_translator_test_scoped_library_t; + +/// +// Structure for testing all of the possible data transfer types. +/// +typedef struct _cef_translator_test_t { + /// + // Base structure. + /// + cef_base_ref_counted_t base; + + // PRIMITIVE VALUES + + /// + // Return a void value. + /// + void(CEF_CALLBACK* get_void)(struct _cef_translator_test_t* self); + + /// + // Return a bool value. + /// + int(CEF_CALLBACK* get_bool)(struct _cef_translator_test_t* self); + + /// + // Return an int value. + /// + int(CEF_CALLBACK* get_int)(struct _cef_translator_test_t* self); + + /// + // Return a double value. + /// + double(CEF_CALLBACK* get_double)(struct _cef_translator_test_t* self); + + /// + // Return a long value. + /// + long(CEF_CALLBACK* get_long)(struct _cef_translator_test_t* self); + + /// + // Return a size_t value. + /// + size_t(CEF_CALLBACK* get_sizet)(struct _cef_translator_test_t* self); + + /// + // Set a void value. + /// + int(CEF_CALLBACK* set_void)(struct _cef_translator_test_t* self); + + /// + // Set a bool value. + /// + int(CEF_CALLBACK* set_bool)(struct _cef_translator_test_t* self, int val); + + /// + // Set an int value. + /// + int(CEF_CALLBACK* set_int)(struct _cef_translator_test_t* self, int val); + + /// + // Set a double value. + /// + int(CEF_CALLBACK* set_double)(struct _cef_translator_test_t* self, + double val); + + /// + // Set a long value. + /// + int(CEF_CALLBACK* set_long)(struct _cef_translator_test_t* self, long val); + + /// + // Set a size_t value. + /// + int(CEF_CALLBACK* set_sizet)(struct _cef_translator_test_t* self, size_t val); + + /// + // Set a int list value. + /// + int(CEF_CALLBACK* set_int_list)(struct _cef_translator_test_t* self, + size_t valCount, + int const* val); + + /// + // Return an int list value by out-param. + /// + int(CEF_CALLBACK* get_int_list_by_ref)(struct _cef_translator_test_t* self, + size_t* valCount, + int* val); + + /// + // Return the number of points that will be output above. + /// + size_t(CEF_CALLBACK* get_int_list_size)(struct _cef_translator_test_t* self); + + // STRING VALUES + + /// + // Return a string value. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t(CEF_CALLBACK* get_string)( + struct _cef_translator_test_t* self); + + /// + // Set a string value. + /// + int(CEF_CALLBACK* set_string)(struct _cef_translator_test_t* self, + const cef_string_t* val); + + /// + // Return a string value by out-param. + /// + void(CEF_CALLBACK* get_string_by_ref)(struct _cef_translator_test_t* self, + cef_string_t* val); + + /// + // Set a string list value. + /// + int(CEF_CALLBACK* set_string_list)(struct _cef_translator_test_t* self, + cef_string_list_t val); + + /// + // Return a string list value by out-param. + /// + int(CEF_CALLBACK* get_string_list_by_ref)(struct _cef_translator_test_t* self, + cef_string_list_t val); + + /// + // Set a string map value. + /// + int(CEF_CALLBACK* set_string_map)(struct _cef_translator_test_t* self, + cef_string_map_t val); + + /// + // Return a string map value by out-param. + /// + int(CEF_CALLBACK* get_string_map_by_ref)(struct _cef_translator_test_t* self, + cef_string_map_t val); + + /// + // Set a string multimap value. + /// + int(CEF_CALLBACK* set_string_multimap)(struct _cef_translator_test_t* self, + cef_string_multimap_t val); + + /// + // Return a string multimap value by out-param. + /// + int(CEF_CALLBACK* get_string_multimap_by_ref)( + struct _cef_translator_test_t* self, + cef_string_multimap_t val); + + // STRUCT VALUES + + /// + // Return a point value. + /// + cef_point_t(CEF_CALLBACK* get_point)(struct _cef_translator_test_t* self); + + /// + // Set a point value. + /// + int(CEF_CALLBACK* set_point)(struct _cef_translator_test_t* self, + const cef_point_t* val); + + /// + // Return a point value by out-param. + /// + void(CEF_CALLBACK* get_point_by_ref)(struct _cef_translator_test_t* self, + cef_point_t* val); + + /// + // Set a point list vlaue. + /// + int(CEF_CALLBACK* set_point_list)(struct _cef_translator_test_t* self, + size_t valCount, + cef_point_t const* val); + + /// + // Return a point list value by out-param. + /// + int(CEF_CALLBACK* get_point_list_by_ref)(struct _cef_translator_test_t* self, + size_t* valCount, + cef_point_t* val); + + /// + // Return the number of points that will be output above. + /// + size_t(CEF_CALLBACK* get_point_list_size)( + struct _cef_translator_test_t* self); + + // LIBRARY-SIDE REFPTR VALUES + + /// + // Return an new library-side object. + /// + struct _cef_translator_test_ref_ptr_library_t*( + CEF_CALLBACK* get_ref_ptr_library)(struct _cef_translator_test_t* self, + int val); + + /// + // Set an object. Returns the value from + // cef_translator_test_ref_ptr_library_t::get_value(). This tests input and + // execution of a library-side object type. + /// + int(CEF_CALLBACK* set_ref_ptr_library)( + struct _cef_translator_test_t* self, + struct _cef_translator_test_ref_ptr_library_t* val); + + /// + // Set an object. Returns the object passed in. This tests input and output of + // a library-side object type. + /// + struct _cef_translator_test_ref_ptr_library_t*( + CEF_CALLBACK* set_ref_ptr_library_and_return)( + struct _cef_translator_test_t* self, + struct _cef_translator_test_ref_ptr_library_t* val); + + /// + // Set a child object. Returns the value from + // cef_translator_test_ref_ptr_library_t::get_value(). This tests input of a + // library- side child object type and execution as the parent type. + /// + int(CEF_CALLBACK* set_child_ref_ptr_library)( + struct _cef_translator_test_t* self, + struct _cef_translator_test_ref_ptr_library_child_t* val); + + /// + // Set a child object. Returns the object as the parent type. This tests input + // of a library-side child object type and return as the parent type. + /// + struct _cef_translator_test_ref_ptr_library_t*( + CEF_CALLBACK* set_child_ref_ptr_library_and_return_parent)( + struct _cef_translator_test_t* self, + struct _cef_translator_test_ref_ptr_library_child_t* val); + + /// + // Set an object list vlaue. + /// + int(CEF_CALLBACK* set_ref_ptr_library_list)( + struct _cef_translator_test_t* self, + size_t valCount, + struct _cef_translator_test_ref_ptr_library_t* const* val, + int val1, + int val2); + + /// + // Return an object list value by out-param. + /// + int(CEF_CALLBACK* get_ref_ptr_library_list_by_ref)( + struct _cef_translator_test_t* self, + size_t* valCount, + struct _cef_translator_test_ref_ptr_library_t** val, + int val1, + int val2); + + /// + // Return the number of object that will be output above. + /// + size_t(CEF_CALLBACK* get_ref_ptr_library_list_size)( + struct _cef_translator_test_t* self); + + // CLIENT-SIDE REFPTR VALUES + + /// + // Set an object. Returns the value from + // cef_translator_test_ref_ptr_client_t::get_value(). This tests input and + // execution of a client-side object type. + /// + int(CEF_CALLBACK* set_ref_ptr_client)( + struct _cef_translator_test_t* self, + struct _cef_translator_test_ref_ptr_client_t* val); + + /// + // Set an object. Returns the handler passed in. This tests input and output + // of a client-side object type. + /// + struct _cef_translator_test_ref_ptr_client_t*( + CEF_CALLBACK* set_ref_ptr_client_and_return)( + struct _cef_translator_test_t* self, + struct _cef_translator_test_ref_ptr_client_t* val); + + /// + // Set a child object. Returns the value from + // cef_translator_test_ref_ptr_client_t::get_value(). This tests input of a + // client- side child object type and execution as the parent type. + /// + int(CEF_CALLBACK* set_child_ref_ptr_client)( + struct _cef_translator_test_t* self, + struct _cef_translator_test_ref_ptr_client_child_t* val); + + /// + // Set a child object. Returns the object as the parent type. This tests input + // of a client-side child object type and return as the parent type. + /// + struct _cef_translator_test_ref_ptr_client_t*( + CEF_CALLBACK* set_child_ref_ptr_client_and_return_parent)( + struct _cef_translator_test_t* self, + struct _cef_translator_test_ref_ptr_client_child_t* val); + + /// + // Set an object list vlaue. + /// + int(CEF_CALLBACK* set_ref_ptr_client_list)( + struct _cef_translator_test_t* self, + size_t valCount, + struct _cef_translator_test_ref_ptr_client_t* const* val, + int val1, + int val2); + + /// + // Return an object list value by out-param. + /// + int(CEF_CALLBACK* get_ref_ptr_client_list_by_ref)( + struct _cef_translator_test_t* self, + size_t* valCount, + struct _cef_translator_test_ref_ptr_client_t** val, + struct _cef_translator_test_ref_ptr_client_t* val1, + struct _cef_translator_test_ref_ptr_client_t* val2); + + /// + // Return the number of object that will be output above. + /// + size_t(CEF_CALLBACK* get_ref_ptr_client_list_size)( + struct _cef_translator_test_t* self); + + // LIBRARY-SIDE OWNPTR VALUES + + /// + // Return an new library-side object. + /// + struct _cef_translator_test_scoped_library_t*( + CEF_CALLBACK* get_own_ptr_library)(struct _cef_translator_test_t* self, + int val); + + /// + // Set an object. Returns the value from + // cef_translator_test_scoped_library_t::get_value(). This tests input and + // execution of a library-side object type. + /// + int(CEF_CALLBACK* set_own_ptr_library)( + struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_library_t* val); + + /// + // Set an object. Returns the object passed in. This tests input and output of + // a library-side object type. + /// + struct _cef_translator_test_scoped_library_t*( + CEF_CALLBACK* set_own_ptr_library_and_return)( + struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_library_t* val); + + /// + // Set a child object. Returns the value from + // cef_translator_test_scoped_library_t::get_value(). This tests input of a + // library- side child object type and execution as the parent type. + /// + int(CEF_CALLBACK* set_child_own_ptr_library)( + struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_library_child_t* val); + + /// + // Set a child object. Returns the object as the parent type. This tests input + // of a library-side child object type and return as the parent type. + /// + struct _cef_translator_test_scoped_library_t*( + CEF_CALLBACK* set_child_own_ptr_library_and_return_parent)( + struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_library_child_t* val); + + // CLIENT-SIDE OWNPTR VALUES + + /// + // Set an object. Returns the value from + // cef_translator_test_scoped_client_t::get_value(). This tests input and + // execution of a client-side object type. + /// + int(CEF_CALLBACK* set_own_ptr_client)( + struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_client_t* val); + + /// + // Set an object. Returns the handler passed in. This tests input and output + // of a client-side object type. + /// + struct _cef_translator_test_scoped_client_t*( + CEF_CALLBACK* set_own_ptr_client_and_return)( + struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_client_t* val); + + /// + // Set a child object. Returns the value from + // cef_translator_test_scoped_client_t::get_value(). This tests input of a + // client- side child object type and execution as the parent type. + /// + int(CEF_CALLBACK* set_child_own_ptr_client)( + struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_client_child_t* val); + + /// + // Set a child object. Returns the object as the parent type. This tests input + // of a client-side child object type and return as the parent type. + /// + struct _cef_translator_test_scoped_client_t*( + CEF_CALLBACK* set_child_own_ptr_client_and_return_parent)( + struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_client_child_t* val); + + // LIBRARY-SIDE RAWPTR VALUES + + /// + // Set an object. Returns the value from + // cef_translator_test_scoped_library_t::get_value(). This tests input and + // execution of a library-side object type. + /// + int(CEF_CALLBACK* set_raw_ptr_library)( + struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_library_t* val); + + /// + // Set a child object. Returns the value from + // cef_translator_test_scoped_library_t::get_value(). This tests input of a + // library- side child object type and execution as the parent type. + /// + int(CEF_CALLBACK* set_child_raw_ptr_library)( + struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_library_child_t* val); + + /// + // Set an object list vlaue. + /// + int(CEF_CALLBACK* set_raw_ptr_library_list)( + struct _cef_translator_test_t* self, + size_t valCount, + struct _cef_translator_test_scoped_library_t* const* val, + int val1, + int val2); + + // CLIENT-SIDE RAWPTR VALUES + + /// + // Set an object. Returns the value from + // cef_translator_test_scoped_client_t::get_value(). This tests input and + // execution of a client-side object type. + /// + int(CEF_CALLBACK* set_raw_ptr_client)( + struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_client_t* val); + + /// + // Set a child object. Returns the value from + // cef_translator_test_scoped_client_t::get_value(). This tests input of a + // client- side child object type and execution as the parent type. + /// + int(CEF_CALLBACK* set_child_raw_ptr_client)( + struct _cef_translator_test_t* self, + struct _cef_translator_test_scoped_client_child_t* val); + + /// + // Set an object list vlaue. + /// + int(CEF_CALLBACK* set_raw_ptr_client_list)( + struct _cef_translator_test_t* self, + size_t valCount, + struct _cef_translator_test_scoped_client_t* const* val, + int val1, + int val2); +} cef_translator_test_t; + +/// +// Create the test object. +/// +CEF_EXPORT cef_translator_test_t* cef_translator_test_create(); + +/// +// Library-side test object for RefPtr. +/// +typedef struct _cef_translator_test_ref_ptr_library_t { + /// + // Base structure. + /// + cef_base_ref_counted_t base; + + /// + // Return a value. + /// + int(CEF_CALLBACK* get_value)( + struct _cef_translator_test_ref_ptr_library_t* self); + + /// + // Set a value. + /// + void(CEF_CALLBACK* set_value)( + struct _cef_translator_test_ref_ptr_library_t* self, + int value); +} cef_translator_test_ref_ptr_library_t; + +/// +// Create the test object. +/// +CEF_EXPORT cef_translator_test_ref_ptr_library_t* +cef_translator_test_ref_ptr_library_create(int value); + +/// +// Library-side child test object for RefPtr. +/// +typedef struct _cef_translator_test_ref_ptr_library_child_t { + /// + // Base structure. + /// + cef_translator_test_ref_ptr_library_t base; + + /// + // Return a value. + /// + int(CEF_CALLBACK* get_other_value)( + struct _cef_translator_test_ref_ptr_library_child_t* self); + + /// + // Set a value. + /// + void(CEF_CALLBACK* set_other_value)( + struct _cef_translator_test_ref_ptr_library_child_t* self, + int value); +} cef_translator_test_ref_ptr_library_child_t; + +/// +// Create the test object. +/// +CEF_EXPORT cef_translator_test_ref_ptr_library_child_t* +cef_translator_test_ref_ptr_library_child_create(int value, int other_value); + +/// +// Another library-side child test object for RefPtr. +/// +typedef struct _cef_translator_test_ref_ptr_library_child_child_t { + /// + // Base structure. + /// + cef_translator_test_ref_ptr_library_child_t base; + + /// + // Return a value. + /// + int(CEF_CALLBACK* get_other_other_value)( + struct _cef_translator_test_ref_ptr_library_child_child_t* self); + + /// + // Set a value. + /// + void(CEF_CALLBACK* set_other_other_value)( + struct _cef_translator_test_ref_ptr_library_child_child_t* self, + int value); +} cef_translator_test_ref_ptr_library_child_child_t; + +/// +// Create the test object. +/// +CEF_EXPORT cef_translator_test_ref_ptr_library_child_child_t* +cef_translator_test_ref_ptr_library_child_child_create(int value, + int other_value, + int other_other_value); + +/// +// Client-side test object for RefPtr. +/// +typedef struct _cef_translator_test_ref_ptr_client_t { + /// + // Base structure. + /// + cef_base_ref_counted_t base; + + /// + // Return a value. + /// + int(CEF_CALLBACK* get_value)( + struct _cef_translator_test_ref_ptr_client_t* self); +} cef_translator_test_ref_ptr_client_t; + +/// +// Client-side child test object for RefPtr. +/// +typedef struct _cef_translator_test_ref_ptr_client_child_t { + /// + // Base structure. + /// + cef_translator_test_ref_ptr_client_t base; + + /// + // Return a value. + /// + int(CEF_CALLBACK* get_other_value)( + struct _cef_translator_test_ref_ptr_client_child_t* self); +} cef_translator_test_ref_ptr_client_child_t; + +/// +// Library-side test object for OwnPtr/RawPtr. +/// +typedef struct _cef_translator_test_scoped_library_t { + /// + // Base structure. + /// + cef_base_scoped_t base; + + /// + // Return a value. + /// + int(CEF_CALLBACK* get_value)( + struct _cef_translator_test_scoped_library_t* self); + + /// + // Set a value. + /// + void(CEF_CALLBACK* set_value)( + struct _cef_translator_test_scoped_library_t* self, + int value); +} cef_translator_test_scoped_library_t; + +/// +// Create the test object. +/// +CEF_EXPORT cef_translator_test_scoped_library_t* +cef_translator_test_scoped_library_create(int value); + +/// +// Library-side child test object for OwnPtr/RawPtr. +/// +typedef struct _cef_translator_test_scoped_library_child_t { + /// + // Base structure. + /// + cef_translator_test_scoped_library_t base; + + /// + // Return a value. + /// + int(CEF_CALLBACK* get_other_value)( + struct _cef_translator_test_scoped_library_child_t* self); + + /// + // Set a value. + /// + void(CEF_CALLBACK* set_other_value)( + struct _cef_translator_test_scoped_library_child_t* self, + int value); +} cef_translator_test_scoped_library_child_t; + +/// +// Create the test object. +/// +CEF_EXPORT cef_translator_test_scoped_library_child_t* +cef_translator_test_scoped_library_child_create(int value, int other_value); + +/// +// Another library-side child test object for OwnPtr/RawPtr. +/// +typedef struct _cef_translator_test_scoped_library_child_child_t { + /// + // Base structure. + /// + cef_translator_test_scoped_library_child_t base; + + /// + // Return a value. + /// + int(CEF_CALLBACK* get_other_other_value)( + struct _cef_translator_test_scoped_library_child_child_t* self); + + /// + // Set a value. + /// + void(CEF_CALLBACK* set_other_other_value)( + struct _cef_translator_test_scoped_library_child_child_t* self, + int value); +} cef_translator_test_scoped_library_child_child_t; + +/// +// Create the test object. +/// +CEF_EXPORT cef_translator_test_scoped_library_child_child_t* +cef_translator_test_scoped_library_child_child_create(int value, + int other_value, + int other_other_value); + +/// +// Client-side test object for OwnPtr/RawPtr. +/// +typedef struct _cef_translator_test_scoped_client_t { + /// + // Base structure. + /// + cef_base_scoped_t base; + + /// + // Return a value. + /// + int(CEF_CALLBACK* get_value)( + struct _cef_translator_test_scoped_client_t* self); +} cef_translator_test_scoped_client_t; + +/// +// Client-side child test object for OwnPtr/RawPtr. +/// +typedef struct _cef_translator_test_scoped_client_child_t { + /// + // Base structure. + /// + cef_translator_test_scoped_client_t base; + + /// + // Return a value. + /// + int(CEF_CALLBACK* get_other_value)( + struct _cef_translator_test_scoped_client_child_t* self); +} cef_translator_test_scoped_client_child_t; + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_TEST_CEF_TRANSLATOR_TEST_CAPI_H_ diff --git a/include/capi/views/cef_box_layout_capi.h b/include/capi/views/cef_box_layout_capi.h new file mode 100644 index 0000000..e887764 --- /dev/null +++ b/include/capi/views/cef_box_layout_capi.h @@ -0,0 +1,88 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=acbfe00533fba6a55e9a0d0d0c6a317f54dbf887$ +// + +#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_BOX_LAYOUT_CAPI_H_ +#define CEF_INCLUDE_CAPI_VIEWS_CEF_BOX_LAYOUT_CAPI_H_ +#pragma once + +#include "include/capi/views/cef_layout_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct _cef_view_t; + +/// +// A Layout manager that arranges child views vertically or horizontally in a +// side-by-side fashion with spacing around and between the child views. The +// child views are always sized according to their preferred size. If the host's +// bounds provide insufficient space, child views will be clamped. Excess space +// will not be distributed. Methods must be called on the browser process UI +// thread unless otherwise indicated. +/// +typedef struct _cef_box_layout_t { + /// + // Base structure. + /// + cef_layout_t base; + + /// + // Set the flex weight for the given |view|. 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. + /// + void(CEF_CALLBACK* set_flex_for_view)(struct _cef_box_layout_t* self, + struct _cef_view_t* view, + int flex); + + /// + // Clears the flex for the given |view|, causing it to use the default flex + // specified via cef_box_layout_tSettings.default_flex. + /// + void(CEF_CALLBACK* clear_flex_for_view)(struct _cef_box_layout_t* self, + struct _cef_view_t* view); +} cef_box_layout_t; + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_VIEWS_CEF_BOX_LAYOUT_CAPI_H_ diff --git a/include/capi/views/cef_browser_view_capi.h b/include/capi/views/cef_browser_view_capi.h new file mode 100644 index 0000000..f34fbd9 --- /dev/null +++ b/include/capi/views/cef_browser_view_capi.h @@ -0,0 +1,102 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=0ba6628b63ed6641097a1714d4facf5343cf2252$ +// + +#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_BROWSER_VIEW_CAPI_H_ +#define CEF_INCLUDE_CAPI_VIEWS_CEF_BROWSER_VIEW_CAPI_H_ +#pragma once + +#include "include/capi/cef_browser_capi.h" +#include "include/capi/views/cef_browser_view_delegate_capi.h" +#include "include/capi/views/cef_view_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// A View hosting a cef_browser_t instance. Methods must be called on the +// browser process UI thread unless otherwise indicated. +/// +typedef struct _cef_browser_view_t { + /// + // Base structure. + /// + cef_view_t base; + + /// + // Returns the cef_browser_t hosted by this BrowserView. Will return NULL if + // the browser has not yet been created or has already been destroyed. + /// + struct _cef_browser_t*(CEF_CALLBACK* get_browser)( + struct _cef_browser_view_t* self); + + /// + // Sets whether accelerators registered with cef_window_t::SetAccelerator are + // triggered before or after the event is sent to the cef_browser_t. If + // |prefer_accelerators| is true (1) then the matching accelerator will be + // triggered immediately and the event will not be sent to the cef_browser_t. + // If |prefer_accelerators| is false (0) then the matching accelerator will + // only be triggered if the event is not handled by web content or by + // cef_keyboard_handler_t. The default value is false (0). + /// + void(CEF_CALLBACK* set_prefer_accelerators)(struct _cef_browser_view_t* self, + int prefer_accelerators); +} cef_browser_view_t; + +/// +// Create a new BrowserView. The underlying cef_browser_t will not be created +// until this view is added to the views hierarchy. +/// +CEF_EXPORT cef_browser_view_t* cef_browser_view_create( + struct _cef_client_t* client, + const cef_string_t* url, + const struct _cef_browser_settings_t* settings, + struct _cef_request_context_t* request_context, + struct _cef_browser_view_delegate_t* delegate); + +/// +// Returns the BrowserView associated with |browser|. +/// +CEF_EXPORT cef_browser_view_t* cef_browser_view_get_for_browser( + struct _cef_browser_t* browser); + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_VIEWS_CEF_BROWSER_VIEW_CAPI_H_ diff --git a/include/capi/views/cef_browser_view_delegate_capi.h b/include/capi/views/cef_browser_view_delegate_capi.h new file mode 100644 index 0000000..a6115c2 --- /dev/null +++ b/include/capi/views/cef_browser_view_delegate_capi.h @@ -0,0 +1,121 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=08193b1ef781224bf7664c5bf407af8674ad2362$ +// + +#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_BROWSER_VIEW_DELEGATE_CAPI_H_ +#define CEF_INCLUDE_CAPI_VIEWS_CEF_BROWSER_VIEW_DELEGATE_CAPI_H_ +#pragma once + +#include "include/capi/cef_client_capi.h" +#include "include/capi/views/cef_view_delegate_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct _cef_browser_t; +struct _cef_browser_view_t; + +/// +// Implement this structure to handle BrowserView events. The functions of this +// structure will be called on the browser process UI thread unless otherwise +// indicated. +/// +typedef struct _cef_browser_view_delegate_t { + /// + // Base structure. + /// + cef_view_delegate_t base; + + /// + // Called when |browser| associated with |browser_view| is created. This + // function will be called after cef_life_span_handler_t::on_after_created() + // is called for |browser| and before on_popup_browser_view_created() is + // called for |browser|'s parent delegate if |browser| is a popup. + /// + void(CEF_CALLBACK* on_browser_created)( + struct _cef_browser_view_delegate_t* self, + struct _cef_browser_view_t* browser_view, + struct _cef_browser_t* browser); + + /// + // Called when |browser| associated with |browser_view| is destroyed. Release + // all references to |browser| and do not attempt to execute any functions on + // |browser| after this callback returns. This function will be called before + // cef_life_span_handler_t::on_before_close() is called for |browser|. + /// + void(CEF_CALLBACK* on_browser_destroyed)( + struct _cef_browser_view_delegate_t* self, + struct _cef_browser_view_t* browser_view, + struct _cef_browser_t* browser); + + /// + // Called before a new popup BrowserView is created. The popup originated from + // |browser_view|. |settings| and |client| are the values returned from + // cef_life_span_handler_t::on_before_popup(). |is_devtools| will be true (1) + // if the popup will be a DevTools browser. Return the delegate that will be + // used for the new popup BrowserView. + /// + struct _cef_browser_view_delegate_t*( + CEF_CALLBACK* get_delegate_for_popup_browser_view)( + struct _cef_browser_view_delegate_t* self, + struct _cef_browser_view_t* browser_view, + const struct _cef_browser_settings_t* settings, + struct _cef_client_t* client, + int is_devtools); + + /// + // Called after |popup_browser_view| is created. This function will be called + // after cef_life_span_handler_t::on_after_created() and on_browser_created() + // are called for the new popup browser. The popup originated from + // |browser_view|. |is_devtools| will be true (1) if the popup is a DevTools + // browser. Optionally add |popup_browser_view| to the views hierarchy + // yourself and return true (1). Otherwise return false (0) and a default + // cef_window_t will be created for the popup. + /// + int(CEF_CALLBACK* on_popup_browser_view_created)( + struct _cef_browser_view_delegate_t* self, + struct _cef_browser_view_t* browser_view, + struct _cef_browser_view_t* popup_browser_view, + int is_devtools); +} cef_browser_view_delegate_t; + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_VIEWS_CEF_BROWSER_VIEW_DELEGATE_CAPI_H_ diff --git a/include/capi/views/cef_button_capi.h b/include/capi/views/cef_button_capi.h new file mode 100644 index 0000000..1722086 --- /dev/null +++ b/include/capi/views/cef_button_capi.h @@ -0,0 +1,103 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=f785be05a42d3490ac2e625470befa7d4f77befb$ +// + +#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_BUTTON_CAPI_H_ +#define CEF_INCLUDE_CAPI_VIEWS_CEF_BUTTON_CAPI_H_ +#pragma once + +#include "include/capi/views/cef_view_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct _cef_label_button_t; + +/// +// A View representing a button. Depending on the specific type, the button +// could be implemented by a native control or custom rendered. Methods must be +// called on the browser process UI thread unless otherwise indicated. +/// +typedef struct _cef_button_t { + /// + // Base structure. + /// + cef_view_t base; + + /// + // Returns this Button as a LabelButton or NULL if this is not a LabelButton. + /// + struct _cef_label_button_t*(CEF_CALLBACK* as_label_button)( + struct _cef_button_t* self); + + /// + // Sets the current display state of the Button. + /// + void(CEF_CALLBACK* set_state)(struct _cef_button_t* self, + cef_button_state_t state); + + /// + // Returns the current display state of the Button. + /// + cef_button_state_t(CEF_CALLBACK* get_state)(struct _cef_button_t* self); + + /// + // Sets the Button will use an ink drop effect for displaying state changes. + /// + void(CEF_CALLBACK* set_ink_drop_enabled)(struct _cef_button_t* self, + int enabled); + + /// + // Sets the tooltip text that will be displayed when the user hovers the mouse + // cursor over the Button. + /// + void(CEF_CALLBACK* set_tooltip_text)(struct _cef_button_t* self, + const cef_string_t* tooltip_text); + + /// + // Sets the accessible name that will be exposed to assistive technology (AT). + /// + void(CEF_CALLBACK* set_accessible_name)(struct _cef_button_t* self, + const cef_string_t* name); +} cef_button_t; + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_VIEWS_CEF_BUTTON_CAPI_H_ diff --git a/include/capi/views/cef_button_delegate_capi.h b/include/capi/views/cef_button_delegate_capi.h new file mode 100644 index 0000000..4ebbeb2 --- /dev/null +++ b/include/capi/views/cef_button_delegate_capi.h @@ -0,0 +1,80 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=eb5e428e07fbad33c7da94735969b0ff4dd6fb9f$ +// + +#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_BUTTON_DELEGATE_CAPI_H_ +#define CEF_INCLUDE_CAPI_VIEWS_CEF_BUTTON_DELEGATE_CAPI_H_ +#pragma once + +#include "include/capi/views/cef_view_delegate_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct _cef_button_t; + +/// +// Implement this structure to handle Button events. The functions of this +// structure will be called on the browser process UI thread unless otherwise +// indicated. +/// +typedef struct _cef_button_delegate_t { + /// + // Base structure. + /// + cef_view_delegate_t base; + + /// + // Called when |button| is pressed. + /// + void(CEF_CALLBACK* on_button_pressed)(struct _cef_button_delegate_t* self, + struct _cef_button_t* button); + + /// + // Called when the state of |button| changes. + /// + void(CEF_CALLBACK* on_button_state_changed)( + struct _cef_button_delegate_t* self, + struct _cef_button_t* button); +} cef_button_delegate_t; + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_VIEWS_CEF_BUTTON_DELEGATE_CAPI_H_ diff --git a/include/capi/views/cef_display_capi.h b/include/capi/views/cef_display_capi.h new file mode 100644 index 0000000..be7a05f --- /dev/null +++ b/include/capi/views/cef_display_capi.h @@ -0,0 +1,146 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=20e9f8cdab0325b3d860128a946f3120563fa08e$ +// + +#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_DISPLAY_CAPI_H_ +#define CEF_INCLUDE_CAPI_VIEWS_CEF_DISPLAY_CAPI_H_ +#pragma once + +#include "include/capi/cef_base_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// This structure typically, but not always, corresponds to a physical display +// connected to the system. A fake Display may exist on a headless system, or a +// Display may correspond to a remote, virtual display. All size and position +// values are in density independent pixels (DIP) unless otherwise indicated. +// Methods must be called on the browser process UI thread unless otherwise +// indicated. +/// +typedef struct _cef_display_t { + /// + // Base structure. + /// + cef_base_ref_counted_t base; + + /// + // Returns the unique identifier for this Display. + /// + int64(CEF_CALLBACK* get_id)(struct _cef_display_t* self); + + /// + // Returns this Display's device pixel scale factor. This specifies how much + // the UI should be scaled when the actual output has more pixels than + // standard displays (which is around 100~120dpi). The potential return values + // differ by platform. + /// + float(CEF_CALLBACK* get_device_scale_factor)(struct _cef_display_t* self); + + /// + // Convert |point| from density independent pixels (DIP) to pixel coordinates + // using this Display's device scale factor. + /// + void(CEF_CALLBACK* convert_point_to_pixels)(struct _cef_display_t* self, + cef_point_t* point); + + /// + // Convert |point| from pixel coordinates to density independent pixels (DIP) + // using this Display's device scale factor. + /// + void(CEF_CALLBACK* convert_point_from_pixels)(struct _cef_display_t* self, + cef_point_t* point); + + /// + // Returns this Display's bounds. This is the full size of the display. + /// + cef_rect_t(CEF_CALLBACK* get_bounds)(struct _cef_display_t* self); + + /// + // Returns this Display's work area. This excludes areas of the display that + // are occupied for window manager toolbars, etc. + /// + cef_rect_t(CEF_CALLBACK* get_work_area)(struct _cef_display_t* self); + + /// + // Returns this Display's rotation in degrees. + /// + int(CEF_CALLBACK* get_rotation)(struct _cef_display_t* self); +} cef_display_t; + +/// +// Returns the primary Display. +/// +CEF_EXPORT cef_display_t* cef_display_get_primary(); + +/// +// Returns the Display nearest |point|. Set |input_pixel_coords| to true (1) if +// |point| is in pixel coordinates instead of density independent pixels (DIP). +/// +CEF_EXPORT cef_display_t* cef_display_get_nearest_point( + const cef_point_t* point, + int input_pixel_coords); + +/// +// Returns the Display that most closely intersects |bounds|. Set +// |input_pixel_coords| to true (1) if |bounds| is in pixel coordinates instead +// of density independent pixels (DIP). +/// +CEF_EXPORT cef_display_t* cef_display_get_matching_bounds( + const cef_rect_t* bounds, + int input_pixel_coords); + +/// +// Returns the total number of Displays. Mirrored displays are excluded; this +// function is intended to return the number of distinct, usable displays. +/// +CEF_EXPORT size_t cef_display_get_count(); + +/// +// Returns all Displays. Mirrored displays are excluded; this function is +// intended to return distinct, usable displays. +/// +CEF_EXPORT void cef_display_get_alls(size_t* displaysCount, + cef_display_t** displays); + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_VIEWS_CEF_DISPLAY_CAPI_H_ diff --git a/include/capi/cef_url_capi.h b/include/capi/views/cef_fill_layout_capi.h similarity index 66% rename from include/capi/cef_url_capi.h rename to include/capi/views/cef_fill_layout_capi.h index 3254931..3a29b08 100644 --- a/include/capi/cef_url_capi.h +++ b/include/capi/views/cef_fill_layout_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -33,43 +33,33 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // +// $hash=32d7f76955b00935902e954344c76efe864eabf4$ +// -#ifndef CEF_INCLUDE_CAPI_CEF_URL_CAPI_H_ -#define CEF_INCLUDE_CAPI_CEF_URL_CAPI_H_ +#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_FILL_LAYOUT_CAPI_H_ +#define CEF_INCLUDE_CAPI_VIEWS_CEF_FILL_LAYOUT_CAPI_H_ #pragma once +#include "include/capi/views/cef_layout_capi.h" + #ifdef __cplusplus extern "C" { #endif -#include "include/capi/cef_base_capi.h" - - -/// -// Parse the specified |url| into its component parts. Returns false (0) if the -// URL is NULL or invalid. -/// -CEF_EXPORT int cef_parse_url(const cef_string_t* url, - struct _cef_urlparts_t* parts); - -/// -// Creates a URL from the specified |parts|, which must contain a non-NULL spec -// or a non-NULL host and path (at a minimum), but not both. Returns false (0) -// if |parts| isn't initialized as described. -/// -CEF_EXPORT int cef_create_url(const struct _cef_urlparts_t* parts, - cef_string_t* url); - /// -// Returns the mime type for the specified file extension or an NULL string if -// unknown. +// A simple Layout that causes the associated Panel's one child to be sized to +// match the bounds of its parent. Methods must be called on the browser process +// UI thread unless otherwise indicated. /// -// The resulting string must be freed by calling cef_string_userfree_free(). -CEF_EXPORT cef_string_userfree_t cef_get_mime_type( - const cef_string_t* extension); +typedef struct _cef_fill_layout_t { + /// + // Base structure. + /// + cef_layout_t base; +} cef_fill_layout_t; #ifdef __cplusplus } #endif -#endif // CEF_INCLUDE_CAPI_CEF_URL_CAPI_H_ +#endif // CEF_INCLUDE_CAPI_VIEWS_CEF_FILL_LAYOUT_CAPI_H_ diff --git a/include/capi/views/cef_label_button_capi.h b/include/capi/views/cef_label_button_capi.h new file mode 100644 index 0000000..64310d2 --- /dev/null +++ b/include/capi/views/cef_label_button_capi.h @@ -0,0 +1,166 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=ff20922a0e73fdb84b0cb1864f35911a1a725f8a$ +// + +#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_LABEL_BUTTON_CAPI_H_ +#define CEF_INCLUDE_CAPI_VIEWS_CEF_LABEL_BUTTON_CAPI_H_ +#pragma once + +#include "include/capi/cef_image_capi.h" +#include "include/capi/views/cef_button_capi.h" +#include "include/capi/views/cef_button_delegate_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct _cef_menu_button_t; + +/// +// LabelButton is a button with optional text and/or icon. Methods must be +// called on the browser process UI thread unless otherwise indicated. +/// +typedef struct _cef_label_button_t { + /// + // Base structure. + /// + cef_button_t base; + + /// + // Returns this LabelButton as a MenuButton or NULL if this is not a + // MenuButton. + /// + struct _cef_menu_button_t*(CEF_CALLBACK* as_menu_button)( + struct _cef_label_button_t* self); + + /// + // Sets the text shown on the LabelButton. By default |text| will also be used + // as the accessible name. + /// + void(CEF_CALLBACK* set_text)(struct _cef_label_button_t* self, + const cef_string_t* text); + + /// + // Returns the text shown on the LabelButton. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t(CEF_CALLBACK* get_text)( + struct _cef_label_button_t* self); + + /// + // Sets the image shown for |button_state|. When this Button is drawn if no + // image exists for the current state then the image for + // CEF_BUTTON_STATE_NORMAL, if any, will be shown. + /// + void(CEF_CALLBACK* set_image)(struct _cef_label_button_t* self, + cef_button_state_t button_state, + struct _cef_image_t* image); + + /// + // Returns the image shown for |button_state|. If no image exists for that + // state then the image for CEF_BUTTON_STATE_NORMAL will be returned. + /// + struct _cef_image_t*(CEF_CALLBACK* get_image)( + struct _cef_label_button_t* self, + cef_button_state_t button_state); + + /// + // Sets the text color shown for the specified button |for_state| to |color|. + /// + void(CEF_CALLBACK* set_text_color)(struct _cef_label_button_t* self, + cef_button_state_t for_state, + cef_color_t color); + + /// + // Sets the text colors shown for the non-disabled states to |color|. + /// + void(CEF_CALLBACK* set_enabled_text_colors)(struct _cef_label_button_t* self, + cef_color_t color); + + /// + // Sets the font list. The format is ",[STYLES] ", + // where: - FONT_FAMILY_LIST is a comma-separated list of font family names, - + // STYLES is an optional space-separated list of style names (case-sensitive + // "Bold" and "Italic" are supported), and + // - SIZE is an integer font size in pixels with the suffix "px". + // + // Here are examples of valid font description strings: - "Arial, Helvetica, + // Bold Italic 14px" - "Arial, 14px" + /// + void(CEF_CALLBACK* set_font_list)(struct _cef_label_button_t* self, + const cef_string_t* font_list); + + /// + // Sets the horizontal alignment; reversed in RTL. Default is + // CEF_HORIZONTAL_ALIGNMENT_CENTER. + /// + void(CEF_CALLBACK* set_horizontal_alignment)( + struct _cef_label_button_t* self, + cef_horizontal_alignment_t alignment); + + /// + // Reset the minimum size of this LabelButton to |size|. + /// + void(CEF_CALLBACK* set_minimum_size)(struct _cef_label_button_t* self, + const cef_size_t* size); + + /// + // Reset the maximum size of this LabelButton to |size|. + /// + void(CEF_CALLBACK* set_maximum_size)(struct _cef_label_button_t* self, + const cef_size_t* size); +} cef_label_button_t; + +/// +// Create a new LabelButton. A |delegate| must be provided to handle the button +// click. |text| will be shown on the LabelButton and used as the default +// accessible name. If |with_frame| is true (1) the button will have a visible +// frame at all times, center alignment, additional padding and a default +// minimum size of 70x33 DIP. If |with_frame| is false (0) the button will only +// have a visible frame on hover/press, left alignment, less padding and no +// default minimum size. +/// +CEF_EXPORT cef_label_button_t* cef_label_button_create( + struct _cef_button_delegate_t* delegate, + const cef_string_t* text, + int with_frame); + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_VIEWS_CEF_LABEL_BUTTON_CAPI_H_ diff --git a/include/capi/views/cef_layout_capi.h b/include/capi/views/cef_layout_capi.h new file mode 100644 index 0000000..be870aa --- /dev/null +++ b/include/capi/views/cef_layout_capi.h @@ -0,0 +1,85 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=0fd9d445840558956dbe281f1d5d20ec003684d1$ +// + +#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_LAYOUT_CAPI_H_ +#define CEF_INCLUDE_CAPI_VIEWS_CEF_LAYOUT_CAPI_H_ +#pragma once + +#include "include/capi/cef_base_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct _cef_box_layout_t; +struct _cef_fill_layout_t; + +/// +// A Layout handles the sizing of the children of a Panel according to +// implementation-specific heuristics. Methods must be called on the browser +// process UI thread unless otherwise indicated. +/// +typedef struct _cef_layout_t { + /// + // Base structure. + /// + cef_base_ref_counted_t base; + + /// + // Returns this Layout as a BoxLayout or NULL if this is not a BoxLayout. + /// + struct _cef_box_layout_t*(CEF_CALLBACK* as_box_layout)( + struct _cef_layout_t* self); + + /// + // Returns this Layout as a FillLayout or NULL if this is not a FillLayout. + /// + struct _cef_fill_layout_t*(CEF_CALLBACK* as_fill_layout)( + struct _cef_layout_t* self); + + /// + // Returns true (1) if this Layout is valid. + /// + int(CEF_CALLBACK* is_valid)(struct _cef_layout_t* self); +} cef_layout_t; + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_VIEWS_CEF_LAYOUT_CAPI_H_ diff --git a/include/capi/views/cef_menu_button_capi.h b/include/capi/views/cef_menu_button_capi.h new file mode 100644 index 0000000..c540bc2 --- /dev/null +++ b/include/capi/views/cef_menu_button_capi.h @@ -0,0 +1,101 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=cf3b867dfc26e13b96f2e20fe8b974a38d28119e$ +// + +#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_MENU_BUTTON_CAPI_H_ +#define CEF_INCLUDE_CAPI_VIEWS_CEF_MENU_BUTTON_CAPI_H_ +#pragma once + +#include "include/capi/cef_menu_model_capi.h" +#include "include/capi/views/cef_label_button_capi.h" +#include "include/capi/views/cef_menu_button_delegate_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// MenuButton is a button with optional text, icon and/or menu marker that shows +// a menu when clicked with the left mouse button. All size and position values +// are in density independent pixels (DIP) unless otherwise indicated. Methods +// must be called on the browser process UI thread unless otherwise indicated. +/// +typedef struct _cef_menu_button_t { + /// + // Base structure. + /// + cef_label_button_t base; + + /// + // Show a menu with contents |menu_model|. |screen_point| specifies the menu + // position in screen coordinates. |anchor_position| specifies how the menu + // will be anchored relative to |screen_point|. This function should be called + // from cef_menu_button_delegate_t::on_menu_button_pressed(). + /// + void(CEF_CALLBACK* show_menu)(struct _cef_menu_button_t* self, + struct _cef_menu_model_t* menu_model, + const cef_point_t* screen_point, + cef_menu_anchor_position_t anchor_position); + + /// + // Show the menu for this button. Results in a call to + // cef_menu_button_delegate_t::on_menu_button_pressed(). + /// + void(CEF_CALLBACK* trigger_menu)(struct _cef_menu_button_t* self); +} cef_menu_button_t; + +/// +// Create a new MenuButton. A |delegate| must be provided to call show_menu() +// when the button is clicked. |text| will be shown on the MenuButton and used +// as the default accessible name. If |with_frame| is true (1) the button will +// have a visible frame at all times, center alignment, additional padding and a +// default minimum size of 70x33 DIP. If |with_frame| is false (0) the button +// will only have a visible frame on hover/press, left alignment, less padding +// and no default minimum size. If |with_menu_marker| is true (1) a menu marker +// will be added to the button. +/// +CEF_EXPORT cef_menu_button_t* cef_menu_button_create( + struct _cef_menu_button_delegate_t* delegate, + const cef_string_t* text, + int with_frame, + int with_menu_marker); + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_VIEWS_CEF_MENU_BUTTON_CAPI_H_ diff --git a/include/capi/views/cef_menu_button_delegate_capi.h b/include/capi/views/cef_menu_button_delegate_capi.h new file mode 100644 index 0000000..9ed8232 --- /dev/null +++ b/include/capi/views/cef_menu_button_delegate_capi.h @@ -0,0 +1,76 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=a2b3912f8188f19f3d5109aec1b1d03227e31429$ +// + +#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_MENU_BUTTON_DELEGATE_CAPI_H_ +#define CEF_INCLUDE_CAPI_VIEWS_CEF_MENU_BUTTON_DELEGATE_CAPI_H_ +#pragma once + +#include "include/capi/views/cef_button_delegate_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct _cef_menu_button_t; + +/// +// Implement this structure to handle MenuButton events. The functions of this +// structure will be called on the browser process UI thread unless otherwise +// indicated. +/// +typedef struct _cef_menu_button_delegate_t { + /// + // Base structure. + /// + cef_button_delegate_t base; + + /// + // Called when |button| is pressed. Call cef_menu_button_t::show_menu() to + // show the resulting menu at |screen_point|. + /// + void(CEF_CALLBACK* on_menu_button_pressed)( + struct _cef_menu_button_delegate_t* self, + struct _cef_menu_button_t* menu_button, + const cef_point_t* screen_point); +} cef_menu_button_delegate_t; + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_VIEWS_CEF_MENU_BUTTON_DELEGATE_CAPI_H_ diff --git a/include/capi/views/cef_panel_capi.h b/include/capi/views/cef_panel_capi.h new file mode 100644 index 0000000..e792a59 --- /dev/null +++ b/include/capi/views/cef_panel_capi.h @@ -0,0 +1,151 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=dd5ea19f73dcec3e4f229920f44c9de6599e4f36$ +// + +#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_PANEL_CAPI_H_ +#define CEF_INCLUDE_CAPI_VIEWS_CEF_PANEL_CAPI_H_ +#pragma once + +#include "include/capi/views/cef_panel_delegate_capi.h" +#include "include/capi/views/cef_view_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct _cef_box_layout_t; +struct _cef_fill_layout_t; +struct _cef_layout_t; +struct _cef_window_t; + +/// +// A Panel is a container in the views hierarchy that can contain other Views as +// children. Methods must be called on the browser process UI thread unless +// otherwise indicated. +/// +typedef struct _cef_panel_t { + /// + // Base structure. + /// + cef_view_t base; + + /// + // Returns this Panel as a Window or NULL if this is not a Window. + /// + struct _cef_window_t*(CEF_CALLBACK* as_window)(struct _cef_panel_t* self); + + /// + // Set this Panel's Layout to FillLayout and return the FillLayout object. + /// + struct _cef_fill_layout_t*(CEF_CALLBACK* set_to_fill_layout)( + struct _cef_panel_t* self); + + /// + // Set this Panel's Layout to BoxLayout and return the BoxLayout object. + /// + struct _cef_box_layout_t*(CEF_CALLBACK* set_to_box_layout)( + struct _cef_panel_t* self, + const struct _cef_box_layout_settings_t* settings); + + /// + // Get the Layout. + /// + struct _cef_layout_t*(CEF_CALLBACK* get_layout)(struct _cef_panel_t* self); + + /// + // Lay out the child Views (set their bounds based on sizing heuristics + // specific to the current Layout). + /// + void(CEF_CALLBACK* layout)(struct _cef_panel_t* self); + + /// + // Add a child View. + /// + void(CEF_CALLBACK* add_child_view)(struct _cef_panel_t* self, + struct _cef_view_t* view); + + /// + // Add a child View at the specified |index|. If |index| matches the result of + // GetChildCount() then the View will be added at the end. + /// + void(CEF_CALLBACK* add_child_view_at)(struct _cef_panel_t* self, + struct _cef_view_t* view, + int index); + + /// + // Move the child View to the specified |index|. A negative value for |index| + // will move the View to the end. + /// + void(CEF_CALLBACK* reorder_child_view)(struct _cef_panel_t* self, + struct _cef_view_t* view, + int index); + + /// + // Remove a child View. The View can then be added to another Panel. + /// + void(CEF_CALLBACK* remove_child_view)(struct _cef_panel_t* self, + struct _cef_view_t* view); + + /// + // Remove all child Views. The removed Views will be deleted if the client + // holds no references to them. + /// + void(CEF_CALLBACK* remove_all_child_views)(struct _cef_panel_t* self); + + /// + // Returns the number of child Views. + /// + size_t(CEF_CALLBACK* get_child_view_count)(struct _cef_panel_t* self); + + /// + // Returns the child View at the specified |index|. + /// + struct _cef_view_t*( + CEF_CALLBACK* get_child_view_at)(struct _cef_panel_t* self, int index); +} cef_panel_t; + +/// +// Create a new Panel. +/// +CEF_EXPORT cef_panel_t* cef_panel_create( + struct _cef_panel_delegate_t* delegate); + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_VIEWS_CEF_PANEL_CAPI_H_ diff --git a/include/capi/views/cef_panel_delegate_capi.h b/include/capi/views/cef_panel_delegate_capi.h new file mode 100644 index 0000000..7e68907 --- /dev/null +++ b/include/capi/views/cef_panel_delegate_capi.h @@ -0,0 +1,65 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=c3aac051e19d368c3c7e415fcb160abb83060011$ +// + +#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_PANEL_DELEGATE_CAPI_H_ +#define CEF_INCLUDE_CAPI_VIEWS_CEF_PANEL_DELEGATE_CAPI_H_ +#pragma once + +#include "include/capi/views/cef_view_delegate_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// Implement this structure to handle Panel events. The functions of this +// structure will be called on the browser process UI thread unless otherwise +// indicated. +/// +typedef struct _cef_panel_delegate_t { + /// + // Base structure. + /// + cef_view_delegate_t base; +} cef_panel_delegate_t; + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_VIEWS_CEF_PANEL_DELEGATE_CAPI_H_ diff --git a/include/capi/views/cef_scroll_view_capi.h b/include/capi/views/cef_scroll_view_capi.h new file mode 100644 index 0000000..7e23b09 --- /dev/null +++ b/include/capi/views/cef_scroll_view_capi.h @@ -0,0 +1,112 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=ec6ad7d358194b055c2c2b5bda3d6b9c6429185a$ +// + +#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_SCROLL_VIEW_CAPI_H_ +#define CEF_INCLUDE_CAPI_VIEWS_CEF_SCROLL_VIEW_CAPI_H_ +#pragma once + +#include "include/capi/views/cef_view_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// A ScrollView will show horizontal and/or vertical scrollbars when necessary +// based on the size of the attached content view. Methods must be called on the +// browser process UI thread unless otherwise indicated. +/// +typedef struct _cef_scroll_view_t { + /// + // Base structure. + /// + cef_view_t base; + + /// + // Set the content View. The content View must have a specified size (e.g. via + // cef_view_t::SetBounds or cef_view_tDelegate::GetPreferredSize). + /// + void(CEF_CALLBACK* set_content_view)(struct _cef_scroll_view_t* self, + struct _cef_view_t* view); + + /// + // Returns the content View. + /// + struct _cef_view_t*(CEF_CALLBACK* get_content_view)( + struct _cef_scroll_view_t* self); + + /// + // Returns the visible region of the content View. + /// + cef_rect_t(CEF_CALLBACK* get_visible_content_rect)( + struct _cef_scroll_view_t* self); + + /// + // Returns true (1) if the horizontal scrollbar is currently showing. + /// + int(CEF_CALLBACK* has_horizontal_scrollbar)(struct _cef_scroll_view_t* self); + + /// + // Returns the height of the horizontal scrollbar. + /// + int(CEF_CALLBACK* get_horizontal_scrollbar_height)( + struct _cef_scroll_view_t* self); + + /// + // Returns true (1) if the vertical scrollbar is currently showing. + /// + int(CEF_CALLBACK* has_vertical_scrollbar)(struct _cef_scroll_view_t* self); + + /// + // Returns the width of the vertical scrollbar. + /// + int(CEF_CALLBACK* get_vertical_scrollbar_width)( + struct _cef_scroll_view_t* self); +} cef_scroll_view_t; + +/// +// Create a new ScrollView. +/// +CEF_EXPORT cef_scroll_view_t* cef_scroll_view_create( + struct _cef_view_delegate_t* delegate); + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_VIEWS_CEF_SCROLL_VIEW_CAPI_H_ diff --git a/include/capi/views/cef_textfield_capi.h b/include/capi/views/cef_textfield_capi.h new file mode 100644 index 0000000..e99dd4b --- /dev/null +++ b/include/capi/views/cef_textfield_capi.h @@ -0,0 +1,276 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=0dbd10f061bf4d63be22d050b93f5231fd7fb677$ +// + +#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_TEXTFIELD_CAPI_H_ +#define CEF_INCLUDE_CAPI_VIEWS_CEF_TEXTFIELD_CAPI_H_ +#pragma once + +#include "include/capi/views/cef_textfield_delegate_capi.h" +#include "include/capi/views/cef_view_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// A Textfield supports editing of text. This control is custom rendered with no +// platform-specific code. Methods must be called on the browser process UI +// thread unless otherwise indicated. +/// +typedef struct _cef_textfield_t { + /// + // Base structure. + /// + cef_view_t base; + + /// + // Sets whether the text will be displayed as asterisks. + /// + void(CEF_CALLBACK* set_password_input)(struct _cef_textfield_t* self, + int password_input); + + /// + // Returns true (1) if the text will be displayed as asterisks. + /// + int(CEF_CALLBACK* is_password_input)(struct _cef_textfield_t* self); + + /// + // Sets whether the text will read-only. + /// + void(CEF_CALLBACK* set_read_only)(struct _cef_textfield_t* self, + int read_only); + + /// + // Returns true (1) if the text is read-only. + /// + int(CEF_CALLBACK* is_read_only)(struct _cef_textfield_t* self); + + /// + // Returns the currently displayed text. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t(CEF_CALLBACK* get_text)(struct _cef_textfield_t* self); + + /// + // Sets the contents to |text|. The cursor will be moved to end of the text if + // the current position is outside of the text range. + /// + void(CEF_CALLBACK* set_text)(struct _cef_textfield_t* self, + const cef_string_t* text); + + /// + // Appends |text| to the previously-existing text. + /// + void(CEF_CALLBACK* append_text)(struct _cef_textfield_t* self, + const cef_string_t* text); + + /// + // Inserts |text| at the current cursor position replacing any selected text. + /// + void(CEF_CALLBACK* insert_or_replace_text)(struct _cef_textfield_t* self, + const cef_string_t* text); + + /// + // Returns true (1) if there is any selected text. + /// + int(CEF_CALLBACK* has_selection)(struct _cef_textfield_t* self); + + /// + // Returns the currently selected text. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t(CEF_CALLBACK* get_selected_text)( + struct _cef_textfield_t* self); + + /// + // Selects all text. If |reversed| is true (1) the range will end at the + // logical beginning of the text; this generally shows the leading portion of + // text that overflows its display area. + /// + void(CEF_CALLBACK* select_all)(struct _cef_textfield_t* self, int reversed); + + /// + // Clears the text selection and sets the caret to the end. + /// + void(CEF_CALLBACK* clear_selection)(struct _cef_textfield_t* self); + + /// + // Returns the selected logical text range. + /// + cef_range_t(CEF_CALLBACK* get_selected_range)(struct _cef_textfield_t* self); + + /// + // Selects the specified logical text range. + /// + void(CEF_CALLBACK* select_range)(struct _cef_textfield_t* self, + const cef_range_t* range); + + /// + // Returns the current cursor position. + /// + size_t(CEF_CALLBACK* get_cursor_position)(struct _cef_textfield_t* self); + + /// + // Sets the text color. + /// + void(CEF_CALLBACK* set_text_color)(struct _cef_textfield_t* self, + cef_color_t color); + + /// + // Returns the text color. + /// + cef_color_t(CEF_CALLBACK* get_text_color)(struct _cef_textfield_t* self); + + /// + // Sets the selection text color. + /// + void(CEF_CALLBACK* set_selection_text_color)(struct _cef_textfield_t* self, + cef_color_t color); + + /// + // Returns the selection text color. + /// + cef_color_t(CEF_CALLBACK* get_selection_text_color)( + struct _cef_textfield_t* self); + + /// + // Sets the selection background color. + /// + void(CEF_CALLBACK* set_selection_background_color)( + struct _cef_textfield_t* self, + cef_color_t color); + + /// + // Returns the selection background color. + /// + cef_color_t(CEF_CALLBACK* get_selection_background_color)( + struct _cef_textfield_t* self); + + /// + // Sets the font list. The format is ",[STYLES] ", + // where: - FONT_FAMILY_LIST is a comma-separated list of font family names, - + // STYLES is an optional space-separated list of style names (case-sensitive + // "Bold" and "Italic" are supported), and + // - SIZE is an integer font size in pixels with the suffix "px". + // + // Here are examples of valid font description strings: - "Arial, Helvetica, + // Bold Italic 14px" - "Arial, 14px" + /// + void(CEF_CALLBACK* set_font_list)(struct _cef_textfield_t* self, + const cef_string_t* font_list); + + /// + // Applies |color| to the specified |range| without changing the default + // color. If |range| is NULL the color will be set on the complete text + // contents. + /// + void(CEF_CALLBACK* apply_text_color)(struct _cef_textfield_t* self, + cef_color_t color, + const cef_range_t* range); + + /// + // Applies |style| to the specified |range| without changing the default + // style. If |add| is true (1) the style will be added, otherwise the style + // will be removed. If |range| is NULL the style will be set on the complete + // text contents. + /// + void(CEF_CALLBACK* apply_text_style)(struct _cef_textfield_t* self, + cef_text_style_t style, + int add, + const cef_range_t* range); + + /// + // Returns true (1) if the action associated with the specified command id is + // enabled. See additional comments on execute_command(). + /// + int(CEF_CALLBACK* is_command_enabled)(struct _cef_textfield_t* self, + int command_id); + + /// + // Performs the action associated with the specified command id. Valid values + // include IDS_APP_UNDO, IDS_APP_REDO, IDS_APP_CUT, IDS_APP_COPY, + // IDS_APP_PASTE, IDS_APP_DELETE, IDS_APP_SELECT_ALL, IDS_DELETE_* and + // IDS_MOVE_*. See include/cef_pack_strings.h for definitions. + /// + void(CEF_CALLBACK* execute_command)(struct _cef_textfield_t* self, + int command_id); + + /// + // Clears Edit history. + /// + void(CEF_CALLBACK* clear_edit_history)(struct _cef_textfield_t* self); + + /// + // Sets the placeholder text that will be displayed when the Textfield is + // NULL. + /// + void(CEF_CALLBACK* set_placeholder_text)(struct _cef_textfield_t* self, + const cef_string_t* text); + + /// + // Returns the placeholder text that will be displayed when the Textfield is + // NULL. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t(CEF_CALLBACK* get_placeholder_text)( + struct _cef_textfield_t* self); + + /// + // Sets the placeholder text color. + /// + void(CEF_CALLBACK* set_placeholder_text_color)(struct _cef_textfield_t* self, + cef_color_t color); + + /// + // Set the accessible name that will be exposed to assistive technology (AT). + /// + void(CEF_CALLBACK* set_accessible_name)(struct _cef_textfield_t* self, + const cef_string_t* name); +} cef_textfield_t; + +/// +// Create a new Textfield. +/// +CEF_EXPORT cef_textfield_t* cef_textfield_create( + struct _cef_textfield_delegate_t* delegate); + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_VIEWS_CEF_TEXTFIELD_CAPI_H_ diff --git a/include/capi/views/cef_textfield_delegate_capi.h b/include/capi/views/cef_textfield_delegate_capi.h new file mode 100644 index 0000000..17ce9fe --- /dev/null +++ b/include/capi/views/cef_textfield_delegate_capi.h @@ -0,0 +1,83 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=542381be4ca1f8b31da984b8ba9a13696da3917c$ +// + +#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_TEXTFIELD_DELEGATE_CAPI_H_ +#define CEF_INCLUDE_CAPI_VIEWS_CEF_TEXTFIELD_DELEGATE_CAPI_H_ +#pragma once + +#include "include/capi/views/cef_view_delegate_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct _cef_textfield_t; + +/// +// Implement this structure to handle Textfield events. The functions of this +// structure will be called on the browser process UI thread unless otherwise +// indicated. +/// +typedef struct _cef_textfield_delegate_t { + /// + // Base structure. + /// + cef_view_delegate_t base; + + /// + // Called when |textfield| recieves a keyboard event. |event| contains + // information about the keyboard event. Return true (1) if the keyboard event + // was handled or false (0) otherwise for default handling. + /// + int(CEF_CALLBACK* on_key_event)(struct _cef_textfield_delegate_t* self, + struct _cef_textfield_t* textfield, + const struct _cef_key_event_t* event); + + /// + // Called after performing a user action that may change |textfield|. + /// + void(CEF_CALLBACK* on_after_user_action)( + struct _cef_textfield_delegate_t* self, + struct _cef_textfield_t* textfield); +} cef_textfield_delegate_t; + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_VIEWS_CEF_TEXTFIELD_DELEGATE_CAPI_H_ diff --git a/include/capi/views/cef_view_capi.h b/include/capi/views/cef_view_capi.h new file mode 100644 index 0000000..c6496ae --- /dev/null +++ b/include/capi/views/cef_view_capi.h @@ -0,0 +1,389 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=de8c557cc87233b9d9caeccfaf426f14ee4b499a$ +// + +#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_VIEW_CAPI_H_ +#define CEF_INCLUDE_CAPI_VIEWS_CEF_VIEW_CAPI_H_ +#pragma once + +#include "include/capi/views/cef_view_delegate_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct _cef_browser_view_t; +struct _cef_button_t; +struct _cef_panel_t; +struct _cef_scroll_view_t; +struct _cef_textfield_t; +struct _cef_window_t; + +/// +// A View is a rectangle within the views View hierarchy. It is the base +// structure for all Views. All size and position values are in density +// independent pixels (DIP) unless otherwise indicated. Methods must be called +// on the browser process UI thread unless otherwise indicated. +/// +typedef struct _cef_view_t { + /// + // Base structure. + /// + cef_base_ref_counted_t base; + + /// + // Returns this View as a BrowserView or NULL if this is not a BrowserView. + /// + struct _cef_browser_view_t*(CEF_CALLBACK* as_browser_view)( + struct _cef_view_t* self); + + /// + // Returns this View as a Button or NULL if this is not a Button. + /// + struct _cef_button_t*(CEF_CALLBACK* as_button)(struct _cef_view_t* self); + + /// + // Returns this View as a Panel or NULL if this is not a Panel. + /// + struct _cef_panel_t*(CEF_CALLBACK* as_panel)(struct _cef_view_t* self); + + /// + // Returns this View as a ScrollView or NULL if this is not a ScrollView. + /// + struct _cef_scroll_view_t*(CEF_CALLBACK* as_scroll_view)( + struct _cef_view_t* self); + + /// + // Returns this View as a Textfield or NULL if this is not a Textfield. + /// + struct _cef_textfield_t*(CEF_CALLBACK* as_textfield)( + struct _cef_view_t* self); + + /// + // Returns the type of this View as a string. Used primarily for testing + // purposes. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t(CEF_CALLBACK* get_type_string)( + struct _cef_view_t* self); + + /// + // Returns a string representation of this View which includes the type and + // various type-specific identifying attributes. If |include_children| is true + // (1) any child Views will also be included. Used primarily for testing + // purposes. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t(CEF_CALLBACK* to_string)(struct _cef_view_t* self, + int include_children); + + /// + // Returns true (1) if this View is valid. + /// + int(CEF_CALLBACK* is_valid)(struct _cef_view_t* self); + + /// + // Returns true (1) if this View is currently attached to another View. A View + // can only be attached to one View at a time. + /// + int(CEF_CALLBACK* is_attached)(struct _cef_view_t* self); + + /// + // Returns true (1) if this View is the same as |that| View. + /// + int(CEF_CALLBACK* is_same)(struct _cef_view_t* self, + struct _cef_view_t* that); + + /// + // Returns the delegate associated with this View, if any. + /// + struct _cef_view_delegate_t*(CEF_CALLBACK* get_delegate)( + struct _cef_view_t* self); + + /// + // Returns the top-level Window hosting this View, if any. + /// + struct _cef_window_t*(CEF_CALLBACK* get_window)(struct _cef_view_t* self); + + /// + // Returns the ID for this View. + /// + int(CEF_CALLBACK* get_id)(struct _cef_view_t* self); + + /// + // Sets the ID for this View. ID should be unique within the subtree that you + // intend to search for it. 0 is the default ID for views. + /// + void(CEF_CALLBACK* set_id)(struct _cef_view_t* self, int id); + + /// + // Returns the group id of this View, or -1 if not set. + /// + int(CEF_CALLBACK* get_group_id)(struct _cef_view_t* self); + + /// + // A group id is used to tag Views which are part of the same logical group. + // Focus can be moved between views with the same group using the arrow keys. + // The group id is immutable once it's set. + /// + void(CEF_CALLBACK* set_group_id)(struct _cef_view_t* self, int group_id); + + /// + // Returns the View that contains this View, if any. + /// + struct _cef_view_t*(CEF_CALLBACK* get_parent_view)(struct _cef_view_t* self); + + /// + // Recursively descends the view tree starting at this View, and returns the + // first child that it encounters with the given ID. Returns NULL if no + // matching child view is found. + /// + struct _cef_view_t*(CEF_CALLBACK* get_view_for_id)(struct _cef_view_t* self, + int id); + + /// + // Sets the bounds (size and position) of this View. Position is in parent + // coordinates. + /// + void(CEF_CALLBACK* set_bounds)(struct _cef_view_t* self, + const cef_rect_t* bounds); + + /// + // Returns the bounds (size and position) of this View. Position is in parent + // coordinates. + /// + cef_rect_t(CEF_CALLBACK* get_bounds)(struct _cef_view_t* self); + + /// + // Returns the bounds (size and position) of this View. Position is in screen + // coordinates. + /// + cef_rect_t(CEF_CALLBACK* get_bounds_in_screen)(struct _cef_view_t* self); + + /// + // Sets the size of this View without changing the position. + /// + void(CEF_CALLBACK* set_size)(struct _cef_view_t* self, + const cef_size_t* size); + + /// + // Returns the size of this View. + /// + cef_size_t(CEF_CALLBACK* get_size)(struct _cef_view_t* self); + + /// + // Sets the position of this View without changing the size. |position| is in + // parent coordinates. + /// + void(CEF_CALLBACK* set_position)(struct _cef_view_t* self, + const cef_point_t* position); + + /// + // Returns the position of this View. Position is in parent coordinates. + /// + cef_point_t(CEF_CALLBACK* get_position)(struct _cef_view_t* self); + + /// + // Returns the size this View would like to be if enough space is available. + /// + cef_size_t(CEF_CALLBACK* get_preferred_size)(struct _cef_view_t* self); + + /// + // Size this View to its preferred size. + /// + void(CEF_CALLBACK* size_to_preferred_size)(struct _cef_view_t* self); + + /// + // Returns the minimum size for this View. + /// + cef_size_t(CEF_CALLBACK* get_minimum_size)(struct _cef_view_t* self); + + /// + // Returns the maximum size for this View. + /// + cef_size_t(CEF_CALLBACK* get_maximum_size)(struct _cef_view_t* self); + + /// + // Returns the height necessary to display this View with the provided width. + /// + int(CEF_CALLBACK* get_height_for_width)(struct _cef_view_t* self, int width); + + /// + // Indicate that this View and all parent Views require a re-layout. This + // ensures the next call to layout() will propagate to this View even if the + // bounds of parent Views do not change. + /// + void(CEF_CALLBACK* invalidate_layout)(struct _cef_view_t* self); + + /// + // Sets whether this View is visible. Windows are hidden by default and other + // views are visible by default. This View and any parent views must be set as + // visible for this View to be drawn in a Window. If this View is set as + // hidden then it and any child views will not be drawn and, if any of those + // views currently have focus, then focus will also be cleared. Painting is + // scheduled as needed. If this View is a Window then calling this function is + // equivalent to calling the Window show() and hide() functions. + /// + void(CEF_CALLBACK* set_visible)(struct _cef_view_t* self, int visible); + + /// + // Returns whether this View is visible. A view may be visible but still not + // drawn in a Window if any parent views are hidden. If this View is a Window + // then a return value of true (1) indicates that this Window is currently + // visible to the user on-screen. If this View is not a Window then call + // is_drawn() to determine whether this View and all parent views are visible + // and will be drawn. + /// + int(CEF_CALLBACK* is_visible)(struct _cef_view_t* self); + + /// + // Returns whether this View is visible and drawn in a Window. A view is drawn + // if it and all parent views are visible. If this View is a Window then + // calling this function is equivalent to calling is_visible(). Otherwise, to + // determine if the containing Window is visible to the user on-screen call + // is_visible() on the Window. + /// + int(CEF_CALLBACK* is_drawn)(struct _cef_view_t* self); + + /// + // Set whether this View is enabled. A disabled View does not receive keyboard + // or mouse inputs. If |enabled| differs from the current value the View will + // be repainted. Also, clears focus if the focused View is disabled. + /// + void(CEF_CALLBACK* set_enabled)(struct _cef_view_t* self, int enabled); + + /// + // Returns whether this View is enabled. + /// + int(CEF_CALLBACK* is_enabled)(struct _cef_view_t* self); + + /// + // Sets whether this View is capable of taking focus. It will clear focus if + // the focused View is set to be non-focusable. This is false (0) by default + // so that a View used as a container does not get the focus. + /// + void(CEF_CALLBACK* set_focusable)(struct _cef_view_t* self, int focusable); + + /// + // Returns true (1) if this View is focusable, enabled and drawn. + /// + int(CEF_CALLBACK* is_focusable)(struct _cef_view_t* self); + + /// + // Return whether this View is focusable when the user requires full keyboard + // access, even though it may not be normally focusable. + /// + int(CEF_CALLBACK* is_accessibility_focusable)(struct _cef_view_t* self); + + /// + // Request keyboard focus. If this View is focusable it will become the + // focused View. + /// + void(CEF_CALLBACK* request_focus)(struct _cef_view_t* self); + + /// + // Sets the background color for this View. + /// + void(CEF_CALLBACK* set_background_color)(struct _cef_view_t* self, + cef_color_t color); + + /// + // Returns the background color for this View. + /// + cef_color_t(CEF_CALLBACK* get_background_color)(struct _cef_view_t* self); + + /// + // Convert |point| from this View's coordinate system to that of the screen. + // This View must belong to a Window when calling this function. Returns true + // (1) if the conversion is successful or false (0) otherwise. Use + // cef_display_t::convert_point_to_pixels() after calling this function if + // further conversion to display-specific pixel coordinates is desired. + /// + int(CEF_CALLBACK* convert_point_to_screen)(struct _cef_view_t* self, + cef_point_t* point); + + /// + // Convert |point| to this View's coordinate system from that of the screen. + // This View must belong to a Window when calling this function. Returns true + // (1) if the conversion is successful or false (0) otherwise. Use + // cef_display_t::convert_point_from_pixels() before calling this function if + // conversion from display-specific pixel coordinates is necessary. + /// + int(CEF_CALLBACK* convert_point_from_screen)(struct _cef_view_t* self, + cef_point_t* point); + + /// + // Convert |point| from this View's coordinate system to that of the Window. + // This View must belong to a Window when calling this function. Returns true + // (1) if the conversion is successful or false (0) otherwise. + /// + int(CEF_CALLBACK* convert_point_to_window)(struct _cef_view_t* self, + cef_point_t* point); + + /// + // Convert |point| to this View's coordinate system from that of the Window. + // This View must belong to a Window when calling this function. Returns true + // (1) if the conversion is successful or false (0) otherwise. + /// + int(CEF_CALLBACK* convert_point_from_window)(struct _cef_view_t* self, + cef_point_t* point); + + /// + // Convert |point| from this View's coordinate system to that of |view|. + // |view| needs to be in the same Window but not necessarily the same view + // hierarchy. Returns true (1) if the conversion is successful or false (0) + // otherwise. + /// + int(CEF_CALLBACK* convert_point_to_view)(struct _cef_view_t* self, + struct _cef_view_t* view, + cef_point_t* point); + + /// + // Convert |point| to this View's coordinate system from that |view|. |view| + // needs to be in the same Window but not necessarily the same view hierarchy. + // Returns true (1) if the conversion is successful or false (0) otherwise. + /// + int(CEF_CALLBACK* convert_point_from_view)(struct _cef_view_t* self, + struct _cef_view_t* view, + cef_point_t* point); +} cef_view_t; + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_VIEWS_CEF_VIEW_CAPI_H_ diff --git a/include/capi/views/cef_view_delegate_capi.h b/include/capi/views/cef_view_delegate_capi.h new file mode 100644 index 0000000..4bcfdbb --- /dev/null +++ b/include/capi/views/cef_view_delegate_capi.h @@ -0,0 +1,134 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=982ad223be14ddf50a61b3cf803330397349b661$ +// + +#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_VIEW_DELEGATE_CAPI_H_ +#define CEF_INCLUDE_CAPI_VIEWS_CEF_VIEW_DELEGATE_CAPI_H_ +#pragma once + +#include "include/capi/cef_base_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct _cef_view_t; + +/// +// Implement this structure to handle view events. The functions of this +// structure will be called on the browser process UI thread unless otherwise +// indicated. +/// +typedef struct _cef_view_delegate_t { + /// + // Base structure. + /// + cef_base_ref_counted_t base; + + /// + // Return the preferred size for |view|. The Layout will use this information + // to determine the display size. + /// + cef_size_t(CEF_CALLBACK* get_preferred_size)( + struct _cef_view_delegate_t* self, + struct _cef_view_t* view); + + /// + // Return the minimum size for |view|. + /// + cef_size_t(CEF_CALLBACK* get_minimum_size)(struct _cef_view_delegate_t* self, + struct _cef_view_t* view); + + /// + // Return the maximum size for |view|. + /// + cef_size_t(CEF_CALLBACK* get_maximum_size)(struct _cef_view_delegate_t* self, + struct _cef_view_t* view); + + /// + // Return the height necessary to display |view| with the provided |width|. If + // not specified the result of get_preferred_size().height will be used by + // default. Override if |view|'s preferred height depends upon the width (for + // example, with Labels). + /// + int(CEF_CALLBACK* get_height_for_width)(struct _cef_view_delegate_t* self, + struct _cef_view_t* view, + int width); + + /// + // Called when the parent of |view| has changed. If |view| is being added to + // |parent| then |added| will be true (1). If |view| is being removed from + // |parent| then |added| will be false (0). If |view| is being reparented the + // remove notification will be sent before the add notification. Do not modify + // the view hierarchy in this callback. + /// + void(CEF_CALLBACK* on_parent_view_changed)(struct _cef_view_delegate_t* self, + struct _cef_view_t* view, + int added, + struct _cef_view_t* parent); + + /// + // Called when a child of |view| has changed. If |child| is being added to + // |view| then |added| will be true (1). If |child| is being removed from + // |view| then |added| will be false (0). If |child| is being reparented the + // remove notification will be sent to the old parent before the add + // notification is sent to the new parent. Do not modify the view hierarchy in + // this callback. + /// + void(CEF_CALLBACK* on_child_view_changed)(struct _cef_view_delegate_t* self, + struct _cef_view_t* view, + int added, + struct _cef_view_t* child); + + /// + // Called when |view| gains focus. + /// + void(CEF_CALLBACK* on_focus)(struct _cef_view_delegate_t* self, + struct _cef_view_t* view); + + /// + // Called when |view| loses focus. + /// + void(CEF_CALLBACK* on_blur)(struct _cef_view_delegate_t* self, + struct _cef_view_t* view); +} cef_view_delegate_t; + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_VIEWS_CEF_VIEW_DELEGATE_CAPI_H_ diff --git a/include/capi/views/cef_window_capi.h b/include/capi/views/cef_window_capi.h new file mode 100644 index 0000000..f025e02 --- /dev/null +++ b/include/capi/views/cef_window_capi.h @@ -0,0 +1,314 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=ef258af57aea577693ce52d61b630ca29bdd5ea0$ +// + +#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_CAPI_H_ +#define CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_CAPI_H_ +#pragma once + +#include "include/capi/cef_image_capi.h" +#include "include/capi/cef_menu_model_capi.h" +#include "include/capi/views/cef_display_capi.h" +#include "include/capi/views/cef_panel_capi.h" +#include "include/capi/views/cef_window_delegate_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// A Window is a top-level Window/widget in the Views hierarchy. By default it +// will have a non-client area with title bar, icon and buttons that supports +// moving and resizing. All size and position values are in density independent +// pixels (DIP) unless otherwise indicated. Methods must be called on the +// browser process UI thread unless otherwise indicated. +/// +typedef struct _cef_window_t { + /// + // Base structure. + /// + cef_panel_t base; + + /// + // Show the Window. + /// + void(CEF_CALLBACK* show)(struct _cef_window_t* self); + + /// + // Hide the Window. + /// + void(CEF_CALLBACK* hide)(struct _cef_window_t* self); + + /// + // Sizes the Window to |size| and centers it in the current display. + /// + void(CEF_CALLBACK* center_window)(struct _cef_window_t* self, + const cef_size_t* size); + + /// + // Close the Window. + /// + void(CEF_CALLBACK* close)(struct _cef_window_t* self); + + /// + // Returns true (1) if the Window has been closed. + /// + int(CEF_CALLBACK* is_closed)(struct _cef_window_t* self); + + /// + // Activate the Window, assuming it already exists and is visible. + /// + void(CEF_CALLBACK* activate)(struct _cef_window_t* self); + + /// + // Deactivate the Window, making the next Window in the Z order the active + // Window. + /// + void(CEF_CALLBACK* deactivate)(struct _cef_window_t* self); + + /// + // Returns whether the Window is the currently active Window. + /// + int(CEF_CALLBACK* is_active)(struct _cef_window_t* self); + + /// + // Bring this Window to the top of other Windows in the Windowing system. + /// + void(CEF_CALLBACK* bring_to_top)(struct _cef_window_t* self); + + /// + // Set the Window to be on top of other Windows in the Windowing system. + /// + void(CEF_CALLBACK* set_always_on_top)(struct _cef_window_t* self, int on_top); + + /// + // Returns whether the Window has been set to be on top of other Windows in + // the Windowing system. + /// + int(CEF_CALLBACK* is_always_on_top)(struct _cef_window_t* self); + + /// + // Maximize the Window. + /// + void(CEF_CALLBACK* maximize)(struct _cef_window_t* self); + + /// + // Minimize the Window. + /// + void(CEF_CALLBACK* minimize)(struct _cef_window_t* self); + + /// + // Restore the Window. + /// + void(CEF_CALLBACK* restore)(struct _cef_window_t* self); + + /// + // Set fullscreen Window state. + /// + void(CEF_CALLBACK* set_fullscreen)(struct _cef_window_t* self, + int fullscreen); + + /// + // Returns true (1) if the Window is maximized. + /// + int(CEF_CALLBACK* is_maximized)(struct _cef_window_t* self); + + /// + // Returns true (1) if the Window is minimized. + /// + int(CEF_CALLBACK* is_minimized)(struct _cef_window_t* self); + + /// + // Returns true (1) if the Window is fullscreen. + /// + int(CEF_CALLBACK* is_fullscreen)(struct _cef_window_t* self); + + /// + // Set the Window title. + /// + void(CEF_CALLBACK* set_title)(struct _cef_window_t* self, + const cef_string_t* title); + + /// + // Get the Window title. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t(CEF_CALLBACK* get_title)(struct _cef_window_t* self); + + /// + // Set the Window icon. This should be a 16x16 icon suitable for use in the + // Windows's title bar. + /// + void(CEF_CALLBACK* set_window_icon)(struct _cef_window_t* self, + struct _cef_image_t* image); + + /// + // Get the Window icon. + /// + struct _cef_image_t*(CEF_CALLBACK* get_window_icon)( + struct _cef_window_t* self); + + /// + // Set the Window App icon. This should be a larger icon for use in the host + // environment app switching UI. On Windows, this is the ICON_BIG used in Alt- + // Tab list and Windows taskbar. The Window icon will be used by default if no + // Window App icon is specified. + /// + void(CEF_CALLBACK* set_window_app_icon)(struct _cef_window_t* self, + struct _cef_image_t* image); + + /// + // Get the Window App icon. + /// + struct _cef_image_t*(CEF_CALLBACK* get_window_app_icon)( + struct _cef_window_t* self); + + /// + // Show a menu with contents |menu_model|. |screen_point| specifies the menu + // position in screen coordinates. |anchor_position| specifies how the menu + // will be anchored relative to |screen_point|. + /// + void(CEF_CALLBACK* show_menu)(struct _cef_window_t* self, + struct _cef_menu_model_t* menu_model, + const cef_point_t* screen_point, + cef_menu_anchor_position_t anchor_position); + + /// + // Cancel the menu that is currently showing, if any. + /// + void(CEF_CALLBACK* cancel_menu)(struct _cef_window_t* self); + + /// + // Returns the Display that most closely intersects the bounds of this Window. + // May return NULL if this Window is not currently displayed. + /// + struct _cef_display_t*(CEF_CALLBACK* get_display)(struct _cef_window_t* self); + + /// + // Returns the bounds (size and position) of this Window's client area. + // Position is in screen coordinates. + /// + cef_rect_t(CEF_CALLBACK* get_client_area_bounds_in_screen)( + struct _cef_window_t* self); + + /// + // Set the regions where mouse events will be intercepted by this Window to + // support drag operations. Call this function with an NULL vector to clear + // the draggable regions. The draggable region bounds should be in window + // coordinates. + /// + void(CEF_CALLBACK* set_draggable_regions)( + struct _cef_window_t* self, + size_t regionsCount, + cef_draggable_region_t const* regions); + + /// + // Retrieve the platform window handle for this Window. + /// + cef_window_handle_t(CEF_CALLBACK* get_window_handle)( + struct _cef_window_t* self); + + /// + // Simulate a key press. |key_code| is the VKEY_* value from Chromium's + // ui/events/keycodes/keyboard_codes.h header (VK_* values on Windows). + // |event_flags| is some combination of EVENTFLAG_SHIFT_DOWN, + // EVENTFLAG_CONTROL_DOWN and/or EVENTFLAG_ALT_DOWN. This function is exposed + // primarily for testing purposes. + /// + void(CEF_CALLBACK* send_key_press)(struct _cef_window_t* self, + int key_code, + uint32 event_flags); + + /// + // Simulate a mouse move. The mouse cursor will be moved to the specified + // (screen_x, screen_y) position. This function is exposed primarily for + // testing purposes. + /// + void(CEF_CALLBACK* send_mouse_move)(struct _cef_window_t* self, + int screen_x, + int screen_y); + + /// + // Simulate mouse down and/or mouse up events. |button| is the mouse button + // type. If |mouse_down| is true (1) a mouse down event will be sent. If + // |mouse_up| is true (1) a mouse up event will be sent. If both are true (1) + // a mouse down event will be sent followed by a mouse up event (equivalent to + // clicking the mouse button). The events will be sent using the current + // cursor position so make sure to call send_mouse_move() first to position + // the mouse. This function is exposed primarily for testing purposes. + /// + void(CEF_CALLBACK* send_mouse_events)(struct _cef_window_t* self, + cef_mouse_button_type_t button, + int mouse_down, + int mouse_up); + + /// + // Set the keyboard accelerator for the specified |command_id|. |key_code| can + // be any virtual key or character value. cef_window_delegate_t::OnAccelerator + // will be called if the keyboard combination is triggered while this window + // has focus. + /// + void(CEF_CALLBACK* set_accelerator)(struct _cef_window_t* self, + int command_id, + int key_code, + int shift_pressed, + int ctrl_pressed, + int alt_pressed); + + /// + // Remove the keyboard accelerator for the specified |command_id|. + /// + void(CEF_CALLBACK* remove_accelerator)(struct _cef_window_t* self, + int command_id); + + /// + // Remove all keyboard accelerators. + /// + void(CEF_CALLBACK* remove_all_accelerators)(struct _cef_window_t* self); +} cef_window_t; + +/// +// Create a new Window. +/// +CEF_EXPORT cef_window_t* cef_window_create_top_level( + struct _cef_window_delegate_t* delegate); + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_CAPI_H_ diff --git a/include/capi/views/cef_window_delegate_capi.h b/include/capi/views/cef_window_delegate_capi.h new file mode 100644 index 0000000..a669d38 --- /dev/null +++ b/include/capi/views/cef_window_delegate_capi.h @@ -0,0 +1,132 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=e4957abc4c3b80b9f324d74d2c8c6aa2632c52d9$ +// + +#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_DELEGATE_CAPI_H_ +#define CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_DELEGATE_CAPI_H_ +#pragma once + +#include "include/capi/views/cef_panel_delegate_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct _cef_window_t; + +/// +// Implement this structure to handle window events. The functions of this +// structure will be called on the browser process UI thread unless otherwise +// indicated. +/// +typedef struct _cef_window_delegate_t { + /// + // Base structure. + /// + cef_panel_delegate_t base; + + /// + // Called when |window| is created. + /// + void(CEF_CALLBACK* on_window_created)(struct _cef_window_delegate_t* self, + struct _cef_window_t* window); + + /// + // Called when |window| is destroyed. Release all references to |window| and + // do not attempt to execute any functions on |window| after this callback + // returns. + /// + void(CEF_CALLBACK* on_window_destroyed)(struct _cef_window_delegate_t* self, + struct _cef_window_t* window); + + /// + // Return true (1) if |window| should be created without a frame or title bar. + // The window will be resizable if can_resize() returns true (1). Use + // cef_window_t::set_draggable_regions() to specify draggable regions. + /// + int(CEF_CALLBACK* is_frameless)(struct _cef_window_delegate_t* self, + struct _cef_window_t* window); + + /// + // Return true (1) if |window| can be resized. + /// + int(CEF_CALLBACK* can_resize)(struct _cef_window_delegate_t* self, + struct _cef_window_t* window); + + /// + // Return true (1) if |window| can be maximized. + /// + int(CEF_CALLBACK* can_maximize)(struct _cef_window_delegate_t* self, + struct _cef_window_t* window); + + /// + // Return true (1) if |window| can be minimized. + /// + int(CEF_CALLBACK* can_minimize)(struct _cef_window_delegate_t* self, + struct _cef_window_t* window); + + /// + // Return true (1) if |window| can be closed. This will be called for user- + // initiated window close actions and when cef_window_t::close() is called. + /// + int(CEF_CALLBACK* can_close)(struct _cef_window_delegate_t* self, + struct _cef_window_t* window); + + /// + // Called when a keyboard accelerator registered with + // cef_window_t::SetAccelerator is triggered. Return true (1) if the + // accelerator was handled or false (0) otherwise. + /// + int(CEF_CALLBACK* on_accelerator)(struct _cef_window_delegate_t* self, + struct _cef_window_t* window, + int command_id); + + /// + // Called after all other controls in the window have had a chance to handle + // the event. |event| contains information about the keyboard event. Return + // true (1) if the keyboard event was handled or false (0) otherwise. + /// + int(CEF_CALLBACK* on_key_event)(struct _cef_window_delegate_t* self, + struct _cef_window_t* window, + const struct _cef_key_event_t* event); +} cef_window_delegate_t; + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_DELEGATE_CAPI_H_ diff --git a/include/internal/cef_build.h b/include/internal/cef_build.h deleted file mode 100644 index 4b8c545..0000000 --- a/include/internal/cef_build.h +++ /dev/null @@ -1,129 +0,0 @@ -// 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_BUILD_H_ -#define CEF_INCLUDE_INTERNAL_CEF_BUILD_H_ -#pragma once - -#if defined(BUILDING_CEF_SHARED) - -#include "base/compiler_specific.h" - -#else // !BUILDING_CEF_SHARED - -#if defined(_WIN32) -#ifndef OS_WIN -#define OS_WIN 1 -#endif -#elif defined(__APPLE__) -#ifndef OS_MACOSX -#define OS_MACOSX 1 -#endif -#elif defined(__linux__) -#ifndef OS_LINUX -#define OS_LINUX 1 -#endif -#else -#error Please add support for your platform in cef_build.h -#endif - -// For access to standard POSIXish features, use OS_POSIX instead of a -// more specific macro. -#if defined(OS_MACOSX) || defined(OS_LINUX) -#ifndef OS_POSIX -#define OS_POSIX 1 -#endif -#endif - -// Compiler detection. -#if defined(__GNUC__) -#ifndef COMPILER_GCC -#define COMPILER_GCC 1 -#endif -#elif defined(_MSC_VER) -#ifndef COMPILER_MSVC -#define COMPILER_MSVC 1 -#endif -#else -#error Please add support for your compiler in cef_build.h -#endif - -// Annotate a virtual method indicating it must be overriding a virtual -// method in the parent class. -// Use like: -// virtual void foo() OVERRIDE; -#ifndef OVERRIDE -#if defined(COMPILER_MSVC) -#define OVERRIDE override -#elif defined(__clang__) -#define OVERRIDE override -#else -#define OVERRIDE -#endif -#endif - -#ifndef ALLOW_THIS_IN_INITIALIZER_LIST -#if defined(COMPILER_MSVC) - -// MSVC_PUSH_DISABLE_WARNING pushes |n| onto a stack of warnings to be disabled. -// The warning remains disabled until popped by MSVC_POP_WARNING. -#define MSVC_PUSH_DISABLE_WARNING(n) __pragma(warning(push)) \ - __pragma(warning(disable:n)) - -// MSVC_PUSH_WARNING_LEVEL pushes |n| as the global warning level. The level -// remains in effect until popped by MSVC_POP_WARNING(). Use 0 to disable all -// warnings. -#define MSVC_PUSH_WARNING_LEVEL(n) __pragma(warning(push, n)) - -// Pop effects of innermost MSVC_PUSH_* macro. -#define MSVC_POP_WARNING() __pragma(warning(pop)) - -// Allows |this| to be passed as an argument in constructor initializer lists. -// This uses push/pop instead of the seemingly simpler suppress feature to avoid -// having the warning be disabled for more than just |code|. -// -// Example usage: -// Foo::Foo() : x(NULL), ALLOW_THIS_IN_INITIALIZER_LIST(y(this)), z(3) {} -// -// Compiler warning C4355: 'this': used in base member initializer list: -// http://msdn.microsoft.com/en-us/library/3c594ae3(VS.80).aspx -#define ALLOW_THIS_IN_INITIALIZER_LIST(code) MSVC_PUSH_DISABLE_WARNING(4355) \ - code \ - MSVC_POP_WARNING() -#else // !COMPILER_MSVC - -#define ALLOW_THIS_IN_INITIALIZER_LIST(code) code - -#endif // !COMPILER_MSVC -#endif - -#endif // !BUILDING_CEF_SHARED - -#endif // CEF_INCLUDE_INTERNAL_CEF_BUILD_H_ diff --git a/include/internal/cef_export.h b/include/internal/cef_export.h index 80b6e7b..1915f5e 100644 --- a/include/internal/cef_export.h +++ b/include/internal/cef_export.h @@ -32,7 +32,7 @@ #define CEF_INCLUDE_INTERNAL_CEF_EXPORT_H_ #pragma once -#include "include/internal/cef_build.h" +#include "include/base/cef_build.h" #if defined(COMPILER_MSVC) @@ -43,18 +43,17 @@ #else #define CEF_EXPORT #endif -#define CEF_CALLBACK __stdcall #elif defined(COMPILER_GCC) -#define CEF_EXPORT __attribute__ ((visibility("default"))) +#define CEF_EXPORT __attribute__((visibility("default"))) + +#endif // COMPILER_GCC -#ifdef OS_WIN +#if defined(OS_WIN) #define CEF_CALLBACK __stdcall #else #define CEF_CALLBACK #endif -#endif // COMPILER_GCC - #endif // CEF_INCLUDE_INTERNAL_CEF_EXPORT_H_ diff --git a/include/internal/cef_linux.h b/include/internal/cef_linux.h index ddf15ce..ecf74e0 100644 --- a/include/internal/cef_linux.h +++ b/include/internal/cef_linux.h @@ -27,52 +27,17 @@ // (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 -#if defined(OS_LINUX) -#include #include "include/internal/cef_types_linux.h" #include "include/internal/cef_types_wrappers.h" -// Atomic increment and decrement. -inline long CefAtomicIncrement(long volatile *pDest) { // NOLINT(runtime/int) - return __sync_add_and_fetch(pDest, 1); -} -inline long CefAtomicDecrement(long volatile *pDest) { // NOLINT(runtime/int) - return __sync_sub_and_fetch(pDest, 1); -} - -// Critical section wrapper. -class CefCriticalSection { - public: - CefCriticalSection() { - pthread_mutexattr_init(&attr_); - pthread_mutexattr_settype(&attr_, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&lock_, &attr_); - } - virtual ~CefCriticalSection() { - pthread_mutex_destroy(&lock_); - pthread_mutexattr_destroy(&attr_); - } - void Lock() { - pthread_mutex_lock(&lock_); - } - void Unlock() { - pthread_mutex_unlock(&lock_); - } - - pthread_mutex_t lock_; - pthread_mutexattr_t attr_; -}; - // Handle types. #define CefCursorHandle cef_cursor_handle_t #define CefEventHandle cef_event_handle_t #define CefWindowHandle cef_window_handle_t -#define CefTextInputContext cef_text_input_context_t struct CefMainArgsTraits { typedef cef_main_args_t struct_type; @@ -80,8 +45,9 @@ struct CefMainArgsTraits { static inline void init(struct_type* s) {} static inline void clear(struct_type* s) {} - static inline void set(const struct_type* src, struct_type* target, - bool copy) { + static inline void set(const struct_type* src, + struct_type* target, + bool copy) { target->argc = src->argc; target->argv = src->argv; } @@ -107,12 +73,16 @@ struct CefWindowInfoTraits { static inline void init(struct_type* s) {} static inline void clear(struct_type* s) {} - static inline void set(const struct_type* src, struct_type* target, - bool copy) { - target->parent_widget = src->parent_widget; - target->window_rendering_disabled = src->window_rendering_disabled; - target->transparent_painting = src->transparent_painting; - target->widget = src->widget; + static inline void set(const struct_type* src, + struct_type* target, + bool copy) { + target->x = src->x; + target->y = src->y; + target->width = src->width; + target->height = src->height; + target->parent_window = src->parent_window; + target->windowless_rendering_enabled = src->windowless_rendering_enabled; + target->window = src->window; } }; @@ -125,20 +95,33 @@ class CefWindowInfo : public CefStructBase { explicit CefWindowInfo(const cef_window_info_t& r) : parent(r) {} explicit CefWindowInfo(const CefWindowInfo& r) : parent(r) {} - void SetAsChild(CefWindowHandle ParentWidget) { - parent_widget = ParentWidget; + /// + // Create the browser as a child window. + /// + void SetAsChild(CefWindowHandle parent, const CefRect& windowRect) { + parent_window = parent; + x = windowRect.x; + y = windowRect.y; + width = windowRect.width; + height = windowRect.height; } - void SetTransparentPainting(bool transparentPainting) { - transparent_painting = transparentPainting; - } - - void SetAsOffScreen(CefWindowHandle ParentWidget) { - window_rendering_disabled = true; - parent_widget = ParentWidget; + /// + // 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 // OS_LINUX - #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 0000000..598263d --- /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 + +#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(); + +/// +// 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 index 352a5c2..689d88c 100644 --- a/include/internal/cef_mac.h +++ b/include/internal/cef_mac.h @@ -27,52 +27,17 @@ // (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 -#if defined(OS_MACOSX) -#include #include "include/internal/cef_types_mac.h" #include "include/internal/cef_types_wrappers.h" -// Atomic increment and decrement. -inline long CefAtomicIncrement(long volatile *pDest) { // NOLINT(runtime/int) - return __sync_add_and_fetch(pDest, 1); -} -inline long CefAtomicDecrement(long volatile *pDest) { // NOLINT(runtime/int) - return __sync_sub_and_fetch(pDest, 1); -} - -// Critical section wrapper. -class CefCriticalSection { - public: - CefCriticalSection() { - pthread_mutexattr_init(&attr_); - pthread_mutexattr_settype(&attr_, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&lock_, &attr_); - } - virtual ~CefCriticalSection() { - pthread_mutex_destroy(&lock_); - pthread_mutexattr_destroy(&attr_); - } - void Lock() { - pthread_mutex_lock(&lock_); - } - void Unlock() { - pthread_mutex_unlock(&lock_); - } - - pthread_mutex_t lock_; - pthread_mutexattr_t attr_; -}; - // Handle types. #define CefCursorHandle cef_cursor_handle_t #define CefEventHandle cef_event_handle_t #define CefWindowHandle cef_window_handle_t -#define CefTextInputContext cef_text_input_context_t struct CefMainArgsTraits { typedef cef_main_args_t struct_type; @@ -80,8 +45,9 @@ struct CefMainArgsTraits { static inline void init(struct_type* s) {} static inline void clear(struct_type* s) {} - static inline void set(const struct_type* src, struct_type* target, - bool copy) { + static inline void set(const struct_type* src, + struct_type* target, + bool copy) { target->argc = src->argc; target->argv = src->argv; } @@ -110,19 +76,19 @@ struct CefWindowInfoTraits { cef_string_clear(&s->window_name); } - static inline void set(const struct_type* src, struct_type* target, - bool copy) { - target->view = src->view; - target->parent_view = src->parent_view; + 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->window_name, copy); target->x = src->x; target->y = src->y; target->width = src->width; target->height = src->height; target->hidden = src->hidden; - target->transparent_painting = src->transparent_painting; - target->window_rendering_disabled = src->window_rendering_disabled; + target->parent_view = src->parent_view; + target->windowless_rendering_enabled = src->windowless_rendering_enabled; + target->view = src->view; } }; @@ -135,9 +101,11 @@ class CefWindowInfo : public CefStructBase { explicit CefWindowInfo(const cef_window_info_t& r) : parent(r) {} explicit CefWindowInfo(const CefWindowInfo& r) : parent(r) {} - void SetAsChild(CefWindowHandle ParentView, int x, int y, int width, - int height) { - parent_view = ParentView; + /// + // Create the browser as a child view. + /// + void SetAsChild(CefWindowHandle parent, int x, int y, int width, int height) { + parent_view = parent; this->x = x; this->y = y; this->width = width; @@ -145,16 +113,22 @@ class CefWindowInfo : public CefStructBase { hidden = false; } - void SetTransparentPainting(bool transparentPainting) { - transparent_painting = transparentPainting; - } - - void SetAsOffScreen(NSView* view) { - window_rendering_disabled = true; - parent_view = view; + /// + // 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 // OS_MACOSX - #endif // CEF_INCLUDE_INTERNAL_CEF_MAC_H_ diff --git a/include/internal/cef_ptr.h b/include/internal/cef_ptr.h index fcbe69e..044c733 100644 --- a/include/internal/cef_ptr.h +++ b/include/internal/cef_ptr.h @@ -1,5 +1,4 @@ -// Copyright (c) 2008 Marshall A. Greenblatt. Portions Copyright (c) -// 2006-2008 Google Inc. All rights reserved. +// 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 @@ -28,22 +27,29 @@ // (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 +#include "include/base/cef_build.h" +#include "include/base/cef_ref_counted.h" + +#if defined(USING_CHROMIUM_INCLUDES) +#include // For std::unique_ptr. +#else +#include "include/base/cef_scoped_ptr.h" +#endif /// -// Smart pointer implementation borrowed from base/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: //

-//   class MyFoo : public CefBase {
+//   class MyFoo : public CefBaseRefCounted {
 //    ...
 //   };
 //
@@ -143,57 +149,82 @@
 // 
//

/// +#if defined(HAS_CPP11_TEMPLATE_ALIAS_SUPPORT) template -class CefRefPtr { - public: - CefRefPtr() : ptr_(NULL) { - } +using CefRefPtr = scoped_refptr; +#else +// When template aliases are not supported use a define instead of subclassing +// because it's otherwise hard to get the constructors to behave correctly. +#define CefRefPtr scoped_refptr +#endif - CefRefPtr(T* p) : ptr_(p) { // NOLINT(runtime/explicit) - if (ptr_) - ptr_->AddRef(); - } +/// +// A CefOwnPtr is like a T*, except that the destructor of CefOwnPtr +// automatically deletes the pointer it holds (if any). That is, CefOwnPtr +// owns the T object that it points to. Like a T*, a CefOwnPtr may hold +// either NULL or a pointer to a T object. Also like T*, CefOwnPtr is +// thread-compatible, and once you dereference it, you get the thread safety +// guarantees of T. +/// +#if defined(USING_CHROMIUM_INCLUDES) +// Implementation-side code uses std::unique_ptr instead of scoped_ptr. +template > +using CefOwnPtr = std::unique_ptr; +#elif defined(HAS_CPP11_TEMPLATE_ALIAS_SUPPORT) +template > +using CefOwnPtr = scoped_ptr; +#else +// When template aliases are not supported use a define instead of subclassing +// because it's otherwise hard to get the constructors to behave correctly. +#define CefOwnPtr scoped_ptr +#endif - CefRefPtr(const CefRefPtr& r) : ptr_(r.ptr_) { - if (ptr_) - ptr_->AddRef(); - } +/// +// A CefRawPtr is the same as T* +/// +#if defined(HAS_CPP11_TEMPLATE_ALIAS_SUPPORT) +#define CEF_RAW_PTR_GET(r) r +template +using CefRawPtr = T*; +#else +// Simple wrapper implementation that behaves as much like T* as possible. +// CEF_RAW_PTR_GET is required for VS2008 compatibility (Issue #2155). +#define CEF_RAW_PTR_GET(r) r.get() +template +class CefRawPtr { + public: + CefRawPtr() : ptr_(nullptr) {} + CefRawPtr(T* p) : ptr_(p) {} + CefRawPtr(const CefRawPtr& r) : ptr_(r.ptr_) {} - ~CefRefPtr() { - if (ptr_) - ptr_->Release(); - } + template + CefRawPtr(const CefRawPtr& r) : ptr_(r.get()) {} T* get() const { return ptr_; } + + // Allow CefRawPtr to be used in boolean expression and comparison operations. operator T*() const { return ptr_; } - T* operator->() const { return ptr_; } - CefRefPtr& operator=(T* p) { - // AddRef first so that self assignment should work - if (p) - p->AddRef(); - if (ptr_ ) - ptr_ ->Release(); - ptr_ = p; - return *this; + T* operator->() const { + assert(ptr_ != NULL); + return ptr_; } - CefRefPtr& operator=(const CefRefPtr& r) { - return *this = r.ptr_; + CefRawPtr& operator=(T* p) { + ptr_ = p; + return *this; } - void swap(T** pp) { - T* p = ptr_; - ptr_ = *pp; - *pp = p; - } + CefRawPtr& operator=(const CefRawPtr& r) { return *this = r.ptr_; } - void swap(CefRefPtr& r) { - swap(&r.ptr_); // NOLINT(build/include_what_you_use) + template + CefRawPtr& operator=(const CefRawPtr& r) { + return *this = r.get(); } private: T* ptr_; }; +#endif #endif // CEF_INCLUDE_INTERNAL_CEF_PTR_H_ diff --git a/include/internal/cef_string.h b/include/internal/cef_string.h index 65be1d1..77c8ca3 100644 --- a/include/internal/cef_string.h +++ b/include/internal/cef_string.h @@ -44,7 +44,6 @@ // Build with the wide string type as default. // #define CEF_STRING_TYPE_WIDE 1 - #include "include/internal/cef_string_types.h" #ifdef __cplusplus @@ -77,8 +76,7 @@ typedef cef_string_userfree_utf8_t cef_string_userfree_t; #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_t cef_string_utf16_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 diff --git a/include/internal/cef_string_list.h b/include/internal/cef_string_list.h index 52a0abf..b44bac7 100644 --- a/include/internal/cef_string_list.h +++ b/include/internal/cef_string_list.h @@ -51,14 +51,15 @@ CEF_EXPORT cef_string_list_t cef_string_list_alloc(); /// // Return the number of elements in the string list. /// -CEF_EXPORT int cef_string_list_size(cef_string_list_t 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, - int index, cef_string_t* value); + size_t index, + cef_string_t* value); /// // Append a new value at the end of the string list. diff --git a/include/internal/cef_string_map.h b/include/internal/cef_string_map.h index 93eea2a..0f33425 100644 --- a/include/internal/cef_string_map.h +++ b/include/internal/cef_string_map.h @@ -51,7 +51,7 @@ CEF_EXPORT cef_string_map_t cef_string_map_alloc(); /// // Return the number of elements in the string map. /// -CEF_EXPORT int cef_string_map_size(cef_string_map_t map); +CEF_EXPORT size_t cef_string_map_size(cef_string_map_t map); /// // Return the value assigned to the specified key. @@ -63,13 +63,15 @@ CEF_EXPORT int cef_string_map_find(cef_string_map_t map, /// // Return the key at the specified zero-based string map index. /// -CEF_EXPORT int cef_string_map_key(cef_string_map_t map, int 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, int index, +CEF_EXPORT int cef_string_map_value(cef_string_map_t map, + size_t index, cef_string_t* value); /// @@ -89,7 +91,6 @@ CEF_EXPORT void cef_string_map_clear(cef_string_map_t map); /// CEF_EXPORT void cef_string_map_free(cef_string_map_t map); - #ifdef __cplusplus } #endif diff --git a/include/internal/cef_string_multimap.h b/include/internal/cef_string_multimap.h index cd39042..cd07746 100644 --- a/include/internal/cef_string_multimap.h +++ b/include/internal/cef_string_multimap.h @@ -52,32 +52,34 @@ CEF_EXPORT cef_string_multimap_t cef_string_multimap_alloc(); /// // Return the number of elements in the string multimap. /// -CEF_EXPORT int cef_string_multimap_size(cef_string_multimap_t map); +CEF_EXPORT size_t cef_string_multimap_size(cef_string_multimap_t map); /// // Return the number of values with the specified key. /// -CEF_EXPORT int cef_string_multimap_find_count(cef_string_multimap_t map, - const cef_string_t* 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, - int value_index, + 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, int 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, int index, +CEF_EXPORT int cef_string_multimap_value(cef_string_multimap_t map, + size_t index, cef_string_t* value); /// @@ -97,7 +99,6 @@ CEF_EXPORT void cef_string_multimap_clear(cef_string_multimap_t map); /// CEF_EXPORT void cef_string_multimap_free(cef_string_multimap_t map); - #ifdef __cplusplus } #endif diff --git a/include/internal/cef_string_types.h b/include/internal/cef_string_types.h index 7ab6671..ea91960 100644 --- a/include/internal/cef_string_types.h +++ b/include/internal/cef_string_types.h @@ -36,26 +36,14 @@ // modification. It is the user's responsibility to provide synchronization if // modifying CEF strings from multiple threads. -#ifdef __cplusplus -extern "C" { -#endif - -#include "include/internal/cef_build.h" -#include "include/internal/cef_export.h" #include -// CEF character type definitions. wchar_t is 2 bytes on Windows and 4 bytes on -// most other platforms. - -#if defined(OS_WIN) -typedef wchar_t char16; -#else // !OS_WIN -typedef unsigned short char16; // NOLINT (runtime/int) -#ifndef WCHAR_T_IS_UTF32 -#define WCHAR_T_IS_UTF32 -#endif // WCHAR_T_IS_UTF32 -#endif // !OS_WIN +#include "include/base/cef_basictypes.h" +#include "include/internal/cef_export.h" +#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 @@ -82,32 +70,35 @@ typedef struct _cef_string_utf16_t { 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); - +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) - +#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. @@ -117,7 +108,6 @@ 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(). /// @@ -129,7 +119,6 @@ CEF_EXPORT int cef_string_utf8_cmp(const cef_string_utf8_t* str1, 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 @@ -137,35 +126,40 @@ CEF_EXPORT int cef_string_utf16_cmp(const cef_string_utf16_t* str1, // 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_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_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_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_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_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_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_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_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 @@ -176,7 +170,6 @@ 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. @@ -186,7 +179,6 @@ CEF_EXPORT cef_string_userfree_wide_t cef_string_userfree_wide_alloc(); CEF_EXPORT cef_string_userfree_utf8_t cef_string_userfree_utf8_alloc(); CEF_EXPORT cef_string_userfree_utf16_t cef_string_userfree_utf16_alloc(); - /// // These functions free the string structure allocated by the associated // alloc function. Any string contents will first be cleared. @@ -196,6 +188,17 @@ 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 } diff --git a/include/internal/cef_string_wrappers.h b/include/internal/cef_string_wrappers.h index 875bcc5..f965e9c 100644 --- a/include/internal/cef_string_wrappers.h +++ b/include/internal/cef_string_wrappers.h @@ -33,13 +33,14 @@ #include #include + +#include "include/base/cef_string16.h" #include "include/internal/cef_string_types.h" -#ifdef BUILDING_CEF_SHARED -#include "base/strings/string16.h" +#if defined(USING_CHROMIUM_INCLUDES) +#include "base/files/file_path.h" #endif - /// // Traits implementation for wide character strings. /// @@ -48,9 +49,11 @@ struct CefStringTraitsWide { 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) { + 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) { @@ -64,10 +67,10 @@ struct CefStringTraitsWide { } // Conversion methods. - static inline bool from_ascii(const char* str, size_t len, struct_type *s) { + 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) { + 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); @@ -77,19 +80,18 @@ struct CefStringTraitsWide { cef_string_utf8_clear(&cstr); return str; } - static inline bool from_string(const std::string& str, struct_type *s) { + static inline bool from_string(const std::string& str, struct_type* s) { return cef_string_utf8_to_wide(str.c_str(), str.length(), s) ? true : false; } - static inline std::wstring to_wstring(const struct_type *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& str, struct_type *s) { - return cef_string_wide_set(str.c_str(), str.length(), s, true) ? - true : false; + static inline bool from_wstring(const std::wstring& str, struct_type* s) { + return cef_string_wide_set(str.c_str(), str.length(), s, true) ? true + : false; } -#if defined(BUILDING_CEF_SHARED) #if defined(WCHAR_T_IS_UTF32) - static inline base::string16 to_string16(const struct_type *s) { + static inline base::string16 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); @@ -99,21 +101,19 @@ struct CefStringTraitsWide { cef_string_utf16_clear(&cstr); return str; } - static inline bool from_string16(const base::string16& str, - struct_type *s) { - return cef_string_utf16_to_wide(str.c_str(), str.length(), s) ? - true : false; + static inline bool from_string16(const base::string16& str, struct_type* s) { + return cef_string_utf16_to_wide(str.c_str(), str.length(), s) ? true + : false; } -#else // WCHAR_T_IS_UTF32 - static inline base::string16 to_string16(const struct_type *s) { +#else // WCHAR_T_IS_UTF32 + static inline base::string16 to_string16(const struct_type* s) { return base::string16(s->str, s->length); } - static inline bool from_string16(const base::string16& str, struct_type *s) { - return cef_string_wide_set(str.c_str(), str.length(), s, true) ? - true : false; + static inline bool from_string16(const base::string16& str, struct_type* s) { + return cef_string_wide_set(str.c_str(), str.length(), s, true) ? true + : false; } #endif // WCHAR_T_IS_UTF32 -#endif // BUILDING_CEF_SHARED }; /// @@ -124,9 +124,11 @@ struct CefStringTraitsUTF8 { 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) { + 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) { @@ -162,7 +164,6 @@ struct CefStringTraitsUTF8 { static inline bool from_wstring(const std::wstring& str, struct_type* s) { return cef_string_wide_to_utf8(str.c_str(), str.length(), s) ? true : false; } -#if defined(BUILDING_CEF_SHARED) static inline base::string16 to_string16(const struct_type* s) { cef_string_utf16_t cstr; memset(&cstr, 0, sizeof(cstr)); @@ -174,10 +175,9 @@ struct CefStringTraitsUTF8 { return str; } static inline bool from_string16(const base::string16& str, struct_type* s) { - return cef_string_utf16_to_utf8(str.c_str(), str.length(), s) ? - true : false; + return cef_string_utf16_to_utf8(str.c_str(), str.length(), s) ? true + : false; } -#endif // BUILDING_CEF_SHARED }; /// @@ -188,9 +188,11 @@ struct CefStringTraitsUTF16 { 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) { + 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) { @@ -218,8 +220,8 @@ struct CefStringTraitsUTF16 { return str; } static inline bool from_string(const std::string& str, struct_type* s) { - return cef_string_utf8_to_utf16(str.c_str(), str.length(), s) ? - true : false; + return cef_string_utf8_to_utf16(str.c_str(), str.length(), s) ? true + : false; } #if defined(WCHAR_T_IS_UTF32) static inline std::wstring to_wstring(const struct_type* s) { @@ -233,27 +235,25 @@ struct CefStringTraitsUTF16 { return str; } static inline bool from_wstring(const std::wstring& str, struct_type* s) { - return cef_string_wide_to_utf16(str.c_str(), str.length(), s) ? - true : false; + return cef_string_wide_to_utf16(str.c_str(), str.length(), s) ? true + : false; } -#else // WCHAR_T_IS_UTF32 +#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& str, struct_type* s) { - return cef_string_utf16_set(str.c_str(), str.length(), s, true) ? - true : false; + return cef_string_utf16_set(str.c_str(), str.length(), s, true) ? true + : false; } #endif // WCHAR_T_IS_UTF32 -#if defined(BUILDING_CEF_SHARED) static inline base::string16 to_string16(const struct_type* s) { return base::string16(s->str, s->length); } static inline bool from_string16(const base::string16& str, struct_type* s) { - return cef_string_utf16_set(str.c_str(), str.length(), s, true) ? - true : false; + return cef_string_utf16_set(str.c_str(), str.length(), s, true) ? true + : false; } -#endif // BUILDING_CEF_SHARED }; /// @@ -299,8 +299,7 @@ class CefStringBase { /// // Create a new string from an existing string. Data will always be copied. /// - CefStringBase(const CefStringBase& str) - : string_(NULL), owner_(false) { + CefStringBase(const CefStringBase& str) : string_(NULL), owner_(false) { FromString(str.c_str(), str.length(), true); } @@ -309,12 +308,10 @@ class CefStringBase { // copied. Translation will occur if necessary based on the underlying string // type. /// - CefStringBase(const std::string& src) // NOLINT(runtime/explicit) - : string_(NULL), owner_(false) { + CefStringBase(const std::string& src) : string_(NULL), owner_(false) { FromString(src); } - CefStringBase(const char* src) // NOLINT(runtime/explicit) - : string_(NULL), owner_(false) { + CefStringBase(const char* src) : string_(NULL), owner_(false) { if (src) FromString(std::string(src)); } @@ -324,32 +321,28 @@ class CefStringBase { // copied. Translation will occur if necessary based on the underlying string // type. /// - CefStringBase(const std::wstring& src) // NOLINT(runtime/explicit) - : string_(NULL), owner_(false) { + CefStringBase(const std::wstring& src) : string_(NULL), owner_(false) { FromWString(src); } - CefStringBase(const wchar_t* src) // NOLINT(runtime/explicit) - : string_(NULL), owner_(false) { + CefStringBase(const wchar_t* src) : string_(NULL), owner_(false) { if (src) FromWString(std::wstring(src)); } -#if (defined(BUILDING_CEF_SHARED) && defined(WCHAR_T_IS_UTF32)) +#if defined(WCHAR_T_IS_UTF32) /// // 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 base::string16& src) // NOLINT(runtime/explicit) - : string_(NULL), owner_(false) { + CefStringBase(const base::string16& src) : string_(NULL), owner_(false) { FromString16(src); } - CefStringBase(const char16* src) // NOLINT(runtime/explicit) - : string_(NULL), owner_(false) { + CefStringBase(const char16* src) : string_(NULL), owner_(false) { if (src) FromString16(base::string16(src)); } -#endif // BUILDING_CEF_SHARED && WCHAR_T_IS_UTF32 +#endif // WCHAR_T_IS_UTF32 /// // Create a new string from an existing character array. If |copy| is true @@ -358,7 +351,7 @@ class CefStringBase { // and will not be freed by this class. /// CefStringBase(const char_type* src, size_t src_len, bool copy) - : string_(NULL), owner_(false) { + : string_(NULL), owner_(false) { if (src && src_len > 0) FromString(src, src_len, copy); } @@ -368,8 +361,7 @@ class CefStringBase { // ownership. Referenced structures must exist for the lifetime of this class // and will not be freed by this class. /// - CefStringBase(const struct_type* src) // NOLINT(runtime/explicit) - : string_(NULL), owner_(false) { + CefStringBase(const struct_type* src) : string_(NULL), owner_(false) { if (!src) return; // Reference the existing structure without taking ownership. @@ -378,7 +370,6 @@ class CefStringBase { virtual ~CefStringBase() { ClearAndFree(); } - // The following methods are named for compatibility with the standard library // string template types. @@ -435,7 +426,6 @@ class CefStringBase { str.owner_ = tmp_owner; } - // The following methods are unique to CEF string template types. /// @@ -612,7 +602,7 @@ class CefStringBase { AllocIfNeeded(); return traits::from_wstring(str, string_); } -#if defined(BUILDING_CEF_SHARED) + /// // Return this string's data as a string16. Translation will occur if // necessary based on the underlying string type. @@ -636,20 +626,15 @@ class CefStringBase { AllocIfNeeded(); return traits::from_string16(str, string_); } -#endif // BUILDING_CEF_SHARED /// // 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); } @@ -667,9 +652,7 @@ class CefStringBase { FromString(str.c_str(), str.length(), true); return *this; } - operator std::string() const { - return ToString(); - } + operator std::string() const { return ToString(); } CefStringBase& operator=(const std::string& str) { FromString(str); return *this; @@ -678,9 +661,7 @@ class CefStringBase { FromString(std::string(str)); return *this; } - operator std::wstring() const { - return ToWString(); - } + operator std::wstring() const { return ToWString(); } CefStringBase& operator=(const std::wstring& str) { FromWString(str); return *this; @@ -689,10 +670,8 @@ class CefStringBase { FromWString(std::wstring(str)); return *this; } -#if (defined(BUILDING_CEF_SHARED) && defined(WCHAR_T_IS_UTF32)) - operator base::string16() const { - return ToString16(); - } +#if defined(WCHAR_T_IS_UTF32) + operator base::string16() const { return ToString16(); } CefStringBase& operator=(const base::string16& str) { FromString16(str); return *this; @@ -701,7 +680,18 @@ class CefStringBase { FromString16(base::string16(str)); return *this; } -#endif // BUILDING_CEF_SHARED && WCHAR_T_IS_UTF32 +#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. @@ -717,7 +707,6 @@ class CefStringBase { bool owner_; }; - typedef CefStringBase CefStringWide; typedef CefStringBase CefStringUTF8; typedef CefStringBase CefStringUTF16; diff --git a/include/internal/cef_thread_internal.h b/include/internal/cef_thread_internal.h new file mode 100644 index 0000000..f326bcd --- /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 +#elif defined(OS_POSIX) +#include +#include +#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(); + +#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(); + +#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 index 64e601f..5435e59 100644 --- a/include/internal/cef_time.h +++ b/include/internal/cef_time.h @@ -35,14 +35,15 @@ extern "C" { #endif -#include "include/internal/cef_export.h" #include +#include "include/internal/cef_export.h" /// // Time information. Values should always be in UTC. /// typedef struct _cef_time_t { - int year; // Four digit year "2007" + int year; // Four or five digit year "2007" (1601 to 30827 on + // Windows, 1970 to 2038 on 32-bit POSIX) int month; // 1-based month (values 1 = January, etc.) int day_of_week; // 0-based day of week (0 = Sunday, etc.) int day_of_month; // 1-based day of month (1-31) diff --git a/include/internal/cef_trace_event_internal.h b/include/internal/cef_trace_event_internal.h new file mode 100644 index 0000000..6df8707 --- /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_tuple.h b/include/internal/cef_tuple.h deleted file mode 100644 index c2cdf70..0000000 --- a/include/internal/cef_tuple.h +++ /dev/null @@ -1,1088 +0,0 @@ -// Copyright (c) 2006-2011 Google Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the name Chromium Embedded -// Framework nor the names of its contributors may be used to endorse -// or promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// The contents of this file are identical to base/tuple.h - -// A Tuple is a generic templatized container, similar in concept to std::pair. -// There are classes Tuple0 to Tuple6, cooresponding to the number of elements -// it contains. The convenient MakeTuple() function takes 0 to 6 arguments, -// and will construct and return the appropriate Tuple object. The functions -// DispatchToMethod and DispatchToFunction take a function pointer or instance -// and method pointer, and unpack a tuple into arguments to the call. -// -// Tuple elements are copied by value, and stored in the tuple. See the unit -// tests for more details of how/when the values are copied. -// -// Example usage: -// // These two methods of creating a Tuple are identical. -// Tuple2 tuple_a(1, "wee"); -// Tuple2 tuple_b = MakeTuple(1, "wee"); -// -// void SomeFunc(int a, const char* b) { } -// DispatchToFunction(&SomeFunc, tuple_a); // SomeFunc(1, "wee") -// DispatchToFunction( -// &SomeFunc, MakeTuple(10, "foo")); // SomeFunc(10, "foo") -// -// struct { void SomeMeth(int a, int b, int c) { } } foo; -// DispatchToMethod(&foo, &Foo::SomeMeth, MakeTuple(1, 2, 3)); -// // foo->SomeMeth(1, 2, 3); - -#ifndef CEF_INCLUDE_INTERNAL_CEF_TUPLE_H_ -#define CEF_INCLUDE_INTERNAL_CEF_TUPLE_H_ -#pragma once - -// If base/tuple.h is included first then exclude this file. This is to -// facilitate the use of both base/bind.h and cef_runnable.h in unit tests. -#ifndef BASE_TUPLE_H__ - -#if defined(OS_CHROMEOS) -// To troubleshoot crosbug.com/7327. -#include "base/logging.h" -#endif -// Traits ---------------------------------------------------------------------- -// -// A simple traits class for tuple arguments. -// -// ValueType: the bare, nonref version of a type (same as the type for nonrefs). -// RefType: the ref version of a type (same as the type for refs). -// ParamType: what type to pass to functions (refs should not be constified). - -template -struct TupleTraits { - typedef P ValueType; - typedef P& RefType; - typedef const P& ParamType; -}; - -template -struct TupleTraits { - typedef P ValueType; - typedef P& RefType; - typedef P& ParamType; -}; - -template -struct TupleTypes { }; - -// Tuple ----------------------------------------------------------------------- -// -// This set of classes is useful for bundling 0 or more heterogeneous data types -// into a single variable. The advantage of this is that it greatly simplifies -// function objects that need to take an arbitrary number of parameters; see -// RunnableMethod and IPC::MessageWithTuple. -// -// Tuple0 is supplied to act as a 'void' type. It can be used, for example, -// when dispatching to a function that accepts no arguments (see the -// Dispatchers below). -// Tuple1 is rarely useful. One such use is when A is non-const ref that you -// want filled by the dispatchee, and the tuple is merely a container for that -// output (a "tier"). See MakeRefTuple and its usages. - -struct Tuple0 { - typedef Tuple0 ValueTuple; - typedef Tuple0 RefTuple; - typedef Tuple0 ParamTuple; -}; - -template -struct Tuple1 { - public: - typedef A TypeA; - - Tuple1() {} - explicit Tuple1(typename TupleTraits::ParamType a) : a(a) {} - - A a; -}; - -template -struct Tuple2 { - public: - typedef A TypeA; - typedef B TypeB; - - Tuple2() {} - Tuple2(typename TupleTraits::ParamType a, - typename TupleTraits::ParamType b) - : a(a), b(b) { - } - - A a; - B b; -}; - -template -struct Tuple3 { - public: - typedef A TypeA; - typedef B TypeB; - typedef C TypeC; - - Tuple3() {} - Tuple3(typename TupleTraits::ParamType a, - typename TupleTraits::ParamType b, - typename TupleTraits::ParamType c) - : a(a), b(b), c(c) { - } - - A a; - B b; - C c; -}; - -template -struct Tuple4 { - public: - typedef A TypeA; - typedef B TypeB; - typedef C TypeC; - typedef D TypeD; - - Tuple4() {} - Tuple4(typename TupleTraits::ParamType a, - typename TupleTraits::ParamType b, - typename TupleTraits::ParamType c, - typename TupleTraits::ParamType d) - : a(a), b(b), c(c), d(d) { - } - - A a; - B b; - C c; - D d; -}; - -template -struct Tuple5 { - public: - typedef A TypeA; - typedef B TypeB; - typedef C TypeC; - typedef D TypeD; - typedef E TypeE; - - Tuple5() {} - Tuple5(typename TupleTraits::ParamType a, - typename TupleTraits::ParamType b, - typename TupleTraits::ParamType c, - typename TupleTraits::ParamType d, - typename TupleTraits::ParamType e) - : a(a), b(b), c(c), d(d), e(e) { - } - - A a; - B b; - C c; - D d; - E e; -}; - -template -struct Tuple6 { - public: - typedef A TypeA; - typedef B TypeB; - typedef C TypeC; - typedef D TypeD; - typedef E TypeE; - typedef F TypeF; - - Tuple6() {} - Tuple6(typename TupleTraits::ParamType a, - typename TupleTraits::ParamType b, - typename TupleTraits::ParamType c, - typename TupleTraits::ParamType d, - typename TupleTraits::ParamType e, - typename TupleTraits::ParamType f) - : a(a), b(b), c(c), d(d), e(e), f(f) { - } - - A a; - B b; - C c; - D d; - E e; - F f; -}; - -template -struct Tuple7 { - public: - typedef A TypeA; - typedef B TypeB; - typedef C TypeC; - typedef D TypeD; - typedef E TypeE; - typedef F TypeF; - typedef G TypeG; - - Tuple7() {} - Tuple7(typename TupleTraits::ParamType a, - typename TupleTraits::ParamType b, - typename TupleTraits::ParamType c, - typename TupleTraits::ParamType d, - typename TupleTraits::ParamType e, - typename TupleTraits::ParamType f, - typename TupleTraits::ParamType g) - : a(a), b(b), c(c), d(d), e(e), f(f), g(g) { - } - - A a; - B b; - C c; - D d; - E e; - F f; - G g; -}; - -template -struct Tuple8 { - public: - typedef A TypeA; - typedef B TypeB; - typedef C TypeC; - typedef D TypeD; - typedef E TypeE; - typedef F TypeF; - typedef G TypeG; - typedef H TypeH; - - Tuple8() {} - Tuple8(typename TupleTraits::ParamType a, - typename TupleTraits::ParamType b, - typename TupleTraits::ParamType c, - typename TupleTraits::ParamType d, - typename TupleTraits::ParamType e, - typename TupleTraits::ParamType f, - typename TupleTraits::ParamType g, - typename TupleTraits::ParamType h) - : a(a), b(b), c(c), d(d), e(e), f(f), g(g), h(h) { - } - - A a; - B b; - C c; - D d; - E e; - F f; - G g; - H h; -}; - -// Tuple types ---------------------------------------------------------------- -// -// Allows for selection of ValueTuple/RefTuple/ParamTuple without needing the -// definitions of class types the tuple takes as parameters. - -template <> -struct TupleTypes< Tuple0 > { - typedef Tuple0 ValueTuple; - typedef Tuple0 RefTuple; - typedef Tuple0 ParamTuple; -}; - -template -struct TupleTypes< Tuple1 > { - typedef Tuple1::ValueType> ValueTuple; - typedef Tuple1::RefType> RefTuple; - typedef Tuple1::ParamType> ParamTuple; -}; - -template -struct TupleTypes< Tuple2 > { - typedef Tuple2::ValueType, - typename TupleTraits::ValueType> ValueTuple; -typedef Tuple2::RefType, - typename TupleTraits::RefType> RefTuple; - typedef Tuple2::ParamType, - typename TupleTraits::ParamType> ParamTuple; -}; - -template -struct TupleTypes< Tuple3 > { - typedef Tuple3::ValueType, - typename TupleTraits::ValueType, - typename TupleTraits::ValueType> ValueTuple; -typedef Tuple3::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType> RefTuple; - typedef Tuple3::ParamType, - typename TupleTraits::ParamType, - typename TupleTraits::ParamType> ParamTuple; -}; - -template -struct TupleTypes< Tuple4 > { - typedef Tuple4::ValueType, - typename TupleTraits::ValueType, - typename TupleTraits::ValueType, - typename TupleTraits::ValueType> ValueTuple; -typedef Tuple4::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType> RefTuple; - typedef Tuple4::ParamType, - typename TupleTraits::ParamType, - typename TupleTraits::ParamType, - typename TupleTraits::ParamType> ParamTuple; -}; - -template -struct TupleTypes< Tuple5 > { - typedef Tuple5::ValueType, - typename TupleTraits::ValueType, - typename TupleTraits::ValueType, - typename TupleTraits::ValueType, - typename TupleTraits::ValueType> ValueTuple; -typedef Tuple5::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType> RefTuple; - typedef Tuple5::ParamType, - typename TupleTraits::ParamType, - typename TupleTraits::ParamType, - typename TupleTraits::ParamType, - typename TupleTraits::ParamType> ParamTuple; -}; - -template -struct TupleTypes< Tuple6 > { - typedef Tuple6::ValueType, - typename TupleTraits::ValueType, - typename TupleTraits::ValueType, - typename TupleTraits::ValueType, - typename TupleTraits::ValueType, - typename TupleTraits::ValueType> ValueTuple; -typedef Tuple6::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType> RefTuple; - typedef Tuple6::ParamType, - typename TupleTraits::ParamType, - typename TupleTraits::ParamType, - typename TupleTraits::ParamType, - typename TupleTraits::ParamType, - typename TupleTraits::ParamType> ParamTuple; -}; - -template -struct TupleTypes< Tuple7 > { - typedef Tuple7::ValueType, - typename TupleTraits::ValueType, - typename TupleTraits::ValueType, - typename TupleTraits::ValueType, - typename TupleTraits::ValueType, - typename TupleTraits::ValueType, - typename TupleTraits::ValueType> ValueTuple; -typedef Tuple7::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType> RefTuple; - typedef Tuple7::ParamType, - typename TupleTraits::ParamType, - typename TupleTraits::ParamType, - typename TupleTraits::ParamType, - typename TupleTraits::ParamType, - typename TupleTraits::ParamType, - typename TupleTraits::ParamType> ParamTuple; -}; - -template -struct TupleTypes< Tuple8 > { - typedef Tuple8::ValueType, - typename TupleTraits::ValueType, - typename TupleTraits::ValueType, - typename TupleTraits::ValueType, - typename TupleTraits::ValueType, - typename TupleTraits::ValueType, - typename TupleTraits::ValueType, - typename TupleTraits::ValueType> ValueTuple; -typedef Tuple8::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType> RefTuple; - typedef Tuple8::ParamType, - typename TupleTraits::ParamType, - typename TupleTraits::ParamType, - typename TupleTraits::ParamType, - typename TupleTraits::ParamType, - typename TupleTraits::ParamType, - typename TupleTraits::ParamType, - typename TupleTraits::ParamType> ParamTuple; -}; - -// Tuple creators ------------------------------------------------------------- -// -// Helper functions for constructing tuples while inferring the template -// argument types. - -inline Tuple0 MakeTuple() { - return Tuple0(); -} - -template -inline Tuple1 MakeTuple(const A& a) { - return Tuple1(a); -} - -template -inline Tuple2 MakeTuple(const A& a, const B& b) { - return Tuple2(a, b); -} - -template -inline Tuple3 MakeTuple(const A& a, const B& b, const C& c) { - return Tuple3(a, b, c); -} - -template -inline Tuple4 MakeTuple(const A& a, const B& b, const C& c, - const D& d) { - return Tuple4(a, b, c, d); -} - -template -inline Tuple5 MakeTuple(const A& a, const B& b, const C& c, - const D& d, const E& e) { - return Tuple5(a, b, c, d, e); -} - -template -inline Tuple6 MakeTuple(const A& a, const B& b, const C& c, - const D& d, const E& e, const F& f) { - return Tuple6(a, b, c, d, e, f); -} - -template -inline Tuple7 MakeTuple(const A& a, const B& b, const C& c, - const D& d, const E& e, const F& f, - const G& g) { - return Tuple7(a, b, c, d, e, f, g); -} - -template -inline Tuple8 MakeTuple(const A& a, const B& b, - const C& c, const D& d, - const E& e, const F& f, - const G& g, const H& h) { - return Tuple8(a, b, c, d, e, f, g, h); -} - -// The following set of helpers make what Boost refers to as "Tiers" - a tuple -// of references. - -template -inline Tuple1 MakeRefTuple(A& a) { - return Tuple1(a); -} - -template -inline Tuple2 MakeRefTuple(A& a, B& b) { - return Tuple2(a, b); -} - -template -inline Tuple3 MakeRefTuple(A& a, B& b, C& c) { - return Tuple3(a, b, c); -} - -template -inline Tuple4 MakeRefTuple(A& a, B& b, C& c, D& d) { - return Tuple4(a, b, c, d); -} - -template -inline Tuple5 MakeRefTuple(A& a, B& b, C& c, D& d, E& e) { - return Tuple5(a, b, c, d, e); -} - -template -inline Tuple6 MakeRefTuple(A& a, B& b, C& c, D& d, E& e, - F& f) { - return Tuple6(a, b, c, d, e, f); -} - -template -inline Tuple7 MakeRefTuple(A& a, B& b, C& c, D& d, - E& e, F& f, G& g) { - return Tuple7(a, b, c, d, e, f, g); -} - -template -inline Tuple8 MakeRefTuple(A& a, B& b, C& c, - D& d, E& e, F& f, - G& g, H& h) { - return Tuple8(a, b, c, d, e, f, g, h); -} - -// Dispatchers ---------------------------------------------------------------- -// -// Helper functions that call the given method on an object, with the unpacked -// tuple arguments. Notice that they all have the same number of arguments, -// so you need only write: -// DispatchToMethod(object, &Object::method, args); -// This is very useful for templated dispatchers, since they don't need to know -// what type |args| is. - -// Non-Static Dispatchers with no out params. - -template -inline void DispatchToMethod(ObjT* obj, Method method, const Tuple0& arg) { - (obj->*method)(); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, const A& arg) { - (obj->*method)(arg); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, const Tuple1& arg) { -#if defined(OS_CHROMEOS) - // To troubleshoot crosbug.com/7327. - CHECK(obj); - CHECK(&arg); - CHECK(method); -#endif - (obj->*method)(arg.a); -} - -template -inline void DispatchToMethod(ObjT* obj, - Method method, - const Tuple2& arg) { - (obj->*method)(arg.a, arg.b); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple3& arg) { - (obj->*method)(arg.a, arg.b, arg.c); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple4& arg) { - (obj->*method)(arg.a, arg.b, arg.c, arg.d); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple5& arg) { - (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple6& arg) { - (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple7& arg) { - (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f, arg.g); -} - -// Static Dispatchers with no out params. - -template -inline void DispatchToFunction(Function function, const Tuple0& arg) { - (*function)(); -} - -template -inline void DispatchToFunction(Function function, const A& arg) { - (*function)(arg); -} - -template -inline void DispatchToFunction(Function function, const Tuple1& arg) { - (*function)(arg.a); -} - -template -inline void DispatchToFunction(Function function, const Tuple2& arg) { - (*function)(arg.a, arg.b); -} - -template -inline void DispatchToFunction(Function function, const Tuple3& arg) { - (*function)(arg.a, arg.b, arg.c); -} - -template -inline void DispatchToFunction(Function function, - const Tuple4& arg) { - (*function)(arg.a, arg.b, arg.c, arg.d); -} - -template -inline void DispatchToFunction(Function function, - const Tuple5& arg) { - (*function)(arg.a, arg.b, arg.c, arg.d, arg.e); -} - -template -inline void DispatchToFunction(Function function, - const Tuple6& arg) { - (*function)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f); -} - -template -inline void DispatchToFunction(Function function, - const Tuple7& arg) { - (*function)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f, arg.g); -} - -template -inline void DispatchToFunction(Function function, - const Tuple8& arg) { - (*function)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f, arg.g, arg.h); -} - -// Dispatchers with 0 out param (as a Tuple0). - -template -inline void DispatchToMethod(ObjT* obj, - Method method, - const Tuple0& arg, Tuple0*) { - (obj->*method)(); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, const A& arg, Tuple0*) { - (obj->*method)(arg); -} - -template -inline void DispatchToMethod(ObjT* obj, - Method method, - const Tuple1& arg, Tuple0*) { - (obj->*method)(arg.a); -} - -template -inline void DispatchToMethod(ObjT* obj, - Method method, - const Tuple2& arg, Tuple0*) { - (obj->*method)(arg.a, arg.b); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple3& arg, Tuple0*) { - (obj->*method)(arg.a, arg.b, arg.c); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple4& arg, Tuple0*) { - (obj->*method)(arg.a, arg.b, arg.c, arg.d); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple5& arg, Tuple0*) { - (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple6& arg, Tuple0*) { - (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f); -} - -// Dispatchers with 1 out param. - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple0& in, - Tuple1* out) { - (obj->*method)(&out->a); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const InA& in, - Tuple1* out) { - (obj->*method)(in, &out->a); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple1& in, - Tuple1* out) { - (obj->*method)(in.a, &out->a); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple2& in, - Tuple1* out) { - (obj->*method)(in.a, in.b, &out->a); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple3& in, - Tuple1* out) { - (obj->*method)(in.a, in.b, in.c, &out->a); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple4& in, - Tuple1* out) { - (obj->*method)(in.a, in.b, in.c, in.d, &out->a); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple5& in, - Tuple1* out) { - (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple6& in, - Tuple1* out) { - (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, &out->a); -} - -// Dispatchers with 2 out params. - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple0& in, - Tuple2* out) { - (obj->*method)(&out->a, &out->b); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const InA& in, - Tuple2* out) { - (obj->*method)(in, &out->a, &out->b); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple1& in, - Tuple2* out) { - (obj->*method)(in.a, &out->a, &out->b); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple2& in, - Tuple2* out) { - (obj->*method)(in.a, in.b, &out->a, &out->b); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple3& in, - Tuple2* out) { - (obj->*method)(in.a, in.b, in.c, &out->a, &out->b); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple4& in, - Tuple2* out) { - (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple5& in, - Tuple2* out) { - (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a, &out->b); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple6& in, - Tuple2* out) { - (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, &out->a, &out->b); -} - -// Dispatchers with 3 out params. - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple0& in, - Tuple3* out) { - (obj->*method)(&out->a, &out->b, &out->c); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const InA& in, - Tuple3* out) { - (obj->*method)(in, &out->a, &out->b, &out->c); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple1& in, - Tuple3* out) { - (obj->*method)(in.a, &out->a, &out->b, &out->c); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple2& in, - Tuple3* out) { - (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple3& in, - Tuple3* out) { - (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple4& in, - Tuple3* out) { - (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple5& in, - Tuple3* out) { - (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a, &out->b, &out->c); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple6& in, - Tuple3* out) { - (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, &out->a, &out->b, &out->c); -} - -// Dispatchers with 4 out params. - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple0& in, - Tuple4* out) { - (obj->*method)(&out->a, &out->b, &out->c, &out->d); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const InA& in, - Tuple4* out) { - (obj->*method)(in, &out->a, &out->b, &out->c, &out->d); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple1& in, - Tuple4* out) { - (obj->*method)(in.a, &out->a, &out->b, &out->c, &out->d); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple2& in, - Tuple4* out) { - (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c, &out->d); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple3& in, - Tuple4* out) { - (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c, &out->d); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple4& in, - Tuple4* out) { - (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c, &out->d); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple5& in, - Tuple4* out) { - (obj->*method)(in.a, in.b, in.c, in.d, in.e, - &out->a, &out->b, &out->c, &out->d); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple6& in, - Tuple4* out) { - (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, - &out->a, &out->b, &out->c, &out->d); -} - -// Dispatchers with 5 out params. - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple0& in, - Tuple5* out) { - (obj->*method)(&out->a, &out->b, &out->c, &out->d, &out->e); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const InA& in, - Tuple5* out) { - (obj->*method)(in, &out->a, &out->b, &out->c, &out->d, &out->e); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple1& in, - Tuple5* out) { - (obj->*method)(in.a, &out->a, &out->b, &out->c, &out->d, &out->e); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple2& in, - Tuple5* out) { - (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c, &out->d, &out->e); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple3& in, - Tuple5* out) { - (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c, &out->d, &out->e); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple4& in, - Tuple5* out) { - (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c, &out->d, - &out->e); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple5& in, - Tuple5* out) { - (obj->*method)(in.a, in.b, in.c, in.d, in.e, - &out->a, &out->b, &out->c, &out->d, &out->e); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple6& in, - Tuple5* out) { - (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, - &out->a, &out->b, &out->c, &out->d, &out->e); -} - -#endif // BASE_TUPLE_H__ - -#endif // CEF_INCLUDE_INTERNAL_CEF_TUPLE_H_ diff --git a/include/internal/cef_types.h b/include/internal/cef_types.h index cf8eb39..cb04000 100644 --- a/include/internal/cef_types.h +++ b/include/internal/cef_types.h @@ -27,12 +27,11 @@ // (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/internal/cef_build.h" +#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" @@ -46,77 +45,36 @@ #include "include/internal/cef_types_linux.h" #endif -#include // For UINT_MAX -#include // For size_t - -// The NSPR system headers define 64-bit as |long| when possible, except on -// Mac OS X. In order to not have typedef mismatches, we do the same on LP64. -// -// On Mac OS X, |long long| is used for 64-bit types for compatibility with -// format macros even in the LP64 model. -#if defined(__LP64__) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) -typedef long int64; // NOLINT(runtime/int) -typedef unsigned long uint64; // NOLINT(runtime/int) -#else -typedef long long int64; // NOLINT(runtime/int) -typedef unsigned long long uint64; // NOLINT(runtime/int) -#endif - -// TODO: Remove these type guards. These are to avoid conflicts with -// obsolete/protypes.h in the Gecko SDK. -#ifndef _INT32 -#define _INT32 -typedef int int32; -#endif - -// TODO: Remove these type guards. These are to avoid conflicts with -// obsolete/protypes.h in the Gecko SDK. -#ifndef _UINT32 -#define _UINT32 -typedef unsigned int uint32; -#endif - -// UTF-16 character type -#ifndef char16 -#if defined(WIN32) -typedef wchar_t char16; -#else -typedef unsigned short char16; -#endif -#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; +typedef uint32 cef_color_t; // Return the alpha byte from a cef_color_t value. -#define CefColorGetA(color) (((color) >> 24) & 0xFF) +#define CefColorGetA(color) (((color) >> 24) & 0xFF) // Return the red byte from a cef_color_t value. -#define CefColorGetR(color) (((color) >> 16) & 0xFF) +#define CefColorGetR(color) (((color) >> 16) & 0xFF) // Return the green byte from a cef_color_t value. -#define CefColorGetG(color) (((color) >> 8) & 0xFF) +#define CefColorGetG(color) (((color) >> 8) & 0xFF) // Return the blue byte from a cef_color_t value. -#define CefColorGetB(color) (((color) >> 0) & 0xFF) +#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( \ - (static_cast(a) << 24) | \ - (static_cast(r) << 16) | \ - (static_cast(g) << 8) | \ - (static_cast(b) << 0)) +#define CefColorSetARGB(a, r, g, b) \ + static_cast( \ + (static_cast(a) << 24) | (static_cast(r) << 16) | \ + (static_cast(g) << 8) | (static_cast(b) << 0)) // Return an int64 value with the specified low and high int32 component values. -#define CefInt64Set(int32_low, int32_high) \ - static_cast((static_cast(int32_low)) | \ - (static_cast(static_cast(int32_high))) << 32) +#define CefInt64Set(int32_low, int32_high) \ + static_cast((static_cast(int32_low)) | \ + (static_cast(static_cast(int32_high))) \ + << 32) // Return the low int32 value from an int64 value. #define CefInt64GetLow(int64_val) static_cast(int64_val) // Return the high int32 value from an int64 value. #define CefInt64GetHigh(int64_val) \ - static_cast((static_cast(int64_val) >> 32) & 0xFFFFFFFFL) - + static_cast((static_cast(int64_val) >> 32) & 0xFFFFFFFFL) #ifdef __cplusplus extern "C" { @@ -151,11 +109,6 @@ typedef enum { /// LOGSEVERITY_ERROR, - /// - // ERROR_REPORT logging. - /// - LOGSEVERITY_ERROR_REPORT, - /// // Completely disable logging. /// @@ -210,19 +163,50 @@ typedef struct _cef_settings_t { /// // The path to a separate executable that will be launched for sub-processes. - // By default the browser process executable is used. See the comments on - // CefExecuteProcess() for details. Also configurable using the - // "browser-subprocess-path" command-line switch. + // 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/ Helper.app/Contents/MacOS/ Helper" + // in the top-level app bundle. See the comments on CefExecuteProcess() for + // details. 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. Also configurable using + // the "framework-dir-path" command-line switch. + /// + cef_string_t framework_dir_path; + /// // Set to true (1) to have the browser process message loop run in a separate // thread. If false (0) than the CefDoMessageLoopWork() function must be - // called from your application message loop. + // called from your application message loop. This option is only supported on + // Windows. /// 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 @@ -232,23 +216,47 @@ typedef struct _cef_settings_t { int command_line_args_disabled; /// - // The location where cache data will be stored on disk. If empty an in-memory - // cache will be used for some features and a temporary disk cache for others. - // HTML5 databases such as localStorage will only persist across sessions if a - // cache path is specified. + // The location where cache data will be stored on disk. If 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. /// cef_string_t cache_path; + /// + // The location where user data such as spell checking dictionary files will + // be stored on disk. If empty then the default platform-specific user data + // directory will be used ("~/.cef_user_data" directory on Linux, + // "~/Library/Application Support/CEF/User Data" directory on Mac OS X, + // "Local Settings\Application Data\CEF\User Data" directory under the user + // profile directory on Windows). + /// + 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. 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. + // 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 @@ -274,10 +282,12 @@ typedef struct _cef_settings_t { cef_string_t locale; /// - // The directory and file name to use for the debug log. If empty, the - // default name of "debug.log" will be used and the file will be written - // to the application directory. Also configurable using the "log-file" - // command-line switch. + // 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 Mac OS X a + // "~/Library/Logs/_debug.log" file will be written where + // is the name of the main app executable. Also configurable using the + // "log-file" command-line switch. /// cef_string_t log_file; @@ -289,12 +299,6 @@ typedef struct _cef_settings_t { /// cef_log_severity_t log_severity; - /// - // Enable DCHECK in release mode to ease debugging. Also configurable using the - // "enable-release-dcheck" command-line switch. - /// - int release_dcheck_enabled; - /// // Custom flags that will be used when initializing the V8 JavaScript engine. // The consequences of using custom flags may not be well tested. Also @@ -340,53 +344,130 @@ typedef struct _cef_settings_t { /// // The number of stack trace frames to capture for uncaught exceptions. - // Specify a positive value to enable the CefV8ContextHandler:: + // 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; - /// - // By default CEF V8 references will be invalidated (the IsValid() method will - // return false) after the owning context has been released. This reduces the - // need for external record keeping and avoids crashes due to the use of V8 - // references after the associated context has been released. - // - // CEF currently offers two context safety implementations with different - // performance characteristics. The default implementation (value of 0) uses a - // map of hash values and should provide better performance in situations with - // a small number contexts. The alternate implementation (value of 1) uses a - // hidden value attached to each context and should provide better performance - // in situations with a large number of contexts. - // - // If you need better performance in the creation of V8 references and you - // plan to manually track context lifespan you can disable context safety by - // specifying a value of -1. - // - // Also configurable using the "context-safety-implementation" command-line - // switch. - /// - int context_safety_implementation; - /// // Set to true (1) to ignore errors related to invalid SSL certificates. // Enabling this setting can lead to potential security vulnerabilities like // "man in the middle" attacks. Applications that load content from the // internet should not enable this setting. Also configurable using the - // "ignore-certificate-errors" command-line switch. + // "ignore-certificate-errors" command-line switch. Can be overridden for + // individual CefRequestContext instances via the + // CefRequestContextSettings.ignore_certificate_errors value. /// int ignore_certificate_errors; /// - // Opaque background color used for accelerated content. By default the - // background color will be white. Only the RGB compontents of the specified - // value will be used. The alpha component must greater than 0 to enable use - // of the background color but will be otherwise ignored. + // Set to true (1) to enable date-based expiration of built in network + // security information (i.e. certificate transparency logs, HSTS preloading + // and pinning information). Enabling this option improves network security + // but may cause HTTPS load failures when using CEF binaries built more than + // 10 weeks in the past. See https://www.certificate-transparency.org/ and + // https://www.chromium.org/hsts for details. Also configurable using the + // "enable-net-security-expiration" command-line switch. Can be overridden for + // individual CefRequestContext instances via the + // CefRequestContextSettings.enable_net_security_expiration value. + /// + int enable_net_security_expiration; + + /// + // 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; } 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 will be stored on disk. If 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; + + /// + // Set to true (1) to ignore errors related to invalid SSL certificates. + // Enabling this setting can lead to potential security vulnerabilities like + // "man in the middle" attacks. Applications that load content from the + // internet should not enable this setting. Can be set globally using the + // CefSettings.ignore_certificate_errors value. This value will be ignored if + // |cache_path| matches the CefSettings.cache_path value. + /// + int ignore_certificate_errors; + + /// + // Set to true (1) to enable date-based expiration of built in network + // security information (i.e. certificate transparency logs, HSTS preloading + // and pinning information). Enabling this option improves network security + // but may cause HTTPS load failures when using CEF binaries built more than + // 10 weeks in the past. See https://www.certificate-transparency.org/ and + // https://www.chromium.org/hsts for details. Can be set globally using the + // CefSettings.enable_net_security_expiration value. + /// + int enable_net_security_expiration; + + /// + // 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; +} 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 @@ -399,6 +480,15 @@ typedef struct _cef_browser_settings_t { /// 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; + // The below values map to WebPreferences settings. /// @@ -443,8 +533,9 @@ typedef struct _cef_browser_settings_t { /// // 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. Also configurable using the - // "disable-javascript-close-windows" command-line switch. + // 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; @@ -462,18 +553,6 @@ typedef struct _cef_browser_settings_t { /// cef_state_t javascript_dom_paste; - /// - // Controls whether the caret position will be drawn. Also configurable using - // the "enable-caret-browsing" command-line switch. - /// - cef_state_t caret_browsing; - - /// - // Controls whether the Java plugin will be loaded. Also configurable using - // the "disable-java" command-line switch. - /// - cef_state_t java; - /// // Controls whether any plugins will be loaded. Also configurable using the // "disable-plugins" command-line switch. @@ -552,14 +631,46 @@ typedef struct _cef_browser_settings_t { cef_state_t webgl; /// - // Controls whether content that depends on accelerated compositing can be - // used. Note that accelerated compositing requires hardware support and may - // not work on all systems even when enabled. Also configurable using the - // "disable-accelerated-compositing" command-line switch. + // 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 CefBrowserSettings.accept_language_list value. If both values are + // empty then "en-US,en" will be used. /// - cef_state_t accelerated_compositing; + cef_string_t accept_language_list; } 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. /// @@ -724,6 +835,18 @@ typedef enum { // 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 Mac OS X. + /// + PK_USER_DATA, } cef_path_key_t; /// @@ -766,6 +889,7 @@ typedef enum { ERR_SSL_VERSION_OR_CIPHER_MISMATCH = -113, ERR_SSL_RENEGOTIATION_REQUESTED = -114, ERR_CERT_COMMON_NAME_INVALID = -200, + ERR_CERT_BEGIN = ERR_CERT_COMMON_NAME_INVALID, ERR_CERT_DATE_INVALID = -201, ERR_CERT_AUTHORITY_INVALID = -202, ERR_CERT_CONTAINS_ERRORS = -203, @@ -773,7 +897,13 @@ typedef enum { ERR_CERT_UNABLE_TO_CHECK_REVOCATION = -205, ERR_CERT_REVOKED = -206, ERR_CERT_INVALID = -207, - ERR_CERT_END = -208, + ERR_CERT_WEAK_SIGNATURE_ALGORITHM = -208, + // -209 is available: was ERR_CERT_NOT_IN_DNS. + ERR_CERT_NON_UNIQUE_NAME = -210, + ERR_CERT_WEAK_KEY = -211, + ERR_CERT_NAME_CONSTRAINT_VIOLATION = -212, + ERR_CERT_VALIDITY_TOO_LONG = -213, + ERR_CERT_END = ERR_CERT_VALIDITY_TOO_LONG, ERR_INVALID_URL = -300, ERR_DISALLOWED_URL_SCHEME = -301, ERR_UNKNOWN_URL_SCHEME = -302, @@ -790,29 +920,79 @@ typedef enum { ERR_INSECURE_RESPONSE = -501, } 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, + WOD_CURRENT_TAB, + WOD_SINGLETON_TAB, + WOD_NEW_FOREGROUND_TAB, + WOD_NEW_BACKGROUND_TAB, + WOD_NEW_POPUP, + WOD_NEW_WINDOW, + WOD_SAVE_TO_DISK, + WOD_OFF_THE_RECORD, + WOD_IGNORE_ACTION +} 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 + 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; /// // 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_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; @@ -820,18 +1000,18 @@ typedef enum { // V8 property attribute values. /// typedef enum { - V8_PROPERTY_ATTRIBUTE_NONE = 0, // Writeable, Enumerable, - // Configurable - V8_PROPERTY_ATTRIBUTE_READONLY = 1 << 0, // Not writeable - V8_PROPERTY_ATTRIBUTE_DONTENUM = 1 << 1, // Not enumerable - V8_PROPERTY_ATTRIBUTE_DONTDELETE = 1 << 2 // Not configurable + V8_PROPERTY_ATTRIBUTE_NONE = 0, // Writeable, Enumerable, + // Configurable + V8_PROPERTY_ATTRIBUTE_READONLY = 1 << 0, // Not writeable + V8_PROPERTY_ATTRIBUTE_DONTENUM = 1 << 1, // Not enumerable + V8_PROPERTY_ATTRIBUTE_DONTDELETE = 1 << 2 // Not configurable } cef_v8_propertyattribute_t; /// // Post data elements may represent either bytes or files. /// typedef enum { - PDE_TYPE_EMPTY = 0, + PDE_TYPE_EMPTY = 0, PDE_TYPE_BYTES, PDE_TYPE_FILE, } cef_postdataelement_type_t; @@ -910,6 +1090,26 @@ typedef enum { // XMLHttpRequest. /// RT_XHR, + + /// + // A request for a + /// + 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, } cef_resource_type_t; /// @@ -1020,50 +1220,35 @@ typedef enum { /// // Default behavior. /// - UR_FLAG_NONE = 0, + UR_FLAG_NONE = 0, /// // If set the cache will be skipped when handling the request. /// - UR_FLAG_SKIP_CACHE = 1 << 0, - - /// - // If set user name, password, and cookies may be sent with the request. - /// - UR_FLAG_ALLOW_CACHED_CREDENTIALS = 1 << 1, + UR_FLAG_SKIP_CACHE = 1 << 0, /// - // If set cookies may be sent with the request and saved from the response. - // UR_FLAG_ALLOW_CACHED_CREDENTIALS must also be set. + // If set user name, password, and cookies may be sent with the request, and + // cookies may be saved from the response. /// - UR_FLAG_ALLOW_COOKIES = 1 << 2, + UR_FLAG_ALLOW_CACHED_CREDENTIALS = 1 << 1, /// // If set upload progress events will be generated when a request has a body. /// - UR_FLAG_REPORT_UPLOAD_PROGRESS = 1 << 3, - - /// - // If set load timing info will be collected for the request. - /// - UR_FLAG_REPORT_LOAD_TIMING = 1 << 4, - - /// - // If set the headers sent and received for the request will be recorded. - /// - UR_FLAG_REPORT_RAW_HEADERS = 1 << 5, + UR_FLAG_REPORT_UPLOAD_PROGRESS = 1 << 3, /// // If set the CefURLRequestClient::OnDownloadData method will not be called. /// - UR_FLAG_NO_DOWNLOAD_DATA = 1 << 6, + UR_FLAG_NO_DOWNLOAD_DATA = 1 << 6, /// // 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 << 7, + UR_FLAG_NO_RETRY_ON_5XX = 1 << 7, } cef_urlrequest_flags_t; /// @@ -1097,6 +1282,14 @@ typedef enum { UR_FAILED, } cef_urlrequest_status_t; +/// +// Structure representing a point. +/// +typedef struct _cef_point_t { + int x; + int y; +} cef_point_t; + /// // Structure representing a rectangle. /// @@ -1107,6 +1300,47 @@ typedef struct _cef_rect_t { int height; } cef_rect_t; +/// +// Structure representing a size. +/// +typedef struct _cef_size_t { + int width; + int height; +} cef_size_t; + +/// +// Structure representing a range. +/// +typedef struct _cef_range_t { + int from; + int to; +} cef_range_t; + +/// +// Structure representing insets. +/// +typedef struct _cef_insets_t { + int top; + int left; + int bottom; + int right; +} cef_insets_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. /// @@ -1125,7 +1359,7 @@ typedef enum { // Existing thread IDs. /// typedef enum { -// BROWSER PROCESS THREADS -- Only available in the browser process. + // BROWSER PROCESS THREADS -- Only available in the browser process. /// // The main thread in the browser. This will be the same as the main @@ -1165,7 +1399,7 @@ typedef enum { /// TID_IO, -// RENDER PROCESS THREADS -- Only available in the render process. + // RENDER PROCESS THREADS -- Only available in the render process. /// // The main thread in the renderer. Used for all WebKit and V8 interaction. @@ -1173,6 +1407,73 @@ typedef enum { 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. /// @@ -1259,38 +1560,53 @@ typedef struct _cef_screen_info_t { /// typedef enum { // Navigation. - MENU_ID_BACK = 100, - MENU_ID_FORWARD = 101, - MENU_ID_RELOAD = 102, - MENU_ID_RELOAD_NOCACHE = 103, - MENU_ID_STOPLOAD = 104, + 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, + 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, + 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. For example, + // plugin placeholder menu items or Flash menu items. + MENU_ID_CUSTOM_FIRST = 220, + MENU_ID_CUSTOM_LAST = 250, // All user-defined menu IDs should come between MENU_ID_USER_FIRST and // MENU_ID_USER_LAST to avoid overlapping the Chromium and CEF ID ranges // defined in the tools/gritsettings/resource_ids file. - MENU_ID_USER_FIRST = 26500, - MENU_ID_USER_LAST = 28500, + MENU_ID_USER_FIRST = 26500, + MENU_ID_USER_LAST = 28500, } cef_menu_id_t; /// // Mouse button types. /// typedef enum { - MBT_LEFT = 0, + MBT_LEFT = 0, MBT_MIDDLE, MBT_RIGHT, } cef_mouse_button_type_t; @@ -1320,7 +1636,7 @@ typedef struct _cef_mouse_event_t { // Paint element types. /// typedef enum { - PET_VIEW = 0, + PET_VIEW = 0, PET_POPUP, } cef_paint_element_type_t; @@ -1328,20 +1644,20 @@ typedef enum { // 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_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, + 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_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, } cef_event_flags_t; /// @@ -1363,31 +1679,31 @@ typedef enum { /// // No node is selected. /// - CM_TYPEFLAG_NONE = 0, + CM_TYPEFLAG_NONE = 0, /// // The top page is selected. /// - CM_TYPEFLAG_PAGE = 1 << 0, + CM_TYPEFLAG_PAGE = 1 << 0, /// // A subframe page is selected. /// - CM_TYPEFLAG_FRAME = 1 << 1, + CM_TYPEFLAG_FRAME = 1 << 1, /// // A link is selected. /// - CM_TYPEFLAG_LINK = 1 << 2, + CM_TYPEFLAG_LINK = 1 << 2, /// // A media node is selected. /// - CM_TYPEFLAG_MEDIA = 1 << 3, + CM_TYPEFLAG_MEDIA = 1 << 3, /// // There is a textual or mixed selection that is selected. /// - CM_TYPEFLAG_SELECTION = 1 << 4, + CM_TYPEFLAG_SELECTION = 1 << 4, /// // An editable element is selected. /// - CM_TYPEFLAG_EDITABLE = 1 << 5, + CM_TYPEFLAG_EDITABLE = 1 << 5, } cef_context_menu_type_flags_t; /// @@ -1424,41 +1740,60 @@ typedef enum { // Supported context menu media state bit flags. /// typedef enum { - CM_MEDIAFLAG_NONE = 0, - CM_MEDIAFLAG_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_HAS_VIDEO = 1 << 6, - CM_MEDIAFLAG_CONTROL_ROOT_ELEMENT = 1 << 7, - CM_MEDIAFLAG_CAN_PRINT = 1 << 8, - CM_MEDIAFLAG_CAN_ROTATE = 1 << 9, + CM_MEDIAFLAG_NONE = 0, + CM_MEDIAFLAG_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_HAS_VIDEO = 1 << 6, + CM_MEDIAFLAG_CONTROL_ROOT_ELEMENT = 1 << 7, + CM_MEDIAFLAG_CAN_PRINT = 1 << 8, + CM_MEDIAFLAG_CAN_ROTATE = 1 << 9, } cef_context_menu_media_state_flags_t; /// // Supported context menu edit state bit flags. /// 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_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, } cef_context_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; @@ -1594,7 +1929,6 @@ typedef struct _cef_popup_features_t { int fullscreen; int dialog; - cef_string_list_t additionalFeatures; } cef_popup_features_t; /// @@ -1628,7 +1962,6 @@ typedef enum { DOM_EVENT_CATEGORY_POPSTATE = 0x2000, DOM_EVENT_CATEGORY_PROGRESS = 0x4000, DOM_EVENT_CATEGORY_XMLHTTPREQUEST_PROGRESS = 0x8000, - DOM_EVENT_CATEGORY_BEFORE_LOAD = 0x10000, } cef_dom_event_category_t; /// @@ -1650,14 +1983,11 @@ typedef enum { DOM_NODE_TYPE_ATTRIBUTE, DOM_NODE_TYPE_TEXT, DOM_NODE_TYPE_CDATA_SECTION, - DOM_NODE_TYPE_ENTITY, DOM_NODE_TYPE_PROCESSING_INSTRUCTIONS, DOM_NODE_TYPE_COMMENT, DOM_NODE_TYPE_DOCUMENT, DOM_NODE_TYPE_DOCUMENT_TYPE, DOM_NODE_TYPE_DOCUMENT_FRAGMENT, - DOM_NODE_TYPE_NOTATION, - DOM_NODE_TYPE_XPATH_NAMESPACE, } cef_dom_node_type_t; /// @@ -1674,11 +2004,36 @@ typedef enum { /// 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, + + /// + // General mask defining the bits used for the type values. + /// + FILE_DIALOG_TYPE_MASK = 0xFF, + + // Qualifiers. + // Any of the type values above can be augmented by one or more qualifiers. + // These qualifiers further define the dialog behavior. + + /// + // Prompt to overwrite if the user selects an existing file with the Save + // dialog. + /// + FILE_DIALOG_OVERWRITEPROMPT_FLAG = 0x01000000, + + /// + // Do not display read-only files. + /// + FILE_DIALOG_HIDEREADONLY_FLAG = 0x02000000, } cef_file_dialog_mode_t; /// @@ -1733,7 +2088,7 @@ typedef struct _cef_geoposition_t { double speed; /// - // Time of position measurement in miliseconds since Epoch in UTC time. This + // Time of position measurement in milliseconds since Epoch in UTC time. This // is taken from the host computer's system clock. /// cef_time_t timestamp; @@ -1749,6 +2104,708 @@ typedef struct _cef_geoposition_t { cef_string_t error_message; } cef_geoposition_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_CUSTOM, +} 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, + + /// + // Unescapes characters that can be used in spoofing attempts (such as LOCK) + // and control characters (such as BiDi control characters and %01). This + // INCLUDES NULLs. This is used for rare cases such as data: URL decoding + // where the result is binary data. + // + // DO NOT use UU_SPOOFING_AND_CONTROL_CHARS if the URL is going to be + // displayed in the UI for security reasons. + /// + UU_SPOOFING_AND_CONTROL_CHARS = 1 << 4, + + /// + // URL queries use "+" for space. This flag controls that replacement. + /// + UU_REPLACE_PLUS_WITH_SPACE = 1 << 5, +} 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; + +/// +// Error codes that can be returned from CefParseJSONAndReturnError. +/// +typedef enum { + JSON_NO_ERROR = 0, + JSON_INVALID_ESCAPE, + JSON_SYNTAX_ERROR, + JSON_UNEXPECTED_TOKEN, + JSON_TRAILING_COMMA, + JSON_TOO_MUCH_NESTING, + JSON_UNEXPECTED_DATA_AFTER_ROOT, + JSON_UNSUPPORTED_ENCODING, + JSON_UNQUOTED_DICTIONARY_KEY, + JSON_PARSE_ERROR_COUNT +} cef_json_parser_error_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. + /// + PDF_PRINT_MARGIN_DEFAULT, + + /// + // No margins. + /// + PDF_PRINT_MARGIN_NONE, + + /// + // Minimum margins. + /// + PDF_PRINT_MARGIN_MINIMUM, + + /// + // 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. +/// +typedef struct _cef_pdf_print_settings_t { + /// + // Page title to display in the header. Only used if |header_footer_enabled| + // is set to true (1). + /// + cef_string_t header_footer_title; + + /// + // URL to display in the footer. Only used if |header_footer_enabled| is set + // to true (1). + /// + cef_string_t header_footer_url; + + /// + // Output page size in microns. If either of these values is less than or + // equal to zero then the default paper size (A4) will be used. + /// + int page_width; + int page_height; + + /// + // The percentage to scale the PDF by before printing (e.g. 50 is 50%). + // If this value is less than or equal to zero the default value of 100 + // will be used. + /// + int scale_factor; + + /// + // Margins in millimeters. Only used if |margin_type| is set to + // PDF_PRINT_MARGIN_CUSTOM. + /// + double margin_top; + double margin_right; + double margin_bottom; + double margin_left; + + /// + // Margin type. + /// + cef_pdf_print_margin_type_t margin_type; + + /// + // Set to true (1) to print headers and footers or false (0) to not print + // headers and footers. + /// + int header_footer_enabled; + + /// + // Set to true (1) to print the selection only or false (0) to print all. + /// + int selection_only; + + /// + // Set to true (1) for landscape mode or false (0) for portrait mode. + /// + int landscape; + + /// + // Set to true (1) to print background graphics or false (0) to not print + // background graphics. + /// + int backgrounds_enabled; + +} cef_pdf_print_settings_t; + +/// +// Supported UI scale factors for the platform. SCALE_FACTOR_NONE is used for +// density independent resources such as string, html/js files or an image that +// can be used for any scale factors (such as wallpapers). +/// +typedef enum { + SCALE_FACTOR_NONE = 0, + SCALE_FACTOR_100P, + SCALE_FACTOR_125P, + SCALE_FACTOR_133P, + SCALE_FACTOR_140P, + SCALE_FACTOR_150P, + SCALE_FACTOR_180P, + SCALE_FACTOR_200P, + SCALE_FACTOR_250P, + SCALE_FACTOR_300P, +} cef_scale_factor_t; + +/// +// Plugin policies supported by CefRequestContextHandler::OnBeforePluginLoad. +/// +typedef enum { + /// + // Allow the content. + /// + PLUGIN_POLICY_ALLOW, + + /// + // Allow important content and block unimportant content based on heuristics. + // The user can manually load blocked content. + /// + PLUGIN_POLICY_DETECT_IMPORTANT, + + /// + // Block the content. The user can manually load blocked content. + /// + PLUGIN_POLICY_BLOCK, + + /// + // Disable the content. The user cannot load disabled content. + /// + PLUGIN_POLICY_DISABLE, +} cef_plugin_policy_t; + +/// +// 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. +/// +typedef enum { + /// + // Always send the complete Referrer value. + /// + REFERRER_POLICY_ALWAYS, + + /// + // Use the default policy. This is REFERRER_POLICY_ORIGIN_WHEN_CROSS_ORIGIN + // when the `--reduced-referrer-granularity` command-line flag is specified + // and REFERRER_POLICY_NO_REFERRER_WHEN_DOWNGRADE otherwise. + // + /// + REFERRER_POLICY_DEFAULT, + + /// + // When navigating from HTTPS to HTTP do not send the Referrer value. + // Otherwise, send the complete Referrer value. + /// + REFERRER_POLICY_NO_REFERRER_WHEN_DOWNGRADE, + + /// + // Never send the Referrer value. + /// + REFERRER_POLICY_NEVER, + + /// + // Only send the origin component of the Referrer value. + /// + REFERRER_POLICY_ORIGIN, + + /// + // When navigating cross-origin only send the origin component of the Referrer + // value. Otherwise, send the complete Referrer value. + /// + REFERRER_POLICY_ORIGIN_WHEN_CROSS_ORIGIN, +} 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, + // Reserve 6 for TLS 1.3. + 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; + +/// +// Error codes for CDM registration. See cef_web_plugin.h for details. +/// +typedef enum { + /// + // No error. Registration completed successfully. + /// + CEF_CDM_REGISTRATION_ERROR_NONE, + + /// + // Required files or manifest contents are missing. + /// + CEF_CDM_REGISTRATION_ERROR_INCORRECT_CONTENTS, + + /// + // The CDM is incompatible with the current Chromium version. + /// + CEF_CDM_REGISTRATION_ERROR_INCOMPATIBLE, + + /// + // CDM registration is not supported at this time. + /// + CEF_CDM_REGISTRATION_ERROR_NOT_SUPPORTED, +} cef_cdm_registration_error_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; +} cef_composition_underline_t; + #ifdef __cplusplus } #endif diff --git a/include/internal/cef_types_linux.h b/include/internal/cef_types_linux.h index 24d299b..f5e1747 100644 --- a/include/internal/cef_types_linux.h +++ b/include/internal/cef_types_linux.h @@ -27,26 +27,38 @@ // (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/internal/cef_build.h" +#include "include/base/cef_build.h" #if defined(OS_LINUX) -#include + +typedef union _XEvent XEvent; +typedef struct _XDisplay XDisplay; + +#include "include/internal/cef_export.h" #include "include/internal/cef_string.h" +// Handle types. +#define cef_cursor_handle_t unsigned long +#define cef_event_handle_t XEvent* +#define cef_window_handle_t unsigned long + +#define kNullCursorHandle 0 +#define kNullEventHandle NULL +#define kNullWindowHandle 0 + #ifdef __cplusplus extern "C" { #endif -// Handle types. -#define cef_cursor_handle_t GdkCursor* -#define cef_event_handle_t GdkEvent* -#define cef_window_handle_t GtkWidget* -#define cef_text_input_context_t void* +/// +// 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. +/// +CEF_EXPORT XDisplay* cef_get_xdisplay(); /// // Structure representing CefExecuteProcess arguments. @@ -60,19 +72,34 @@ typedef struct _cef_main_args_t { // Class representing window information. /// typedef struct _cef_window_info_t { - // Pointer for the parent GtkBox widget. - cef_window_handle_t parent_widget; + unsigned int x; + unsigned int y; + unsigned int width; + unsigned int height; - // If window rendering is disabled no browser window will be created. Set - // |parent_widget| to the window that will act as the parent for popup menus, - // dialog boxes, etc. - int window_rendering_disabled; + /// + // Pointer for the parent window. + /// + cef_window_handle_t parent_window; - // Set to true to enable transparent painting. - int transparent_painting; + /// + // 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; - // Pointer for the new browser widget. - cef_window_handle_t widget; + /// + // Pointer for the new browser window. Only used with windowed rendering. + /// + cef_window_handle_t window; } cef_window_info_t; #ifdef __cplusplus diff --git a/include/internal/cef_types_mac.h b/include/internal/cef_types_mac.h index 5a973d3..3bd62d0 100644 --- a/include/internal/cef_types_mac.h +++ b/include/internal/cef_types_mac.h @@ -27,12 +27,11 @@ // (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/internal/cef_build.h" +#include "include/base/cef_build.h" #if defined(OS_MACOSX) #include "include/internal/cef_string.h" @@ -43,24 +42,24 @@ @class NSCursor; @class NSEvent; @class NSView; -@class NSTextInputContext; #else class NSCursor; class NSEvent; struct NSView; -class NSTextInputContext; #endif #define cef_cursor_handle_t NSCursor* #define cef_event_handle_t NSEvent* #define cef_window_handle_t NSView* -#define cef_text_input_context_t NSTextInputContext* #else #define cef_cursor_handle_t void* #define cef_event_handle_t void* #define cef_window_handle_t void* -#define cef_text_input_context_t void* #endif +#define kNullCursorHandle NULL +#define kNullEventHandle NULL +#define kNullWindowHandle NULL + #ifdef __cplusplus extern "C" { #endif @@ -82,20 +81,34 @@ typedef struct _cef_window_info_t { int y; int width; int height; + + /// + // Set to true (1) to create the view initially hidden. + /// int hidden; + /// // NSView pointer for the parent view. + /// cef_window_handle_t parent_view; - // If window rendering is disabled no browser window will be created. Set - // |parent_view| to the window that will act as the parent for popup menus, - // dialog boxes, etc. - int window_rendering_disabled; - - // Set to true to enable transparent painting. - int transparent_painting; + /// + // 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; - // NSView pointer for the new browser view. + /// + // NSView pointer for the new browser view. Only used with windowed rendering. + /// cef_window_handle_t view; } cef_window_info_t; diff --git a/include/internal/cef_types_win.h b/include/internal/cef_types_win.h index 8c4693c..50a2ebf 100644 --- a/include/internal/cef_types_win.h +++ b/include/internal/cef_types_win.h @@ -27,33 +27,33 @@ // (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/internal/cef_build.h" +#include "include/base/cef_build.h" #if defined(OS_WIN) #include #include "include/internal/cef_string.h" -#ifdef __cplusplus -extern "C" { -#endif - // Handle types. #define cef_cursor_handle_t HCURSOR #define cef_event_handle_t MSG* #define cef_window_handle_t HWND -#define cef_text_input_context_t void* + +#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; +typedef struct _cef_main_args_t { HINSTANCE instance; } cef_main_args_t; /// // Structure representing window information. @@ -70,19 +70,23 @@ typedef struct _cef_window_info_t { cef_window_handle_t parent_window; HMENU menu; - // If window rendering is disabled no browser window will be created. Set - // |parent_window| to be used for identifying monitor info - // (MonitorFromWindow). If |parent_window| is not provided the main screen - // monitor will be used. - BOOL window_rendering_disabled; - - // Set to true to enable transparent painting. - // If window rendering is disabled and |transparent_painting| is set to true - // WebKit rendering will draw on a transparent background (RGBA=0x00000000). - // When this value is false the background will be white and opaque. - BOOL transparent_painting; + /// + // 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; - // Handle for the new browser window. + /// + // Handle for the new browser window. Only used with windowed rendering. + /// cef_window_handle_t window; } cef_window_info_t; diff --git a/include/internal/cef_types_wrappers.h b/include/internal/cef_types_wrappers.h index 5aa689d..13ebcfb 100644 --- a/include/internal/cef_types_wrappers.h +++ b/include/internal/cef_types_wrappers.h @@ -43,9 +43,7 @@ class CefStructBase : public traits::struct_type { public: typedef typename traits::struct_type struct_type; - CefStructBase() : attached_to_(NULL) { - Init(); - } + CefStructBase() : attached_to_(NULL) { Init(); } virtual ~CefStructBase() { // Only clear this object's data if it isn't currently attached to a // structure. @@ -57,7 +55,7 @@ class CefStructBase : public traits::struct_type { Init(); *this = r; } - CefStructBase(const struct_type& r) { // NOLINT(runtime/explicit) + CefStructBase(const struct_type& r) { Init(); *this = r; } @@ -133,6 +131,42 @@ class CefStructBase : public traits::struct_type { struct_type* attached_to_; }; +struct CefPointTraits { + typedef cef_point_t struct_type; + + static inline void init(struct_type* s) {} + static inline void clear(struct_type* s) {} + + static inline void set(const struct_type* src, + struct_type* target, + bool copy) { + *target = *src; + } +}; + +/// +// Class representing a point. +/// +class CefPoint : public CefStructBase { + public: + typedef CefStructBase parent; + + CefPoint() : parent() {} + CefPoint(const cef_point_t& r) : parent(r) {} + CefPoint(const CefPoint& r) : parent(r) {} + CefPoint(int x, int y) : parent() { Set(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); +} struct CefRectTraits { typedef cef_rect_t struct_type; @@ -140,8 +174,9 @@ struct CefRectTraits { static inline void init(struct_type* s) {} static inline void clear(struct_type* s) {} - static inline void set(const struct_type* src, struct_type* target, - bool copy) { + static inline void set(const struct_type* src, + struct_type* target, + bool copy) { *target = *src; } }; @@ -154,15 +189,26 @@ class CefRect : public CefStructBase { typedef CefStructBase parent; CefRect() : parent() {} - CefRect(const cef_rect_t& r) : parent(r) {} // NOLINT(runtime/explicit) - CefRect(const CefRect& r) : parent(r) {} // NOLINT(runtime/explicit) + CefRect(const cef_rect_t& r) : parent(r) {} + CefRect(const CefRect& r) : parent(r) {} CefRect(int x, int y, int width, int height) : parent() { Set(x, y, width, height); } bool IsEmpty() const { return width <= 0 || height <= 0; } - void Set(int x, int y, int width, int height) { - this->x = x, this->y = y, this->width = width, this->height = height; + 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); } }; @@ -174,6 +220,164 @@ inline bool operator!=(const CefRect& a, const CefRect& b) { return !(a == b); } +struct CefSizeTraits { + typedef cef_size_t struct_type; + + static inline void init(struct_type* s) {} + static inline void clear(struct_type* s) {} + + static inline void set(const struct_type* src, + struct_type* target, + bool copy) { + *target = *src; + } +}; + +/// +// Class representing a size. +/// +class CefSize : public CefStructBase { + public: + typedef CefStructBase parent; + + CefSize() : parent() {} + CefSize(const cef_size_t& r) : parent(r) {} + CefSize(const CefSize& r) : parent(r) {} + CefSize(int width, int height) : parent() { Set(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); +} + +struct CefRangeTraits { + typedef cef_range_t struct_type; + + static inline void init(struct_type* s) {} + static inline void clear(struct_type* s) {} + + static inline void set(const struct_type* src, + struct_type* target, + bool copy) { + *target = *src; + } +}; + +/// +// Class representing a range. +/// +class CefRange : public CefStructBase { + public: + typedef CefStructBase parent; + + CefRange() : parent() {} + CefRange(const cef_range_t& r) : parent(r) {} + CefRange(const CefRange& r) : parent(r) {} + CefRange(int from, int to) : parent() { Set(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); +} + +struct CefInsetsTraits { + typedef cef_insets_t struct_type; + + static inline void init(struct_type* s) {} + static inline void clear(struct_type* s) {} + + static inline void set(const struct_type* src, + struct_type* target, + bool copy) { + *target = *src; + } +}; + +/// +// Class representing insets. +/// +class CefInsets : public CefStructBase { + public: + typedef CefStructBase parent; + + CefInsets() : parent() {} + CefInsets(const cef_insets_t& r) : parent(r) {} + CefInsets(const CefInsets& r) : parent(r) {} + CefInsets(int top, int left, int bottom, int right) : parent() { + Set(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); +} + +struct CefDraggableRegionTraits { + typedef cef_draggable_region_t struct_type; + + static inline void init(struct_type* s) {} + static inline void clear(struct_type* s) {} + + static inline void set(const struct_type* src, + struct_type* target, + bool copy) { + *target = *src; + } +}; + +/// +// Class representing a draggable region. +/// +class CefDraggableRegion : public CefStructBase { + public: + typedef CefStructBase parent; + + CefDraggableRegion() : parent() {} + CefDraggableRegion(const cef_draggable_region_t& r) : parent(r) {} + CefDraggableRegion(const CefDraggableRegion& r) : parent(r) {} + CefDraggableRegion(const CefRect& bounds, bool draggable) : parent() { + Set(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); +} + struct CefScreenInfoTraits { typedef cef_screen_info_t struct_type; @@ -181,8 +385,9 @@ struct CefScreenInfoTraits { static inline void clear(struct_type* s) {} - static inline void set(const struct_type* src, struct_type* target, - bool copy) { + static inline void set(const struct_type* src, + struct_type* target, + bool copy) { target->device_scale_factor = src->device_scale_factor; target->depth = src->depth; target->depth_per_component = src->depth_per_component; @@ -193,38 +398,39 @@ struct CefScreenInfoTraits { }; /// -// Class representing the virtual screen information for use when window rendering -// is disabled. +// Class representing the virtual screen information for use when window +// rendering is disabled. /// class CefScreenInfo : public CefStructBase { public: typedef CefStructBase parent; CefScreenInfo() : parent() {} - CefScreenInfo(const cef_screen_info_t& r) : parent(r) {} // NOLINT(runtime/explicit) - CefScreenInfo(const CefScreenInfo& r) : parent(r) {} // NOLINT(runtime/explicit) + CefScreenInfo(const cef_screen_info_t& r) : parent(r) {} + CefScreenInfo(const CefScreenInfo& r) : parent(r) {} CefScreenInfo(float device_scale_factor, int depth, int depth_per_component, bool is_monochrome, const CefRect& rect, - const CefRect& available_rect) : parent() { - Set(device_scale_factor, depth, depth_per_component, - is_monochrome, rect, available_rect); - } - - void Set(float device_scale_factor, - int depth, - int depth_per_component, - bool is_monochrome, - const CefRect& rect, - const CefRect& available_rect) { - this->device_scale_factor = device_scale_factor; - this->depth = depth; - this->depth_per_component = depth_per_component; - this->is_monochrome = is_monochrome; - this->rect = rect; - this->available_rect = available_rect; + const CefRect& available_rect) + : parent() { + Set(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; } }; @@ -235,8 +441,9 @@ struct CefKeyEventTraits { static inline void clear(struct_type* s) {} - static inline void set(const struct_type* src, struct_type* target, - bool copy) { + static inline void set(const struct_type* src, + struct_type* target, + bool copy) { target->type = src->type; target->modifiers = src->modifiers; target->windows_key_code = src->windows_key_code; @@ -260,8 +467,9 @@ struct CefMouseEventTraits { static inline void clear(struct_type* s) {} - static inline void set(const struct_type* src, struct_type* target, - bool copy) { + static inline void set(const struct_type* src, + struct_type* target, + bool copy) { target->x = src->x; target->y = src->y; target->modifiers = src->modifiers; @@ -285,18 +493,11 @@ struct CefPopupFeaturesTraits { s->resizable = true; } - static inline void clear(struct_type* s) { - if (s->additionalFeatures) - cef_string_list_free(s->additionalFeatures); - } - - static inline void set(const struct_type* src, struct_type* target, - bool copy) { - if (target->additionalFeatures) - cef_string_list_free(target->additionalFeatures); - target->additionalFeatures = src->additionalFeatures ? - cef_string_list_copy(src->additionalFeatures) : NULL; + static inline void clear(struct_type* s) {} + static inline void set(const struct_type* src, + struct_type* target, + bool copy) { target->x = src->x; target->xSet = src->xSet; target->y = src->y; @@ -321,17 +522,16 @@ struct CefPopupFeaturesTraits { /// typedef CefStructBase CefPopupFeatures; - struct CefSettingsTraits { typedef cef_settings_t struct_type; - static inline void init(struct_type* s) { - s->size = sizeof(struct_type); - } + 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->cache_path); + cef_string_clear(&s->user_data_path); cef_string_clear(&s->user_agent); cef_string_clear(&s->product_version); cef_string_clear(&s->locale); @@ -339,45 +539,58 @@ struct CefSettingsTraits { 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); } - static inline void set(const struct_type* src, struct_type* target, - bool copy) { + static inline void set(const struct_type* src, + struct_type* target, + bool copy) { target->single_process = src->single_process; target->no_sandbox = src->no_sandbox; cef_string_set(src->browser_subprocess_path.str, - src->browser_subprocess_path.length, - &target->browser_subprocess_path, copy); + 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); 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); + &target->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); + &target->user_agent, copy); cef_string_set(src->product_version.str, src->product_version.length, - &target->product_version, copy); + &target->product_version, 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); + copy); target->log_severity = src->log_severity; - target->release_dcheck_enabled = src->release_dcheck_enabled; cef_string_set(src->javascript_flags.str, src->javascript_flags.length, - &target->javascript_flags, copy); + &target->javascript_flags, copy); cef_string_set(src->resources_dir_path.str, src->resources_dir_path.length, - &target->resources_dir_path, copy); + &target->resources_dir_path, copy); cef_string_set(src->locales_dir_path.str, src->locales_dir_path.length, - &target->locales_dir_path, copy); + &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->context_safety_implementation = src->context_safety_implementation; target->ignore_certificate_errors = src->ignore_certificate_errors; + target->enable_net_security_expiration = + src->enable_net_security_expiration; target->background_color = src->background_color; + + cef_string_set(src->accept_language_list.str, + src->accept_language_list.length, + &target->accept_language_list, copy); } }; @@ -386,13 +599,42 @@ struct CefSettingsTraits { /// typedef CefStructBase CefSettings; +struct CefRequestContextSettingsTraits { + typedef cef_request_context_settings_t struct_type; + + 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); + } + + 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; + target->ignore_certificate_errors = src->ignore_certificate_errors; + target->enable_net_security_expiration = + src->enable_net_security_expiration; + cef_string_set(src->accept_language_list.str, + src->accept_language_list.length, + &target->accept_language_list, copy); + } +}; + +/// +// Class representing request context initialization settings. +/// +typedef CefStructBase + CefRequestContextSettings; struct CefBrowserSettingsTraits { typedef cef_browser_settings_t struct_type; - static inline void init(struct_type* s) { - s->size = sizeof(struct_type); - } + 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); @@ -402,23 +644,30 @@ struct CefBrowserSettingsTraits { 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) { + 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); + 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); + &target->fixed_font_family, copy); cef_string_set(src->serif_font_family.str, src->serif_font_family.length, - &target->serif_font_family, copy); + &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); + 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); + 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); + 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; @@ -426,7 +675,7 @@ struct CefBrowserSettingsTraits { 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->default_encoding, copy); target->remote_fonts = src->remote_fonts; target->javascript = src->javascript; @@ -434,8 +683,6 @@ struct CefBrowserSettingsTraits { 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->caret_browsing = src->caret_browsing; - target->java = src->java; target->plugins = src->plugins; target->universal_access_from_file_urls = src->universal_access_from_file_urls; @@ -447,10 +694,15 @@ struct CefBrowserSettingsTraits { 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->databases = src->databases; target->application_cache = src->application_cache; target->webgl = src->webgl; - target->accelerated_compositing = src->accelerated_compositing; + + target->background_color = src->background_color; + + cef_string_set(src->accept_language_list.str, + src->accept_language_list.length, + &target->accept_language_list, copy); } }; @@ -459,7 +711,6 @@ struct CefBrowserSettingsTraits { /// typedef CefStructBase CefBrowserSettings; - struct CefURLPartsTraits { typedef cef_urlparts_t struct_type; @@ -477,14 +728,15 @@ struct CefURLPartsTraits { cef_string_clear(&s->query); } - static inline void set(const struct_type* src, struct_type* target, - bool copy) { + 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); + copy); cef_string_set(src->password.str, src->password.length, &target->password, - copy); + 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); @@ -498,7 +750,6 @@ struct CefURLPartsTraits { /// typedef CefStructBase CefURLParts; - struct CefTimeTraits { typedef cef_time_t struct_type; @@ -506,8 +757,9 @@ struct CefTimeTraits { static inline void clear(struct_type* s) {} - static inline void set(const struct_type* src, struct_type* target, - bool copy) { + static inline void set(const struct_type* src, + struct_type* target, + bool copy) { *target = *src; } }; @@ -520,15 +772,13 @@ class CefTime : public CefStructBase { typedef CefStructBase parent; CefTime() : parent() {} - CefTime(const cef_time_t& r) : parent(r) {} // NOLINT(runtime/explicit) - CefTime(const CefTime& r) : parent(r) {} // NOLINT(runtime/explicit) + CefTime(const cef_time_t& r) : parent(r) {} + CefTime(const CefTime& r) : parent(r) {} explicit CefTime(time_t r) : parent() { SetTimeT(r); } explicit CefTime(double r) : parent() { SetDoubleT(r); } // Converts to/from time_t. - void SetTimeT(time_t r) { - cef_time_from_timet(r, this); - } + 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); @@ -538,9 +788,7 @@ class CefTime : public CefStructBase { // 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); - } + void SetDoubleT(double r) { cef_time_from_doublet(r, this); } double GetDoubleT() const { double time = 0; cef_time_to_doublet(this, &time); @@ -548,9 +796,7 @@ class CefTime : public CefStructBase { } // Set this object to now. - void Now() { - cef_time_now(this); - } + void Now() { cef_time_now(this); } // Return the delta between this object and |other| in milliseconds. long long Delta(const CefTime& other) { @@ -560,7 +806,6 @@ class CefTime : public CefStructBase { } }; - struct CefCookieTraits { typedef cef_cookie_t struct_type; @@ -573,8 +818,9 @@ struct CefCookieTraits { cef_string_clear(&s->path); } - static inline void set(const struct_type* src, struct_type* target, - bool copy) { + 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); @@ -593,7 +839,6 @@ struct CefCookieTraits { /// typedef CefStructBase CefCookie; - struct CefGeopositionTraits { typedef cef_geoposition_t struct_type; @@ -603,8 +848,9 @@ struct CefGeopositionTraits { cef_string_clear(&s->error_message); } - static inline void set(const struct_type* src, struct_type* target, - bool copy) { + static inline void set(const struct_type* src, + struct_type* target, + bool copy) { target->latitude = src->latitude; target->longitude = src->longitude; target->altitude = src->altitude; @@ -615,7 +861,7 @@ struct CefGeopositionTraits { target->timestamp = src->timestamp; target->error_code = src->error_code; cef_string_set(src->error_message.str, src->error_message.length, - &target->error_message, copy); + &target->error_message, copy); } }; @@ -624,4 +870,115 @@ struct CefGeopositionTraits { /// typedef CefStructBase CefGeoposition; +struct CefCursorInfoTraits { + typedef cef_cursor_info_t struct_type; + + static inline void init(struct_type* s) {} + + static inline void clear(struct_type* s) {} + + static inline void set(const struct_type* src, + struct_type* target, + bool copy) { + target->hotspot = src->hotspot; + target->image_scale_factor = src->image_scale_factor; + target->buffer = src->buffer; + target->size = src->size; + } +}; + +/// +// Class representing cursor information. +/// +typedef CefStructBase CefCursorInfo; + +struct CefPdfPrintSettingsTraits { + typedef cef_pdf_print_settings_t struct_type; + + static inline void init(struct_type* s) {} + + static inline void clear(struct_type* s) { + cef_string_clear(&s->header_footer_title); + cef_string_clear(&s->header_footer_url); + } + + static inline void set(const struct_type* src, + struct_type* target, + bool copy) { + cef_string_set(src->header_footer_title.str, + src->header_footer_title.length, + &target->header_footer_title, copy); + cef_string_set(src->header_footer_url.str, src->header_footer_url.length, + &target->header_footer_url, copy); + + target->page_width = src->page_width; + target->page_height = src->page_height; + + target->scale_factor = src->scale_factor; + + target->margin_top = src->margin_top; + target->margin_right = src->margin_right; + target->margin_bottom = src->margin_bottom; + target->margin_left = src->margin_left; + target->margin_type = src->margin_type; + + target->header_footer_enabled = src->header_footer_enabled; + target->selection_only = src->selection_only; + target->landscape = src->landscape; + target->backgrounds_enabled = src->backgrounds_enabled; + } +}; + +/// +// Class representing PDF print settings +/// +typedef CefStructBase CefPdfPrintSettings; + +struct CefBoxLayoutSettingsTraits { + typedef cef_box_layout_settings_t struct_type; + + static inline void init(struct_type* s) {} + + static inline void clear(struct_type* s) {} + + static inline void set(const struct_type* src, + struct_type* target, + bool copy) { + *target = *src; + } +}; + +/// +// Class representing CefBoxLayout settings. +/// +typedef CefStructBase CefBoxLayoutSettings; + +struct CefCompositionUnderlineTraits { + typedef cef_composition_underline_t struct_type; + + static inline void init(struct_type* s) { + s->range.from = 0; + s->range.to = 0; + s->color = 0; + s->background_color = 0; + s->thick = 0; + } + + static inline void clear(struct_type* s) {} + + static inline void set(const struct_type* src, + struct_type* target, + bool copy) { + target->range = src->range; + target->color = src->color; + target->background_color = src->background_color; + target->thick = src->thick; + } +}; + +/// +// Class representing IME composition underline. +/// +typedef CefStructBase CefCompositionUnderline; + #endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_ diff --git a/include/internal/cef_win.h b/include/internal/cef_win.h index 29e26c4..8b30a4f 100644 --- a/include/internal/cef_win.h +++ b/include/internal/cef_win.h @@ -27,51 +27,19 @@ // (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 -#if defined(OS_WIN) -#include #include "include/internal/cef_types_win.h" #include "include/internal/cef_types_wrappers.h" -/// -// Atomic increment and decrement. -/// -#define CefAtomicIncrement(p) InterlockedIncrement(p) -#define CefAtomicDecrement(p) InterlockedDecrement(p) - -/// -// Critical section wrapper. -/// -class CefCriticalSection { - public: - CefCriticalSection() { - memset(&m_sec, 0, sizeof(CRITICAL_SECTION)); - InitializeCriticalSection(&m_sec); - } - virtual ~CefCriticalSection() { - DeleteCriticalSection(&m_sec); - } - void Lock() { - EnterCriticalSection(&m_sec); - } - void Unlock() { - LeaveCriticalSection(&m_sec); - } - - CRITICAL_SECTION m_sec; -}; - /// // Handle types. /// #define CefCursorHandle cef_cursor_handle_t #define CefEventHandle cef_event_handle_t #define CefWindowHandle cef_window_handle_t -#define CefTextInputContext cef_text_input_context_t struct CefMainArgsTraits { typedef cef_main_args_t struct_type; @@ -79,8 +47,9 @@ struct CefMainArgsTraits { static inline void init(struct_type* s) {} static inline void clear(struct_type* s) {} - static inline void set(const struct_type* src, struct_type* target, - bool copy) { + static inline void set(const struct_type* src, + struct_type* target, + bool copy) { target->instance = src->instance; } }; @@ -93,9 +62,7 @@ class CefMainArgs : public CefStructBase { CefMainArgs() : parent() {} explicit CefMainArgs(const cef_main_args_t& r) : parent(r) {} explicit CefMainArgs(const CefMainArgs& r) : parent(r) {} - explicit CefMainArgs(HINSTANCE hInstance) : parent() { - instance = hInstance; - } + explicit CefMainArgs(HINSTANCE hInstance) : parent() { instance = hInstance; } }; struct CefWindowInfoTraits { @@ -107,11 +74,12 @@ struct CefWindowInfoTraits { cef_string_clear(&s->window_name); } - static inline void set(const struct_type* src, struct_type* target, - bool copy) { + 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->window_name, copy); target->style = src->style; target->x = src->x; target->y = src->y; @@ -119,9 +87,8 @@ struct CefWindowInfoTraits { target->height = src->height; target->parent_window = src->parent_window; target->menu = src->menu; + target->windowless_rendering_enabled = src->windowless_rendering_enabled; target->window = src->window; - target->transparent_painting = src->transparent_painting; - target->window_rendering_disabled = src->window_rendering_disabled; } }; @@ -136,20 +103,26 @@ class CefWindowInfo : public CefStructBase { explicit CefWindowInfo(const cef_window_info_t& r) : parent(r) {} explicit CefWindowInfo(const CefWindowInfo& r) : parent(r) {} - void SetAsChild(HWND hWndParent, RECT windowRect) { - style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_TABSTOP | - WS_VISIBLE; - parent_window = hWndParent; + /// + // Create the browser as a child window. + /// + void SetAsChild(CefWindowHandle parent, RECT windowRect) { + style = + WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_TABSTOP | WS_VISIBLE; + parent_window = parent; x = windowRect.left; y = windowRect.top; width = windowRect.right - windowRect.left; height = windowRect.bottom - windowRect.top; } - void SetAsPopup(HWND hWndParent, const CefString& windowName) { - style = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | - WS_VISIBLE; - parent_window = hWndParent; + /// + // 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; x = CW_USEDEFAULT; y = CW_USEDEFAULT; width = CW_USEDEFAULT; @@ -158,16 +131,22 @@ class CefWindowInfo : public CefStructBase { cef_string_copy(windowName.c_str(), windowName.length(), &window_name); } - void SetTransparentPainting(BOOL transparentPainting) { - transparent_painting = transparentPainting; - } - - void SetAsOffScreen(HWND hWndParent) { - window_rendering_disabled = TRUE; - parent_window = hWndParent; + /// + // 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 // OS_WIN - #endif // CEF_INCLUDE_INTERNAL_CEF_WIN_H_ diff --git a/src/cef/cef.go b/src/cef/cef.go index 04aecc2..286a6d7 100644 --- a/src/cef/cef.go +++ b/src/cef/cef.go @@ -4,21 +4,6 @@ package cef -/* -CEF capi fixes --------------- -1. In cef_string.h: - this => typedef cef_string_utf16_t cef_string_t; - to => #define cef_string_t cef_string_utf16_t -2. In cef_export.h: - #elif defined(COMPILER_GCC) - #define CEF_EXPORT __attribute__ ((visibility("default"))) - #ifdef OS_WIN - #define CEF_CALLBACK __stdcall - #else - #define CEF_CALLBACK - #endif -*/ /* #cgo CFLAGS: -I./../../ @@ -27,6 +12,8 @@ CEF capi fixes #include "include/capi/cef_app_capi.h" #include "handlers/cef_app.h" #include "handlers/cef_client.h" + +cef_life_span_handler_t g_life_span_handler = {}; */ import "C" import "unsafe" @@ -69,7 +56,6 @@ const ( LOGSEVERITY_INFO = C.LOGSEVERITY_INFO LOGSEVERITY_WARNING = C.LOGSEVERITY_WARNING LOGSEVERITY_ERROR = C.LOGSEVERITY_ERROR - LOGSEVERITY_ERROR_REPORT = C.LOGSEVERITY_ERROR_REPORT LOGSEVERITY_DISABLE = C.LOGSEVERITY_DISABLE ) @@ -83,11 +69,11 @@ func _InitializeGlobalCStructures() { _AppHandler = (*C.cef_app_t)( C.calloc(1, C.sizeof_cef_app_t)) - C.initialize_app_handler(_AppHandler) + C.initialize_cef_app(_AppHandler) _ClientHandler = (*C.struct__cef_client_t)( C.calloc(1, C.sizeof_struct__cef_client_t)) - C.initialize_client_handler(_ClientHandler) + C.initialize_cef_client(_ClientHandler) } func ExecuteProcess(appHandle unsafe.Pointer) int {