mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Rename CEF1 files from /trunk to /trunk/cef1 (issue #564).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@570 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@@ -1,129 +0,0 @@
|
||||
// Copyright (c) 2011 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
#ifndef CEF_INCLUDE_INTERNAL_CEF_BUILD_H_
|
||||
#define CEF_INCLUDE_INTERNAL_CEF_BUILD_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(BUILDING_CEF_SHARED)
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
|
||||
#else // !BUILDING_CEF_SHARED
|
||||
|
||||
#if defined(_WIN32)
|
||||
#ifndef OS_WIN
|
||||
#define OS_WIN 1
|
||||
#endif
|
||||
#elif defined(__APPLE__)
|
||||
#ifndef OS_MACOSX
|
||||
#define OS_MACOSX 1
|
||||
#endif
|
||||
#elif defined(__linux__)
|
||||
#ifndef OS_LINUX
|
||||
#define OS_LINUX 1
|
||||
#endif
|
||||
#else
|
||||
#error Please add support for your platform in cef_build.h
|
||||
#endif
|
||||
|
||||
// For access to standard POSIXish features, use OS_POSIX instead of a
|
||||
// more specific macro.
|
||||
#if defined(OS_MACOSX) || defined(OS_LINUX)
|
||||
#ifndef OS_POSIX
|
||||
#define OS_POSIX 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Compiler detection.
|
||||
#if defined(__GNUC__)
|
||||
#ifndef COMPILER_GCC
|
||||
#define COMPILER_GCC 1
|
||||
#endif
|
||||
#elif defined(_MSC_VER)
|
||||
#ifndef COMPILER_MSVC
|
||||
#define COMPILER_MSVC 1
|
||||
#endif
|
||||
#else
|
||||
#error Please add support for your compiler in cef_build.h
|
||||
#endif
|
||||
|
||||
// Annotate a virtual method indicating it must be overriding a virtual
|
||||
// method in the parent class.
|
||||
// Use like:
|
||||
// virtual void foo() OVERRIDE;
|
||||
#ifndef OVERRIDE
|
||||
#if defined(COMPILER_MSVC)
|
||||
#define OVERRIDE override
|
||||
#elif defined(__clang__)
|
||||
#define OVERRIDE override
|
||||
#else
|
||||
#define OVERRIDE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ALLOW_THIS_IN_INITIALIZER_LIST
|
||||
#if defined(COMPILER_MSVC)
|
||||
|
||||
// MSVC_PUSH_DISABLE_WARNING pushes |n| onto a stack of warnings to be disabled.
|
||||
// The warning remains disabled until popped by MSVC_POP_WARNING.
|
||||
#define MSVC_PUSH_DISABLE_WARNING(n) __pragma(warning(push)) \
|
||||
__pragma(warning(disable:n))
|
||||
|
||||
// MSVC_PUSH_WARNING_LEVEL pushes |n| as the global warning level. The level
|
||||
// remains in effect until popped by MSVC_POP_WARNING(). Use 0 to disable all
|
||||
// warnings.
|
||||
#define MSVC_PUSH_WARNING_LEVEL(n) __pragma(warning(push, n))
|
||||
|
||||
// Pop effects of innermost MSVC_PUSH_* macro.
|
||||
#define MSVC_POP_WARNING() __pragma(warning(pop))
|
||||
|
||||
// Allows |this| to be passed as an argument in constructor initializer lists.
|
||||
// This uses push/pop instead of the seemingly simpler suppress feature to avoid
|
||||
// having the warning be disabled for more than just |code|.
|
||||
//
|
||||
// Example usage:
|
||||
// Foo::Foo() : x(NULL), ALLOW_THIS_IN_INITIALIZER_LIST(y(this)), z(3) {}
|
||||
//
|
||||
// Compiler warning C4355: 'this': used in base member initializer list:
|
||||
// http://msdn.microsoft.com/en-us/library/3c594ae3(VS.80).aspx
|
||||
#define ALLOW_THIS_IN_INITIALIZER_LIST(code) MSVC_PUSH_DISABLE_WARNING(4355) \
|
||||
code \
|
||||
MSVC_POP_WARNING()
|
||||
#else // !COMPILER_MSVC
|
||||
|
||||
#define ALLOW_THIS_IN_INITIALIZER_LIST(code) code
|
||||
|
||||
#endif // !COMPILER_MSVC
|
||||
#endif
|
||||
|
||||
#endif // !BUILDING_CEF_SHARED
|
||||
|
||||
#endif // CEF_INCLUDE_INTERNAL_CEF_BUILD_H_
|
@@ -1,55 +0,0 @@
|
||||
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef CEF_INCLUDE_INTERNAL_CEF_EXPORT_H_
|
||||
#define CEF_INCLUDE_INTERNAL_CEF_EXPORT_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/internal/cef_build.h"
|
||||
|
||||
#if defined(COMPILER_MSVC)
|
||||
|
||||
#ifdef BUILDING_CEF_SHARED
|
||||
#define CEF_EXPORT __declspec(dllexport)
|
||||
#elif USING_CEF_SHARED
|
||||
#define CEF_EXPORT __declspec(dllimport)
|
||||
#else
|
||||
#define CEF_EXPORT
|
||||
#endif
|
||||
#define CEF_CALLBACK __stdcall
|
||||
|
||||
#elif defined(COMPILER_GCC)
|
||||
|
||||
#define CEF_EXPORT __attribute__ ((visibility("default")))
|
||||
#define CEF_CALLBACK
|
||||
|
||||
#endif // COMPILER_GCC
|
||||
|
||||
#endif // CEF_INCLUDE_INTERNAL_CEF_EXPORT_H_
|
@@ -1,119 +0,0 @@
|
||||
// Copyright (c) 2010 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
#ifndef CEF_INCLUDE_INTERNAL_CEF_LINUX_H_
|
||||
#define CEF_INCLUDE_INTERNAL_CEF_LINUX_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(OS_LINUX)
|
||||
#include <pthread.h>
|
||||
#include "include/internal/cef_types_linux.h"
|
||||
#include "include/internal/cef_types_wrappers.h"
|
||||
|
||||
// Atomic increment and decrement.
|
||||
inline long CefAtomicIncrement(long volatile *pDest) { // NOLINT(runtime/int)
|
||||
return __sync_add_and_fetch(pDest, 1);
|
||||
}
|
||||
inline long CefAtomicDecrement(long volatile *pDest) { // NOLINT(runtime/int)
|
||||
return __sync_sub_and_fetch(pDest, 1);
|
||||
}
|
||||
|
||||
// Critical section wrapper.
|
||||
class CefCriticalSection {
|
||||
public:
|
||||
CefCriticalSection() {
|
||||
pthread_mutexattr_init(&attr_);
|
||||
pthread_mutexattr_settype(&attr_, PTHREAD_MUTEX_RECURSIVE);
|
||||
pthread_mutex_init(&lock_, &attr_);
|
||||
}
|
||||
virtual ~CefCriticalSection() {
|
||||
pthread_mutex_destroy(&lock_);
|
||||
pthread_mutexattr_destroy(&attr_);
|
||||
}
|
||||
void Lock() {
|
||||
pthread_mutex_lock(&lock_);
|
||||
}
|
||||
void Unlock() {
|
||||
pthread_mutex_unlock(&lock_);
|
||||
}
|
||||
|
||||
pthread_mutex_t lock_;
|
||||
pthread_mutexattr_t attr_;
|
||||
};
|
||||
|
||||
// Handle types.
|
||||
#define CefWindowHandle cef_window_handle_t
|
||||
#define CefCursorHandle cef_cursor_handle_t
|
||||
|
||||
struct 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->m_Widget = src->m_Widget;
|
||||
target->m_ParentWidget = src->m_ParentWidget;
|
||||
}
|
||||
};
|
||||
|
||||
// Class representing window information.
|
||||
class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
|
||||
public:
|
||||
typedef CefStructBase<CefWindowInfoTraits> parent;
|
||||
|
||||
CefWindowInfo() : parent() {}
|
||||
explicit CefWindowInfo(const cef_window_info_t& r) : parent(r) {}
|
||||
explicit CefWindowInfo(const CefWindowInfo& r) : parent(r) {}
|
||||
|
||||
void SetAsChild(CefWindowHandle ParentWidget) {
|
||||
m_ParentWidget = ParentWidget;
|
||||
}
|
||||
};
|
||||
|
||||
struct CefPrintInfoTraits {
|
||||
typedef cef_print_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->m_Scale = src->m_Scale;
|
||||
}
|
||||
};
|
||||
|
||||
// Class representing print context information.
|
||||
typedef CefStructBase<CefPrintInfoTraits> CefPrintInfo;
|
||||
|
||||
#endif // OS_LINUX
|
||||
|
||||
#endif // CEF_INCLUDE_INTERNAL_CEF_LINUX_H_
|
@@ -1,135 +0,0 @@
|
||||
// Copyright (c) 2010 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
#ifndef CEF_INCLUDE_INTERNAL_CEF_MAC_H_
|
||||
#define CEF_INCLUDE_INTERNAL_CEF_MAC_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
#include <pthread.h>
|
||||
#include "include/internal/cef_types_mac.h"
|
||||
#include "include/internal/cef_types_wrappers.h"
|
||||
|
||||
// Atomic increment and decrement.
|
||||
inline long CefAtomicIncrement(long volatile *pDest) { // NOLINT(runtime/int)
|
||||
return __sync_add_and_fetch(pDest, 1);
|
||||
}
|
||||
inline long CefAtomicDecrement(long volatile *pDest) { // NOLINT(runtime/int)
|
||||
return __sync_sub_and_fetch(pDest, 1);
|
||||
}
|
||||
|
||||
// Handle types.
|
||||
#define CefWindowHandle cef_window_handle_t
|
||||
#define CefCursorHandle cef_cursor_handle_t
|
||||
|
||||
// Critical section wrapper.
|
||||
class CefCriticalSection {
|
||||
public:
|
||||
CefCriticalSection() {
|
||||
pthread_mutexattr_init(&attr_);
|
||||
pthread_mutexattr_settype(&attr_, PTHREAD_MUTEX_RECURSIVE);
|
||||
pthread_mutex_init(&lock_, &attr_);
|
||||
}
|
||||
virtual ~CefCriticalSection() {
|
||||
pthread_mutex_destroy(&lock_);
|
||||
pthread_mutexattr_destroy(&attr_);
|
||||
}
|
||||
void Lock() {
|
||||
pthread_mutex_lock(&lock_);
|
||||
}
|
||||
void Unlock() {
|
||||
pthread_mutex_unlock(&lock_);
|
||||
}
|
||||
|
||||
pthread_mutex_t lock_;
|
||||
pthread_mutexattr_t attr_;
|
||||
};
|
||||
|
||||
struct 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->m_windowName);
|
||||
}
|
||||
|
||||
static inline void set(const struct_type* src, struct_type* target,
|
||||
bool copy) {
|
||||
target->m_View = src->m_View;
|
||||
target->m_ParentView = src->m_ParentView;
|
||||
cef_string_set(src->m_windowName.str, src->m_windowName.length,
|
||||
&target->m_windowName, copy);
|
||||
target->m_x = src->m_x;
|
||||
target->m_y = src->m_y;
|
||||
target->m_nWidth = src->m_nWidth;
|
||||
target->m_nHeight = src->m_nHeight;
|
||||
target->m_bHidden = src->m_bHidden;
|
||||
}
|
||||
};
|
||||
|
||||
// Class representing window information.
|
||||
class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
|
||||
public:
|
||||
typedef CefStructBase<CefWindowInfoTraits> parent;
|
||||
|
||||
CefWindowInfo() : parent() {}
|
||||
explicit CefWindowInfo(const cef_window_info_t& r) : parent(r) {}
|
||||
explicit CefWindowInfo(const CefWindowInfo& r) : parent(r) {}
|
||||
|
||||
void SetAsChild(CefWindowHandle ParentView, int x, int y, int width,
|
||||
int height) {
|
||||
m_ParentView = ParentView;
|
||||
m_x = x;
|
||||
m_y = y;
|
||||
m_nWidth = width;
|
||||
m_nHeight = height;
|
||||
m_bHidden = false;
|
||||
}
|
||||
};
|
||||
|
||||
struct CefPrintInfoTraits {
|
||||
typedef cef_print_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->m_Scale = src->m_Scale;
|
||||
}
|
||||
};
|
||||
|
||||
// Class representing print context information.
|
||||
typedef CefStructBase<CefPrintInfoTraits> CefPrintInfo;
|
||||
|
||||
#endif // OS_MACOSX
|
||||
|
||||
#endif // CEF_INCLUDE_INTERNAL_CEF_MAC_H_
|
@@ -1,90 +0,0 @@
|
||||
// Copyright (c) 2011 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
#ifndef CEF_INCLUDE_INTERNAL_CEF_NPLUGIN_TYPES_H_
|
||||
#define CEF_INCLUDE_INTERNAL_CEF_NPLUGIN_TYPES_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/internal/cef_export.h"
|
||||
#include "include/internal/cef_string.h"
|
||||
#include "third_party/npapi/bindings/npapi.h"
|
||||
#include "third_party/npapi/bindings/nphostapi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Netscape plugins are normally built at separate DLLs that are loaded by the
|
||||
// browser when needed. This interface supports the creation of plugins that
|
||||
// are an embedded component of the application. Embedded plugins built using
|
||||
// this interface use the same Netscape Plugin API as DLL-based plugins.
|
||||
// See https://developer.mozilla.org/En/Gecko_Plugin_API_Reference for complete
|
||||
// documentation on how to use the Netscape Plugin API.
|
||||
|
||||
// This structure provides attribute information and entry point functions for
|
||||
// a plugin.
|
||||
typedef struct _cef_plugin_info_t {
|
||||
// The unique name that identifies the plugin.
|
||||
cef_string_t unique_name;
|
||||
|
||||
// The friendly display name of the plugin.
|
||||
cef_string_t display_name;
|
||||
|
||||
// The version string of the plugin.
|
||||
cef_string_t version;
|
||||
|
||||
// A description of the plugin.
|
||||
cef_string_t description;
|
||||
|
||||
// A pipe (|) delimited list of mime type values that the plugin supports.
|
||||
cef_string_t mime_types;
|
||||
|
||||
// A pipe (|) delimited list of extension values. Each value is associated
|
||||
// with the mime type value at the same position. Multiple file extensions
|
||||
// for the same mime type may be delimited with commas (,).
|
||||
cef_string_t file_extensions;
|
||||
|
||||
// A pipe (|) delimited list of description values. Each value is associated
|
||||
// with the mime type value at the same position.
|
||||
cef_string_t type_descriptions;
|
||||
|
||||
// Entry point function pointers.
|
||||
#if !defined(OS_POSIX) || defined(OS_MACOSX)
|
||||
NP_GetEntryPointsFunc np_getentrypoints;
|
||||
#endif
|
||||
NP_InitializeFunc np_initialize;
|
||||
NP_ShutdownFunc np_shutdown;
|
||||
} cef_plugin_info_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_INTERNAL_CEF_NPLUGIN_TYPES_H_
|
@@ -1,199 +0,0 @@
|
||||
// Copyright (c) 2008 Marshall A. Greenblatt. Portions Copyright (c)
|
||||
// 2006-2008 Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
#ifndef CEF_INCLUDE_INTERNAL_CEF_PTR_H_
|
||||
#define CEF_INCLUDE_INTERNAL_CEF_PTR_H_
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
///
|
||||
// Smart pointer implementation borrowed from base/ref_counted.h
|
||||
// <p>
|
||||
// A smart pointer class for reference counted objects. Use this class instead
|
||||
// of calling AddRef and Release manually on a reference counted object to
|
||||
// avoid common memory leaks caused by forgetting to Release an object
|
||||
// reference. Sample usage:
|
||||
// <pre>
|
||||
// class MyFoo : public CefBase {
|
||||
// ...
|
||||
// };
|
||||
//
|
||||
// void some_function() {
|
||||
// // The MyFoo object that |foo| represents starts with a single
|
||||
// // reference.
|
||||
// CefRefPtr<MyFoo> foo = new MyFoo();
|
||||
// foo->Method(param);
|
||||
// // |foo| is released when this function returns
|
||||
// }
|
||||
//
|
||||
// void some_other_function() {
|
||||
// CefRefPtr<MyFoo> foo = new MyFoo();
|
||||
// ...
|
||||
// foo = NULL; // explicitly releases |foo|
|
||||
// ...
|
||||
// if (foo)
|
||||
// foo->Method(param);
|
||||
// }
|
||||
// </pre>
|
||||
// The above examples show how CefRefPtr<T> acts like a pointer to T.
|
||||
// Given two CefRefPtr<T> classes, it is also possible to exchange
|
||||
// references between the two objects, like so:
|
||||
// <pre>
|
||||
// {
|
||||
// CefRefPtr<MyFoo> a = new MyFoo();
|
||||
// CefRefPtr<MyFoo> b;
|
||||
//
|
||||
// b.swap(a);
|
||||
// // now, |b| references the MyFoo object, and |a| references NULL.
|
||||
// }
|
||||
// </pre>
|
||||
// To make both |a| and |b| in the above example reference the same MyFoo
|
||||
// object, simply use the assignment operator:
|
||||
// <pre>
|
||||
// {
|
||||
// CefRefPtr<MyFoo> a = new MyFoo();
|
||||
// CefRefPtr<MyFoo> b;
|
||||
//
|
||||
// b = a;
|
||||
// // now, |a| and |b| each own a reference to the same MyFoo object.
|
||||
// // the reference count of the underlying MyFoo object will be 2.
|
||||
// }
|
||||
// </pre>
|
||||
// Reference counted objects can also be passed as function parameters and
|
||||
// used as function return values:
|
||||
// <pre>
|
||||
// void some_func_with_param(CefRefPtr<MyFoo> param) {
|
||||
// // A reference is added to the MyFoo object that |param| represents
|
||||
// // during the scope of some_func_with_param() and released when
|
||||
// // some_func_with_param() goes out of scope.
|
||||
// }
|
||||
//
|
||||
// CefRefPtr<MyFoo> some_func_with_retval() {
|
||||
// // The MyFoo object that |foox| represents starts with a single
|
||||
// // reference.
|
||||
// CefRefPtr<MyFoo> foox = new MyFoo();
|
||||
//
|
||||
// // Creating the return value adds an additional reference.
|
||||
// return foox;
|
||||
//
|
||||
// // When some_func_with_retval() goes out of scope the original |foox|
|
||||
// // reference is released.
|
||||
// }
|
||||
//
|
||||
// void and_another_function() {
|
||||
// CefRefPtr<MyFoo> foo = new MyFoo();
|
||||
//
|
||||
// // pass |foo| as a parameter.
|
||||
// some_function(foo);
|
||||
//
|
||||
// CefRefPtr<MyFoo> foo2 = some_func_with_retval();
|
||||
// // Now, since we kept a reference to the some_func_with_retval() return
|
||||
// // value, |foo2| is the only class pointing to the MyFoo object created
|
||||
// in some_func_with_retval(), and it has a reference count of 1.
|
||||
//
|
||||
// some_func_with_retval();
|
||||
// // Now, since we didn't keep a reference to the some_func_with_retval()
|
||||
// // return value, the MyFoo object created in some_func_with_retval()
|
||||
// // will automatically be released.
|
||||
// }
|
||||
// </pre>
|
||||
// And in standard containers:
|
||||
// <pre>
|
||||
// {
|
||||
// // Create a vector that holds MyFoo objects.
|
||||
// std::vector<CefRefPtr<MyFoo> > MyFooVec;
|
||||
//
|
||||
// // The MyFoo object that |foo| represents starts with a single
|
||||
// // reference.
|
||||
// CefRefPtr<MyFoo> foo = new MyFoo();
|
||||
//
|
||||
// // When the MyFoo object is added to |MyFooVec| the reference count
|
||||
// // is increased to 2.
|
||||
// MyFooVec.push_back(foo);
|
||||
// }
|
||||
// </pre>
|
||||
// </p>
|
||||
///
|
||||
template <class T>
|
||||
class CefRefPtr {
|
||||
public:
|
||||
CefRefPtr() : ptr_(NULL) {
|
||||
}
|
||||
|
||||
CefRefPtr(T* p) : ptr_(p) { // NOLINT(runtime/explicit)
|
||||
if (ptr_)
|
||||
ptr_->AddRef();
|
||||
}
|
||||
|
||||
CefRefPtr(const CefRefPtr<T>& r) : ptr_(r.ptr_) {
|
||||
if (ptr_)
|
||||
ptr_->AddRef();
|
||||
}
|
||||
|
||||
~CefRefPtr() {
|
||||
if (ptr_)
|
||||
ptr_->Release();
|
||||
}
|
||||
|
||||
T* get() const { return ptr_; }
|
||||
operator T*() const { return ptr_; }
|
||||
T* operator->() const { return ptr_; }
|
||||
|
||||
CefRefPtr<T>& operator=(T* p) {
|
||||
// AddRef first so that self assignment should work
|
||||
if (p)
|
||||
p->AddRef();
|
||||
if (ptr_ )
|
||||
ptr_ ->Release();
|
||||
ptr_ = p;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CefRefPtr<T>& operator=(const CefRefPtr<T>& r) {
|
||||
return *this = r.ptr_;
|
||||
}
|
||||
|
||||
void swap(T** pp) {
|
||||
T* p = ptr_;
|
||||
ptr_ = *pp;
|
||||
*pp = p;
|
||||
}
|
||||
|
||||
void swap(CefRefPtr<T>& r) {
|
||||
swap(&r.ptr_); // NOLINT(build/include_what_you_use)
|
||||
}
|
||||
|
||||
private:
|
||||
T* ptr_;
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_INTERNAL_CEF_PTR_H_
|
@@ -1,113 +0,0 @@
|
||||
// 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_
|
@@ -1,88 +0,0 @@
|
||||
// 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_
|
@@ -1,97 +0,0 @@
|
||||
// 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_
|
@@ -1,105 +0,0 @@
|
||||
// Copyright (c) 2011 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef CEF_INCLUDE_INTERNAL_CEF_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_
|
@@ -1,204 +0,0 @@
|
||||
// Copyright (c) 2010 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef CEF_INCLUDE_INTERNAL_CEF_STRING_TYPES_H_
|
||||
#define CEF_INCLUDE_INTERNAL_CEF_STRING_TYPES_H_
|
||||
#pragma once
|
||||
|
||||
// CEF provides functions for converting between UTF-8, -16 and -32 strings.
|
||||
// CEF string types are safe for reading from multiple threads but not for
|
||||
// modification. It is the user's responsibility to provide synchronization if
|
||||
// modifying CEF strings from multiple threads.
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "include/internal/cef_build.h"
|
||||
#include "include/internal/cef_export.h"
|
||||
#include <stddef.h>
|
||||
|
||||
// CEF character type definitions. wchar_t is 2 bytes on Windows and 4 bytes on
|
||||
// most other platforms.
|
||||
|
||||
#if defined(OS_WIN)
|
||||
typedef wchar_t char16;
|
||||
#else // !OS_WIN
|
||||
typedef unsigned short char16; // NOLINT (runtime/int)
|
||||
#ifndef WCHAR_T_IS_UTF32
|
||||
#define WCHAR_T_IS_UTF32
|
||||
#endif // WCHAR_T_IS_UTF32
|
||||
#endif // !OS_WIN
|
||||
|
||||
|
||||
// CEF string type definitions. Whomever allocates |str| is responsible for
|
||||
// providing an appropriate |dtor| implementation that will free the string in
|
||||
// the same memory space. When reusing an existing string structure make sure
|
||||
// to call |dtor| for the old value before assigning new |str| and |dtor|
|
||||
// values. Static strings will have a NULL |dtor| value. Using the below
|
||||
// functions if you want this managed for you.
|
||||
|
||||
typedef struct _cef_string_wide_t {
|
||||
wchar_t* str;
|
||||
size_t length;
|
||||
void (*dtor)(wchar_t* str);
|
||||
} cef_string_wide_t;
|
||||
|
||||
typedef struct _cef_string_utf8_t {
|
||||
char* str;
|
||||
size_t length;
|
||||
void (*dtor)(char* str);
|
||||
} cef_string_utf8_t;
|
||||
|
||||
typedef struct _cef_string_utf16_t {
|
||||
char16* str;
|
||||
size_t length;
|
||||
void (*dtor)(char16* str);
|
||||
} cef_string_utf16_t;
|
||||
|
||||
|
||||
///
|
||||
// These functions set string values. If |copy| is true (1) the value will be
|
||||
// copied instead of referenced. It is up to the user to properly manage
|
||||
// the lifespan of references.
|
||||
///
|
||||
|
||||
CEF_EXPORT int cef_string_wide_set(const wchar_t* src, size_t src_len,
|
||||
cef_string_wide_t* output, int copy);
|
||||
CEF_EXPORT int cef_string_utf8_set(const char* src, size_t src_len,
|
||||
cef_string_utf8_t* output, int copy);
|
||||
CEF_EXPORT int cef_string_utf16_set(const char16* src, size_t src_len,
|
||||
cef_string_utf16_t* output, int copy);
|
||||
|
||||
|
||||
///
|
||||
// Convenience macros for copying values.
|
||||
///
|
||||
|
||||
#define cef_string_wide_copy(src, src_len, output) \
|
||||
cef_string_wide_set(src, src_len, output, true)
|
||||
#define cef_string_utf8_copy(src, src_len, output) \
|
||||
cef_string_utf8_set(src, src_len, output, true)
|
||||
#define cef_string_utf16_copy(src, src_len, output) \
|
||||
cef_string_utf16_set(src, src_len, output, true)
|
||||
|
||||
|
||||
///
|
||||
// These functions clear string values. The structure itself is not freed.
|
||||
///
|
||||
|
||||
CEF_EXPORT void cef_string_wide_clear(cef_string_wide_t* str);
|
||||
CEF_EXPORT void cef_string_utf8_clear(cef_string_utf8_t* str);
|
||||
CEF_EXPORT void cef_string_utf16_clear(cef_string_utf16_t* str);
|
||||
|
||||
|
||||
///
|
||||
// These functions compare two string values with the same results as strcmp().
|
||||
///
|
||||
|
||||
CEF_EXPORT int cef_string_wide_cmp(const cef_string_wide_t* str1,
|
||||
const cef_string_wide_t* str2);
|
||||
CEF_EXPORT int cef_string_utf8_cmp(const cef_string_utf8_t* str1,
|
||||
const cef_string_utf8_t* str2);
|
||||
CEF_EXPORT int cef_string_utf16_cmp(const cef_string_utf16_t* str1,
|
||||
const cef_string_utf16_t* str2);
|
||||
|
||||
|
||||
///
|
||||
// These functions convert between UTF-8, -16, and -32 strings. They are
|
||||
// potentially slow so unnecessary conversions should be avoided. The best
|
||||
// possible result will always be written to |output| with the boolean return
|
||||
// value indicating whether the conversion is 100% valid.
|
||||
///
|
||||
|
||||
CEF_EXPORT int cef_string_wide_to_utf8(const wchar_t* src, size_t src_len,
|
||||
cef_string_utf8_t* output);
|
||||
CEF_EXPORT int cef_string_utf8_to_wide(const char* src, size_t src_len,
|
||||
cef_string_wide_t* output);
|
||||
|
||||
CEF_EXPORT int cef_string_wide_to_utf16(const wchar_t* src, size_t src_len,
|
||||
cef_string_utf16_t* output);
|
||||
CEF_EXPORT int cef_string_utf16_to_wide(const char16* src, size_t src_len,
|
||||
cef_string_wide_t* output);
|
||||
|
||||
CEF_EXPORT int cef_string_utf8_to_utf16(const char* src, size_t src_len,
|
||||
cef_string_utf16_t* output);
|
||||
CEF_EXPORT int cef_string_utf16_to_utf8(const char16* src, size_t src_len,
|
||||
cef_string_utf8_t* output);
|
||||
|
||||
|
||||
///
|
||||
// These functions convert an ASCII string, typically a hardcoded constant, to a
|
||||
// Wide/UTF16 string. Use instead of the UTF8 conversion routines if you know
|
||||
// the string is ASCII.
|
||||
///
|
||||
|
||||
CEF_EXPORT int cef_string_ascii_to_wide(const char* src, size_t src_len,
|
||||
cef_string_wide_t* output);
|
||||
CEF_EXPORT int cef_string_ascii_to_utf16(const char* src, size_t src_len,
|
||||
cef_string_utf16_t* output);
|
||||
|
||||
|
||||
|
||||
///
|
||||
// It is sometimes necessary for the system to allocate string structures with
|
||||
// the expectation that the user will free them. The userfree types act as a
|
||||
// hint that the user is responsible for freeing the structure.
|
||||
///
|
||||
|
||||
typedef cef_string_wide_t* cef_string_userfree_wide_t;
|
||||
typedef cef_string_utf8_t* cef_string_userfree_utf8_t;
|
||||
typedef cef_string_utf16_t* cef_string_userfree_utf16_t;
|
||||
|
||||
|
||||
///
|
||||
// These functions allocate a new string structure. They must be freed by
|
||||
// calling the associated free function.
|
||||
///
|
||||
|
||||
CEF_EXPORT cef_string_userfree_wide_t cef_string_userfree_wide_alloc();
|
||||
CEF_EXPORT cef_string_userfree_utf8_t cef_string_userfree_utf8_alloc();
|
||||
CEF_EXPORT cef_string_userfree_utf16_t cef_string_userfree_utf16_alloc();
|
||||
|
||||
|
||||
///
|
||||
// These functions free the string structure allocated by the associated
|
||||
// alloc function. Any string contents will first be cleared.
|
||||
///
|
||||
|
||||
CEF_EXPORT void cef_string_userfree_wide_free(cef_string_userfree_wide_t str);
|
||||
CEF_EXPORT void cef_string_userfree_utf8_free(cef_string_userfree_utf8_t str);
|
||||
CEF_EXPORT void cef_string_userfree_utf16_free(cef_string_userfree_utf16_t str);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_INTERNAL_CEF_STRING_TYPES_H_
|
@@ -1,708 +0,0 @@
|
||||
// Copyright (c) 2010 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef CEF_INCLUDE_INTERNAL_CEF_STRING_WRAPPERS_H_
|
||||
#define CEF_INCLUDE_INTERNAL_CEF_STRING_WRAPPERS_H_
|
||||
#pragma once
|
||||
|
||||
#include <memory.h>
|
||||
#include <string>
|
||||
#include "include/internal/cef_string_types.h"
|
||||
|
||||
#ifdef BUILDING_CEF_SHARED
|
||||
#include "base/string16.h"
|
||||
#endif
|
||||
|
||||
|
||||
///
|
||||
// Traits implementation for wide character strings.
|
||||
///
|
||||
struct CefStringTraitsWide {
|
||||
typedef wchar_t char_type;
|
||||
typedef cef_string_wide_t struct_type;
|
||||
typedef cef_string_userfree_wide_t userfree_struct_type;
|
||||
|
||||
static inline void clear(struct_type *s) { cef_string_wide_clear(s); }
|
||||
static inline int set(const char_type* src, size_t src_size,
|
||||
struct_type* output, int copy) {
|
||||
return cef_string_wide_set(src, src_size, output, copy);
|
||||
}
|
||||
static inline int compare(const struct_type* s1, const struct_type* s2) {
|
||||
return cef_string_wide_cmp(s1, s2);
|
||||
}
|
||||
static inline userfree_struct_type userfree_alloc() {
|
||||
return cef_string_userfree_wide_alloc();
|
||||
}
|
||||
static inline void userfree_free(userfree_struct_type ufs) {
|
||||
return cef_string_userfree_wide_free(ufs);
|
||||
}
|
||||
|
||||
// Conversion methods.
|
||||
static inline bool from_ascii(const char* str, size_t len, struct_type *s) {
|
||||
return cef_string_ascii_to_wide(str, len, s) ? true : false;
|
||||
}
|
||||
static inline std::string to_string(const struct_type *s) {
|
||||
cef_string_utf8_t cstr;
|
||||
memset(&cstr, 0, sizeof(cstr));
|
||||
cef_string_wide_to_utf8(s->str, s->length, &cstr);
|
||||
std::string str;
|
||||
if (cstr.length > 0)
|
||||
str = std::string(cstr.str, cstr.length);
|
||||
cef_string_utf8_clear(&cstr);
|
||||
return str;
|
||||
}
|
||||
static inline bool from_string(const std::string& str, struct_type *s) {
|
||||
return cef_string_utf8_to_wide(str.c_str(), str.length(), s) ? true : false;
|
||||
}
|
||||
static inline std::wstring to_wstring(const struct_type *s) {
|
||||
return std::wstring(s->str, s->length);
|
||||
}
|
||||
static inline bool from_wstring(const std::wstring& str, struct_type *s) {
|
||||
return cef_string_wide_set(str.c_str(), str.length(), s, true) ?
|
||||
true : false;
|
||||
}
|
||||
#if defined(BUILDING_CEF_SHARED)
|
||||
#if defined(WCHAR_T_IS_UTF32)
|
||||
static inline string16 to_string16(const struct_type *s) {
|
||||
cef_string_utf16_t cstr;
|
||||
memset(&cstr, 0, sizeof(cstr));
|
||||
cef_string_wide_to_utf16(s->str, s->length, &cstr);
|
||||
string16 str;
|
||||
if (cstr.length > 0)
|
||||
str = string16(cstr.str, cstr.length);
|
||||
cef_string_utf16_clear(&cstr);
|
||||
return str;
|
||||
}
|
||||
static inline bool from_string16(const string16& str, struct_type *s) {
|
||||
return cef_string_utf16_to_wide(str.c_str(), str.length(), s) ?
|
||||
true : false;
|
||||
}
|
||||
#else // WCHAR_T_IS_UTF32
|
||||
static inline string16 to_string16(const struct_type *s) {
|
||||
return string16(s->str, s->length);
|
||||
}
|
||||
static inline bool from_string16(const string16& str, struct_type *s) {
|
||||
return cef_string_wide_set(str.c_str(), str.length(), s, true) ?
|
||||
true : false;
|
||||
}
|
||||
#endif // WCHAR_T_IS_UTF32
|
||||
#endif // BUILDING_CEF_SHARED
|
||||
};
|
||||
|
||||
///
|
||||
// Traits implementation for utf8 character strings.
|
||||
///
|
||||
struct CefStringTraitsUTF8 {
|
||||
typedef char char_type;
|
||||
typedef cef_string_utf8_t struct_type;
|
||||
typedef cef_string_userfree_utf8_t userfree_struct_type;
|
||||
|
||||
static inline void clear(struct_type *s) { cef_string_utf8_clear(s); }
|
||||
static inline int set(const char_type* src, size_t src_size,
|
||||
struct_type* output, int copy) {
|
||||
return cef_string_utf8_set(src, src_size, output, copy);
|
||||
}
|
||||
static inline int compare(const struct_type* s1, const struct_type* s2) {
|
||||
return cef_string_utf8_cmp(s1, s2);
|
||||
}
|
||||
static inline userfree_struct_type userfree_alloc() {
|
||||
return cef_string_userfree_utf8_alloc();
|
||||
}
|
||||
static inline void userfree_free(userfree_struct_type ufs) {
|
||||
return cef_string_userfree_utf8_free(ufs);
|
||||
}
|
||||
|
||||
// Conversion methods.
|
||||
static inline bool from_ascii(const char* str, size_t len, struct_type* s) {
|
||||
return cef_string_utf8_copy(str, len, s) ? true : false;
|
||||
}
|
||||
static inline std::string to_string(const struct_type* s) {
|
||||
return std::string(s->str, s->length);
|
||||
}
|
||||
static inline bool from_string(const std::string& str, struct_type* s) {
|
||||
return cef_string_utf8_copy(str.c_str(), str.length(), s) ? true : false;
|
||||
}
|
||||
static inline std::wstring to_wstring(const struct_type* s) {
|
||||
cef_string_wide_t cstr;
|
||||
memset(&cstr, 0, sizeof(cstr));
|
||||
cef_string_utf8_to_wide(s->str, s->length, &cstr);
|
||||
std::wstring str;
|
||||
if (cstr.length > 0)
|
||||
str = std::wstring(cstr.str, cstr.length);
|
||||
cef_string_wide_clear(&cstr);
|
||||
return str;
|
||||
}
|
||||
static inline bool from_wstring(const std::wstring& str, struct_type* s) {
|
||||
return cef_string_wide_to_utf8(str.c_str(), str.length(), s) ? true : false;
|
||||
}
|
||||
#if defined(BUILDING_CEF_SHARED)
|
||||
static inline string16 to_string16(const struct_type* s) {
|
||||
cef_string_utf16_t cstr;
|
||||
memset(&cstr, 0, sizeof(cstr));
|
||||
cef_string_utf8_to_utf16(s->str, s->length, &cstr);
|
||||
string16 str;
|
||||
if (cstr.length > 0)
|
||||
str = string16(cstr.str, cstr.length);
|
||||
cef_string_utf16_clear(&cstr);
|
||||
return str;
|
||||
}
|
||||
static inline bool from_string16(const string16& str, struct_type* s) {
|
||||
return cef_string_utf16_to_utf8(str.c_str(), str.length(), s) ?
|
||||
true : false;
|
||||
}
|
||||
#endif // BUILDING_CEF_SHARED
|
||||
};
|
||||
|
||||
///
|
||||
// Traits implementation for utf16 character strings.
|
||||
///
|
||||
struct CefStringTraitsUTF16 {
|
||||
typedef char16 char_type;
|
||||
typedef cef_string_utf16_t struct_type;
|
||||
typedef cef_string_userfree_utf16_t userfree_struct_type;
|
||||
|
||||
static inline void clear(struct_type *s) { cef_string_utf16_clear(s); }
|
||||
static inline int set(const char_type* src, size_t src_size,
|
||||
struct_type* output, int copy) {
|
||||
return cef_string_utf16_set(src, src_size, output, copy);
|
||||
}
|
||||
static inline int compare(const struct_type* s1, const struct_type* s2) {
|
||||
return cef_string_utf16_cmp(s1, s2);
|
||||
}
|
||||
static inline userfree_struct_type userfree_alloc() {
|
||||
return cef_string_userfree_utf16_alloc();
|
||||
}
|
||||
static inline void userfree_free(userfree_struct_type ufs) {
|
||||
return cef_string_userfree_utf16_free(ufs);
|
||||
}
|
||||
|
||||
// Conversion methods.
|
||||
static inline bool from_ascii(const char* str, size_t len, struct_type* s) {
|
||||
return cef_string_ascii_to_utf16(str, len, s) ? true : false;
|
||||
}
|
||||
static inline std::string to_string(const struct_type* s) {
|
||||
cef_string_utf8_t cstr;
|
||||
memset(&cstr, 0, sizeof(cstr));
|
||||
cef_string_utf16_to_utf8(s->str, s->length, &cstr);
|
||||
std::string str;
|
||||
if (cstr.length > 0)
|
||||
str = std::string(cstr.str, cstr.length);
|
||||
cef_string_utf8_clear(&cstr);
|
||||
return str;
|
||||
}
|
||||
static inline bool from_string(const std::string& str, struct_type* s) {
|
||||
return cef_string_utf8_to_utf16(str.c_str(), str.length(), s) ?
|
||||
true : false;
|
||||
}
|
||||
#if defined(WCHAR_T_IS_UTF32)
|
||||
static inline std::wstring to_wstring(const struct_type* s) {
|
||||
cef_string_wide_t cstr;
|
||||
memset(&cstr, 0, sizeof(cstr));
|
||||
cef_string_utf16_to_wide(s->str, s->length, &cstr);
|
||||
std::wstring str;
|
||||
if (cstr.length > 0)
|
||||
str = std::wstring(cstr.str, cstr.length);
|
||||
cef_string_wide_clear(&cstr);
|
||||
return str;
|
||||
}
|
||||
static inline bool from_wstring(const std::wstring& str, struct_type* s) {
|
||||
return cef_string_wide_to_utf16(str.c_str(), str.length(), s) ?
|
||||
true : false;
|
||||
}
|
||||
#else // WCHAR_T_IS_UTF32
|
||||
static inline std::wstring to_wstring(const struct_type* s) {
|
||||
return std::wstring(s->str, s->length);
|
||||
}
|
||||
static inline bool from_wstring(const std::wstring& str, struct_type* s) {
|
||||
return cef_string_utf16_set(str.c_str(), str.length(), s, true) ?
|
||||
true : false;
|
||||
}
|
||||
#endif // WCHAR_T_IS_UTF32
|
||||
#if defined(BUILDING_CEF_SHARED)
|
||||
static inline string16 to_string16(const struct_type* s) {
|
||||
return string16(s->str, s->length);
|
||||
}
|
||||
static inline bool from_string16(const string16& str, struct_type* s) {
|
||||
return cef_string_utf16_set(str.c_str(), str.length(), s, true) ?
|
||||
true : false;
|
||||
}
|
||||
#endif // BUILDING_CEF_SHARED
|
||||
};
|
||||
|
||||
///
|
||||
// CEF string classes can convert between all supported string types. For
|
||||
// example, the CefStringWide class uses wchar_t as the underlying character
|
||||
// type and provides two approaches for converting data to/from a UTF8 string
|
||||
// (std::string).
|
||||
// <p>
|
||||
// 1. Implicit conversion using the assignment operator overload.
|
||||
// <pre>
|
||||
// CefStringWide aCefString;
|
||||
// std::string aUTF8String;
|
||||
// aCefString = aUTF8String; // Assign std::string to CefStringWide
|
||||
// aUTF8String = aCefString; // Assign CefStringWide to std::string
|
||||
// </pre>
|
||||
// 2. Explicit conversion using the FromString/ToString methods.
|
||||
// <pre>
|
||||
// CefStringWide aCefString;
|
||||
// std::string aUTF8String;
|
||||
// aCefString.FromString(aUTF8String); // Assign std::string to CefStringWide
|
||||
// aUTF8String = aCefString.ToString(); // Assign CefStringWide to std::string
|
||||
// </pre>
|
||||
// Conversion will only occur if the assigned value is a different string type.
|
||||
// Assigning a std::string to a CefStringUTF8, for example, will copy the data
|
||||
// without performing a conversion.
|
||||
// </p>
|
||||
// CEF string classes are safe for reading from multiple threads but not for
|
||||
// modification. It is the user's responsibility to provide synchronization if
|
||||
// modifying CEF strings from multiple threads.
|
||||
///
|
||||
template <class traits>
|
||||
class CefStringBase {
|
||||
public:
|
||||
typedef typename traits::char_type char_type;
|
||||
typedef typename traits::struct_type struct_type;
|
||||
typedef typename traits::userfree_struct_type userfree_struct_type;
|
||||
|
||||
///
|
||||
// Default constructor.
|
||||
///
|
||||
CefStringBase() : string_(NULL), owner_(false) {}
|
||||
|
||||
///
|
||||
// Create a new string from an existing string. Data will always be copied.
|
||||
///
|
||||
CefStringBase(const CefStringBase& str)
|
||||
: string_(NULL), owner_(false) {
|
||||
FromString(str.c_str(), str.length(), true);
|
||||
}
|
||||
|
||||
///
|
||||
// Create a new string from an existing std::string. Data will be always
|
||||
// copied. Translation will occur if necessary based on the underlying string
|
||||
// type.
|
||||
///
|
||||
CefStringBase(const std::string& src) // NOLINT(runtime/explicit)
|
||||
: string_(NULL), owner_(false) {
|
||||
FromString(src);
|
||||
}
|
||||
CefStringBase(const char* src) // NOLINT(runtime/explicit)
|
||||
: string_(NULL), owner_(false) {
|
||||
FromString(std::string(src));
|
||||
}
|
||||
|
||||
///
|
||||
// Create a new string from an existing std::wstring. Data will be always
|
||||
// copied. Translation will occur if necessary based on the underlying string
|
||||
// type.
|
||||
///
|
||||
CefStringBase(const std::wstring& src) // NOLINT(runtime/explicit)
|
||||
: string_(NULL), owner_(false) {
|
||||
FromWString(src);
|
||||
}
|
||||
CefStringBase(const wchar_t* src) // NOLINT(runtime/explicit)
|
||||
: string_(NULL), owner_(false) {
|
||||
FromWString(std::wstring(src));
|
||||
}
|
||||
|
||||
#if (defined(BUILDING_CEF_SHARED) && defined(WCHAR_T_IS_UTF32))
|
||||
///
|
||||
// Create a new string from an existing string16. Data will be always
|
||||
// copied. Translation will occur if necessary based on the underlying string
|
||||
// type.
|
||||
///
|
||||
CefStringBase(const string16& src) // NOLINT(runtime/explicit)
|
||||
: string_(NULL), owner_(false) {
|
||||
FromString16(src);
|
||||
}
|
||||
CefStringBase(const char16* src) // NOLINT(runtime/explicit)
|
||||
: string_(NULL), owner_(false) {
|
||||
FromString16(string16(src));
|
||||
}
|
||||
#endif // BUILDING_CEF_SHARED && WCHAR_T_IS_UTF32
|
||||
|
||||
///
|
||||
// Create a new string from an existing character array. If |copy| is true
|
||||
// this class will copy the data. Otherwise, this class will reference the
|
||||
// existing data. Referenced data must exist for the lifetime of this class
|
||||
// and will not be freed by this class.
|
||||
///
|
||||
CefStringBase(const char_type* src, size_t src_len, bool copy)
|
||||
: string_(NULL), owner_(false) {
|
||||
FromString(src, src_len, copy);
|
||||
}
|
||||
|
||||
///
|
||||
// Create a new string referencing an existing string structure without taking
|
||||
// ownership. Referenced structures must exist for the lifetime of this class
|
||||
// and will not be freed by this class.
|
||||
///
|
||||
CefStringBase(const struct_type* src) // NOLINT(runtime/explicit)
|
||||
: string_(NULL), owner_(false) {
|
||||
if (!src)
|
||||
return;
|
||||
// Reference the existing structure without taking ownership.
|
||||
Attach(const_cast<struct_type*>(src), false);
|
||||
}
|
||||
|
||||
virtual ~CefStringBase() { ClearAndFree(); }
|
||||
|
||||
|
||||
// The following methods are named for compatibility with the standard library
|
||||
// string template types.
|
||||
|
||||
///
|
||||
// Return a read-only pointer to the string data.
|
||||
///
|
||||
const char_type* c_str() const { return (string_ ? string_->str : NULL); }
|
||||
|
||||
///
|
||||
// Return the length of the string data.
|
||||
///
|
||||
size_t length() const { return (string_ ? string_->length : 0); }
|
||||
|
||||
///
|
||||
// Return the length of the string data.
|
||||
///
|
||||
inline size_t size() const { return length(); }
|
||||
|
||||
///
|
||||
// Returns true if the string is empty.
|
||||
///
|
||||
bool empty() const { return (string_ == NULL || string_->length == 0); }
|
||||
|
||||
///
|
||||
// Compare this string to the specified string.
|
||||
///
|
||||
int compare(const CefStringBase& str) const {
|
||||
if (empty() && str.empty())
|
||||
return 0;
|
||||
if (empty())
|
||||
return -1;
|
||||
if (str.empty())
|
||||
return 1;
|
||||
return traits::compare(string_, str.GetStruct());
|
||||
}
|
||||
|
||||
///
|
||||
// Clear the string data.
|
||||
///
|
||||
void clear() {
|
||||
if (!empty())
|
||||
traits::clear(string_);
|
||||
}
|
||||
|
||||
|
||||
// The following methods are unique to CEF string template types.
|
||||
|
||||
///
|
||||
// Returns true if this class owns the underlying string structure.
|
||||
///
|
||||
bool IsOwner() const { return owner_; }
|
||||
|
||||
///
|
||||
// Returns a read-only pointer to the underlying string structure. May return
|
||||
// NULL if no structure is currently allocated.
|
||||
///
|
||||
const struct_type* GetStruct() const { return string_; }
|
||||
|
||||
///
|
||||
// Returns a writable pointer to the underlying string structure. Will never
|
||||
// return NULL.
|
||||
///
|
||||
struct_type* GetWritableStruct() {
|
||||
AllocIfNeeded();
|
||||
return string_;
|
||||
}
|
||||
|
||||
///
|
||||
// Clear the state of this class. The underlying string structure and data
|
||||
// will be freed if this class owns the structure.
|
||||
///
|
||||
void ClearAndFree() {
|
||||
if (!string_)
|
||||
return;
|
||||
if (owner_) {
|
||||
clear();
|
||||
delete string_;
|
||||
}
|
||||
string_ = NULL;
|
||||
owner_ = false;
|
||||
}
|
||||
|
||||
///
|
||||
// Attach to the specified string structure. If |owner| is true this class
|
||||
// will take ownership of the structure.
|
||||
///
|
||||
void Attach(struct_type* str, bool owner) {
|
||||
// Free the previous structure and data, if any.
|
||||
ClearAndFree();
|
||||
|
||||
string_ = str;
|
||||
owner_ = owner;
|
||||
}
|
||||
|
||||
///
|
||||
// Take ownership of the specified userfree structure's string data. The
|
||||
// userfree structure itself will be freed. Only use this method with userfree
|
||||
// structures.
|
||||
///
|
||||
void AttachToUserFree(userfree_struct_type str) {
|
||||
// Free the previous structure and data, if any.
|
||||
ClearAndFree();
|
||||
|
||||
if (!str)
|
||||
return;
|
||||
|
||||
AllocIfNeeded();
|
||||
owner_ = true;
|
||||
memcpy(string_, str, sizeof(struct_type));
|
||||
|
||||
// Free the |str| structure but not the data.
|
||||
memset(str, 0, sizeof(struct_type));
|
||||
traits::userfree_free(str);
|
||||
}
|
||||
|
||||
///
|
||||
// Detach from the underlying string structure. To avoid memory leaks only use
|
||||
// this method if you already hold a pointer to the underlying string
|
||||
// structure.
|
||||
///
|
||||
void Detach() {
|
||||
string_ = NULL;
|
||||
owner_ = false;
|
||||
}
|
||||
|
||||
///
|
||||
// Create a userfree structure and give it ownership of this class' string
|
||||
// data. This class will be disassociated from the data. May return NULL if
|
||||
// this string class currently contains no data.
|
||||
///
|
||||
userfree_struct_type DetachToUserFree() {
|
||||
if (empty())
|
||||
return NULL;
|
||||
|
||||
userfree_struct_type str = traits::userfree_alloc();
|
||||
memcpy(str, string_, sizeof(struct_type));
|
||||
|
||||
// Free this class' structure but not the data.
|
||||
memset(string_, 0, sizeof(struct_type));
|
||||
ClearAndFree();
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
///
|
||||
// Set this string's data to the specified character array. If |copy| is true
|
||||
// this class will copy the data. Otherwise, this class will reference the
|
||||
// existing data. Referenced data must exist for the lifetime of this class
|
||||
// and will not be freed by this class.
|
||||
///
|
||||
bool FromString(const char_type* src, size_t src_len, bool copy) {
|
||||
if (src == NULL || src_len == 0) {
|
||||
clear();
|
||||
return true;
|
||||
}
|
||||
AllocIfNeeded();
|
||||
return traits::set(src, src_len, string_, copy) ? true : false;
|
||||
}
|
||||
|
||||
///
|
||||
// Set this string's data from an existing ASCII string. Data will be always
|
||||
// copied. Translation will occur if necessary based on the underlying string
|
||||
// type.
|
||||
///
|
||||
bool FromASCII(const char* str) {
|
||||
size_t len = str ? strlen(str) : 0;
|
||||
if (len == 0) {
|
||||
clear();
|
||||
return true;
|
||||
}
|
||||
AllocIfNeeded();
|
||||
return traits::from_ascii(str, len, string_);
|
||||
}
|
||||
|
||||
///
|
||||
// Return this string's data as a std::string. Translation will occur if
|
||||
// necessary based on the underlying string type.
|
||||
///
|
||||
std::string ToString() const {
|
||||
if (empty())
|
||||
return std::string();
|
||||
return traits::to_string(string_);
|
||||
}
|
||||
|
||||
///
|
||||
// Set this string's data from an existing std::string. Data will be always
|
||||
// copied. Translation will occur if necessary based on the underlying string
|
||||
// type.
|
||||
///
|
||||
bool FromString(const std::string& str) {
|
||||
if (str.empty()) {
|
||||
clear();
|
||||
return true;
|
||||
}
|
||||
AllocIfNeeded();
|
||||
return traits::from_string(str, string_);
|
||||
}
|
||||
|
||||
///
|
||||
// Return this string's data as a std::wstring. Translation will occur if
|
||||
// necessary based on the underlying string type.
|
||||
///
|
||||
std::wstring ToWString() const {
|
||||
if (empty())
|
||||
return std::wstring();
|
||||
return traits::to_wstring(string_);
|
||||
}
|
||||
|
||||
///
|
||||
// Set this string's data from an existing std::wstring. Data will be always
|
||||
// copied. Translation will occur if necessary based on the underlying string
|
||||
// type.
|
||||
///
|
||||
bool FromWString(const std::wstring& str) {
|
||||
if (str.empty()) {
|
||||
clear();
|
||||
return true;
|
||||
}
|
||||
AllocIfNeeded();
|
||||
return traits::from_wstring(str, string_);
|
||||
}
|
||||
#if defined(BUILDING_CEF_SHARED)
|
||||
///
|
||||
// Return this string's data as a string16. Translation will occur if
|
||||
// necessary based on the underlying string type.
|
||||
///
|
||||
string16 ToString16() const {
|
||||
if (empty())
|
||||
return string16();
|
||||
return traits::to_string16(string_);
|
||||
}
|
||||
|
||||
///
|
||||
// Set this string's data from an existing string16. Data will be always
|
||||
// copied. Translation will occur if necessary based on the underlying string
|
||||
// type.
|
||||
///
|
||||
bool FromString16(const string16& str) {
|
||||
if (str.empty()) {
|
||||
clear();
|
||||
return true;
|
||||
}
|
||||
AllocIfNeeded();
|
||||
return traits::from_string16(str, string_);
|
||||
}
|
||||
#endif // BUILDING_CEF_SHARED
|
||||
|
||||
///
|
||||
// Comparison operator overloads.
|
||||
///
|
||||
bool operator<(const CefStringBase& str) const {
|
||||
return (compare(str) < 0);
|
||||
}
|
||||
bool operator<=(const CefStringBase& str) const {
|
||||
return (compare(str) <= 0);
|
||||
}
|
||||
bool operator>(const CefStringBase& str) const {
|
||||
return (compare(str) > 0);
|
||||
}
|
||||
bool operator>=(const CefStringBase& str) const {
|
||||
return (compare(str) >= 0);
|
||||
}
|
||||
bool operator==(const CefStringBase& str) const {
|
||||
return (compare(str) == 0);
|
||||
}
|
||||
bool operator!=(const CefStringBase& str) const {
|
||||
return (compare(str) != 0);
|
||||
}
|
||||
|
||||
///
|
||||
// Assignment operator overloads.
|
||||
///
|
||||
CefStringBase& operator=(const CefStringBase& str) {
|
||||
FromString(str.c_str(), str.length(), true);
|
||||
return *this;
|
||||
}
|
||||
operator std::string() const {
|
||||
return ToString();
|
||||
}
|
||||
CefStringBase& operator=(const std::string& str) {
|
||||
FromString(str);
|
||||
return *this;
|
||||
}
|
||||
CefStringBase& operator=(const char* str) {
|
||||
FromString(std::string(str));
|
||||
return *this;
|
||||
}
|
||||
operator std::wstring() const {
|
||||
return ToWString();
|
||||
}
|
||||
CefStringBase& operator=(const std::wstring& str) {
|
||||
FromWString(str);
|
||||
return *this;
|
||||
}
|
||||
CefStringBase& operator=(const wchar_t* str) {
|
||||
FromWString(std::wstring(str));
|
||||
return *this;
|
||||
}
|
||||
#if (defined(BUILDING_CEF_SHARED) && defined(WCHAR_T_IS_UTF32))
|
||||
operator string16() const {
|
||||
return ToString16();
|
||||
}
|
||||
CefStringBase& operator=(const string16& str) {
|
||||
FromString16(str);
|
||||
return *this;
|
||||
}
|
||||
CefStringBase& operator=(const char16* str) {
|
||||
FromString16(string16(str));
|
||||
return *this;
|
||||
}
|
||||
#endif // BUILDING_CEF_SHARED && WCHAR_T_IS_UTF32
|
||||
|
||||
private:
|
||||
// Allocate the string structure if it doesn't already exist.
|
||||
void AllocIfNeeded() {
|
||||
if (string_ == NULL) {
|
||||
string_ = new struct_type;
|
||||
memset(string_, 0, sizeof(struct_type));
|
||||
owner_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
struct_type* string_;
|
||||
bool owner_;
|
||||
};
|
||||
|
||||
|
||||
typedef CefStringBase<CefStringTraitsWide> CefStringWide;
|
||||
typedef CefStringBase<CefStringTraitsUTF8> CefStringUTF8;
|
||||
typedef CefStringBase<CefStringTraitsUTF16> CefStringUTF16;
|
||||
|
||||
#endif // CEF_INCLUDE_INTERNAL_CEF_STRING_WRAPPERS_H_
|
@@ -1,78 +0,0 @@
|
||||
// Copyright (c) 2011 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef CEF_INCLUDE_INTERNAL_CEF_TIME_H_
|
||||
#define CEF_INCLUDE_INTERNAL_CEF_TIME_H_
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "include/internal/cef_export.h"
|
||||
#include <time.h>
|
||||
|
||||
///
|
||||
// Time information. Values should always be in UTC.
|
||||
///
|
||||
typedef struct _cef_time_t {
|
||||
int year; // Four digit year "2007"
|
||||
int month; // 1-based month (values 1 = January, etc.)
|
||||
#if !defined(OS_MACOSX)
|
||||
int day_of_week; // 0-based day of week (0 = Sunday, etc.)
|
||||
#endif
|
||||
int day_of_month; // 1-based day of month (1-31)
|
||||
int hour; // Hour within the current day (0-23)
|
||||
int minute; // Minute within the current hour (0-59)
|
||||
int second; // Second within the current minute (0-59 plus leap
|
||||
// seconds which may take it up to 60).
|
||||
int millisecond; // Milliseconds within the current second (0-999)
|
||||
} cef_time_t;
|
||||
|
||||
///
|
||||
// Converts cef_time_t to/from time_t. Returns true (1) on success and false (0)
|
||||
// on failure.
|
||||
///
|
||||
CEF_EXPORT int cef_time_to_timet(const cef_time_t* cef_time, time_t* time);
|
||||
CEF_EXPORT int cef_time_from_timet(time_t time, cef_time_t* cef_time);
|
||||
|
||||
///
|
||||
// Converts cef_time_t to/from a double which is the number of seconds since
|
||||
// epoch (Jan 1, 1970). Webkit uses this format to represent time. A value of 0
|
||||
// means "not initialized". Returns true (1) on success and false (0) on
|
||||
// failure.
|
||||
///
|
||||
CEF_EXPORT int cef_time_to_doublet(const cef_time_t* cef_time, double* time);
|
||||
CEF_EXPORT int cef_time_from_doublet(double time, cef_time_t* cef_time);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_INTERNAL_CEF_TIME_H_
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,81 +0,0 @@
|
||||
// Copyright (c) 2010 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
#ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_LINUX_H_
|
||||
#define CEF_INCLUDE_INTERNAL_CEF_TYPES_LINUX_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/internal/cef_build.h"
|
||||
|
||||
#if defined(OS_LINUX)
|
||||
#include <gtk/gtk.h>
|
||||
#include "include/internal/cef_string.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Window handle.
|
||||
#define cef_window_handle_t GtkWidget*
|
||||
#define cef_cursor_handle_t void*
|
||||
|
||||
///
|
||||
// Supported graphics implementations.
|
||||
///
|
||||
enum cef_graphics_implementation_t {
|
||||
DESKTOP_IN_PROCESS = 0,
|
||||
DESKTOP_IN_PROCESS_COMMAND_BUFFER,
|
||||
};
|
||||
|
||||
///
|
||||
// Class representing window information.
|
||||
///
|
||||
typedef struct _cef_window_info_t {
|
||||
// Pointer for the parent GtkBox widget.
|
||||
cef_window_handle_t m_ParentWidget;
|
||||
|
||||
// Pointer for the new browser widget.
|
||||
cef_window_handle_t m_Widget;
|
||||
} cef_window_info_t;
|
||||
|
||||
///
|
||||
// Class representing print context information.
|
||||
///
|
||||
typedef struct _cef_print_info_t {
|
||||
double m_Scale;
|
||||
} cef_print_info_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // OS_LINUX
|
||||
|
||||
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_LINUX_H_
|
@@ -1,96 +0,0 @@
|
||||
// Copyright (c) 2010 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
#ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_MAC_H_
|
||||
#define CEF_INCLUDE_INTERNAL_CEF_TYPES_MAC_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/internal/cef_build.h"
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
#include "include/internal/cef_string.h"
|
||||
|
||||
// Window handle.
|
||||
#ifdef __cplusplus
|
||||
#ifdef __OBJC__
|
||||
@class NSView;
|
||||
#else
|
||||
struct NSView;
|
||||
#endif
|
||||
#define cef_window_handle_t NSView*
|
||||
#else
|
||||
#define cef_window_handle_t void*
|
||||
#endif
|
||||
#define cef_cursor_handle_t void*
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
// Supported graphics implementations.
|
||||
///
|
||||
enum cef_graphics_implementation_t {
|
||||
DESKTOP_IN_PROCESS = 0,
|
||||
DESKTOP_IN_PROCESS_COMMAND_BUFFER,
|
||||
};
|
||||
|
||||
///
|
||||
// Class representing window information.
|
||||
///
|
||||
typedef struct _cef_window_info_t {
|
||||
cef_string_t m_windowName;
|
||||
int m_x;
|
||||
int m_y;
|
||||
int m_nWidth;
|
||||
int m_nHeight;
|
||||
int m_bHidden;
|
||||
|
||||
// NSView pointer for the parent view.
|
||||
cef_window_handle_t m_ParentView;
|
||||
|
||||
// NSView pointer for the new browser view.
|
||||
cef_window_handle_t m_View;
|
||||
} cef_window_info_t;
|
||||
|
||||
///
|
||||
// Class representing print context information.
|
||||
///
|
||||
typedef struct _cef_print_info_t {
|
||||
double m_Scale;
|
||||
} cef_print_info_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // OS_MACOSX
|
||||
|
||||
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_MAC_H_
|
@@ -1,101 +0,0 @@
|
||||
// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
#ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_WIN_H_
|
||||
#define CEF_INCLUDE_INTERNAL_CEF_TYPES_WIN_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/internal/cef_build.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include <windows.h>
|
||||
#include "include/internal/cef_string.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Window handle.
|
||||
#define cef_window_handle_t HWND
|
||||
#define cef_cursor_handle_t HCURSOR
|
||||
|
||||
///
|
||||
// Supported graphics implementations.
|
||||
///
|
||||
enum cef_graphics_implementation_t {
|
||||
ANGLE_IN_PROCESS = 0,
|
||||
ANGLE_IN_PROCESS_COMMAND_BUFFER,
|
||||
DESKTOP_IN_PROCESS,
|
||||
DESKTOP_IN_PROCESS_COMMAND_BUFFER,
|
||||
};
|
||||
|
||||
///
|
||||
// Class representing window information.
|
||||
///
|
||||
typedef struct _cef_window_info_t {
|
||||
// Standard parameters required by CreateWindowEx()
|
||||
DWORD m_dwExStyle;
|
||||
cef_string_t m_windowName;
|
||||
DWORD m_dwStyle;
|
||||
int m_x;
|
||||
int m_y;
|
||||
int m_nWidth;
|
||||
int m_nHeight;
|
||||
cef_window_handle_t m_hWndParent;
|
||||
HMENU m_hMenu;
|
||||
|
||||
// If window rendering is disabled no browser window will be created. Set
|
||||
// |m_hWndParent| to the window that will act as the parent for popup menus,
|
||||
// dialog boxes, etc.
|
||||
BOOL m_bWindowRenderingDisabled;
|
||||
|
||||
// Set to true to enable transparent painting.
|
||||
BOOL m_bTransparentPainting;
|
||||
|
||||
// Handle for the new browser window.
|
||||
cef_window_handle_t m_hWnd;
|
||||
} cef_window_info_t;
|
||||
|
||||
///
|
||||
// Class representing print context information.
|
||||
///
|
||||
typedef struct _cef_print_info_t {
|
||||
HDC m_hDC;
|
||||
RECT m_Rect;
|
||||
double m_Scale;
|
||||
} cef_print_info_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // OS_WIN
|
||||
|
||||
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_WIN_H_
|
@@ -1,642 +0,0 @@
|
||||
// Copyright (c) 2011 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_
|
||||
#define CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/internal/cef_string.h"
|
||||
#include "include/internal/cef_string_list.h"
|
||||
#include "include/internal/cef_types.h"
|
||||
|
||||
///
|
||||
// Template class that provides common functionality for CEF structure wrapping.
|
||||
///
|
||||
template <class traits>
|
||||
class CefStructBase : public traits::struct_type {
|
||||
public:
|
||||
typedef typename traits::struct_type struct_type;
|
||||
|
||||
CefStructBase() : attached_to_(NULL) {
|
||||
Init();
|
||||
}
|
||||
virtual ~CefStructBase() {
|
||||
// Only clear this object's data if it isn't currently attached to a
|
||||
// structure.
|
||||
if (!attached_to_)
|
||||
Clear(this);
|
||||
}
|
||||
|
||||
CefStructBase(const CefStructBase& r) {
|
||||
Init();
|
||||
*this = r;
|
||||
}
|
||||
CefStructBase(const struct_type& r) { // NOLINT(runtime/explicit)
|
||||
Init();
|
||||
*this = r;
|
||||
}
|
||||
|
||||
///
|
||||
// Clear this object's values.
|
||||
///
|
||||
void Reset() {
|
||||
Clear(this);
|
||||
Init();
|
||||
}
|
||||
|
||||
///
|
||||
// Attach to the source structure's existing values. DetachTo() can be called
|
||||
// to insert the values back into the existing structure.
|
||||
///
|
||||
void AttachTo(struct_type& source) {
|
||||
// Only clear this object's data if it isn't currently attached to a
|
||||
// structure.
|
||||
if (!attached_to_)
|
||||
Clear(this);
|
||||
|
||||
// This object is now attached to the new structure.
|
||||
attached_to_ = &source;
|
||||
|
||||
// Transfer ownership of the values from the source structure.
|
||||
memcpy(static_cast<struct_type*>(this), &source, sizeof(struct_type));
|
||||
}
|
||||
|
||||
///
|
||||
// Relinquish ownership of values to the target structure.
|
||||
///
|
||||
void DetachTo(struct_type& target) {
|
||||
if (attached_to_ != &target) {
|
||||
// Clear the target structure's values only if we are not currently
|
||||
// attached to that structure.
|
||||
Clear(&target);
|
||||
}
|
||||
|
||||
// Transfer ownership of the values to the target structure.
|
||||
memcpy(&target, static_cast<struct_type*>(this), sizeof(struct_type));
|
||||
|
||||
// Remove the references from this object.
|
||||
Init();
|
||||
}
|
||||
|
||||
///
|
||||
// Set this object's values. If |copy| is true the source structure's values
|
||||
// will be copied instead of referenced.
|
||||
///
|
||||
void Set(const struct_type& source, bool copy) {
|
||||
traits::set(&source, this, copy);
|
||||
}
|
||||
|
||||
CefStructBase& operator=(const CefStructBase& s) {
|
||||
return operator=(static_cast<const struct_type&>(s));
|
||||
}
|
||||
|
||||
CefStructBase& operator=(const struct_type& s) {
|
||||
Set(s, true);
|
||||
return *this;
|
||||
}
|
||||
|
||||
protected:
|
||||
void Init() {
|
||||
memset(static_cast<struct_type*>(this), 0, sizeof(struct_type));
|
||||
attached_to_ = NULL;
|
||||
traits::init(this);
|
||||
}
|
||||
|
||||
static void Clear(struct_type* s) { traits::clear(s); }
|
||||
|
||||
struct_type* attached_to_;
|
||||
};
|
||||
|
||||
|
||||
struct CefRectTraits {
|
||||
typedef cef_rect_t struct_type;
|
||||
|
||||
static inline void init(struct_type* s) {}
|
||||
static inline void clear(struct_type* s) {}
|
||||
|
||||
static inline void set(const struct_type* src, struct_type* target,
|
||||
bool copy) {
|
||||
*target = *src;
|
||||
}
|
||||
};
|
||||
|
||||
///
|
||||
// Class representing a rectangle.
|
||||
///
|
||||
class CefRect : public CefStructBase<CefRectTraits> {
|
||||
public:
|
||||
typedef CefStructBase<CefRectTraits> parent;
|
||||
|
||||
CefRect() : parent() {}
|
||||
CefRect(const cef_rect_t& r) : parent(r) {} // NOLINT(runtime/explicit)
|
||||
CefRect(const CefRect& r) : parent(r) {} // NOLINT(runtime/explicit)
|
||||
CefRect(int x, int y, int width, int height) : parent() {
|
||||
Set(x, y, width, height);
|
||||
}
|
||||
|
||||
bool IsEmpty() const { return width <= 0 || height <= 0; }
|
||||
void Set(int x, int y, int width, int height) {
|
||||
this->x = x, this->y = y, this->width = width, this->height = height;
|
||||
}
|
||||
};
|
||||
|
||||
inline bool operator==(const CefRect& a, const CefRect& b) {
|
||||
return a.x == b.x && a.y == b.y && a.width == b.width && a.height == b.height;
|
||||
}
|
||||
|
||||
inline bool operator!=(const CefRect& a, const CefRect& b) {
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
|
||||
struct CefPrintOptionsTraits {
|
||||
typedef cef_print_options_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 print options.
|
||||
///
|
||||
typedef CefStructBase<CefPrintOptionsTraits> CefPrintOptions;
|
||||
|
||||
|
||||
|
||||
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->cache_path);
|
||||
cef_string_clear(&s->user_agent);
|
||||
cef_string_clear(&s->product_version);
|
||||
cef_string_clear(&s->locale);
|
||||
if (s->extra_plugin_paths)
|
||||
cef_string_list_free(s->extra_plugin_paths);
|
||||
cef_string_clear(&s->log_file);
|
||||
cef_string_clear(&s->javascript_flags);
|
||||
cef_string_clear(&s->pack_file_path);
|
||||
cef_string_clear(&s->locales_dir_path);
|
||||
}
|
||||
|
||||
static inline void set(const struct_type* src, struct_type* target,
|
||||
bool copy) {
|
||||
target->multi_threaded_message_loop = src->multi_threaded_message_loop;
|
||||
|
||||
cef_string_set(src->cache_path.str, src->cache_path.length,
|
||||
&target->cache_path, copy);
|
||||
cef_string_set(src->user_agent.str, src->user_agent.length,
|
||||
&target->user_agent, copy);
|
||||
cef_string_set(src->product_version.str, src->product_version.length,
|
||||
&target->product_version, copy);
|
||||
cef_string_set(src->locale.str, src->locale.length, &target->locale, copy);
|
||||
|
||||
if (target->extra_plugin_paths)
|
||||
cef_string_list_free(target->extra_plugin_paths);
|
||||
target->extra_plugin_paths = src->extra_plugin_paths ?
|
||||
cef_string_list_copy(src->extra_plugin_paths) : NULL;
|
||||
|
||||
cef_string_set(src->log_file.str, src->log_file.length, &target->log_file,
|
||||
copy);
|
||||
target->log_severity = src->log_severity;
|
||||
target->graphics_implementation = src->graphics_implementation;
|
||||
target->local_storage_quota = src->local_storage_quota;
|
||||
target->session_storage_quota = src->session_storage_quota;
|
||||
cef_string_set(src->javascript_flags.str, src->javascript_flags.length,
|
||||
&target->javascript_flags, copy);
|
||||
|
||||
#if defined(OS_WIN)
|
||||
target->auto_detect_proxy_settings_enabled =
|
||||
src->auto_detect_proxy_settings_enabled;
|
||||
#endif
|
||||
|
||||
cef_string_set(src->pack_file_path.str, src->pack_file_path.length,
|
||||
&target->pack_file_path, copy);
|
||||
cef_string_set(src->locales_dir_path.str, src->locales_dir_path.length,
|
||||
&target->locales_dir_path, copy);
|
||||
target->pack_loading_disabled = src->pack_loading_disabled;
|
||||
}
|
||||
};
|
||||
|
||||
///
|
||||
// Class representing initialization settings.
|
||||
///
|
||||
typedef CefStructBase<CefSettingsTraits> CefSettings;
|
||||
|
||||
|
||||
struct CefBrowserSettingsTraits {
|
||||
typedef cef_browser_settings_t struct_type;
|
||||
|
||||
static inline void init(struct_type* s) {
|
||||
s->size = sizeof(struct_type);
|
||||
}
|
||||
|
||||
static inline void clear(struct_type* s) {
|
||||
cef_string_clear(&s->standard_font_family);
|
||||
cef_string_clear(&s->fixed_font_family);
|
||||
cef_string_clear(&s->serif_font_family);
|
||||
cef_string_clear(&s->sans_serif_font_family);
|
||||
cef_string_clear(&s->cursive_font_family);
|
||||
cef_string_clear(&s->fantasy_font_family);
|
||||
cef_string_clear(&s->default_encoding);
|
||||
cef_string_clear(&s->user_style_sheet_location);
|
||||
}
|
||||
|
||||
static inline void set(const struct_type* src, struct_type* target,
|
||||
bool copy) {
|
||||
target->drag_drop_disabled = src->drag_drop_disabled;
|
||||
target->load_drops_disabled = src->load_drops_disabled;
|
||||
target->history_disabled = src->history_disabled;
|
||||
|
||||
cef_string_set(src->standard_font_family.str,
|
||||
src->standard_font_family.length, &target->standard_font_family, copy);
|
||||
cef_string_set(src->fixed_font_family.str, src->fixed_font_family.length,
|
||||
&target->fixed_font_family, copy);
|
||||
cef_string_set(src->serif_font_family.str, src->serif_font_family.length,
|
||||
&target->serif_font_family, copy);
|
||||
cef_string_set(src->sans_serif_font_family.str,
|
||||
src->sans_serif_font_family.length, &target->sans_serif_font_family,
|
||||
copy);
|
||||
cef_string_set(src->cursive_font_family.str,
|
||||
src->cursive_font_family.length, &target->cursive_font_family, copy);
|
||||
cef_string_set(src->fantasy_font_family.str,
|
||||
src->fantasy_font_family.length, &target->fantasy_font_family, copy);
|
||||
|
||||
target->default_font_size = src->default_font_size;
|
||||
target->default_fixed_font_size = src->default_fixed_font_size;
|
||||
target->minimum_font_size = src->minimum_font_size;
|
||||
target->minimum_logical_font_size = src->minimum_logical_font_size;
|
||||
target->remote_fonts_disabled = src->remote_fonts_disabled;
|
||||
|
||||
cef_string_set(src->default_encoding.str, src->default_encoding.length,
|
||||
&target->default_encoding, copy);
|
||||
|
||||
target->encoding_detector_enabled = src->encoding_detector_enabled;
|
||||
target->javascript_disabled = src->javascript_disabled;
|
||||
target->javascript_open_windows_disallowed =
|
||||
src->javascript_open_windows_disallowed;
|
||||
target->javascript_close_windows_disallowed =
|
||||
src->javascript_close_windows_disallowed;
|
||||
target->javascript_access_clipboard_disallowed =
|
||||
src->javascript_access_clipboard_disallowed;
|
||||
target->dom_paste_disabled = src->dom_paste_disabled;
|
||||
target->caret_browsing_enabled = src->caret_browsing_enabled;
|
||||
target->java_disabled = src->java_disabled;
|
||||
target->plugins_disabled = src->plugins_disabled;
|
||||
target->universal_access_from_file_urls_allowed =
|
||||
src->universal_access_from_file_urls_allowed;
|
||||
target->file_access_from_file_urls_allowed =
|
||||
src->file_access_from_file_urls_allowed;
|
||||
target->web_security_disabled = src->web_security_disabled;
|
||||
target->xss_auditor_enabled = src->xss_auditor_enabled;
|
||||
target->image_load_disabled = src->image_load_disabled;
|
||||
target->shrink_standalone_images_to_fit =
|
||||
src->shrink_standalone_images_to_fit;
|
||||
target->site_specific_quirks_disabled = src->site_specific_quirks_disabled;
|
||||
target->text_area_resize_disabled = src->text_area_resize_disabled;
|
||||
target->page_cache_disabled = src->page_cache_disabled;
|
||||
target->tab_to_links_disabled = src->tab_to_links_disabled;
|
||||
target->hyperlink_auditing_disabled = src->hyperlink_auditing_disabled;
|
||||
target->user_style_sheet_enabled = src->user_style_sheet_enabled;
|
||||
|
||||
cef_string_set(src->user_style_sheet_location.str,
|
||||
src->user_style_sheet_location.length,
|
||||
&target->user_style_sheet_location, copy);
|
||||
|
||||
target->author_and_user_styles_disabled =
|
||||
src->author_and_user_styles_disabled;
|
||||
target->local_storage_disabled = src->local_storage_disabled;
|
||||
target->databases_disabled = src->databases_disabled;
|
||||
target->application_cache_disabled = src->application_cache_disabled;
|
||||
target->webgl_disabled = src->webgl_disabled;
|
||||
target->accelerated_compositing_enabled =
|
||||
src->accelerated_compositing_enabled;
|
||||
target->threaded_compositing_enabled = src->threaded_compositing_enabled;
|
||||
target->accelerated_layers_disabled = src->accelerated_layers_disabled;
|
||||
target->accelerated_video_disabled = src->accelerated_video_disabled;
|
||||
target->accelerated_2d_canvas_disabled =
|
||||
src->accelerated_2d_canvas_disabled;
|
||||
target->accelerated_painting_disabled = src->accelerated_painting_disabled;
|
||||
target->accelerated_filters_disabled = src->accelerated_filters_disabled;
|
||||
target->accelerated_plugins_disabled = src->accelerated_plugins_disabled;
|
||||
target->developer_tools_disabled = src->developer_tools_disabled;
|
||||
target->fullscreen_enabled = src->fullscreen_enabled;
|
||||
}
|
||||
};
|
||||
|
||||
///
|
||||
// Class representing browser initialization settings.
|
||||
///
|
||||
typedef CefStructBase<CefBrowserSettingsTraits> CefBrowserSettings;
|
||||
|
||||
|
||||
struct CefURLPartsTraits {
|
||||
typedef cef_urlparts_t struct_type;
|
||||
|
||||
static inline void init(struct_type* s) {}
|
||||
|
||||
static inline void clear(struct_type* s) {
|
||||
cef_string_clear(&s->spec);
|
||||
cef_string_clear(&s->scheme);
|
||||
cef_string_clear(&s->username);
|
||||
cef_string_clear(&s->password);
|
||||
cef_string_clear(&s->host);
|
||||
cef_string_clear(&s->port);
|
||||
cef_string_clear(&s->path);
|
||||
cef_string_clear(&s->query);
|
||||
}
|
||||
|
||||
static inline void set(const struct_type* src, struct_type* target,
|
||||
bool copy) {
|
||||
cef_string_set(src->spec.str, src->spec.length, &target->spec, copy);
|
||||
cef_string_set(src->scheme.str, src->scheme.length, &target->scheme, copy);
|
||||
cef_string_set(src->username.str, src->username.length, &target->username,
|
||||
copy);
|
||||
cef_string_set(src->password.str, src->password.length, &target->password,
|
||||
copy);
|
||||
cef_string_set(src->host.str, src->host.length, &target->host, copy);
|
||||
cef_string_set(src->port.str, src->port.length, &target->port, copy);
|
||||
cef_string_set(src->path.str, src->path.length, &target->path, copy);
|
||||
cef_string_set(src->query.str, src->query.length, &target->query, copy);
|
||||
}
|
||||
};
|
||||
|
||||
///
|
||||
// Class representing a URL's component parts.
|
||||
///
|
||||
typedef CefStructBase<CefURLPartsTraits> CefURLParts;
|
||||
|
||||
|
||||
struct CefTimeTraits {
|
||||
typedef cef_time_t struct_type;
|
||||
|
||||
static inline void init(struct_type* s) {}
|
||||
|
||||
static inline void clear(struct_type* s) {}
|
||||
|
||||
static inline void set(const struct_type* src, struct_type* target,
|
||||
bool copy) {
|
||||
*target = *src;
|
||||
}
|
||||
};
|
||||
|
||||
///
|
||||
// Class representing a time.
|
||||
///
|
||||
class CefTime : public CefStructBase<CefTimeTraits> {
|
||||
public:
|
||||
typedef CefStructBase<CefTimeTraits> parent;
|
||||
|
||||
CefTime() : parent() {}
|
||||
CefTime(const cef_time_t& r) : parent(r) {} // NOLINT(runtime/explicit)
|
||||
CefTime(const CefTime& r) : parent(r) {} // NOLINT(runtime/explicit)
|
||||
explicit CefTime(time_t r) : parent() { SetTimeT(r); }
|
||||
explicit CefTime(double r) : parent() { SetDoubleT(r); }
|
||||
|
||||
// Converts to/from time_t.
|
||||
void SetTimeT(time_t r) {
|
||||
cef_time_from_timet(r, this);
|
||||
}
|
||||
time_t GetTimeT() const {
|
||||
time_t time = 0;
|
||||
cef_time_to_timet(this, &time);
|
||||
return time;
|
||||
}
|
||||
|
||||
// Converts to/from a double which is the number of seconds since epoch
|
||||
// (Jan 1, 1970). Webkit uses this format to represent time. A value of 0
|
||||
// means "not initialized".
|
||||
void SetDoubleT(double r) {
|
||||
cef_time_from_doublet(r, this);
|
||||
}
|
||||
double GetDoubleT() const {
|
||||
double time = 0;
|
||||
cef_time_to_doublet(this, &time);
|
||||
return time;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct CefCookieTraits {
|
||||
typedef cef_cookie_t struct_type;
|
||||
|
||||
static inline void init(struct_type* s) {}
|
||||
|
||||
static inline void clear(struct_type* s) {
|
||||
cef_string_clear(&s->name);
|
||||
cef_string_clear(&s->value);
|
||||
cef_string_clear(&s->domain);
|
||||
cef_string_clear(&s->path);
|
||||
}
|
||||
|
||||
static inline void set(const struct_type* src, struct_type* target,
|
||||
bool copy) {
|
||||
cef_string_set(src->name.str, src->name.length, &target->name, copy);
|
||||
cef_string_set(src->value.str, src->value.length, &target->value, copy);
|
||||
cef_string_set(src->domain.str, src->domain.length, &target->domain, copy);
|
||||
cef_string_set(src->path.str, src->path.length, &target->path, copy);
|
||||
target->secure = src->secure;
|
||||
target->httponly = src->httponly;
|
||||
target->creation = src->creation;
|
||||
target->last_access = src->last_access;
|
||||
target->has_expires = src->has_expires;
|
||||
target->expires = src->expires;
|
||||
}
|
||||
};
|
||||
|
||||
///
|
||||
// Class representing a cookie.
|
||||
///
|
||||
typedef CefStructBase<CefCookieTraits> CefCookie;
|
||||
|
||||
|
||||
struct CefMenuInfoTraits {
|
||||
typedef cef_menu_info_t struct_type;
|
||||
|
||||
static inline void init(struct_type* s) {}
|
||||
|
||||
static inline void clear(struct_type* s) {
|
||||
cef_string_clear(&s->linkUrl);
|
||||
cef_string_clear(&s->imageUrl);
|
||||
cef_string_clear(&s->pageUrl);
|
||||
cef_string_clear(&s->frameUrl);
|
||||
cef_string_clear(&s->selectionText);
|
||||
cef_string_clear(&s->misspelledWord);
|
||||
cef_string_clear(&s->securityInfo);
|
||||
}
|
||||
|
||||
static inline void set(const struct_type* src, struct_type* target,
|
||||
bool copy) {
|
||||
target->typeFlags = src->typeFlags;
|
||||
target->x = src->x;
|
||||
target->y = src->y;
|
||||
|
||||
cef_string_set(src->linkUrl.str, src->linkUrl.length,
|
||||
&target->linkUrl, copy);
|
||||
cef_string_set(src->imageUrl.str, src->imageUrl.length,
|
||||
&target->imageUrl, copy);
|
||||
cef_string_set(src->pageUrl.str, src->pageUrl.length,
|
||||
&target->pageUrl, copy);
|
||||
cef_string_set(src->frameUrl.str, src->frameUrl.length,
|
||||
&target->frameUrl, copy);
|
||||
cef_string_set(src->selectionText.str, src->selectionText.length,
|
||||
&target->selectionText, copy);
|
||||
cef_string_set(src->misspelledWord.str, src->misspelledWord.length,
|
||||
&target->misspelledWord, copy);
|
||||
cef_string_set(src->securityInfo.str, src->securityInfo.length,
|
||||
&target->securityInfo, copy);
|
||||
|
||||
target->editFlags = src->editFlags;
|
||||
}
|
||||
};
|
||||
|
||||
///
|
||||
// Class representing menu info.
|
||||
///
|
||||
typedef CefStructBase<CefMenuInfoTraits> CefMenuInfo;
|
||||
|
||||
|
||||
struct CefProxyInfoTraits {
|
||||
typedef cef_proxy_info_t struct_type;
|
||||
|
||||
static inline void init(struct_type* s) {}
|
||||
|
||||
static inline void clear(struct_type* s) {
|
||||
cef_string_clear(&s->proxyList);
|
||||
}
|
||||
|
||||
static inline void set(const struct_type* src, struct_type* target,
|
||||
bool copy) {
|
||||
target->proxyType = src->proxyType;
|
||||
cef_string_set(src->proxyList.str, src->proxyList.length,
|
||||
&target->proxyList, copy);
|
||||
}
|
||||
};
|
||||
|
||||
///
|
||||
// Class representing the results of proxy resolution.
|
||||
///
|
||||
class CefProxyInfo : public CefStructBase<CefProxyInfoTraits> {
|
||||
public:
|
||||
///
|
||||
// Use a direction connection instead of a proxy.
|
||||
///
|
||||
void UseDirect() {
|
||||
proxyType = PROXY_TYPE_DIRECT;
|
||||
}
|
||||
|
||||
///
|
||||
// Use one or more named proxy servers specified in WinHTTP format. Each proxy
|
||||
// server is of the form:
|
||||
//
|
||||
// [<scheme>"://"]<server>[":"<port>]
|
||||
//
|
||||
// Multiple values may be separated by semicolons or whitespace. For example,
|
||||
// "foo1:80;foo2:80".
|
||||
///
|
||||
void UseNamedProxy(const CefString& proxy_uri_list) {
|
||||
proxyType = PROXY_TYPE_NAMED;
|
||||
(CefString(&proxyList)) = proxy_uri_list;
|
||||
}
|
||||
|
||||
///
|
||||
// Use one or more named proxy servers specified in PAC script format. For
|
||||
// example, "PROXY foobar:99; SOCKS fml:2; DIRECT".
|
||||
///
|
||||
void UsePacString(const CefString& pac_string) {
|
||||
proxyType = PROXY_TYPE_PAC_STRING;
|
||||
(CefString(&proxyList)) = pac_string;
|
||||
}
|
||||
|
||||
bool IsDirect() const { return proxyType == PROXY_TYPE_DIRECT; }
|
||||
bool IsNamedProxy() const { return proxyType == PROXY_TYPE_NAMED; }
|
||||
bool IsPacString() const { return proxyType == PROXY_TYPE_PAC_STRING; }
|
||||
|
||||
CefString ProxyList() const { return CefString(&proxyList); }
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_
|
@@ -1,167 +0,0 @@
|
||||
// Copyright (c) 2008 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
#ifndef CEF_INCLUDE_INTERNAL_CEF_WIN_H_
|
||||
#define CEF_INCLUDE_INTERNAL_CEF_WIN_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include <windows.h>
|
||||
#include "include/internal/cef_types_win.h"
|
||||
#include "include/internal/cef_types_wrappers.h"
|
||||
|
||||
///
|
||||
// Atomic increment and decrement.
|
||||
///
|
||||
#define CefAtomicIncrement(p) InterlockedIncrement(p)
|
||||
#define CefAtomicDecrement(p) InterlockedDecrement(p)
|
||||
|
||||
///
|
||||
// Critical section wrapper.
|
||||
///
|
||||
class CefCriticalSection {
|
||||
public:
|
||||
CefCriticalSection() {
|
||||
memset(&m_sec, 0, sizeof(CRITICAL_SECTION));
|
||||
InitializeCriticalSection(&m_sec);
|
||||
}
|
||||
virtual ~CefCriticalSection() {
|
||||
DeleteCriticalSection(&m_sec);
|
||||
}
|
||||
void Lock() {
|
||||
EnterCriticalSection(&m_sec);
|
||||
}
|
||||
void Unlock() {
|
||||
LeaveCriticalSection(&m_sec);
|
||||
}
|
||||
|
||||
CRITICAL_SECTION m_sec;
|
||||
};
|
||||
|
||||
///
|
||||
// Handle types.
|
||||
///
|
||||
#define CefWindowHandle cef_window_handle_t
|
||||
#define CefCursorHandle cef_cursor_handle_t
|
||||
|
||||
|
||||
struct 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->m_windowName);
|
||||
}
|
||||
|
||||
static inline void set(const struct_type* src, struct_type* target,
|
||||
bool copy) {
|
||||
target->m_dwExStyle = src->m_dwExStyle;
|
||||
cef_string_set(src->m_windowName.str, src->m_windowName.length,
|
||||
&target->m_windowName, copy);
|
||||
target->m_dwStyle = src->m_dwStyle;
|
||||
target->m_x = src->m_x;
|
||||
target->m_y = src->m_y;
|
||||
target->m_nWidth = src->m_nWidth;
|
||||
target->m_nHeight = src->m_nHeight;
|
||||
target->m_hWndParent = src->m_hWndParent;
|
||||
target->m_hMenu = src->m_hMenu;
|
||||
target->m_bWindowRenderingDisabled = src->m_bWindowRenderingDisabled;
|
||||
target->m_bTransparentPainting = src->m_bTransparentPainting;
|
||||
target->m_hWnd = src->m_hWnd;
|
||||
}
|
||||
};
|
||||
|
||||
///
|
||||
// Class representing window information.
|
||||
///
|
||||
class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
|
||||
public:
|
||||
typedef CefStructBase<CefWindowInfoTraits> parent;
|
||||
|
||||
CefWindowInfo() : parent() {}
|
||||
explicit CefWindowInfo(const cef_window_info_t& r) : parent(r) {}
|
||||
explicit CefWindowInfo(const CefWindowInfo& r) : parent(r) {}
|
||||
|
||||
void SetAsChild(HWND hWndParent, RECT windowRect) {
|
||||
m_dwStyle = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_TABSTOP |
|
||||
WS_VISIBLE;
|
||||
m_hWndParent = hWndParent;
|
||||
m_x = windowRect.left;
|
||||
m_y = windowRect.top;
|
||||
m_nWidth = windowRect.right - windowRect.left;
|
||||
m_nHeight = windowRect.bottom - windowRect.top;
|
||||
}
|
||||
|
||||
void SetAsPopup(HWND hWndParent, const CefString& windowName) {
|
||||
m_dwStyle = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS |
|
||||
WS_VISIBLE;
|
||||
m_hWndParent = hWndParent;
|
||||
m_x = CW_USEDEFAULT;
|
||||
m_y = CW_USEDEFAULT;
|
||||
m_nWidth = CW_USEDEFAULT;
|
||||
m_nHeight = CW_USEDEFAULT;
|
||||
|
||||
cef_string_copy(windowName.c_str(), windowName.length(), &m_windowName);
|
||||
}
|
||||
|
||||
void SetAsOffScreen(HWND hWndParent) {
|
||||
m_bWindowRenderingDisabled = TRUE;
|
||||
m_hWndParent = hWndParent;
|
||||
}
|
||||
|
||||
void SetTransparentPainting(BOOL transparentPainting) {
|
||||
m_bTransparentPainting = transparentPainting;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct CefPrintInfoTraits {
|
||||
typedef cef_print_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->m_hDC = src->m_hDC;
|
||||
target->m_Rect = src->m_Rect;
|
||||
target->m_Scale = src->m_Scale;
|
||||
}
|
||||
};
|
||||
|
||||
///
|
||||
// Class representing print context information.
|
||||
///
|
||||
typedef CefStructBase<CefPrintInfoTraits> CefPrintInfo;
|
||||
|
||||
#endif // OS_WIN
|
||||
|
||||
#endif // CEF_INCLUDE_INTERNAL_CEF_WIN_H_
|
Reference in New Issue
Block a user