Create 2272 release branch for CEF3.

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/2272@1993 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2015-01-24 03:26:25 +00:00
parent 0d6bfeb4dd
commit dc47bc006a
1045 changed files with 190843 additions and 0 deletions

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/base/cef_build.h"
#if defined(COMPILER_MSVC)
#ifdef BUILDING_CEF_SHARED
#define CEF_EXPORT __declspec(dllexport)
#elif USING_CEF_SHARED
#define CEF_EXPORT __declspec(dllimport)
#else
#define CEF_EXPORT
#endif
#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,130 @@
// Copyright (c) 2010 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CEF_INCLUDE_INTERNAL_CEF_LINUX_H_
#define CEF_INCLUDE_INTERNAL_CEF_LINUX_H_
#pragma once
#include "include/internal/cef_types_linux.h"
#include "include/internal/cef_types_wrappers.h"
// Handle types.
#define CefCursorHandle cef_cursor_handle_t
#define CefEventHandle cef_event_handle_t
#define CefWindowHandle cef_window_handle_t
#define CefTextInputContext cef_text_input_context_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->x = src->x;
target->y = src->y;
target->width = src->width;
target->height = src->height;
target->parent_window = src->parent_window;
target->windowless_rendering_enabled = src->windowless_rendering_enabled;
target->transparent_painting_enabled = src->transparent_painting_enabled;
target->window = src->window;
}
};
// Class representing window information.
class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
public:
typedef CefStructBase<CefWindowInfoTraits> parent;
CefWindowInfo() : parent() {}
explicit CefWindowInfo(const cef_window_info_t& r) : parent(r) {}
explicit CefWindowInfo(const CefWindowInfo& r) : parent(r) {}
///
// Create the browser as a child window.
///
void SetAsChild(CefWindowHandle parent,
const CefRect& windowRect) {
parent_window = parent;
x = windowRect.x;
y = windowRect.y;
width = windowRect.width;
height = windowRect.height;
}
///
// Create the browser using windowless (off-screen) rendering. No window
// will be created for the browser and all rendering will occur via the
// CefRenderHandler interface. The |parent| value will be used to identify
// monitor info and to act as the parent window for dialogs, context menus,
// etc. If |parent| is not provided then the main screen monitor will be used
// and some functionality that requires a parent window may not function
// correctly. If |transparent| is true a transparent background color will be
// used (RGBA=0x00000000). If |transparent| is false the background will be
// white and opaque. In order to create windowless browsers the
// CefSettings.windowless_rendering_enabled value must be set to true.
///
void SetAsWindowless(CefWindowHandle parent, bool transparent) {
windowless_rendering_enabled = true;
parent_window = parent;
transparent_painting_enabled = transparent;
}
};
#endif // CEF_INCLUDE_INTERNAL_CEF_LINUX_H_

View File

@ -0,0 +1,66 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CEF_INCLUDE_INTERNAL_CEF_LOGGING_INTERNAL_H_
#define CEF_INCLUDE_INTERNAL_CEF_LOGGING_INTERNAL_H_
#pragma once
#include "include/internal/cef_export.h"
#ifdef __cplusplus
extern "C" {
#endif
// See include/base/cef_logging.h for macros and intended usage.
///
// Gets the current log level.
///
CEF_EXPORT int cef_get_min_log_level();
///
// Gets the current vlog level for the given file (usually taken from
// __FILE__). Note that |N| is the size *with* the null terminator.
///
CEF_EXPORT int cef_get_vlog_level(const char* file_start, size_t N);
///
// Add a log message. See the LogSeverity defines for supported |severity|
// values.
///
CEF_EXPORT void cef_log(const char* file,
int line,
int severity,
const char* message);
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // CEF_INCLUDE_INTERNAL_CEF_LOGGING_INTERNAL_H_

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

@ -0,0 +1,137 @@
// Copyright (c) 2010 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CEF_INCLUDE_INTERNAL_CEF_MAC_H_
#define CEF_INCLUDE_INTERNAL_CEF_MAC_H_
#pragma once
#include "include/internal/cef_types_mac.h"
#include "include/internal/cef_types_wrappers.h"
// Handle types.
#define CefCursorHandle cef_cursor_handle_t
#define CefEventHandle cef_event_handle_t
#define CefWindowHandle cef_window_handle_t
#define CefTextInputContext cef_text_input_context_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, 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) {
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;
target->parent_view = src->parent_view;
target->windowless_rendering_enabled = src->windowless_rendering_enabled;
target->transparent_painting_enabled = src->transparent_painting_enabled;
target->view = src->view;
}
};
// Class representing window information.
class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
public:
typedef CefStructBase<CefWindowInfoTraits> parent;
CefWindowInfo() : parent() {}
explicit CefWindowInfo(const cef_window_info_t& r) : parent(r) {}
explicit CefWindowInfo(const CefWindowInfo& r) : parent(r) {}
///
// Create the browser as a child view.
///
void SetAsChild(CefWindowHandle parent, int x, int y, int width,
int height) {
parent_view = parent;
this->x = x;
this->y = y;
this->width = width;
this->height = height;
hidden = false;
}
///
// Create the browser using windowless (off-screen) rendering. No view
// will be created for the browser and all rendering will occur via the
// CefRenderHandler interface. The |parent| value will be used to identify
// monitor info and to act as the parent view for dialogs, context menus,
// etc. If |parent| is not provided then the main screen monitor will be used
// and some functionality that requires a parent view may not function
// correctly. If |transparent| is true a transparent background color will be
// used (RGBA=0x00000000). If |transparent| is false the background will be
// white and opaque. In order to create windowless browsers the
// CefSettings.windowless_rendering_enabled value must be set to true.
///
void SetAsWindowless(CefWindowHandle parent, bool transparent) {
windowless_rendering_enabled = true;
parent_view = parent;
transparent_painting_enabled = transparent;
}
};
#endif // CEF_INCLUDE_INTERNAL_CEF_MAC_H_

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

@ -0,0 +1,161 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CEF_INCLUDE_INTERNAL_CEF_PTR_H_
#define CEF_INCLUDE_INTERNAL_CEF_PTR_H_
#pragma once
#include "include/base/cef_ref_counted.h"
///
// Smart pointer implementation that is an alias of scoped_refptr from
// include/base/cef_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 scoped_refptr<T> {
public:
typedef scoped_refptr<T> parent;
CefRefPtr() : parent() {}
CefRefPtr(T* p) : parent(p) {}
CefRefPtr(const scoped_refptr<T>& r) : parent(r) {}
template <typename U>
CefRefPtr(const scoped_refptr<U>& r) : parent(r) {}
};
#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,205 @@
// 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.
#include <stddef.h>
#include "include/base/cef_build.h"
#include "include/internal/cef_export.h"
#ifdef __cplusplus
extern "C" {
#endif
// 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,715 @@
// 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/base/cef_string16.h"
#include "include/internal/cef_string_types.h"
///
// 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(WCHAR_T_IS_UTF32)
static inline base::string16 to_string16(const struct_type *s) {
cef_string_utf16_t cstr;
memset(&cstr, 0, sizeof(cstr));
cef_string_wide_to_utf16(s->str, s->length, &cstr);
base::string16 str;
if (cstr.length > 0)
str = base::string16(cstr.str, cstr.length);
cef_string_utf16_clear(&cstr);
return str;
}
static inline bool from_string16(const base::string16& str,
struct_type *s) {
return cef_string_utf16_to_wide(str.c_str(), str.length(), s) ?
true : false;
}
#else // WCHAR_T_IS_UTF32
static inline base::string16 to_string16(const struct_type *s) {
return base::string16(s->str, s->length);
}
static inline bool from_string16(const base::string16& str, struct_type *s) {
return cef_string_wide_set(str.c_str(), str.length(), s, true) ?
true : false;
}
#endif // WCHAR_T_IS_UTF32
};
///
// 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;
}
static inline base::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);
base::string16 str;
if (cstr.length > 0)
str = base::string16(cstr.str, cstr.length);
cef_string_utf16_clear(&cstr);
return str;
}
static inline bool from_string16(const base::string16& str, struct_type* s) {
return cef_string_utf16_to_utf8(str.c_str(), str.length(), s) ?
true : false;
}
};
///
// 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
static inline base::string16 to_string16(const struct_type* s) {
return base::string16(s->str, s->length);
}
static inline bool from_string16(const base::string16& str, struct_type* s) {
return cef_string_utf16_set(str.c_str(), str.length(), s, true) ?
true : false;
}
};
///
// 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) {
if (src)
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) {
if (src)
FromWString(std::wstring(src));
}
#if defined(WCHAR_T_IS_UTF32)
///
// Create a new string from an existing string16. Data will be always
// copied. Translation will occur if necessary based on the underlying string
// type.
///
CefStringBase(const base::string16& src) // NOLINT(runtime/explicit)
: string_(NULL), owner_(false) {
FromString16(src);
}
CefStringBase(const char16* src) // NOLINT(runtime/explicit)
: string_(NULL), owner_(false) {
if (src)
FromString16(base::string16(src));
}
#endif // WCHAR_T_IS_UTF32
///
// Create a new string from an existing character array. If |copy| is true
// this class will copy the data. Otherwise, this class will reference the
// existing data. Referenced data must exist for the lifetime of this class
// and will not be freed by this class.
///
CefStringBase(const char_type* src, size_t src_len, bool copy)
: string_(NULL), owner_(false) {
if (src && src_len > 0)
FromString(src, src_len, copy);
}
///
// Create a new string referencing an existing string structure without taking
// ownership. Referenced structures must exist for the lifetime of this class
// and will not be freed by this class.
///
CefStringBase(const struct_type* src) // 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 (string_)
traits::clear(string_);
}
///
// Swap this string's contents with the specified string.
///
void swap(CefStringBase& str) {
struct_type* tmp_string = string_;
bool tmp_owner = owner_;
string_ = str.string_;
owner_ = str.owner_;
str.string_ = tmp_string;
str.owner_ = tmp_owner;
}
// The following methods are unique to CEF string template types.
///
// Returns true if this class owns the underlying string structure.
///
bool IsOwner() const { return owner_; }
///
// Returns a read-only pointer to the underlying string structure. May return
// NULL if no structure is currently allocated.
///
const struct_type* GetStruct() const { return string_; }
///
// Returns a writable pointer to the underlying string structure. Will never
// return NULL.
///
struct_type* GetWritableStruct() {
AllocIfNeeded();
return string_;
}
///
// Clear the state of this class. The underlying string structure and data
// will be freed if this class owns the structure.
///
void ClearAndFree() {
if (!string_)
return;
if (owner_) {
clear();
delete string_;
}
string_ = NULL;
owner_ = false;
}
///
// Attach to the specified string structure. If |owner| is true this class
// will take ownership of the structure.
///
void Attach(struct_type* str, bool owner) {
// Free the previous structure and data, if any.
ClearAndFree();
string_ = str;
owner_ = owner;
}
///
// Take ownership of the specified userfree structure's string data. The
// userfree structure itself will be freed. Only use this method with userfree
// structures.
///
void AttachToUserFree(userfree_struct_type str) {
// Free the previous structure and data, if any.
ClearAndFree();
if (!str)
return;
AllocIfNeeded();
owner_ = true;
memcpy(string_, str, sizeof(struct_type));
// Free the |str| structure but not the data.
memset(str, 0, sizeof(struct_type));
traits::userfree_free(str);
}
///
// Detach from the underlying string structure. To avoid memory leaks only use
// this method if you already hold a pointer to the underlying string
// structure.
///
void Detach() {
string_ = NULL;
owner_ = false;
}
///
// Create a userfree structure and give it ownership of this class' string
// data. This class will be disassociated from the data. May return NULL if
// this string class currently contains no data.
///
userfree_struct_type DetachToUserFree() {
if (empty())
return NULL;
userfree_struct_type str = traits::userfree_alloc();
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_);
}
///
// Return this string's data as a string16. Translation will occur if
// necessary based on the underlying string type.
///
base::string16 ToString16() const {
if (empty())
return base::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 base::string16& str) {
if (str.empty()) {
clear();
return true;
}
AllocIfNeeded();
return traits::from_string16(str, string_);
}
///
// Comparison operator overloads.
///
bool operator<(const CefStringBase& str) const {
return (compare(str) < 0);
}
bool operator<=(const CefStringBase& str) const {
return (compare(str) <= 0);
}
bool operator>(const CefStringBase& str) const {
return (compare(str) > 0);
}
bool operator>=(const CefStringBase& str) const {
return (compare(str) >= 0);
}
bool operator==(const CefStringBase& str) const {
return (compare(str) == 0);
}
bool operator!=(const CefStringBase& str) const {
return (compare(str) != 0);
}
///
// Assignment operator overloads.
///
CefStringBase& operator=(const CefStringBase& str) {
FromString(str.c_str(), str.length(), true);
return *this;
}
operator std::string() const {
return ToString();
}
CefStringBase& operator=(const std::string& str) {
FromString(str);
return *this;
}
CefStringBase& operator=(const 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(WCHAR_T_IS_UTF32)
operator base::string16() const {
return ToString16();
}
CefStringBase& operator=(const base::string16& str) {
FromString16(str);
return *this;
}
CefStringBase& operator=(const char16* str) {
FromString16(base::string16(str));
return *this;
}
#endif // 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,74 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CEF_INCLUDE_INTERNAL_CEF_THREAD_INTERNAL_H_
#define CEF_INCLUDE_INTERNAL_CEF_THREAD_INTERNAL_H_
#pragma once
#if defined(OS_WIN)
#include <windows.h>
#elif defined(OS_POSIX)
#include <pthread.h>
#include <unistd.h>
#endif
#include "include/internal/cef_export.h"
#ifdef __cplusplus
extern "C" {
#endif
#if defined(OS_WIN)
typedef DWORD cef_platform_thread_id_t;
#elif defined(OS_POSIX)
typedef pid_t cef_platform_thread_id_t;
#endif
///
// Returns the current platform thread ID.
///
CEF_EXPORT cef_platform_thread_id_t cef_get_current_platform_thread_id();
#if defined(OS_WIN)
typedef DWORD cef_platform_thread_handle_t;
#elif defined(OS_POSIX)
typedef pthread_t cef_platform_thread_handle_t;
#endif
///
// Returns the current platform thread handle.
///
CEF_EXPORT cef_platform_thread_handle_t
cef_get_current_platform_thread_handle();
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // CEF_INCLUDE_INTERNAL_CEF_THREAD_INTERNAL_H_

View File

@ -0,0 +1,88 @@
// 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.)
int day_of_week; // 0-based day of week (0 = Sunday, etc.)
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);
///
// Retrieve the current system time.
//
CEF_EXPORT int cef_time_now(cef_time_t* cef_time);
///
// Retrieve the delta in milliseconds between two time values.
//
CEF_EXPORT int cef_time_delta(const cef_time_t* cef_time1,
const cef_time_t* cef_time2,
long long* delta);
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_INTERNAL_CEF_TIME_H_

View File

@ -0,0 +1,124 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CEF_INCLUDE_INTERNAL_CEF_TRACE_EVENT_INTERNAL_H_
#define CEF_INCLUDE_INTERNAL_CEF_TRACE_EVENT_INTERNAL_H_
#pragma once
#include "include/internal/cef_export.h"
#include "include/internal/cef_types.h"
#ifdef __cplusplus
extern "C" {
#endif
// See include/base/cef_trace_event.h for macros and intended usage.
// Functions for tracing counters and functions; called from macros.
// - |category| string must have application lifetime (static or literal). They
// may not include "(quotes) chars.
// - |argX_name|, |argX_val|, |valueX_name|, |valeX_val| are optional parameters
// and represent pairs of name and values of arguments
// - |copy| is used to avoid memory scoping issues with the |name| and
// |arg_name| parameters by copying them
// - |id| is used to disambiguate counters with the same name, or match async
// trace events
CEF_EXPORT void cef_trace_event_instant(const char* category,
const char* name,
const char* arg1_name,
uint64 arg1_val,
const char* arg2_name,
uint64 arg2_val,
int copy);
CEF_EXPORT void cef_trace_event_begin(const char* category,
const char* name,
const char* arg1_name,
uint64 arg1_val,
const char* arg2_name,
uint64 arg2_val,
int copy);
CEF_EXPORT void cef_trace_event_end(const char* category,
const char* name,
const char* arg1_name,
uint64 arg1_val,
const char* arg2_name,
uint64 arg2_val,
int copy);
CEF_EXPORT void cef_trace_counter(const char* category,
const char* name,
const char* value1_name,
uint64 value1_val,
const char* value2_name,
uint64 value2_val,
int copy);
CEF_EXPORT void cef_trace_counter_id(const char* category,
const char* name,
uint64 id,
const char* value1_name,
uint64 value1_val,
const char* value2_name,
uint64 value2_val,
int copy);
CEF_EXPORT void cef_trace_event_async_begin(const char* category,
const char* name,
uint64 id,
const char* arg1_name,
uint64 arg1_val,
const char* arg2_name,
uint64 arg2_val,
int copy);
CEF_EXPORT void cef_trace_event_async_step_into(const char* category,
const char* name,
uint64 id,
uint64 step,
const char* arg1_name,
uint64 arg1_val,
int copy);
CEF_EXPORT void cef_trace_event_async_step_past(const char* category,
const char* name,
uint64 id,
uint64 step,
const char* arg1_name,
uint64 arg1_val,
int copy);
CEF_EXPORT void cef_trace_event_async_end(const char* category,
const char* name,
uint64 id,
const char* arg1_name,
uint64 arg1_val,
const char* arg2_name,
uint64 arg2_val,
int copy);
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // CEF_INCLUDE_INTERNAL_CEF_TRACE_EVENT_INTERNAL_H_

1934
include/internal/cef_types.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,119 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_LINUX_H_
#define CEF_INCLUDE_INTERNAL_CEF_TYPES_LINUX_H_
#pragma once
#include "include/base/cef_build.h"
#if defined(OS_LINUX)
typedef union _XEvent XEvent;
typedef struct _XDisplay XDisplay;
#include "include/internal/cef_export.h"
#include "include/internal/cef_string.h"
// Handle types.
#define cef_cursor_handle_t unsigned long
#define cef_event_handle_t XEvent*
#define cef_window_handle_t unsigned long
#define kNullCursorHandle 0
#define kNullEventHandle NULL
#define kNullWindowHandle 0
#ifdef __cplusplus
extern "C" {
#endif
///
// Return the singleton X11 display shared with Chromium. The display is not
// thread-safe and must only be accessed on the browser process UI thread.
///
CEF_EXPORT XDisplay* cef_get_xdisplay();
#define cef_text_input_context_t void*
///
// Structure representing CefExecuteProcess arguments.
///
typedef struct _cef_main_args_t {
int argc;
char** argv;
} cef_main_args_t;
///
// Class representing window information.
///
typedef struct _cef_window_info_t {
unsigned int x;
unsigned int y;
unsigned int width;
unsigned int height;
///
// Pointer for the parent window.
///
cef_window_handle_t parent_window;
///
// Set to true (1) to create the browser using windowless (off-screen)
// rendering. No window will be created for the browser and all rendering will
// occur via the CefRenderHandler interface. The |parent_window| value will be
// used to identify monitor info and to act as the parent window for dialogs,
// context menus, etc. If |parent_window| is not provided then the main screen
// monitor will be used and some functionality that requires a parent window
// may not function correctly. In order to create windowless browsers the
// CefSettings.windowless_rendering_enabled value must be set to true.
///
int windowless_rendering_enabled;
///
// Set to true (1) to enable transparent painting in combination with
// windowless rendering. When this value is true a transparent background
// color will be used (RGBA=0x00000000). When this value is false the
// background will be white and opaque.
///
int transparent_painting_enabled;
///
// Pointer for the new browser window. Only used with windowed rendering.
///
cef_window_handle_t window;
} cef_window_info_t;
#ifdef __cplusplus
}
#endif
#endif // OS_LINUX
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_LINUX_H_

View File

@ -0,0 +1,132 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_MAC_H_
#define CEF_INCLUDE_INTERNAL_CEF_TYPES_MAC_H_
#pragma once
#include "include/base/cef_build.h"
#if defined(OS_MACOSX)
#include "include/internal/cef_string.h"
// Handle types.
#ifdef __cplusplus
#ifdef __OBJC__
@class NSCursor;
@class NSEvent;
@class NSView;
@class NSTextInputContext;
#else
class NSCursor;
class NSEvent;
struct NSView;
class NSTextInputContext;
#endif
#define cef_cursor_handle_t NSCursor*
#define cef_event_handle_t NSEvent*
#define cef_window_handle_t NSView*
#define cef_text_input_context_t NSTextInputContext*
#else
#define cef_cursor_handle_t void*
#define cef_event_handle_t void*
#define cef_window_handle_t void*
#define cef_text_input_context_t void*
#endif
#define kNullCursorHandle NULL
#define kNullEventHandle NULL
#define kNullWindowHandle NULL
#ifdef __cplusplus
extern "C" {
#endif
///
// Structure representing CefExecuteProcess arguments.
///
typedef struct _cef_main_args_t {
int argc;
char** argv;
} cef_main_args_t;
///
// Class representing window information.
///
typedef struct _cef_window_info_t {
cef_string_t window_name;
int x;
int y;
int width;
int height;
///
// Set to true (1) to create the view initially hidden.
///
int hidden;
///
// NSView pointer for the parent view.
///
cef_window_handle_t parent_view;
///
// Set to true (1) to create the browser using windowless (off-screen)
// rendering. No view will be created for the browser and all rendering will
// occur via the CefRenderHandler interface. The |parent_view| value will be
// used to identify monitor info and to act as the parent view for dialogs,
// context menus, etc. If |parent_view| is not provided then the main screen
// monitor will be used and some functionality that requires a parent view
// may not function correctly. In order to create windowless browsers the
// CefSettings.windowless_rendering_enabled value must be set to true.
///
int windowless_rendering_enabled;
///
// Set to true (1) to enable transparent painting in combination with
// windowless rendering. When this value is true a transparent background
// color will be used (RGBA=0x00000000). When this value is false the
// background will be white and opaque.
///
int transparent_painting_enabled;
///
// NSView pointer for the new browser view. Only used with windowed rendering.
///
cef_window_handle_t view;
} cef_window_info_t;
#ifdef __cplusplus
}
#endif
#endif // OS_MACOSX
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_MAC_H_

View File

@ -0,0 +1,109 @@
// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_WIN_H_
#define CEF_INCLUDE_INTERNAL_CEF_TYPES_WIN_H_
#pragma once
#include "include/base/cef_build.h"
#if defined(OS_WIN)
#include <windows.h>
#include "include/internal/cef_string.h"
// Handle types.
#define cef_cursor_handle_t HCURSOR
#define cef_event_handle_t MSG*
#define cef_window_handle_t HWND
#define cef_text_input_context_t void*
#define kNullCursorHandle NULL
#define kNullEventHandle NULL
#define kNullWindowHandle NULL
#ifdef __cplusplus
extern "C" {
#endif
///
// Structure representing CefExecuteProcess arguments.
///
typedef struct _cef_main_args_t {
HINSTANCE instance;
} cef_main_args_t;
///
// 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 (1) to create the browser using windowless (off-screen)
// rendering. No window will be created for the browser and all rendering will
// occur via the CefRenderHandler interface. The |parent_window| value will be
// used to identify monitor info and to act as the parent window for dialogs,
// context menus, etc. If |parent_window| is not provided then the main screen
// monitor will be used and some functionality that requires a parent window
// may not function correctly. In order to create windowless browsers the
// CefSettings.windowless_rendering_enabled value must be set to true.
///
int windowless_rendering_enabled;
///
// Set to true (1) to enable transparent painting in combination with
// windowless rendering. When this value is true a transparent background
// color will be used (RGBA=0x00000000). When this value is false the
// background will be white and opaque.
///
int transparent_painting_enabled;
///
// Handle for the new browser window. Only used with windowed rendering.
///
cef_window_handle_t window;
} cef_window_info_t;
#ifdef __cplusplus
}
#endif
#endif // OS_WIN
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_WIN_H_

View File

@ -0,0 +1,780 @@
// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_
#define CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_
#pragma once
#include "include/internal/cef_string.h"
#include "include/internal/cef_string_list.h"
#include "include/internal/cef_types.h"
///
// Template class that provides common functionality for CEF structure wrapping.
///
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 CefPointTraits {
typedef cef_point_t struct_type;
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s) {}
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
*target = *src;
}
};
///
// Class representing a point.
///
class CefPoint : public CefStructBase<CefPointTraits> {
public:
typedef CefStructBase<CefPointTraits> parent;
CefPoint() : parent() {}
CefPoint(const cef_point_t& r) : parent(r) {} // NOLINT(runtime/explicit)
CefPoint(const CefPoint& r) : parent(r) {} // NOLINT(runtime/explicit)
CefPoint(int x, int y) : parent() {
Set(x, y);
}
bool IsEmpty() const { return x <= 0 && y <= 0; }
void Set(int x, int y) {
this->x = x, this->y = y;
}
};
inline bool operator==(const CefPoint& a, const CefPoint& b) {
return a.x == b.x && a.y == b.y;
}
inline bool operator!=(const CefPoint& a, const CefPoint& b) {
return !(a == b);
}
struct CefRectTraits {
typedef cef_rect_t struct_type;
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 CefSizeTraits {
typedef cef_size_t struct_type;
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s) {}
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
*target = *src;
}
};
///
// Class representing a size.
///
class CefSize : public CefStructBase<CefSizeTraits> {
public:
typedef CefStructBase<CefSizeTraits> parent;
CefSize() : parent() {}
CefSize(const cef_size_t& r) : parent(r) {} // NOLINT(runtime/explicit)
CefSize(const CefSize& r) : parent(r) {} // NOLINT(runtime/explicit)
CefSize(int width, int height) : parent() {
Set(width, height);
}
bool IsEmpty() const { return width <= 0 || height <= 0; }
void Set(int width, int height) {
this->width = width, this->height = height;
}
};
inline bool operator==(const CefSize& a, const CefSize& b) {
return a.width == b.width && a.height == b.height;
}
inline bool operator!=(const CefSize& a, const CefSize& b) {
return !(a == b);
}
struct CefScreenInfoTraits {
typedef cef_screen_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->device_scale_factor = src->device_scale_factor;
target->depth = src->depth;
target->depth_per_component = src->depth_per_component;
target->is_monochrome = src->is_monochrome;
target->rect = src->rect;
target->available_rect = src->available_rect;
}
};
///
// Class representing the virtual screen information for use when window rendering
// is disabled.
///
class CefScreenInfo : public CefStructBase<CefScreenInfoTraits> {
public:
typedef CefStructBase<CefScreenInfoTraits> parent;
CefScreenInfo() : parent() {}
CefScreenInfo(const cef_screen_info_t& r) : parent(r) {} // NOLINT(runtime/explicit)
CefScreenInfo(const CefScreenInfo& r) : parent(r) {} // NOLINT(runtime/explicit)
CefScreenInfo(float device_scale_factor,
int depth,
int depth_per_component,
bool is_monochrome,
const CefRect& rect,
const CefRect& available_rect) : parent() {
Set(device_scale_factor, depth, depth_per_component,
is_monochrome, rect, available_rect);
}
void Set(float device_scale_factor,
int depth,
int depth_per_component,
bool is_monochrome,
const CefRect& rect,
const CefRect& available_rect) {
this->device_scale_factor = device_scale_factor;
this->depth = depth;
this->depth_per_component = depth_per_component;
this->is_monochrome = is_monochrome;
this->rect = rect;
this->available_rect = available_rect;
}
};
struct CefKeyEventTraits {
typedef cef_key_event_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->type = src->type;
target->modifiers = src->modifiers;
target->windows_key_code = src->windows_key_code;
target->native_key_code = src->native_key_code;
target->is_system_key = src->is_system_key;
target->character = src->character;
target->unmodified_character = src->unmodified_character;
target->focus_on_editable_field = src->focus_on_editable_field;
}
};
///
// Class representing a a keyboard event.
///
typedef CefStructBase<CefKeyEventTraits> CefKeyEvent;
struct CefMouseEventTraits {
typedef cef_mouse_event_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->x = src->x;
target->y = src->y;
target->modifiers = src->modifiers;
}
};
///
// Class representing a mouse event.
///
typedef CefStructBase<CefMouseEventTraits> CefMouseEvent;
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);
cef_string_clear(&s->log_file);
cef_string_clear(&s->javascript_flags);
cef_string_clear(&s->resources_dir_path);
cef_string_clear(&s->locales_dir_path);
}
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
target->single_process = src->single_process;
target->no_sandbox = src->no_sandbox;
cef_string_set(src->browser_subprocess_path.str,
src->browser_subprocess_path.length,
&target->browser_subprocess_path, copy);
target->multi_threaded_message_loop = src->multi_threaded_message_loop;
target->windowless_rendering_enabled = src->windowless_rendering_enabled;
target->command_line_args_disabled = src->command_line_args_disabled;
cef_string_set(src->cache_path.str, src->cache_path.length,
&target->cache_path, copy);
target->persist_session_cookies = src->persist_session_cookies;
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);
cef_string_set(src->log_file.str, src->log_file.length, &target->log_file,
copy);
target->log_severity = src->log_severity;
cef_string_set(src->javascript_flags.str, src->javascript_flags.length,
&target->javascript_flags, copy);
cef_string_set(src->resources_dir_path.str, src->resources_dir_path.length,
&target->resources_dir_path, copy);
cef_string_set(src->locales_dir_path.str, src->locales_dir_path.length,
&target->locales_dir_path, copy);
target->pack_loading_disabled = src->pack_loading_disabled;
target->remote_debugging_port = src->remote_debugging_port;
target->uncaught_exception_stack_size = src->uncaught_exception_stack_size;
target->context_safety_implementation = src->context_safety_implementation;
target->ignore_certificate_errors = src->ignore_certificate_errors;
target->background_color = src->background_color;
}
};
///
// 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);
}
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
target->windowless_frame_rate = src->windowless_frame_rate;
cef_string_set(src->standard_font_family.str,
src->standard_font_family.length, &target->standard_font_family, copy);
cef_string_set(src->fixed_font_family.str, src->fixed_font_family.length,
&target->fixed_font_family, copy);
cef_string_set(src->serif_font_family.str, src->serif_font_family.length,
&target->serif_font_family, copy);
cef_string_set(src->sans_serif_font_family.str,
src->sans_serif_font_family.length, &target->sans_serif_font_family,
copy);
cef_string_set(src->cursive_font_family.str,
src->cursive_font_family.length, &target->cursive_font_family, copy);
cef_string_set(src->fantasy_font_family.str,
src->fantasy_font_family.length, &target->fantasy_font_family, copy);
target->default_font_size = src->default_font_size;
target->default_fixed_font_size = src->default_fixed_font_size;
target->minimum_font_size = src->minimum_font_size;
target->minimum_logical_font_size = src->minimum_logical_font_size;
cef_string_set(src->default_encoding.str, src->default_encoding.length,
&target->default_encoding, copy);
target->remote_fonts = src->remote_fonts;
target->javascript = src->javascript;
target->javascript_open_windows = src->javascript_open_windows;
target->javascript_close_windows = src->javascript_close_windows;
target->javascript_access_clipboard = src->javascript_access_clipboard;
target->javascript_dom_paste = src->javascript_dom_paste;
target->caret_browsing = src->caret_browsing;
target->java = src->java;
target->plugins = src->plugins;
target->universal_access_from_file_urls =
src->universal_access_from_file_urls;
target->file_access_from_file_urls = src->file_access_from_file_urls;
target->web_security = src->web_security;
target->image_loading = src->image_loading;
target->image_shrink_standalone_to_fit =
src->image_shrink_standalone_to_fit;
target->text_area_resize = src->text_area_resize;
target->tab_to_links = src->tab_to_links;
target->local_storage = src->local_storage;
target->databases= src->databases;
target->application_cache = src->application_cache;
target->webgl = src->webgl;
target->background_color = src->background_color;
}
};
///
// 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->origin);
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->origin.str, src->origin.length, &target->origin, copy);
cef_string_set(src->path.str, src->path.length, &target->path, copy);
cef_string_set(src->query.str, src->query.length, &target->query, copy);
}
};
///
// 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;
}
// Set this object to now.
void Now() {
cef_time_now(this);
}
// Return the delta between this object and |other| in milliseconds.
long long Delta(const CefTime& other) {
long long delta = 0;
cef_time_delta(this, &other, &delta);
return delta;
}
};
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 CefGeopositionTraits {
typedef cef_geoposition_t struct_type;
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s) {
cef_string_clear(&s->error_message);
}
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
target->latitude = src->latitude;
target->longitude = src->longitude;
target->altitude = src->altitude;
target->accuracy = src->accuracy;
target->altitude_accuracy = src->altitude_accuracy;
target->heading = src->heading;
target->speed = src->speed;
target->timestamp = src->timestamp;
target->error_code = src->error_code;
cef_string_set(src->error_message.str, src->error_message.length,
&target->error_message, copy);
}
};
///
// Class representing a geoposition.
///
typedef CefStructBase<CefGeopositionTraits> CefGeoposition;
struct CefPageRangeTraits {
typedef cef_page_range_t struct_type;
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s) {}
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
*target = *src;
}
};
///
// Class representing a print job page range.
///
class CefPageRange : public CefStructBase<CefPageRangeTraits> {
public:
typedef CefStructBase<CefPageRangeTraits> parent;
CefPageRange() : parent() {}
CefPageRange(const cef_page_range_t& r) // NOLINT(runtime/explicit)
: parent(r) {}
CefPageRange(const CefPageRange& r) // NOLINT(runtime/explicit)
: parent(r) {}
CefPageRange(int from, int to) : parent() {
Set(from, to);
}
void Set(int from, int to) {
this->from = from, this->to = to;
}
};
inline bool operator==(const CefPageRange& a, const CefPageRange& b) {
return a.from == b.from && a.to == b.to;
}
inline bool operator!=(const CefPageRange& a, const CefPageRange& b) {
return !(a == b);
}
struct CefCursorInfoTraits {
typedef cef_cursor_info_t struct_type;
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s) {}
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
target->hotspot = src->hotspot;
target->image_scale_factor = src->image_scale_factor;
target->buffer = src->buffer;
target->size = src->size;
}
};
///
// Class representing cursor information.
///
typedef CefStructBase<CefCursorInfoTraits> CefCursorInfo;
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_

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

@ -0,0 +1,156 @@
// Copyright (c) 2008 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CEF_INCLUDE_INTERNAL_CEF_WIN_H_
#define CEF_INCLUDE_INTERNAL_CEF_WIN_H_
#pragma once
#include "include/internal/cef_types_win.h"
#include "include/internal/cef_types_wrappers.h"
///
// Handle types.
///
#define CefCursorHandle cef_cursor_handle_t
#define CefEventHandle cef_event_handle_t
#define CefWindowHandle cef_window_handle_t
#define CefTextInputContext cef_text_input_context_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->transparent_painting_enabled = src->transparent_painting_enabled;
target->windowless_rendering_enabled = src->windowless_rendering_enabled;
target->window = src->window;
}
};
///
// Class representing window information.
///
class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
public:
typedef CefStructBase<CefWindowInfoTraits> parent;
CefWindowInfo() : parent() {}
explicit CefWindowInfo(const cef_window_info_t& r) : parent(r) {}
explicit CefWindowInfo(const CefWindowInfo& r) : parent(r) {}
///
// Create the browser as a child window.
///
void SetAsChild(CefWindowHandle parent, RECT windowRect) {
style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_TABSTOP |
WS_VISIBLE;
parent_window = parent;
x = windowRect.left;
y = windowRect.top;
width = windowRect.right - windowRect.left;
height = windowRect.bottom - windowRect.top;
}
///
// Create the browser as a popup window.
///
void SetAsPopup(CefWindowHandle parent, const CefString& windowName) {
style = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS |
WS_VISIBLE;
parent_window = parent;
x = CW_USEDEFAULT;
y = CW_USEDEFAULT;
width = CW_USEDEFAULT;
height = CW_USEDEFAULT;
cef_string_copy(windowName.c_str(), windowName.length(), &window_name);
}
///
// Create the browser using windowless (off-screen) rendering. No window
// will be created for the browser and all rendering will occur via the
// CefRenderHandler interface. The |parent| value will be used to identify
// monitor info and to act as the parent window for dialogs, context menus,
// etc. If |parent| is not provided then the main screen monitor will be used
// and some functionality that requires a parent window may not function
// correctly. If |transparent| is true a transparent background color will be
// used (RGBA=0x00000000). If |transparent| is false the background will be
// white and opaque. In order to create windowless browsers the
// CefSettings.windowless_rendering_enabled value must be set to true.
///
void SetAsWindowless(CefWindowHandle parent, bool transparent) {
windowless_rendering_enabled = TRUE;
parent_window = parent;
transparent_painting_enabled = transparent;
}
};
#endif // CEF_INCLUDE_INTERNAL_CEF_WIN_H_