Branch CEF3 files from /branches/cef3 to /trunk/cef3 (issue #564).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@571 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2012-04-03 01:34:16 +00:00
parent b568f160d9
commit 34adee805c
516 changed files with 83249 additions and 0 deletions

View File

@ -0,0 +1,129 @@
// 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_

View File

@ -0,0 +1,55 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CEF_INCLUDE_INTERNAL_CEF_EXPORT_H_
#define CEF_INCLUDE_INTERNAL_CEF_EXPORT_H_
#pragma once
#include "include/internal/cef_build.h"
#if defined(COMPILER_MSVC)
#ifdef BUILDING_CEF_SHARED
#define CEF_EXPORT __declspec(dllexport)
#elif USING_CEF_SHARED
#define CEF_EXPORT __declspec(dllimport)
#else
#define CEF_EXPORT
#endif
#define CEF_CALLBACK __stdcall
#elif defined(COMPILER_GCC)
#define CEF_EXPORT __attribute__ ((visibility("default")))
#define CEF_CALLBACK
#endif // COMPILER_GCC
#endif // CEF_INCLUDE_INTERNAL_CEF_EXPORT_H_

View File

@ -0,0 +1,131 @@
// Copyright (c) 2010 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CEF_INCLUDE_INTERNAL_CEF_LINUX_H_
#define CEF_INCLUDE_INTERNAL_CEF_LINUX_H_
#pragma once
#if defined(OS_LINUX)
#include <pthread.h>
#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 CefWindowHandle cef_window_handle_t
#define CefCursorHandle cef_cursor_handle_t
struct CefMainArgsTraits {
typedef cef_main_args_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->argc = src->argc;
target->argv = src->argv;
}
};
// Class representing CefExecuteProcess arguments.
class CefMainArgs : public CefStructBase<CefMainArgsTraits> {
public:
typedef CefStructBase<CefMainArgsTraits> parent;
CefMainArgs() : parent() {}
explicit CefMainArgs(const cef_main_args_t& r) : parent(r) {}
explicit CefMainArgs(const CefMainArgs& r) : parent(r) {}
CefMainArgs(int argc_arg, char** argv_arg) : parent() {
argc = argc_arg;
argv = argv_arg;
}
};
struct CefWindowInfoTraits {
typedef cef_window_info_t struct_type;
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s) {}
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
target->widget = src->widget;
target->parent_widget = src->parent_widget;
}
};
// Class representing window information.
class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
public:
typedef CefStructBase<CefWindowInfoTraits> parent;
CefWindowInfo() : parent() {}
explicit CefWindowInfo(const cef_window_info_t& r) : parent(r) {}
explicit CefWindowInfo(const CefWindowInfo& r) : parent(r) {}
void SetAsChild(CefWindowHandle ParentWidget) {
parent_widget = ParentWidget;
}
};
#endif // OS_LINUX
#endif // CEF_INCLUDE_INTERNAL_CEF_LINUX_H_

147
include/internal/cef_mac.h Normal file
View File

@ -0,0 +1,147 @@
// Copyright (c) 2010 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CEF_INCLUDE_INTERNAL_CEF_MAC_H_
#define CEF_INCLUDE_INTERNAL_CEF_MAC_H_
#pragma once
#if defined(OS_MACOSX)
#include <pthread.h>
#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);
}
// Handle types.
#define CefWindowHandle cef_window_handle_t
#define CefCursorHandle cef_cursor_handle_t
// 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_;
};
struct CefMainArgsTraits {
typedef cef_main_args_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->argc = src->argc;
target->argv = src->argv;
}
};
// Class representing CefExecuteProcess arguments.
class CefMainArgs : public CefStructBase<CefMainArgsTraits> {
public:
typedef CefStructBase<CefMainArgsTraits> parent;
CefMainArgs() : parent() {}
explicit CefMainArgs(const cef_main_args_t& r) : parent(r) {}
explicit CefMainArgs(const CefMainArgs& r) : parent(r) {}
CefMainArgs(int argc, char** argv) : parent() {
this->argc = argc;
this->argv = argv;
}
};
struct CefWindowInfoTraits {
typedef cef_window_info_t struct_type;
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s) {
cef_string_clear(&s->window_name);
}
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
target->view = src->view;
target->parent_view = src->parent_view;
cef_string_set(src->window_name.str, src->window_name.length,
&target->window_name, copy);
target->x = src->x;
target->y = src->y;
target->width = src->width;
target->height = src->height;
target->hidden = src->hidden;
}
};
// Class representing window information.
class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
public:
typedef CefStructBase<CefWindowInfoTraits> parent;
CefWindowInfo() : parent() {}
explicit CefWindowInfo(const cef_window_info_t& r) : parent(r) {}
explicit CefWindowInfo(const CefWindowInfo& r) : parent(r) {}
void SetAsChild(CefWindowHandle ParentView, int x, int y, int width,
int height) {
parent_view = ParentView;
this->x = x;
this->y = y;
this->width = width;
this->height = height;
hidden = false;
}
};
#endif // OS_MACOSX
#endif // CEF_INCLUDE_INTERNAL_CEF_MAC_H_

199
include/internal/cef_ptr.h Normal file
View File

@ -0,0 +1,199 @@
// Copyright (c) 2008 Marshall A. Greenblatt. Portions Copyright (c)
// 2006-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.
#ifndef CEF_INCLUDE_INTERNAL_CEF_PTR_H_
#define CEF_INCLUDE_INTERNAL_CEF_PTR_H_
#pragma once
#include <stddef.h>
///
// Smart pointer implementation borrowed from base/ref_counted.h
// <p>
// A smart pointer class for reference counted objects. Use this class instead
// of calling AddRef and Release manually on a reference counted object to
// avoid common memory leaks caused by forgetting to Release an object
// reference. Sample usage:
// <pre>
// class MyFoo : public CefBase {
// ...
// };
//
// void some_function() {
// // The MyFoo object that |foo| represents starts with a single
// // reference.
// CefRefPtr&lt;MyFoo&gt; foo = new MyFoo();
// foo-&gt;Method(param);
// // |foo| is released when this function returns
// }
//
// void some_other_function() {
// CefRefPtr&lt;MyFoo&gt; foo = new MyFoo();
// ...
// foo = NULL; // explicitly releases |foo|
// ...
// if (foo)
// foo-&gt;Method(param);
// }
// </pre>
// The above examples show how CefRefPtr&lt;T&gt; acts like a pointer to T.
// Given two CefRefPtr&lt;T&gt; classes, it is also possible to exchange
// references between the two objects, like so:
// <pre>
// {
// CefRefPtr&lt;MyFoo&gt; a = new MyFoo();
// CefRefPtr&lt;MyFoo&gt; b;
//
// b.swap(a);
// // now, |b| references the MyFoo object, and |a| references NULL.
// }
// </pre>
// To make both |a| and |b| in the above example reference the same MyFoo
// object, simply use the assignment operator:
// <pre>
// {
// CefRefPtr&lt;MyFoo&gt; a = new MyFoo();
// CefRefPtr&lt;MyFoo&gt; b;
//
// b = a;
// // now, |a| and |b| each own a reference to the same MyFoo object.
// // the reference count of the underlying MyFoo object will be 2.
// }
// </pre>
// Reference counted objects can also be passed as function parameters and
// used as function return values:
// <pre>
// void some_func_with_param(CefRefPtr&lt;MyFoo&gt; param) {
// // A reference is added to the MyFoo object that |param| represents
// // during the scope of some_func_with_param() and released when
// // some_func_with_param() goes out of scope.
// }
//
// CefRefPtr&lt;MyFoo&gt; some_func_with_retval() {
// // The MyFoo object that |foox| represents starts with a single
// // reference.
// CefRefPtr&lt;MyFoo&gt; foox = new MyFoo();
//
// // Creating the return value adds an additional reference.
// return foox;
//
// // When some_func_with_retval() goes out of scope the original |foox|
// // reference is released.
// }
//
// void and_another_function() {
// CefRefPtr&lt;MyFoo&gt; foo = new MyFoo();
//
// // pass |foo| as a parameter.
// some_function(foo);
//
// CefRefPtr&lt;MyFoo&gt; foo2 = some_func_with_retval();
// // Now, since we kept a reference to the some_func_with_retval() return
// // value, |foo2| is the only class pointing to the MyFoo object created
// in some_func_with_retval(), and it has a reference count of 1.
//
// some_func_with_retval();
// // Now, since we didn't keep a reference to the some_func_with_retval()
// // return value, the MyFoo object created in some_func_with_retval()
// // will automatically be released.
// }
// </pre>
// And in standard containers:
// <pre>
// {
// // Create a vector that holds MyFoo objects.
// std::vector&lt;CefRefPtr&lt;MyFoo&gt; &gt; MyFooVec;
//
// // The MyFoo object that |foo| represents starts with a single
// // reference.
// CefRefPtr&lt;MyFoo&gt; foo = new MyFoo();
//
// // When the MyFoo object is added to |MyFooVec| the reference count
// // is increased to 2.
// MyFooVec.push_back(foo);
// }
// </pre>
// </p>
///
template <class T>
class CefRefPtr {
public:
CefRefPtr() : ptr_(NULL) {
}
CefRefPtr(T* p) : ptr_(p) { // NOLINT(runtime/explicit)
if (ptr_)
ptr_->AddRef();
}
CefRefPtr(const CefRefPtr<T>& r) : ptr_(r.ptr_) {
if (ptr_)
ptr_->AddRef();
}
~CefRefPtr() {
if (ptr_)
ptr_->Release();
}
T* get() const { return ptr_; }
operator T*() const { return ptr_; }
T* operator->() const { return ptr_; }
CefRefPtr<T>& operator=(T* p) {
// AddRef first so that self assignment should work
if (p)
p->AddRef();
if (ptr_ )
ptr_ ->Release();
ptr_ = p;
return *this;
}
CefRefPtr<T>& operator=(const CefRefPtr<T>& r) {
return *this = r.ptr_;
}
void swap(T** pp) {
T* p = ptr_;
ptr_ = *pp;
*pp = p;
}
void swap(CefRefPtr<T>& r) {
swap(&r.ptr_); // NOLINT(build/include_what_you_use)
}
private:
T* ptr_;
};
#endif // CEF_INCLUDE_INTERNAL_CEF_PTR_H_

View File

@ -0,0 +1,113 @@
// Copyright (c) 2010 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CEF_INCLUDE_INTERNAL_CEF_STRING_H_
#define CEF_INCLUDE_INTERNAL_CEF_STRING_H_
#pragma once
// The CEF interface is built with one string type as the default. Comment out
// all but one of the CEF_STRING_TYPE_* defines below to specify the default.
// If you change the default you MUST recompile all of CEF.
// Build with the UTF8 string type as default.
// #define CEF_STRING_TYPE_UTF8 1
// Build with the UTF16 string type as default.
#define CEF_STRING_TYPE_UTF16 1
// Build with the wide string type as default.
// #define CEF_STRING_TYPE_WIDE 1
#include "include/internal/cef_string_types.h"
#ifdef __cplusplus
#include "include/internal/cef_string_wrappers.h"
#if defined(CEF_STRING_TYPE_UTF16)
typedef CefStringUTF16 CefString;
#elif defined(CEF_STRING_TYPE_UTF8)
typedef CefStringUTF8 CefString;
#elif defined(CEF_STRING_TYPE_WIDE)
typedef CefStringWide CefString;
#endif
#endif // __cplusplus
#if defined(CEF_STRING_TYPE_UTF8)
typedef char cef_char_t;
typedef cef_string_utf8_t cef_string_t;
typedef cef_string_userfree_utf8_t cef_string_userfree_t;
#define cef_string_set cef_string_utf8_set
#define cef_string_copy cef_string_utf8_copy
#define cef_string_clear cef_string_utf8_clear
#define cef_string_userfree_alloc cef_string_userfree_utf8_alloc
#define cef_string_userfree_free cef_string_userfree_utf8_free
#define cef_string_from_ascii cef_string_utf8_copy
#define cef_string_to_utf8 cef_string_utf8_copy
#define cef_string_from_utf8 cef_string_utf8_copy
#define cef_string_to_utf16 cef_string_utf8_to_utf16
#define cef_string_from_utf16 cef_string_utf16_to_utf8
#define cef_string_to_wide cef_string_utf8_to_wide
#define cef_string_from_wide cef_string_wide_to_utf8
#elif defined(CEF_STRING_TYPE_UTF16)
typedef char16 cef_char_t;
typedef cef_string_userfree_utf16_t cef_string_userfree_t;
typedef cef_string_utf16_t cef_string_t;
#define cef_string_set cef_string_utf16_set
#define cef_string_copy cef_string_utf16_copy
#define cef_string_clear cef_string_utf16_clear
#define cef_string_userfree_alloc cef_string_userfree_utf16_alloc
#define cef_string_userfree_free cef_string_userfree_utf16_free
#define cef_string_from_ascii cef_string_ascii_to_utf16
#define cef_string_to_utf8 cef_string_utf16_to_utf8
#define cef_string_from_utf8 cef_string_utf8_to_utf16
#define cef_string_to_utf16 cef_string_utf16_copy
#define cef_string_from_utf16 cef_string_utf16_copy
#define cef_string_to_wide cef_string_utf16_to_wide
#define cef_string_from_wide cef_string_wide_to_utf16
#elif defined(CEF_STRING_TYPE_WIDE)
typedef wchar_t cef_char_t;
typedef cef_string_wide_t cef_string_t;
typedef cef_string_userfree_wide_t cef_string_userfree_t;
#define cef_string_set cef_string_wide_set
#define cef_string_copy cef_string_wide_copy
#define cef_string_clear cef_string_wide_clear
#define cef_string_userfree_alloc cef_string_userfree_wide_alloc
#define cef_string_userfree_free cef_string_userfree_wide_free
#define cef_string_from_ascii cef_string_ascii_to_wide
#define cef_string_to_utf8 cef_string_wide_to_utf8
#define cef_string_from_utf8 cef_string_utf8_to_wide
#define cef_string_to_utf16 cef_string_wide_to_utf16
#define cef_string_from_utf16 cef_string_utf16_to_wide
#define cef_string_to_wide cef_string_wide_copy
#define cef_string_from_wide cef_string_wide_copy
#else
#error Please choose a string type.
#endif
#endif // CEF_INCLUDE_INTERNAL_CEF_STRING_H_

View File

@ -0,0 +1,88 @@
// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CEF_INCLUDE_INTERNAL_CEF_STRING_LIST_H_
#define CEF_INCLUDE_INTERNAL_CEF_STRING_LIST_H_
#pragma once
#include "include/internal/cef_export.h"
#include "include/internal/cef_string.h"
#ifdef __cplusplus
extern "C" {
#endif
///
// CEF string maps are a set of key/value string pairs.
///
typedef void* cef_string_list_t;
///
// Allocate a new string map.
///
CEF_EXPORT cef_string_list_t cef_string_list_alloc();
///
// Return the number of elements in the string list.
///
CEF_EXPORT int 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);
///
// Append a new value at the end of the string list.
///
CEF_EXPORT void cef_string_list_append(cef_string_list_t list,
const cef_string_t* value);
///
// Clear the string list.
///
CEF_EXPORT void cef_string_list_clear(cef_string_list_t list);
///
// Free the string list.
///
CEF_EXPORT void cef_string_list_free(cef_string_list_t list);
///
// Creates a copy of an existing string list.
///
CEF_EXPORT cef_string_list_t cef_string_list_copy(cef_string_list_t list);
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_INTERNAL_CEF_STRING_LIST_H_

View File

@ -0,0 +1,97 @@
// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CEF_INCLUDE_INTERNAL_CEF_STRING_MAP_H_
#define CEF_INCLUDE_INTERNAL_CEF_STRING_MAP_H_
#pragma once
#include "include/internal/cef_export.h"
#include "include/internal/cef_string.h"
#ifdef __cplusplus
extern "C" {
#endif
///
// CEF string maps are a set of key/value string pairs.
///
typedef void* cef_string_map_t;
///
// Allocate a new string map.
///
CEF_EXPORT cef_string_map_t cef_string_map_alloc();
///
// Return the number of elements in the string map.
///
CEF_EXPORT int cef_string_map_size(cef_string_map_t map);
///
// Return the value assigned to the specified key.
///
CEF_EXPORT int cef_string_map_find(cef_string_map_t map,
const cef_string_t* key,
cef_string_t* value);
///
// Return the key at the specified zero-based string map index.
///
CEF_EXPORT int cef_string_map_key(cef_string_map_t map, int 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_string_t* value);
///
// Append a new key/value pair at the end of the string map.
///
CEF_EXPORT int cef_string_map_append(cef_string_map_t map,
const cef_string_t* key,
const cef_string_t* value);
///
// Clear the string map.
///
CEF_EXPORT void cef_string_map_clear(cef_string_map_t map);
///
// Free the string map.
///
CEF_EXPORT void cef_string_map_free(cef_string_map_t map);
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_INTERNAL_CEF_STRING_MAP_H_

View File

@ -0,0 +1,105 @@
// Copyright (c) 2011 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CEF_INCLUDE_INTERNAL_CEF_STRING_MULTIMAP_H_
#define CEF_INCLUDE_INTERNAL_CEF_STRING_MULTIMAP_H_
#pragma once
#include "include/internal/cef_export.h"
#include "include/internal/cef_string.h"
#ifdef __cplusplus
extern "C" {
#endif
///
// CEF string multimaps are a set of key/value string pairs.
// More than one value can be assigned to a single key.
///
typedef void* cef_string_multimap_t;
///
// Allocate a new string multimap.
///
CEF_EXPORT cef_string_multimap_t cef_string_multimap_alloc();
///
// Return the number of elements in the string multimap.
///
CEF_EXPORT int 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);
///
// 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,
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_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_string_t* value);
///
// Append a new key/value pair at the end of the string multimap.
///
CEF_EXPORT int cef_string_multimap_append(cef_string_multimap_t map,
const cef_string_t* key,
const cef_string_t* value);
///
// Clear the string multimap.
///
CEF_EXPORT void cef_string_multimap_clear(cef_string_multimap_t map);
///
// Free the string multimap.
///
CEF_EXPORT void cef_string_multimap_free(cef_string_multimap_t map);
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_INTERNAL_CEF_STRING_MULTIMAP_H_

View File

@ -0,0 +1,204 @@
// Copyright (c) 2010 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CEF_INCLUDE_INTERNAL_CEF_STRING_TYPES_H_
#define CEF_INCLUDE_INTERNAL_CEF_STRING_TYPES_H_
#pragma once
// CEF provides functions for converting between UTF-8, -16 and -32 strings.
// CEF string types are safe for reading from multiple threads but not for
// modification. It is the user's responsibility to provide synchronization if
// modifying CEF strings from multiple threads.
#ifdef __cplusplus
extern "C" {
#endif
#include "include/internal/cef_build.h"
#include "include/internal/cef_export.h"
#include <stddef.h>
// 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
// CEF string type definitions. Whomever allocates |str| is responsible for
// providing an appropriate |dtor| implementation that will free the string in
// the same memory space. When reusing an existing string structure make sure
// to call |dtor| for the old value before assigning new |str| and |dtor|
// values. Static strings will have a NULL |dtor| value. Using the below
// functions if you want this managed for you.
typedef struct _cef_string_wide_t {
wchar_t* str;
size_t length;
void (*dtor)(wchar_t* str);
} cef_string_wide_t;
typedef struct _cef_string_utf8_t {
char* str;
size_t length;
void (*dtor)(char* str);
} cef_string_utf8_t;
typedef struct _cef_string_utf16_t {
char16* str;
size_t length;
void (*dtor)(char16* str);
} cef_string_utf16_t;
///
// These functions set string values. If |copy| is true (1) the value will be
// copied instead of referenced. It is up to the user to properly manage
// the lifespan of references.
///
CEF_EXPORT int cef_string_wide_set(const wchar_t* src, size_t src_len,
cef_string_wide_t* output, int copy);
CEF_EXPORT int cef_string_utf8_set(const char* src, size_t src_len,
cef_string_utf8_t* output, int copy);
CEF_EXPORT int cef_string_utf16_set(const char16* src, size_t src_len,
cef_string_utf16_t* output, int copy);
///
// Convenience macros for copying values.
///
#define cef_string_wide_copy(src, src_len, output) \
cef_string_wide_set(src, src_len, output, true)
#define cef_string_utf8_copy(src, src_len, output) \
cef_string_utf8_set(src, src_len, output, true)
#define cef_string_utf16_copy(src, src_len, output) \
cef_string_utf16_set(src, src_len, output, true)
///
// These functions clear string values. The structure itself is not freed.
///
CEF_EXPORT void cef_string_wide_clear(cef_string_wide_t* str);
CEF_EXPORT void cef_string_utf8_clear(cef_string_utf8_t* str);
CEF_EXPORT void cef_string_utf16_clear(cef_string_utf16_t* str);
///
// These functions compare two string values with the same results as strcmp().
///
CEF_EXPORT int cef_string_wide_cmp(const cef_string_wide_t* str1,
const cef_string_wide_t* str2);
CEF_EXPORT int cef_string_utf8_cmp(const cef_string_utf8_t* str1,
const cef_string_utf8_t* str2);
CEF_EXPORT int cef_string_utf16_cmp(const cef_string_utf16_t* str1,
const cef_string_utf16_t* str2);
///
// These functions convert between UTF-8, -16, and -32 strings. They are
// potentially slow so unnecessary conversions should be avoided. The best
// possible result will always be written to |output| with the boolean return
// value indicating whether the conversion is 100% valid.
///
CEF_EXPORT int cef_string_wide_to_utf8(const wchar_t* src, size_t src_len,
cef_string_utf8_t* output);
CEF_EXPORT int cef_string_utf8_to_wide(const char* src, size_t src_len,
cef_string_wide_t* output);
CEF_EXPORT int cef_string_wide_to_utf16(const wchar_t* src, size_t src_len,
cef_string_utf16_t* output);
CEF_EXPORT int cef_string_utf16_to_wide(const char16* src, size_t src_len,
cef_string_wide_t* output);
CEF_EXPORT int cef_string_utf8_to_utf16(const char* src, size_t src_len,
cef_string_utf16_t* output);
CEF_EXPORT int cef_string_utf16_to_utf8(const char16* src, size_t src_len,
cef_string_utf8_t* output);
///
// These functions convert an ASCII string, typically a hardcoded constant, to a
// Wide/UTF16 string. Use instead of the UTF8 conversion routines if you know
// the string is ASCII.
///
CEF_EXPORT int cef_string_ascii_to_wide(const char* src, size_t src_len,
cef_string_wide_t* output);
CEF_EXPORT int cef_string_ascii_to_utf16(const char* src, size_t src_len,
cef_string_utf16_t* output);
///
// It is sometimes necessary for the system to allocate string structures with
// the expectation that the user will free them. The userfree types act as a
// hint that the user is responsible for freeing the structure.
///
typedef cef_string_wide_t* cef_string_userfree_wide_t;
typedef cef_string_utf8_t* cef_string_userfree_utf8_t;
typedef cef_string_utf16_t* cef_string_userfree_utf16_t;
///
// These functions allocate a new string structure. They must be freed by
// calling the associated free function.
///
CEF_EXPORT cef_string_userfree_wide_t cef_string_userfree_wide_alloc();
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.
///
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);
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_INTERNAL_CEF_STRING_TYPES_H_

View File

@ -0,0 +1,708 @@
// Copyright (c) 2010 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CEF_INCLUDE_INTERNAL_CEF_STRING_WRAPPERS_H_
#define CEF_INCLUDE_INTERNAL_CEF_STRING_WRAPPERS_H_
#pragma once
#include <memory.h>
#include <string>
#include "include/internal/cef_string_types.h"
#ifdef BUILDING_CEF_SHARED
#include "base/string16.h"
#endif
///
// Traits implementation for wide character strings.
///
struct CefStringTraitsWide {
typedef wchar_t char_type;
typedef cef_string_wide_t struct_type;
typedef cef_string_userfree_wide_t userfree_struct_type;
static inline void clear(struct_type *s) { cef_string_wide_clear(s); }
static inline int set(const char_type* src, size_t src_size,
struct_type* output, int copy) {
return cef_string_wide_set(src, src_size, output, copy);
}
static inline int compare(const struct_type* s1, const struct_type* s2) {
return cef_string_wide_cmp(s1, s2);
}
static inline userfree_struct_type userfree_alloc() {
return cef_string_userfree_wide_alloc();
}
static inline void userfree_free(userfree_struct_type ufs) {
return cef_string_userfree_wide_free(ufs);
}
// Conversion methods.
static inline bool from_ascii(const char* str, size_t len, struct_type *s) {
return cef_string_ascii_to_wide(str, len, s) ? true : false;
}
static inline std::string to_string(const struct_type *s) {
cef_string_utf8_t cstr;
memset(&cstr, 0, sizeof(cstr));
cef_string_wide_to_utf8(s->str, s->length, &cstr);
std::string str;
if (cstr.length > 0)
str = std::string(cstr.str, cstr.length);
cef_string_utf8_clear(&cstr);
return str;
}
static inline bool from_string(const std::string& 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) {
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;
}
#if defined(BUILDING_CEF_SHARED)
#if defined(WCHAR_T_IS_UTF32)
static inline 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);
string16 str;
if (cstr.length > 0)
str = string16(cstr.str, cstr.length);
cef_string_utf16_clear(&cstr);
return str;
}
static inline bool from_string16(const 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 string16 to_string16(const struct_type *s) {
return string16(s->str, s->length);
}
static inline bool from_string16(const 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
};
///
// Traits implementation for utf8 character strings.
///
struct CefStringTraitsUTF8 {
typedef char char_type;
typedef cef_string_utf8_t struct_type;
typedef cef_string_userfree_utf8_t userfree_struct_type;
static inline void clear(struct_type *s) { cef_string_utf8_clear(s); }
static inline int set(const char_type* src, size_t src_size,
struct_type* output, int copy) {
return cef_string_utf8_set(src, src_size, output, copy);
}
static inline int compare(const struct_type* s1, const struct_type* s2) {
return cef_string_utf8_cmp(s1, s2);
}
static inline userfree_struct_type userfree_alloc() {
return cef_string_userfree_utf8_alloc();
}
static inline void userfree_free(userfree_struct_type ufs) {
return cef_string_userfree_utf8_free(ufs);
}
// Conversion methods.
static inline bool from_ascii(const char* str, size_t len, struct_type* s) {
return cef_string_utf8_copy(str, len, s) ? true : false;
}
static inline std::string to_string(const struct_type* s) {
return std::string(s->str, s->length);
}
static inline bool from_string(const std::string& str, struct_type* s) {
return cef_string_utf8_copy(str.c_str(), str.length(), s) ? true : false;
}
static inline std::wstring to_wstring(const struct_type* s) {
cef_string_wide_t cstr;
memset(&cstr, 0, sizeof(cstr));
cef_string_utf8_to_wide(s->str, s->length, &cstr);
std::wstring str;
if (cstr.length > 0)
str = std::wstring(cstr.str, cstr.length);
cef_string_wide_clear(&cstr);
return str;
}
static inline bool from_wstring(const std::wstring& 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 string16 to_string16(const struct_type* s) {
cef_string_utf16_t cstr;
memset(&cstr, 0, sizeof(cstr));
cef_string_utf8_to_utf16(s->str, s->length, &cstr);
string16 str;
if (cstr.length > 0)
str = string16(cstr.str, cstr.length);
cef_string_utf16_clear(&cstr);
return str;
}
static inline bool from_string16(const string16& str, struct_type* s) {
return cef_string_utf16_to_utf8(str.c_str(), str.length(), s) ?
true : false;
}
#endif // BUILDING_CEF_SHARED
};
///
// Traits implementation for utf16 character strings.
///
struct CefStringTraitsUTF16 {
typedef char16 char_type;
typedef cef_string_utf16_t struct_type;
typedef cef_string_userfree_utf16_t userfree_struct_type;
static inline void clear(struct_type *s) { cef_string_utf16_clear(s); }
static inline int set(const char_type* src, size_t src_size,
struct_type* output, int copy) {
return cef_string_utf16_set(src, src_size, output, copy);
}
static inline int compare(const struct_type* s1, const struct_type* s2) {
return cef_string_utf16_cmp(s1, s2);
}
static inline userfree_struct_type userfree_alloc() {
return cef_string_userfree_utf16_alloc();
}
static inline void userfree_free(userfree_struct_type ufs) {
return cef_string_userfree_utf16_free(ufs);
}
// Conversion methods.
static inline bool from_ascii(const char* str, size_t len, struct_type* s) {
return cef_string_ascii_to_utf16(str, len, s) ? true : false;
}
static inline std::string to_string(const struct_type* s) {
cef_string_utf8_t cstr;
memset(&cstr, 0, sizeof(cstr));
cef_string_utf16_to_utf8(s->str, s->length, &cstr);
std::string str;
if (cstr.length > 0)
str = std::string(cstr.str, cstr.length);
cef_string_utf8_clear(&cstr);
return str;
}
static inline bool from_string(const std::string& str, struct_type* s) {
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) {
cef_string_wide_t cstr;
memset(&cstr, 0, sizeof(cstr));
cef_string_utf16_to_wide(s->str, s->length, &cstr);
std::wstring str;
if (cstr.length > 0)
str = std::wstring(cstr.str, cstr.length);
cef_string_wide_clear(&cstr);
return str;
}
static inline bool from_wstring(const std::wstring& str, struct_type* s) {
return cef_string_wide_to_utf16(str.c_str(), str.length(), s) ?
true : false;
}
#else // WCHAR_T_IS_UTF32
static inline std::wstring to_wstring(const struct_type* s) {
return std::wstring(s->str, s->length);
}
static inline bool from_wstring(const std::wstring& str, struct_type* s) {
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 string16 to_string16(const struct_type* s) {
return string16(s->str, s->length);
}
static inline bool from_string16(const string16& str, struct_type* s) {
return cef_string_utf16_set(str.c_str(), str.length(), s, true) ?
true : false;
}
#endif // BUILDING_CEF_SHARED
};
///
// CEF string classes can convert between all supported string types. For
// example, the CefStringWide class uses wchar_t as the underlying character
// type and provides two approaches for converting data to/from a UTF8 string
// (std::string).
// <p>
// 1. Implicit conversion using the assignment operator overload.
// <pre>
// CefStringWide aCefString;
// std::string aUTF8String;
// aCefString = aUTF8String; // Assign std::string to CefStringWide
// aUTF8String = aCefString; // Assign CefStringWide to std::string
// </pre>
// 2. Explicit conversion using the FromString/ToString methods.
// <pre>
// CefStringWide aCefString;
// std::string aUTF8String;
// aCefString.FromString(aUTF8String); // Assign std::string to CefStringWide
// aUTF8String = aCefString.ToString(); // Assign CefStringWide to std::string
// </pre>
// Conversion will only occur if the assigned value is a different string type.
// Assigning a std::string to a CefStringUTF8, for example, will copy the data
// without performing a conversion.
// </p>
// CEF string classes are safe for reading from multiple threads but not for
// modification. It is the user's responsibility to provide synchronization if
// modifying CEF strings from multiple threads.
///
template <class traits>
class CefStringBase {
public:
typedef typename traits::char_type char_type;
typedef typename traits::struct_type struct_type;
typedef typename traits::userfree_struct_type userfree_struct_type;
///
// Default constructor.
///
CefStringBase() : string_(NULL), owner_(false) {}
///
// Create a new string from an existing string. Data will always be copied.
///
CefStringBase(const CefStringBase& str)
: string_(NULL), owner_(false) {
FromString(str.c_str(), str.length(), true);
}
///
// Create a new string from an existing std::string. Data will be always
// copied. Translation will occur if necessary based on the underlying string
// type.
///
CefStringBase(const std::string& src) // NOLINT(runtime/explicit)
: string_(NULL), owner_(false) {
FromString(src);
}
CefStringBase(const char* src) // NOLINT(runtime/explicit)
: string_(NULL), owner_(false) {
FromString(std::string(src));
}
///
// Create a new string from an existing std::wstring. Data will be always
// copied. Translation will occur if necessary based on the underlying string
// type.
///
CefStringBase(const std::wstring& src) // NOLINT(runtime/explicit)
: string_(NULL), owner_(false) {
FromWString(src);
}
CefStringBase(const wchar_t* src) // NOLINT(runtime/explicit)
: string_(NULL), owner_(false) {
FromWString(std::wstring(src));
}
#if (defined(BUILDING_CEF_SHARED) && 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 string16& src) // NOLINT(runtime/explicit)
: string_(NULL), owner_(false) {
FromString16(src);
}
CefStringBase(const char16* src) // NOLINT(runtime/explicit)
: string_(NULL), owner_(false) {
FromString16(string16(src));
}
#endif // BUILDING_CEF_SHARED && WCHAR_T_IS_UTF32
///
// Create a new string from an existing character array. If |copy| is true
// this class will copy the data. Otherwise, this class will reference the
// existing data. Referenced data must exist for the lifetime of this class
// and will not be freed by this class.
///
CefStringBase(const char_type* src, size_t src_len, bool copy)
: string_(NULL), owner_(false) {
FromString(src, src_len, copy);
}
///
// Create a new string referencing an existing string structure without taking
// ownership. Referenced structures must exist for the lifetime of this class
// and will not be freed by this class.
///
CefStringBase(const struct_type* src) // NOLINT(runtime/explicit)
: string_(NULL), owner_(false) {
if (!src)
return;
// Reference the existing structure without taking ownership.
Attach(const_cast<struct_type*>(src), false);
}
virtual ~CefStringBase() { ClearAndFree(); }
// The following methods are named for compatibility with the standard library
// string template types.
///
// Return a read-only pointer to the string data.
///
const char_type* c_str() const { return (string_ ? string_->str : NULL); }
///
// Return the length of the string data.
///
size_t length() const { return (string_ ? string_->length : 0); }
///
// Return the length of the string data.
///
inline size_t size() const { return length(); }
///
// Returns true if the string is empty.
///
bool empty() const { return (string_ == NULL || string_->length == 0); }
///
// Compare this string to the specified string.
///
int compare(const CefStringBase& str) const {
if (empty() && str.empty())
return 0;
if (empty())
return -1;
if (str.empty())
return 1;
return traits::compare(string_, str.GetStruct());
}
///
// Clear the string data.
///
void clear() {
if (!empty())
traits::clear(string_);
}
// The following methods are unique to CEF string template types.
///
// Returns true if this class owns the underlying string structure.
///
bool IsOwner() const { return owner_; }
///
// Returns a read-only pointer to the underlying string structure. May return
// NULL if no structure is currently allocated.
///
const struct_type* GetStruct() const { return string_; }
///
// Returns a writable pointer to the underlying string structure. Will never
// return NULL.
///
struct_type* GetWritableStruct() {
AllocIfNeeded();
return string_;
}
///
// Clear the state of this class. The underlying string structure and data
// will be freed if this class owns the structure.
///
void ClearAndFree() {
if (!string_)
return;
if (owner_) {
clear();
delete string_;
}
string_ = NULL;
owner_ = false;
}
///
// Attach to the specified string structure. If |owner| is true this class
// will take ownership of the structure.
///
void Attach(struct_type* str, bool owner) {
// Free the previous structure and data, if any.
ClearAndFree();
string_ = str;
owner_ = owner;
}
///
// Take ownership of the specified userfree structure's string data. The
// userfree structure itself will be freed. Only use this method with userfree
// structures.
///
void AttachToUserFree(userfree_struct_type str) {
// Free the previous structure and data, if any.
ClearAndFree();
if (!str)
return;
AllocIfNeeded();
owner_ = true;
memcpy(string_, str, sizeof(struct_type));
// Free the |str| structure but not the data.
memset(str, 0, sizeof(struct_type));
traits::userfree_free(str);
}
///
// Detach from the underlying string structure. To avoid memory leaks only use
// this method if you already hold a pointer to the underlying string
// structure.
///
void Detach() {
string_ = NULL;
owner_ = false;
}
///
// Create a userfree structure and give it ownership of this class' string
// data. This class will be disassociated from the data. May return NULL if
// this string class currently contains no data.
///
userfree_struct_type DetachToUserFree() {
if (empty())
return NULL;
userfree_struct_type str = traits::userfree_alloc();
memcpy(str, string_, sizeof(struct_type));
// Free this class' structure but not the data.
memset(string_, 0, sizeof(struct_type));
ClearAndFree();
return str;
}
///
// Set this string's data to the specified character array. If |copy| is true
// this class will copy the data. Otherwise, this class will reference the
// existing data. Referenced data must exist for the lifetime of this class
// and will not be freed by this class.
///
bool FromString(const char_type* src, size_t src_len, bool copy) {
if (src == NULL || src_len == 0) {
clear();
return true;
}
AllocIfNeeded();
return traits::set(src, src_len, string_, copy) ? true : false;
}
///
// Set this string's data from an existing ASCII string. Data will be always
// copied. Translation will occur if necessary based on the underlying string
// type.
///
bool FromASCII(const char* str) {
size_t len = str ? strlen(str) : 0;
if (len == 0) {
clear();
return true;
}
AllocIfNeeded();
return traits::from_ascii(str, len, string_);
}
///
// Return this string's data as a std::string. Translation will occur if
// necessary based on the underlying string type.
///
std::string ToString() const {
if (empty())
return std::string();
return traits::to_string(string_);
}
///
// Set this string's data from an existing std::string. Data will be always
// copied. Translation will occur if necessary based on the underlying string
// type.
///
bool FromString(const std::string& str) {
if (str.empty()) {
clear();
return true;
}
AllocIfNeeded();
return traits::from_string(str, string_);
}
///
// Return this string's data as a std::wstring. Translation will occur if
// necessary based on the underlying string type.
///
std::wstring ToWString() const {
if (empty())
return std::wstring();
return traits::to_wstring(string_);
}
///
// Set this string's data from an existing std::wstring. Data will be always
// copied. Translation will occur if necessary based on the underlying string
// type.
///
bool FromWString(const std::wstring& str) {
if (str.empty()) {
clear();
return true;
}
AllocIfNeeded();
return traits::from_wstring(str, string_);
}
#if defined(BUILDING_CEF_SHARED)
///
// Return this string's data as a string16. Translation will occur if
// necessary based on the underlying string type.
///
string16 ToString16() const {
if (empty())
return string16();
return traits::to_string16(string_);
}
///
// Set this string's data from an existing string16. Data will be always
// copied. Translation will occur if necessary based on the underlying string
// type.
///
bool FromString16(const string16& str) {
if (str.empty()) {
clear();
return true;
}
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);
}
///
// Assignment operator overloads.
///
CefStringBase& operator=(const CefStringBase& str) {
FromString(str.c_str(), str.length(), true);
return *this;
}
operator std::string() const {
return ToString();
}
CefStringBase& operator=(const std::string& str) {
FromString(str);
return *this;
}
CefStringBase& operator=(const char* str) {
FromString(std::string(str));
return *this;
}
operator std::wstring() const {
return ToWString();
}
CefStringBase& operator=(const std::wstring& str) {
FromWString(str);
return *this;
}
CefStringBase& operator=(const wchar_t* str) {
FromWString(std::wstring(str));
return *this;
}
#if (defined(BUILDING_CEF_SHARED) && defined(WCHAR_T_IS_UTF32))
operator string16() const {
return ToString16();
}
CefStringBase& operator=(const string16& str) {
FromString16(str);
return *this;
}
CefStringBase& operator=(const char16* str) {
FromString16(string16(str));
return *this;
}
#endif // BUILDING_CEF_SHARED && WCHAR_T_IS_UTF32
private:
// Allocate the string structure if it doesn't already exist.
void AllocIfNeeded() {
if (string_ == NULL) {
string_ = new struct_type;
memset(string_, 0, sizeof(struct_type));
owner_ = true;
}
}
struct_type* string_;
bool owner_;
};
typedef CefStringBase<CefStringTraitsWide> CefStringWide;
typedef CefStringBase<CefStringTraitsUTF8> CefStringUTF8;
typedef CefStringBase<CefStringTraitsUTF16> CefStringUTF16;
#endif // CEF_INCLUDE_INTERNAL_CEF_STRING_WRAPPERS_H_

View File

@ -0,0 +1,78 @@
// Copyright (c) 2011 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CEF_INCLUDE_INTERNAL_CEF_TIME_H_
#define CEF_INCLUDE_INTERNAL_CEF_TIME_H_
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "include/internal/cef_export.h"
#include <time.h>
///
// Time information. Values should always be in UTC.
///
typedef struct _cef_time_t {
int year; // Four digit year "2007"
int month; // 1-based month (values 1 = January, etc.)
#if !defined(OS_MACOSX)
int day_of_week; // 0-based day of week (0 = Sunday, etc.)
#endif
int day_of_month; // 1-based day of month (1-31)
int hour; // Hour within the current day (0-23)
int minute; // Minute within the current hour (0-59)
int second; // Second within the current minute (0-59 plus leap
// seconds which may take it up to 60).
int millisecond; // Milliseconds within the current second (0-999)
} cef_time_t;
///
// Converts cef_time_t to/from time_t. Returns true (1) on success and false (0)
// on failure.
///
CEF_EXPORT int cef_time_to_timet(const cef_time_t* cef_time, time_t* time);
CEF_EXPORT int cef_time_from_timet(time_t time, cef_time_t* cef_time);
///
// Converts cef_time_t to/from a double which is the number of seconds since
// epoch (Jan 1, 1970). Webkit uses this format to represent time. A value of 0
// means "not initialized". Returns true (1) on success and false (0) on
// failure.
///
CEF_EXPORT int cef_time_to_doublet(const cef_time_t* cef_time, double* time);
CEF_EXPORT int cef_time_from_doublet(double time, cef_time_t* cef_time);
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_INTERNAL_CEF_TIME_H_

1082
include/internal/cef_tuple.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,858 @@
// Copyright (c) 2010 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_H_
#define CEF_INCLUDE_INTERNAL_CEF_TYPES_H_
#pragma once
#include "include/internal/cef_build.h"
#include "include/internal/cef_string.h"
#include "include/internal/cef_string_list.h"
#include "include/internal/cef_time.h"
// Bring in platform-specific definitions.
#if defined(OS_WIN)
#include "include/internal/cef_types_win.h"
#elif defined(OS_MACOSX)
#include "include/internal/cef_types_mac.h"
#elif defined(OS_LINUX)
#include "include/internal/cef_types_linux.h"
#endif
#include <stddef.h> // 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
// <inttypes.h> 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
#ifdef __cplusplus
extern "C" {
#endif
///
// Log severity levels.
///
enum cef_log_severity_t {
LOGSEVERITY_VERBOSE = -1,
LOGSEVERITY_INFO,
LOGSEVERITY_WARNING,
LOGSEVERITY_ERROR,
LOGSEVERITY_ERROR_REPORT,
// Disables logging completely.
LOGSEVERITY_DISABLE = 99
};
///
// Initialization settings. Specify NULL or 0 to get the recommended default
// values.
///
typedef struct _cef_settings_t {
///
// Size of this structure.
///
size_t size;
///
// Set to true (1) to use a single process for the browser and renderer. This
// run mode is not officially supported by Chromium and is less stable than
// the multi-process default.
///
bool single_process;
///
// 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.
///
cef_string_t browser_subprocess_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.
///
bool multi_threaded_message_loop;
///
// Set to true (1) to disable configuration of browser process features using
// standard CEF and Chromium command-line arguments. Configuration can still
// be specified using CEF data structures or via the
// CefApp::OnBeforeCommandLineProcessing() method.
///
bool command_line_args_disabled;
///
// The location where cache data will be stored on disk. If empty an in-memory
// cache will be used. HTML5 databases such as localStorage will only persist
// across sessions if a cache path is specified.
///
cef_string_t cache_path;
///
// Value that will be returned as the User-Agent HTTP header. If empty the
// default User-Agent string will be used.
///
cef_string_t user_agent;
///
// Value that will be inserted as the product portion of the default
// User-Agent string. If empty the Chromium product version will be used. If
// |userAgent| is specified this value will be ignored.
///
cef_string_t product_version;
///
// The locale string that will be passed to WebKit. If empty the default
// locale of "en-US" will be used. This value is ignored on Linux where locale
// is determined using environment variable parsing with the precedence order:
// LANGUAGE, LC_ALL, LC_MESSAGES and LANG.
///
cef_string_t locale;
///
// List of fully qualified paths to plugins (including plugin name) that will
// be loaded in addition to any plugins found in the default search paths.
///
cef_string_list_t extra_plugin_paths;
///
// 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.
///
cef_string_t log_file;
///
// The log severity. Only messages of this severity level or higher will be
// logged.
///
cef_log_severity_t log_severity;
///
// The graphics implementation that CEF will use for rendering GPU accelerated
// content like WebGL, accelerated layers and 3D CSS.
///
cef_graphics_implementation_t graphics_implementation;
///
// Quota limit for localStorage data across all origins. Default size is 5MB.
///
unsigned int local_storage_quota;
///
// Quota limit for sessionStorage data per namespace. Default size is 5MB.
///
unsigned int session_storage_quota;
///
// Custom flags that will be used when initializing the V8 JavaScript engine.
// The consequences of using custom flags may not be well tested.
///
cef_string_t javascript_flags;
#if defined(OS_WIN)
///
// Set to true (1) to use the system proxy resolver on Windows when
// "Automatically detect settings" is checked. This setting is disabled
// by default for performance reasons.
///
bool auto_detect_proxy_settings_enabled;
#endif
///
// The fully qualified path for the cef.pak file. If this value is empty
// the cef.pak file must be located in the module directory. This value is
// ignored on Mac OS X where pack files are always loaded from the app bundle
// resource directory.
///
cef_string_t pack_file_path;
///
// The fully qualified path for the locales directory. If this value is empty
// the locales directory must be located in the module directory. This value
// is ignored on Mac OS X where pack files are always loaded from the app
// bundle resource directory.
///
cef_string_t locales_dir_path;
///
// Set to true (1) to disable loading of pack files for resources and locales.
// A resource bundle handler must be provided for the browser and render
// processes via CefApp::GetResourceBundleHandler() if loading of pack files
// is disabled.
///
bool pack_loading_disabled;
} cef_settings_t;
///
// Browser initialization settings. Specify NULL or 0 to get the recommended
// default values. The consequences of using custom values may not be well
// tested.
///
typedef struct _cef_browser_settings_t {
///
// Size of this structure.
///
size_t size;
///
// Disable drag & drop of URLs from other windows.
///
bool drag_drop_disabled;
///
// Disable default navigation resulting from drag & drop of URLs.
///
bool load_drops_disabled;
///
// Disable history back/forward navigation.
///
bool history_disabled;
// The below values map to WebPreferences settings.
///
// Font settings.
///
cef_string_t standard_font_family;
cef_string_t fixed_font_family;
cef_string_t serif_font_family;
cef_string_t sans_serif_font_family;
cef_string_t cursive_font_family;
cef_string_t fantasy_font_family;
int default_font_size;
int default_fixed_font_size;
int minimum_font_size;
int minimum_logical_font_size;
///
// Set to true (1) to disable loading of fonts from remote sources.
///
bool remote_fonts_disabled;
///
// Default encoding for Web content. If empty "ISO-8859-1" will be used.
///
cef_string_t default_encoding;
///
// Set to true (1) to attempt automatic detection of content encoding.
///
bool encoding_detector_enabled;
///
// Set to true (1) to disable JavaScript.
///
bool javascript_disabled;
///
// Set to true (1) to disallow JavaScript from opening windows.
///
bool javascript_open_windows_disallowed;
///
// Set to true (1) to disallow JavaScript from closing windows.
///
bool javascript_close_windows_disallowed;
///
// Set to true (1) to disallow JavaScript from accessing the clipboard.
///
bool javascript_access_clipboard_disallowed;
///
// Set to true (1) to disable DOM pasting in the editor. DOM pasting also
// depends on |javascript_cannot_access_clipboard| being false (0).
///
bool dom_paste_disabled;
///
// Set to true (1) to enable drawing of the caret position.
///
bool caret_browsing_enabled;
///
// Set to true (1) to disable Java.
///
bool java_disabled;
///
// Set to true (1) to disable plugins.
///
bool plugins_disabled;
///
// Set to true (1) to allow access to all URLs from file URLs.
///
bool universal_access_from_file_urls_allowed;
///
// Set to true (1) to allow access to file URLs from other file URLs.
///
bool file_access_from_file_urls_allowed;
///
// Set to true (1) to allow risky security behavior such as cross-site
// scripting (XSS). Use with extreme care.
///
bool web_security_disabled;
///
// Set to true (1) to enable console warnings about XSS attempts.
///
bool xss_auditor_enabled;
///
// Set to true (1) to suppress the network load of image URLs. A cached
// image will still be rendered if requested.
///
bool image_load_disabled;
///
// Set to true (1) to shrink standalone images to fit the page.
///
bool shrink_standalone_images_to_fit;
///
// Set to true (1) to disable browser backwards compatibility features.
///
bool site_specific_quirks_disabled;
///
// Set to true (1) to disable resize of text areas.
///
bool text_area_resize_disabled;
///
// Set to true (1) to disable use of the page cache.
///
bool page_cache_disabled;
///
// Set to true (1) to not have the tab key advance focus to links.
///
bool tab_to_links_disabled;
///
// Set to true (1) to disable hyperlink pings (<a ping> and window.sendPing).
///
bool hyperlink_auditing_disabled;
///
// Set to true (1) to enable the user style sheet for all pages.
///
bool user_style_sheet_enabled;
///
// Location of the user style sheet. This must be a data URL of the form
// "data:text/css;charset=utf-8;base64,csscontent" where "csscontent" is the
// base64 encoded contents of the CSS file.
///
cef_string_t user_style_sheet_location;
///
// Set to true (1) to disable style sheets.
///
bool author_and_user_styles_disabled;
///
// Set to true (1) to disable local storage.
///
bool local_storage_disabled;
///
// Set to true (1) to disable databases.
///
bool databases_disabled;
///
// Set to true (1) to disable application cache.
///
bool application_cache_disabled;
///
// Set to true (1) to disable WebGL.
///
bool webgl_disabled;
///
// Set to true (1) to disable accelerated compositing.
///
bool accelerated_compositing_disabled;
///
// Set to true (1) to disable accelerated layers. This affects features like
// 3D CSS transforms.
///
bool accelerated_layers_disabled;
///
// Set to true (1) to disable accelerated video.
///
bool accelerated_video_disabled;
///
// Set to true (1) to disable accelerated 2d canvas.
///
bool accelerated_2d_canvas_disabled;
///
// Set to true (1) to enable accelerated painting.
///
bool accelerated_painting_enabled;
///
// Set to true (1) to enable accelerated filters.
///
bool accelerated_filters_enabled;
///
// Set to true (1) to disable accelerated plugins.
///
bool accelerated_plugins_disabled;
///
// Set to true (1) to disable developer tools (WebKit inspector).
///
bool developer_tools_disabled;
///
// Set to true (1) to enable fullscreen mode.
///
bool fullscreen_enabled;
} cef_browser_settings_t;
///
// URL component parts.
///
typedef struct _cef_urlparts_t {
///
// The complete URL specification.
///
cef_string_t spec;
///
// Scheme component not including the colon (e.g., "http").
///
cef_string_t scheme;
///
// User name component.
///
cef_string_t username;
///
// Password component.
///
cef_string_t password;
///
// Host component. This may be a hostname, an IPv4 address or an IPv6 literal
// surrounded by square brackets (e.g., "[2001:db8::1]").
///
cef_string_t host;
///
// Port number component.
///
cef_string_t port;
///
// Path component including the first slash following the host.
///
cef_string_t path;
///
// Query string component (i.e., everything following the '?').
///
cef_string_t query;
} cef_urlparts_t;
///
// Cookie information.
///
typedef struct _cef_cookie_t {
///
// The cookie name.
///
cef_string_t name;
///
// The cookie value.
///
cef_string_t value;
///
// If |domain| is empty a host cookie will be created instead of a domain
// cookie. Domain cookies are stored with a leading "." and are visible to
// sub-domains whereas host cookies are not.
///
cef_string_t domain;
///
// If |path| is non-empty only URLs at or below the path will get the cookie
// value.
///
cef_string_t path;
///
// If |secure| is true the cookie will only be sent for HTTPS requests.
///
bool secure;
///
// If |httponly| is true the cookie will only be sent for HTTP requests.
///
bool httponly;
///
// The cookie creation date. This is automatically populated by the system on
// cookie creation.
///
cef_time_t creation;
///
// The cookie last access date. This is automatically populated by the system
// on access.
///
cef_time_t last_access;
///
// The cookie expiration date is only valid if |has_expires| is true.
///
bool has_expires;
cef_time_t expires;
} cef_cookie_t;
///
// Storage types.
///
enum cef_storage_type_t {
ST_LOCALSTORAGE = 0,
ST_SESSIONSTORAGE,
};
///
// Supported error code values. See net\base\net_error_list.h for complete
// descriptions of the error codes.
///
enum cef_handler_errorcode_t {
ERR_FAILED = -2,
ERR_ABORTED = -3,
ERR_INVALID_ARGUMENT = -4,
ERR_INVALID_HANDLE = -5,
ERR_FILE_NOT_FOUND = -6,
ERR_TIMED_OUT = -7,
ERR_FILE_TOO_BIG = -8,
ERR_UNEXPECTED = -9,
ERR_ACCESS_DENIED = -10,
ERR_NOT_IMPLEMENTED = -11,
ERR_CONNECTION_CLOSED = -100,
ERR_CONNECTION_RESET = -101,
ERR_CONNECTION_REFUSED = -102,
ERR_CONNECTION_ABORTED = -103,
ERR_CONNECTION_FAILED = -104,
ERR_NAME_NOT_RESOLVED = -105,
ERR_INTERNET_DISCONNECTED = -106,
ERR_SSL_PROTOCOL_ERROR = -107,
ERR_ADDRESS_INVALID = -108,
ERR_ADDRESS_UNREACHABLE = -109,
ERR_SSL_CLIENT_AUTH_CERT_NEEDED = -110,
ERR_TUNNEL_CONNECTION_FAILED = -111,
ERR_NO_SSL_VERSIONS_ENABLED = -112,
ERR_SSL_VERSION_OR_CIPHER_MISMATCH = -113,
ERR_SSL_RENEGOTIATION_REQUESTED = -114,
ERR_CERT_COMMON_NAME_INVALID = -200,
ERR_CERT_DATE_INVALID = -201,
ERR_CERT_AUTHORITY_INVALID = -202,
ERR_CERT_CONTAINS_ERRORS = -203,
ERR_CERT_NO_REVOCATION_MECHANISM = -204,
ERR_CERT_UNABLE_TO_CHECK_REVOCATION = -205,
ERR_CERT_REVOKED = -206,
ERR_CERT_INVALID = -207,
ERR_CERT_END = -208,
ERR_INVALID_URL = -300,
ERR_DISALLOWED_URL_SCHEME = -301,
ERR_UNKNOWN_URL_SCHEME = -302,
ERR_TOO_MANY_REDIRECTS = -310,
ERR_UNSAFE_REDIRECT = -311,
ERR_UNSAFE_PORT = -312,
ERR_INVALID_RESPONSE = -320,
ERR_INVALID_CHUNKED_ENCODING = -321,
ERR_METHOD_NOT_SUPPORTED = -322,
ERR_UNEXPECTED_PROXY_AUTH = -323,
ERR_EMPTY_RESPONSE = -324,
ERR_RESPONSE_HEADERS_TOO_BIG = -325,
ERR_CACHE_MISS = -400,
ERR_INSECURE_RESPONSE = -501,
};
///
// V8 access control values.
///
enum cef_v8_accesscontrol_t {
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
};
///
// V8 property attribute values.
///
enum cef_v8_propertyattribute_t {
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
};
///
// Post data elements may represent either bytes or files.
///
enum cef_postdataelement_type_t {
PDE_TYPE_EMPTY = 0,
PDE_TYPE_BYTES,
PDE_TYPE_FILE,
};
enum cef_weburlrequest_flags_t {
WUR_FLAG_NONE = 0,
WUR_FLAG_SKIP_CACHE = 0x1,
WUR_FLAG_ALLOW_CACHED_CREDENTIALS = 0x2,
WUR_FLAG_ALLOW_COOKIES = 0x4,
WUR_FLAG_REPORT_UPLOAD_PROGRESS = 0x8,
WUR_FLAG_REPORT_LOAD_TIMING = 0x10,
WUR_FLAG_REPORT_RAW_HEADERS = 0x20
};
///
// Structure representing a rectangle.
///
typedef struct _cef_rect_t {
int x;
int y;
int width;
int height;
} cef_rect_t;
///
// Existing process IDs.
///
enum cef_process_id_t {
///
// Browser process.
///
PID_BROWSER,
///
// Renderer process.
///
PID_RENDERER,
};
///
// Existing thread IDs.
///
enum cef_thread_id_t {
// BROWSER PROCESS THREADS -- Only available in the browser process.
///
// The main thread in the browser. This will be the same as the main
// application thread if CefInitialize() is called with a
// CefSettings.multi_threaded_message_loop value of false.
///
TID_UI,
///
// Used to interact with the database.
///
TID_DB,
///
// Used to interact with the file system.
///
TID_FILE,
///
// Used for file system operations that block user interactions.
// Responsiveness of this thread affects users.
///
TID_FILE_USER_BLOCKING,
///
// Used to launch and terminate browser processes.
///
TID_PROCESS_LAUNCHER,
///
// Used to handle slow HTTP cache operations.
///
TID_CACHE,
///
// Used to process IPC and network messages.
///
TID_IO,
// RENDER PROCESS THREADS -- Only available in the render process.
///
// The main thread in the renderer. Used for all WebKit and V8 interaction.
///
TID_RENDERER,
};
///
// Supported value types.
///
enum cef_value_type_t {
VTYPE_INVALID = 0,
VTYPE_NULL,
VTYPE_BOOL,
VTYPE_INT,
VTYPE_DOUBLE,
VTYPE_STRING,
VTYPE_BINARY,
VTYPE_DICTIONARY,
VTYPE_LIST,
};
///
// Supported XML encoding types. The parser supports ASCII, ISO-8859-1, and
// UTF16 (LE and BE) by default. All other types must be translated to UTF8
// before being passed to the parser. If a BOM is detected and the correct
// decoder is available then that decoder will be used automatically.
///
enum cef_xml_encoding_type_t {
XML_ENCODING_NONE = 0,
XML_ENCODING_UTF8,
XML_ENCODING_UTF16LE,
XML_ENCODING_UTF16BE,
XML_ENCODING_ASCII,
};
///
// XML node types.
///
enum cef_xml_node_type_t {
XML_NODE_UNSUPPORTED = 0,
XML_NODE_PROCESSING_INSTRUCTION,
XML_NODE_DOCUMENT_TYPE,
XML_NODE_ELEMENT_START,
XML_NODE_ELEMENT_END,
XML_NODE_ATTRIBUTE,
XML_NODE_TEXT,
XML_NODE_CDATA,
XML_NODE_ENTITY_REFERENCE,
XML_NODE_WHITESPACE,
XML_NODE_COMMENT,
};
///
// Status message types.
///
enum cef_handler_statustype_t {
STATUSTYPE_TEXT = 0,
STATUSTYPE_MOUSEOVER_URL,
STATUSTYPE_KEYBOARD_FOCUS_URL,
};
///
// Popup window features.
///
typedef struct _cef_popup_features_t {
int x;
bool xSet;
int y;
bool ySet;
int width;
bool widthSet;
int height;
bool heightSet;
bool menuBarVisible;
bool statusBarVisible;
bool toolBarVisible;
bool locationBarVisible;
bool scrollbarsVisible;
bool resizable;
bool fullscreen;
bool dialog;
cef_string_list_t additionalFeatures;
} cef_popup_features_t;
///
// Proxy types.
///
enum cef_proxy_type_t {
PROXY_TYPE_DIRECT = 0,
PROXY_TYPE_NAMED,
PROXY_TYPE_PAC_STRING,
};
///
// Proxy information.
///
typedef struct _cef_proxy_info_t {
enum cef_proxy_type_t proxyType;
cef_string_t proxyList;
} cef_proxy_info_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_H_

View File

@ -0,0 +1,82 @@
// Copyright (c) 2010 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_LINUX_H_
#define CEF_INCLUDE_INTERNAL_CEF_TYPES_LINUX_H_
#pragma once
#include "include/internal/cef_build.h"
#if defined(OS_LINUX)
#include <gtk/gtk.h>
#include "include/internal/cef_string.h"
#ifdef __cplusplus
extern "C" {
#endif
// Window handle.
#define cef_window_handle_t GtkWidget*
#define cef_cursor_handle_t void*
///
// Structure representing CefExecuteProcess arguments.
///
typedef struct _cef_main_args_t {
int argc;
char** argv;
} cef_main_args_t;
///
// Supported graphics implementations.
///
enum cef_graphics_implementation_t {
DESKTOP_IN_PROCESS = 0,
DESKTOP_IN_PROCESS_COMMAND_BUFFER,
};
///
// Class representing window information.
///
typedef struct _cef_window_info_t {
// Pointer for the parent GtkBox widget.
cef_window_handle_t parent_widget;
// Pointer for the new browser widget.
cef_window_handle_t widget;
} cef_window_info_t;
#ifdef __cplusplus
}
#endif
#endif // OS_LINUX
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_LINUX_H_

View File

@ -0,0 +1,97 @@
// Copyright (c) 2010 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_MAC_H_
#define CEF_INCLUDE_INTERNAL_CEF_TYPES_MAC_H_
#pragma once
#include "include/internal/cef_build.h"
#if defined(OS_MACOSX)
#include "include/internal/cef_string.h"
// Window handle.
#ifdef __cplusplus
#ifdef __OBJC__
@class NSView;
#else
struct NSView;
#endif
#define cef_window_handle_t NSView*
#else
#define cef_window_handle_t void*
#endif
#define cef_cursor_handle_t void*
#ifdef __cplusplus
extern "C" {
#endif
///
// Structure representing CefExecuteProcess arguments.
///
typedef struct _cef_main_args_t {
int argc;
char** argv;
} cef_main_args_t;
///
// Supported graphics implementations.
///
enum cef_graphics_implementation_t {
DESKTOP_IN_PROCESS = 0,
DESKTOP_IN_PROCESS_COMMAND_BUFFER,
};
///
// Class representing window information.
///
typedef struct _cef_window_info_t {
cef_string_t window_name;
int x;
int y;
int width;
int height;
int hidden;
// NSView pointer for the parent view.
cef_window_handle_t parent_view;
// NSView pointer for the new browser view.
cef_window_handle_t view;
} cef_window_info_t;
#ifdef __cplusplus
}
#endif
#endif // OS_MACOSX
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_MAC_H_

View File

@ -0,0 +1,94 @@
// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_WIN_H_
#define CEF_INCLUDE_INTERNAL_CEF_TYPES_WIN_H_
#pragma once
#include "include/internal/cef_build.h"
#if defined(OS_WIN)
#include <windows.h>
#include "include/internal/cef_string.h"
#ifdef __cplusplus
extern "C" {
#endif
// Window handle.
#define cef_window_handle_t HWND
#define cef_cursor_handle_t HCURSOR
///
// Structure representing CefExecuteProcess arguments.
///
typedef struct _cef_main_args_t {
HINSTANCE instance;
} cef_main_args_t;
///
// Supported graphics implementations.
///
enum cef_graphics_implementation_t {
ANGLE_IN_PROCESS = 0,
ANGLE_IN_PROCESS_COMMAND_BUFFER,
DESKTOP_IN_PROCESS,
DESKTOP_IN_PROCESS_COMMAND_BUFFER,
};
///
// Structure representing window information.
///
typedef struct _cef_window_info_t {
// Standard parameters required by CreateWindowEx()
DWORD ex_style;
cef_string_t window_name;
DWORD style;
int x;
int y;
int width;
int height;
cef_window_handle_t parent_window;
HMENU menu;
// Set to true to enable transparent painting.
BOOL transparent_painting;
// Handle for the new browser window.
cef_window_handle_t window;
} cef_window_info_t;
#ifdef __cplusplus
}
#endif
#endif // OS_WIN
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_WIN_H_

View File

@ -0,0 +1,582 @@
// 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_TYPES_WRAPPERS_H_
#define CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_
#pragma once
#include "include/internal/cef_string.h"
#include "include/internal/cef_string_list.h"
#include "include/internal/cef_types.h"
///
// Template class that provides common functionality for CEF structure wrapping.
///
template <class traits>
class CefStructBase : public traits::struct_type {
public:
typedef typename traits::struct_type struct_type;
CefStructBase() : attached_to_(NULL) {
Init();
}
virtual ~CefStructBase() {
// Only clear this object's data if it isn't currently attached to a
// structure.
if (!attached_to_)
Clear(this);
}
CefStructBase(const CefStructBase& r) {
Init();
*this = r;
}
CefStructBase(const struct_type& r) { // NOLINT(runtime/explicit)
Init();
*this = r;
}
///
// Clear this object's values.
///
void Reset() {
Clear(this);
Init();
}
///
// Attach to the source structure's existing values. DetachTo() can be called
// to insert the values back into the existing structure.
///
void AttachTo(struct_type& source) {
// Only clear this object's data if it isn't currently attached to a
// structure.
if (!attached_to_)
Clear(this);
// This object is now attached to the new structure.
attached_to_ = &source;
// Transfer ownership of the values from the source structure.
memcpy(static_cast<struct_type*>(this), &source, sizeof(struct_type));
}
///
// Relinquish ownership of values to the target structure.
///
void DetachTo(struct_type& target) {
if (attached_to_ != &target) {
// Clear the target structure's values only if we are not currently
// attached to that structure.
Clear(&target);
}
// Transfer ownership of the values to the target structure.
memcpy(&target, static_cast<struct_type*>(this), sizeof(struct_type));
// Remove the references from this object.
Init();
}
///
// Set this object's values. If |copy| is true the source structure's values
// will be copied instead of referenced.
///
void Set(const struct_type& source, bool copy) {
traits::set(&source, this, copy);
}
CefStructBase& operator=(const CefStructBase& s) {
return operator=(static_cast<const struct_type&>(s));
}
CefStructBase& operator=(const struct_type& s) {
Set(s, true);
return *this;
}
protected:
void Init() {
memset(static_cast<struct_type*>(this), 0, sizeof(struct_type));
attached_to_ = NULL;
traits::init(this);
}
static void Clear(struct_type* s) { traits::clear(s); }
struct_type* attached_to_;
};
struct CefRectTraits {
typedef cef_rect_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 rectangle.
///
class CefRect : public CefStructBase<CefRectTraits> {
public:
typedef CefStructBase<CefRectTraits> parent;
CefRect() : parent() {}
CefRect(const cef_rect_t& r) : parent(r) {} // NOLINT(runtime/explicit)
CefRect(const CefRect& r) : parent(r) {} // NOLINT(runtime/explicit)
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;
}
};
inline bool operator==(const CefRect& a, const CefRect& b) {
return a.x == b.x && a.y == b.y && a.width == b.width && a.height == b.height;
}
inline bool operator!=(const CefRect& a, const CefRect& b) {
return !(a == b);
}
struct CefPopupFeaturesTraits {
typedef cef_popup_features_t struct_type;
static inline void init(struct_type* s) {
s->menuBarVisible = true;
s->statusBarVisible = true;
s->toolBarVisible = true;
s->locationBarVisible = true;
s->scrollbarsVisible = true;
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;
target->x = src->x;
target->xSet = src->xSet;
target->y = src->y;
target->ySet = src->ySet;
target->width = src->width;
target->widthSet = src->widthSet;
target->height = src->height;
target->heightSet = src->heightSet;
target->menuBarVisible = src->menuBarVisible;
target->statusBarVisible = src->statusBarVisible;
target->toolBarVisible = src->toolBarVisible;
target->locationBarVisible = src->locationBarVisible;
target->scrollbarsVisible = src->scrollbarsVisible;
target->resizable = src->resizable;
target->fullscreen = src->fullscreen;
target->dialog = src->dialog;
}
};
///
// Class representing popup window features.
///
typedef CefStructBase<CefPopupFeaturesTraits> CefPopupFeatures;
struct CefSettingsTraits {
typedef cef_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->browser_subprocess_path);
cef_string_clear(&s->cache_path);
cef_string_clear(&s->user_agent);
cef_string_clear(&s->product_version);
cef_string_clear(&s->locale);
if (s->extra_plugin_paths)
cef_string_list_free(s->extra_plugin_paths);
cef_string_clear(&s->log_file);
cef_string_clear(&s->javascript_flags);
cef_string_clear(&s->pack_file_path);
cef_string_clear(&s->locales_dir_path);
}
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
target->single_process = src->single_process;
cef_string_set(src->browser_subprocess_path.str,
src->browser_subprocess_path.length,
&target->browser_subprocess_path, copy);
target->multi_threaded_message_loop = src->multi_threaded_message_loop;
target->command_line_args_disabled = src->command_line_args_disabled;
cef_string_set(src->cache_path.str, src->cache_path.length,
&target->cache_path, copy);
cef_string_set(src->user_agent.str, src->user_agent.length,
&target->user_agent, copy);
cef_string_set(src->product_version.str, src->product_version.length,
&target->product_version, copy);
cef_string_set(src->locale.str, src->locale.length, &target->locale, copy);
if (target->extra_plugin_paths)
cef_string_list_free(target->extra_plugin_paths);
target->extra_plugin_paths = src->extra_plugin_paths ?
cef_string_list_copy(src->extra_plugin_paths) : NULL;
cef_string_set(src->log_file.str, src->log_file.length, &target->log_file,
copy);
target->log_severity = src->log_severity;
target->graphics_implementation = src->graphics_implementation;
target->local_storage_quota = src->local_storage_quota;
target->session_storage_quota = src->session_storage_quota;
cef_string_set(src->javascript_flags.str, src->javascript_flags.length,
&target->javascript_flags, copy);
#if defined(OS_WIN)
target->auto_detect_proxy_settings_enabled =
src->auto_detect_proxy_settings_enabled;
#endif
cef_string_set(src->pack_file_path.str, src->pack_file_path.length,
&target->pack_file_path, copy);
cef_string_set(src->locales_dir_path.str, src->locales_dir_path.length,
&target->locales_dir_path, copy);
target->pack_loading_disabled = src->pack_loading_disabled;
}
};
///
// Class representing initialization settings.
///
typedef CefStructBase<CefSettingsTraits> CefSettings;
struct CefBrowserSettingsTraits {
typedef cef_browser_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->standard_font_family);
cef_string_clear(&s->fixed_font_family);
cef_string_clear(&s->serif_font_family);
cef_string_clear(&s->sans_serif_font_family);
cef_string_clear(&s->cursive_font_family);
cef_string_clear(&s->fantasy_font_family);
cef_string_clear(&s->default_encoding);
cef_string_clear(&s->user_style_sheet_location);
}
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
target->drag_drop_disabled = src->drag_drop_disabled;
target->load_drops_disabled = src->load_drops_disabled;
target->history_disabled = src->history_disabled;
cef_string_set(src->standard_font_family.str,
src->standard_font_family.length, &target->standard_font_family, copy);
cef_string_set(src->fixed_font_family.str, src->fixed_font_family.length,
&target->fixed_font_family, copy);
cef_string_set(src->serif_font_family.str, src->serif_font_family.length,
&target->serif_font_family, copy);
cef_string_set(src->sans_serif_font_family.str,
src->sans_serif_font_family.length, &target->sans_serif_font_family,
copy);
cef_string_set(src->cursive_font_family.str,
src->cursive_font_family.length, &target->cursive_font_family, copy);
cef_string_set(src->fantasy_font_family.str,
src->fantasy_font_family.length, &target->fantasy_font_family, copy);
target->default_font_size = src->default_font_size;
target->default_fixed_font_size = src->default_fixed_font_size;
target->minimum_font_size = src->minimum_font_size;
target->minimum_logical_font_size = src->minimum_logical_font_size;
target->remote_fonts_disabled = src->remote_fonts_disabled;
cef_string_set(src->default_encoding.str, src->default_encoding.length,
&target->default_encoding, copy);
target->encoding_detector_enabled = src->encoding_detector_enabled;
target->javascript_disabled = src->javascript_disabled;
target->javascript_open_windows_disallowed =
src->javascript_open_windows_disallowed;
target->javascript_close_windows_disallowed =
src->javascript_close_windows_disallowed;
target->javascript_access_clipboard_disallowed =
src->javascript_access_clipboard_disallowed;
target->dom_paste_disabled = src->dom_paste_disabled;
target->caret_browsing_enabled = src->caret_browsing_enabled;
target->java_disabled = src->java_disabled;
target->plugins_disabled = src->plugins_disabled;
target->universal_access_from_file_urls_allowed =
src->universal_access_from_file_urls_allowed;
target->file_access_from_file_urls_allowed =
src->file_access_from_file_urls_allowed;
target->web_security_disabled = src->web_security_disabled;
target->xss_auditor_enabled = src->xss_auditor_enabled;
target->image_load_disabled = src->image_load_disabled;
target->shrink_standalone_images_to_fit =
src->shrink_standalone_images_to_fit;
target->site_specific_quirks_disabled = src->site_specific_quirks_disabled;
target->text_area_resize_disabled = src->text_area_resize_disabled;
target->page_cache_disabled = src->page_cache_disabled;
target->tab_to_links_disabled = src->tab_to_links_disabled;
target->hyperlink_auditing_disabled = src->hyperlink_auditing_disabled;
target->user_style_sheet_enabled = src->user_style_sheet_enabled;
cef_string_set(src->user_style_sheet_location.str,
src->user_style_sheet_location.length,
&target->user_style_sheet_location, copy);
target->author_and_user_styles_disabled =
src->author_and_user_styles_disabled;
target->local_storage_disabled = src->local_storage_disabled;
target->databases_disabled = src->databases_disabled;
target->application_cache_disabled = src->application_cache_disabled;
target->webgl_disabled = src->webgl_disabled;
target->accelerated_compositing_disabled =
src->accelerated_compositing_disabled;
target->accelerated_layers_disabled = src->accelerated_layers_disabled;
target->accelerated_video_disabled = src->accelerated_video_disabled;
target->accelerated_2d_canvas_disabled =
src->accelerated_2d_canvas_disabled;
target->accelerated_painting_enabled = src->accelerated_painting_enabled;
target->accelerated_filters_enabled = src->accelerated_filters_enabled;
target->accelerated_plugins_disabled = src->accelerated_plugins_disabled;
target->developer_tools_disabled = src->developer_tools_disabled;
target->fullscreen_enabled = src->fullscreen_enabled;
}
};
///
// Class representing browser initialization settings.
///
typedef CefStructBase<CefBrowserSettingsTraits> CefBrowserSettings;
struct CefURLPartsTraits {
typedef cef_urlparts_t struct_type;
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s) {
cef_string_clear(&s->spec);
cef_string_clear(&s->scheme);
cef_string_clear(&s->username);
cef_string_clear(&s->password);
cef_string_clear(&s->host);
cef_string_clear(&s->port);
cef_string_clear(&s->path);
cef_string_clear(&s->query);
}
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
cef_string_set(src->spec.str, src->spec.length, &target->spec, copy);
cef_string_set(src->scheme.str, src->scheme.length, &target->scheme, copy);
cef_string_set(src->username.str, src->username.length, &target->username,
copy);
cef_string_set(src->password.str, src->password.length, &target->password,
copy);
cef_string_set(src->host.str, src->host.length, &target->host, copy);
cef_string_set(src->port.str, src->port.length, &target->port, copy);
cef_string_set(src->path.str, src->path.length, &target->path, copy);
cef_string_set(src->query.str, src->query.length, &target->query, copy);
}
};
///
// Class representing a URL's component parts.
///
typedef CefStructBase<CefURLPartsTraits> CefURLParts;
struct CefTimeTraits {
typedef cef_time_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 time.
///
class CefTime : public CefStructBase<CefTimeTraits> {
public:
typedef CefStructBase<CefTimeTraits> parent;
CefTime() : parent() {}
CefTime(const cef_time_t& r) : parent(r) {} // NOLINT(runtime/explicit)
CefTime(const CefTime& r) : parent(r) {} // NOLINT(runtime/explicit)
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);
}
time_t GetTimeT() const {
time_t time = 0;
cef_time_to_timet(this, &time);
return time;
}
// Converts to/from a double which is the number of seconds since epoch
// (Jan 1, 1970). Webkit uses this format to represent time. A value of 0
// means "not initialized".
void SetDoubleT(double r) {
cef_time_from_doublet(r, this);
}
double GetDoubleT() const {
double time = 0;
cef_time_to_doublet(this, &time);
return time;
}
};
struct CefCookieTraits {
typedef cef_cookie_t struct_type;
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s) {
cef_string_clear(&s->name);
cef_string_clear(&s->value);
cef_string_clear(&s->domain);
cef_string_clear(&s->path);
}
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
cef_string_set(src->name.str, src->name.length, &target->name, copy);
cef_string_set(src->value.str, src->value.length, &target->value, copy);
cef_string_set(src->domain.str, src->domain.length, &target->domain, copy);
cef_string_set(src->path.str, src->path.length, &target->path, copy);
target->secure = src->secure;
target->httponly = src->httponly;
target->creation = src->creation;
target->last_access = src->last_access;
target->has_expires = src->has_expires;
target->expires = src->expires;
}
};
///
// Class representing a cookie.
///
typedef CefStructBase<CefCookieTraits> CefCookie;
struct CefProxyInfoTraits {
typedef cef_proxy_info_t struct_type;
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s) {
cef_string_clear(&s->proxyList);
}
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
target->proxyType = src->proxyType;
cef_string_set(src->proxyList.str, src->proxyList.length,
&target->proxyList, copy);
}
};
///
// Class representing the results of proxy resolution.
///
class CefProxyInfo : public CefStructBase<CefProxyInfoTraits> {
public:
///
// Use a direction connection instead of a proxy.
///
void UseDirect() {
proxyType = PROXY_TYPE_DIRECT;
}
///
// Use one or more named proxy servers specified in WinHTTP format. Each proxy
// server is of the form:
//
// [<scheme>"://"]<server>[":"<port>]
//
// Multiple values may be separated by semicolons or whitespace. For example,
// "foo1:80;foo2:80".
///
void UseNamedProxy(const CefString& proxy_uri_list) {
proxyType = PROXY_TYPE_NAMED;
(CefString(&proxyList)) = proxy_uri_list;
}
///
// Use one or more named proxy servers specified in PAC script format. For
// example, "PROXY foobar:99; SOCKS fml:2; DIRECT".
///
void UsePacString(const CefString& pac_string) {
proxyType = PROXY_TYPE_PAC_STRING;
(CefString(&proxyList)) = pac_string;
}
bool IsDirect() const { return proxyType == PROXY_TYPE_DIRECT; }
bool IsNamedProxy() const { return proxyType == PROXY_TYPE_NAMED; }
bool IsPacString() const { return proxyType == PROXY_TYPE_PAC_STRING; }
CefString ProxyList() const { return CefString(&proxyList); }
};
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_

165
include/internal/cef_win.h Normal file
View File

@ -0,0 +1,165 @@
// Copyright (c) 2008 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CEF_INCLUDE_INTERNAL_CEF_WIN_H_
#define CEF_INCLUDE_INTERNAL_CEF_WIN_H_
#pragma once
#if defined(OS_WIN)
#include <windows.h>
#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 CefWindowHandle cef_window_handle_t
#define CefCursorHandle cef_cursor_handle_t
struct CefMainArgsTraits {
typedef cef_main_args_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->instance = src->instance;
}
};
// Class representing CefExecuteProcess arguments.
class CefMainArgs : public CefStructBase<CefMainArgsTraits> {
public:
typedef CefStructBase<CefMainArgsTraits> parent;
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;
}
};
struct CefWindowInfoTraits {
typedef cef_window_info_t struct_type;
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s) {
cef_string_clear(&s->window_name);
}
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
target->ex_style = src->ex_style;
cef_string_set(src->window_name.str, src->window_name.length,
&target->window_name, copy);
target->style = src->style;
target->x = src->x;
target->y = src->y;
target->width = src->width;
target->height = src->height;
target->parent_window = src->parent_window;
target->menu = src->menu;
target->window = src->window;
target->transparent_painting = src->transparent_painting;
}
};
///
// Class representing window information.
///
class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
public:
typedef CefStructBase<CefWindowInfoTraits> parent;
CefWindowInfo() : parent() {}
explicit CefWindowInfo(const cef_window_info_t& r) : parent(r) {}
explicit CefWindowInfo(const CefWindowInfo& r) : parent(r) {}
void SetAsChild(HWND hWndParent, RECT windowRect) {
style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_TABSTOP |
WS_VISIBLE;
parent_window = hWndParent;
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;
x = CW_USEDEFAULT;
y = CW_USEDEFAULT;
width = CW_USEDEFAULT;
height = CW_USEDEFAULT;
cef_string_copy(windowName.c_str(), windowName.length(), &window_name);
}
void SetTransparentPainting(BOOL transparentPainting) {
transparent_painting = transparentPainting;
}
};
#endif // OS_WIN
#endif // CEF_INCLUDE_INTERNAL_CEF_WIN_H_