Introduce CefString and cef_string_t implementations that support string type conversions and customization of the API string type (issue #146).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@145 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2010-11-22 17:49:46 +00:00
parent 1e1c2ad8d7
commit 7d60642638
121 changed files with 2598 additions and 3209 deletions

10
cef.gyp
View File

@ -89,7 +89,6 @@
'tests/cefclient/res/small.ico',
'tests/cefclient/res/uiplugin.html',
'tests/cefclient/resource_util_win.cpp',
'tests/cefclient/string_util_win.cpp',
'tests/cefclient/uiplugin.cpp',
'tests/cefclient/uiplugin.h',
'tests/cefclient/uiplugin_test.cpp',
@ -149,8 +148,6 @@
},
'sources': [
'tests/cefclient/cefclient_mac.mm',
'tests/cefclient/string_util_mac.h',
'tests/cefclient/string_util_mac.mm',
],
}],
[ 'OS=="linux" or OS=="freebsd" or OS=="openbsd"', {
@ -179,6 +176,7 @@
'tests/unittests/request_unittest.cc',
'tests/unittests/run_all_unittests.cc',
'tests/unittests/stream_unittest.cc',
'tests/unittests/string_unittest.cc',
'tests/unittests/test_handler.h',
'tests/unittests/test_suite.h',
'tests/unittests/v8_unittest.cc',
@ -283,6 +281,8 @@
'include/cef_string.h',
'include/cef_string_list.h',
'include/cef_string_map.h',
'include/cef_string_types.h',
'include/cef_string_wrappers.h',
'include/cef_types.h',
'libcef_dll/cef_logging.h',
'libcef_dll/cpptoc/browser_cpptoc.cc',
@ -466,6 +466,8 @@
'include/cef_string.h',
'include/cef_string_list.h',
'include/cef_string_map.h',
'include/cef_string_types.h',
'include/cef_string_wrappers.h',
'include/cef_types.h',
'libcef/browser_appcache_system.cc',
'libcef/browser_appcache_system.h',
@ -511,9 +513,9 @@
'libcef/cef_process_sub_thread.h',
'libcef/cef_process_ui_thread.cc',
'libcef/cef_process_ui_thread.h',
'libcef/cef_string.c',
'libcef/cef_string_list.cc',
'libcef/cef_string_map.cc',
'libcef/cef_string_types.cc',
'libcef/cef_thread.cc',
'libcef/cef_thread.h',
'libcef/dom_storage_area.cc',

View File

@ -137,8 +137,8 @@ void CefDoMessageLoopWork();
// example.test.increment();
//
/*--cef()--*/
bool CefRegisterExtension(const std::wstring& extension_name,
const std::wstring& javascript_code,
bool CefRegisterExtension(const CefString& extension_name,
const CefString& javascript_code,
CefRefPtr<CefV8Handler> handler);
@ -147,8 +147,8 @@ bool CefRegisterExtension(const std::wstring& extension_name,
// by CefSchemeHandler instances returned by the factory. Specify an empty
// |host_name| value to match all host names.
/*--cef()--*/
bool CefRegisterScheme(const std::wstring& scheme_name,
const std::wstring& host_name,
bool CefRegisterScheme(const CefString& scheme_name,
const CefString& host_name,
CefRefPtr<CefSchemeHandlerFactory> factory);
@ -215,9 +215,9 @@ public:
//
// class MyHandler : public CefThreadSafeBase<CefHandler>
// {
// std::wstring m_title;
// CefString m_title;
//
// virtual RetVal HandleTitleChange(const std::wstring& title)
// virtual RetVal HandleTitleChange(const CefString& title)
// {
// Lock(); // Begin protecting code
// m_title = title;
@ -354,7 +354,7 @@ public:
/*--cef()--*/
static bool CreateBrowser(CefWindowInfo& windowInfo, bool popup,
CefRefPtr<CefHandler> handler,
const std::wstring& url);
const CefString& url);
// Create a new browser window using the window parameters specified
// by |windowInfo|. The |popup| parameter should be true if the new window is
@ -364,7 +364,7 @@ public:
static CefRefPtr<CefBrowser> CreateBrowserSync(CefWindowInfo& windowInfo,
bool popup,
CefRefPtr<CefHandler> handler,
const std::wstring& url);
const CefString& url);
// Returns true if the browser can navigate backwards.
/*--cef()--*/
@ -415,11 +415,11 @@ public:
// Returns the frame with the specified name, or NULL if not found.
/*--cef()--*/
virtual CefRefPtr<CefFrame> GetFrame(const std::wstring& name) =0;
virtual CefRefPtr<CefFrame> GetFrame(const CefString& name) =0;
// Returns the names of all existing frames.
/*--cef()--*/
virtual void GetFrameNames(std::vector<std::wstring>& names) =0;
virtual void GetFrameNames(std::vector<CefString>& names) =0;
// Search for |searchText|. |identifier| can be used to have multiple searches
// running simultaniously. |forward| indicates whether to search forward or
@ -427,7 +427,7 @@ public:
// be case-sensitive. |findNext| indicates whether this is the first request
// or a follow-up.
/*--cef()--*/
virtual void Find(int identifier, const std::wstring& searchText,
virtual void Find(int identifier, const CefString& searchText,
bool forward, bool matchCase, bool findNext) =0;
// Cancel all searches that are currently going on.
@ -476,11 +476,11 @@ public:
// Returns this frame's HTML source as a string.
/*--cef()--*/
virtual std::wstring GetSource() =0;
virtual CefString GetSource() =0;
// Returns this frame's display text as a string.
/*--cef()--*/
virtual std::wstring GetText() =0;
virtual CefString GetText() =0;
// Load the request represented by the |request| object.
/*--cef()--*/
@ -488,17 +488,17 @@ public:
// Load the specified |url|.
/*--cef()--*/
virtual void LoadURL(const std::wstring& url) =0;
virtual void LoadURL(const CefString& url) =0;
// Load the contents of |string| with the optional dummy target |url|.
/*--cef()--*/
virtual void LoadString(const std::wstring& string,
const std::wstring& url) =0;
virtual void LoadString(const CefString& string,
const CefString& url) =0;
// Load the contents of |stream| with the optional dummy target |url|.
/*--cef()--*/
virtual void LoadStream(CefRefPtr<CefStreamReader> stream,
const std::wstring& url) =0;
const CefString& url) =0;
// Execute a string of JavaScript code in this frame. The |script_url|
// parameter is the URL where the script in question can be found, if any.
@ -506,8 +506,8 @@ public:
// error. The |start_line| parameter is the base line number to use for error
// reporting.
/*--cef()--*/
virtual void ExecuteJavaScript(const std::wstring& jsCode,
const std::wstring& scriptUrl,
virtual void ExecuteJavaScript(const CefString& jsCode,
const CefString& scriptUrl,
int startLine) =0;
// Returns true if this is the main frame.
@ -520,11 +520,11 @@ public:
// Returns this frame's name.
/*--cef()--*/
virtual std::wstring GetName() =0;
virtual CefString GetName() =0;
// Return the URL currently loaded in this frame.
/*--cef()--*/
virtual std::wstring GetURL() =0;
virtual CefString GetURL() =0;
};
@ -557,7 +557,7 @@ public:
CefWindowInfo& windowInfo, bool popup,
const CefPopupFeatures& popupFeatures,
CefRefPtr<CefHandler>& handler,
std::wstring& url,
CefString& url,
CefBrowserSettings& settings) =0;
// Event called after a new window is created. The return value is currently
@ -570,13 +570,13 @@ public:
/*--cef()--*/
virtual RetVal HandleAddressChange(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const std::wstring& url) =0;
const CefString& url) =0;
// Event called when the page title changes. The return value is currently
// ignored.
/*--cef()--*/
virtual RetVal HandleTitleChange(CefRefPtr<CefBrowser> browser,
const std::wstring& title) =0;
const CefString& title) =0;
// Various browser navigation types supported by chrome.
typedef cef_handler_navtype_t NavType;
@ -618,8 +618,8 @@ public:
virtual RetVal HandleLoadError(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
ErrorCode errorCode,
const std::wstring& failedUrl,
std::wstring& errorText) =0;
const CefString& failedUrl,
CefString& errorText) =0;
// Event called before a resource is loaded. To allow the resource to load
// normally return RV_CONTINUE. To redirect the resource to a new url
@ -632,9 +632,9 @@ public:
/*--cef()--*/
virtual RetVal HandleBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefRequest> request,
std::wstring& redirectUrl,
CefString& redirectUrl,
CefRefPtr<CefStreamReader>& resourceStream,
std::wstring& mimeType,
CefString& mimeType,
int loadFlags) =0;
// Called when a server indicates via the 'Content-Disposition' header that a
@ -646,8 +646,8 @@ public:
// or RV_HANDLED to cancel the file download.
/*--cef()--*/
virtual RetVal HandleDownloadResponse(CefRefPtr<CefBrowser> browser,
const std::wstring& mimeType,
const std::wstring& fileName,
const CefString& mimeType,
const CefString& fileName,
int64 contentLength,
CefRefPtr<CefDownloadHandler>& handler) =0;
@ -668,7 +668,7 @@ public:
// alternate text. The return value is currently ignored.
/*--cef()--*/
virtual RetVal HandleGetMenuLabel(CefRefPtr<CefBrowser> browser,
MenuId menuId, std::wstring& label) =0;
MenuId menuId, CefString& label) =0;
// Event called when an option is selected from the default context menu.
// Return RV_HANDLED to cancel default handling of the action.
@ -703,22 +703,22 @@ public:
virtual RetVal HandlePrintHeaderFooter(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefPrintInfo& printInfo,
const std::wstring& url,
const std::wstring& title,
const CefString& url,
const CefString& title,
int currentPage, int maxPages,
std::wstring& topLeft,
std::wstring& topCenter,
std::wstring& topRight,
std::wstring& bottomLeft,
std::wstring& bottomCenter,
std::wstring& bottomRight) =0;
CefString& topLeft,
CefString& topCenter,
CefString& topRight,
CefString& bottomLeft,
CefString& bottomCenter,
CefString& bottomRight) =0;
// Run a JS alert message. Return RV_CONTINUE to display the default alert
// or RV_HANDLED if you displayed a custom alert.
/*--cef()--*/
virtual RetVal HandleJSAlert(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const std::wstring& message) =0;
const CefString& message) =0;
// Run a JS confirm request. Return RV_CONTINUE to display the default alert
// or RV_HANDLED if you displayed a custom alert. If you handled the alert
@ -726,7 +726,7 @@ public:
/*--cef()--*/
virtual RetVal HandleJSConfirm(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const std::wstring& message, bool& retval) =0;
const CefString& message, bool& retval) =0;
// Run a JS prompt request. Return RV_CONTINUE to display the default prompt
// or RV_HANDLED if you displayed a custom prompt. If you handled the prompt
@ -735,10 +735,10 @@ public:
/*--cef()--*/
virtual RetVal HandleJSPrompt(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const std::wstring& message,
const std::wstring& defaultValue,
const CefString& message,
const CefString& defaultValue,
bool& retval,
std::wstring& result) =0;
CefString& result) =0;
// Event called for adding values to a frame's JavaScript 'window' object. The
// return value is currently ignored.
@ -792,14 +792,14 @@ public:
// the browser to display the tooltip.
/*--cef()--*/
virtual RetVal HandleTooltip(CefRefPtr<CefBrowser> browser,
std::wstring& text) =0;
CefString& text) =0;
// Called to display a console message. Return RV_HANDLED to stop the message
// from being output to the console.
/*--cef()--*/
virtual RetVal HandleConsoleMessage(CefRefPtr<CefBrowser> browser,
const std::wstring& message,
const std::wstring& source, int line) =0;
const CefString& message,
const CefString& source, int line) =0;
// Called to report find results returned by CefBrowser::Find(). |identifer|
// is the identifier passed to CefBrowser::Find(), |count| is the number of
@ -820,7 +820,7 @@ public:
class CefRequest : public CefBase
{
public:
typedef std::map<std::wstring,std::wstring> HeaderMap;
typedef std::map<CefString,CefString> HeaderMap;
// Create a new CefRequest object.
/*--cef()--*/
@ -828,16 +828,16 @@ public:
// Fully qualified URL to load.
/*--cef()--*/
virtual std::wstring GetURL() =0;
virtual CefString GetURL() =0;
/*--cef()--*/
virtual void SetURL(const std::wstring& url) =0;
virtual void SetURL(const CefString& url) =0;
// Optional request method type, defaulting to POST if post data is provided
// and GET otherwise.
/*--cef()--*/
virtual std::wstring GetMethod() =0;
virtual CefString GetMethod() =0;
/*--cef()--*/
virtual void SetMethod(const std::wstring& method) =0;
virtual void SetMethod(const CefString& method) =0;
// Optional post data.
/*--cef()--*/
@ -853,8 +853,8 @@ public:
// Set all values at one time.
/*--cef()--*/
virtual void Set(const std::wstring& url,
const std::wstring& method,
virtual void Set(const CefString& url,
const CefString& method,
CefRefPtr<CefPostData> postData,
const HeaderMap& headerMap) =0;
};
@ -912,7 +912,7 @@ public:
// The post data element will represent a file.
/*--cef()--*/
virtual void SetToFile(const std::wstring& fileName) =0;
virtual void SetToFile(const CefString& fileName) =0;
// The post data element will represent bytes. The bytes passed
// in will be copied.
@ -925,7 +925,7 @@ public:
// Return the file name.
/*--cef()--*/
virtual std::wstring GetFile() =0;
virtual CefString GetFile() =0;
// Return the number of bytes.
/*--cef()--*/
@ -969,7 +969,7 @@ class CefStreamReader : public CefBase
public:
// Create a new CefStreamReader object.
/*--cef()--*/
static CefRefPtr<CefStreamReader> CreateForFile(const std::wstring& fileName);
static CefRefPtr<CefStreamReader> CreateForFile(const CefString& fileName);
/*--cef()--*/
static CefRefPtr<CefStreamReader> CreateForData(void* data, size_t size);
/*--cef()--*/
@ -1026,7 +1026,7 @@ class CefStreamWriter : public CefBase
public:
// Create a new CefStreamWriter object.
/*--cef()--*/
static CefRefPtr<CefStreamWriter> CreateForFile(const std::wstring& fileName);
static CefRefPtr<CefStreamWriter> CreateForFile(const CefString& fileName);
/*--cef()--*/
static CefRefPtr<CefStreamWriter> CreateForHandler(CefRefPtr<CefWriteHandler> handler);
@ -1059,11 +1059,11 @@ public:
// Execute with the specified argument list and return value. Return true if
// the method was handled.
/*--cef()--*/
virtual bool Execute(const std::wstring& name,
virtual bool Execute(const CefString& name,
CefRefPtr<CefV8Value> object,
const CefV8ValueList& arguments,
CefRefPtr<CefV8Value>& retval,
std::wstring& exception) =0;
CefString& exception) =0;
};
@ -1087,13 +1087,13 @@ public:
/*--cef()--*/
static CefRefPtr<CefV8Value> CreateDouble(double value);
/*--cef()--*/
static CefRefPtr<CefV8Value> CreateString(const std::wstring& value);
static CefRefPtr<CefV8Value> CreateString(const CefString& value);
/*--cef()--*/
static CefRefPtr<CefV8Value> CreateObject(CefRefPtr<CefBase> user_data);
/*--cef()--*/
static CefRefPtr<CefV8Value> CreateArray();
/*--cef()--*/
static CefRefPtr<CefV8Value> CreateFunction(const std::wstring& name,
static CefRefPtr<CefV8Value> CreateFunction(const CefString& name,
CefRefPtr<CefV8Handler> handler);
// Check the value type.
@ -1125,7 +1125,7 @@ public:
/*--cef()--*/
virtual double GetDoubleValue() =0;
/*--cef()--*/
virtual std::wstring GetStringValue() =0;
virtual CefString GetStringValue() =0;
// OBJECT METHODS - These methods are only available on objects. Arrays and
@ -1135,32 +1135,32 @@ public:
// Returns true if the object has a value with the specified identifier.
/*--cef(capi_name=has_value_bykey)--*/
virtual bool HasValue(const std::wstring& key) =0;
virtual bool HasValue(const CefString& key) =0;
/*--cef(capi_name=has_value_byindex)--*/
virtual bool HasValue(int index) =0;
// Delete the value with the specified identifier.
/*--cef(capi_name=delete_value_bykey)--*/
virtual bool DeleteValue(const std::wstring& key) =0;
virtual bool DeleteValue(const CefString& key) =0;
/*--cef(capi_name=delete_value_byindex)--*/
virtual bool DeleteValue(int index) =0;
// Returns the value with the specified identifier.
/*--cef(capi_name=get_value_bykey)--*/
virtual CefRefPtr<CefV8Value> GetValue(const std::wstring& key) =0;
virtual CefRefPtr<CefV8Value> GetValue(const CefString& key) =0;
/*--cef(capi_name=get_value_byindex)--*/
virtual CefRefPtr<CefV8Value> GetValue(int index) =0;
// Associate value with the specified identifier.
/*--cef(capi_name=set_value_bykey)--*/
virtual bool SetValue(const std::wstring& key, CefRefPtr<CefV8Value> value) =0;
virtual bool SetValue(const CefString& key, CefRefPtr<CefV8Value> value) =0;
/*--cef(capi_name=set_value_byindex)--*/
virtual bool SetValue(int index, CefRefPtr<CefV8Value> value) =0;
// Read the keys for the object's values into the specified vector. Integer-
// based keys will also be returned as strings.
/*--cef()--*/
virtual bool GetKeys(std::vector<std::wstring>& keys) =0;
virtual bool GetKeys(std::vector<CefString>& keys) =0;
// Returns the user data, if any, specified when the object was created.
/*--cef()--*/
@ -1178,7 +1178,7 @@ public:
// Returns the function name.
/*--cef()--*/
virtual std::wstring GetFunctionName() =0;
virtual CefString GetFunctionName() =0;
// Returns the function handler or NULL if not a CEF-created function.
/*--cef()--*/
@ -1189,7 +1189,7 @@ public:
virtual bool ExecuteFunction(CefRefPtr<CefV8Value> object,
const CefV8ValueList& arguments,
CefRefPtr<CefV8Value>& retval,
std::wstring& exception) =0;
CefString& exception) =0;
};
@ -1220,7 +1220,7 @@ public:
// |mime_type| to the mime type for the response.
/*--cef()--*/
virtual bool ProcessRequest(CefRefPtr<CefRequest> request,
std::wstring& mime_type, int* response_length) =0;
CefString& mime_type, int* response_length) =0;
// Cancel processing of the request.
/*--cef()--*/
@ -1265,7 +1265,7 @@ public:
/*--cef()--*/
static CefRefPtr<CefXmlReader> Create(CefRefPtr<CefStreamReader> stream,
EncodingType encodingType,
const std::wstring& URI);
const CefString& URI);
// Moves the cursor to the next node in the document. This method must be
// called at least once to set the current cursor position. Returns true if
@ -1284,7 +1284,7 @@ public:
// Returns the error string.
/*--cef()--*/
virtual std::wstring GetError() =0;
virtual CefString GetError() =0;
// The below methods retrieve data for the node at the current cursor
@ -1301,32 +1301,32 @@ public:
// Returns the local name. See
// http://www.w3.org/TR/REC-xml-names/#NT-LocalPart for additional details.
/*--cef()--*/
virtual std::wstring GetLocalName() =0;
virtual CefString GetLocalName() =0;
// Returns the namespace prefix. See http://www.w3.org/TR/REC-xml-names/ for
// additional details.
/*--cef()--*/
virtual std::wstring GetPrefix() =0;
virtual CefString GetPrefix() =0;
// Returns the qualified name, equal to (Prefix:)LocalName. See
// http://www.w3.org/TR/REC-xml-names/#ns-qualnames for additional details.
/*--cef()--*/
virtual std::wstring GetQualifiedName() =0;
virtual CefString GetQualifiedName() =0;
// Returns the URI defining the namespace associated with the node. See
// http://www.w3.org/TR/REC-xml-names/ for additional details.
/*--cef()--*/
virtual std::wstring GetNamespaceURI() =0;
virtual CefString GetNamespaceURI() =0;
// Returns the base URI of the node. See http://www.w3.org/TR/xmlbase/ for
// additional details.
/*--cef()--*/
virtual std::wstring GetBaseURI() =0;
virtual CefString GetBaseURI() =0;
// Returns the xml:lang scope within which the node resides. See
// http://www.w3.org/TR/REC-xml/#sec-lang-tag for additional details.
/*--cef()--*/
virtual std::wstring GetXmlLang() =0;
virtual CefString GetXmlLang() =0;
// Returns true if the node represents an empty element. <a/> is considered
// empty but <a></a> is not.
@ -1339,7 +1339,7 @@ public:
// Returns the text value.
/*--cef()--*/
virtual std::wstring GetValue() =0;
virtual CefString GetValue() =0;
// Returns true if the node has attributes.
/*--cef()--*/
@ -1351,25 +1351,25 @@ public:
// Returns the value of the attribute at the specified 0-based index.
/*--cef(capi_name=get_attribute_byindex)--*/
virtual std::wstring GetAttribute(int index) =0;
virtual CefString GetAttribute(int index) =0;
// Returns the value of the attribute with the specified qualified name.
/*--cef(capi_name=get_attribute_byqname)--*/
virtual std::wstring GetAttribute(const std::wstring& qualifiedName) =0;
virtual CefString GetAttribute(const CefString& qualifiedName) =0;
// Returns the value of the attribute with the specified local name and
// namespace URI.
/*--cef(capi_name=get_attribute_bylname)--*/
virtual std::wstring GetAttribute(const std::wstring& localName,
const std::wstring& namespaceURI) =0;
virtual CefString GetAttribute(const CefString& localName,
const CefString& namespaceURI) =0;
// Returns an XML representation of the current node's children.
/*--cef()--*/
virtual std::wstring GetInnerXml() =0;
virtual CefString GetInnerXml() =0;
// Returns an XML representation of the current node including its children.
/*--cef()--*/
virtual std::wstring GetOuterXml() =0;
virtual CefString GetOuterXml() =0;
// Returns the line number for the current node.
/*--cef()--*/
@ -1389,13 +1389,13 @@ public:
// Moves the cursor to the attribute with the specified qualified name.
// Returns true if the cursor position was set successfully.
/*--cef(capi_name=move_to_attribute_byqname)--*/
virtual bool MoveToAttribute(const std::wstring& qualifiedName) =0;
virtual bool MoveToAttribute(const CefString& qualifiedName) =0;
// Moves the cursor to the attribute with the specified local name and
// namespace URI. Returns true if the cursor position was set successfully.
/*--cef(capi_name=move_to_attribute_bylname)--*/
virtual bool MoveToAttribute(const std::wstring& localName,
const std::wstring& namespaceURI) =0;
virtual bool MoveToAttribute(const CefString& localName,
const CefString& namespaceURI) =0;
// Moves the cursor to the first attribute in the current element. Returns
// true if the cursor position was set successfully.
@ -1438,7 +1438,7 @@ public:
// is true then the search will be case sensitive. Returns true if the cursor
// position was set successfully.
/*--cef()--*/
virtual bool MoveToFile(const std::wstring& fileName, bool caseSensitive) =0;
virtual bool MoveToFile(const CefString& fileName, bool caseSensitive) =0;
// Closes the archive. This should be called directly to ensure that cleanup
// occurs on the correct thread.
@ -1450,7 +1450,7 @@ public:
// Returns the name of the file.
/*--cef()--*/
virtual std::wstring GetFileName() =0;
virtual CefString GetFileName() =0;
// Returns the uncompressed size of the file.
/*--cef()--*/
@ -1463,7 +1463,7 @@ public:
// Opens the file for reading of uncompressed data. A read password may
// optionally be specified.
/*--cef()--*/
virtual bool OpenFile(const std::wstring& password) =0;
virtual bool OpenFile(const CefString& password) =0;
// Closes the file.
/*--cef()--*/
@ -1608,14 +1608,10 @@ public:
void Reset()
{
if(cache_path)
cef_string_free(cache_path);
if(user_agent)
cef_string_free(user_agent);
if(product_version)
cef_string_free(product_version);
if(locale)
cef_string_free(locale);
cef_string_clear(&cache_path);
cef_string_clear(&user_agent);
cef_string_clear(&product_version);
cef_string_clear(&locale);
if(extra_plugin_paths)
cef_string_list_free(extra_plugin_paths);
Init();
@ -1641,22 +1637,11 @@ public:
{
multi_threaded_message_loop = r.multi_threaded_message_loop;
if(cache_path)
cef_string_free(cache_path);
cache_path = r.cache_path ? cef_string_alloc(r.cache_path) : NULL;
if(user_agent)
cef_string_free(user_agent);
user_agent = r.user_agent ? cef_string_alloc(r.user_agent) : NULL;
if(product_version)
cef_string_free(product_version);
product_version = r.product_version ?
cef_string_alloc(r.product_version) : NULL;
if(locale)
cef_string_free(locale);
locale = r.locale ? cef_string_alloc(r.locale) : NULL;
cef_string_copy(r.cache_path.str, r.cache_path.length, &cache_path);
cef_string_copy(r.user_agent.str, r.user_agent.length, &user_agent);
cef_string_copy(r.product_version.str, r.product_version.length,
&product_version);
cef_string_copy(r.locale.str, r.locale.length, &locale);
if(extra_plugin_paths)
cef_string_list_free(extra_plugin_paths);
@ -1701,22 +1686,14 @@ public:
void Reset()
{
if(standard_font_family)
cef_string_free(standard_font_family);
if(fixed_font_family)
cef_string_free(fixed_font_family);
if(serif_font_family)
cef_string_free(serif_font_family);
if(sans_serif_font_family)
cef_string_free(sans_serif_font_family);
if(cursive_font_family)
cef_string_free(cursive_font_family);
if(fantasy_font_family)
cef_string_free(fantasy_font_family);
if(default_encoding)
cef_string_free(default_encoding);
if(user_style_sheet_location)
cef_string_free(user_style_sheet_location);
cef_string_clear(&standard_font_family);
cef_string_clear(&fixed_font_family);
cef_string_clear(&serif_font_family);
cef_string_clear(&sans_serif_font_family);
cef_string_clear(&cursive_font_family);
cef_string_clear(&fantasy_font_family);
cef_string_clear(&default_encoding);
cef_string_clear(&user_style_sheet_location);
Init();
}
@ -1740,35 +1717,18 @@ public:
{
drag_drop_disabled = r.drag_drop_disabled;
if(standard_font_family)
cef_string_free(standard_font_family);
standard_font_family = r.standard_font_family ?
cef_string_alloc(r.standard_font_family) : NULL;
if(fixed_font_family)
cef_string_free(fixed_font_family);
fixed_font_family = r.fixed_font_family ?
cef_string_alloc(r.fixed_font_family) : NULL;
if(serif_font_family)
cef_string_free(serif_font_family);
serif_font_family = r.serif_font_family ?
cef_string_alloc(r.serif_font_family) : NULL;
if(sans_serif_font_family)
cef_string_free(sans_serif_font_family);
serif_font_family = r.sans_serif_font_family ?
cef_string_alloc(r.sans_serif_font_family) : NULL;
if(cursive_font_family)
cef_string_free(cursive_font_family);
cursive_font_family = r.cursive_font_family ?
cef_string_alloc(r.cursive_font_family) : NULL;
if(fantasy_font_family)
cef_string_free(fantasy_font_family);
fantasy_font_family = r.fantasy_font_family ?
cef_string_alloc(r.fantasy_font_family) : NULL;
cef_string_copy(r.standard_font_family.str, r.standard_font_family.length,
&standard_font_family);
cef_string_copy(r.fixed_font_family.str, r.fixed_font_family.length,
&fixed_font_family);
cef_string_copy(r.serif_font_family.str, r.serif_font_family.length,
&serif_font_family);
cef_string_copy(r.sans_serif_font_family.str,
r.sans_serif_font_family.length, &sans_serif_font_family);
cef_string_copy(r.cursive_font_family.str, r.cursive_font_family.length,
&cursive_font_family);
cef_string_copy(r.fantasy_font_family.str, r.fantasy_font_family.length,
&fantasy_font_family);
default_font_size = r.default_font_size;
default_fixed_font_size = r.default_fixed_font_size;
@ -1776,10 +1736,8 @@ public:
minimum_logical_font_size = r.minimum_logical_font_size;
remote_fonts_disabled = r.remote_fonts_disabled;
if(default_encoding)
cef_string_free(default_encoding);
default_encoding = r.default_encoding ?
cef_string_alloc(r.default_encoding) : NULL;
cef_string_copy(r.default_encoding.str, r.default_encoding.length,
&default_encoding);
encoding_detector_enabled = r.encoding_detector_enabled;
javascript_disabled = r.javascript_disabled;
@ -1805,10 +1763,8 @@ public:
hyperlink_auditing_disabled = r.hyperlink_auditing_disabled;
user_style_sheet_enabled = r.user_style_sheet_enabled;
if(user_style_sheet_location)
cef_string_free(user_style_sheet_location);
user_style_sheet_location = r.user_style_sheet_location ?
cef_string_alloc(r.user_style_sheet_location) : NULL;
cef_string_copy(r.user_style_sheet_location.str,
r.user_style_sheet_location.length, &user_style_sheet_location);
author_and_user_styles_disabled = r.author_and_user_styles_disabled;
local_storage_disabled = r.local_storage_disabled;

View File

@ -118,15 +118,16 @@ CEF_EXPORT void cef_do_message_loop_work();
// // Call another function.
// example.test.increment();
//
CEF_EXPORT int cef_register_extension(const wchar_t* extension_name,
const wchar_t* javascript_code, struct _cef_v8handler_t* handler);
CEF_EXPORT int cef_register_extension(const cef_string_t* extension_name,
const cef_string_t* javascript_code, struct _cef_v8handler_t* handler);
// Register a custom scheme handler factory for the specified |scheme_name| and
// |host_name|. All URLs beginning with scheme_name://host_name/ can be handled
// by cef_scheme_handler_t instances returned by the factory. Specify an NULL
// |host_name| value to match all host names.
CEF_EXPORT int cef_register_scheme(const wchar_t* scheme_name,
const wchar_t* host_name, struct _cef_scheme_handler_factory_t* factory);
CEF_EXPORT int cef_register_scheme(const cef_string_t* scheme_name,
const cef_string_t* host_name,
struct _cef_scheme_handler_factory_t* factory);
// CEF maintains multiple internal threads that are used for handling different
// types of tasks. The UI thread creates the browser window and is used for all
@ -236,7 +237,7 @@ typedef struct _cef_browser_t
// Returns the frame with the specified name, or NULL if not found.
struct _cef_frame_t* (CEF_CALLBACK *get_frame)(struct _cef_browser_t* self,
const wchar_t* name);
const cef_string_t* name);
// Returns the names of all existing frames.
void (CEF_CALLBACK *get_frame_names)(struct _cef_browser_t* self,
@ -248,7 +249,8 @@ typedef struct _cef_browser_t
// be case-sensitive. |findNext| indicates whether this is the first request
// or a follow-up.
void (CEF_CALLBACK *find)(struct _cef_browser_t* self, int identifier,
const wchar_t* searchText, int forward, int matchCase, int findNext);
const cef_string_t* searchText, int forward, int matchCase,
int findNext);
// Cancel all searches that are currently going on.
void (CEF_CALLBACK *stop_finding)(struct _cef_browser_t* self,
@ -262,14 +264,14 @@ typedef struct _cef_browser_t
// be created on the UI thread. The |popup| parameter should be true (1) if the
// new window is a popup window. This function call will not block.
CEF_EXPORT int cef_browser_create(cef_window_info_t* windowInfo, int popup,
struct _cef_handler_t* handler, const wchar_t* url);
struct _cef_handler_t* handler, const cef_string_t* url);
// Create a new browser window using the window parameters specified by
// |windowInfo|. The |popup| parameter should be true (1) if the new window is a
// popup window. This function call will block and can only be used if the
// |multi_threaded_message_loop| parameter to cef_initialize() is false (0).
CEF_EXPORT cef_browser_t* cef_browser_create_sync(cef_window_info_t* windowInfo,
int popup, struct _cef_handler_t* handler, const wchar_t* url);
int popup, struct _cef_handler_t* handler, const cef_string_t* url);
// Structure used to represent a frame in the browser window. All functions
@ -309,27 +311,28 @@ typedef struct _cef_frame_t
void (CEF_CALLBACK *view_source)(struct _cef_frame_t* self);
// Returns this frame's HTML source as a string.
// The resulting string must be freed by calling cef_string_free().
cef_string_t (CEF_CALLBACK *get_source)(struct _cef_frame_t* self);
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_source)(struct _cef_frame_t* self);
// Returns this frame's display text as a string.
// The resulting string must be freed by calling cef_string_free().
cef_string_t (CEF_CALLBACK *get_text)(struct _cef_frame_t* self);
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_text)(struct _cef_frame_t* self);
// Load the request represented by the |request| object.
void (CEF_CALLBACK *load_request)(struct _cef_frame_t* self,
struct _cef_request_t* request);
// Load the specified |url|.
void (CEF_CALLBACK *load_url)(struct _cef_frame_t* self, const wchar_t* url);
void (CEF_CALLBACK *load_url)(struct _cef_frame_t* self,
const cef_string_t* url);
// Load the contents of |string| with the optional dummy target |url|.
void (CEF_CALLBACK *load_string)(struct _cef_frame_t* self,
const wchar_t* string, const wchar_t* url);
const cef_string_t* string, const cef_string_t* url);
// Load the contents of |stream| with the optional dummy target |url|.
void (CEF_CALLBACK *load_stream)(struct _cef_frame_t* self,
struct _cef_stream_reader_t* stream, const wchar_t* url);
struct _cef_stream_reader_t* stream, const cef_string_t* url);
// Execute a string of JavaScript code in this frame. The |script_url|
// parameter is the URL where the script in question can be found, if any. The
@ -337,7 +340,8 @@ typedef struct _cef_frame_t
// error. The |start_line| parameter is the base line number to use for error
// reporting.
void (CEF_CALLBACK *execute_java_script)(struct _cef_frame_t* self,
const wchar_t* jsCode, const wchar_t* scriptUrl, int startLine);
const cef_string_t* jsCode, const cef_string_t* scriptUrl,
int startLine);
// Returns true (1) if this is the main frame.
int (CEF_CALLBACK *is_main)(struct _cef_frame_t* self);
@ -346,12 +350,12 @@ typedef struct _cef_frame_t
int (CEF_CALLBACK *is_focused)(struct _cef_frame_t* self);
// Returns this frame's name.
// The resulting string must be freed by calling cef_string_free().
cef_string_t (CEF_CALLBACK *get_name)(struct _cef_frame_t* self);
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_name)(struct _cef_frame_t* self);
// Return the URL currently loaded in this frame.
// The resulting string must be freed by calling cef_string_free().
cef_string_t (CEF_CALLBACK *get_url)(struct _cef_frame_t* self);
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_url)(struct _cef_frame_t* self);
} cef_frame_t;
@ -390,13 +394,13 @@ typedef struct _cef_handler_t
// currently ignored.
enum cef_retval_t (CEF_CALLBACK *handle_address_change)(
struct _cef_handler_t* self, struct _cef_browser_t* browser,
struct _cef_frame_t* frame, const wchar_t* url);
struct _cef_frame_t* frame, const cef_string_t* url);
// Event called when the page title changes. The return value is currently
// ignored.
enum cef_retval_t (CEF_CALLBACK *handle_title_change)(
struct _cef_handler_t* self, struct _cef_browser_t* browser,
const wchar_t* title);
const cef_string_t* title);
// Event called before browser navigation. The client has an opportunity to
// modify the |request| object if desired. Return RV_HANDLED to cancel
@ -428,7 +432,7 @@ typedef struct _cef_handler_t
enum cef_retval_t (CEF_CALLBACK *handle_load_error)(
struct _cef_handler_t* self, struct _cef_browser_t* browser,
struct _cef_frame_t* frame, enum cef_handler_errorcode_t errorCode,
const wchar_t* failedUrl, cef_string_t* errorText);
const cef_string_t* failedUrl, cef_string_t* errorText);
// Event called before a resource is loaded. To allow the resource to load
// normally return RV_CONTINUE. To redirect the resource to a new url populate
@ -453,8 +457,8 @@ typedef struct _cef_handler_t
// RV_HANDLED to cancel the file download.
enum cef_retval_t (CEF_CALLBACK *handle_download_response)(
struct _cef_handler_t* self, struct _cef_browser_t* browser,
const wchar_t* mimeType, const wchar_t* fileName, int64 contentLength,
struct _cef_download_handler_t** handler);
const cef_string_t* mimeType, const cef_string_t* fileName,
int64 contentLength, struct _cef_download_handler_t** handler);
// Event called before a context menu is displayed. To cancel display of the
// default context menu return RV_HANDLED.
@ -498,23 +502,23 @@ typedef struct _cef_handler_t
enum cef_retval_t (CEF_CALLBACK *handle_print_header_footer)(
struct _cef_handler_t* self, struct _cef_browser_t* browser,
struct _cef_frame_t* frame, struct _cef_print_info_t* printInfo,
const wchar_t* url, const wchar_t* title, int currentPage, int maxPages,
cef_string_t* topLeft, cef_string_t* topCenter, cef_string_t* topRight,
cef_string_t* bottomLeft, cef_string_t* bottomCenter,
cef_string_t* bottomRight);
const cef_string_t* url, const cef_string_t* title, int currentPage,
int maxPages, cef_string_t* topLeft, cef_string_t* topCenter,
cef_string_t* topRight, cef_string_t* bottomLeft,
cef_string_t* bottomCenter, cef_string_t* bottomRight);
// Run a JS alert message. Return RV_CONTINUE to display the default alert or
// RV_HANDLED if you displayed a custom alert.
enum cef_retval_t (CEF_CALLBACK *handle_jsalert)(struct _cef_handler_t* self,
struct _cef_browser_t* browser, struct _cef_frame_t* frame,
const wchar_t* message);
const cef_string_t* message);
// Run a JS confirm request. Return RV_CONTINUE to display the default alert
// or RV_HANDLED if you displayed a custom alert. If you handled the alert
// set |retval| to true (1) if the user accepted the confirmation.
enum cef_retval_t (CEF_CALLBACK *handle_jsconfirm)(
struct _cef_handler_t* self, struct _cef_browser_t* browser,
struct _cef_frame_t* frame, const wchar_t* message, int* retval);
struct _cef_frame_t* frame, const cef_string_t* message, int* retval);
// Run a JS prompt request. Return RV_CONTINUE to display the default prompt
// or RV_HANDLED if you displayed a custom prompt. If you handled the prompt
@ -522,8 +526,8 @@ typedef struct _cef_handler_t
// |result| to the resulting value.
enum cef_retval_t (CEF_CALLBACK *handle_jsprompt)(struct _cef_handler_t* self,
struct _cef_browser_t* browser, struct _cef_frame_t* frame,
const wchar_t* message, const wchar_t* defaultValue, int* retval,
cef_string_t* result);
const cef_string_t* message, const cef_string_t* defaultValue,
int* retval, cef_string_t* result);
// Event called for adding values to a frame's JavaScript 'window' object. The
// return value is currently ignored.
@ -576,7 +580,7 @@ typedef struct _cef_handler_t
// from being output to the console.
enum cef_retval_t (CEF_CALLBACK *handle_console_message)(
struct _cef_handler_t* self, struct _cef_browser_t* browser,
const wchar_t* message, const wchar_t* source, int line);
const cef_string_t* message, const cef_string_t* source, int line);
// Called to report find results returned by cef_browser_t::find().
// |identifer| is the identifier passed to cef_browser_t::find(), |count| is
@ -600,16 +604,17 @@ typedef struct _cef_request_t
cef_base_t base;
// Fully qualified URL to load.
// The resulting string must be freed by calling cef_string_free().
cef_string_t (CEF_CALLBACK *get_url)(struct _cef_request_t* self);
void (CEF_CALLBACK *set_url)(struct _cef_request_t* self, const wchar_t* url);
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_url)(struct _cef_request_t* self);
void (CEF_CALLBACK *set_url)(struct _cef_request_t* self,
const cef_string_t* url);
// Optional request function type, defaulting to POST if post data is provided
// and GET otherwise.
// The resulting string must be freed by calling cef_string_free().
cef_string_t (CEF_CALLBACK *get_method)(struct _cef_request_t* self);
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_method)(struct _cef_request_t* self);
void (CEF_CALLBACK *set_method)(struct _cef_request_t* self,
const wchar_t* method);
const cef_string_t* method);
// Optional post data.
struct _cef_post_data_t* (CEF_CALLBACK *get_post_data)(
@ -624,8 +629,8 @@ typedef struct _cef_request_t
cef_string_map_t headerMap);
// Set all values at one time.
void (CEF_CALLBACK *set)(struct _cef_request_t* self, const wchar_t* url,
const wchar_t* method, struct _cef_post_data_t* postData,
void (CEF_CALLBACK *set)(struct _cef_request_t* self, const cef_string_t* url,
const cef_string_t* method, struct _cef_post_data_t* postData,
cef_string_map_t headerMap);
} cef_request_t;
@ -678,7 +683,7 @@ typedef struct _cef_post_data_element_t
// The post data element will represent a file.
void (CEF_CALLBACK *set_to_file)(struct _cef_post_data_element_t* self,
const wchar_t* fileName);
const cef_string_t* fileName);
// The post data element will represent bytes. The bytes passed in will be
// copied.
@ -690,8 +695,9 @@ typedef struct _cef_post_data_element_t
struct _cef_post_data_element_t* self);
// Return the file name.
// The resulting string must be freed by calling cef_string_free().
cef_string_t (CEF_CALLBACK *get_file)(struct _cef_post_data_element_t* self);
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_file)(
struct _cef_post_data_element_t* self);
// Return the number of bytes.
size_t (CEF_CALLBACK *get_bytes_count)(struct _cef_post_data_element_t* self);
@ -758,7 +764,7 @@ typedef struct _cef_stream_reader_t
// Create a new cef_stream_reader_t object.
CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_file(
const wchar_t* fileName);
const cef_string_t* fileName);
CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_data(void* data,
size_t size);
CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_handler(
@ -815,7 +821,7 @@ typedef struct _cef_stream_writer_t
// Create a new cef_stream_writer_t object.
CEF_EXPORT cef_stream_writer_t* cef_stream_writer_create_for_file(
const wchar_t* fileName);
const cef_string_t* fileName);
CEF_EXPORT cef_stream_writer_t* cef_stream_writer_create_for_handler(
cef_write_handler_t* handler);
@ -829,9 +835,9 @@ typedef struct _cef_v8handler_t
// Execute with the specified argument list and return value. Return true (1)
// if the function was handled.
int (CEF_CALLBACK *execute)(struct _cef_v8handler_t* self,
const wchar_t* name, struct _cef_v8value_t* object, size_t argumentCount,
struct _cef_v8value_t* const* arguments, struct _cef_v8value_t** retval,
cef_string_t* exception);
const cef_string_t* name, struct _cef_v8value_t* object,
size_t argumentCount, struct _cef_v8value_t* const* arguments,
struct _cef_v8value_t** retval, cef_string_t* exception);
} cef_v8handler_t;
@ -858,8 +864,9 @@ typedef struct _cef_v8value_t
int (CEF_CALLBACK *get_bool_value)(struct _cef_v8value_t* self);
int (CEF_CALLBACK *get_int_value)(struct _cef_v8value_t* self);
double (CEF_CALLBACK *get_double_value)(struct _cef_v8value_t* self);
// The resulting string must be freed by calling cef_string_free().
cef_string_t (CEF_CALLBACK *get_string_value)(struct _cef_v8value_t* self);
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_string_value)(
struct _cef_v8value_t* self);
// OBJECT METHODS - These functions are only available on objects. Arrays and
@ -869,24 +876,24 @@ typedef struct _cef_v8value_t
// Returns true (1) if the object has a value with the specified identifier.
int (CEF_CALLBACK *has_value_bykey)(struct _cef_v8value_t* self,
const wchar_t* key);
const cef_string_t* key);
int (CEF_CALLBACK *has_value_byindex)(struct _cef_v8value_t* self, int index);
// Delete the value with the specified identifier.
int (CEF_CALLBACK *delete_value_bykey)(struct _cef_v8value_t* self,
const wchar_t* key);
const cef_string_t* key);
int (CEF_CALLBACK *delete_value_byindex)(struct _cef_v8value_t* self,
int index);
// Returns the value with the specified identifier.
struct _cef_v8value_t* (CEF_CALLBACK *get_value_bykey)(
struct _cef_v8value_t* self, const wchar_t* key);
struct _cef_v8value_t* self, const cef_string_t* key);
struct _cef_v8value_t* (CEF_CALLBACK *get_value_byindex)(
struct _cef_v8value_t* self, int index);
// Associate value with the specified identifier.
int (CEF_CALLBACK *set_value_bykey)(struct _cef_v8value_t* self,
const wchar_t* key, struct _cef_v8value_t* value);
const cef_string_t* key, struct _cef_v8value_t* value);
int (CEF_CALLBACK *set_value_byindex)(struct _cef_v8value_t* self, int index,
struct _cef_v8value_t* value);
@ -909,8 +916,9 @@ typedef struct _cef_v8value_t
// FUNCTION METHODS - These functions are only available on functions.
// Returns the function name.
// The resulting string must be freed by calling cef_string_free().
cef_string_t (CEF_CALLBACK *get_function_name)(struct _cef_v8value_t* self);
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_function_name)(
struct _cef_v8value_t* self);
// Returns the function handler or NULL if not a CEF-created function.
struct _cef_v8handler_t* (CEF_CALLBACK *get_function_handler)(
@ -934,10 +942,10 @@ CEF_EXPORT cef_v8value_t* cef_v8value_create_null();
CEF_EXPORT cef_v8value_t* cef_v8value_create_bool(int value);
CEF_EXPORT cef_v8value_t* cef_v8value_create_int(int value);
CEF_EXPORT cef_v8value_t* cef_v8value_create_double(double value);
CEF_EXPORT cef_v8value_t* cef_v8value_create_string(const wchar_t* value);
CEF_EXPORT cef_v8value_t* cef_v8value_create_string(const cef_string_t* value);
CEF_EXPORT cef_v8value_t* cef_v8value_create_object(cef_base_t* user_data);
CEF_EXPORT cef_v8value_t* cef_v8value_create_array();
CEF_EXPORT cef_v8value_t* cef_v8value_create_function(const wchar_t* name,
CEF_EXPORT cef_v8value_t* cef_v8value_create_function(const cef_string_t* name,
cef_v8handler_t* handler);
@ -1022,8 +1030,9 @@ typedef struct _cef_xml_reader_t
int (CEF_CALLBACK *has_error)(struct _cef_xml_reader_t* self);
// Returns the error string.
// The resulting string must be freed by calling cef_string_free().
cef_string_t (CEF_CALLBACK *get_error)(struct _cef_xml_reader_t* self);
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_error)(
struct _cef_xml_reader_t* self);
// The below functions retrieve data for the node at the current cursor
@ -1038,35 +1047,39 @@ typedef struct _cef_xml_reader_t
// Returns the local name. See http://www.w3.org/TR/REC-xml-names/#NT-
// LocalPart for additional details.
// The resulting string must be freed by calling cef_string_free().
cef_string_t (CEF_CALLBACK *get_local_name)(struct _cef_xml_reader_t* self);
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_local_name)(
struct _cef_xml_reader_t* self);
// Returns the namespace prefix. See http://www.w3.org/TR/REC-xml-names/ for
// additional details.
// The resulting string must be freed by calling cef_string_free().
cef_string_t (CEF_CALLBACK *get_prefix)(struct _cef_xml_reader_t* self);
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_prefix)(
struct _cef_xml_reader_t* self);
// Returns the qualified name, equal to (Prefix:)LocalName. See
// http://www.w3.org/TR/REC-xml-names/#ns-qualnames for additional details.
// The resulting string must be freed by calling cef_string_free().
cef_string_t (CEF_CALLBACK *get_qualified_name)(
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_qualified_name)(
struct _cef_xml_reader_t* self);
// Returns the URI defining the namespace associated with the node. See
// http://www.w3.org/TR/REC-xml-names/ for additional details.
// The resulting string must be freed by calling cef_string_free().
cef_string_t (CEF_CALLBACK *get_namespace_uri)(
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_namespace_uri)(
struct _cef_xml_reader_t* self);
// Returns the base URI of the node. See http://www.w3.org/TR/xmlbase/ for
// additional details.
// The resulting string must be freed by calling cef_string_free().
cef_string_t (CEF_CALLBACK *get_base_uri)(struct _cef_xml_reader_t* self);
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_base_uri)(
struct _cef_xml_reader_t* self);
// Returns the xml:lang scope within which the node resides. See
// http://www.w3.org/TR/REC-xml/#sec-lang-tag for additional details.
// The resulting string must be freed by calling cef_string_free().
cef_string_t (CEF_CALLBACK *get_xml_lang)(struct _cef_xml_reader_t* self);
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_xml_lang)(
struct _cef_xml_reader_t* self);
// Returns true (1) if the node represents an NULL element. <a/> is considered
// NULL but <a></a> is not.
@ -1076,8 +1089,9 @@ typedef struct _cef_xml_reader_t
int (CEF_CALLBACK *has_value)(struct _cef_xml_reader_t* self);
// Returns the text value.
// The resulting string must be freed by calling cef_string_free().
cef_string_t (CEF_CALLBACK *get_value)(struct _cef_xml_reader_t* self);
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_value)(
struct _cef_xml_reader_t* self);
// Returns true (1) if the node has attributes.
int (CEF_CALLBACK *has_attributes)(struct _cef_xml_reader_t* self);
@ -1086,29 +1100,31 @@ typedef struct _cef_xml_reader_t
size_t (CEF_CALLBACK *get_attribute_count)(struct _cef_xml_reader_t* self);
// Returns the value of the attribute at the specified 0-based index.
// The resulting string must be freed by calling cef_string_free().
cef_string_t (CEF_CALLBACK *get_attribute_byindex)(
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_attribute_byindex)(
struct _cef_xml_reader_t* self, int index);
// Returns the value of the attribute with the specified qualified name.
// The resulting string must be freed by calling cef_string_free().
cef_string_t (CEF_CALLBACK *get_attribute_byqname)(
struct _cef_xml_reader_t* self, const wchar_t* qualifiedName);
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_attribute_byqname)(
struct _cef_xml_reader_t* self, const cef_string_t* qualifiedName);
// Returns the value of the attribute with the specified local name and
// namespace URI.
// The resulting string must be freed by calling cef_string_free().
cef_string_t (CEF_CALLBACK *get_attribute_bylname)(
struct _cef_xml_reader_t* self, const wchar_t* localName,
const wchar_t* namespaceURI);
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_attribute_bylname)(
struct _cef_xml_reader_t* self, const cef_string_t* localName,
const cef_string_t* namespaceURI);
// Returns an XML representation of the current node's children.
// The resulting string must be freed by calling cef_string_free().
cef_string_t (CEF_CALLBACK *get_inner_xml)(struct _cef_xml_reader_t* self);
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_inner_xml)(
struct _cef_xml_reader_t* self);
// Returns an XML representation of the current node including its children.
// The resulting string must be freed by calling cef_string_free().
cef_string_t (CEF_CALLBACK *get_outer_xml)(struct _cef_xml_reader_t* self);
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_outer_xml)(
struct _cef_xml_reader_t* self);
// Returns the line number for the current node.
int (CEF_CALLBACK *get_line_number)(struct _cef_xml_reader_t* self);
@ -1127,13 +1143,13 @@ typedef struct _cef_xml_reader_t
// Moves the cursor to the attribute with the specified qualified name.
// Returns true (1) if the cursor position was set successfully.
int (CEF_CALLBACK *move_to_attribute_byqname)(struct _cef_xml_reader_t* self,
const wchar_t* qualifiedName);
const cef_string_t* qualifiedName);
// Moves the cursor to the attribute with the specified local name and
// namespace URI. Returns true (1) if the cursor position was set
// successfully.
int (CEF_CALLBACK *move_to_attribute_bylname)(struct _cef_xml_reader_t* self,
const wchar_t* localName, const wchar_t* namespaceURI);
const cef_string_t* localName, const cef_string_t* namespaceURI);
// Moves the cursor to the first attribute in the current element. Returns
// true (1) if the cursor position was set successfully.
@ -1153,7 +1169,7 @@ typedef struct _cef_xml_reader_t
// Create a new cef_xml_reader_t object. The returned object's functions can
// only be called from the thread that created the object.
CEF_EXPORT cef_xml_reader_t* cef_xml_reader_create(cef_stream_reader_t* stream,
enum cef_xml_encoding_type_t encodingType, const wchar_t* URI);
enum cef_xml_encoding_type_t encodingType, const cef_string_t* URI);
// Structure that supports the reading of zip archives via the zlib unzip API.
@ -1174,7 +1190,7 @@ typedef struct _cef_zip_reader_t
// is true (1) then the search will be case sensitive. Returns true (1) if the
// cursor position was set successfully.
int (CEF_CALLBACK *move_to_file)(struct _cef_zip_reader_t* self,
const wchar_t* fileName, int caseSensitive);
const cef_string_t* fileName, int caseSensitive);
// Closes the archive. This should be called directly to ensure that cleanup
// occurs on the correct thread.
@ -1184,8 +1200,9 @@ typedef struct _cef_zip_reader_t
// The below functions act on the file at the current cursor position.
// Returns the name of the file.
// The resulting string must be freed by calling cef_string_free().
cef_string_t (CEF_CALLBACK *get_file_name)(struct _cef_zip_reader_t* self);
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_file_name)(
struct _cef_zip_reader_t* self);
// Returns the uncompressed size of the file.
long (CEF_CALLBACK *get_file_size)(struct _cef_zip_reader_t* self);
@ -1196,7 +1213,7 @@ typedef struct _cef_zip_reader_t
// Opens the file for reading of uncompressed data. A read password may
// optionally be specified.
int (CEF_CALLBACK *open_file)(struct _cef_zip_reader_t* self,
const wchar_t* password);
const cef_string_t* password);
// Closes the file.
int (CEF_CALLBACK *close_file)(struct _cef_zip_reader_t* self);

View File

@ -99,8 +99,7 @@ public:
void Reset()
{
if(m_windowName)
cef_string_free(m_windowName);
cef_string_clear(&m_windowName);
Init();
}
@ -121,12 +120,7 @@ public:
}
CefWindowInfo& operator=(const cef_window_info_t& r)
{
if(m_windowName)
cef_string_free(m_windowName);
if(r.m_windowName)
m_windowName = cef_string_alloc(r.m_windowName);
else
m_windowName = NULL;
cef_string_copy(r.m_windowName.str, r.m_windowName.length, &m_windowName);
m_x = r.m_x;
m_y = r.m_y;
m_nWidth = r.m_nWidth;
@ -137,11 +131,7 @@ public:
protected:
void Init()
{
m_windowName = NULL;
m_x = 0;
m_y = 0;
m_nWidth = 0;
m_nHeight = 0;
memset(static_cast<cef_window_info_t*>(this), 0, sizeof(cef_window_info_t));
}
};
@ -168,11 +158,6 @@ public:
*this = r;
}
void Init()
{
m_Scale = 0;
}
CefPrintInfo& operator=(const CefPrintInfo& r)
{
return operator=(static_cast<const cef_print_info_t&>(r));
@ -182,6 +167,12 @@ public:
m_Scale = r.m_Scale;
return *this;
}
protected:
void Init()
{
m_Scale = 0;
}
};
// Window handle.

View File

@ -102,8 +102,7 @@ public:
void Reset()
{
if(m_windowName)
cef_string_free(m_windowName);
cef_string_clear(&m_windowName);
Init();
}
@ -136,12 +135,7 @@ public:
{
m_View = r.m_View;
m_ParentView = r.m_ParentView;
if(m_windowName)
cef_string_free(m_windowName);
if(r.m_windowName)
m_windowName = cef_string_alloc(r.m_windowName);
else
m_windowName = NULL;
cef_string_copy(r.m_windowName.str, r.m_windowName.length, &m_windowName);
m_x = r.m_x;
m_y = r.m_y;
m_nWidth = r.m_nWidth;
@ -152,13 +146,7 @@ public:
protected:
void Init()
{
m_View = NULL;
m_ParentView = NULL;
m_windowName = NULL;
m_x = 0;
m_y = 0;
m_nWidth = 0;
m_nHeight = 0;
memset(static_cast<cef_window_info_t*>(this), 0, sizeof(cef_window_info_t));
}
};
@ -185,11 +173,6 @@ public:
*this = r;
}
void Init()
{
m_Scale = 0;
}
CefPrintInfo& operator=(const CefPrintInfo& r)
{
return operator=(static_cast<const cef_print_info_t&>(r));
@ -199,6 +182,12 @@ public:
m_Scale = r.m_Scale;
return *this;
}
protected:
void Init()
{
m_Scale = 0;
}
};
#endif // defined(__APPLE__)

View File

@ -31,7 +31,7 @@
#ifndef _CEF_PLUGIN_H
#define _CEF_PLUGIN_H
#include <string>
#include "cef_string.h"
#include <vector>
#include "third_party/npapi/bindings/npapi.h"
#include "third_party/npapi/bindings/nphostapi.h"
@ -46,29 +46,29 @@
// This structure describes a mime type entry for a plugin.
struct CefPluginMimeType {
// The actual mime type.
std::wstring mime_type;
CefString mime_type;
// A list of all the file extensions for this mime type.
std::vector<std::wstring> file_extensions;
std::vector<CefString> file_extensions;
// Description of the mime type.
std::wstring description;
CefString description;
};
// This structure provides attribute information and entry point functions for
// a plugin.
struct CefPluginInfo {
// The unique name that identifies the plugin.
std::wstring unique_name;
CefString unique_name;
// The friendly display name of the plugin.
std::wstring display_name;
CefString display_name;
// The version string of the plugin.
std::wstring version;
CefString version;
// A description of the plugin.
std::wstring description;
CefString description;
// A list of all the mime types that this plugin supports.
std::vector<CefPluginMimeType> mime_types;

View File

@ -50,28 +50,28 @@ extern "C" {
// a plugin.
typedef struct _cef_plugin_info_t {
// The unique name that identifies the plugin.
const wchar_t* unique_name;
cef_string_t unique_name;
// The friendly display name of the plugin.
const wchar_t* display_name;
cef_string_t display_name;
// The version string of the plugin.
const wchar_t* version;
cef_string_t version;
// A description of the plugin.
const wchar_t* description;
cef_string_t description;
// A pipe (|) delimited list of mime type values that the plugin supports.
const wchar_t* mime_types;
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 (,).
const wchar_t* file_extensions;
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.
const wchar_t* type_descriptions;
cef_string_t type_descriptions;
// Entry point function pointers.
NP_GetEntryPointsFunc np_getentrypoints;

View File

@ -1,4 +1,4 @@
// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved.
// 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
@ -30,57 +30,83 @@
#ifndef _CEF_STRING_H
#define _CEF_STRING_H
// 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 "cef_string_types.h"
#ifdef __cplusplus
extern "C" {
#include "cef_string_wrappers.h"
#if defined(CEF_STRING_TYPE_UTF8)
typedef CefStringUTF8 CefString;
#elif defined(CEF_STRING_TYPE_UTF16)
typedef CefStringUTF16 CefString;
#elif defined(CEF_STRING_TYPE_WIDE)
typedef CefStringWide CefString;
#endif
#endif // __cplusplus
#include "cef_export.h"
#include <wchar.h>
// CEF strings are NUL-terminated wide character strings prefixed with a size
// value, similar to the Microsoft BSTR type. Use the below API functions for
// allocating, managing and freeing CEF strings.
typedef wchar_t* cef_string_t;
// Return the wide character length of the CEF string as allocated by
// cef_string_alloc_len(). The returned value does not include the NUL
// terminating character. This length may differ from the string length
// as returned by wcslen().
CEF_EXPORT size_t cef_string_length(cef_string_t str);
// Allocate and return a new CEF string that is a copy of |str|. If |str| is
// NULL or if allocation fails NULL will be returned. If |str| is of length
// 0 a valid empty CEF string will be returned.
CEF_EXPORT cef_string_t cef_string_alloc(const wchar_t* str);
// Allocate and return a new CEF string that is a copy of |str|. |len| is the
// wide character length of the new CEF string not including the NUL
// terminating character. |str| will be copied without checking for a NUL
// terminating character. If |str| is NULL or if allocation fails NULL will
// be returned. If |str| is of length 0 a valid empty CEF string will be
// returned.
CEF_EXPORT cef_string_t cef_string_alloc_length(const wchar_t* str,
size_t len);
// Reallocate an existing CEF string. The contents of |oldstr| will be
// replaced with the contents of |newstr|; |newstr| may not be NULL. Returns 1
// on success and 0 on failure.
CEF_EXPORT int cef_string_realloc(cef_string_t* oldstr, const wchar_t* newstr);
// Reallocate an existing CEF string. If |newstr| is NULL the contents of
// |oldstr| will remain unchanged; otherwise, they will be replaced with the
// contents of |newstr|. |len| is the new wide character length of the string
// not including the NUL terminating character. Returns 1 on success and 0
// on failure.
CEF_EXPORT int cef_string_realloc_length(cef_string_t* oldstr,
const wchar_t* newstr,
size_t len);
// Free a CEF string. If |str| is NULL this function does nothing.
CEF_EXPORT void cef_string_free(cef_string_t str);
#ifdef __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_t 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_STRING_H

View File

@ -30,14 +30,13 @@
#ifndef _CEF_STRING_LIST_H
#define _CEF_STRING_LIST_H
#include "cef_export.h"
#include "cef_string.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "cef_export.h"
#include "cef_string.h"
#include <wchar.h>
// CEF string maps are a set of key/value string pairs.
typedef void* cef_string_list_t;
@ -47,11 +46,14 @@ 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);
// Return the value at the specified zero-based string list index.
CEF_EXPORT cef_string_t cef_string_list_value(cef_string_list_t list, int index);
// 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 key/value pair at the end of the string list.
CEF_EXPORT void cef_string_list_append(cef_string_list_t list, const wchar_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);

View File

@ -30,14 +30,13 @@
#ifndef _CEF_STRING_MAP_H
#define _CEF_STRING_MAP_H
#include "cef_export.h"
#include "cef_string.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "cef_export.h"
#include "cef_string.h"
#include <wchar.h>
// CEF string maps are a set of key/value string pairs.
typedef void* cef_string_map_t;
@ -48,18 +47,22 @@ CEF_EXPORT cef_string_map_t cef_string_map_alloc();
CEF_EXPORT int cef_string_map_size(cef_string_map_t map);
// Return the value assigned to the specified key.
CEF_EXPORT cef_string_t cef_string_map_find(cef_string_map_t map,
const wchar_t* 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 cef_string_t cef_string_map_key(cef_string_map_t map, int 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 cef_string_t cef_string_map_value(cef_string_map_t map, int 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 void cef_string_map_append(cef_string_map_t map, const wchar_t* key,
const wchar_t* value);
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);

View File

@ -31,10 +31,6 @@
#ifndef _CEF_TYPES_H
#define _CEF_TYPES_H
#ifdef __cplusplus
extern "C" {
#endif
#include "cef_string_list.h"
// Bring in platform-specific definitions.
@ -54,6 +50,10 @@ typedef long int64;
typedef long long int64;
#endif
#ifdef __cplusplus
extern "C" {
#endif
// Initialization settings. Specify NULL or 0 to get the recommended default
// values.
typedef struct _cef_settings_t
@ -292,14 +292,14 @@ typedef struct _cef_handler_menuinfo_t
int typeFlags;
int x;
int y;
const wchar_t* linkUrl;
const wchar_t* imageUrl;
const wchar_t* pageUrl;
const wchar_t* frameUrl;
const wchar_t* selectionText;
const wchar_t* misspelledWord;
cef_string_t linkUrl;
cef_string_t imageUrl;
cef_string_t pageUrl;
cef_string_t frameUrl;
cef_string_t selectionText;
cef_string_t misspelledWord;
int editFlags;
const wchar_t* securityInfo;
cef_string_t securityInfo;
} cef_handler_menuinfo_t;
// The cef_handler_menuinfo_t typeFlags value will be a combination of the

View File

@ -31,13 +31,13 @@
#ifndef _CEF_TYPES_LINUX_H
#define _CEF_TYPES_LINUX_H
#if defined(__linux__)
#include "cef_string.h"
#ifdef __cplusplus
extern "C" {
#endif
#if defined(__linux__)
#include "cef_string.h"
// Window handle.
#define cef_window_handle_t void*
@ -58,10 +58,10 @@ typedef struct _cef_print_info_t
double m_Scale;
} cef_print_info_t;
#endif // defined(__linux__)
#ifdef __cplusplus
}
#endif
#endif // defined(__linux__)
#endif // _CEF_TYPES_LINUX_H

View File

@ -31,13 +31,13 @@
#ifndef _CEF_TYPES_MAC_H
#define _CEF_TYPES_MAC_H
#if defined(__APPLE__)
#include "cef_string.h"
#ifdef __cplusplus
extern "C" {
#endif
#if defined(__APPLE__)
#include "cef_string.h"
// Window handle.
#define cef_window_handle_t void*
@ -64,10 +64,10 @@ typedef struct _cef_print_info_t
double m_Scale;
} cef_print_info_t;
#endif // defined(__APPLE__)
#ifdef __cplusplus
}
#endif
#endif // defined(__APPLE__)
#endif // _CEF_TYPES_MAC_H

View File

@ -31,14 +31,14 @@
#ifndef _CEF_TYPES_WIN_H
#define _CEF_TYPES_WIN_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _WIN32
#include <windows.h>
#include "cef_string.h"
#ifdef __cplusplus
extern "C" {
#endif
// Window handle.
#define cef_window_handle_t HWND
@ -68,10 +68,10 @@ typedef struct _cef_print_info_t
double m_Scale;
} cef_print_info_t;
#endif // _WIN32
#ifdef __cplusplus
}
#endif
#endif // _WIN32
#endif // _CEF_TYPES_WIN_H

View File

@ -90,8 +90,7 @@ public:
void Reset()
{
if(m_windowName)
cef_string_free(m_windowName);
cef_string_clear(&m_windowName);
Init();
}
@ -113,12 +112,7 @@ public:
CefWindowInfo& operator=(const cef_window_info_t& r)
{
m_dwExStyle = r.m_dwExStyle;
if(m_windowName)
cef_string_free(m_windowName);
if(r.m_windowName)
m_windowName = cef_string_alloc(r.m_windowName);
else
m_windowName = NULL;
cef_string_copy(r.m_windowName.str, r.m_windowName.length, &m_windowName);
m_dwStyle = r.m_dwStyle;
m_x = r.m_x;
m_y = r.m_y;
@ -141,7 +135,7 @@ public:
m_nHeight = windowRect.bottom - windowRect.top;
}
void SetAsPopup(HWND hWndParent, LPCWSTR windowName)
void SetAsPopup(HWND hWndParent, const CefString& windowName)
{
m_dwStyle = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
m_hWndParent = hWndParent;
@ -150,27 +144,13 @@ public:
m_nWidth = CW_USEDEFAULT;
m_nHeight = CW_USEDEFAULT;
if(m_windowName)
cef_string_free(m_windowName);
if(windowName)
m_windowName = cef_string_alloc(windowName);
else
m_windowName = NULL;
cef_string_copy(windowName.c_str(), windowName.length(), &m_windowName);
}
protected:
void Init()
{
m_dwExStyle = 0;
m_windowName = NULL;
m_dwStyle = 0;
m_x = 0;
m_y = 0;
m_nWidth = 0;
m_nHeight = 0;
m_hWndParent = NULL;
m_hMenu = 0;
m_hWnd = NULL;
memset(static_cast<cef_window_info_t*>(this), 0, sizeof(cef_window_info_t));
}
};

View File

@ -64,18 +64,18 @@ class CefXmlObject : public CefThreadSafeBase<CefBase>
{
public:
typedef std::vector<CefRefPtr<CefXmlObject> > ObjectVector;
typedef std::map<std::wstring, std::wstring > AttributeMap;
typedef std::map<CefString, CefString > AttributeMap;
// Create a new object with the specified name. An object name must always be
// at least one character long.
CefXmlObject(const std::wstring& name);
CefXmlObject(const CefString& name);
virtual ~CefXmlObject();
// Load the contents of the specified XML stream into this object. The
// existing children and attributes, if any, will first be cleared.
bool Load(CefRefPtr<CefStreamReader> stream,
CefXmlReader::EncodingType encodingType,
const std::wstring& URI, std::wstring* loadError);
const CefString& URI, CefString* loadError);
// Set the name, children and attributes of this object to a duplicate of the
// specified object's contents. The existing children and attributes, if any,
@ -98,8 +98,8 @@ public:
// Access the object's name. An object name must always be at least one
// character long.
std::wstring GetName();
bool SetName(const std::wstring& name);
CefString GetName();
bool SetName(const CefString& name);
// Access the object's parent. The parent can be NULL if this object has not
// been added as the child on another object.
@ -109,15 +109,15 @@ public:
// Access the object's value. An object cannot have a value if it also has
// children. Attempting to set the value while children exist will fail.
bool HasValue();
std::wstring GetValue();
bool SetValue(const std::wstring& value);
CefString GetValue();
bool SetValue(const CefString& value);
// Access the object's attributes. Attributes must have unique names.
bool HasAttributes();
size_t GetAttributeCount();
bool HasAttribute(const std::wstring& name);
std::wstring GetAttributeValue(const std::wstring& name);
bool SetAttributeValue(const std::wstring& name, const std::wstring& value);
bool HasAttribute(const CefString& name);
CefString GetAttributeValue(const CefString& name);
bool SetAttributeValue(const CefString& name, const CefString& value);
size_t GetAttributes(AttributeMap& attributes);
void ClearAttributes();
@ -135,17 +135,17 @@ public:
void ClearChildren();
// Find the first child with the specified name.
CefRefPtr<CefXmlObject> FindChild(const std::wstring& name);
CefRefPtr<CefXmlObject> FindChild(const CefString& name);
// Find all children with the specified name.
size_t FindChildren(const std::wstring& name, ObjectVector& children);
size_t FindChildren(const CefString& name, ObjectVector& children);
private:
void SetParent(CefXmlObject* parent);
std::wstring name_;
CefString name_;
CefXmlObject* parent_;
std::wstring value_;
CefString value_;
AttributeMap attributes_;
ObjectVector children_;
};
@ -209,7 +209,7 @@ public:
// Returns a CefStreamReader object for streaming the contents of the file.
virtual CefRefPtr<CefStreamReader> GetStreamReader() =0;
};
typedef std::map<std::wstring, CefRefPtr<File> > FileMap;
typedef std::map<CefString, CefRefPtr<File> > FileMap;
// Create a new object.
CefZipArchive();
@ -228,13 +228,13 @@ public:
size_t GetFileCount();
// Returns true if the specified file exists and has contents.
bool HasFile(const std::wstring& fileName);
bool HasFile(const CefString& fileName);
// Returns the specified file.
CefRefPtr<File> GetFile(const std::wstring& fileName);
CefRefPtr<File> GetFile(const CefString& fileName);
// Removes the specified file.
bool RemoveFile(const std::wstring& fileName);
bool RemoveFile(const CefString& fileName);
// Returns the map of all files.
size_t GetFiles(FileMap& map);

View File

@ -40,11 +40,6 @@ using WebKit::WebString;
using WebKit::WebURL;
using WebKit::WebURLRequest;
using WebKit::WebView;
using webkit_glue::StdStringToWebString;
using webkit_glue::StdWStringToWebString;
using webkit_glue::WebStringToStdString;
using webkit_glue::WebStringToStdWString;
CefBrowserImpl::CefBrowserImpl(const CefWindowInfo& windowInfo,
const CefBrowserSettings& settings, bool popup,
@ -187,19 +182,19 @@ CefRefPtr<CefFrame> CefBrowserImpl::GetFocusedFrame()
return GetWebView() ? GetCefFrame(GetWebView()->focusedFrame()) : NULL;
}
CefRefPtr<CefFrame> CefBrowserImpl::GetFrame(const std::wstring& name)
CefRefPtr<CefFrame> CefBrowserImpl::GetFrame(const CefString& name)
{
WebView* view = GetWebView();
if (!view)
return NULL;
WebFrame* frame = view->findFrameByName(StdWStringToWebString(name));
WebFrame* frame = view->findFrameByName(string16(name));
if(frame)
return GetCefFrame(frame);
return NULL;
}
void CefBrowserImpl::GetFrameNames(std::vector<std::wstring>& names)
void CefBrowserImpl::GetFrameNames(std::vector<CefString>& names)
{
WebView* view = GetWebView();
if (!view)
@ -208,13 +203,15 @@ void CefBrowserImpl::GetFrameNames(std::vector<std::wstring>& names)
WebFrame* main_frame = view->mainFrame();
WebFrame* it = main_frame;
do {
if(it != main_frame)
names.push_back(UTF16ToWideHack(it->name()));
if(it != main_frame) {
string16 str = it->name();
names.push_back(str);
}
it = it->traverseNext(true);
} while (it != main_frame);
}
void CefBrowserImpl::Find(int identifier, const std::wstring& searchText,
void CefBrowserImpl::Find(int identifier, const CefString& searchText,
bool forward, bool matchCase, bool findNext)
{
WebKit::WebFindOptions options;
@ -244,11 +241,11 @@ CefRefPtr<CefFrame> CefBrowserImpl::GetCefFrame(WebFrame* frame)
if(frame == view->mainFrame()) {
// Use or create the single main frame reference.
if(frame_main_ == NULL)
frame_main_ = new CefFrameImpl(this, std::wstring());
frame_main_ = new CefFrameImpl(this, CefString());
cef_frame = frame_main_;
} else {
// Locate or create the appropriate named reference.
std::wstring name = UTF16ToWideHack(frame->name());
CefString name = frame->name();
DCHECK(!name.empty());
FrameMap::const_iterator it = frames_.find(name);
if(it != frames_.end())
@ -264,7 +261,7 @@ CefRefPtr<CefFrame> CefBrowserImpl::GetCefFrame(WebFrame* frame)
return cef_frame;
}
void CefBrowserImpl::RemoveCefFrame(const std::wstring& name)
void CefBrowserImpl::RemoveCefFrame(const CefString& name)
{
Lock();
@ -285,10 +282,10 @@ WebFrame* CefBrowserImpl::GetWebFrame(CefRefPtr<CefFrame> frame)
if (!view)
return NULL;
std::wstring name = frame->GetName();
CefString name = frame->GetName();
if(name.empty())
return view ->mainFrame();
return view ->findFrameByName(StdWStringToWebString(name));
return view ->findFrameByName(string16(name));
}
void CefBrowserImpl::Undo(CefRefPtr<CefFrame> frame)
@ -355,7 +352,7 @@ void CefBrowserImpl::ViewSource(CefRefPtr<CefFrame> frame)
&CefBrowserImpl::UIT_HandleAction, MENU_ID_VIEWSOURCE, frame.get()));
}
std::wstring CefBrowserImpl::GetSource(CefRefPtr<CefFrame> frame)
CefString CefBrowserImpl::GetSource(CefRefPtr<CefFrame> frame)
{
if(!CefThread::CurrentlyOn(CefThread::UI))
{
@ -377,22 +374,19 @@ std::wstring CefBrowserImpl::GetSource(CefRefPtr<CefFrame> frame)
// Wait for the UI thread callback to tell us that the data is available
event.Wait();
return UTF8ToWide(
static_cast<CefBytesWriter*>(stream.get())->GetDataString());
return static_cast<CefBytesWriter*>(stream.get())->GetDataString();
}
else
{
// Retrieve the document string directly
WebKit::WebFrame* web_frame = GetWebFrame(frame);
if(web_frame) {
std::string markup = web_frame->contentAsMarkup().utf8();
return UTF8ToWide(markup);
}
return std::wstring();
if(web_frame)
return web_frame->contentAsMarkup();
return CefString();
}
}
std::wstring CefBrowserImpl::GetText(CefRefPtr<CefFrame> frame)
CefString CefBrowserImpl::GetText(CefRefPtr<CefFrame> frame)
{
if(!CefThread::CurrentlyOn(CefThread::UI))
{
@ -414,8 +408,7 @@ std::wstring CefBrowserImpl::GetText(CefRefPtr<CefFrame> frame)
// Wait for the UI thread callback to tell us that the data is available
event.Wait();
return UTF8ToWide(
static_cast<CefBytesWriter*>(stream.get())->GetDataString());
return static_cast<CefBytesWriter*>(stream.get())->GetDataString();
}
else
{
@ -423,7 +416,7 @@ std::wstring CefBrowserImpl::GetText(CefRefPtr<CefFrame> frame)
WebKit::WebFrame* web_frame = GetWebFrame(frame);
if(web_frame)
return webkit_glue::DumpDocumentText(web_frame);
return std::wstring();
return CefString();
}
}
@ -438,7 +431,7 @@ void CefBrowserImpl::LoadRequest(CefRefPtr<CefFrame> frame,
}
void CefBrowserImpl::LoadURL(CefRefPtr<CefFrame> frame,
const std::wstring& url)
const CefString& url)
{
frame->AddRef();
CefThread::PostTask(CefThread::UI, FROM_HERE, NewRunnableMethod(this,
@ -446,8 +439,8 @@ void CefBrowserImpl::LoadURL(CefRefPtr<CefFrame> frame,
}
void CefBrowserImpl::LoadString(CefRefPtr<CefFrame> frame,
const std::wstring& string,
const std::wstring& url)
const CefString& string,
const CefString& url)
{
frame->AddRef();
CefThread::PostTask(CefThread::UI, FROM_HERE, NewRunnableMethod(this,
@ -456,7 +449,7 @@ void CefBrowserImpl::LoadString(CefRefPtr<CefFrame> frame,
void CefBrowserImpl::LoadStream(CefRefPtr<CefFrame> frame,
CefRefPtr<CefStreamReader> stream,
const std::wstring& url)
const CefString& url)
{
DCHECK(stream.get() != NULL);
frame->AddRef();
@ -467,8 +460,8 @@ void CefBrowserImpl::LoadStream(CefRefPtr<CefFrame> frame,
}
void CefBrowserImpl::ExecuteJavaScript(CefRefPtr<CefFrame> frame,
const std::wstring& jsCode,
const std::wstring& scriptUrl,
const CefString& jsCode,
const CefString& scriptUrl,
int startLine)
{
frame->AddRef();
@ -477,25 +470,23 @@ void CefBrowserImpl::ExecuteJavaScript(CefRefPtr<CefFrame> frame,
startLine));
}
std::wstring CefBrowserImpl::GetURL(CefRefPtr<CefFrame> frame)
CefString CefBrowserImpl::GetURL(CefRefPtr<CefFrame> frame)
{
WebFrame* web_frame = GetWebFrame(frame);
if(web_frame) {
std::string spec = web_frame->url().spec();
return UTF8ToWide(spec);
}
return std::wstring();
if(web_frame)
return web_frame->url().spec();
return CefString();
}
// static
bool CefBrowser::CreateBrowser(CefWindowInfo& windowInfo, bool popup,
CefRefPtr<CefHandler> handler,
const std::wstring& url)
const CefString& url)
{
if(!_Context.get())
return false;
std::wstring newUrl = url;
CefString newUrl = url;
CefBrowserSettings settings(_Context->browser_defaults());
if(handler.get())
@ -517,12 +508,12 @@ bool CefBrowser::CreateBrowser(CefWindowInfo& windowInfo, bool popup,
// static
CefRefPtr<CefBrowser> CefBrowser::CreateBrowserSync(CefWindowInfo& windowInfo,
bool popup, CefRefPtr<CefHandler> handler, const std::wstring& url)
bool popup, CefRefPtr<CefHandler> handler, const CefString& url)
{
if(!_Context.get() || !CefThread::CurrentlyOn(CefThread::UI))
return NULL;
std::wstring newUrl = url;
CefString newUrl = url;
CefRefPtr<CefBrowser> alternateBrowser;
CefBrowserSettings settings(_Context->browser_defaults());
@ -563,17 +554,17 @@ void CefBrowserImpl::UIT_DestroyBrowser()
}
void CefBrowserImpl::UIT_LoadURL(CefFrame* frame,
const std::wstring& url)
const CefString& url)
{
UIT_LoadURLForRequest(frame, url, std::wstring(), WebHTTPBody(),
UIT_LoadURLForRequest(frame, url, CefString(), WebHTTPBody(),
CefRequest::HeaderMap());
}
void CefBrowserImpl::UIT_LoadURLForRequestRef(CefFrame* frame,
CefRequest* request)
{
std::wstring url = request->GetURL();
std::wstring method = request->GetMethod();
CefString url = request->GetURL();
CefString method = request->GetMethod();
CefRequestImpl *impl = static_cast<CefRequestImpl*>(request);
@ -593,8 +584,8 @@ void CefBrowserImpl::UIT_LoadURLForRequestRef(CefFrame* frame,
}
void CefBrowserImpl::UIT_LoadURLForRequest(CefFrame* frame,
const std::wstring& url,
const std::wstring& method,
const CefString& url,
const CefString& method,
const WebKit::WebHTTPBody& upload_data,
const CefRequest::HeaderMap& headers)
{
@ -603,58 +594,61 @@ void CefBrowserImpl::UIT_LoadURLForRequest(CefFrame* frame,
if (url.empty())
return;
GURL gurl(StdWStringToWebString(url));
std::string urlStr(url);
GURL gurl = GURL(urlStr);
if (!gurl.is_valid() && !gurl.has_scheme()) {
// Try to add "http://" at the beginning
std::wstring new_url = std::wstring(L"http://") + url;
gurl = GURL(StdWStringToWebString(new_url));
std::string new_url = std::string("http://") + urlStr;
gurl = GURL(new_url);
if (!gurl.is_valid())
return;
}
nav_controller_->LoadEntry(
new BrowserNavigationEntry(-1, gurl, std::wstring(), frame->GetName(),
new BrowserNavigationEntry(-1, gurl, CefString(), frame->GetName(),
method, upload_data, headers));
frame->Release();
}
void CefBrowserImpl::UIT_LoadHTML(CefFrame* frame,
const std::wstring& html,
const std::wstring& url)
const CefString& html,
const CefString& url)
{
REQUIRE_UIT();
GURL gurl(StdWStringToWebString(url));
std::string urlStr(url);
GURL gurl = GURL(urlStr);
if (!gurl.is_valid() && !gurl.has_scheme()) {
// Try to add "http://" at the beginning
std::wstring new_url = std::wstring(L"http://") + url;
gurl = GURL(StdWStringToWebString(new_url));
std::string new_url = std::string("http://") + urlStr;
gurl = GURL(new_url);
if (!gurl.is_valid())
return;
}
WebFrame* web_frame = GetWebFrame(frame);
if(web_frame)
web_frame->loadHTMLString(WideToUTF8(html), gurl);
web_frame->loadHTMLString(std::string(html), gurl);
frame->Release();
}
void CefBrowserImpl::UIT_LoadHTMLForStreamRef(CefFrame* frame,
CefStreamReader* stream,
const std::wstring& url)
const CefString& url)
{
REQUIRE_UIT();
GURL gurl(StdWStringToWebString(url));
std::string urlStr(url);
GURL gurl = GURL(urlStr);
if (!gurl.is_valid() && !gurl.has_scheme()) {
// Try to add "http://" at the beginning
std::wstring new_url = std::wstring(L"http://") + url;
gurl = GURL(StdWStringToWebString(new_url));
std::string new_url = std::string("http://") + urlStr;
gurl = GURL(new_url);
if (!gurl.is_valid())
return;
}
@ -681,18 +675,16 @@ void CefBrowserImpl::UIT_LoadHTMLForStreamRef(CefFrame* frame,
}
void CefBrowserImpl::UIT_ExecuteJavaScript(CefFrame* frame,
const std::wstring& js_code,
const std::wstring& script_url,
const CefString& js_code,
const CefString& script_url,
int start_line)
{
REQUIRE_UIT();
WebFrame* web_frame = GetWebFrame(frame);
if(web_frame) {
web_frame->executeScript(
WebScriptSource(StdWStringToWebString(js_code),
WebURL(GURL(StdWStringToWebString(script_url))),
start_line));
web_frame->executeScript(WebScriptSource(string16(js_code),
WebURL(GURL(std::string(script_url))), start_line));
}
frame->Release();
@ -722,12 +714,10 @@ bool CefBrowserImpl::UIT_Navigate(const BrowserNavigationEntry& entry,
// Get the right target frame for the entry.
WebFrame* frame;
if (!entry.GetTargetFrame().empty()) {
frame = view->findFrameByName(
StdWStringToWebString(entry.GetTargetFrame()));
} else {
if (!entry.GetTargetFrame().empty())
frame = view->findFrameByName(string16(entry.GetTargetFrame()));
else
frame = view->mainFrame();
}
// TODO(mpcomplete): should we clear the target frame, or should
// back/forward navigations maintain the target frame?
@ -752,23 +742,22 @@ bool CefBrowserImpl::UIT_Navigate(const BrowserNavigationEntry& entry,
DCHECK(entry.GetPageID() == -1);
WebURLRequest request(entry.GetURL());
if(entry.GetMethod().size() > 0)
request.setHTTPMethod(StdWStringToWebString(entry.GetMethod()));
if(entry.GetMethod().length() > 0)
request.setHTTPMethod(string16(entry.GetMethod()));
if(entry.GetHeaders().size() > 0)
CefRequestImpl::SetHeaderMap(entry.GetHeaders(), request);
if(!entry.GetUploadData().isNull())
{
std::string method = WebStringToStdString(request.httpMethod());
if(method == "GET" || method == "HEAD") {
request.setHTTPMethod(StdStringToWebString("POST"));
}
if(request.httpHeaderField(StdStringToWebString("Content-Type")).length()
== 0) {
string16 method = request.httpMethod();
if(method == ASCIIToUTF16("GET") || method == ASCIIToUTF16("HEAD"))
request.setHTTPMethod(ASCIIToUTF16("POST"));
if(request.httpHeaderField(ASCIIToUTF16("Content-Type")).length() == 0) {
request.setHTTPHeaderField(
StdStringToWebString("Content-Type"),
StdStringToWebString("application/x-www-form-urlencoded"));
ASCIIToUTF16("Content-Type"),
ASCIIToUTF16("application/x-www-form-urlencoded"));
}
request.setHTTPBody(entry.GetUploadData());
}
@ -797,16 +786,16 @@ bool CefBrowserImpl::UIT_Navigate(const BrowserNavigationEntry& entry,
}
CefRefPtr<CefBrowserImpl> CefBrowserImpl::UIT_CreatePopupWindow(
const std::wstring& url, const CefPopupFeatures& features)
const CefString& url, const CefPopupFeatures& features)
{
REQUIRE_UIT();
CefWindowInfo info;
#if defined(OS_WIN)
info.SetAsPopup(NULL, url.c_str());
info.SetAsPopup(NULL, CefString());
#endif
CefRefPtr<CefHandler> handler = handler_;
std::wstring newUrl = url;
CefString newUrl = url;
// Start with the current browser window's settings.
CefBrowserSettings settings(settings_);
@ -938,10 +927,11 @@ void CefBrowserImpl::UIT_GetDocumentTextNotify(CefFrame* frame,
WebKit::WebFrame* web_frame = GetWebFrame(frame);
if(web_frame) {
// Retrieve the document string
std::wstring str = webkit_glue::DumpDocumentText(web_frame);
std::string cstr = WideToUTF8(str);
std::wstring wstr = webkit_glue::DumpDocumentText(web_frame);
std::string str;
WideToUTF8(wstr.c_str(), wstr.length(), &str);
// Write the document string to the stream
writer->Write(cstr.c_str(), cstr.size(), 1);
writer->Write(str.c_str(), str.size(), 1);
}
// Notify the calling thread that the data is now available
@ -973,7 +963,7 @@ void CefBrowserImpl::UIT_CanGoForwardNotify(bool *retVal,
event->Signal();
}
void CefBrowserImpl::UIT_Find(int identifier, const std::wstring& search_text,
void CefBrowserImpl::UIT_Find(int identifier, const CefString& search_text,
const WebKit::WebFindOptions& options)
{
WebView* view = GetWebView();
@ -981,6 +971,7 @@ void CefBrowserImpl::UIT_Find(int identifier, const std::wstring& search_text,
return;
WebFrame* main_frame = view->mainFrame();
string16 searchText(search_text);
if (main_frame->document().isPluginDocument()) {
WebPlugin* plugin = main_frame->document().to<WebPluginDocument>().plugin();
@ -990,8 +981,7 @@ void CefBrowserImpl::UIT_Find(int identifier, const std::wstring& search_text,
// Just navigate back/forward.
delegate->SelectFindResult(options.forward);
} else {
if (delegate->StartFind(StdWStringToWebString(search_text),
options.matchCase, identifier)) {
if (delegate->StartFind(searchText, options.matchCase, identifier)) {
} else {
// No find results.
UIT_NotifyFindStatus(identifier, 0, gfx::Rect(), 0, true);
@ -1018,8 +1008,8 @@ void CefBrowserImpl::UIT_Find(int identifier, const std::wstring& search_text,
WebRange current_selection = focused_frame->selectionRange();
do {
result = search_frame->find(identifier, StdWStringToWebString(search_text),
options, wrap_within_frame, &selection_rect);
result = search_frame->find(identifier, searchText, options,
wrap_within_frame, &selection_rect);
if (!result) {
// don't leave text selected as you move to the next frame.
@ -1045,7 +1035,7 @@ void CefBrowserImpl::UIT_Find(int identifier, const std::wstring& search_text,
// match for the search word(s).
if (multi_frame && search_frame == focused_frame) {
result = search_frame->find(
identifier, StdWStringToWebString(search_text),
identifier, searchText,
options, true, // Force wrapping.
&selection_rect);
}
@ -1086,9 +1076,7 @@ void CefBrowserImpl::UIT_Find(int identifier, const std::wstring& search_text,
if (result) {
// Start new scoping request. If the scoping function determines that it
// needs to scope, it will defer until later.
search_frame->scopeStringMatches(identifier,
StdWStringToWebString(search_text),
options,
search_frame->scopeStringMatches(identifier, searchText, options,
true); // reset the tickmarks
}

View File

@ -58,9 +58,9 @@ public:
virtual CefRefPtr<CefHandler> GetHandler();
virtual CefRefPtr<CefFrame> GetMainFrame();
virtual CefRefPtr<CefFrame> GetFocusedFrame();
virtual CefRefPtr<CefFrame> GetFrame(const std::wstring& name);
virtual void GetFrameNames(std::vector<std::wstring>& names);
virtual void Find(int identifier, const std::wstring& searchText,
virtual CefRefPtr<CefFrame> GetFrame(const CefString& name);
virtual void GetFrameNames(std::vector<CefString>& names);
virtual void Find(int identifier, const CefString& searchText,
bool forward, bool matchCase, bool findNext);
virtual void StopFinding(bool clearSelection);
@ -70,7 +70,7 @@ public:
// guarantee that the same CefFrame object will be returned across different
// calls to this function.
CefRefPtr<CefFrame> GetCefFrame(WebKit::WebFrame* frame);
void RemoveCefFrame(const std::wstring& name);
void RemoveCefFrame(const CefString& name);
// Return the WebFrame object associated with the specified CefFrame. This
// may return NULL if no WebFrame with the CefFrame's name exists.
@ -86,23 +86,23 @@ public:
void SelectAll(CefRefPtr<CefFrame> frame);
void Print(CefRefPtr<CefFrame> frame);
void ViewSource(CefRefPtr<CefFrame> frame);
std::wstring GetSource(CefRefPtr<CefFrame> frame);
std::wstring GetText(CefRefPtr<CefFrame> frame);
CefString GetSource(CefRefPtr<CefFrame> frame);
CefString GetText(CefRefPtr<CefFrame> frame);
void LoadRequest(CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request);
void LoadURL(CefRefPtr<CefFrame> frame,
const std::wstring& url);
const CefString& url);
void LoadString(CefRefPtr<CefFrame> frame,
const std::wstring& string,
const std::wstring& url);
const CefString& string,
const CefString& url);
void LoadStream(CefRefPtr<CefFrame> frame,
CefRefPtr<CefStreamReader> stream,
const std::wstring& url);
const CefString& url);
void ExecuteJavaScript(CefRefPtr<CefFrame> frame,
const std::wstring& jsCode,
const std::wstring& scriptUrl,
const CefString& jsCode,
const CefString& scriptUrl,
int startLine);
std::wstring GetURL(CefRefPtr<CefFrame> frame);
CefString GetURL(CefRefPtr<CefFrame> frame);
WebKit::WebView* GetWebView() const {
return webviewhost_.get() ? webviewhost_->webview() : NULL;
@ -151,36 +151,36 @@ public:
is_modal_ = val;
}
void UIT_SetTitle(const std::wstring& title) {
void UIT_SetTitle(const CefString& title) {
REQUIRE_UIT();
title_ = title;
}
std::wstring UIT_GetTitle() {
CefString UIT_GetTitle() {
REQUIRE_UIT();
return title_;
}
void UIT_CreateBrowser(const std::wstring& url);
void UIT_CreateBrowser(const CefString& url);
void UIT_DestroyBrowser();
void UIT_LoadURL(CefFrame* frame,
const std::wstring& url);
const CefString& url);
void UIT_LoadURLForRequest(CefFrame* frame,
const std::wstring& url,
const std::wstring& method,
const CefString& url,
const CefString& method,
const WebKit::WebHTTPBody& upload_data,
const CefRequest::HeaderMap& headers);
void UIT_LoadURLForRequestRef(CefFrame* frame,
CefRequest* request);
void UIT_LoadHTML(CefFrame* frame,
const std::wstring& html,
const std::wstring& url);
const CefString& html,
const CefString& url);
void UIT_LoadHTMLForStreamRef(CefFrame* frame,
CefStreamReader* stream,
const std::wstring& url);
const CefString& url);
void UIT_ExecuteJavaScript(CefFrame* frame,
const std::wstring& js_code,
const std::wstring& script_url,
const CefString& js_code,
const CefString& script_url,
int start_line);
void UIT_GoBackOrForward(int offset);
void UIT_Reload(bool ignoreCache);
@ -189,7 +189,7 @@ public:
bool ignoreCahce);
void UIT_SetFocus(WebWidgetHost* host, bool enable);
CefRefPtr<CefBrowserImpl> UIT_CreatePopupWindow(const std::wstring& url,
CefRefPtr<CefBrowserImpl> UIT_CreatePopupWindow(const CefString& url,
const CefPopupFeatures& features);
WebKit::WebWidget* UIT_CreatePopupWidget();
void UIT_ClosePopupWidget();
@ -223,7 +223,7 @@ public:
void UIT_SetUniqueID(int id) { unique_id_ = id; }
int UIT_GetUniqueID() { return unique_id_; }
void UIT_Find(int identifier, const std::wstring& search_text,
void UIT_Find(int identifier, const CefString& search_text,
const WebKit::WebFindOptions& options);
void UIT_StopFinding(bool clear_selection);
void UIT_NotifyFindStatus(int identifier, int count,
@ -247,14 +247,14 @@ protected:
scoped_ptr<BrowserWebViewDelegate> popup_delegate_;
scoped_ptr<BrowserNavigationController> nav_controller_;
std::wstring title_;
CefString title_;
#if defined(OS_WIN)
// Context object used to manage printing.
printing::PrintingContext print_context_;
#endif
typedef std::map<std::wstring, CefFrame*> FrameMap;
typedef std::map<CefString, CefFrame*> FrameMap;
FrameMap frames_;
CefFrame* frame_main_;
@ -270,7 +270,7 @@ protected:
class CefFrameImpl : public CefThreadSafeBase<CefFrame>
{
public:
CefFrameImpl(CefBrowserImpl* browser, const std::wstring& name)
CefFrameImpl(CefBrowserImpl* browser, const CefString& name)
: browser_(browser), name_(name) {}
virtual ~CefFrameImpl() { browser_->RemoveCefFrame(name_); }
@ -284,30 +284,30 @@ public:
virtual void SelectAll() { browser_->SelectAll(this); }
virtual void Print() { browser_->Print(this); }
virtual void ViewSource() { browser_->ViewSource(this); }
virtual std::wstring GetSource() { return browser_->GetSource(this); }
virtual std::wstring GetText() { return browser_->GetText(this); }
virtual CefString GetSource() { return browser_->GetSource(this); }
virtual CefString GetText() { return browser_->GetText(this); }
virtual void LoadRequest(CefRefPtr<CefRequest> request)
{ return browser_->LoadRequest(this, request); }
virtual void LoadURL(const std::wstring& url)
virtual void LoadURL(const CefString& url)
{ return browser_->LoadURL(this, url); }
virtual void LoadString(const std::wstring& string,
const std::wstring& url)
virtual void LoadString(const CefString& string,
const CefString& url)
{ return browser_->LoadString(this, string, url); }
virtual void LoadStream(CefRefPtr<CefStreamReader> stream,
const std::wstring& url)
const CefString& url)
{ return browser_->LoadStream(this, stream, url); }
virtual void ExecuteJavaScript(const std::wstring& jsCode,
const std::wstring& scriptUrl,
virtual void ExecuteJavaScript(const CefString& jsCode,
const CefString& scriptUrl,
int startLine)
{ return browser_->ExecuteJavaScript(this, jsCode, scriptUrl, startLine); }
virtual bool IsMain() { return name_.empty(); }
virtual bool IsFocused();
virtual std::wstring GetName() { return name_; }
virtual std::wstring GetURL() { return browser_->GetURL(this); }
virtual CefString GetName() { return name_; }
virtual CefString GetURL() { return browser_->GetURL(this); }
private:
CefRefPtr<CefBrowserImpl> browser_;
std::wstring name_;
CefString name_;
};
#endif // _BROWSER_IMPL_H

View File

@ -10,7 +10,6 @@
#import <Cocoa/Cocoa.h>
#include "base/utf_string_conversions.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/WebKit/chromium/public/WebRect.h"
#include "third_party/WebKit/WebKit/chromium/public/WebSize.h"
@ -32,7 +31,7 @@ gfx::NativeWindow CefBrowserImpl::GetMainWndHandle() const {
return (NSWindow*)window_info_.m_View;
}
void CefBrowserImpl::UIT_CreateBrowser(const std::wstring& url)
void CefBrowserImpl::UIT_CreateBrowser(const CefString& url)
{
REQUIRE_UIT();
@ -67,7 +66,7 @@ void CefBrowserImpl::UIT_CreateBrowser(const std::wstring& url)
if(url.size() > 0) {
CefRefPtr<CefFrame> frame = GetMainFrame();
frame->AddRef();
UIT_LoadURL(frame, url.c_str());
UIT_LoadURL(frame, url);
}
}

View File

@ -8,7 +8,6 @@
#include "browser_settings.h"
#include "printing/units.h"
#include "base/utf_string_conversions.h"
#include "base/win_util.h"
#include "skia/ext/vector_canvas.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
@ -96,13 +95,15 @@ gfx::NativeWindow CefBrowserImpl::GetMainWndHandle() const {
return window_info_.m_hWnd;
}
void CefBrowserImpl::UIT_CreateBrowser(const std::wstring& url)
void CefBrowserImpl::UIT_CreateBrowser(const CefString& url)
{
REQUIRE_UIT();
std::wstring windowName(CefString(&window_info_.m_windowName));
// Create the new browser window
window_info_.m_hWnd = CreateWindowEx(window_info_.m_dwExStyle, GetWndClass(),
window_info_.m_windowName, window_info_.m_dwStyle,
windowName.c_str(), window_info_.m_dwStyle,
window_info_.m_x, window_info_.m_y, window_info_.m_nWidth,
window_info_.m_nHeight, window_info_.m_hWndParent, window_info_.m_hMenu,
::GetModuleHandle(NULL), NULL);
@ -140,10 +141,10 @@ void CefBrowserImpl::UIT_CreateBrowser(const std::wstring& url)
handler_->HandleAfterCreated(this);
}
if(url.size() > 0) {
if(url.length() > 0) {
CefRefPtr<CefFrame> frame = GetMainFrame();
frame->AddRef();
UIT_LoadURL(frame, url.c_str());
UIT_LoadURL(frame, url);
}
}
@ -307,12 +308,11 @@ void CefBrowserImpl::UIT_PrintPage(int page_number, int total_pages,
printInfo.m_Rect = rect;
printInfo.m_Scale = scale;
std::string spec = frame->url().spec();
std::wstring url = UTF8ToWide(spec);
std::wstring title = title_;
CefString url(frame->url().spec());
CefString title = title_;
std::wstring topLeft, topCenter, topRight;
std::wstring bottomLeft, bottomCenter, bottomRight;
CefString topLeft, topCenter, topRight;
CefString bottomLeft, bottomCenter, bottomRight;
// allow the handler to format print header and/or footer
CefHandler::RetVal rv = handler_->HandlePrintHeaderFooter(this,
@ -333,33 +333,39 @@ void CefBrowserImpl::UIT_PrintPage(int page_number, int total_pages,
// TODO(cef): Keep the header strings inside a reasonable bounding box
// so that they don't overlap each other.
if(topLeft.size() > 0) {
DrawText(hDC, topLeft.c_str(), topLeft.size(), &rect,
if(topLeft.length() > 0) {
std::wstring topLeftStr(topLeft);
DrawText(hDC, topLeftStr.c_str(), topLeftStr.length(), &rect,
DT_LEFT | DT_TOP | DT_SINGLELINE | DT_END_ELLIPSIS
| DT_EXPANDTABS | DT_NOPREFIX);
}
if(topCenter.size() > 0) {
DrawText(hDC, topCenter.c_str(), topCenter.size(), &rect,
if(topCenter.length() > 0) {
std::wstring topCenterStr(topCenter);
DrawText(hDC, topCenterStr.c_str(), topCenterStr.length(), &rect,
DT_CENTER | DT_TOP | DT_SINGLELINE | DT_END_ELLIPSIS
| DT_EXPANDTABS | DT_NOPREFIX);
}
if(topRight.size() > 0) {
DrawText(hDC, topRight.c_str(), topRight.size(), &rect,
if(topRight.length() > 0) {
std::wstring topRightStr(topRight);
DrawText(hDC, topRightStr.c_str(), topRightStr.length(), &rect,
DT_RIGHT | DT_TOP | DT_SINGLELINE | DT_END_ELLIPSIS
| DT_EXPANDTABS | DT_NOPREFIX);
}
if(bottomLeft.size() > 0) {
DrawText(hDC, bottomLeft.c_str(), bottomLeft.size(), &rect,
if(bottomLeft.length() > 0) {
std::wstring bottomLeftStr(bottomLeft);
DrawText(hDC, bottomLeftStr.c_str(), bottomLeftStr.length(), &rect,
DT_LEFT | DT_BOTTOM | DT_SINGLELINE | DT_END_ELLIPSIS
| DT_EXPANDTABS | DT_NOPREFIX);
}
if(bottomCenter.size() > 0) {
DrawText(hDC, bottomCenter.c_str(), bottomCenter.size(), &rect,
if(bottomCenter.length() > 0) {
std::wstring bottomCenterStr(bottomCenter);
DrawText(hDC, bottomCenterStr.c_str(), bottomCenterStr.length(), &rect,
DT_CENTER | DT_BOTTOM | DT_SINGLELINE | DT_END_ELLIPSIS
| DT_EXPANDTABS | DT_NOPREFIX);
}
if(bottomRight.size() > 0) {
DrawText(hDC, bottomRight.c_str(), bottomRight.size(), &rect,
if(bottomRight.length() > 0) {
std::wstring bottomRightStr(bottomRight);
DrawText(hDC, bottomRightStr.c_str(), bottomRightStr.length(), &rect,
DT_RIGHT | DT_BOTTOM | DT_SINGLELINE | DT_END_ELLIPSIS
| DT_EXPANDTABS | DT_NOPREFIX);
}

View File

@ -18,9 +18,9 @@ BrowserNavigationEntry::BrowserNavigationEntry()
BrowserNavigationEntry::BrowserNavigationEntry(int page_id,
const GURL& url,
const std::wstring& title,
const std::wstring& target_frame,
const std::wstring& method,
const CefString& title,
const CefString& target_frame,
const CefString& method,
const WebKit::WebHTTPBody& upload,
const CefRequest::HeaderMap& headers)
: page_id_(page_id),

View File

@ -43,9 +43,9 @@ class BrowserNavigationEntry {
BrowserNavigationEntry();
BrowserNavigationEntry(int page_id,
const GURL& url,
const std::wstring& title,
const std::wstring& target_frame,
const std::wstring& method,
const CefString& title,
const CefString& target_frame,
const CefString& method,
const WebKit::WebHTTPBody& upload,
const CefRequest::HeaderMap& headers);
~BrowserNavigationEntry();
@ -55,8 +55,8 @@ class BrowserNavigationEntry {
const GURL& GetURL() const { return url_; }
// Set / Get the title
void SetTitle(const std::wstring& a_title) { title_ = a_title; }
const std::wstring& GetTitle() const { return title_; }
void SetTitle(const CefString& a_title) { title_ = a_title; }
const CefString& GetTitle() const { return title_; }
// Set / Get opaque state.
// WARNING: This state is saved to the database and used to restore previous
@ -70,9 +70,9 @@ class BrowserNavigationEntry {
void SetPageID(int page_id) { page_id_ = page_id; }
int32 GetPageID() const { return page_id_; }
const std::wstring& GetTargetFrame() const { return target_frame_; }
const CefString& GetTargetFrame() const { return target_frame_; }
const std::wstring& GetMethod() const { return method_; }
const CefString& GetMethod() const { return method_; }
const WebKit::WebHTTPBody& GetUploadData() const { return upload_; }
const CefRequest::HeaderMap& GetHeaders() const { return headers_; }
@ -82,13 +82,13 @@ private:
int32 page_id_;
GURL url_;
std::wstring title_;
CefString title_;
std::string state_;
std::wstring method_;
CefString method_;
WebKit::WebHTTPBody upload_;
CefRequest::HeaderMap headers_;
std::wstring target_frame_;
CefString target_frame_;
DISALLOW_COPY_AND_ASSIGN(BrowserNavigationEntry);
};

View File

@ -53,7 +53,6 @@
#include "base/time.h"
#include "base/timer.h"
#include "base/thread.h"
#include "base/utf_string_conversions.h"
#include "base/waitable_event.h"
#include "net/base/cookie_store.h"
#include "net/base/file_stream.h"
@ -178,8 +177,7 @@ class RequestProxy : public URLRequest::Delegate,
CefRefPtr<CefHandler> handler = browser_->GetHandler();
if (handler.get()) {
CefRefPtr<CefDownloadHandler> dl_handler;
if (handler->HandleDownloadResponse(browser_,
UTF8ToWide(info.mime_type), UTF8ToWide(filename),
if (handler->HandleDownloadResponse(browser_, info.mime_type, filename,
info.content_length, dl_handler) == RV_CONTINUE) {
download_handler_ = dl_handler;
}
@ -263,15 +261,14 @@ class RequestProxy : public URLRequest::Delegate,
CefRefPtr<CefRequest> request(new CefRequestImpl());
CefRequestImpl* requestimpl = static_cast<CefRequestImpl*>(request.get());
const std::wstring originalUrl = UTF8ToWide(params->url.spec());
std::string originalUrl(params->url.spec());
requestimpl->SetURL(originalUrl);
requestimpl->SetMethod(UTF8ToWide(params->method));
requestimpl->SetMethod(params->method);
// Transfer request headers
CefRequest::HeaderMap headerMap;
CefRequestImpl::ParseHeaders(params->headers, headerMap);
headerMap.insert(
std::make_pair(L"Referrer", UTF8ToWide(params->referrer.spec())));
headerMap.insert(std::make_pair("Referrer", params->referrer.spec()));
requestimpl->SetHeaderMap(headerMap);
// Transfer post data, if any
@ -285,30 +282,33 @@ class RequestProxy : public URLRequest::Delegate,
int loadFlags = params->load_flags;
// Handler output will be returned in these variables
std::wstring redirectUrl;
CefString redirectUrl;
CefRefPtr<CefStreamReader> resourceStream;
std::wstring mimeType;
CefString mimeType;
CefHandler::RetVal rv = handler->HandleBeforeResourceLoad(
browser_, request, redirectUrl, resourceStream, mimeType, loadFlags);
browser_, request, redirectUrl, resourceStream, mimeType,
loadFlags);
// Observe URL from request.
const std::wstring requestUrl = request->GetURL();
const std::string requestUrl(request->GetURL());
if(requestUrl != originalUrl) {
params->url = GURL(WideToUTF8(requestUrl));
params->url = GURL(requestUrl);
redirectUrl.clear(); // Request URL trumps redirect URL
}
// Observe method from request.
params->method = WideToUTF8(request->GetMethod());
params->method = request->GetMethod();
// Observe headers from request.
request->GetHeaderMap(headerMap);
CefRequest::HeaderMap::iterator referrer = headerMap.find(L"Referrer");
CefString referrerStr;
referrerStr.FromASCII("Referrer");
CefRequest::HeaderMap::iterator referrer = headerMap.find(referrerStr);
if(referrer == headerMap.end()) {
params->referrer = GURL();
} else {
params->referrer = GURL(WideToUTF8(referrer->second));
params->referrer = GURL(std::string(referrer->second));
headerMap.erase(referrer);
}
params->headers = CefRequestImpl::GenerateHeaders(headerMap);
@ -328,7 +328,7 @@ class RequestProxy : public URLRequest::Delegate,
std::string(), base::Time());
} else if(!redirectUrl.empty()) {
// redirect to the specified URL
params->url = GURL(WideToUTF8(redirectUrl));
params->url = GURL(std::string(redirectUrl));
ResourceResponseInfo info;
bool defer_redirect;
OnReceivedRedirect(params->url, info, &defer_redirect);
@ -345,7 +345,7 @@ class RequestProxy : public URLRequest::Delegate,
ResourceResponseInfo info;
info.content_length = static_cast<int64>(offset);
if(!mimeType.empty())
info.mime_type = WideToUTF8(mimeType);
info.mime_type = mimeType;
OnReceivedResponse(info, false);
AsyncReadData();
}

View File

@ -3,28 +3,27 @@
// be found in the LICENSE file.
#include "../include/cef.h"
#include "base/utf_string_conversions.h"
#include "webkit/glue/webpreferences.h"
void BrowserToWebSettings(const CefBrowserSettings& cef, WebPreferences& web)
{
if (cef.standard_font_family)
web.standard_font_family = cef.standard_font_family;
if (cef.standard_font_family.length > 0)
web.standard_font_family = CefString(&cef.standard_font_family);
else
web.standard_font_family = L"Times";
if (cef.fixed_font_family)
web.fixed_font_family = cef.fixed_font_family;
if (cef.fixed_font_family.length > 0)
web.fixed_font_family = CefString(&cef.fixed_font_family);
else
web.fixed_font_family = L"Courier";
if (cef.serif_font_family)
web.serif_font_family = cef.serif_font_family;
if (cef.serif_font_family.length > 0)
web.serif_font_family = CefString(&cef.serif_font_family);
else
web.serif_font_family = L"Times";
if (cef.sans_serif_font_family)
web.sans_serif_font_family = cef.sans_serif_font_family;
if (cef.sans_serif_font_family.length > 0)
web.sans_serif_font_family = CefString(&cef.sans_serif_font_family);
else
web.sans_serif_font_family = L"Helvetica";
@ -39,8 +38,8 @@ void BrowserToWebSettings(const CefBrowserSettings& cef, WebPreferences& web)
// and fantasy fonts, but it should not matter for layout tests
// as long as they're available.
if (cef.cursive_font_family) {
web.cursive_font_family = cef.cursive_font_family;
if (cef.cursive_font_family.length > 0) {
web.cursive_font_family = CefString(&cef.cursive_font_family);
} else {
#if defined(OS_MACOSX)
web.cursive_font_family = L"Apple Chancery";
@ -49,8 +48,8 @@ void BrowserToWebSettings(const CefBrowserSettings& cef, WebPreferences& web)
#endif
}
if (cef.fantasy_font_family) {
web.fantasy_font_family = cef.fantasy_font_family;
if (cef.fantasy_font_family.length > 0) {
web.fantasy_font_family = CefString(&cef.fantasy_font_family);
} else {
#if defined(OS_MACOSX)
web.fantasy_font_family = L"Papyrus";
@ -79,8 +78,8 @@ void BrowserToWebSettings(const CefBrowserSettings& cef, WebPreferences& web)
else
web.minimum_logical_font_size = 9;
if (cef.default_encoding)
web.default_encoding = WideToUTF8(cef.default_encoding);
if (cef.default_encoding.length > 0)
web.default_encoding = CefString(&cef.default_encoding);
else
web.default_encoding = "ISO-8859-1";
@ -113,9 +112,9 @@ void BrowserToWebSettings(const CefBrowserSettings& cef, WebPreferences& web)
web.user_style_sheet_enabled = cef.user_style_sheet_enabled;
if (cef.user_style_sheet_location) {
if (cef.user_style_sheet_location.length > 0) {
web.user_style_sheet_location =
GURL(WideToUTF8(cef.user_style_sheet_location));
GURL(std::string(CefString(&cef.user_style_sheet_location)));
}
web.author_and_user_styles_enabled = !cef.author_and_user_styles_disabled;
@ -128,87 +127,3 @@ void BrowserToWebSettings(const CefBrowserSettings& cef, WebPreferences& web)
web.accelerated_2d_canvas_enabled = !cef.accelerated_2d_canvas_disabled;
web.memory_info_enabled = false;
}
void WebToBrowserSettings(const WebPreferences& web, CefBrowserSettings& cef)
{
cef.Reset();
if (!web.standard_font_family.empty()) {
cef.standard_font_family =
cef_string_alloc(web.standard_font_family.c_str());
}
if (!web.fixed_font_family.empty()) {
cef.fixed_font_family =
cef_string_alloc(web.fixed_font_family.c_str());
}
if (!web.serif_font_family.empty()) {
cef.serif_font_family =
cef_string_alloc(web.serif_font_family.c_str());
}
if (!web.cursive_font_family.empty()) {
cef.cursive_font_family =
cef_string_alloc(web.cursive_font_family.c_str());
}
if (!web.fantasy_font_family.empty()) {
cef.fantasy_font_family =
cef_string_alloc(web.fantasy_font_family.c_str());
}
cef.default_font_size = web.default_font_size;
cef.default_fixed_font_size = web.default_fixed_font_size;
cef.minimum_font_size = web.minimum_font_size;
cef.minimum_logical_font_size = web.minimum_logical_font_size;
cef.remote_fonts_disabled = !web.remote_fonts_enabled;
if (!web.default_encoding.empty()) {
std::wstring wstr;
UTF8ToWide(web.default_encoding.c_str(), web.default_encoding.length(),
&wstr);
cef.default_encoding = cef_string_alloc(wstr.c_str());
}
cef.encoding_detector_enabled = web.uses_universal_detector;
cef.javascript_disabled = !web.java_enabled;
cef.javascript_open_windows_disallowed =
!web.javascript_can_open_windows_automatically;
cef.javascript_close_windows_disallowed =
!web.allow_scripts_to_close_windows;
cef.javascript_access_clipboard_disallowed =
!web.javascript_can_access_clipboard;
cef.dom_paste_disabled = !web.dom_paste_enabled;
cef.caret_browsing_enabled = web.caret_browsing_enabled;
cef.java_disabled = !web.java_enabled;
cef.plugins_disabled = !web.plugins_enabled;
cef.universal_access_from_file_urls_allowed =
web.allow_universal_access_from_file_urls;
cef.file_access_from_file_urls_allowed = web.allow_file_access_from_file_urls;
cef.web_security_disabled = !web.web_security_enabled;
cef.xss_auditor_enabled = web.xss_auditor_enabled;
cef.image_load_disabled = !web.loads_images_automatically;
cef.shrink_standalone_images_to_fit = web.shrinks_standalone_images_to_fit;
cef.site_specific_quirks_disabled = !web.site_specific_quirks_enabled;
cef.text_area_resize_disabled = !web.text_areas_are_resizable;
cef.page_cache_disabled = !web.uses_page_cache;
cef.tab_to_links_disabled = !web.tabs_to_links;
cef.hyperlink_auditing_disabled = !web.hyperlink_auditing_enabled;
cef.user_style_sheet_enabled = web.user_style_sheet_enabled;
if (!web.user_style_sheet_location.is_empty()) {
std::string str = web.user_style_sheet_location.spec();
std::wstring wstr;
UTF8ToWide(str.c_str(), str.length(), &wstr);
cef.user_style_sheet_location = cef_string_alloc(wstr.c_str());
}
cef.author_and_user_styles_disabled = !web.author_and_user_styles_enabled;
cef.local_storage_disabled = !web.local_storage_enabled;
cef.databases_disabled = !web.databases_enabled;
cef.application_cache_disabled = !web.application_cache_enabled;
cef.experimental_webgl_enabled = web.experimental_webgl_enabled;
cef.accelerated_compositing_disabled = !web.accelerated_compositing_enabled;
cef.accelerated_2d_canvas_disabled = !web.accelerated_2d_canvas_enabled;
}

View File

@ -9,6 +9,5 @@ class CefBrowserSettings;
struct WebPreferences;
void BrowserToWebSettings(const CefBrowserSettings& cef, WebPreferences& web);
void WebToBrowserSettings(const WebPreferences& web, CefBrowserSettings& cef);
#endif // _CEF_BROWSER_SETTINGS_H

View File

@ -22,7 +22,6 @@ MSVC_POP_WARNING();
#include "base/path_service.h"
#include "base/scoped_ptr.h"
#include "base/string16.h"
#include "base/utf_string_conversions.h"
#include "net/base/mime_util.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
@ -73,8 +72,8 @@ bool IsProtocolSupportedForMedia(const GURL& url) {
std::string GetWebKitLocale() {
const CefSettings& settings = _Context->settings();
if (settings.locale)
return WideToUTF8(settings.locale);
if (settings.locale.length > 0)
return CefString(&settings.locale);
return "en-US";
}
@ -104,29 +103,11 @@ void ClearCache()
WebCore::cache()->setDisabled(false);
}
WebKit::WebString StdStringToWebString(const std::string& str) {
return WebKit::WebString::fromUTF8(str.data(), str.size());
}
std::string WebStringToStdString(const WebKit::WebString& str) {
std::string ret;
if (!str.isNull())
UTF16ToUTF8(str.data(), str.length(), &ret);
return ret;
}
WebKit::WebString StdWStringToWebString(const std::wstring& str) {
return StdStringToWebString(WideToUTF8(str));
}
std::wstring WebStringToStdWString(const WebKit::WebString& str) {
return UTF8ToWide(WebStringToStdString(str));
}
std::string GetProductVersion() {
const CefSettings& settings = _Context->settings();
if (settings.product_version)
return WideToUTF8(settings.product_version);
if (settings.product_version.length > 0) {
return CefString(&settings.product_version);
}
return "Chrome/7.0.517.0";
}

View File

@ -12,7 +12,6 @@
namespace WebKit {
class WebFrame;
class WebString;
class WebView;
}
@ -43,14 +42,6 @@ v8::Handle<v8::Context> GetV8Context(WebKit::WebFrame* frame);
// Clear all cached data.
void ClearCache();
WebKit::WebString StdStringToWebString(const std::string& str);
std::string WebStringToStdString(const WebKit::WebString& str);
WebKit::WebString StdWStringToWebString(const std::wstring& str);
std::wstring WebStringToStdWString(const WebKit::WebString& str);
// Returns true if the specified 'Content-Disposition' header value represents
// an attachment download. Also returns the file name.
bool IsContentDispositionAttachment(const std::string& cd_header,

View File

@ -21,7 +21,6 @@
#include "base/message_loop.h"
#include "base/process_util.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "gfx/point.h"
#include "media/filters/audio_renderer_impl.h"
#include "net/base/net_errors.h"
@ -152,10 +151,10 @@ void TranslatePopupFeatures(const WebWindowFeatures& webKitFeatures,
if (webKitFeatures.additionalFeatures.size() > 0)
features.additionalFeatures = cef_string_list_alloc();
CefString str;
for(unsigned int i = 0; i < webKitFeatures.additionalFeatures.size(); ++i) {
cef_string_list_append(features.additionalFeatures,
webkit_glue::WebStringToStdWString(
webKitFeatures.additionalFeatures[i]).c_str());
str = string16(webKitFeatures.additionalFeatures[i]);
cef_string_list_append(features.additionalFeatures, str.GetStruct());
}
}
@ -191,21 +190,21 @@ WebStorageNamespace* BrowserWebViewDelegate::createSessionStorageNamespace(
void BrowserWebViewDelegate::didAddMessageToConsole(
const WebConsoleMessage& message, const WebString& source_name,
unsigned source_line) {
std::wstring wmessage = UTF16ToWideHack(message.text);
std::wstring wsource = UTF16ToWideHack(source_name);
std::string messageStr = message.text.utf8();
std::string sourceStr = source_name.utf8();
CefHandler::RetVal rv = RV_CONTINUE;
CefRefPtr<CefHandler> handler = browser_->GetHandler();
if(handler.get()) {
rv = handler->HandleConsoleMessage(browser_, wmessage, wsource,
rv = handler->HandleConsoleMessage(browser_, messageStr, sourceStr,
source_line);
}
if(rv == RV_CONTINUE) {
logging::LogMessage("CONSOLE", 0).stream() << "\""
<< message.text.utf8().data()
<< messageStr
<< ",\" source: "
<< source_name.utf8().data()
<< sourceStr
<< "("
<< source_line
<< ")";
@ -357,8 +356,8 @@ bool BrowserWebViewDelegate::runFileChooser(
void BrowserWebViewDelegate::runModalAlertDialog(
WebFrame* frame, const WebString& message) {
std::wstring messageStr = UTF16ToWideHack(message);
CefHandler::RetVal rv = RV_CONTINUE;
CefString messageStr = string16(message);
CefRefPtr<CefHandler> handler = browser_->GetHandler();
if(handler.get()) {
rv = handler->HandleJSAlert(browser_, browser_->GetCefFrame(frame),
@ -370,8 +369,8 @@ void BrowserWebViewDelegate::runModalAlertDialog(
bool BrowserWebViewDelegate::runModalConfirmDialog(
WebFrame* frame, const WebString& message) {
std::wstring messageStr = UTF16ToWideHack(message);
CefHandler::RetVal rv = RV_CONTINUE;
CefString messageStr = string16(message);
bool retval = false;
CefRefPtr<CefHandler> handler = browser_->GetHandler();
if(handler.get()) {
@ -386,25 +385,25 @@ bool BrowserWebViewDelegate::runModalConfirmDialog(
bool BrowserWebViewDelegate::runModalPromptDialog(
WebFrame* frame, const WebString& message, const WebString& default_value,
WebString* actual_value) {
std::wstring wmessage = UTF16ToWideHack(message);
std::wstring wdefault = UTF16ToWideHack(default_value);
std::wstring wresult;
CefString messageStr = string16(message);
CefString defaultValueStr = string16(default_value);
CefString actualValueStr;
if(actual_value)
wresult = UTF16ToWideHack(*actual_value);
actualValueStr = string16(*actual_value);
CefHandler::RetVal rv = RV_CONTINUE;
bool retval = false;
CefRefPtr<CefHandler> handler = browser_->GetHandler();
if(handler.get()) {
rv = handler->HandleJSPrompt(browser_, browser_->GetCefFrame(frame),
wmessage, wdefault, retval, wresult);
messageStr, defaultValueStr, retval, actualValueStr);
}
if(rv != RV_HANDLED)
retval = ShowJavaScriptPrompt(frame, wmessage, wdefault, &wresult);
if(actual_value && !wresult.empty())
*actual_value = WideToUTF16Hack(wresult);
if(rv != RV_HANDLED) {
retval = ShowJavaScriptPrompt(frame, messageStr, defaultValueStr,
&actualValueStr);
}
if (actual_value)
*actual_value = string16(actualValueStr);
return retval;
}
@ -426,12 +425,11 @@ void BrowserWebViewDelegate::setKeyboardFocusURL(const WebKit::WebURL& url) {
void BrowserWebViewDelegate::setToolTipText(
const WebString& text, WebTextDirection hint)
{
std::wstring tooltipText(UTF8ToWide(webkit_glue::WebStringToStdString(text)));
CefString tooltipStr = string16(text);
CefRefPtr<CefHandler> handler = browser_->GetHandler();
if(handler.get() && handler->HandleTooltip(browser_, tooltipText)
if(handler.get() && handler->HandleTooltip(browser_, tooltipStr)
== RV_CONTINUE){
GetWidgetHost()->SetTooltipText(tooltipText);
GetWidgetHost()->SetTooltipText(tooltipStr);
}
}
@ -601,7 +599,7 @@ void BrowserWebViewDelegate::loadURLExternally(
WebFrame* frame, const WebURLRequest& request,
WebNavigationPolicy policy) {
DCHECK_NE(policy, WebKit::WebNavigationPolicyCurrentTab);
browser_->UIT_CreatePopupWindow(UTF8ToWide(request.url().spec().data()),
browser_->UIT_CreatePopupWindow(std::string(request.url().spec().data()),
CefPopupFeatures());
}
@ -618,9 +616,8 @@ WebNavigationPolicy BrowserWebViewDelegate::decidePolicyForNavigation(
if (!request_url.is_valid())
return WebKit::WebNavigationPolicyIgnore;
req->SetURL(UTF8ToWide(request_url.spec()));
req->SetMethod(
UTF8ToWide(webkit_glue::WebStringToStdString(request.httpMethod())));
req->SetURL(request_url.spec());
req->SetMethod(string16(request.httpMethod()));
const WebKit::WebHTTPBody& httpBody = request.httpBody();
if(!httpBody.isNull()) {
@ -717,13 +714,13 @@ void BrowserWebViewDelegate::didFailProvisionalLoad(
CefRefPtr<CefHandler> handler = browser_->GetHandler();
if(handler.get()) {
// give the handler an opportunity to generate a custom error message
std::wstring error_str;
CefString errorStr;
CefHandler::RetVal rv = handler->HandleLoadError(browser_,
browser_->GetCefFrame(frame),
static_cast<CefHandler::ErrorCode>(error.reason),
UTF8ToWide(failed_ds->request().url().spec().data()), error_str);
if(rv == RV_HANDLED && !error_str.empty())
error_text = WideToUTF8(error_str);
std::string(failed_ds->request().url().spec().data()), errorStr);
if(rv == RV_HANDLED && !errorStr.empty())
error_text = errorStr;
} else {
error_text = StringPrintf("Error %d when loading url %s",
error.reason, failed_ds->request().url().spec().data());
@ -767,13 +764,12 @@ void BrowserWebViewDelegate::didClearWindowObject(WebFrame* frame) {
void BrowserWebViewDelegate::didReceiveTitle(
WebFrame* frame, const WebString& title) {
std::wstring wtitle = UTF16ToWideHack(title);
browser_->UIT_SetTitle(wtitle);
CefString titleStr = string16(title);
browser_->UIT_SetTitle(titleStr);
CefRefPtr<CefHandler> handler = browser_->GetHandler();
if(handler.get()) {
// Notify the handler of a page title change
handler->HandleTitleChange(browser_, wtitle);
handler->HandleTitleChange(browser_, titleStr);
}
}
@ -971,7 +967,7 @@ void BrowserWebViewDelegate::UpdateURL(WebFrame* frame) {
entry->SetURL(request.url());
}
std::wstring url = UTF8ToWide(entry->GetURL().spec().c_str());
std::string url = std::string(entry->GetURL().spec().c_str());
CefRefPtr<CefHandler> handler = browser_->GetHandler();
if(handler.get()) {

View File

@ -251,13 +251,13 @@ class BrowserWebViewDelegate : public WebKit::WebViewClient,
// Default handling of JavaScript messages.
void ShowJavaScriptAlert(WebKit::WebFrame* webframe,
const std::wstring& message);
const CefString& message);
bool ShowJavaScriptConfirm(WebKit::WebFrame* webframe,
const std::wstring& message);
const CefString& message);
bool ShowJavaScriptPrompt(WebKit::WebFrame* webframe,
const std::wstring& message,
const std::wstring& default_value,
std::wstring* result);
const CefString& message,
const CefString& default_value,
CefString* result);
// Called to show the file chooser dialog.
bool ShowFileChooser(std::vector<FilePath>& file_names,

View File

@ -8,7 +8,6 @@
#import <Cocoa/Cocoa.h>
#include "base/sys_string_conversions.h"
#include "base/utf_string_conversions.h"
#include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h"
#include "third_party/WebKit/WebKit/chromium/public/WebPopupMenu.h"
#include "third_party/WebKit/WebKit/chromium/public/WebView.h"
@ -198,7 +197,7 @@ void BrowserWebViewDelegate::DidMovePlugin(
void BrowserWebViewDelegate::ShowJavaScriptAlert(
WebKit::WebFrame* webframe, const std::wstring& message) {
NSString *text =
[NSString stringWithUTF8String:WideToUTF8(message).c_str()];
[NSString stringWithUTF8String:(std::string(message).c_str())];
NSAlert *alert = [NSAlert alertWithMessageText:@"JavaScript Alert"
defaultButton:@"OK"
alternateButton:nil
@ -234,7 +233,7 @@ bool BrowserWebViewDelegate::ShowFileChooser(std::vector<FilePath>& file_names,
/*
void BrowserWebViewDelegate::SetPageTitle(const std::wstring& title) {
[[browser_->GetWebViewHost()->view_handle() window]
setTitle:[NSString stringWithUTF8String:WideToUTF8(title).c_str()]];
setTitle:[NSString stringWithUTF8String:(std::string(title).c_str())]];
}
void BrowserWebViewDelegate::SetAddressBarURL(const GURL& url) {

View File

@ -20,7 +20,6 @@
#include "base/message_loop.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "gfx/gdi_util.h"
#include "gfx/native_widget_types.h"
#include "gfx/point.h"
@ -205,7 +204,7 @@ static void AddMenuItem(CefRefPtr<CefBrowser> browser, HMENU menu, int index,
CefHandler::MenuId id, const wchar_t* label,
bool enabled, std::list<std::wstring>& label_list)
{
std::wstring actual_label = label;
CefString actual_label(label);
CefRefPtr<CefHandler> handler = browser->GetHandler();
if(handler.get()) {
// Let the handler change the label if desired
@ -284,28 +283,30 @@ void BrowserWebViewDelegate::showContextMenu(
if(handler.get()) {
// Gather menu information
CefHandler::MenuInfo menuInfo;
std::wstring linkStr, imageStr, pageStr, frameStr;
std::wstring selectedTextStr, misspelledWordStr, securityInfoStr;
linkStr = UTF16ToWideHack(data.linkURL.spec().utf16());
imageStr = UTF16ToWideHack(data.srcURL.spec().utf16());
pageStr = UTF16ToWideHack(data.pageURL.spec().utf16());
frameStr = UTF16ToWideHack(data.frameURL.spec().utf16());
selectedTextStr = UTF16ToWideHack(data.selectedText);
misspelledWordStr = UTF16ToWideHack(data.misspelledWord);
securityInfoStr = UTF16ToWideHack(data.securityInfo.utf16());
CefString linkStr(std::string(data.linkURL.spec()));
CefString imageStr(std::string(data.srcURL.spec()));
CefString pageStr(std::string(data.pageURL.spec()));
CefString frameStr(std::string(data.frameURL.spec()));
CefString selectedTextStr(string16(data.selectedText));
CefString misspelledWordStr(string16(data.misspelledWord));
CefString securityInfoStr(std::string(data.securityInfo));
menuInfo.typeFlags = type_flags;
menuInfo.x = screen_pt.x;
menuInfo.y = screen_pt.y;
menuInfo.linkUrl = linkStr.c_str();
menuInfo.imageUrl = imageStr.c_str();
menuInfo.pageUrl = pageStr.c_str();
menuInfo.frameUrl = frameStr.c_str();
menuInfo.selectionText = selectedTextStr.c_str();
menuInfo.misspelledWord = misspelledWordStr.c_str();
cef_string_set(linkStr.c_str(), linkStr.length(), &menuInfo.linkUrl, false);
cef_string_set(imageStr.c_str(), imageStr.length(), &menuInfo.imageUrl,
false);
cef_string_set(pageStr.c_str(), pageStr.length(), &menuInfo.pageUrl, false);
cef_string_set(frameStr.c_str(), frameStr.length(), &menuInfo.frameUrl,
false);
cef_string_set(selectedTextStr.c_str(), selectedTextStr.length(),
&menuInfo.selectionText, false);
cef_string_set(misspelledWordStr.c_str(), misspelledWordStr.length(),
&menuInfo.misspelledWord, false);
menuInfo.editFlags = edit_flags;
menuInfo.securityInfo = securityInfoStr.c_str();
cef_string_set(securityInfoStr.c_str(), securityInfoStr.length(),
&menuInfo.securityInfo, false);
// Notify the handler that a context menu is requested
CefHandler::RetVal rv = handler->HandleBeforeMenu(browser_, menuInfo);
@ -383,27 +384,30 @@ end:
// Private methods ------------------------------------------------------------
void BrowserWebViewDelegate::ShowJavaScriptAlert(WebFrame* webframe,
const std::wstring& message)
const CefString& message)
{
// TODO(cef): Think about what we should be showing as the prompt caption
MessageBox(browser_->GetMainWndHandle(), message.c_str(),
browser_->UIT_GetTitle().c_str(), MB_OK | MB_ICONWARNING);
std::wstring messageStr = message;
std::wstring titleStr = browser_->UIT_GetTitle();
MessageBox(browser_->GetMainWndHandle(), messageStr.c_str(), titleStr.c_str(),
MB_OK | MB_ICONWARNING);
}
bool BrowserWebViewDelegate::ShowJavaScriptConfirm(WebFrame* webframe,
const std::wstring& message)
const CefString& message)
{
// TODO(cef): Think about what we should be showing as the prompt caption
int rv = MessageBox(browser_->GetMainWndHandle(), message.c_str(),
browser_->UIT_GetTitle().c_str(),
MB_YESNO | MB_ICONQUESTION);
std::wstring messageStr = message;
std::wstring titleStr = browser_->UIT_GetTitle();
int rv = MessageBox(browser_->GetMainWndHandle(), messageStr.c_str(),
titleStr.c_str(), MB_YESNO | MB_ICONQUESTION);
return (rv == IDYES);
}
bool BrowserWebViewDelegate::ShowJavaScriptPrompt(WebFrame* webframe,
const std::wstring& message,
const std::wstring& default_value,
std::wstring* result)
const CefString& message,
const CefString& default_value,
CefString* result)
{
// TODO(cef): Implement a default prompt dialog
return false;
@ -414,10 +418,7 @@ namespace
// from chrome/browser/views/shell_dialogs_win.cc
bool RunOpenFileDialog(
const std::wstring& filter,
HWND owner,
FilePath* path)
bool RunOpenFileDialog(const std::wstring& filter, HWND owner, FilePath* path)
{
OPENFILENAME ofn;
@ -446,9 +447,7 @@ bool RunOpenFileDialog(
return success;
}
bool RunOpenMultiFileDialog(
const std::wstring& filter,
HWND owner,
bool RunOpenMultiFileDialog(const std::wstring& filter, HWND owner,
std::vector<FilePath>* paths)
{
OPENFILENAME ofn;
@ -509,12 +508,10 @@ bool BrowserWebViewDelegate::ShowFileChooser(std::vector<FilePath>& file_names,
{
bool result = false;
if (multi_select)
{
result = RunOpenMultiFileDialog(L"", browser_->GetMainWndHandle(), &file_names);
}
else
{
if (multi_select) {
result = RunOpenMultiFileDialog(L"", browser_->GetMainWndHandle(),
&file_names);
} else {
FilePath file_name;
result = RunOpenFileDialog(L"", browser_->GetMainWndHandle(), &file_name);
if (result)

View File

@ -11,7 +11,6 @@
#include "webwidget_host.h"
#include "base/scoped_ptr.h"
#include "base/utf_string_conversions.h"
#include "gfx/rect.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/WebKit/chromium/public/WebView.h"

View File

@ -13,7 +13,6 @@
#if defined(OS_MACOSX) || defined(OS_WIN)
#include "base/nss_util.h"
#endif
#include "base/utf_string_conversions.h"
#include "webkit/glue/plugins/plugin_list.h"
// Global CefContext pointer
@ -193,14 +192,7 @@ bool CefContext::Initialize(const CefSettings& settings,
settings_ = settings;
browser_defaults_ = browser_defaults;
std::wstring cachePathStr;
if(settings.cache_path)
cachePathStr = settings.cache_path;
#if defined(OS_WIN)
cache_path_ = FilePath(cachePathStr);
#else
cache_path_ = FilePath(WideToUTF8(cachePathStr));
#endif
cache_path_ = FilePath(CefString(&settings.cache_path));
#if defined(OS_MACOSX) || defined(OS_WIN)
// We want to be sure to init NSPR on the main thread.

View File

@ -11,7 +11,6 @@
#include "browser_socket_stream_bridge.h"
#include "browser_webblobregistry_impl.h"
#include "base/utf_string_conversions.h"
#include "build/build_config.h"
#if defined(OS_WIN)

View File

@ -125,20 +125,17 @@ void CefProcessUIThread::Init() {
const CefSettings& settings = _Context->settings();
if (settings.user_agent)
webkit_glue::SetUserAgent(WideToUTF8(settings.user_agent));
if (settings.user_agent.length > 0)
webkit_glue::SetUserAgent(CefString(&settings.user_agent));
if (settings.extra_plugin_paths) {
cef_string_t str;
FilePath path;
int size = cef_string_list_size(settings.extra_plugin_paths);
for(int i = 0; i < size; ++i) {
str = cef_string_list_value(settings.extra_plugin_paths, i);
#if defined(OS_WIN)
path = FilePath(str);
#else
path = FilePath(WideToUTF8(str));
#endif
if (!cef_string_list_value(settings.extra_plugin_paths, i, &str))
continue;
path = FilePath(CefString(&str));
NPAPI::PluginList::Singleton()->AddExtraPluginPath(path);
}
}

View File

@ -1,169 +0,0 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "include/cef_string.h"
#include "build/build_config.h"
#include <limits.h>
#if defined(OS_MACOSX)
#include <stdlib.h>
#else
#include <malloc.h>
#endif
#include <string.h>
typedef unsigned long dword_t;
CEF_EXPORT size_t cef_string_length(cef_string_t str)
{
dword_t* ptr;
if(!str)
return 0;
// The string length, in bytes, is placed in a dword_t immediately proceeding
// the string value.
ptr = (dword_t*)str;
ptr--;
return (size_t)(*ptr / sizeof(wchar_t));
}
CEF_EXPORT cef_string_t cef_string_alloc(const wchar_t* str)
{
if(!str)
return NULL;
return cef_string_alloc_length(str, wcslen(str));
}
CEF_EXPORT cef_string_t cef_string_alloc_length(const wchar_t* str,
size_t len)
{
dword_t size, *ptr;
wchar_t* newstr;
// Check that the size can fit in a dword_t.
if(len >= (UINT_MAX - sizeof(wchar_t) - sizeof(dword_t)) / sizeof(wchar_t))
return NULL;
// Get the size of the string in bytes.
size = sizeof(wchar_t) * len;
// Allocate the new buffer including space for the proceeding dword_t size
// value and the terminating nul.
ptr = (dword_t*)malloc(sizeof(dword_t) + size + sizeof(wchar_t));
if(!ptr)
return NULL;
// Set the size as the first value in the newly allocated memory and
// increment to the string location.
*ptr = size;
ptr++;
if(str != NULL)
{
// Copy the string to the buffer.
memcpy(ptr, str, size);
}
else
{
// Initialize the string to zeros.
memset(ptr, 0, size);
}
newstr = (wchar_t*)ptr;
// Nul-terminate the string.
newstr[len] = '\0';
return (cef_string_t)newstr;
}
CEF_EXPORT int cef_string_realloc(cef_string_t* oldstr, const wchar_t* newstr)
{
if(!oldstr)
return 0;
// Free the old string.
cef_string_free(*oldstr);
// Copy the new string.
*oldstr = cef_string_alloc(newstr);
return 1;
}
CEF_EXPORT int cef_string_realloc_length(cef_string_t* oldstr,
const wchar_t* newstr,
size_t len)
{
if(!oldstr)
return 0;
// Check that the size can fit in a dword_t.
if(len >= (UINT_MAX - sizeof(wchar_t) - sizeof(dword_t)) / sizeof(wchar_t))
return 0;
if(*oldstr)
{
dword_t newsize, *oldptr, *newptr;
// Get the new size of the string in bytes.
newsize = sizeof(wchar_t) * len;
// Adjust the pointer to account for the dword_t immediately proceeding the
// string value.
oldptr = (dword_t*)*oldstr;
oldptr--;
// Re-allocate the buffer including space for the proceeding dword_t size
// value and the terminating nul.
newptr = (dword_t*)realloc(
oldptr, sizeof(dword_t) + newsize + sizeof(wchar_t));
if(!newptr)
return 0;
// Set the size as the first value in the newly allocated memory and
// increment to the string location.
*newptr = newsize;
newptr++;
// Set the string pointer to the beginning on the string in the newly
// allocated memory.
*oldstr = (cef_string_t)newptr;
if(newstr)
{
// Copy the new string value. Use of memmove() ensures that any
// overlapping region in the old string will be copied before being
// overwritten.
memmove(*oldstr, newstr, newsize);
// Nul-terminate the string.
*oldstr[len] = '\0';
}
}
else
{
// Allocate the string.
*oldstr = cef_string_alloc_length(newstr, len);
}
return 1;
}
CEF_EXPORT void cef_string_free(cef_string_t str)
{
dword_t* ptr;
if(!str)
return;
// The size is placed in a dword_t immediately proceeding the string value.
ptr = (dword_t*)str;
ptr--;
free(ptr);
}

View File

@ -7,7 +7,7 @@
#include <vector>
typedef std::vector<std::wstring> StringList;
typedef std::vector<CefString> StringList;
CEF_EXPORT cef_string_list_t cef_string_list_alloc()
{
@ -21,24 +21,26 @@ CEF_EXPORT int cef_string_list_size(cef_string_list_t list)
return impl->size();
}
CEF_EXPORT cef_string_t cef_string_list_value(cef_string_list_t list, int index)
CEF_EXPORT int cef_string_list_value(cef_string_list_t list, int index,
cef_string_t* value)
{
DCHECK(list);
DCHECK(value);
StringList* impl = (StringList*)list;
DCHECK(index >= 0 && index < (int)impl->size());
if(index < 0 || index >= (int)impl->size())
return NULL;
return cef_string_alloc((*impl)[index].c_str());
return false;
const CefString& str = (*impl)[index];
return cef_string_copy(str.c_str(), str.length(), value);
}
CEF_EXPORT void cef_string_list_append(cef_string_list_t list, const wchar_t* value)
CEF_EXPORT void cef_string_list_append(cef_string_list_t list,
const cef_string_t* value)
{
DCHECK(list);
DCHECK(value);
StringList* impl = (StringList*)list;
std::wstring valstr;
if(value)
valstr = value;
impl->push_back(valstr);
impl->push_back(CefString(value));
}
CEF_EXPORT void cef_string_list_clear(cef_string_list_t list)

View File

@ -7,7 +7,7 @@
#include <map>
typedef std::map<std::wstring, std::wstring> StringMap;
typedef std::map<CefString, CefString> StringMap;
CEF_EXPORT cef_string_map_t cef_string_map_alloc()
{
@ -21,23 +21,25 @@ CEF_EXPORT int cef_string_map_size(cef_string_map_t map)
return impl->size();
}
CEF_EXPORT cef_string_t cef_string_map_find(cef_string_map_t map,
const wchar_t* key)
CEF_EXPORT int cef_string_map_find(cef_string_map_t map,
const cef_string_t* key,
cef_string_t* value)
{
DCHECK(map);
DCHECK(value);
StringMap* impl = (StringMap*)map;
std::wstring keystr;
if(key)
keystr = key;
StringMap::const_iterator it = impl->find(keystr);
StringMap::const_iterator it = impl->find(CefString(key));
if(it == impl->end())
return NULL;
return cef_string_alloc(it->second.c_str());
const CefString& val = it->second;
return cef_string_set(val.c_str(), val.length(), value, true);
}
CEF_EXPORT cef_string_t cef_string_map_key(cef_string_map_t map, int index)
CEF_EXPORT int cef_string_map_key(cef_string_map_t map, int index,
cef_string_t* key)
{
DCHECK(map);
DCHECK(key);
StringMap* impl = (StringMap*)map;
DCHECK(index >= 0 && index < (int)impl->size());
if(index < 0 || index >= (int)impl->size())
@ -45,37 +47,38 @@ CEF_EXPORT cef_string_t cef_string_map_key(cef_string_map_t map, int index)
StringMap::const_iterator it = impl->begin();
for(int ct = 0; it != impl->end(); ++it, ct++) {
if(ct == index)
return cef_string_alloc(it->first.c_str());
return cef_string_set(it->first.c_str(), it->first.length(), key, true);
}
return NULL;
return 0;
}
CEF_EXPORT cef_string_t cef_string_map_value(cef_string_map_t map, int index)
CEF_EXPORT int cef_string_map_value(cef_string_map_t map, int index,
cef_string_t* value)
{
DCHECK(map);
DCHECK(value);
StringMap* impl = (StringMap*)map;
DCHECK(index >= 0 && index < (int)impl->size());
if(index < 0 || index >= (int)impl->size())
return NULL;
StringMap::const_iterator it = impl->begin();
for(int ct = 0; it != impl->end(); ++it, ct++) {
if(ct == index)
return cef_string_alloc(it->second.c_str());
if(ct == index) {
return cef_string_set(it->second.c_str(), it->second.length(), value,
true);
}
return NULL;
}
return 0;
}
CEF_EXPORT void cef_string_map_append(cef_string_map_t map, const wchar_t* key,
const wchar_t* value)
CEF_EXPORT int cef_string_map_append(cef_string_map_t map,
const cef_string_t* key,
const cef_string_t* value)
{
DCHECK(map);
StringMap* impl = (StringMap*)map;
std::wstring keystr, valstr;
if(key)
keystr = key;
if(value)
valstr = value;
impl->insert(std::pair<std::wstring, std::wstring>(keystr, valstr));
impl->insert(std::make_pair(CefString(key), CefString(value)));
return 1;
}
CEF_EXPORT void cef_string_map_clear(cef_string_map_t map)

294
libcef/cef_string_types.cc Normal file
View File

@ -0,0 +1,294 @@
// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "include/cef_string_types.h"
#include "base/logging.h"
#include "base/string16.h"
#include "base/utf_string_conversions.h"
namespace {
void string_wide_dtor(wchar_t* str)
{
delete [] str;
}
void string_utf8_dtor(char* str)
{
delete [] str;
}
void string_utf16_dtor(char16_t* str)
{
delete [] str;
}
} // namespace
CEF_EXPORT int cef_string_wide_set(const wchar_t* src, size_t src_len,
cef_string_wide_t* output, int copy)
{
cef_string_wide_clear(output);
if (copy) {
if (src && src_len > 0) {
output->str = new wchar_t[src_len+1];
if (!output->str)
return 0;
memcpy(output->str, src, src_len * sizeof(wchar_t));
output->str[src_len] = 0;
output->length = src_len;
output->dtor = string_wide_dtor;
}
} else {
output->str = const_cast<wchar_t*>(src);
output->length = src_len;
output->dtor = NULL;
}
return 1;
}
CEF_EXPORT int cef_string_utf8_set(const char* src, size_t src_len,
cef_string_utf8_t* output, int copy)
{
cef_string_utf8_clear(output);
if (copy) {
if (src && src_len > 0) {
output->str = new char[src_len+1];
if (!output->str)
return 0;
memcpy(output->str, src, src_len * sizeof(char));
output->str[src_len] = 0;
output->length = src_len;
output->dtor = string_utf8_dtor;
}
} else {
output->str = const_cast<char*>(src);
output->length = src_len;
output->dtor = NULL;
}
return 1;
}
CEF_EXPORT int cef_string_utf16_set(const char16_t* src, size_t src_len,
cef_string_utf16_t* output, int copy)
{
cef_string_utf16_clear(output);
if (copy) {
if (src && src_len > 0) {
output->str = new char16_t[src_len+1];
if (!output->str)
return 0;
memcpy(output->str, src, src_len * sizeof(char16_t));
output->str[src_len] = 0;
output->length = src_len;
output->dtor = string_utf16_dtor;
}
} else {
output->str = const_cast<char16_t*>(src);
output->length = src_len;
output->dtor = NULL;
}
return 1;
}
CEF_EXPORT void cef_string_wide_clear(cef_string_wide_t* str)
{
DCHECK(str != NULL);
if (str->dtor && str->str)
str->dtor(str->str);
str->str = NULL;
str->length = 0;
str->dtor = NULL;
}
CEF_EXPORT void cef_string_utf8_clear(cef_string_utf8_t* str)
{
DCHECK(str != NULL);
if (str->dtor && str->str)
str->dtor(str->str);
str->str = NULL;
str->length = 0;
str->dtor = NULL;
}
CEF_EXPORT void cef_string_utf16_clear(cef_string_utf16_t* str)
{
DCHECK(str != NULL);
if (str->dtor && str->str)
str->dtor(str->str);
str->str = NULL;
str->length = 0;
str->dtor = NULL;
}
CEF_EXPORT int cef_string_wide_cmp(const cef_string_wide_t* str1,
const cef_string_wide_t* str2)
{
if (str1->length == 0 && str2->length == 0)
return 0;
int r = wcsncmp(str1->str, str2->str, std::min(str1->length, str2->length));
if (r == 0) {
if (str1->length > str2->length)
return 1;
else if (str1->length < str2->length)
return -1;
}
return r;
}
CEF_EXPORT int cef_string_utf8_cmp(const cef_string_utf8_t* str1,
const cef_string_utf8_t* str2)
{
if (str1->length == 0 && str2->length == 0)
return 0;
int r = strncmp(str1->str, str2->str, std::min(str1->length, str2->length));
if (r == 0) {
if (str1->length > str2->length)
return 1;
else if (str1->length < str2->length)
return -1;
}
return r;
}
CEF_EXPORT int cef_string_utf16_cmp(const cef_string_utf16_t* str1,
const cef_string_utf16_t* str2)
{
if (str1->length == 0 && str2->length == 0)
return 0;
#if defined(WCHAR_T_IS_UTF32)
int r = c16memcmp(str1->str, str2->str, std::min(str1->length, str2->length));
#else
int r = wcsncmp(str1->str, str2->str, std::min(str1->length, str2->length));
#endif
if (r == 0) {
if (str1->length > str2->length)
return 1;
else if (str1->length < str2->length)
return -1;
}
return r;
}
CEF_EXPORT int cef_string_wide_to_utf8(const wchar_t* src, size_t src_len,
cef_string_utf8_t* output)
{
std::string str;
bool ret = WideToUTF8(src, src_len, &str);
if (!cef_string_utf8_set(str.c_str(), str.length(), output, true))
return false;
return ret;
}
CEF_EXPORT int cef_string_utf8_to_wide(const char* src, size_t src_len,
cef_string_wide_t* output)
{
std::wstring str;
bool ret = UTF8ToWide(src, src_len, &str);
if (!cef_string_wide_set(str.c_str(), str.length(), output, true))
return false;
return ret;
}
CEF_EXPORT int cef_string_wide_to_utf16(const wchar_t* src, size_t src_len,
cef_string_utf16_t* output)
{
string16 str;
bool ret = WideToUTF16(src, src_len, &str);
if (!cef_string_utf16_set(str.c_str(), str.length(), output, true))
return false;
return ret;
}
CEF_EXPORT int cef_string_utf16_to_wide(const char16_t* src, size_t src_len,
cef_string_wide_t* output)
{
std::wstring str;
bool ret = UTF16ToWide(src, src_len, &str);
if (!cef_string_wide_set(str.c_str(), str.length(), output, true))
return false;
return ret;
}
CEF_EXPORT int cef_string_utf8_to_utf16(const char* src, size_t src_len,
cef_string_utf16_t* output)
{
string16 str;
bool ret = UTF8ToUTF16(src, src_len, &str);
if (!cef_string_utf16_set(str.c_str(), str.length(), output, true))
return false;
return ret;
}
CEF_EXPORT int cef_string_utf16_to_utf8(const char16_t* src, size_t src_len,
cef_string_utf8_t* output)
{
std::string str;
bool ret = UTF16ToUTF8(src, src_len, &str);
if (!cef_string_utf8_set(str.c_str(), str.length(), output, true))
return false;
return ret;
}
CEF_EXPORT int cef_string_ascii_to_wide(const char* src, size_t src_len,
cef_string_wide_t* output)
{
std::wstring str = ASCIIToWide(std::string(src, src_len));
return cef_string_wide_set(str.c_str(), str.length(), output, true);
}
CEF_EXPORT int cef_string_ascii_to_utf16(const char* src, size_t src_len,
cef_string_utf16_t* output)
{
string16 str = ASCIIToUTF16(std::string(src, src_len));
return cef_string_utf16_set(str.c_str(), str.length(), output, true);
}
CEF_EXPORT cef_string_userfree_wide_t cef_string_userfree_wide_alloc()
{
cef_string_wide_t* s = new cef_string_wide_t;
memset(s, 0, sizeof(cef_string_wide_t));
return s;
}
CEF_EXPORT cef_string_userfree_utf8_t cef_string_userfree_utf8_alloc()
{
cef_string_utf8_t* s = new cef_string_utf8_t;
memset(s, 0, sizeof(cef_string_utf8_t));
return s;
}
CEF_EXPORT cef_string_userfree_utf16_t cef_string_userfree_utf16_alloc()
{
cef_string_utf16_t* s = new cef_string_utf16_t;
memset(s, 0, sizeof(cef_string_utf16_t));
return s;
}
CEF_EXPORT void cef_string_userfree_wide_free(cef_string_userfree_wide_t str)
{
cef_string_wide_clear(str);
delete str;
}
CEF_EXPORT void cef_string_userfree_utf8_free(cef_string_userfree_utf8_t str)
{
cef_string_utf8_clear(str);
delete str;
}
CEF_EXPORT void cef_string_userfree_utf16_free(cef_string_userfree_utf16_t str)
{
cef_string_utf16_clear(str);
delete str;
}

View File

@ -75,11 +75,11 @@ void PrintSettings::ResetRequestedPageMargins() {
void PrintSettings::Init(HDC hdc,
const DEVMODE& dev_mode,
const PageRanges& new_ranges,
const std::wstring& new_device_name,
const CefString& new_device_name,
bool print_selection_only,
bool print_to_file) {
DCHECK(hdc);
printer_name_ = dev_mode.dmDeviceName;
printer_name_ = std::wstring(dev_mode.dmDeviceName);
device_name_ = new_device_name;
ranges = new_ranges;
landscape = dev_mode.dmOrientation == DMORIENT_LANDSCAPE;

View File

@ -84,7 +84,7 @@ class PrintSettings {
void Init(HDC hdc,
const DEVMODE& dev_mode,
const PageRanges& new_ranges,
const std::wstring& new_device_name,
const CefString& new_device_name,
bool selection_only,
bool to_file);
#endif
@ -102,11 +102,11 @@ class PrintSettings {
// output.
bool Equals(const PrintSettings& rhs) const;
const std::wstring& printer_name() const { return printer_name_; }
void set_device_name(const std::wstring& device_name) {
const CefString& printer_name() const { return printer_name_; }
void set_device_name(const CefString& device_name) {
device_name_ = device_name;
}
const std::wstring& device_name() const { return device_name_; }
const CefString& device_name() const { return device_name_; }
int dpi() const { return dpi_; }
const PageSetup& page_setup_pixels() const { return page_setup_pixels_; }
@ -160,10 +160,10 @@ class PrintSettings {
// Settings that can't be changed without side-effects.
// Printer name as shown to the user.
std::wstring printer_name_;
CefString printer_name_;
// Printer device name as opened by the OS.
std::wstring device_name_;
CefString device_name_;
// Page setup in pixel units, dpi adjusted.
PageSetup page_setup_pixels_;

View File

@ -176,7 +176,7 @@ PrintingContext::Result PrintingContext::Init() {
TCHAR printername[512];
DWORD size = sizeof(printername)-1;
if(GetDefaultPrinter(printername, &size)) {
return Init(std::wstring(printername), false);
return Init(CefString(printername), false);
}
return FAILED;
}
@ -186,13 +186,14 @@ PrintingContext::Result PrintingContext::InitWithSettings(
DCHECK(!in_print_job_);
settings_ = settings;
return Init(settings_.device_name().c_str(), true);
return Init(settings_.device_name(), true);
}
PrintingContext::Result PrintingContext::Init(const std::wstring& device_name,
PrintingContext::Result PrintingContext::Init(const CefString& device_name,
bool adjust_dev_mode) {
HANDLE printer;
if (!OpenPrinter(const_cast<wchar_t*>(device_name.c_str()),
std::wstring deviceNameStr = device_name;
if (!OpenPrinter(const_cast<wchar_t*>(deviceNameStr.c_str()),
&printer,
NULL))
return FAILED;
@ -224,7 +225,7 @@ void PrintingContext::ResetSettings() {
}
PrintingContext::Result PrintingContext::NewDocument(
const std::wstring& document_name) {
const CefString& document_name) {
DCHECK(!in_print_job_);
if (!hdc_)
return OnError();
@ -239,7 +240,8 @@ PrintingContext::Result PrintingContext::NewDocument(
return OnError();
DOCINFO di = { sizeof(DOCINFO) };
di.lpszDocName = document_name.c_str();
std::wstring documentNameStr = document_name;
di.lpszDocName = documentNameStr.c_str();
wchar_t szFileName[MAX_PATH] = L"";
if (settings_.to_file) {
@ -343,7 +345,7 @@ BOOL PrintingContext::AbortProc(HDC hdc, int nCode) {
}
bool PrintingContext::InitializeSettings(const DEVMODE& dev_mode,
const std::wstring& new_device_name,
const CefString& new_device_name,
const PRINTPAGERANGE* ranges,
int number_ranges,
bool selection_only,
@ -389,7 +391,7 @@ bool PrintingContext::InitializeSettings(const DEVMODE& dev_mode,
}
bool PrintingContext::GetPrinterSettings(HANDLE printer,
const std::wstring& device_name,
const CefString& device_name,
bool adjust_dev_mode) {
DCHECK(!in_print_job_);
scoped_array<uint8> buffer;
@ -451,9 +453,10 @@ bool PrintingContext::GetPrinterSettings(HANDLE printer,
return false;
}
bool PrintingContext::AllocateContext(const std::wstring& printer_name,
bool PrintingContext::AllocateContext(const CefString& printer_name,
const DEVMODE* dev_mode) {
hdc_ = CreateDC(L"WINSPOOL", printer_name.c_str(), NULL, dev_mode);
std::wstring printerNameStr = printer_name;
hdc_ = CreateDC(L"WINSPOOL", printerNameStr.c_str(), NULL, dev_mode);
DCHECK(hdc_);
return hdc_ != NULL;
}

View File

@ -53,7 +53,7 @@ class PrintingContext {
// like IPC message processing! Some printers have side-effects on this call
// like virtual printers that ask the user for the path of the saved document;
// for example a PDF printer.
Result NewDocument(const std::wstring& document_name);
Result NewDocument(const CefString& document_name);
// Starts a new page.
Result NewPage();
@ -94,7 +94,7 @@ class PrintingContext {
// Reads the settings from the selected device context. Updates settings_ and
// its margins.
bool InitializeSettings(const DEVMODE& dev_mode,
const std::wstring& new_device_name,
const CefString& new_device_name,
const PRINTPAGERANGE* ranges,
int number_ranges,
bool selection_only,
@ -103,18 +103,18 @@ class PrintingContext {
// Retrieves the printer's default low-level settings. hdc_ is allocated with
// this call.
bool GetPrinterSettings(HANDLE printer,
const std::wstring& device_name,
const CefString& device_name,
bool adjust_dev_mode);
// Allocates the HDC for a specific DEVMODE.
bool AllocateContext(const std::wstring& printer_name,
bool AllocateContext(const CefString& printer_name,
const DEVMODE* dev_mode);
// Updates printer dev_mode with settings_
void PrintingContext::AdjustDevMode(DEVMODE& dev_mode);
// Initializes the hdc_ either with setting_ or with just printer defaults.
Result Init(const std::wstring& device_name, bool adjust_dev_mode);
Result Init(const CefString& device_name, bool adjust_dev_mode);
// Parses the result of a PRINTDLGEX result.
Result ParseDialogResultEx(const PRINTDLGEX& dialog_options);

View File

@ -6,7 +6,6 @@
#include "browser_webkit_glue.h"
#include "base/logging.h"
#include "base/utf_string_conversions.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_util.h"
#include "net/url_request/url_request.h"
@ -25,30 +24,30 @@ CefRequestImpl::CefRequestImpl()
{
}
std::wstring CefRequestImpl::GetURL()
CefString CefRequestImpl::GetURL()
{
Lock();
std::wstring url = url_;
CefString url = url_;
Unlock();
return url;
}
void CefRequestImpl::SetURL(const std::wstring& url)
void CefRequestImpl::SetURL(const CefString& url)
{
Lock();
url_ = url;
Unlock();
}
std::wstring CefRequestImpl::GetMethod()
CefString CefRequestImpl::GetMethod()
{
Lock();
std::wstring method = method_;
CefString method = method_;
Unlock();
return method;
}
void CefRequestImpl::SetMethod(const std::wstring& method)
void CefRequestImpl::SetMethod(const CefString& method)
{
Lock();
method_ = method;
@ -84,8 +83,8 @@ void CefRequestImpl::SetHeaderMap(const HeaderMap& headerMap)
Unlock();
}
void CefRequestImpl::Set(const std::wstring& url,
const std::wstring& method,
void CefRequestImpl::Set(const CefString& url,
const CefString& method,
CefRefPtr<CefPostData> postData,
const HeaderMap& headerMap)
{
@ -99,14 +98,13 @@ void CefRequestImpl::Set(const std::wstring& url,
void CefRequestImpl::Set(URLRequest* request)
{
SetURL(UTF8ToWide(request->url().spec()));
SetMethod(UTF8ToWide(request->method()));
SetURL(request->url().spec());
SetMethod(request->method());
// Transfer request headers
HeaderMap headerMap;
GetHeaderMap(request->extra_request_headers(), headerMap);
headerMap.insert(
std::make_pair(L"Referrer", UTF8ToWide(request->referrer())));
headerMap.insert(std::make_pair(L"Referrer", request->referrer()));
SetHeaderMap(headerMap);
// Transfer post data, if any
@ -123,7 +121,7 @@ void CefRequestImpl::GetHeaderMap(const net::HttpRequestHeaders& headers, Header
{
net::HttpRequestHeaders::Iterator it(headers);
do {
map[UTF8ToWide(it.name())] = UTF8ToWide(it.value());
map[it.name()] = it.value();
} while (it.GetNext());
}
@ -136,10 +134,7 @@ void CefRequestImpl::GetHeaderMap(const WebKit::WebURLRequest& request,
virtual void visitHeader(const WebKit::WebString& name,
const WebKit::WebString& value) {
map_->insert(
std::make_pair(
UTF8ToWide(webkit_glue::WebStringToStdString(name)),
UTF8ToWide(webkit_glue::WebStringToStdString(value))));
map_->insert(std::make_pair(string16(name), string16(value)));
}
private:
@ -154,11 +149,8 @@ void CefRequestImpl::SetHeaderMap(const HeaderMap& map,
WebKit::WebURLRequest& request)
{
HeaderMap::const_iterator it = map.begin();
for(; it != map.end(); ++it) {
request.setHTTPHeaderField(
webkit_glue::StdWStringToWebString(it->first.c_str()),
webkit_glue::StdWStringToWebString(it->second.c_str()));
}
for(; it != map.end(); ++it)
request.setHTTPHeaderField(string16(it->first), string16(it->second));
}
std::string CefRequestImpl::GenerateHeaders(const HeaderMap& map)
@ -168,15 +160,15 @@ std::string CefRequestImpl::GenerateHeaders(const HeaderMap& map)
for(HeaderMap::const_iterator header = map.begin();
header != map.end();
++header) {
const std::wstring& key = header->first;
const std::wstring& value = header->second;
const CefString& key = header->first;
const CefString& value = header->second;
if(!key.empty()) {
// Delimit with "\r\n".
if(!headers.empty())
headers += "\r\n";
headers += WideToUTF8(key) + ": " + WideToUTF8(value);
headers += std::string(key) + ": " + std::string(value);
}
}
@ -194,7 +186,7 @@ void CefRequestImpl::ParseHeaders(const std::string& header_str, HeaderMap& map)
void* iter = NULL;
std::string name, value;
while(headers->EnumerateHeaderLines(&iter, &name, &value))
map.insert(std::make_pair(UTF8ToWide(name), UTF8ToWide(value)));
map.insert(std::make_pair(name, value));
}
CefRefPtr<CefPostData> CefPostData::CreatePostData()
@ -351,6 +343,7 @@ CefRefPtr<CefPostDataElement> CefPostDataElement::CreatePostDataElement()
CefPostDataElementImpl::CefPostDataElementImpl()
{
type_ = PDE_TYPE_EMPTY;
memset(&data_, 0, sizeof(data_));
}
CefPostDataElementImpl::~CefPostDataElementImpl()
@ -364,31 +357,21 @@ void CefPostDataElementImpl::SetToEmpty()
if(type_ == PDE_TYPE_BYTES)
free(data_.bytes.bytes);
else if(type_ == PDE_TYPE_FILE)
free(data_.filename);
cef_string_clear(&data_.filename);
type_ = PDE_TYPE_EMPTY;
memset(&data_, 0, sizeof(data_));
Unlock();
}
void CefPostDataElementImpl::SetToFile(const std::wstring& fileName)
void CefPostDataElementImpl::SetToFile(const CefString& fileName)
{
Lock();
// Clear any data currently in the element
SetToEmpty();
// Assign the new file name
size_t size = fileName.size();
wchar_t* data = static_cast<wchar_t*>(malloc((size + 1) * sizeof(wchar_t)));
DCHECK(data != NULL);
if(data == NULL)
return;
memcpy(static_cast<void*>(data), static_cast<const void*>(fileName.c_str()),
size * sizeof(wchar_t));
data[size] = 0;
// Assign the new data
type_ = PDE_TYPE_FILE;
data_.filename = data;
cef_string_copy(fileName.c_str(), fileName.length(), &data_.filename);
Unlock();
}
@ -420,13 +403,13 @@ CefPostDataElement::Type CefPostDataElementImpl::GetType()
return type;
}
std::wstring CefPostDataElementImpl::GetFile()
CefString CefPostDataElementImpl::GetFile()
{
Lock();
DCHECK(type_ == PDE_TYPE_FILE);
std::wstring filename;
CefString filename;
if(type_ == PDE_TYPE_FILE)
filename = data_.filename;
filename.FromString(data_.filename.str, data_.filename.length, false);
Unlock();
return filename;
}
@ -484,11 +467,8 @@ void CefPostDataElementImpl::Get(net::UploadData::Element& element)
if(type_ == PDE_TYPE_BYTES) {
element.SetToBytes(static_cast<char*>(data_.bytes.bytes), data_.bytes.size);
} else if(type_ == PDE_TYPE_FILE) {
#if defined(OS_WIN)
element.SetToFilePath(FilePath(data_.filename));
#else
element.SetToFilePath(FilePath(WideToUTF8(data_.filename)));
#endif
FilePath path = FilePath(CefString(&data_.filename));
element.SetToFilePath(path);
} else {
NOTREACHED();
}
@ -504,7 +484,7 @@ void CefPostDataElementImpl::Set(const WebKit::WebHTTPBody::Element& element)
SetToBytes(element.data.size(),
static_cast<const void*>(element.data.data()));
} else if(element.type == WebKit::WebHTTPBody::Element::TypeFile) {
SetToFile(UTF8ToWide(webkit_glue::WebStringToStdString(element.filePath)));
SetToFile(string16(element.filePath));
} else {
NOTREACHED();
}
@ -522,7 +502,7 @@ void CefPostDataElementImpl::Get(WebKit::WebHTTPBody::Element& element)
static_cast<char*>(data_.bytes.bytes), data_.bytes.size);
} else if(type_ == PDE_TYPE_FILE) {
element.type = WebKit::WebHTTPBody::Element::TypeFile;
element.filePath.assign(webkit_glue::StdWStringToWebString(data_.filename));
element.filePath.assign(string16(CefString(&data_.filename)));
} else {
NOTREACHED();
}

View File

@ -20,16 +20,16 @@ public:
CefRequestImpl();
~CefRequestImpl() {}
virtual std::wstring GetURL();
virtual void SetURL(const std::wstring& url);
virtual std::wstring GetMethod();
virtual void SetMethod(const std::wstring& method);
virtual CefString GetURL();
virtual void SetURL(const CefString& url);
virtual CefString GetMethod();
virtual void SetMethod(const CefString& method);
virtual CefRefPtr<CefPostData> GetPostData();
virtual void SetPostData(CefRefPtr<CefPostData> postData);
virtual void GetHeaderMap(HeaderMap& headerMap);
virtual void SetHeaderMap(const HeaderMap& headerMap);
virtual void Set(const std::wstring& url,
const std::wstring& method,
virtual void Set(const CefString& url,
const CefString& method,
CefRefPtr<CefPostData> postData,
const HeaderMap& headerMap);
@ -46,8 +46,8 @@ public:
static void ParseHeaders(const std::string& header_str, HeaderMap& map);
protected:
std::wstring url_;
std::wstring method_;
CefString url_;
CefString method_;
CefRefPtr<CefPostData> postdata_;
HeaderMap headermap_;
};
@ -82,10 +82,10 @@ public:
~CefPostDataElementImpl();
virtual void SetToEmpty();
virtual void SetToFile(const std::wstring& fileName);
virtual void SetToFile(const CefString& fileName);
virtual void SetToBytes(size_t size, const void* bytes);
virtual Type GetType();
virtual std::wstring GetFile();
virtual CefString GetFile();
virtual size_t GetBytesCount();
virtual size_t GetBytes(size_t size, void* bytes);
@ -103,7 +103,7 @@ protected:
void* bytes;
size_t size;
} bytes;
wchar_t* filename;
cef_string_t filename;
} data_;
};

View File

@ -6,7 +6,6 @@
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/message_loop.h"
#include "base/utf_string_conversions.h"
#include "googleurl/src/url_util.h"
#include "net/base/completion_callback.h"
#include "net/base/io_buffer.h"
@ -187,13 +186,13 @@ private:
static_cast<CefRequestImpl*>(req.get())->Set(owner_->request());
owner_->handler_->Cancel();
std::wstring mime_type;
CefString mime_type;
int response_length = 0;
// handler should complete content generation in ProcessRequest
bool res = owner_->handler_->ProcessRequest(req, mime_type,
&response_length);
if (res) {
owner_->mime_type_ = WideToUTF8(mime_type);
owner_->mime_type_ = mime_type;
owner_->response_length_ = response_length;
}
//////////////////////////////////////////////////////////////////////////
@ -390,8 +389,8 @@ private:
std::string host_name_;
};
bool CefRegisterScheme(const std::wstring& scheme_name,
const std::wstring& host_name,
bool CefRegisterScheme(const CefString& scheme_name,
const CefString& host_name,
CefRefPtr<CefSchemeHandlerFactory> factory)
{
// Verify that the context is already initialized
@ -403,8 +402,7 @@ bool CefRegisterScheme(const std::wstring& scheme_name,
// will call AddRef() and Release() on the object in debug mode, resulting in
// the object being deleted if it doesn't already have a reference.
CefRefPtr<SchemeRequestJobWrapper> wrapper(
new SchemeRequestJobWrapper(WideToUTF8(scheme_name),
WideToUTF8(host_name), factory));
new SchemeRequestJobWrapper(scheme_name, host_name, factory));
CefThread::PostTask(CefThread::UI, FROM_HERE, NewRunnableMethod(wrapper.get(),
&SchemeRequestJobWrapper::RegisterScheme));

View File

@ -3,24 +3,18 @@
// can be found in the LICENSE file.
#include "stream_impl.h"
#include "base/logging.h"
#include "base/utf_string_conversions.h"
// Static functions
CefRefPtr<CefStreamReader> CefStreamReader::CreateForFile(
const std::wstring& fileName)
const CefString& fileName)
{
CefRefPtr<CefStreamReader> reader;
#if defined(OS_WIN)
FILE *f = _wfopen(fileName.c_str(), L"rb");
#else
FILE *f = fopen(WideToUTF8(fileName).c_str(), "rb");
#endif
if(f)
reader = new CefFileReader(f, true);
std::string fileNameStr = fileName;
FILE *file = fopen(fileNameStr.c_str(), "rb");
if(file)
reader = new CefFileReader(file, true);
return reader;
}
@ -46,15 +40,12 @@ CefRefPtr<CefStreamReader> CefStreamReader::CreateForHandler(
}
CefRefPtr<CefStreamWriter> CefStreamWriter::CreateForFile(
const std::wstring& fileName)
const CefString& fileName)
{
DCHECK(!fileName.empty());
CefRefPtr<CefStreamWriter> writer;
#if defined(OS_WIN)
FILE* file = _wfopen(fileName.c_str(), L"wb");
#else
FILE* file = fopen(WideToUTF8(fileName).c_str(), "wb");
#endif
std::string fileNameStr = fileName;
FILE *file = fopen(fileNameStr.c_str(), "wb");
if(file)
writer = new CefFileWriter(file, true);
return writer;

View File

@ -6,7 +6,6 @@
#include "cef_context.h"
#include "tracker.h"
#include "base/lazy_instance.h"
#include "base/utf_string_conversions.h"
#include "third_party/WebKit/WebKit/chromium/public/WebKit.h"
#include "third_party/WebKit/WebKit/chromium/public/WebScriptController.h"
@ -56,26 +55,24 @@ static void TrackDestructor(v8::Persistent<v8::Value> object,
// Convert a wide string to a V8 string.
static v8::Handle<v8::String> GetV8String(const std::wstring& str)
static v8::Handle<v8::String> GetV8String(const CefString& str)
{
std::string tmpStr = WideToUTF8(str);
std::string tmpStr = str;
return v8::String::New(tmpStr.c_str(), tmpStr.length());
}
// Convert a V8 string to a wide string.
static std::wstring GetWString(v8::Handle<v8::String> str)
// Convert a V8 string to a UTF8 string.
static std::string GetString(v8::Handle<v8::String> str)
{
// Allocate enough space for a worst-case conversion.
size_t len = str->Length()*4;
char* buf = new char[len];
int newlen = str->WriteUtf8(buf, len);
std::wstring value;
UTF8ToWide(buf, newlen, &value);
int len = str->Utf8Length();
char* buf = new char[len+1];
str->WriteUtf8(buf, len+1);
std::string ret(buf, len);
delete [] buf;
return value;
return ret;
}
// V8 function callback
static v8::Handle<v8::Value> FunctionCallbackImpl(const v8::Arguments& args)
{
@ -87,11 +84,11 @@ static v8::Handle<v8::Value> FunctionCallbackImpl(const v8::Arguments& args)
for(int i = 0; i < args.Length(); i++)
params.push_back(new CefV8ValueImpl(args[i]));
std::wstring func_name =
GetWString(v8::Handle<v8::String>::Cast(args.Callee()->GetName()));
CefString func_name =
GetString(v8::Handle<v8::String>::Cast(args.Callee()->GetName()));
CefRefPtr<CefV8Value> object = new CefV8ValueImpl(args.This());
CefRefPtr<CefV8Value> retval;
std::wstring exception;
CefString exception;
v8::Handle<v8::Value> value = v8::Null();
if(handler->Execute(func_name, object, params, retval, exception)) {
@ -142,8 +139,8 @@ private:
CefV8Handler* handler_;
};
bool CefRegisterExtension(const std::wstring& extension_name,
const std::wstring& javascript_code,
bool CefRegisterExtension(const CefString& extension_name,
const CefString& javascript_code,
CefRefPtr<CefV8Handler> handler)
{
// Verify that the context is already initialized
@ -153,9 +150,9 @@ bool CefRegisterExtension(const std::wstring& extension_name,
if(!handler.get())
return false;
TrackString* name = new TrackString(WideToUTF8(extension_name));
TrackString* name = new TrackString(extension_name);
TrackAdd(name);
TrackString* code = new TrackString(WideToUTF8(javascript_code));
TrackString* code = new TrackString(javascript_code);
TrackAdd(name);
ExtensionWrapper* wrapper = new ExtensionWrapper(name->GetString(),
@ -205,7 +202,7 @@ CefRefPtr<CefV8Value> CefV8Value::CreateDouble(double value)
}
// static
CefRefPtr<CefV8Value> CefV8Value::CreateString(const std::wstring& value)
CefRefPtr<CefV8Value> CefV8Value::CreateString(const CefString& value)
{
v8::HandleScope handle_scope;
return new CefV8ValueImpl(GetV8String(value));
@ -244,7 +241,7 @@ CefRefPtr<CefV8Value> CefV8Value::CreateArray()
}
// static
CefRefPtr<CefV8Value> CefV8Value::CreateFunction(const std::wstring& name,
CefRefPtr<CefV8Value> CefV8Value::CreateFunction(const CefString& name,
CefRefPtr<CefV8Handler> handler)
{
v8::HandleScope handle_scope;
@ -324,9 +321,10 @@ v8::Handle<v8::Value> CefV8ValueImpl::GetValue()
return rv;
}
bool CefV8ValueImpl::IsReservedKey(const std::wstring& key)
bool CefV8ValueImpl::IsReservedKey(const CefString& key)
{
return (key.find(L"Cef::") == 0 || key.find(L"v8::") == 0);
std::string str = key;
return (str.find("Cef::") == 0 || str.find("v8::") == 0);
}
bool CefV8ValueImpl::IsUndefined()
@ -441,17 +439,17 @@ double CefV8ValueImpl::GetDoubleValue()
return rv;
}
std::wstring CefV8ValueImpl::GetStringValue()
CefString CefV8ValueImpl::GetStringValue()
{
std::wstring rv;
CefString rv;
Lock();
v8::HandleScope handle_scope;
rv = GetWString(v8_value_->ToString());
rv = GetString(v8_value_->ToString());
Unlock();
return rv;
}
bool CefV8ValueImpl::HasValue(const std::wstring& key)
bool CefV8ValueImpl::HasValue(const CefString& key)
{
if(IsReservedKey(key))
return false;
@ -480,7 +478,7 @@ bool CefV8ValueImpl::HasValue(int index)
return rv;
}
bool CefV8ValueImpl::DeleteValue(const std::wstring& key)
bool CefV8ValueImpl::DeleteValue(const CefString& key)
{
if(IsReservedKey(key))
return false;
@ -509,7 +507,7 @@ bool CefV8ValueImpl::DeleteValue(int index)
return rv;
}
CefRefPtr<CefV8Value> CefV8ValueImpl::GetValue(const std::wstring& key)
CefRefPtr<CefV8Value> CefV8ValueImpl::GetValue(const CefString& key)
{
if(IsReservedKey(key))
return false;
@ -538,7 +536,7 @@ CefRefPtr<CefV8Value> CefV8ValueImpl::GetValue(int index)
return rv;
}
bool CefV8ValueImpl::SetValue(const std::wstring& key,
bool CefV8ValueImpl::SetValue(const CefString& key,
CefRefPtr<CefV8Value> value)
{
if(IsReservedKey(key))
@ -574,7 +572,7 @@ bool CefV8ValueImpl::SetValue(int index, CefRefPtr<CefV8Value> value)
return rv;
}
bool CefV8ValueImpl::GetKeys(std::vector<std::wstring>& keys)
bool CefV8ValueImpl::GetKeys(std::vector<CefString>& keys)
{
bool rv = false;
Lock();
@ -585,7 +583,7 @@ bool CefV8ValueImpl::GetKeys(std::vector<std::wstring>& keys)
uint32_t len = arr_keys->Length();
for(uint32_t i = 0; i < len; ++i) {
v8::Local<v8::Value> value = arr_keys->Get(v8::Integer::New(i));
std::wstring str = GetWString(value->ToString());
CefString str = GetString(value->ToString());
if(!IsReservedKey(str))
keys.push_back(str);
}
@ -624,15 +622,15 @@ int CefV8ValueImpl::GetArrayLength()
return rv;
}
std::wstring CefV8ValueImpl::GetFunctionName()
CefString CefV8ValueImpl::GetFunctionName()
{
std::wstring rv;
CefString rv;
Lock();
if(v8_value_->IsFunction()) {
v8::HandleScope handle_scope;
v8::Local<v8::Object> obj = v8_value_->ToObject();
v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(obj);
rv = GetWString(v8::Handle<v8::String>::Cast(func->GetName()));
rv = GetString(v8::Handle<v8::String>::Cast(func->GetName()));
}
Unlock();
return rv;
@ -656,7 +654,7 @@ CefRefPtr<CefV8Handler> CefV8ValueImpl::GetFunctionHandler()
bool CefV8ValueImpl::ExecuteFunction(CefRefPtr<CefV8Value> object,
const CefV8ValueList& arguments,
CefRefPtr<CefV8Value>& retval,
std::wstring& exception)
CefString& exception)
{
bool rv = false;
Lock();
@ -682,7 +680,7 @@ bool CefV8ValueImpl::ExecuteFunction(CefRefPtr<CefV8Value> object,
v8::TryCatch try_catch;
v8::Local<v8::Value> func_rv = func->Call(recv, argc, argv);
if (try_catch.HasCaught())
exception = GetWString(try_catch.Message()->Get());
exception = GetString(try_catch.Message()->Get());
else
retval = new CefV8ValueImpl(func_rv);

View File

@ -20,7 +20,7 @@ public:
bool Attach(v8::Handle<v8::Value> value, CefTrackObject* tracker = NULL);
void Detach();
v8::Handle<v8::Value> GetValue();
bool IsReservedKey(const std::wstring& key);
bool IsReservedKey(const CefString& key);
virtual bool IsUndefined();
virtual bool IsNull();
@ -34,24 +34,24 @@ public:
virtual bool GetBoolValue();
virtual int GetIntValue();
virtual double GetDoubleValue();
virtual std::wstring GetStringValue();
virtual bool HasValue(const std::wstring& key);
virtual CefString GetStringValue();
virtual bool HasValue(const CefString& key);
virtual bool HasValue(int index);
virtual bool DeleteValue(const std::wstring& key);
virtual bool DeleteValue(const CefString& key);
virtual bool DeleteValue(int index);
virtual CefRefPtr<CefV8Value> GetValue(const std::wstring& key);
virtual CefRefPtr<CefV8Value> GetValue(const CefString& key);
virtual CefRefPtr<CefV8Value> GetValue(int index);
virtual bool SetValue(const std::wstring& key, CefRefPtr<CefV8Value> value);
virtual bool SetValue(const CefString& key, CefRefPtr<CefV8Value> value);
virtual bool SetValue(int index, CefRefPtr<CefV8Value> value);
virtual bool GetKeys(std::vector<std::wstring>& keys);
virtual bool GetKeys(std::vector<CefString>& keys);
virtual CefRefPtr<CefBase> GetUserData();
virtual int GetArrayLength();
virtual std::wstring GetFunctionName();
virtual CefString GetFunctionName();
virtual CefRefPtr<CefV8Handler> GetFunctionHandler();
virtual bool ExecuteFunction(CefRefPtr<CefV8Value> object,
const CefV8ValueList& arguments,
CefRefPtr<CefV8Value>& retval,
std::wstring& exception);
CefString& exception);
protected:
v8::Persistent<v8::Value> v8_value_;

View File

@ -5,13 +5,13 @@
#ifndef _WEBWIDGET_HOST_H
#define _WEBWIDGET_HOST_H
#include "include/cef_string.h"
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
#include "gfx/native_widget_types.h"
#include "gfx/rect.h"
#include "skia/ext/platform_canvas.h"
#include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h"
#include <string>
namespace gfx {
class Rect;
@ -70,7 +70,7 @@ class WebWidgetHost {
void PaintRect(const gfx::Rect& rect);
void SetTooltipText(const std::wstring& tooltip_text);
void SetTooltipText(const CefString& tooltip_text);
protected:
WebWidgetHost();
@ -144,6 +144,7 @@ class WebWidgetHost {
#if defined(OS_WIN)
bool track_mouse_leave_;
std::wstring tooltip_text_;
#endif
#if defined(TOOLKIT_USES_GTK)
@ -154,7 +155,6 @@ class WebWidgetHost {
WebKit::WebKeyboardEvent last_key_event_;
gfx::NativeView tooltip_view_;
std::wstring tooltip_text_;
bool tooltip_showing_;
#ifndef NDEBUG

View File

@ -214,7 +214,7 @@ void WebWidgetHost::Paint() {
}
}
void WebWidgetHost::SetTooltipText(const std::wstring& tooltip_text) {
void WebWidgetHost::SetTooltipText(const std::string& tooltip_text) {
// TODO(port): Implement this method.
}

View File

@ -372,7 +372,8 @@ void WebWidgetHost::OnNotify(WPARAM wparam, NMHDR* header) {
}
}
void WebWidgetHost::SetTooltipText(const std::wstring& new_tooltip_text) {
void WebWidgetHost::SetTooltipText(const CefString& tooltip_text) {
std::wstring new_tooltip_text(tooltip_text);
if (new_tooltip_text != tooltip_text_) {
tooltip_text_ = new_tooltip_text;

View File

@ -4,14 +4,13 @@
#include "xml_reader_impl.h"
#include "base/logging.h"
#include "base/utf_string_conversions.h"
// Static functions
//static
CefRefPtr<CefXmlReader> CefXmlReader::Create(CefRefPtr<CefStreamReader> stream,
EncodingType encodingType,
const std::wstring& URI)
const CefString& URI)
{
CefRefPtr<CefXmlReaderImpl> impl(new CefXmlReaderImpl());
if (!impl->Initialize(stream, encodingType, URI))
@ -55,14 +54,12 @@ void XMLCALL xml_error_callback(void *arg, const char *msg,
if (!msg)
return;
std::wstring error_str;
UTF8ToWide(msg, strlen(msg), &error_str);
std::string error_str(msg);
if (!error_str.empty() && error_str[error_str.length()-1] == '\n')
error_str.resize(error_str.length()-1);
std::wstringstream ss;
ss << error_str << L", line " << xmlTextReaderLocatorLineNumber(locator);
std::stringstream ss;
ss << error_str << ", line " << xmlTextReaderLocatorLineNumber(locator);
LOG(INFO) << ss.str();
@ -83,14 +80,12 @@ void XMLCALL xml_structured_error_callback(void *userData, xmlErrorPtr error)
if (!error->message)
return;
std::wstring error_str;
UTF8ToWide(error->message, strlen(error->message), &error_str);
std::string error_str(error->message);
if (!error_str.empty() && error_str[error_str.length()-1] == '\n')
error_str.resize(error_str.length()-1);
std::wstringstream ss;
ss << error_str << L", line " << error->line;
std::stringstream ss;
ss << error_str << ", line " << error->line;
LOG(INFO) << ss.str();
@ -98,14 +93,13 @@ void XMLCALL xml_structured_error_callback(void *userData, xmlErrorPtr error)
impl->AppendError(ss.str());
}
std::wstring xmlCharToWString(const xmlChar* xmlStr, bool free)
CefString xmlCharToString(const xmlChar* xmlStr, bool free)
{
if (!xmlStr)
return std::wstring();
return CefString();
const char* str = reinterpret_cast<const char*>(xmlStr);
std::wstring wstr;
UTF8ToWide(str, strlen(str), &wstr);
CefString wstr = std::string(str);
if (free)
xmlFree(const_cast<xmlChar*>(xmlStr));
@ -135,7 +129,7 @@ CefXmlReaderImpl::~CefXmlReaderImpl()
bool CefXmlReaderImpl::Initialize(CefRefPtr<CefStreamReader> stream,
EncodingType encodingType,
const std::wstring& URI)
const CefString& URI)
{
xmlCharEncoding enc = XML_CHAR_ENCODING_NONE;
switch (encodingType) {
@ -164,7 +158,8 @@ bool CefXmlReaderImpl::Initialize(CefRefPtr<CefStreamReader> stream,
input_buffer->readcallback = xml_read_callback;
// Create the text reader.
reader_ = xmlNewTextReader(input_buffer, WideToUTF8(URI).c_str());
std::string uriStr = URI;
reader_ = xmlNewTextReader(input_buffer, uriStr.c_str());
if (!reader_) {
// Free the input buffer.
xmlFreeParserInputBuffer(input_buffer);
@ -209,10 +204,10 @@ bool CefXmlReaderImpl::HasError()
return !error_buf_.str().empty();
}
std::wstring CefXmlReaderImpl::GetError()
CefString CefXmlReaderImpl::GetError()
{
if (!VerifyContext())
return std::wstring();
return CefString();
return error_buf_.str();
}
@ -259,52 +254,52 @@ int CefXmlReaderImpl::GetDepth()
return xmlTextReaderDepth(reader_);
}
std::wstring CefXmlReaderImpl::GetLocalName()
CefString CefXmlReaderImpl::GetLocalName()
{
if (!VerifyContext())
return std::wstring();
return CefString();
return xmlCharToWString(xmlTextReaderConstLocalName(reader_), false);
return xmlCharToString(xmlTextReaderConstLocalName(reader_), false);
}
std::wstring CefXmlReaderImpl::GetPrefix()
CefString CefXmlReaderImpl::GetPrefix()
{
if (!VerifyContext())
return std::wstring();
return CefString();
return xmlCharToWString(xmlTextReaderConstPrefix(reader_), false);
return xmlCharToString(xmlTextReaderConstPrefix(reader_), false);
}
std::wstring CefXmlReaderImpl::GetQualifiedName()
CefString CefXmlReaderImpl::GetQualifiedName()
{
if (!VerifyContext())
return std::wstring();
return CefString();
return xmlCharToWString(xmlTextReaderConstName(reader_), false);
return xmlCharToString(xmlTextReaderConstName(reader_), false);
}
std::wstring CefXmlReaderImpl::GetNamespaceURI()
CefString CefXmlReaderImpl::GetNamespaceURI()
{
if (!VerifyContext())
return std::wstring();
return CefString();
return xmlCharToWString(xmlTextReaderConstNamespaceUri(reader_), false);
return xmlCharToString(xmlTextReaderConstNamespaceUri(reader_), false);
}
std::wstring CefXmlReaderImpl::GetBaseURI()
CefString CefXmlReaderImpl::GetBaseURI()
{
if (!VerifyContext())
return std::wstring();
return CefString();
return xmlCharToWString(xmlTextReaderConstBaseUri(reader_), false);
return xmlCharToString(xmlTextReaderConstBaseUri(reader_), false);
}
std::wstring CefXmlReaderImpl::GetXmlLang()
CefString CefXmlReaderImpl::GetXmlLang()
{
if (!VerifyContext())
return std::wstring();
return CefString();
return xmlCharToWString(xmlTextReaderConstXmlLang(reader_), false);
return xmlCharToString(xmlTextReaderConstXmlLang(reader_), false);
}
bool CefXmlReaderImpl::IsEmptyElement()
@ -328,19 +323,19 @@ bool CefXmlReaderImpl::HasValue()
}
}
std::wstring CefXmlReaderImpl::GetValue()
CefString CefXmlReaderImpl::GetValue()
{
if (!VerifyContext())
return std::wstring();
return CefString();
if (xmlTextReaderNodeType(reader_) == XML_READER_TYPE_ENTITY_REFERENCE) {
// Provide special handling to return entity reference values.
xmlNodePtr node = xmlTextReaderCurrentNode(reader_);
if (node->content != NULL)
return xmlCharToWString(node->content, false);
return NULL;
return xmlCharToString(node->content, false);
return CefString();
} else {
return xmlCharToWString(xmlTextReaderConstValue(reader_), false);
return xmlCharToString(xmlTextReaderConstValue(reader_), false);
}
}
@ -360,50 +355,50 @@ size_t CefXmlReaderImpl::GetAttributeCount()
return xmlTextReaderAttributeCount(reader_);
}
std::wstring CefXmlReaderImpl::GetAttribute(int index)
CefString CefXmlReaderImpl::GetAttribute(int index)
{
if (!VerifyContext())
return std::wstring();
return CefString();
return xmlCharToWString(xmlTextReaderGetAttributeNo(reader_, index), true);
return xmlCharToString(xmlTextReaderGetAttributeNo(reader_, index), true);
}
std::wstring CefXmlReaderImpl::GetAttribute(const std::wstring& qualifiedName)
CefString CefXmlReaderImpl::GetAttribute(const CefString& qualifiedName)
{
if (!VerifyContext())
return std::wstring();
return CefString();
std::string qualifiedNameStr = WideToUTF8(qualifiedName);
return xmlCharToWString(xmlTextReaderGetAttribute(reader_,
std::string qualifiedNameStr = qualifiedName;
return xmlCharToString(xmlTextReaderGetAttribute(reader_,
BAD_CAST qualifiedNameStr.c_str()), true);
}
std::wstring CefXmlReaderImpl::GetAttribute(const std::wstring& localName,
const std::wstring& namespaceURI)
CefString CefXmlReaderImpl::GetAttribute(const CefString& localName,
const CefString& namespaceURI)
{
if (!VerifyContext())
return std::wstring();
return CefString();
std::string localNameStr = WideToUTF8(localName);
std::string namespaceURIStr = WideToUTF8(namespaceURI);
return xmlCharToWString(xmlTextReaderGetAttributeNs(reader_,
std::string localNameStr = localName;
std::string namespaceURIStr = namespaceURI;
return xmlCharToString(xmlTextReaderGetAttributeNs(reader_,
BAD_CAST localNameStr.c_str(), BAD_CAST namespaceURIStr.c_str()), true);
}
std::wstring CefXmlReaderImpl::GetInnerXml()
CefString CefXmlReaderImpl::GetInnerXml()
{
if (!VerifyContext())
return std::wstring();
return CefString();
return xmlCharToWString(xmlTextReaderReadInnerXml(reader_), true);
return xmlCharToString(xmlTextReaderReadInnerXml(reader_), true);
}
std::wstring CefXmlReaderImpl::GetOuterXml()
CefString CefXmlReaderImpl::GetOuterXml()
{
if (!VerifyContext())
return std::wstring();
return CefString();
return xmlCharToWString(xmlTextReaderReadOuterXml(reader_), true);
return xmlCharToString(xmlTextReaderReadOuterXml(reader_), true);
}
int CefXmlReaderImpl::GetLineNumber()
@ -422,24 +417,24 @@ bool CefXmlReaderImpl::MoveToAttribute(int index)
return xmlTextReaderMoveToAttributeNo(reader_, index) == 1 ? true : false;
}
bool CefXmlReaderImpl::MoveToAttribute(const std::wstring& qualifiedName)
bool CefXmlReaderImpl::MoveToAttribute(const CefString& qualifiedName)
{
if (!VerifyContext())
return false;
std::string qualifiedNameStr = WideToUTF8(qualifiedName);
std::string qualifiedNameStr = qualifiedName;
return xmlTextReaderMoveToAttribute(reader_,
BAD_CAST qualifiedNameStr.c_str()) == 1 ? true : false;
}
bool CefXmlReaderImpl::MoveToAttribute(const std::wstring& localName,
const std::wstring& namespaceURI)
bool CefXmlReaderImpl::MoveToAttribute(const CefString& localName,
const CefString& namespaceURI)
{
if (!VerifyContext())
return false;
std::string localNameStr = WideToUTF8(localName);
std::string namespaceURIStr = WideToUTF8(namespaceURI);
std::string localNameStr = localName;
std::string namespaceURIStr = namespaceURI;
return xmlTextReaderMoveToAttributeNs(reader_,
BAD_CAST localNameStr.c_str(), BAD_CAST namespaceURIStr.c_str()) == 1 ?
true : false;
@ -469,7 +464,7 @@ bool CefXmlReaderImpl::MoveToCarryingElement()
return xmlTextReaderMoveToElement(reader_) == 1 ? true : false;
}
void CefXmlReaderImpl::AppendError(const std::wstring& error_str)
void CefXmlReaderImpl::AppendError(const CefString& error_str)
{
if (!error_buf_.str().empty())
error_buf_ << L"\n";

View File

@ -19,42 +19,42 @@ public:
// Initialize the reader context.
bool Initialize(CefRefPtr<CefStreamReader> stream,
EncodingType encodingType, const std::wstring& URI);
EncodingType encodingType, const CefString& URI);
virtual bool MoveToNextNode();
virtual bool Close();
virtual bool HasError();
virtual std::wstring GetError();
virtual CefString GetError();
virtual NodeType GetType();
virtual int GetDepth();
virtual std::wstring GetLocalName();
virtual std::wstring GetPrefix();
virtual std::wstring GetQualifiedName();
virtual std::wstring GetNamespaceURI();
virtual std::wstring GetBaseURI();
virtual std::wstring GetXmlLang();
virtual CefString GetLocalName();
virtual CefString GetPrefix();
virtual CefString GetQualifiedName();
virtual CefString GetNamespaceURI();
virtual CefString GetBaseURI();
virtual CefString GetXmlLang();
virtual bool IsEmptyElement();
virtual bool HasValue();
virtual std::wstring GetValue();
virtual CefString GetValue();
virtual bool HasAttributes();
virtual size_t GetAttributeCount();
virtual std::wstring GetAttribute(int index);
virtual std::wstring GetAttribute(const std::wstring& qualifiedName);
virtual std::wstring GetAttribute(const std::wstring& localName,
const std::wstring& namespaceURI);
virtual std::wstring GetInnerXml();
virtual std::wstring GetOuterXml();
virtual CefString GetAttribute(int index);
virtual CefString GetAttribute(const CefString& qualifiedName);
virtual CefString GetAttribute(const CefString& localName,
const CefString& namespaceURI);
virtual CefString GetInnerXml();
virtual CefString GetOuterXml();
virtual int GetLineNumber();
virtual bool MoveToAttribute(int index);
virtual bool MoveToAttribute(const std::wstring& qualifiedName);
virtual bool MoveToAttribute(const std::wstring& localName,
const std::wstring& namespaceURI);
virtual bool MoveToAttribute(const CefString& qualifiedName);
virtual bool MoveToAttribute(const CefString& localName,
const CefString& namespaceURI);
virtual bool MoveToFirstAttribute();
virtual bool MoveToNextAttribute();
virtual bool MoveToCarryingElement();
// Add another line to the error string.
void AppendError(const std::wstring& error_str);
void AppendError(const CefString& error_str);
// Verify that the reader exists and is being accessed from the correct
// thread.
@ -64,7 +64,7 @@ protected:
PlatformThreadId supported_thread_id_;
CefRefPtr<CefStreamReader> stream_;
xmlTextReaderPtr reader_;
std::wstringstream error_buf_;
std::stringstream error_buf_;
};
#endif // _XML_READER_IMPL_H

View File

@ -4,7 +4,6 @@
#include "zip_reader_impl.h"
#include "base/logging.h"
#include "base/utf_string_conversions.h"
#include <time.h>
// Static functions
@ -146,7 +145,7 @@ bool CefZipReaderImpl::MoveToNextFile()
return (unzGoToNextFile(reader_) == UNZ_OK);
}
bool CefZipReaderImpl::MoveToFile(const std::wstring& fileName, bool caseSensitive)
bool CefZipReaderImpl::MoveToFile(const CefString& fileName, bool caseSensitive)
{
if (!VerifyContext())
return false;
@ -156,7 +155,7 @@ bool CefZipReaderImpl::MoveToFile(const std::wstring& fileName, bool caseSensiti
has_fileinfo_ = false;
std::string fileNameStr = WideToUTF8(fileName);
std::string fileNameStr = fileName;
return (unzLocateFile(reader_, fileNameStr.c_str(),
(caseSensitive ? 1 : 2)) == UNZ_OK);
}
@ -174,10 +173,10 @@ bool CefZipReaderImpl::Close()
return (result == UNZ_OK);
}
std::wstring CefZipReaderImpl::GetFileName()
CefString CefZipReaderImpl::GetFileName()
{
if (!VerifyContext() || !GetFileInfo())
return std::wstring();
return CefString();
return filename_;
}
@ -198,7 +197,7 @@ time_t CefZipReaderImpl::GetFileLastModified()
return filemodified_;
}
bool CefZipReaderImpl::OpenFile(const std::wstring& password)
bool CefZipReaderImpl::OpenFile(const CefString& password)
{
if (!VerifyContext())
return false;
@ -211,7 +210,7 @@ bool CefZipReaderImpl::OpenFile(const std::wstring& password)
if (password.empty()) {
ret = (unzOpenCurrentFile(reader_) == UNZ_OK);
} else {
std::string passwordStr = WideToUTF8(password);
std::string passwordStr = password;
ret = (unzOpenCurrentFilePassword(reader_, passwordStr.c_str()) == UNZ_OK);
}
@ -270,7 +269,7 @@ bool CefZipReaderImpl::GetFileInfo()
}
has_fileinfo_ = true;
UTF8ToWide(file_name, strlen(file_name), &filename_);
filename_ = std::string(file_name);
filesize_ = file_info.uncompressed_size;
struct tm time;

View File

@ -22,12 +22,12 @@ public:
virtual bool MoveToFirstFile();
virtual bool MoveToNextFile();
virtual bool MoveToFile(const std::wstring& fileName, bool caseSensitive);
virtual bool MoveToFile(const CefString& fileName, bool caseSensitive);
virtual bool Close();
virtual std::wstring GetFileName();
virtual CefString GetFileName();
virtual long GetFileSize();
virtual time_t GetFileLastModified();
virtual bool OpenFile(const std::wstring& password);
virtual bool OpenFile(const CefString& password);
virtual bool CloseFile();
virtual int ReadFile(void* buffer, size_t bufferSize);
virtual long Tell();
@ -44,7 +44,7 @@ protected:
unzFile reader_;
bool has_fileopen_;
bool has_fileinfo_;
std::wstring filename_;
CefString filename_;
long filesize_;
time_t filemodified_;
};

View File

@ -13,43 +13,40 @@
#include "libcef_dll/cpptoc/browser_cpptoc.h"
#include "libcef_dll/cpptoc/frame_cpptoc.h"
#include "libcef_dll/ctocpp/handler_ctocpp.h"
#include "libcef_dll/transfer_util.h"
// GLOBAL FUNCTIONS - Body may be edited by hand.
CEF_EXPORT int cef_browser_create(cef_window_info_t* windowInfo, int popup,
struct _cef_handler_t* handler, const wchar_t* url)
struct _cef_handler_t* handler, const cef_string_t* url)
{
DCHECK(windowInfo);
CefRefPtr<CefHandler> handlerPtr;
std::wstring urlStr;
CefWindowInfo wi = *windowInfo;
if(handler)
handlerPtr = CefHandlerCToCpp::Wrap(handler);
if(url)
urlStr = url;
return CefBrowser::CreateBrowser(wi, popup?true:false, handlerPtr, urlStr);
return CefBrowser::CreateBrowser(wi, popup?true:false, handlerPtr,
CefString(url));
}
CEF_EXPORT cef_browser_t* cef_browser_create_sync(cef_window_info_t* windowInfo,
int popup, struct _cef_handler_t* handler, const wchar_t* url)
int popup, struct _cef_handler_t* handler, const cef_string_t* url)
{
DCHECK(windowInfo);
CefRefPtr<CefHandler> handlerPtr;
std::wstring urlStr;
CefWindowInfo wi = *windowInfo;
if(handler)
handlerPtr = CefHandlerCToCpp::Wrap(handler);
if(url)
urlStr = url;
CefRefPtr<CefBrowser> browserPtr(
CefBrowser::CreateBrowserSync(wi, popup?true:false, handlerPtr, urlStr));
CefBrowser::CreateBrowserSync(wi, popup?true:false, handlerPtr,
CefString(url)));
if(browserPtr.get())
return CefBrowserCppToC::Wrap(browserPtr);
return NULL;
@ -193,20 +190,14 @@ struct _cef_frame_t* CEF_CALLBACK browser_get_focused_frame(
}
struct _cef_frame_t* CEF_CALLBACK browser_get_frame(struct _cef_browser_t* self,
const wchar_t* name)
const cef_string_t* name)
{
DCHECK(self);
if(!self)
return NULL;
std::wstring nameStr;
if(name)
nameStr = name;
if(nameStr.empty())
return NULL;
CefRefPtr<CefBrowser> browserPtr = CefBrowserCppToC::Get(self);
CefRefPtr<CefFrame> framePtr = browserPtr->GetFrame(nameStr);
CefRefPtr<CefFrame> framePtr = browserPtr->GetFrame(CefString(name));
if(framePtr.get())
return CefFrameCppToC::Wrap(framePtr);
return NULL;
@ -221,25 +212,19 @@ void CEF_CALLBACK browser_get_frame_names(struct _cef_browser_t* self,
return;
CefRefPtr<CefBrowser> browserPtr = CefBrowserCppToC::Get(self);
std::vector<std::wstring> stringList;
std::vector<CefString> stringList;
browserPtr->GetFrameNames(stringList);
size_t size = stringList.size();
for(size_t i = 0; i < size; ++i)
cef_string_list_append(names, stringList[i].c_str());
transfer_string_list_contents(stringList, names);
}
void CEF_CALLBACK browser_find(struct _cef_browser_t* self, int identifier,
const wchar_t* searchText, int forward, int matchCase, int findNext)
const cef_string_t* searchText, int forward, int matchCase, int findNext)
{
DCHECK(self);
if(!self)
return;
std::wstring searchTextStr;
if(searchText)
searchTextStr = searchText;
CefBrowserCppToC::Get(self)->Find(identifier, searchTextStr,
CefBrowserCppToC::Get(self)->Find(identifier, CefString(searchText),
forward?true:false, matchCase?true:false, findNext?true:false);
}

View File

@ -98,28 +98,24 @@ void CEF_CALLBACK frame_view_source(struct _cef_frame_t* self)
CefFrameCppToC::Get(self)->ViewSource();
}
cef_string_t CEF_CALLBACK frame_get_source(struct _cef_frame_t* self)
cef_string_userfree_t CEF_CALLBACK frame_get_source(struct _cef_frame_t* self)
{
DCHECK(self);
if(!self)
return NULL;
std::wstring sourceStr = CefFrameCppToC::Get(self)->GetSource();
if(!sourceStr.empty())
return cef_string_alloc(sourceStr.c_str());
return NULL;
CefString sourceStr = CefFrameCppToC::Get(self)->GetSource();
return sourceStr.DetachToUserFree();
}
cef_string_t CEF_CALLBACK frame_get_text(struct _cef_frame_t* self)
cef_string_userfree_t CEF_CALLBACK frame_get_text(struct _cef_frame_t* self)
{
DCHECK(self);
if(!self)
return NULL;
std::wstring textStr = CefFrameCppToC::Get(self)->GetText();
if(!textStr.empty())
return cef_string_alloc(textStr.c_str());
return NULL;
CefString textStr = CefFrameCppToC::Get(self)->GetText();
return textStr.DetachToUserFree();
}
void CEF_CALLBACK frame_load_request(struct _cef_frame_t* self,
@ -134,64 +130,47 @@ void CEF_CALLBACK frame_load_request(struct _cef_frame_t* self,
CefFrameCppToC::Get(self)->LoadRequest(requestPtr);
}
void CEF_CALLBACK frame_load_url(struct _cef_frame_t* self, const wchar_t* url)
void CEF_CALLBACK frame_load_url(struct _cef_frame_t* self,
const cef_string_t* url)
{
DCHECK(self);
if(!self)
return;
std::wstring urlStr;
if(url)
urlStr = url;
CefFrameCppToC::Get(self)->LoadURL(urlStr);
CefFrameCppToC::Get(self)->LoadURL(CefString(url));
}
void CEF_CALLBACK frame_load_string(struct _cef_frame_t* self,
const wchar_t* string, const wchar_t* url)
const cef_string_t* string, const cef_string_t* url)
{
DCHECK(self);
if(!self)
return;
std::wstring stringStr, urlStr;
if(string)
stringStr = string;
if(url)
urlStr = url;
CefFrameCppToC::Get(self)->LoadString(stringStr, urlStr);
CefFrameCppToC::Get(self)->LoadString(CefString(string), CefString(url));
}
void CEF_CALLBACK frame_load_stream(struct _cef_frame_t* self,
struct _cef_stream_reader_t* stream, const wchar_t* url)
struct _cef_stream_reader_t* stream, const cef_string_t* url)
{
DCHECK(self);
DCHECK(stream);
if(!self || !stream)
return;
CefRefPtr<CefStreamReader> streamPtr = CefStreamReaderCppToC::Unwrap(stream);
std::wstring urlStr;
if(url)
urlStr = url;
CefFrameCppToC::Get(self)->LoadStream(streamPtr, urlStr);
CefFrameCppToC::Get(self)->LoadStream(CefStreamReaderCppToC::Unwrap(stream),
CefString(url));
}
void CEF_CALLBACK frame_execute_java_script(struct _cef_frame_t* self,
const wchar_t* jsCode, const wchar_t* scriptUrl, int startLine)
const cef_string_t* jsCode, const cef_string_t* scriptUrl, int startLine)
{
DCHECK(self);
if(!self)
return;
std::wstring jsCodeStr, scriptUrlStr;
if(jsCode)
jsCodeStr = jsCode;
if(scriptUrl)
scriptUrlStr = scriptUrl;
CefFrameCppToC::Get(self)->ExecuteJavaScript(jsCodeStr, scriptUrlStr,
startLine);
CefFrameCppToC::Get(self)->ExecuteJavaScript(CefString(jsCode),
CefString(scriptUrl), startLine);
}
int CEF_CALLBACK frame_is_main(struct _cef_frame_t* self)
@ -212,28 +191,24 @@ int CEF_CALLBACK frame_is_focused(struct _cef_frame_t* self)
return CefFrameCppToC::Get(self)->IsFocused();
}
cef_string_t CEF_CALLBACK frame_get_name(struct _cef_frame_t* self)
cef_string_userfree_t CEF_CALLBACK frame_get_name(struct _cef_frame_t* self)
{
DCHECK(self);
if(!self)
return 0;
std::wstring nameStr = CefFrameCppToC::Get(self)->GetName();
if(!nameStr.empty())
return cef_string_alloc(nameStr.c_str());
return NULL;
CefString nameStr = CefFrameCppToC::Get(self)->GetName();
return nameStr.DetachToUserFree();
}
cef_string_t CEF_CALLBACK frame_get_url(struct _cef_frame_t* self)
cef_string_userfree_t CEF_CALLBACK frame_get_url(struct _cef_frame_t* self)
{
DCHECK(self);
if(!self)
return NULL;
std::wstring urlStr = CefFrameCppToC::Get(self)->GetURL();
if(!urlStr.empty())
return cef_string_alloc(urlStr.c_str());
return NULL;
CefString urlStr = CefFrameCppToC::Get(self)->GetURL();
return urlStr.DetachToUserFree();
}

View File

@ -17,7 +17,6 @@
#include "libcef_dll/ctocpp/request_ctocpp.h"
#include "libcef_dll/ctocpp/stream_reader_ctocpp.h"
#include "libcef_dll/ctocpp/v8value_ctocpp.h"
#include "libcef_dll/transfer_util.h"
// MEMBER FUNCTIONS - Body may be edited by hand.
@ -54,15 +53,9 @@ enum cef_retval_t CEF_CALLBACK handler_handle_before_created(
if(parentBrowser)
browserPtr = CefBrowserCToCpp::Wrap(parentBrowser);
std::wstring urlStr;
if(*url)
urlStr = *url;
enum cef_retval_t rv = CefHandlerCppToC::Get(self)->HandleBeforeCreated(
browserPtr, wndInfo, popup?true:false, features, handlerPtr, urlStr,
browserSettings);
transfer_string_contents(urlStr, url);
browserPtr, wndInfo, popup?true:false, features, handlerPtr,
CefString(url), browserSettings);
if(handlerPtr.get() != origHandler) {
// The handler has been changed.
@ -97,7 +90,7 @@ enum cef_retval_t CEF_CALLBACK handler_handle_after_created(
enum cef_retval_t CEF_CALLBACK handler_handle_address_change(
struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame,
const wchar_t* url)
const cef_string_t* url)
{
DCHECK(self);
DCHECK(browser);
@ -105,28 +98,22 @@ enum cef_retval_t CEF_CALLBACK handler_handle_address_change(
if(!self || !browser || !frame)
return RV_CONTINUE;
std::wstring urlStr;
if(url)
urlStr = url;
return CefHandlerCppToC::Get(self)->HandleAddressChange(
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), urlStr);
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame),
CefString(url));
}
enum cef_retval_t CEF_CALLBACK handler_handle_title_change(
struct _cef_handler_t* self, cef_browser_t* browser, const wchar_t* title)
struct _cef_handler_t* self, cef_browser_t* browser,
const cef_string_t* title)
{
DCHECK(self);
DCHECK(browser);
if(!self || !browser)
return RV_CONTINUE;
std::wstring titleStr;
if(title)
titleStr = title;
return CefHandlerCppToC::Get(self)->HandleTitleChange(
CefBrowserCToCpp::Wrap(browser), titleStr);
CefBrowserCToCpp::Wrap(browser), CefString(title));
}
enum cef_retval_t CEF_CALLBACK handler_handle_before_browse(
@ -180,7 +167,7 @@ enum cef_retval_t CEF_CALLBACK handler_handle_load_end(
enum cef_retval_t CEF_CALLBACK handler_handle_load_error(
struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame,
enum cef_handler_errorcode_t errorCode, const wchar_t* failedUrl,
enum cef_handler_errorcode_t errorCode, const cef_string_t* failedUrl,
cef_string_t* errorText)
{
DCHECK(self);
@ -190,20 +177,9 @@ enum cef_retval_t CEF_CALLBACK handler_handle_load_error(
if(!self || !browser || !errorText || !frame)
return RV_CONTINUE;
std::wstring failedUrlStr, errorTextStr;
if(failedUrl)
failedUrlStr = failedUrl;
if(*errorText)
errorTextStr = *errorText;
enum cef_retval_t rv = CefHandlerCppToC::Get(self)->HandleLoadError(
return CefHandlerCppToC::Get(self)->HandleLoadError(
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), errorCode,
failedUrlStr, errorTextStr);
transfer_string_contents(errorTextStr, errorText);
return rv;
CefString(failedUrl), CefString(errorText));
}
enum cef_retval_t CEF_CALLBACK handler_handle_before_resource_load(
@ -220,21 +196,12 @@ enum cef_retval_t CEF_CALLBACK handler_handle_before_resource_load(
if(!self || !browser || !redirectUrl || !resourceStream || !mimeType)
return RV_CONTINUE;
std::wstring redirectUrlStr, mimeTypeStr;
CefRefPtr<CefStreamReader> streamPtr;
if(*redirectUrl)
redirectUrlStr = *redirectUrl;
if(*mimeType)
mimeTypeStr = *mimeType;
enum cef_retval_t rv = CefHandlerCppToC::Get(self)->
HandleBeforeResourceLoad(CefBrowserCToCpp::Wrap(browser),
CefRequestCToCpp::Wrap(request), redirectUrlStr, streamPtr, mimeTypeStr,
loadFlags);
transfer_string_contents(redirectUrlStr, redirectUrl);
transfer_string_contents(mimeTypeStr, mimeType);
CefRequestCToCpp::Wrap(request), CefString(redirectUrl), streamPtr,
CefString(mimeType), loadFlags);
if(streamPtr.get())
*resourceStream = CefStreamReaderCToCpp::Unwrap(streamPtr);
@ -244,8 +211,8 @@ enum cef_retval_t CEF_CALLBACK handler_handle_before_resource_load(
enum cef_retval_t CEF_CALLBACK handler_handle_download_response(
struct _cef_handler_t* self, cef_browser_t* browser,
const wchar_t* mimeType, const wchar_t* fileName, int64 contentLength,
struct _cef_download_handler_t** handler)
const cef_string_t* mimeType, const cef_string_t* fileName,
int64 contentLength, struct _cef_download_handler_t** handler)
{
DCHECK(self);
DCHECK(browser);
@ -254,17 +221,11 @@ enum cef_retval_t CEF_CALLBACK handler_handle_download_response(
if(!self || !browser || !mimeType || !fileName)
return RV_CONTINUE;
std::wstring mimeTypeStr, fileNameStr;
CefRefPtr<CefDownloadHandler> downloadPtr;
if(mimeType)
mimeTypeStr = mimeType;
if(fileName)
fileNameStr = fileName;
enum cef_retval_t rv = CefHandlerCppToC::Get(self)->
HandleDownloadResponse(CefBrowserCToCpp::Wrap(browser), mimeTypeStr,
fileNameStr, contentLength, downloadPtr);
HandleDownloadResponse(CefBrowserCToCpp::Wrap(browser),
CefString(mimeType), CefString(fileName), contentLength, downloadPtr);
if(downloadPtr.get())
*handler = CefDownloadHandlerCppToC::Wrap(downloadPtr);
@ -296,16 +257,8 @@ enum cef_retval_t CEF_CALLBACK handler_handle_get_menu_label(
if(!self || !browser || !label)
return RV_CONTINUE;
std::wstring labelStr;
if(*label)
labelStr = *label;
enum cef_retval_t rv = CefHandlerCppToC::Get(self)->HandleGetMenuLabel(
CefBrowserCToCpp::Wrap(browser), menuId, labelStr);
transfer_string_contents(labelStr, label);
return rv;
return CefHandlerCppToC::Get(self)->HandleGetMenuLabel(
CefBrowserCToCpp::Wrap(browser), menuId, CefString(label));
}
enum cef_retval_t CEF_CALLBACK handler_handle_menu_action(
@ -336,10 +289,11 @@ enum cef_retval_t CEF_CALLBACK handler_handle_print_options(
enum cef_retval_t CEF_CALLBACK handler_handle_print_header_footer(
struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame,
cef_print_info_t* printInfo, const wchar_t* url, const wchar_t* title,
int currentPage, int maxPages, cef_string_t* topLeft,
cef_string_t* topCenter, cef_string_t* topRight, cef_string_t* bottomLeft,
cef_string_t* bottomCenter, cef_string_t* bottomRight)
cef_print_info_t* printInfo, const cef_string_t* url,
const cef_string_t* title, int currentPage, int maxPages,
cef_string_t* topLeft, cef_string_t* topCenter, cef_string_t* topRight,
cef_string_t* bottomLeft, cef_string_t* bottomCenter,
cef_string_t* bottomRight)
{
DCHECK(self);
DCHECK(browser);
@ -351,47 +305,19 @@ enum cef_retval_t CEF_CALLBACK handler_handle_print_header_footer(
|| !topRight || !bottomLeft || !bottomCenter || !bottomRight)
return RV_CONTINUE;
std::wstring urlStr, titleStr;
std::wstring topLeftStr, topCenterStr, topRightStr;
std::wstring bottomLeftStr, bottomCenterStr, bottomRightStr;
CefPrintInfo info = *printInfo;
if(url)
urlStr = url;
if(title)
titleStr = title;
if(*topLeft)
topLeftStr = *topLeft;
if(*topCenter)
topCenterStr = *topCenter;
if(*topRight)
topRightStr = *topRight;
if(*bottomLeft)
bottomLeftStr = *bottomLeft;
if(*bottomCenter)
bottomCenterStr = *bottomCenter;
if(*bottomRight)
bottomRightStr = *bottomRight;
enum cef_retval_t rv = CefHandlerCppToC::Get(self)->
return CefHandlerCppToC::Get(self)->
HandlePrintHeaderFooter(CefBrowserCToCpp::Wrap(browser),
CefFrameCToCpp::Wrap(frame), info, urlStr, titleStr, currentPage,
maxPages, topLeftStr, topCenterStr, topRightStr, bottomLeftStr,
bottomCenterStr, bottomRightStr);
transfer_string_contents(topLeftStr, topLeft);
transfer_string_contents(topCenterStr, topCenter);
transfer_string_contents(topRightStr, topRight);
transfer_string_contents(bottomLeftStr, bottomLeft);
transfer_string_contents(bottomCenterStr, bottomCenter);
transfer_string_contents(bottomRightStr, bottomRight);
return rv;
CefFrameCToCpp::Wrap(frame), info, CefString(url), CefString(title),
currentPage, maxPages, CefString(topLeft), CefString(topCenter),
CefString(topRight), CefString(bottomLeft), CefString(bottomCenter),
CefString(bottomRight));
}
enum cef_retval_t CEF_CALLBACK handler_handle_jsalert(
struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame,
const wchar_t* message)
const cef_string_t* message)
{
DCHECK(self);
DCHECK(browser);
@ -399,17 +325,14 @@ enum cef_retval_t CEF_CALLBACK handler_handle_jsalert(
if(!self || !browser || !frame)
return RV_CONTINUE;
std::wstring messageStr;
if(message)
messageStr = message;
return CefHandlerCppToC::Get(self)->HandleJSAlert(
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), messageStr);
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame),
CefString(message));
}
enum cef_retval_t CEF_CALLBACK handler_handle_jsconfirm(
struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame,
const wchar_t* message, int* retval)
const cef_string_t* message, int* retval)
{
DCHECK(self);
DCHECK(browser);
@ -418,14 +341,10 @@ enum cef_retval_t CEF_CALLBACK handler_handle_jsconfirm(
if(!self || !browser || !retval || !frame)
return RV_CONTINUE;
std::wstring messageStr;
if(message)
messageStr = message;
bool ret = false;
enum cef_retval_t rv = CefHandlerCppToC::Get(self)->HandleJSConfirm(
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), messageStr,
ret);
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame),
CefString(message), ret);
*retval = (ret ? 1 : 0);
return rv;
@ -433,7 +352,7 @@ enum cef_retval_t CEF_CALLBACK handler_handle_jsconfirm(
enum cef_retval_t CEF_CALLBACK handler_handle_jsprompt(
struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame,
const wchar_t* message, const wchar_t* defaultValue, int* retval,
const cef_string_t* message, const cef_string_t* defaultValue, int* retval,
cef_string_t* result)
{
DCHECK(self);
@ -444,23 +363,12 @@ enum cef_retval_t CEF_CALLBACK handler_handle_jsprompt(
if(!self || !browser || !frame || !retval || !result)
return RV_CONTINUE;
std::wstring messageStr, defaultValueStr, resultStr;
if(message)
messageStr = message;
if(defaultValue)
defaultValueStr = defaultValue;
if(*result)
resultStr = *result;
bool ret = false;
enum cef_retval_t rv = CefHandlerCppToC::Get(self)->HandleJSPrompt(
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), messageStr,
defaultValueStr, ret, resultStr);
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame),
CefString(message), CefString(defaultValue), ret, CefString(result));
*retval = (ret ? 1 : 0);
transfer_string_contents(resultStr, result);
return rv;
}
@ -540,35 +448,22 @@ enum cef_retval_t CEF_CALLBACK handler_handle_tooltip(
if(!self || !browser || !text)
return RV_CONTINUE;
std::wstring textStr;
if(*text)
textStr = *text;
enum cef_retval_t rv = CefHandlerCppToC::Get(self)->HandleTooltip(
CefBrowserCToCpp::Wrap(browser), textStr);
transfer_string_contents(textStr, text);
return rv;
return CefHandlerCppToC::Get(self)->HandleTooltip(
CefBrowserCToCpp::Wrap(browser), CefString(text));
}
enum cef_retval_t CEF_CALLBACK handler_handle_console_message(
struct _cef_handler_t* self, cef_browser_t* browser, const wchar_t* message,
const wchar_t* source, int line)
struct _cef_handler_t* self, cef_browser_t* browser,
const cef_string_t* message, const cef_string_t* source, int line)
{
DCHECK(self);
DCHECK(browser);
if(!self || !browser)
return RV_CONTINUE;
std::wstring messageStr, sourceStr;
if(message)
messageStr = message;
if(source)
sourceStr = source;
return CefHandlerCppToC::Get(self)->HandleConsoleMessage(
CefBrowserCToCpp::Wrap(browser), messageStr, sourceStr, line);
CefBrowserCToCpp::Wrap(browser), CefString(message), CefString(source),
line);
}
enum cef_retval_t CEF_CALLBACK handler_handle_find_result(

View File

@ -38,17 +38,13 @@ void CEF_CALLBACK post_data_element_set_to_empty(
}
void CEF_CALLBACK post_data_element_set_to_file(
struct _cef_post_data_element_t* self, const wchar_t* fileName)
struct _cef_post_data_element_t* self, const cef_string_t* fileName)
{
DCHECK(self);
if(!self)
return;
std::wstring fileNameStr;
if(fileName)
fileNameStr = fileName;
CefPostDataElementCppToC::Get(self)->SetToFile(fileNameStr);
CefPostDataElementCppToC::Get(self)->SetToFile(CefString(fileName));
}
void CEF_CALLBACK post_data_element_set_to_bytes(
@ -71,18 +67,15 @@ enum cef_postdataelement_type_t CEF_CALLBACK post_data_element_get_type(
return CefPostDataElementCppToC::Get(self)->GetType();
}
cef_string_t CEF_CALLBACK post_data_element_get_file(
cef_string_userfree_t CEF_CALLBACK post_data_element_get_file(
struct _cef_post_data_element_t* self)
{
DCHECK(self);
if(!self)
return NULL;
std::wstring fileNameStr =
CefPostDataElementCppToC::Get(self)->GetFile();
if(!fileNameStr.empty())
return cef_string_alloc(fileNameStr.c_str());
return NULL;
CefString fileNameStr = CefPostDataElementCppToC::Get(self)->GetFile();
return fileNameStr.DetachToUserFree();
}
size_t CEF_CALLBACK post_data_element_get_bytes_count(

View File

@ -28,54 +28,45 @@ CEF_EXPORT cef_request_t* cef_request_create()
// MEMBER FUNCTIONS - Body may be edited by hand.
cef_string_t CEF_CALLBACK request_get_url(struct _cef_request_t* self)
cef_string_userfree_t CEF_CALLBACK request_get_url(struct _cef_request_t* self)
{
DCHECK(self);
if(!self)
return NULL;
std::wstring urlStr = CefRequestCppToC::Get(self)->GetURL();
if(!urlStr.empty())
return cef_string_alloc(urlStr.c_str());
return NULL;
CefString urlStr = CefRequestCppToC::Get(self)->GetURL();
return urlStr.DetachToUserFree();
}
void CEF_CALLBACK request_set_url(struct _cef_request_t* self,
const wchar_t* url)
const cef_string_t* url)
{
DCHECK(self);
if(!self)
return;
std::wstring urlStr;
if(url)
urlStr = url;
CefRequestCppToC::Get(self)->SetURL(urlStr);
CefRequestCppToC::Get(self)->SetURL(CefString(url));
}
cef_string_t CEF_CALLBACK request_get_method(struct _cef_request_t* self)
cef_string_userfree_t CEF_CALLBACK request_get_method(
struct _cef_request_t* self)
{
DCHECK(self);
if(!self)
return NULL;
std::wstring methodStr = CefRequestCppToC::Get(self)->GetMethod();
if(!methodStr.empty())
return cef_string_alloc(methodStr.c_str());
return NULL;
CefString methodStr = CefRequestCppToC::Get(self)->GetMethod();
return methodStr.DetachToUserFree();
}
void CEF_CALLBACK request_set_method(struct _cef_request_t* self,
const wchar_t* method)
const cef_string_t* method)
{
DCHECK(self);
if(!self)
return;
std::wstring methodStr;
if(method)
methodStr = method;
CefRequestCppToC::Get(self)->SetMethod(methodStr);
CefRequestCppToC::Get(self)->SetMethod(CefString(method));
}
struct _cef_post_data_t* CEF_CALLBACK request_get_post_data(
@ -133,28 +124,24 @@ void CEF_CALLBACK request_set_header_map(struct _cef_request_t* self,
CefRequestCppToC::Get(self)->SetHeaderMap(map);
}
void CEF_CALLBACK request_set(struct _cef_request_t* self, const wchar_t* url,
const wchar_t* method, struct _cef_post_data_t* postData,
cef_string_map_t headerMap)
void CEF_CALLBACK request_set(struct _cef_request_t* self,
const cef_string_t* url, const cef_string_t* method,
struct _cef_post_data_t* postData, cef_string_map_t headerMap)
{
DCHECK(self);
if(!self)
return;
std::wstring urlStr, methodStr;
CefRefPtr<CefPostData> postDataPtr;
CefRequest::HeaderMap map;
if(url)
urlStr = url;
if(method)
methodStr = method;
if(postData)
postDataPtr = CefPostDataCppToC::Unwrap(postData);
if(headerMap)
transfer_string_map_contents(headerMap, map);
CefRequestCppToC::Get(self)->Set(urlStr, methodStr, postDataPtr, map);
CefRequestCppToC::Get(self)->Set(CefString(url), CefString(method),
postDataPtr, map);
}

View File

@ -12,7 +12,6 @@
#include "libcef_dll/cpptoc/scheme_handler_cpptoc.h"
#include "libcef_dll/ctocpp/request_ctocpp.h"
#include "libcef_dll/transfer_util.h"
// MEMBER FUNCTIONS - Body may be edited by hand.
@ -28,16 +27,8 @@ int CEF_CALLBACK scheme_handler_process_request(
if(!self || !request || !mime_type || !response_length)
return 0;
std::wstring mimeTypeStr;
if(*mime_type)
mimeTypeStr = *mime_type;
bool rv = CefSchemeHandlerCppToC::Get(self)->ProcessRequest(
CefRequestCToCpp::Wrap(request), mimeTypeStr, response_length);
transfer_string_contents(mimeTypeStr, mime_type);
return rv?1:0;
return CefSchemeHandlerCppToC::Get(self)->ProcessRequest(
CefRequestCToCpp::Wrap(request), CefString(mime_type), response_length);
}
void CEF_CALLBACK scheme_handler_cancel(struct _cef_scheme_handler_t* self)

View File

@ -17,12 +17,10 @@
// GLOBAL FUNCTIONS - Body may be edited by hand.
CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_file(
const wchar_t* fileName)
const cef_string_t* fileName)
{
std::wstring filenamestr;
if(fileName)
filenamestr = fileName;
CefRefPtr<CefStreamReader> impl = CefStreamReader::CreateForFile(filenamestr);
CefRefPtr<CefStreamReader> impl =
CefStreamReader::CreateForFile(CefString(fileName));
if(impl.get())
return CefStreamReaderCppToC::Wrap(impl);
return NULL;

View File

@ -17,14 +17,14 @@
// GLOBAL FUNCTIONS - Body may be edited by hand.
CEF_EXPORT cef_stream_writer_t* cef_stream_writer_create_for_file(
const wchar_t* fileName)
const cef_string_t* fileName)
{
DCHECK(fileName);
if(!fileName)
return NULL;
std::wstring fileNameStr = fileName;
CefRefPtr<CefStreamWriter> impl = CefStreamWriter::CreateForFile(fileName);
CefRefPtr<CefStreamWriter> impl =
CefStreamWriter::CreateForFile(CefString(fileName));
if(impl.get())
return CefStreamWriterCppToC::Wrap(impl);
return NULL;

View File

@ -17,9 +17,9 @@
// MEMBER FUNCTIONS - Body may be edited by hand.
int CEF_CALLBACK v8handler_execute(struct _cef_v8handler_t* self,
const wchar_t* name, struct _cef_v8value_t* object, size_t argumentCount,
struct _cef_v8value_t* const* arguments, struct _cef_v8value_t** retval,
cef_string_t* exception)
const cef_string_t* name, struct _cef_v8value_t* object,
size_t argumentCount, struct _cef_v8value_t* const* arguments,
struct _cef_v8value_t** retval, cef_string_t* exception)
{
DCHECK(self);
if(!self)
@ -29,22 +29,15 @@ int CEF_CALLBACK v8handler_execute(struct _cef_v8handler_t* self,
if(object)
objectPtr = CefV8ValueCToCpp::Wrap(object);
std::wstring nameStr;
if(name)
nameStr = name;
CefV8ValueList list;
for(size_t i = 0; i < argumentCount; ++i) {
list.push_back(CefV8ValueCToCpp::Wrap(arguments[i]));
}
CefRefPtr<CefV8Value> retValPtr;
std::wstring exceptionStr;
bool rv = CefV8HandlerCppToC::Get(self)->Execute(nameStr, objectPtr,
list, retValPtr, exceptionStr);
bool rv = CefV8HandlerCppToC::Get(self)->Execute(CefString(name), objectPtr,
list, retValPtr, CefString(exception));
if(rv) {
if(!exceptionStr.empty() && exception)
*exception = cef_string_alloc(exceptionStr.c_str());
if(retValPtr.get() && retval)
*retval = CefV8ValueCToCpp::Unwrap(retValPtr);
}

View File

@ -57,13 +57,9 @@ CEF_EXPORT cef_v8value_t* cef_v8value_create_double(double value)
return NULL;
}
CEF_EXPORT cef_v8value_t* cef_v8value_create_string(const wchar_t* value)
CEF_EXPORT cef_v8value_t* cef_v8value_create_string(const cef_string_t* value)
{
std::wstring valueStr;
if(value)
valueStr = value;
CefRefPtr<CefV8Value> impl = CefV8Value::CreateString(valueStr);
CefRefPtr<CefV8Value> impl = CefV8Value::CreateString(CefString(value));
if(impl.get())
return CefV8ValueCppToC::Wrap(impl);
return NULL;
@ -89,17 +85,15 @@ CEF_EXPORT cef_v8value_t* cef_v8value_create_array()
return NULL;
}
CEF_EXPORT cef_v8value_t* cef_v8value_create_function(const wchar_t* name,
CEF_EXPORT cef_v8value_t* cef_v8value_create_function(const cef_string_t* name,
cef_v8handler_t* handler)
{
std::wstring nameStr;
if(name)
nameStr = name;
CefRefPtr<CefV8Handler> handlerPtr;
if(handler)
handlerPtr = CefV8HandlerCToCpp::Wrap(handler);
CefRefPtr<CefV8Value> impl = CefV8Value::CreateFunction(nameStr, handlerPtr);
CefRefPtr<CefV8Value> impl =
CefV8Value::CreateFunction(CefString(name), handlerPtr);
if(impl.get())
return CefV8ValueCppToC::Wrap(impl);
return NULL;
@ -216,30 +210,25 @@ double CEF_CALLBACK v8value_get_double_value(struct _cef_v8value_t* self)
return CefV8ValueCppToC::Get(self)->GetDoubleValue();
}
cef_string_t CEF_CALLBACK v8value_get_string_value(struct _cef_v8value_t* self)
cef_string_userfree_t CEF_CALLBACK v8value_get_string_value(
struct _cef_v8value_t* self)
{
DCHECK(self);
if(!self)
return 0;
std::wstring valueStr = CefV8ValueCppToC::Get(self)->GetStringValue();
if(!valueStr.empty())
return cef_string_alloc(valueStr.c_str());
return NULL;
CefString valueStr = CefV8ValueCppToC::Get(self)->GetStringValue();
return valueStr.DetachToUserFree();
}
int CEF_CALLBACK v8value_has_value_bykey(struct _cef_v8value_t* self,
const wchar_t* key)
const cef_string_t* key)
{
DCHECK(self);
if(!self)
return 0;
std::wstring keyStr;
if(key)
keyStr = key;
return CefV8ValueCppToC::Get(self)->HasValue(keyStr);
return CefV8ValueCppToC::Get(self)->HasValue(CefString(key));
}
int CEF_CALLBACK v8value_has_value_byindex(struct _cef_v8value_t* self,
@ -253,17 +242,13 @@ int CEF_CALLBACK v8value_has_value_byindex(struct _cef_v8value_t* self,
}
int CEF_CALLBACK v8value_delete_value_bykey(struct _cef_v8value_t* self,
const wchar_t* key)
const cef_string_t* key)
{
DCHECK(self);
if(!self)
return 0;
std::wstring keyStr;
if(key)
keyStr = key;
return CefV8ValueCppToC::Get(self)->DeleteValue(keyStr);
return CefV8ValueCppToC::Get(self)->DeleteValue(CefString(key));
}
int CEF_CALLBACK v8value_delete_value_byindex(struct _cef_v8value_t* self,
@ -277,18 +262,14 @@ int CEF_CALLBACK v8value_delete_value_byindex(struct _cef_v8value_t* self,
}
struct _cef_v8value_t* CEF_CALLBACK v8value_get_value_bykey(
struct _cef_v8value_t* self, const wchar_t* key)
struct _cef_v8value_t* self, const cef_string_t* key)
{
DCHECK(self);
if(!self)
return 0;
std::wstring keyStr;
if(key)
keyStr = key;
CefRefPtr<CefV8Value> valuePtr =
CefV8ValueCppToC::Get(self)->GetValue(keyStr);
CefV8ValueCppToC::Get(self)->GetValue(CefString(key));
return CefV8ValueCppToC::Wrap(valuePtr);
}
@ -305,18 +286,14 @@ struct _cef_v8value_t* CEF_CALLBACK v8value_get_value_byindex(
}
int CEF_CALLBACK v8value_set_value_bykey(struct _cef_v8value_t* self,
const wchar_t* key, struct _cef_v8value_t* value)
const cef_string_t* key, struct _cef_v8value_t* value)
{
DCHECK(self);
if(!self)
return 0;
std::wstring keyStr;
if(key)
keyStr = key;
CefRefPtr<CefV8Value> valuePtr = CefV8ValueCppToC::Unwrap(value);
return CefV8ValueCppToC::Get(self)->SetValue(keyStr, valuePtr);
return CefV8ValueCppToC::Get(self)->SetValue(CefString(key), valuePtr);
}
int CEF_CALLBACK v8value_set_value_byindex(struct _cef_v8value_t* self,
@ -337,11 +314,11 @@ int CEF_CALLBACK v8value_get_keys(struct _cef_v8value_t* self,
if(!self)
return 0;
std::vector<std::wstring> keysList;
std::vector<CefString> keysList;
CefV8ValueCppToC::Get(self)->GetKeys(keysList);
size_t size = keysList.size();
for(size_t i = 0; i < size; ++i)
cef_string_list_append(keys, keysList[i].c_str());
cef_string_list_append(keys, keysList[i].GetStruct());
return size;
}
@ -366,17 +343,15 @@ int CEF_CALLBACK v8value_get_array_length(struct _cef_v8value_t* self)
return CefV8ValueCppToC::Get(self)->GetArrayLength();
}
cef_string_t CEF_CALLBACK v8value_get_function_name(struct _cef_v8value_t* self)
cef_string_userfree_t CEF_CALLBACK v8value_get_function_name(
struct _cef_v8value_t* self)
{
DCHECK(self);
if(!self)
return 0;
std::wstring functionNameStr =
CefV8ValueCppToC::Get(self)->GetFunctionName();
if(!functionNameStr.empty())
return cef_string_alloc(functionNameStr.c_str());
return NULL;
CefString functionNameStr = CefV8ValueCppToC::Get(self)->GetFunctionName();
return functionNameStr.DetachToUserFree();
}
cef_v8handler_t* CEF_CALLBACK v8value_get_function_handler(
@ -409,14 +384,11 @@ int CEF_CALLBACK v8value_execute_function(struct _cef_v8value_t* self,
argsList.push_back(CefV8ValueCppToC::Unwrap(arguments[i]));
}
CefRefPtr<CefV8Value> retvalPtr;
std::wstring exceptionStr;
bool rv = CefV8ValueCppToC::Get(self)->ExecuteFunction(objectPtr,
argsList, retvalPtr, exceptionStr);
argsList, retvalPtr, CefString(exception));
if(retvalPtr.get() && retval)
*retval = CefV8ValueCppToC::Wrap(retvalPtr);
if(!exceptionStr.empty() && exception)
*exception = cef_string_alloc(exceptionStr.c_str());
return rv;
}

View File

@ -17,13 +17,10 @@
// GLOBAL FUNCTIONS - Body may be edited by hand.
CEF_EXPORT cef_xml_reader_t* cef_xml_reader_create(cef_stream_reader_t* stream,
enum cef_xml_encoding_type_t encodingType, const wchar_t* URI)
enum cef_xml_encoding_type_t encodingType, const cef_string_t* URI)
{
std::wstring encodingTypeStr;
if(encodingType)
encodingTypeStr = encodingType;
CefRefPtr<CefXmlReader> impl = CefXmlReader::Create(
CefStreamReaderCppToC::Unwrap(stream), encodingType, encodingTypeStr);
CefStreamReaderCppToC::Unwrap(stream), encodingType, CefString(URI));
if(impl.get())
return CefXmlReaderCppToC::Wrap(impl);
return NULL;
@ -59,16 +56,15 @@ int CEF_CALLBACK xml_reader_has_error(struct _cef_xml_reader_t* self)
return CefXmlReaderCppToC::Get(self)->HasError();
}
cef_string_t CEF_CALLBACK xml_reader_get_error(struct _cef_xml_reader_t* self)
cef_string_userfree_t CEF_CALLBACK xml_reader_get_error(
struct _cef_xml_reader_t* self)
{
DCHECK(self);
if(!self)
return NULL;
std::wstring retStr = CefXmlReaderCppToC::Get(self)->GetError();
if(!retStr.empty())
return cef_string_alloc(retStr.c_str());
return NULL;
CefString retStr = CefXmlReaderCppToC::Get(self)->GetError();
return retStr.DetachToUserFree();
}
enum cef_xml_node_type_t CEF_CALLBACK xml_reader_get_type(
@ -90,81 +86,70 @@ int CEF_CALLBACK xml_reader_get_depth(struct _cef_xml_reader_t* self)
return CefXmlReaderCppToC::Get(self)->GetDepth();
}
cef_string_t CEF_CALLBACK xml_reader_get_local_name(
cef_string_userfree_t CEF_CALLBACK xml_reader_get_local_name(
struct _cef_xml_reader_t* self)
{
DCHECK(self);
if(!self)
return NULL;
std::wstring retStr = CefXmlReaderCppToC::Get(self)->GetLocalName();
if(!retStr.empty())
return cef_string_alloc(retStr.c_str());
return NULL;
CefString retStr = CefXmlReaderCppToC::Get(self)->GetLocalName();
return retStr.DetachToUserFree();
}
cef_string_t CEF_CALLBACK xml_reader_get_prefix(struct _cef_xml_reader_t* self)
{
DCHECK(self);
if(!self)
return NULL;
std::wstring retStr = CefXmlReaderCppToC::Get(self)->GetPrefix();
if(!retStr.empty())
return cef_string_alloc(retStr.c_str());
return NULL;
}
cef_string_t CEF_CALLBACK xml_reader_get_qualified_name(
cef_string_userfree_t CEF_CALLBACK xml_reader_get_prefix(
struct _cef_xml_reader_t* self)
{
DCHECK(self);
if(!self)
return NULL;
std::wstring retStr = CefXmlReaderCppToC::Get(self)->GetQualifiedName();
if(!retStr.empty())
return cef_string_alloc(retStr.c_str());
return NULL;
CefString retStr = CefXmlReaderCppToC::Get(self)->GetPrefix();
return retStr.DetachToUserFree();
}
cef_string_t CEF_CALLBACK xml_reader_get_namespace_uri(
cef_string_userfree_t CEF_CALLBACK xml_reader_get_qualified_name(
struct _cef_xml_reader_t* self)
{
DCHECK(self);
if(!self)
return NULL;
std::wstring retStr = CefXmlReaderCppToC::Get(self)->GetNamespaceURI();
if(!retStr.empty())
return cef_string_alloc(retStr.c_str());
return NULL;
CefString retStr = CefXmlReaderCppToC::Get(self)->GetQualifiedName();
return retStr.DetachToUserFree();
}
cef_string_t CEF_CALLBACK xml_reader_get_base_uri(
cef_string_userfree_t CEF_CALLBACK xml_reader_get_namespace_uri(
struct _cef_xml_reader_t* self)
{
DCHECK(self);
if(!self)
return NULL;
std::wstring retStr = CefXmlReaderCppToC::Get(self)->GetBaseURI();
if(!retStr.empty())
return cef_string_alloc(retStr.c_str());
return NULL;
CefString retStr = CefXmlReaderCppToC::Get(self)->GetNamespaceURI();
return retStr.DetachToUserFree();
}
cef_string_t CEF_CALLBACK xml_reader_get_xml_lang(
cef_string_userfree_t CEF_CALLBACK xml_reader_get_base_uri(
struct _cef_xml_reader_t* self)
{
DCHECK(self);
if(!self)
return NULL;
std::wstring retStr = CefXmlReaderCppToC::Get(self)->GetXmlLang();
if(!retStr.empty())
return cef_string_alloc(retStr.c_str());
CefString retStr = CefXmlReaderCppToC::Get(self)->GetBaseURI();
return retStr.DetachToUserFree();
}
cef_string_userfree_t CEF_CALLBACK xml_reader_get_xml_lang(
struct _cef_xml_reader_t* self)
{
DCHECK(self);
if(!self)
return NULL;
CefString retStr = CefXmlReaderCppToC::Get(self)->GetXmlLang();
return retStr.DetachToUserFree();
}
int CEF_CALLBACK xml_reader_is_empty_element(struct _cef_xml_reader_t* self)
@ -185,16 +170,15 @@ int CEF_CALLBACK xml_reader_has_value(struct _cef_xml_reader_t* self)
return CefXmlReaderCppToC::Get(self)->HasValue();
}
cef_string_t CEF_CALLBACK xml_reader_get_value(struct _cef_xml_reader_t* self)
cef_string_userfree_t CEF_CALLBACK xml_reader_get_value(
struct _cef_xml_reader_t* self)
{
DCHECK(self);
if(!self)
return NULL;
std::wstring retStr = CefXmlReaderCppToC::Get(self)->GetValue();
if(!retStr.empty())
return cef_string_alloc(retStr.c_str());
return NULL;
CefString retStr = CefXmlReaderCppToC::Get(self)->GetValue();
return retStr.DetachToUserFree();
}
int CEF_CALLBACK xml_reader_has_attributes(struct _cef_xml_reader_t* self)
@ -216,37 +200,33 @@ size_t CEF_CALLBACK xml_reader_get_attribute_count(
return CefXmlReaderCppToC::Get(self)->GetAttributeCount();
}
cef_string_t CEF_CALLBACK xml_reader_get_attribute_byindex(
cef_string_userfree_t CEF_CALLBACK xml_reader_get_attribute_byindex(
struct _cef_xml_reader_t* self, int index)
{
DCHECK(self);
if(!self)
return NULL;
std::wstring retStr = CefXmlReaderCppToC::Get(self)->GetAttribute(index);
if(!retStr.empty())
return cef_string_alloc(retStr.c_str());
return NULL;
CefString retStr = CefXmlReaderCppToC::Get(self)->GetAttribute(index);
return retStr.DetachToUserFree();
}
cef_string_t CEF_CALLBACK xml_reader_get_attribute_byqname(
struct _cef_xml_reader_t* self, const wchar_t* qualifiedName)
cef_string_userfree_t CEF_CALLBACK xml_reader_get_attribute_byqname(
struct _cef_xml_reader_t* self, const cef_string_t* qualifiedName)
{
DCHECK(self);
DCHECK(qualifiedName);
if(!self || !qualifiedName)
return NULL;
std::wstring retStr = CefXmlReaderCppToC::Get(self)->GetAttribute(
qualifiedName);
if(!retStr.empty())
return cef_string_alloc(retStr.c_str());
return NULL;
CefString retStr = CefXmlReaderCppToC::Get(self)->GetAttribute(
CefString(qualifiedName));
return retStr.DetachToUserFree();
}
cef_string_t CEF_CALLBACK xml_reader_get_attribute_bylname(
struct _cef_xml_reader_t* self, const wchar_t* localName,
const wchar_t* namespaceURI)
cef_string_userfree_t CEF_CALLBACK xml_reader_get_attribute_bylname(
struct _cef_xml_reader_t* self, const cef_string_t* localName,
const cef_string_t* namespaceURI)
{
DCHECK(self);
DCHECK(localName);
@ -254,37 +234,31 @@ cef_string_t CEF_CALLBACK xml_reader_get_attribute_bylname(
if(!self || !localName || !namespaceURI)
return NULL;
std::wstring retStr = CefXmlReaderCppToC::Get(self)->GetAttribute(
localName, namespaceURI);
if(!retStr.empty())
return cef_string_alloc(retStr.c_str());
return NULL;
CefString retStr = CefXmlReaderCppToC::Get(self)->GetAttribute(
CefString(localName), CefString(namespaceURI));
return retStr.DetachToUserFree();
}
cef_string_t CEF_CALLBACK xml_reader_get_inner_xml(
cef_string_userfree_t CEF_CALLBACK xml_reader_get_inner_xml(
struct _cef_xml_reader_t* self)
{
DCHECK(self);
if(!self)
return NULL;
std::wstring retStr = CefXmlReaderCppToC::Get(self)->GetInnerXml();
if(!retStr.empty())
return cef_string_alloc(retStr.c_str());
return NULL;
CefString retStr = CefXmlReaderCppToC::Get(self)->GetInnerXml();
return retStr.DetachToUserFree();
}
cef_string_t CEF_CALLBACK xml_reader_get_outer_xml(
cef_string_userfree_t CEF_CALLBACK xml_reader_get_outer_xml(
struct _cef_xml_reader_t* self)
{
DCHECK(self);
if(!self)
return NULL;
std::wstring retStr = CefXmlReaderCppToC::Get(self)->GetOuterXml();
if(!retStr.empty())
return cef_string_alloc(retStr.c_str());
return NULL;
CefString retStr = CefXmlReaderCppToC::Get(self)->GetOuterXml();
return retStr.DetachToUserFree();
}
int CEF_CALLBACK xml_reader_get_line_number(struct _cef_xml_reader_t* self)
@ -307,19 +281,20 @@ int CEF_CALLBACK xml_reader_move_to_attribute_byindex(
}
int CEF_CALLBACK xml_reader_move_to_attribute_byqname(
struct _cef_xml_reader_t* self, const wchar_t* qualifiedName)
struct _cef_xml_reader_t* self, const cef_string_t* qualifiedName)
{
DCHECK(self);
DCHECK(qualifiedName);
if(!self || !qualifiedName)
return 0;
return CefXmlReaderCppToC::Get(self)->MoveToAttribute(qualifiedName);
return CefXmlReaderCppToC::Get(self)->MoveToAttribute(
CefString(qualifiedName));
}
int CEF_CALLBACK xml_reader_move_to_attribute_bylname(
struct _cef_xml_reader_t* self, const wchar_t* localName,
const wchar_t* namespaceURI)
struct _cef_xml_reader_t* self, const cef_string_t* localName,
const cef_string_t* namespaceURI)
{
DCHECK(self);
DCHECK(localName);
@ -327,8 +302,8 @@ int CEF_CALLBACK xml_reader_move_to_attribute_bylname(
if(!self || !localName || !namespaceURI)
return 0;
return CefXmlReaderCppToC::Get(self)->MoveToAttribute(localName,
namespaceURI);
return CefXmlReaderCppToC::Get(self)->MoveToAttribute(CefString(localName),
CefString(namespaceURI));
}
int CEF_CALLBACK xml_reader_move_to_first_attribute(

View File

@ -47,17 +47,13 @@ int CEF_CALLBACK zip_reader_move_to_next_file(struct _cef_zip_reader_t* self)
}
int CEF_CALLBACK zip_reader_move_to_file(struct _cef_zip_reader_t* self,
const wchar_t* fileName, int caseSensitive)
const cef_string_t* fileName, int caseSensitive)
{
DCHECK(self);
if(!self)
return 0;
std::wstring fileNameStr;
if (fileName)
fileNameStr = fileName;
return CefZipReaderCppToC::Get(self)->MoveToFile(fileNameStr,
return CefZipReaderCppToC::Get(self)->MoveToFile(CefString(fileName),
caseSensitive ? true : false);
}
@ -70,16 +66,16 @@ int CEF_CALLBACK zip_reader_close(struct _cef_zip_reader_t* self)
return CefZipReaderCppToC::Get(self)->Close();
}
cef_string_t CEF_CALLBACK zip_reader_get_file_name(
cef_string_userfree_t CEF_CALLBACK zip_reader_get_file_name(
struct _cef_zip_reader_t* self)
{
DCHECK(self);
if(!self)
return NULL;
std::wstring retStr = CefZipReaderCppToC::Get(self)->GetFileName();
CefString retStr = CefZipReaderCppToC::Get(self)->GetFileName();
if(!retStr.empty())
return cef_string_alloc(retStr.c_str());
return retStr.DetachToUserFree();
return NULL;
}
@ -103,17 +99,13 @@ time_t CEF_CALLBACK zip_reader_get_file_last_modified(
}
int CEF_CALLBACK zip_reader_open_file(struct _cef_zip_reader_t* self,
const wchar_t* password)
const cef_string_t* password)
{
DCHECK(self);
if(!self)
return 0;
std::wstring passwordStr;
if (password)
passwordStr = password;
return CefZipReaderCppToC::Get(self)->OpenFile(passwordStr);
return CefZipReaderCppToC::Get(self)->OpenFile(CefString(password));
}
int CEF_CALLBACK zip_reader_close_file(struct _cef_zip_reader_t* self)

View File

@ -13,22 +13,23 @@
#include "libcef_dll/cpptoc/handler_cpptoc.h"
#include "libcef_dll/ctocpp/browser_ctocpp.h"
#include "libcef_dll/ctocpp/frame_ctocpp.h"
#include "libcef_dll/transfer_util.h"
// STATIC METHODS - Body may be edited by hand.
bool CefBrowser::CreateBrowser(CefWindowInfo& windowInfo, bool popup,
CefRefPtr<CefHandler> handler, const std::wstring& url)
CefRefPtr<CefHandler> handler, const CefString& url)
{
return cef_browser_create(&windowInfo, popup, CefHandlerCppToC::Wrap(handler),
url.c_str())?true:false;
url.GetStruct())?true:false;
}
CefRefPtr<CefBrowser> CefBrowser::CreateBrowserSync(CefWindowInfo& windowInfo,
bool popup, CefRefPtr<CefHandler> handler, const std::wstring& url)
bool popup, CefRefPtr<CefHandler> handler, const CefString& url)
{
cef_browser_t* impl = cef_browser_create_sync(&windowInfo, popup,
CefHandlerCppToC::Wrap(handler), url.c_str());
CefHandlerCppToC::Wrap(handler), url.GetStruct());
if(impl)
return CefBrowserCToCpp::Wrap(impl);
return NULL;
@ -153,19 +154,19 @@ CefRefPtr<CefFrame> CefBrowserCToCpp::GetFocusedFrame()
return NULL;
}
CefRefPtr<CefFrame> CefBrowserCToCpp::GetFrame(const std::wstring& name)
CefRefPtr<CefFrame> CefBrowserCToCpp::GetFrame(const CefString& name)
{
if(CEF_MEMBER_MISSING(struct_, get_main_frame))
return NULL;
cef_frame_t* frameStruct = struct_->get_frame(struct_, name.c_str());
cef_frame_t* frameStruct = struct_->get_frame(struct_, name.GetStruct());
if(frameStruct)
return CefFrameCToCpp::Wrap(frameStruct);
return NULL;
}
void CefBrowserCToCpp::GetFrameNames(std::vector<std::wstring>& names)
void CefBrowserCToCpp::GetFrameNames(std::vector<CefString>& names)
{
if(CEF_MEMBER_MISSING(struct_, get_frame_names))
return;
@ -173,24 +174,17 @@ void CefBrowserCToCpp::GetFrameNames(std::vector<std::wstring>& names)
cef_string_list_t list = cef_string_list_alloc();
struct_->get_frame_names(struct_, list);
cef_string_t str;
int size = cef_string_list_size(list);
for(int i = 0; i < size; ++i) {
str = cef_string_list_value(list, i);
names.push_back(str);
cef_string_free(str);
}
transfer_string_list_contents(list, names);
cef_string_list_free(list);
}
void CefBrowserCToCpp::Find(int identifier, const std::wstring& searchText,
void CefBrowserCToCpp::Find(int identifier, const CefString& searchText,
bool forward, bool matchCase, bool findNext)
{
if(CEF_MEMBER_MISSING(struct_, find))
return;
struct_->find(struct_, identifier, searchText.c_str(), forward,
struct_->find(struct_, identifier, searchText.GetStruct(), forward,
matchCase, findNext);
}

View File

@ -44,10 +44,10 @@ public:
virtual CefRefPtr<CefHandler> GetHandler();
virtual CefRefPtr<CefFrame> GetMainFrame();
virtual CefRefPtr<CefFrame> GetFocusedFrame();
virtual CefRefPtr<CefFrame> GetFrame(const std::wstring& name);
virtual void GetFrameNames(std::vector<std::wstring>& names);
virtual void Find(int identifier, const std::wstring& searchText,
bool forward, bool matchCase, bool findNext);
virtual CefRefPtr<CefFrame> GetFrame(const CefString& name);
virtual void GetFrameNames(std::vector<CefString>& names);
virtual void Find(int identifier, const CefString& searchText, bool forward,
bool matchCase, bool findNext);
virtual void StopFinding(bool clearSelection);
};

View File

@ -89,31 +89,25 @@ void CefFrameCToCpp::ViewSource()
struct_->view_source(struct_);
}
std::wstring CefFrameCToCpp::GetSource()
CefString CefFrameCToCpp::GetSource()
{
std::wstring str;
CefString str;
if(CEF_MEMBER_MISSING(struct_, get_source))
return str;
cef_string_t cef_str = struct_->get_source(struct_);
if(cef_str) {
str = cef_str;
cef_string_free(cef_str);
}
cef_string_userfree_t strPtr = struct_->get_source(struct_);
str.AttachToUserFree(strPtr);
return str;
}
std::wstring CefFrameCToCpp::GetText()
CefString CefFrameCToCpp::GetText()
{
std::wstring str;
CefString str;
if(CEF_MEMBER_MISSING(struct_, get_text))
return str;
cef_string_t cef_str = struct_->get_text(struct_);
if(cef_str) {
str = cef_str;
cef_string_free(cef_str);
}
cef_string_userfree_t strPtr = struct_->get_text(struct_);
str.AttachToUserFree(strPtr);
return str;
}
@ -125,41 +119,40 @@ void CefFrameCToCpp::LoadRequest(CefRefPtr<CefRequest> request)
struct_->load_request(struct_, CefRequestCToCpp::Unwrap(request));
}
void CefFrameCToCpp::LoadURL(const std::wstring& url)
void CefFrameCToCpp::LoadURL(const CefString& url)
{
if(CEF_MEMBER_MISSING(struct_, load_url))
return;
struct_->load_url(struct_, url.c_str());
struct_->load_url(struct_, url.GetStruct());
}
void CefFrameCToCpp::LoadString(const std::wstring& string,
const std::wstring& url)
void CefFrameCToCpp::LoadString(const CefString& string, const CefString& url)
{
if(CEF_MEMBER_MISSING(struct_, load_string))
return;
struct_->load_string(struct_, string.c_str(), url.c_str());
struct_->load_string(struct_, string.GetStruct(), url.GetStruct());
}
void CefFrameCToCpp::LoadStream(CefRefPtr<CefStreamReader> stream,
const std::wstring& url)
const CefString& url)
{
if(CEF_MEMBER_MISSING(struct_, load_stream))
return;
struct_->load_stream(struct_, CefStreamReaderCToCpp::Unwrap(stream),
url.c_str());
url.GetStruct());
}
void CefFrameCToCpp::ExecuteJavaScript(const std::wstring& jsCode,
const std::wstring& scriptUrl, int startLine)
void CefFrameCToCpp::ExecuteJavaScript(const CefString& jsCode,
const CefString& scriptUrl, int startLine)
{
if(CEF_MEMBER_MISSING(struct_, execute_java_script))
return;
struct_->execute_java_script(struct_, jsCode.c_str(), scriptUrl.c_str(),
startLine);
struct_->execute_java_script(struct_, jsCode.GetStruct(),
scriptUrl.GetStruct(), startLine);
}
bool CefFrameCToCpp::IsMain()
@ -178,31 +171,25 @@ bool CefFrameCToCpp::IsFocused()
return struct_->is_focused(struct_)?true:false;
}
std::wstring CefFrameCToCpp::GetName()
CefString CefFrameCToCpp::GetName()
{
std::wstring str;
CefString str;
if(CEF_MEMBER_MISSING(struct_, get_name))
return str;
cef_string_t cef_str = struct_->get_name(struct_);
if(cef_str) {
str = cef_str;
cef_string_free(cef_str);
}
cef_string_userfree_t strPtr = struct_->get_name(struct_);
str.AttachToUserFree(strPtr);
return str;
}
std::wstring CefFrameCToCpp::GetURL()
CefString CefFrameCToCpp::GetURL()
{
std::wstring str;
CefString str;
if(CEF_MEMBER_MISSING(struct_, get_url))
return str;
cef_string_t cef_str = struct_->get_url(struct_);
if(cef_str) {
str = cef_str;
cef_string_free(cef_str);
}
cef_string_userfree_t strPtr = struct_->get_url(struct_);
str.AttachToUserFree(strPtr);
return str;
}

View File

@ -40,19 +40,19 @@ public:
virtual void SelectAll();
virtual void Print();
virtual void ViewSource();
virtual std::wstring GetSource();
virtual std::wstring GetText();
virtual CefString GetSource();
virtual CefString GetText();
virtual void LoadRequest(CefRefPtr<CefRequest> request);
virtual void LoadURL(const std::wstring& url);
virtual void LoadString(const std::wstring& string, const std::wstring& url);
virtual void LoadURL(const CefString& url);
virtual void LoadString(const CefString& string, const CefString& url);
virtual void LoadStream(CefRefPtr<CefStreamReader> stream,
const std::wstring& url);
virtual void ExecuteJavaScript(const std::wstring& jsCode,
const std::wstring& scriptUrl, int startLine);
const CefString& url);
virtual void ExecuteJavaScript(const CefString& jsCode,
const CefString& scriptUrl, int startLine);
virtual bool IsMain();
virtual bool IsFocused();
virtual std::wstring GetName();
virtual std::wstring GetURL();
virtual CefString GetName();
virtual CefString GetURL();
};
#endif // USING_CEF_SHARED

View File

@ -17,7 +17,6 @@
#include "libcef_dll/cpptoc/v8value_cpptoc.h"
#include "libcef_dll/ctocpp/download_handler_ctocpp.h"
#include "libcef_dll/ctocpp/handler_ctocpp.h"
#include "libcef_dll/transfer_util.h"
// VIRTUAL METHODS - Body may be edited by hand.
@ -25,7 +24,7 @@
CefHandler::RetVal CefHandlerCToCpp::HandleBeforeCreated(
CefRefPtr<CefBrowser> parentBrowser, CefWindowInfo& windowInfo, bool popup,
const CefPopupFeatures& popupFeatures, CefRefPtr<CefHandler>& handler,
std::wstring& url, CefBrowserSettings& settings)
CefString& url, CefBrowserSettings& settings)
{
if(CEF_MEMBER_MISSING(struct_, handle_before_created))
return RV_CONTINUE;
@ -39,13 +38,9 @@ CefHandler::RetVal CefHandlerCToCpp::HandleBeforeCreated(
handlerStruct = CefHandlerCToCpp::Unwrap(handler);
cef_handler_t *origHandlerStruct = handlerStruct;
cef_string_t urlRet = NULL;
if(!url.empty())
urlRet = cef_string_alloc(url.c_str());
cef_retval_t rv = struct_->handle_before_created(struct_,
browserStruct, &windowInfo, popup, &popupFeatures, &handlerStruct,
&urlRet, &settings);
url.GetWritableStruct(), &settings);
if(handlerStruct && handlerStruct != origHandlerStruct) {
// The handler was changed.
@ -55,8 +50,6 @@ CefHandler::RetVal CefHandlerCToCpp::HandleBeforeCreated(
handler = NULL;
}
transfer_string_contents(urlRet, url, true);
return rv;
}
@ -72,24 +65,24 @@ CefHandler::RetVal CefHandlerCToCpp::HandleAfterCreated(
CefHandler::RetVal CefHandlerCToCpp::HandleAddressChange(
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
const std::wstring& url)
const CefString& url)
{
if(CEF_MEMBER_MISSING(struct_, handle_address_change))
return RV_CONTINUE;
return struct_->handle_address_change(struct_,
CefBrowserCppToC::Wrap(browser), CefFrameCppToC::Wrap(frame),
url.c_str());
url.GetStruct());
}
CefHandler::RetVal CefHandlerCToCpp::HandleTitleChange(
CefRefPtr<CefBrowser> browser, const std::wstring& title)
CefRefPtr<CefBrowser> browser, const CefString& title)
{
if(CEF_MEMBER_MISSING(struct_, handle_title_change))
return RV_CONTINUE;
return struct_->handle_title_change(struct_, CefBrowserCppToC::Wrap(browser),
title.c_str());
title.GetStruct());
}
CefHandler::RetVal CefHandlerCToCpp::HandleBeforeBrowse(
@ -134,46 +127,30 @@ CefHandler::RetVal CefHandlerCToCpp::HandleLoadEnd(
CefHandler::RetVal CefHandlerCToCpp::HandleLoadError(
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
ErrorCode errorCode, const std::wstring& failedUrl,
std::wstring& errorText)
ErrorCode errorCode, const CefString& failedUrl, CefString& errorText)
{
if(CEF_MEMBER_MISSING(struct_, handle_load_error))
return RV_CONTINUE;
cef_string_t errorTextRet = NULL;
if(!errorText.empty())
errorTextRet = cef_string_alloc(errorText.c_str());
cef_retval_t rv = struct_->handle_load_error(struct_,
return struct_->handle_load_error(struct_,
CefBrowserCppToC::Wrap(browser), CefFrameCppToC::Wrap(frame), errorCode,
failedUrl.c_str(), &errorTextRet);
transfer_string_contents(errorTextRet, errorText, true);
return rv;
failedUrl.GetStruct(), errorText.GetWritableStruct());
}
CefHandler::RetVal CefHandlerCToCpp::HandleBeforeResourceLoad(
CefRefPtr<CefBrowser> browser, CefRefPtr<CefRequest> request,
std::wstring& redirectUrl, CefRefPtr<CefStreamReader>& resourceStream,
std::wstring& mimeType, int loadFlags)
CefString& redirectUrl, CefRefPtr<CefStreamReader>& resourceStream,
CefString& mimeType, int loadFlags)
{
if(CEF_MEMBER_MISSING(struct_, handle_before_resource_load))
return RV_CONTINUE;
cef_string_t redirectUrlRet = NULL;
cef_string_t mimeTypeRet = NULL;
cef_stream_reader_t* streamRet = NULL;
if(!redirectUrl.empty())
redirectUrlRet = cef_string_alloc(redirectUrl.c_str());
cef_retval_t rv = struct_->handle_before_resource_load(struct_,
CefBrowserCppToC::Wrap(browser), CefRequestCppToC::Wrap(request),
&redirectUrlRet, &streamRet, &mimeTypeRet, loadFlags);
transfer_string_contents(redirectUrlRet, redirectUrl, true);
transfer_string_contents(mimeTypeRet, mimeType, true);
redirectUrl.GetWritableStruct(), &streamRet, mimeType.GetWritableStruct(),
loadFlags);
if(streamRet)
resourceStream = CefStreamReaderCppToC::Unwrap(streamRet);
@ -182,8 +159,8 @@ CefHandler::RetVal CefHandlerCToCpp::HandleBeforeResourceLoad(
}
CefHandler::RetVal CefHandlerCToCpp::HandleDownloadResponse(
CefRefPtr<CefBrowser> browser, const std::wstring& mimeType,
const std::wstring& fileName, int64 contentLength,
CefRefPtr<CefBrowser> browser, const CefString& mimeType,
const CefString& fileName, int64 contentLength,
CefRefPtr<CefDownloadHandler>& handler)
{
if(CEF_MEMBER_MISSING(struct_, handle_download_response))
@ -192,7 +169,7 @@ CefHandler::RetVal CefHandlerCToCpp::HandleDownloadResponse(
cef_download_handler_t* handlerRet = NULL;
cef_retval_t rv = struct_->handle_download_response(struct_,
CefBrowserCppToC::Wrap(browser), mimeType.c_str(), fileName.c_str(),
CefBrowserCppToC::Wrap(browser), mimeType.GetStruct(), fileName.GetStruct(),
contentLength, &handlerRet);
if(handlerRet)
@ -212,21 +189,13 @@ CefHandler::RetVal CefHandlerCToCpp::HandleBeforeMenu(
}
CefHandler::RetVal CefHandlerCToCpp::HandleGetMenuLabel(
CefRefPtr<CefBrowser> browser, MenuId menuId, std::wstring& label)
CefRefPtr<CefBrowser> browser, MenuId menuId, CefString& label)
{
if(CEF_MEMBER_MISSING(struct_, handle_get_menu_label))
return RV_CONTINUE;
cef_string_t labelRet = NULL;
if(!label.empty())
labelRet = cef_string_alloc(label.c_str());
cef_retval_t rv = struct_->handle_get_menu_label(struct_,
CefBrowserCppToC::Wrap(browser), menuId, &labelRet);
transfer_string_contents(labelRet, label, true);
return rv;
return struct_->handle_get_menu_label(struct_,
CefBrowserCppToC::Wrap(browser), menuId, label.GetWritableStruct());
}
CefHandler::RetVal CefHandlerCToCpp::HandleMenuAction(
@ -251,61 +220,36 @@ CefHandler::RetVal CefHandlerCToCpp::HandlePrintOptions(
CefHandler::RetVal CefHandlerCToCpp::HandlePrintHeaderFooter(
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
CefPrintInfo& printInfo, const std::wstring& url,
const std::wstring& title, int currentPage, int maxPages,
std::wstring& topLeft, std::wstring& topCenter, std::wstring& topRight,
std::wstring& bottomLeft, std::wstring& bottomCenter,
std::wstring& bottomRight)
CefPrintInfo& printInfo, const CefString& url, const CefString& title,
int currentPage, int maxPages, CefString& topLeft, CefString& topCenter,
CefString& topRight, CefString& bottomLeft, CefString& bottomCenter,
CefString& bottomRight)
{
if(CEF_MEMBER_MISSING(struct_, handle_print_header_footer))
return RV_CONTINUE;
cef_string_t topLeftRet = NULL, topCenterRet = NULL, topRightRet = NULL,
bottomLeftRet = NULL, bottomCenterRet = NULL, bottomRightRet = NULL;
if(!topLeft.empty())
topLeftRet = cef_string_alloc(topLeft.c_str());
if(!topCenter.empty())
topCenterRet = cef_string_alloc(topCenter.c_str());
if(!topRight.empty())
topRightRet = cef_string_alloc(topRight.c_str());
if(!bottomLeft.empty())
bottomLeftRet = cef_string_alloc(bottomLeft.c_str());
if(!bottomCenter.empty())
bottomCenterRet = cef_string_alloc(bottomCenter.c_str());
if(!bottomRight.empty())
bottomRightRet = cef_string_alloc(bottomRight.c_str());
cef_retval_t rv = struct_->handle_print_header_footer(struct_,
return struct_->handle_print_header_footer(struct_,
CefBrowserCppToC::Wrap(browser), CefFrameCppToC::Wrap(frame),
&printInfo, url.c_str(), title.c_str(), currentPage, maxPages,
&topLeftRet, &topCenterRet, &topRightRet, &bottomLeftRet,
&bottomCenterRet, &bottomRightRet);
transfer_string_contents(topLeftRet, topLeft, true);
transfer_string_contents(topCenterRet, topCenter, true);
transfer_string_contents(topRightRet, topRight, true);
transfer_string_contents(bottomLeftRet, bottomLeft, true);
transfer_string_contents(bottomCenterRet, bottomCenter, true);
transfer_string_contents(bottomRightRet, bottomRight, true);
return rv;
&printInfo, url.GetStruct(), title.GetStruct(), currentPage, maxPages,
topLeft.GetWritableStruct(), topCenter.GetWritableStruct(),
topRight.GetWritableStruct(), bottomLeft.GetWritableStruct(),
bottomCenter.GetWritableStruct(), bottomRight.GetWritableStruct());
}
CefHandler::RetVal CefHandlerCToCpp::HandleJSAlert(
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
const std::wstring& message)
const CefString& message)
{
if(CEF_MEMBER_MISSING(struct_, handle_jsalert))
return RV_CONTINUE;
return struct_->handle_jsalert(struct_, CefBrowserCppToC::Wrap(browser),
CefFrameCppToC::Wrap(frame), message.c_str());
CefFrameCppToC::Wrap(frame), message.GetStruct());
}
CefHandler::RetVal CefHandlerCToCpp::HandleJSConfirm(
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
const std::wstring& message, bool& retval)
const CefString& message, bool& retval)
{
if(CEF_MEMBER_MISSING(struct_, handle_jsconfirm))
return RV_CONTINUE;
@ -313,31 +257,25 @@ CefHandler::RetVal CefHandlerCToCpp::HandleJSConfirm(
int ret = 0;
cef_retval_t rv = struct_->handle_jsconfirm(struct_,
CefBrowserCppToC::Wrap(browser), CefFrameCppToC::Wrap(frame),
message.c_str(), &ret);
message.GetStruct(), &ret);
retval = (ret ? true : false);
return rv;
}
CefHandler::RetVal CefHandlerCToCpp::HandleJSPrompt(
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
const std::wstring& message, const std::wstring& defaultValue,
bool& retval, std::wstring& result)
const CefString& message, const CefString& defaultValue, bool& retval,
CefString& result)
{
if(CEF_MEMBER_MISSING(struct_, handle_jsprompt))
return RV_CONTINUE;
cef_string_t resultRet = NULL;
if(!result.empty())
resultRet = cef_string_alloc(result.c_str());
int ret = 0;
cef_retval_t rv = struct_->handle_jsprompt(struct_,
CefBrowserCppToC::Wrap(browser), CefFrameCppToC::Wrap(frame),
message.c_str(), defaultValue.c_str(), &ret, &resultRet);
message.GetStruct(), defaultValue.GetStruct(), &ret,
result.GetWritableStruct());
retval = (ret ? true : false);
transfer_string_contents(resultRet, result, true);
return rv;
}
@ -394,31 +332,25 @@ CefHandler::RetVal CefHandlerCToCpp::HandleKeyEvent(
}
CefHandler::RetVal CefHandlerCToCpp::HandleTooltip(
CefRefPtr<CefBrowser> browser, std::wstring& text)
CefRefPtr<CefBrowser> browser, CefString& text)
{
if(CEF_MEMBER_MISSING(struct_, handle_tooltip))
return RV_CONTINUE;
cef_string_t textRet = NULL;
if(!text.empty())
textRet = cef_string_alloc(text.c_str());
cef_retval_t rv = struct_->handle_tooltip(struct_,
CefBrowserCppToC::Wrap(browser), &textRet);
transfer_string_contents(textRet, text, true);
return rv;
return struct_->handle_tooltip(struct_,
CefBrowserCppToC::Wrap(browser), text.GetWritableStruct());
}
CefHandler::RetVal CefHandlerCToCpp::HandleConsoleMessage(
CefRefPtr<CefBrowser> browser, const std::wstring& message,
const std::wstring& source, int line)
CefRefPtr<CefBrowser> browser, const CefString& message,
const CefString& source, int line)
{
if(CEF_MEMBER_MISSING(struct_, handle_console_message))
return RV_CONTINUE;
return struct_->handle_console_message(struct_,
CefBrowserCppToC::Wrap(browser), message.c_str(), source.c_str(), line);
CefBrowserCppToC::Wrap(browser), message.GetStruct(), source.GetStruct(),
line);
}
CefHandler::RetVal CefHandlerCToCpp::HandleFindResult(

View File

@ -34,12 +34,12 @@ public:
virtual RetVal HandleBeforeCreated(CefRefPtr<CefBrowser> parentBrowser,
CefWindowInfo& windowInfo, bool popup,
const CefPopupFeatures& popupFeatures, CefRefPtr<CefHandler>& handler,
std::wstring& url, CefBrowserSettings& settings);
CefString& url, CefBrowserSettings& settings);
virtual RetVal HandleAfterCreated(CefRefPtr<CefBrowser> browser);
virtual RetVal HandleAddressChange(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, const std::wstring& url);
CefRefPtr<CefFrame> frame, const CefString& url);
virtual RetVal HandleTitleChange(CefRefPtr<CefBrowser> browser,
const std::wstring& title);
const CefString& title);
virtual RetVal HandleBeforeBrowse(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request,
NavType navType, bool isRedirect);
@ -49,34 +49,33 @@ public:
CefRefPtr<CefFrame> frame);
virtual RetVal HandleLoadError(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, ErrorCode errorCode,
const std::wstring& failedUrl, std::wstring& errorText);
const CefString& failedUrl, CefString& errorText);
virtual RetVal HandleBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefRequest> request, std::wstring& redirectUrl,
CefRefPtr<CefStreamReader>& resourceStream, std::wstring& mimeType,
CefRefPtr<CefRequest> request, CefString& redirectUrl,
CefRefPtr<CefStreamReader>& resourceStream, CefString& mimeType,
int loadFlags);
virtual RetVal HandleDownloadResponse(CefRefPtr<CefBrowser> browser,
const std::wstring& mimeType, const std::wstring& fileName,
const CefString& mimeType, const CefString& fileName,
int64 contentLength, CefRefPtr<CefDownloadHandler>& handler);
virtual RetVal HandleBeforeMenu(CefRefPtr<CefBrowser> browser,
const MenuInfo& menuInfo);
virtual RetVal HandleGetMenuLabel(CefRefPtr<CefBrowser> browser,
MenuId menuId, std::wstring& label);
MenuId menuId, CefString& label);
virtual RetVal HandleMenuAction(CefRefPtr<CefBrowser> browser, MenuId menuId);
virtual RetVal HandlePrintOptions(CefRefPtr<CefBrowser> browser,
CefPrintOptions& printOptions);
virtual RetVal HandlePrintHeaderFooter(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, CefPrintInfo& printInfo,
const std::wstring& url, const std::wstring& title, int currentPage,
int maxPages, std::wstring& topLeft, std::wstring& topCenter,
std::wstring& topRight, std::wstring& bottomLeft,
std::wstring& bottomCenter, std::wstring& bottomRight);
CefRefPtr<CefFrame> frame, CefPrintInfo& printInfo, const CefString& url,
const CefString& title, int currentPage, int maxPages,
CefString& topLeft, CefString& topCenter, CefString& topRight,
CefString& bottomLeft, CefString& bottomCenter, CefString& bottomRight);
virtual RetVal HandleJSAlert(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, const std::wstring& message);
CefRefPtr<CefFrame> frame, const CefString& message);
virtual RetVal HandleJSConfirm(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, const std::wstring& message, bool& retval);
CefRefPtr<CefFrame> frame, const CefString& message, bool& retval);
virtual RetVal HandleJSPrompt(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, const std::wstring& message,
const std::wstring& defaultValue, bool& retval, std::wstring& result);
CefRefPtr<CefFrame> frame, const CefString& message,
const CefString& defaultValue, bool& retval, CefString& result);
virtual RetVal HandleJSBinding(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Value> object);
virtual RetVal HandleBeforeWindowClose(CefRefPtr<CefBrowser> browser);
@ -84,10 +83,9 @@ public:
virtual RetVal HandleSetFocus(CefRefPtr<CefBrowser> browser, bool isWidget);
virtual RetVal HandleKeyEvent(CefRefPtr<CefBrowser> browser,
KeyEventType type, int code, int modifiers, bool isSystemKey);
virtual RetVal HandleTooltip(CefRefPtr<CefBrowser> browser,
std::wstring& text);
virtual RetVal HandleTooltip(CefRefPtr<CefBrowser> browser, CefString& text);
virtual RetVal HandleConsoleMessage(CefRefPtr<CefBrowser> browser,
const std::wstring& message, const std::wstring& source, int line);
const CefString& message, const CefString& source, int line);
virtual RetVal HandleFindResult(CefRefPtr<CefBrowser> browser, int identifier,
int count, const CefRect& selectionRect, int activeMatchOrdinal,
bool finalUpdate);

View File

@ -34,12 +34,12 @@ void CefPostDataElementCToCpp::SetToEmpty()
return struct_->set_to_empty(struct_);
}
void CefPostDataElementCToCpp::SetToFile(const std::wstring& fileName)
void CefPostDataElementCToCpp::SetToFile(const CefString& fileName)
{
if(CEF_MEMBER_MISSING(struct_, set_to_file))
return;
return struct_->set_to_file(struct_, fileName.c_str());
return struct_->set_to_file(struct_, fileName.GetStruct());
}
void CefPostDataElementCToCpp::SetToBytes(size_t size, const void* bytes)
@ -58,18 +58,14 @@ CefPostDataElement::Type CefPostDataElementCToCpp::GetType()
return struct_->get_type(struct_);
}
std::wstring CefPostDataElementCToCpp::GetFile()
CefString CefPostDataElementCToCpp::GetFile()
{
std::wstring str;
CefString str;
if(CEF_MEMBER_MISSING(struct_, get_file))
return str;
cef_string_t cef_str = struct_->get_file(struct_);
if(cef_str) {
str = cef_str;
cef_string_free(cef_str);
}
cef_string_userfree_t strPtr = struct_->get_file(struct_);
str.AttachToUserFree(strPtr);
return str;
}

View File

@ -34,10 +34,10 @@ public:
// CefPostDataElement methods
virtual void SetToEmpty();
virtual void SetToFile(const std::wstring& fileName);
virtual void SetToFile(const CefString& fileName);
virtual void SetToBytes(size_t size, const void* bytes);
virtual Type GetType();
virtual std::wstring GetFile();
virtual CefString GetFile();
virtual size_t GetBytesCount();
virtual size_t GetBytes(size_t size, void* bytes);
};

View File

@ -28,48 +28,42 @@ CefRefPtr<CefRequest> CefRequest::CreateRequest()
// VIRTUAL METHODS - Body may be edited by hand.
std::wstring CefRequestCToCpp::GetURL()
CefString CefRequestCToCpp::GetURL()
{
std::wstring str;
CefString str;
if(CEF_MEMBER_MISSING(struct_, get_url))
return str;
cef_string_t cef_str = struct_->get_url(struct_);
if(cef_str) {
str = cef_str;
cef_string_free(cef_str);
}
cef_string_userfree_t strPtr = struct_->get_url(struct_);
str.AttachToUserFree(strPtr);
return str;
}
void CefRequestCToCpp::SetURL(const std::wstring& url)
void CefRequestCToCpp::SetURL(const CefString& url)
{
if(CEF_MEMBER_MISSING(struct_, set_url))
return;
struct_->set_url(struct_, url.c_str());
struct_->set_url(struct_, url.GetStruct());
}
std::wstring CefRequestCToCpp::GetMethod()
CefString CefRequestCToCpp::GetMethod()
{
std::wstring str;
CefString str;
if(CEF_MEMBER_MISSING(struct_, get_method))
return str;
cef_string_t cef_str = struct_->get_method(struct_);
if(cef_str) {
str = cef_str;
cef_string_free(cef_str);
}
cef_string_userfree_t strPtr = struct_->get_method(struct_);
str.AttachToUserFree(strPtr);
return str;
}
void CefRequestCToCpp::SetMethod(const std::wstring& method)
void CefRequestCToCpp::SetMethod(const CefString& method)
{
if(CEF_MEMBER_MISSING(struct_, set_method))
return;
struct_->set_method(struct_, method.c_str());
struct_->set_method(struct_, method.GetStruct());
}
CefRefPtr<CefPostData> CefRequestCToCpp::GetPostData()
@ -128,7 +122,7 @@ void CefRequestCToCpp::SetHeaderMap(const HeaderMap& headerMap)
cef_string_map_free(map);
}
void CefRequestCToCpp::Set(const std::wstring& url, const std::wstring& method,
void CefRequestCToCpp::Set(const CefString& url, const CefString& method,
CefRefPtr<CefPostData> postData, const HeaderMap& headerMap)
{
if(CEF_MEMBER_MISSING(struct_, set))
@ -146,7 +140,8 @@ void CefRequestCToCpp::Set(const std::wstring& url, const std::wstring& method,
transfer_string_map_contents(headerMap, map);
}
struct_->set(struct_, url.c_str(), method.c_str(), postDataStruct, map);
struct_->set(struct_, url.GetStruct(), method.GetStruct(), postDataStruct,
map);
if(map)
cef_string_map_free(map);

View File

@ -31,15 +31,15 @@ public:
virtual ~CefRequestCToCpp() {}
// CefRequest methods
virtual std::wstring GetURL();
virtual void SetURL(const std::wstring& url);
virtual std::wstring GetMethod();
virtual void SetMethod(const std::wstring& method);
virtual CefString GetURL();
virtual void SetURL(const CefString& url);
virtual CefString GetMethod();
virtual void SetMethod(const CefString& method);
virtual CefRefPtr<CefPostData> GetPostData();
virtual void SetPostData(CefRefPtr<CefPostData> postData);
virtual void GetHeaderMap(HeaderMap& headerMap);
virtual void SetHeaderMap(const HeaderMap& headerMap);
virtual void Set(const std::wstring& url, const std::wstring& method,
virtual void Set(const CefString& url, const CefString& method,
CefRefPtr<CefPostData> postData, const HeaderMap& headerMap);
};

View File

@ -12,27 +12,18 @@
#include "libcef_dll/cpptoc/request_cpptoc.h"
#include "libcef_dll/ctocpp/scheme_handler_ctocpp.h"
#include "libcef_dll/transfer_util.h"
// VIRTUAL METHODS - Body may be edited by hand.
bool CefSchemeHandlerCToCpp::ProcessRequest(CefRefPtr<CefRequest> request,
std::wstring& mime_type, int* response_length)
CefString& mime_type, int* response_length)
{
if(CEF_MEMBER_MISSING(struct_, process_request))
return false;
cef_string_t mimeTypeRet = NULL;
if(!mime_type.empty())
mimeTypeRet = cef_string_alloc(mime_type.c_str());
int rv = struct_->process_request(struct_, CefRequestCppToC::Wrap(request),
&mimeTypeRet, response_length);
transfer_string_contents(mimeTypeRet, mime_type, true);
return rv ? true : false;
return struct_->process_request(struct_, CefRequestCppToC::Wrap(request),
mime_type.GetWritableStruct(), response_length) ? true : false;
}
void CefSchemeHandlerCToCpp::Cancel()
@ -49,8 +40,8 @@ bool CefSchemeHandlerCToCpp::ReadResponse(void* data_out, int bytes_to_read,
if(CEF_MEMBER_MISSING(struct_, read_response))
return false;
return struct_->read_response(struct_, data_out, bytes_to_read, bytes_read)
? true : false;
return struct_->read_response(struct_, data_out, bytes_to_read, bytes_read) ?
true : false;
}

View File

@ -34,7 +34,7 @@ public:
// CefSchemeHandler methods
virtual bool ProcessRequest(CefRefPtr<CefRequest> request,
std::wstring& mime_type, int* response_length);
CefString& mime_type, int* response_length);
virtual void Cancel();
virtual bool ReadResponse(void* data_out, int bytes_to_read, int* bytes_read);
};

View File

@ -17,10 +17,10 @@
// STATIC METHODS - Body may be edited by hand.
CefRefPtr<CefStreamReader> CefStreamReader::CreateForFile(
const std::wstring& fileName)
const CefString& fileName)
{
cef_stream_reader_t* impl =
cef_stream_reader_create_for_file(fileName.c_str());
cef_stream_reader_create_for_file(fileName.GetStruct());
if(impl)
return CefStreamReaderCToCpp::Wrap(impl);
return NULL;

View File

@ -17,14 +17,14 @@
// STATIC METHODS - Body may be edited by hand.
CefRefPtr<CefStreamWriter> CefStreamWriter::CreateForFile(
const std::wstring& fileName)
const CefString& fileName)
{
DCHECK(!fileName.empty());
if(fileName.empty())
return NULL;
cef_stream_writer_t* impl =
cef_stream_writer_create_for_file(fileName.c_str());
cef_stream_writer_create_for_file(fileName.GetStruct());
if(impl)
return CefStreamWriterCToCpp::Wrap(impl);
return NULL;

View File

@ -16,9 +16,9 @@
// VIRTUAL METHODS - Body may be edited by hand.
bool CefV8HandlerCToCpp::Execute(const std::wstring& name,
bool CefV8HandlerCToCpp::Execute(const CefString& name,
CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments,
CefRefPtr<CefV8Value>& retval, std::wstring& exception)
CefRefPtr<CefV8Value>& retval, CefString& exception)
{
if(CEF_MEMBER_MISSING(struct_, execute))
return RV_CONTINUE;
@ -32,17 +32,12 @@ bool CefV8HandlerCToCpp::Execute(const std::wstring& name,
}
cef_v8value_t* retvalStruct = NULL;
cef_string_t exceptionStr = NULL;
int rv = struct_->execute(struct_, name.c_str(),
int rv = struct_->execute(struct_, name.GetStruct(),
CefV8ValueCppToC::Wrap(object), argsSize, argsStructPtr, &retvalStruct,
&exceptionStr);
exception.GetWritableStruct());
if(retvalStruct)
retval = CefV8ValueCppToC::Unwrap(retvalStruct);
if(exceptionStr) {
exception = exceptionStr;
cef_string_free(exceptionStr);
}
if(argsStructPtr)
delete [] argsStructPtr;

View File

@ -31,9 +31,9 @@ public:
virtual ~CefV8HandlerCToCpp() {}
// CefV8Handler methods
virtual bool Execute(const std::wstring& name, CefRefPtr<CefV8Value> object,
virtual bool Execute(const CefString& name, CefRefPtr<CefV8Value> object,
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
std::wstring& exception);
CefString& exception);
};
#endif // BUILDING_CEF_SHARED

View File

@ -13,6 +13,7 @@
#include "libcef_dll/cpptoc/base_cpptoc.h"
#include "libcef_dll/cpptoc/v8handler_cpptoc.h"
#include "libcef_dll/ctocpp/v8value_ctocpp.h"
#include "libcef_dll/transfer_util.h"
// STATIC METHODS - Body may be edited by hand.
@ -57,9 +58,9 @@ CefRefPtr<CefV8Value> CefV8Value::CreateDouble(double value)
return NULL;
}
CefRefPtr<CefV8Value> CefV8Value::CreateString(const std::wstring& value)
CefRefPtr<CefV8Value> CefV8Value::CreateString(const CefString& value)
{
cef_v8value_t* impl = cef_v8value_create_string(value.c_str());
cef_v8value_t* impl = cef_v8value_create_string(value.GetStruct());
if(impl)
return CefV8ValueCToCpp::Wrap(impl);
return NULL;
@ -85,14 +86,14 @@ CefRefPtr<CefV8Value> CefV8Value::CreateArray()
return NULL;
}
CefRefPtr<CefV8Value> CefV8Value::CreateFunction(const std::wstring& name,
CefRefPtr<CefV8Value> CefV8Value::CreateFunction(const CefString& name,
CefRefPtr<CefV8Handler> handler)
{
cef_v8handler_t* handlerStruct = NULL;
if(handler.get())
handlerStruct = CefV8HandlerCppToC::Wrap(handler);
cef_v8value_t* impl = cef_v8value_create_function(name.c_str(),
cef_v8value_t* impl = cef_v8value_create_function(name.GetStruct(),
handlerStruct);
if(impl)
return CefV8ValueCToCpp::Wrap(impl);
@ -198,26 +199,23 @@ double CefV8ValueCToCpp::GetDoubleValue()
return struct_->get_double_value(struct_);
}
std::wstring CefV8ValueCToCpp::GetStringValue()
CefString CefV8ValueCToCpp::GetStringValue()
{
std::wstring str;
CefString str;
if(CEF_MEMBER_MISSING(struct_, get_string_value))
return str;
cef_string_t cef_str = struct_->get_string_value(struct_);
if(cef_str) {
str = cef_str;
cef_string_free(cef_str);
}
cef_string_userfree_t strPtr = struct_->get_string_value(struct_);
str.AttachToUserFree(strPtr);
return str;
}
bool CefV8ValueCToCpp::HasValue(const std::wstring& key)
bool CefV8ValueCToCpp::HasValue(const CefString& key)
{
if(CEF_MEMBER_MISSING(struct_, has_value_bykey))
return false;
return struct_->has_value_bykey(struct_, key.c_str())?true:false;
return struct_->has_value_bykey(struct_, key.GetStruct())?true:false;
}
bool CefV8ValueCToCpp::HasValue(int index)
@ -228,12 +226,12 @@ bool CefV8ValueCToCpp::HasValue(int index)
return struct_->has_value_byindex(struct_, index)?true:false;
}
bool CefV8ValueCToCpp::DeleteValue(const std::wstring& key)
bool CefV8ValueCToCpp::DeleteValue(const CefString& key)
{
if(CEF_MEMBER_MISSING(struct_, delete_value_bykey))
return false;
return struct_->delete_value_bykey(struct_, key.c_str())?true:false;
return struct_->delete_value_bykey(struct_, key.GetStruct())?true:false;
}
bool CefV8ValueCToCpp::DeleteValue(int index)
@ -244,12 +242,13 @@ bool CefV8ValueCToCpp::DeleteValue(int index)
return struct_->delete_value_byindex(struct_, index)?true:false;
}
CefRefPtr<CefV8Value> CefV8ValueCToCpp::GetValue(const std::wstring& key)
CefRefPtr<CefV8Value> CefV8ValueCToCpp::GetValue(const CefString& key)
{
if(CEF_MEMBER_MISSING(struct_, get_value_bykey))
return false;
cef_v8value_t* valueStruct = struct_->get_value_bykey(struct_, key.c_str());
cef_v8value_t* valueStruct = struct_->get_value_bykey(struct_,
key.GetStruct());
if(valueStruct)
return CefV8ValueCToCpp::Wrap(valueStruct);
return NULL;
@ -266,13 +265,13 @@ CefRefPtr<CefV8Value> CefV8ValueCToCpp::GetValue(int index)
return NULL;
}
bool CefV8ValueCToCpp::SetValue(const std::wstring& key,
bool CefV8ValueCToCpp::SetValue(const CefString& key,
CefRefPtr<CefV8Value> value)
{
if(CEF_MEMBER_MISSING(struct_, set_value_bykey))
return false;
return struct_->set_value_bykey(struct_, key.c_str(),
return struct_->set_value_bykey(struct_, key.GetStruct(),
CefV8ValueCToCpp::Unwrap(value))?true:false;
}
@ -285,20 +284,14 @@ bool CefV8ValueCToCpp::SetValue(int index, CefRefPtr<CefV8Value> value)
CefV8ValueCToCpp::Unwrap(value))?true:false;
}
bool CefV8ValueCToCpp::GetKeys(std::vector<std::wstring>& keys)
bool CefV8ValueCToCpp::GetKeys(std::vector<CefString>& keys)
{
if(CEF_MEMBER_MISSING(struct_, get_keys))
return false;
cef_string_list_t list = cef_string_list_alloc();
if(struct_->get_keys(struct_, list)) {
cef_string_t str;
int size = cef_string_list_size(list);
for(int i = 0; i < size; ++i) {
str = cef_string_list_value(list, i);
keys.push_back(str);
cef_string_free(str);
}
transfer_string_list_contents(list, keys);
cef_string_list_free(list);
return true;
}
@ -324,17 +317,14 @@ int CefV8ValueCToCpp::GetArrayLength()
return struct_->get_array_length(struct_);
}
std::wstring CefV8ValueCToCpp::GetFunctionName()
CefString CefV8ValueCToCpp::GetFunctionName()
{
std::wstring str;
CefString str;
if(CEF_MEMBER_MISSING(struct_, get_function_name))
return str;
cef_string_t cef_str = struct_->get_function_name(struct_);
if(cef_str) {
str = cef_str;
cef_string_free(cef_str);
}
cef_string_userfree_t strPtr = struct_->get_function_name(struct_);
str.AttachToUserFree(strPtr);
return str;
}
@ -351,7 +341,7 @@ CefRefPtr<CefV8Handler> CefV8ValueCToCpp::GetFunctionHandler()
bool CefV8ValueCToCpp::ExecuteFunction(CefRefPtr<CefV8Value> object,
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
std::wstring& exception)
CefString& exception)
{
if(CEF_MEMBER_MISSING(struct_, execute_function))
return RV_CONTINUE;
@ -365,16 +355,11 @@ bool CefV8ValueCToCpp::ExecuteFunction(CefRefPtr<CefV8Value> object,
}
cef_v8value_t* retvalStruct = NULL;
cef_string_t exceptionStr = NULL;
int rv = struct_->execute_function(struct_, CefV8ValueCToCpp::Unwrap(object),
argsSize, argsStructPtr, &retvalStruct, &exceptionStr);
argsSize, argsStructPtr, &retvalStruct, exception.GetWritableStruct());
if(retvalStruct)
retval = CefV8ValueCToCpp::Wrap(retvalStruct);
if(exceptionStr) {
exception = exceptionStr;
cef_string_free(exceptionStr);
}
if(argsStructPtr)
delete [] argsStructPtr;

View File

@ -43,23 +43,23 @@ public:
virtual bool GetBoolValue();
virtual int GetIntValue();
virtual double GetDoubleValue();
virtual std::wstring GetStringValue();
virtual bool HasValue(const std::wstring& key);
virtual CefString GetStringValue();
virtual bool HasValue(const CefString& key);
virtual bool HasValue(int index);
virtual bool DeleteValue(const std::wstring& key);
virtual bool DeleteValue(const CefString& key);
virtual bool DeleteValue(int index);
virtual CefRefPtr<CefV8Value> GetValue(const std::wstring& key);
virtual CefRefPtr<CefV8Value> GetValue(const CefString& key);
virtual CefRefPtr<CefV8Value> GetValue(int index);
virtual bool SetValue(const std::wstring& key, CefRefPtr<CefV8Value> value);
virtual bool SetValue(const CefString& key, CefRefPtr<CefV8Value> value);
virtual bool SetValue(int index, CefRefPtr<CefV8Value> value);
virtual bool GetKeys(std::vector<std::wstring>& keys);
virtual bool GetKeys(std::vector<CefString>& keys);
virtual CefRefPtr<CefBase> GetUserData();
virtual int GetArrayLength();
virtual std::wstring GetFunctionName();
virtual CefString GetFunctionName();
virtual CefRefPtr<CefV8Handler> GetFunctionHandler();
virtual bool ExecuteFunction(CefRefPtr<CefV8Value> object,
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
std::wstring& exception);
CefString& exception);
};
#endif // USING_CEF_SHARED

View File

@ -17,10 +17,10 @@
// STATIC METHODS - Body may be edited by hand.
CefRefPtr<CefXmlReader> CefXmlReader::Create(CefRefPtr<CefStreamReader> stream,
EncodingType encodingType, const std::wstring& URI)
EncodingType encodingType, const CefString& URI)
{
cef_xml_reader_t* impl = cef_xml_reader_create(
CefStreamReaderCToCpp::Unwrap(stream), encodingType, URI.c_str());
CefStreamReaderCToCpp::Unwrap(stream), encodingType, URI.GetStruct());
if(impl)
return CefXmlReaderCToCpp::Wrap(impl);
return NULL;
@ -53,18 +53,14 @@ bool CefXmlReaderCToCpp::HasError()
return struct_->has_error(struct_) ? true : false;
}
std::wstring CefXmlReaderCToCpp::GetError()
CefString CefXmlReaderCToCpp::GetError()
{
std::wstring str;
CefString str;
if(CEF_MEMBER_MISSING(struct_, get_error))
return str;
cef_string_t cef_str = struct_->get_error(struct_);
if(cef_str) {
str = cef_str;
cef_string_free(cef_str);
}
cef_string_userfree_t strPtr = struct_->get_error(struct_);
str.AttachToUserFree(strPtr);
return str;
}
@ -84,93 +80,69 @@ int CefXmlReaderCToCpp::GetDepth()
return struct_->get_depth(struct_);
}
std::wstring CefXmlReaderCToCpp::GetLocalName()
CefString CefXmlReaderCToCpp::GetLocalName()
{
std::wstring str;
CefString str;
if(CEF_MEMBER_MISSING(struct_, get_local_name))
return str;
cef_string_t cef_str = struct_->get_local_name(struct_);
if(cef_str) {
str = cef_str;
cef_string_free(cef_str);
}
cef_string_userfree_t strPtr = struct_->get_local_name(struct_);
str.AttachToUserFree(strPtr);
return str;
}
std::wstring CefXmlReaderCToCpp::GetPrefix()
CefString CefXmlReaderCToCpp::GetPrefix()
{
std::wstring str;
CefString str;
if(CEF_MEMBER_MISSING(struct_, get_prefix))
return str;
cef_string_t cef_str = struct_->get_prefix(struct_);
if(cef_str) {
str = cef_str;
cef_string_free(cef_str);
}
cef_string_userfree_t strPtr = struct_->get_prefix(struct_);
str.AttachToUserFree(strPtr);
return str;
}
std::wstring CefXmlReaderCToCpp::GetQualifiedName()
CefString CefXmlReaderCToCpp::GetQualifiedName()
{
std::wstring str;
CefString str;
if(CEF_MEMBER_MISSING(struct_, get_qualified_name))
return str;
cef_string_t cef_str = struct_->get_qualified_name(struct_);
if(cef_str) {
str = cef_str;
cef_string_free(cef_str);
}
cef_string_userfree_t strPtr = struct_->get_qualified_name(struct_);
str.AttachToUserFree(strPtr);
return str;
}
std::wstring CefXmlReaderCToCpp::GetNamespaceURI()
CefString CefXmlReaderCToCpp::GetNamespaceURI()
{
std::wstring str;
CefString str;
if(CEF_MEMBER_MISSING(struct_, get_namespace_uri))
return str;
cef_string_t cef_str = struct_->get_namespace_uri(struct_);
if(cef_str) {
str = cef_str;
cef_string_free(cef_str);
}
cef_string_userfree_t strPtr = struct_->get_namespace_uri(struct_);
str.AttachToUserFree(strPtr);
return str;
}
std::wstring CefXmlReaderCToCpp::GetBaseURI()
CefString CefXmlReaderCToCpp::GetBaseURI()
{
std::wstring str;
CefString str;
if(CEF_MEMBER_MISSING(struct_, get_base_uri))
return str;
cef_string_t cef_str = struct_->get_base_uri(struct_);
if(cef_str) {
str = cef_str;
cef_string_free(cef_str);
}
cef_string_userfree_t strPtr = struct_->get_base_uri(struct_);
str.AttachToUserFree(strPtr);
return str;
}
std::wstring CefXmlReaderCToCpp::GetXmlLang()
CefString CefXmlReaderCToCpp::GetXmlLang()
{
std::wstring str;
CefString str;
if(CEF_MEMBER_MISSING(struct_, get_xml_lang))
return str;
cef_string_t cef_str = struct_->get_xml_lang(struct_);
if(cef_str) {
str = cef_str;
cef_string_free(cef_str);
}
cef_string_userfree_t strPtr = struct_->get_xml_lang(struct_);
str.AttachToUserFree(strPtr);
return str;
}
@ -190,18 +162,14 @@ bool CefXmlReaderCToCpp::HasValue()
return struct_->has_value(struct_) ? true : false;
}
std::wstring CefXmlReaderCToCpp::GetValue()
CefString CefXmlReaderCToCpp::GetValue()
{
std::wstring str;
CefString str;
if(CEF_MEMBER_MISSING(struct_, get_value))
return str;
cef_string_t cef_str = struct_->get_value(struct_);
if(cef_str) {
str = cef_str;
cef_string_free(cef_str);
}
cef_string_userfree_t strPtr = struct_->get_value(struct_);
str.AttachToUserFree(strPtr);
return str;
}
@ -221,81 +189,61 @@ size_t CefXmlReaderCToCpp::GetAttributeCount()
return struct_->get_attribute_count(struct_);
}
std::wstring CefXmlReaderCToCpp::GetAttribute(int index)
CefString CefXmlReaderCToCpp::GetAttribute(int index)
{
std::wstring str;
CefString str;
if(CEF_MEMBER_MISSING(struct_, get_attribute_byindex))
return str;
cef_string_t cef_str = struct_->get_attribute_byindex(struct_, index);
if(cef_str) {
str = cef_str;
cef_string_free(cef_str);
}
cef_string_userfree_t strPtr = struct_->get_attribute_byindex(struct_, index);
str.AttachToUserFree(strPtr);
return str;
}
std::wstring CefXmlReaderCToCpp::GetAttribute(const std::wstring& qualifiedName)
CefString CefXmlReaderCToCpp::GetAttribute(const CefString& qualifiedName)
{
std::wstring str;
CefString str;
if(CEF_MEMBER_MISSING(struct_, get_attribute_byqname))
return str;
cef_string_t cef_str = struct_->get_attribute_byqname(struct_,
qualifiedName.c_str());
if(cef_str) {
str = cef_str;
cef_string_free(cef_str);
}
cef_string_userfree_t strPtr = struct_->get_attribute_byqname(struct_,
qualifiedName.GetStruct());
str.AttachToUserFree(strPtr);
return str;
}
std::wstring CefXmlReaderCToCpp::GetAttribute(const std::wstring& localName,
const std::wstring& namespaceURI)
CefString CefXmlReaderCToCpp::GetAttribute(const CefString& localName,
const CefString& namespaceURI)
{
std::wstring str;
CefString str;
if(CEF_MEMBER_MISSING(struct_, get_attribute_bylname))
return str;
cef_string_t cef_str = struct_->get_attribute_bylname(struct_,
localName.c_str(), namespaceURI.c_str());
if(cef_str) {
str = cef_str;
cef_string_free(cef_str);
}
cef_string_userfree_t strPtr = struct_->get_attribute_bylname(struct_,
localName.GetStruct(), namespaceURI.GetStruct());
str.AttachToUserFree(strPtr);
return str;
}
std::wstring CefXmlReaderCToCpp::GetInnerXml()
CefString CefXmlReaderCToCpp::GetInnerXml()
{
std::wstring str;
CefString str;
if(CEF_MEMBER_MISSING(struct_, get_inner_xml))
return str;
cef_string_t cef_str = struct_->get_inner_xml(struct_);
if(cef_str) {
str = cef_str;
cef_string_free(cef_str);
}
cef_string_userfree_t strPtr = struct_->get_inner_xml(struct_);
str.AttachToUserFree(strPtr);
return str;
}
std::wstring CefXmlReaderCToCpp::GetOuterXml()
CefString CefXmlReaderCToCpp::GetOuterXml()
{
std::wstring str;
CefString str;
if(CEF_MEMBER_MISSING(struct_, get_outer_xml))
return str;
cef_string_t cef_str = struct_->get_outer_xml(struct_);
if(cef_str) {
str = cef_str;
cef_string_free(cef_str);
}
cef_string_userfree_t strPtr = struct_->get_outer_xml(struct_);
str.AttachToUserFree(strPtr);
return str;
}
@ -315,23 +263,23 @@ bool CefXmlReaderCToCpp::MoveToAttribute(int index)
return struct_->move_to_attribute_byindex(struct_, index) ? true : false;
}
bool CefXmlReaderCToCpp::MoveToAttribute(const std::wstring& qualifiedName)
bool CefXmlReaderCToCpp::MoveToAttribute(const CefString& qualifiedName)
{
if(CEF_MEMBER_MISSING(struct_, move_to_attribute_byqname))
return false;
return struct_->move_to_attribute_byqname(struct_, qualifiedName.c_str()) ?
return struct_->move_to_attribute_byqname(struct_, qualifiedName.GetStruct())?
true : false;
}
bool CefXmlReaderCToCpp::MoveToAttribute(const std::wstring& localName,
const std::wstring& namespaceURI)
bool CefXmlReaderCToCpp::MoveToAttribute(const CefString& localName,
const CefString& namespaceURI)
{
if(CEF_MEMBER_MISSING(struct_, move_to_attribute_bylname))
return false;
return struct_->move_to_attribute_bylname(struct_, localName.c_str(),
namespaceURI.c_str()) ? true : false;
return struct_->move_to_attribute_bylname(struct_, localName.GetStruct(),
namespaceURI.GetStruct()) ? true : false;
}
bool CefXmlReaderCToCpp::MoveToFirstAttribute()

View File

@ -34,31 +34,31 @@ public:
virtual bool MoveToNextNode();
virtual bool Close();
virtual bool HasError();
virtual std::wstring GetError();
virtual CefString GetError();
virtual NodeType GetType();
virtual int GetDepth();
virtual std::wstring GetLocalName();
virtual std::wstring GetPrefix();
virtual std::wstring GetQualifiedName();
virtual std::wstring GetNamespaceURI();
virtual std::wstring GetBaseURI();
virtual std::wstring GetXmlLang();
virtual CefString GetLocalName();
virtual CefString GetPrefix();
virtual CefString GetQualifiedName();
virtual CefString GetNamespaceURI();
virtual CefString GetBaseURI();
virtual CefString GetXmlLang();
virtual bool IsEmptyElement();
virtual bool HasValue();
virtual std::wstring GetValue();
virtual CefString GetValue();
virtual bool HasAttributes();
virtual size_t GetAttributeCount();
virtual std::wstring GetAttribute(int index);
virtual std::wstring GetAttribute(const std::wstring& qualifiedName);
virtual std::wstring GetAttribute(const std::wstring& localName,
const std::wstring& namespaceURI);
virtual std::wstring GetInnerXml();
virtual std::wstring GetOuterXml();
virtual CefString GetAttribute(int index);
virtual CefString GetAttribute(const CefString& qualifiedName);
virtual CefString GetAttribute(const CefString& localName,
const CefString& namespaceURI);
virtual CefString GetInnerXml();
virtual CefString GetOuterXml();
virtual int GetLineNumber();
virtual bool MoveToAttribute(int index);
virtual bool MoveToAttribute(const std::wstring& qualifiedName);
virtual bool MoveToAttribute(const std::wstring& localName,
const std::wstring& namespaceURI);
virtual bool MoveToAttribute(const CefString& qualifiedName);
virtual bool MoveToAttribute(const CefString& localName,
const CefString& namespaceURI);
virtual bool MoveToFirstAttribute();
virtual bool MoveToNextAttribute();
virtual bool MoveToCarryingElement();

View File

@ -44,13 +44,13 @@ bool CefZipReaderCToCpp::MoveToNextFile()
return struct_->move_to_next_file(struct_) ? true : false;
}
bool CefZipReaderCToCpp::MoveToFile(const std::wstring& fileName,
bool CefZipReaderCToCpp::MoveToFile(const CefString& fileName,
bool caseSensitive)
{
if(CEF_MEMBER_MISSING(struct_, move_to_file))
return false;
return struct_->move_to_file(struct_, fileName.c_str(), caseSensitive) ?
return struct_->move_to_file(struct_, fileName.GetStruct(), caseSensitive) ?
true : false;
}
@ -62,18 +62,14 @@ bool CefZipReaderCToCpp::Close()
return struct_->close(struct_) ? true : false;
}
std::wstring CefZipReaderCToCpp::GetFileName()
CefString CefZipReaderCToCpp::GetFileName()
{
std::wstring str;
CefString str;
if(CEF_MEMBER_MISSING(struct_, get_file_name))
return str;
cef_string_t cef_str = struct_->get_file_name(struct_);
if(cef_str) {
str = cef_str;
cef_string_free(cef_str);
}
cef_string_userfree_t strPtr = struct_->get_file_name(struct_);
str.AttachToUserFree(strPtr);
return str;
}
@ -93,12 +89,12 @@ time_t CefZipReaderCToCpp::GetFileLastModified()
return struct_->get_file_last_modified(struct_);
}
bool CefZipReaderCToCpp::OpenFile(const std::wstring& password)
bool CefZipReaderCToCpp::OpenFile(const CefString& password)
{
if(CEF_MEMBER_MISSING(struct_, open_file))
return 0;
return struct_->open_file(struct_, password.c_str()) ? true : false;
return struct_->open_file(struct_, password.GetStruct()) ? true : false;
}
bool CefZipReaderCToCpp::CloseFile()

View File

@ -33,12 +33,12 @@ public:
// CefZipReader methods
virtual bool MoveToFirstFile();
virtual bool MoveToNextFile();
virtual bool MoveToFile(const std::wstring& fileName, bool caseSensitive);
virtual bool MoveToFile(const CefString& fileName, bool caseSensitive);
virtual bool Close();
virtual std::wstring GetFileName();
virtual CefString GetFileName();
virtual long GetFileSize();
virtual time_t GetFileLastModified();
virtual bool OpenFile(const std::wstring& password);
virtual bool OpenFile(const CefString& password);
virtual bool CloseFile();
virtual int ReadFile(void* buffer, size_t bufferSize);
virtual long Tell();

View File

@ -78,8 +78,8 @@ CEF_EXPORT void cef_do_message_loop_work()
CefDoMessageLoopWork();
}
CEF_EXPORT int cef_register_extension(const wchar_t* extension_name,
const wchar_t* javascript_code,
CEF_EXPORT int cef_register_extension(const cef_string_t* extension_name,
const cef_string_t* javascript_code,
struct _cef_v8handler_t* handler)
{
DCHECK(extension_name);
@ -90,36 +90,45 @@ CEF_EXPORT int cef_register_extension(const wchar_t* extension_name,
if(handler)
handlerPtr = CefV8HandlerCToCpp::Wrap(handler);
if(extension_name)
nameStr = extension_name;
if(javascript_code)
codeStr = javascript_code;
return CefRegisterExtension(nameStr, codeStr, handlerPtr);
return CefRegisterExtension(CefString(extension_name),
CefString(javascript_code), handlerPtr);
}
CEF_EXPORT int cef_register_plugin(const cef_plugin_info_t* plugin_info)
{
CefPluginInfo pluginInfo;
pluginInfo.unique_name = plugin_info->unique_name;
pluginInfo.display_name = plugin_info->display_name;
pluginInfo.version = plugin_info->version;
pluginInfo.description = plugin_info->description;
pluginInfo.unique_name.FromString(plugin_info->unique_name.str,
plugin_info->unique_name.length, true);
pluginInfo.display_name.FromString(plugin_info->display_name.str,
plugin_info->display_name.length, true);
pluginInfo.version.FromString(plugin_info->version.str,
plugin_info->version.length, true);
pluginInfo.description.FromString(plugin_info->description.str,
plugin_info->description.length, true);
std::vector<std::wstring> mime_types, file_extensions;
std::vector<std::wstring> descriptions;
base::SplitString(plugin_info->mime_types, '|', &mime_types);
base::SplitString(plugin_info->file_extensions, '|', &file_extensions);
base::SplitString(plugin_info->type_descriptions, '|', &descriptions);
typedef std::vector<std::string> VectorType;
VectorType mime_types, file_extensions, descriptions, file_extensions_parts;
base::SplitString(CefString(&plugin_info->mime_types), '|',
&mime_types);
base::SplitString(CefString(&plugin_info->file_extensions), '|',
&file_extensions);
base::SplitString(CefString(&plugin_info->type_descriptions), '|',
&descriptions);
for (size_t i = 0; i < mime_types.size(); ++i) {
CefPluginMimeType mimeType;
mimeType.mime_type = mime_types[i];
if (file_extensions.size() > i)
base::SplitString(file_extensions[i], ',', &mimeType.file_extensions);
if (file_extensions.size() > i) {
base::SplitString(file_extensions[i], ',', &file_extensions_parts);
VectorType::const_iterator it = file_extensions_parts.begin();
for(; it != file_extensions_parts.end(); ++it)
mimeType.file_extensions.push_back(*(it));
file_extensions_parts.clear();
}
if (descriptions.size() > i)
mimeType.description = descriptions[i];
@ -134,22 +143,16 @@ CEF_EXPORT int cef_register_plugin(const cef_plugin_info_t* plugin_info)
return CefRegisterPlugin(pluginInfo);
}
CEF_EXPORT int cef_register_scheme(const wchar_t* scheme_name,
const wchar_t* host_name, struct _cef_scheme_handler_factory_t* factory)
CEF_EXPORT int cef_register_scheme(const cef_string_t* scheme_name,
const cef_string_t* host_name,
struct _cef_scheme_handler_factory_t* factory)
{
DCHECK(scheme_name);
DCHECK(factory);
if(!scheme_name || !factory)
return 0;
std::wstring nameStr, codeStr;
if(scheme_name)
nameStr = scheme_name;
if(host_name)
codeStr = host_name;
return CefRegisterScheme(nameStr, codeStr,
return CefRegisterScheme(CefString(scheme_name), CefString(host_name),
CefSchemeHandlerFactoryCToCpp::Wrap(factory));
}

View File

@ -4,65 +4,44 @@
#include "transfer_util.h"
void transfer_string_list_contents(cef_string_list_t fromList,
StringList& toList)
{
int size = cef_string_list_size(fromList);
CefString value;
for(int i = 0; i < size; i++) {
cef_string_list_value(fromList, i, value.GetWritableStruct());
toList.push_back(value);
}
}
void transfer_string_list_contents(const StringList& fromList,
cef_string_list_t toList)
{
size_t size = fromList.size();
for(size_t i = 0; i < size; ++i)
cef_string_list_append(toList, fromList[i].GetStruct());
}
void transfer_string_map_contents(cef_string_map_t fromMap,
std::map<std::wstring, std::wstring>& toMap)
StringMap& toMap)
{
int size = cef_string_map_size(fromMap);
cef_string_t key, value;
std::wstring keystr, valuestr;
CefString key, value;
for(int i = 0; i < size; ++i) {
key = cef_string_map_key(fromMap, i);
value = cef_string_map_value(fromMap, i);
cef_string_map_key(fromMap, i, key.GetWritableStruct());
cef_string_map_value(fromMap, i, value.GetWritableStruct());
if(key) {
keystr = key;
cef_string_free(key);
} else if(!keystr.empty())
keystr.clear();
if(value) {
valuestr = value;
cef_string_free(value);
} else if(!valuestr.empty())
valuestr.clear();
toMap.insert(std::pair<std::wstring, std::wstring>(keystr, valuestr));
toMap.insert(std::pair<CefString, CefString>(key, value));
}
}
void transfer_string_map_contents(const std::map<std::wstring, std::wstring>& fromMap,
void transfer_string_map_contents(const StringMap& fromMap,
cef_string_map_t toMap)
{
std::map<std::wstring, std::wstring>::const_iterator it = fromMap.begin();
for(; it != fromMap.end(); ++it) {
cef_string_map_append(toMap, it->first.c_str(), it->second.c_str());
}
}
void transfer_string_contents(const std::wstring& fromString,
cef_string_t* toString)
{
if(*toString == NULL || *toString != fromString) {
if(*toString) {
cef_string_free(*toString);
*toString = NULL;
}
if(!fromString.empty())
*toString = cef_string_alloc(fromString.c_str());
}
}
void transfer_string_contents(cef_string_t fromString, std::wstring& toString,
bool freeFromString)
{
if(fromString == NULL || fromString != toString) {
if(fromString) {
toString = fromString;
if(freeFromString)
cef_string_free(fromString);
} else if(!toString.empty())
toString.clear();
}
StringMap::const_iterator it = fromMap.begin();
for(; it != fromMap.end(); ++it)
cef_string_map_append(toMap, it->first.GetStruct(), it->second.GetStruct());
}

View File

@ -5,21 +5,23 @@
#ifndef _TRANSFER_UTIL_H
#define _TRANSFER_UTIL_H
#include "include/cef_string.h"
#include "include/cef_string_list.h"
#include "include/cef_string_map.h"
#include <map>
#include <string>
#include <vector>
// Copy contents from one list type to another.
typedef std::vector<CefString> StringList;
void transfer_string_list_contents(cef_string_list_t fromList,
StringList& toList);
void transfer_string_list_contents(const StringList& fromList,
cef_string_list_t toList);
// Copy contents from one map type to another.
typedef std::map<CefString, CefString> StringMap;
void transfer_string_map_contents(cef_string_map_t fromMap,
std::map<std::wstring, std::wstring>& toMap);
void transfer_string_map_contents(const std::map<std::wstring, std::wstring>& fromMap,
StringMap& toMap);
void transfer_string_map_contents(const StringMap& fromMap,
cef_string_map_t toMap);
// Copy the contents from one string type to another.
void transfer_string_contents(const std::wstring& fromString,
cef_string_t* toString);
void transfer_string_contents(cef_string_t fromString, std::wstring& toString,
bool freeFromString);
#endif // _TRANSFER_UTIL_H

View File

@ -18,7 +18,7 @@ public:
bool Load(CefRefPtr<CefStreamReader> stream,
CefXmlReader::EncodingType encodingType,
const std::wstring& URI)
const CefString& URI)
{
CefRefPtr<CefXmlReader> reader(
CefXmlReader::Create(stream, encodingType, URI));
@ -31,7 +31,7 @@ public:
CefXmlObject::ObjectVector queue;
int cur_depth, value_depth = -1;
CefXmlReader::NodeType cur_type;
std::wstringstream cur_value;
std::stringstream cur_value;
bool last_has_ns = false;
queue.push_back(root_object_);
@ -47,17 +47,17 @@ public:
if (cur_type == XML_NODE_ELEMENT_START) {
if (cur_depth == value_depth) {
// Add to the current value.
cur_value << reader->GetOuterXml();
cur_value << std::string(reader->GetOuterXml());
continue;
} else if(last_has_ns && reader->GetPrefix().empty()) {
if (!cur_object->HasChildren()) {
// Start a new value because the last element has a namespace and
// this element does not.
value_depth = cur_depth;
cur_value << reader->GetOuterXml();
cur_value << std::string(reader->GetOuterXml());
} else {
// Value following a child element is not allowed.
std::wstringstream ss;
std::stringstream ss;
ss << L"Value following child element, line " <<
reader->GetLineNumber();
load_error_ = ss.str();
@ -93,7 +93,7 @@ public:
} else if (cur_depth < value_depth) {
// Done with parsing the value portion of the current element.
cur_object->SetValue(cur_value.str());
cur_value.str(L"");
cur_value.str("");
value_depth = -1;
}
@ -105,9 +105,10 @@ public:
// Open tag without close tag or close tag without open tag should
// never occur (the parser catches this error).
DCHECK(false);
std::wstringstream ss;
ss << L"Mismatched end tag for " << cur_object->GetName() <<
L", line " << reader->GetLineNumber();
std::stringstream ss;
ss << "Mismatched end tag for " <<
std::string(cur_object->GetName()) <<
", line " << reader->GetLineNumber();
load_error_ = ss.str();
ret = false;
break;
@ -119,15 +120,15 @@ public:
cur_type == XML_NODE_ENTITY_REFERENCE) {
if (cur_depth == value_depth) {
// Add to the current value.
cur_value << reader->GetValue();
cur_value << std::string(reader->GetValue());
} else if (!cur_object->HasChildren()) {
// Start a new value.
value_depth = cur_depth;
cur_value << reader->GetValue();
cur_value << std::string(reader->GetValue());
} else {
// Value following a child element is not allowed.
std::wstringstream ss;
ss << L"Value following child element, line " <<
std::stringstream ss;
ss << "Value following child element, line " <<
reader->GetLineNumber();
load_error_ = ss.str();
ret = false;
@ -145,16 +146,16 @@ public:
return ret;
}
std::wstring GetLoadError() { return load_error_; }
CefString GetLoadError() { return load_error_; }
private:
std::wstring load_error_;
CefString load_error_;
CefRefPtr<CefXmlObject> root_object_;
};
} // namespace
CefXmlObject::CefXmlObject(const std::wstring& name)
CefXmlObject::CefXmlObject(const CefString& name)
: name_(name), parent_(NULL)
{
}
@ -165,7 +166,7 @@ CefXmlObject::~CefXmlObject()
bool CefXmlObject::Load(CefRefPtr<CefStreamReader> stream,
CefXmlReader::EncodingType encodingType,
const std::wstring& URI, std::wstring* loadError)
const CefString& URI, CefString* loadError)
{
AutoLock lock_scope(this);
Clear();
@ -236,9 +237,9 @@ void CefXmlObject::Clear()
ClearAttributes();
}
std::wstring CefXmlObject::GetName()
CefString CefXmlObject::GetName()
{
std::wstring name;
CefString name;
{
AutoLock lock_scope(this);
name = name_;
@ -246,7 +247,7 @@ std::wstring CefXmlObject::GetName()
return name;
}
bool CefXmlObject::SetName(const std::wstring& name)
bool CefXmlObject::SetName(const CefString& name)
{
DCHECK(!name.empty());
if (name.empty())
@ -279,9 +280,9 @@ bool CefXmlObject::HasValue()
return !value_.empty();
}
std::wstring CefXmlObject::GetValue()
CefString CefXmlObject::GetValue()
{
std::wstring value;
CefString value;
{
AutoLock lock_scope(this);
value = value_;
@ -289,7 +290,7 @@ std::wstring CefXmlObject::GetValue()
return value;
}
bool CefXmlObject::SetValue(const std::wstring& value)
bool CefXmlObject::SetValue(const CefString& value)
{
AutoLock lock_scope(this);
DCHECK(children_.empty());
@ -311,7 +312,7 @@ size_t CefXmlObject::GetAttributeCount()
return attributes_.size();
}
bool CefXmlObject::HasAttribute(const std::wstring& name)
bool CefXmlObject::HasAttribute(const CefString& name)
{
if (name.empty())
return false;
@ -321,10 +322,10 @@ bool CefXmlObject::HasAttribute(const std::wstring& name)
return (it != attributes_.end());
}
std::wstring CefXmlObject::GetAttributeValue(const std::wstring& name)
CefString CefXmlObject::GetAttributeValue(const CefString& name)
{
DCHECK(!name.empty());
std::wstring value;
CefString value;
if (!name.empty()) {
AutoLock lock_scope(this);
AttributeMap::const_iterator it = attributes_.find(name);
@ -334,8 +335,8 @@ std::wstring CefXmlObject::GetAttributeValue(const std::wstring& name)
return value;
}
bool CefXmlObject::SetAttributeValue(const std::wstring& name,
const std::wstring& value)
bool CefXmlObject::SetAttributeValue(const CefString& name,
const CefString& value)
{
DCHECK(!name.empty());
if (name.empty())
@ -346,8 +347,7 @@ bool CefXmlObject::SetAttributeValue(const std::wstring& name,
if (it != attributes_.end()) {
it->second = value;
} else {
attributes_.insert(
std::make_pair<std::wstring,std::wstring>(name, value));
attributes_.insert(std::make_pair(name, value));
}
return true;
}
@ -441,7 +441,7 @@ void CefXmlObject::ClearChildren()
children_.clear();
}
CefRefPtr<CefXmlObject> CefXmlObject::FindChild(const std::wstring& name)
CefRefPtr<CefXmlObject> CefXmlObject::FindChild(const CefString& name)
{
DCHECK(!name.empty());
if (name.empty())
@ -456,7 +456,7 @@ CefRefPtr<CefXmlObject> CefXmlObject::FindChild(const std::wstring& name)
return NULL;
}
size_t CefXmlObject::FindChildren(const std::wstring& name,
size_t CefXmlObject::FindChildren(const CefString& name,
ObjectVector& children)
{
DCHECK(!name.empty());

View File

@ -70,7 +70,7 @@ size_t CefZipArchive::Load(CefRefPtr<CefStreamReader> stream,
continue;
}
if (!reader->OpenFile(L""))
if (!reader->OpenFile(CefString()))
break;
name = reader->GetFileName();
@ -99,8 +99,7 @@ size_t CefZipArchive::Load(CefRefPtr<CefStreamReader> stream,
count++;
// Add the file to the map.
contents_.insert(
std::make_pair<std::wstring, CefRefPtr<File> >(name, contents.get()));
contents_.insert(std::make_pair(name, contents.get()));
} while (reader->MoveToNextFile());
return count;
@ -118,36 +117,36 @@ size_t CefZipArchive::GetFileCount()
return contents_.size();
}
bool CefZipArchive::HasFile(const std::wstring& fileName)
bool CefZipArchive::HasFile(const CefString& fileName)
{
std::wstring str = fileName;
std::transform(str.begin(), str.end(), str.begin(), towlower);
AutoLock lock_scope(this);
FileMap::const_iterator it = contents_.find(str);
FileMap::const_iterator it = contents_.find(CefString(str));
return (it != contents_.end());
}
CefRefPtr<CefZipArchive::File> CefZipArchive::GetFile(
const std::wstring& fileName)
const CefString& fileName)
{
std::wstring str = fileName;
std::transform(str.begin(), str.end(), str.begin(), towlower);
AutoLock lock_scope(this);
FileMap::const_iterator it = contents_.find(str);
FileMap::const_iterator it = contents_.find(CefString(str));
if (it != contents_.end())
return it->second;
return NULL;
}
bool CefZipArchive::RemoveFile(const std::wstring& fileName)
bool CefZipArchive::RemoveFile(const CefString& fileName)
{
std::wstring str = fileName;
std::transform(str.begin(), str.end(), str.begin(), towlower);
AutoLock lock_scope(this);
FileMap::iterator it = contents_.find(str);
FileMap::iterator it = contents_.find(CefString(str));
if (it != contents_.end()) {
contents_.erase(it);
return true;

View File

@ -61,30 +61,40 @@ void CefDoMessageLoopWork()
cef_do_message_loop_work();
}
bool CefRegisterExtension(const std::wstring& extension_name,
const std::wstring& javascript_code,
bool CefRegisterExtension(const CefString& extension_name,
const CefString& javascript_code,
CefRefPtr<CefV8Handler> handler)
{
return cef_register_extension(extension_name.c_str(), javascript_code.c_str(),
CefV8HandlerCppToC::Wrap(handler))?true:false;
return cef_register_extension(extension_name.GetStruct(),
javascript_code.GetStruct(), CefV8HandlerCppToC::Wrap(handler))?
true:false;
}
bool CefRegisterPlugin(const struct CefPluginInfo& plugin_info)
{
cef_plugin_info_t pluginInfo;
memset(&pluginInfo, 0, sizeof(pluginInfo));
pluginInfo.unique_name = plugin_info.unique_name.c_str();
pluginInfo.display_name = plugin_info.display_name.c_str();
pluginInfo.version =plugin_info.version.c_str();
pluginInfo.description = plugin_info.description.c_str();
cef_string_set(plugin_info.unique_name.c_str(),
plugin_info.unique_name.length(),
&pluginInfo.unique_name, false);
cef_string_set(plugin_info.display_name.c_str(),
plugin_info.display_name.length(),
&pluginInfo.display_name, false);
cef_string_set(plugin_info.version.c_str(),
plugin_info.version.length(),
&pluginInfo.version, false);
cef_string_set(plugin_info.description.c_str(),
plugin_info.description.length(),
&pluginInfo.description, false);
std::wstring mimeTypes, fileExtensions, typeDescriptions;
std::string mimeTypes, fileExtensions, typeDescriptions;
for(size_t i = 0; i < plugin_info.mime_types.size(); ++i) {
if(i > 0) {
mimeTypes += L"|";
fileExtensions += L"|";
typeDescriptions += L"|";
mimeTypes += "|";
fileExtensions += "|";
typeDescriptions += "|";
}
mimeTypes += plugin_info.mime_types[i].mime_type;
@ -93,28 +103,37 @@ bool CefRegisterPlugin(const struct CefPluginInfo& plugin_info)
for(size_t j = 0;
j < plugin_info.mime_types[i].file_extensions.size(); ++j) {
if(j > 0) {
fileExtensions += L",";
fileExtensions += ",";
}
fileExtensions += plugin_info.mime_types[i].file_extensions[j];
}
}
pluginInfo.mime_types = mimeTypes.c_str();
pluginInfo.file_extensions = fileExtensions.c_str();
pluginInfo.type_descriptions = typeDescriptions.c_str();
cef_string_from_utf8(mimeTypes.c_str(), mimeTypes.length(),
&pluginInfo.mime_types);
cef_string_from_utf8(fileExtensions.c_str(), fileExtensions.length(),
&pluginInfo.file_extensions);
cef_string_from_utf8(typeDescriptions.c_str(), typeDescriptions.length(),
&pluginInfo.type_descriptions);
pluginInfo.np_getentrypoints = plugin_info.np_getentrypoints;
pluginInfo.np_initialize = plugin_info.np_initialize;
pluginInfo.np_shutdown = plugin_info.np_shutdown;
return (cef_register_plugin(&pluginInfo) ? true : false);
bool ret = cef_register_plugin(&pluginInfo) ? true : false;
cef_string_clear(&pluginInfo.mime_types);
cef_string_clear(&pluginInfo.file_extensions);
cef_string_clear(&pluginInfo.type_descriptions);
return ret;
}
bool CefRegisterScheme(const std::wstring& scheme_name,
const std::wstring& host_name,
bool CefRegisterScheme(const CefString& scheme_name,
const CefString& host_name,
CefRefPtr<CefSchemeHandlerFactory> factory)
{
return cef_register_scheme(scheme_name.c_str(), host_name.c_str(),
return cef_register_scheme(scheme_name.GetStruct(), host_name.GetStruct(),
CefSchemeHandlerFactoryCppToC::Wrap(factory))?true:false;
}

View File

@ -16,30 +16,30 @@ public:
// Execute with the specified argument list and return value. Return true if
// the method was handled.
virtual bool Execute(const std::wstring& name,
virtual bool Execute(const CefString& name,
CefRefPtr<CefV8Value> object,
const CefV8ValueList& arguments,
CefRefPtr<CefV8Value>& retval,
std::wstring& exception)
CefString& exception)
{
if(name == L"Dump")
if(name == "Dump")
{
// The "Dump" function will return a human-readable dump of the input
// arguments.
std::wstringstream stream;
std::stringstream stream;
size_t i;
for(i = 0; i < arguments.size(); ++i)
{
stream << L"arg[" << i << L"] = ";
stream << "arg[" << i << "] = ";
PrintValue(arguments[i], stream, 0);
stream << L"\n";
stream << "\n";
}
retval = CefV8Value::CreateString(stream.str());
return true;
}
else if(name == L"Call")
else if(name == "Call")
{
// The "Call" function will execute a function to get an object and then
// return the result of calling a function belonging to that object. The
@ -80,46 +80,46 @@ public:
}
// Simple function for formatted output of a V8 value.
void PrintValue(CefRefPtr<CefV8Value> value, std::wstringstream &stream,
void PrintValue(CefRefPtr<CefV8Value> value, std::stringstream &stream,
int indent)
{
std::wstringstream indent_stream;
std::stringstream indent_stream;
for(int i = 0; i < indent; ++i)
indent_stream << L" ";
std::wstring indent_str = indent_stream.str();
indent_stream << " ";
std::string indent_str = indent_stream.str();
if(value->IsUndefined())
stream << L"(undefined)";
stream << "(undefined)";
else if(value->IsNull())
stream << L"(null)";
stream << "(null)";
else if(value->IsBool())
stream << L"(bool) " << (value->GetBoolValue() ? L"true" : L"false");
stream << "(bool) " << (value->GetBoolValue() ? "true" : "false");
else if(value->IsInt())
stream << L"(int) " << value->GetIntValue();
stream << "(int) " << value->GetIntValue();
else if(value->IsDouble())
stream << L"(double) " << value->GetDoubleValue();
stream << "(double) " << value->GetDoubleValue();
else if(value->IsString())
stream << L"(string) " << value->GetStringValue().c_str();
stream << "(string) " << std::string(value->GetStringValue());
else if(value->IsFunction())
stream << L"(function) " << value->GetFunctionName().c_str();
stream << "(function) " << std::string(value->GetFunctionName());
else if(value->IsArray()) {
stream << L"(array) [";
stream << "(array) [";
int len = value->GetArrayLength();
for(int i = 0; i < len; ++i) {
stream << L"\n " << indent_str.c_str() << i << L" = ";
stream << "\n " << indent_str.c_str() << i << " = ";
PrintValue(value->GetValue(i), stream, indent+1);
}
stream << L"\n" << indent_str.c_str() << L"]";
stream << "\n" << indent_str.c_str() << "]";
} else if(value->IsObject()) {
stream << L"(object) [";
std::vector<std::wstring> keys;
stream << "(object) [";
std::vector<CefString> keys;
if(value->GetKeys(keys)) {
for(size_t i = 0; i < keys.size(); ++i) {
stream << L"\n " << indent_str.c_str() << keys[i].c_str() << L" = ";
stream << "\n " << indent_str.c_str() << keys[i].c_str() << " = ";
PrintValue(value->GetValue(keys[i]), stream, indent+1);
}
}
stream << L"\n" << indent_str.c_str() << L"]";
stream << "\n" << indent_str.c_str() << "]";
}
}
};
@ -133,41 +133,41 @@ void InitBindingTest(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefV8Value> testObjPtr = CefV8Value::CreateObject(NULL);
// Add the new V8 object to the global window object with the name
// "cef_test".
object->SetValue(L"cef_test", testObjPtr);
object->SetValue("cef_test", testObjPtr);
// Create an instance of ClientV8FunctionHandler as the V8 handler.
CefRefPtr<CefV8Handler> handlerPtr = new ClientV8FunctionHandler();
// Add a new V8 function to the cef_test object with the name "Dump".
testObjPtr->SetValue(L"Dump",
CefV8Value::CreateFunction(L"Dump", handlerPtr));
testObjPtr->SetValue("Dump",
CefV8Value::CreateFunction("Dump", handlerPtr));
// Add a new V8 function to the cef_test object with the name "Call".
testObjPtr->SetValue(L"Call",
CefV8Value::CreateFunction(L"Call", handlerPtr));
testObjPtr->SetValue("Call",
CefV8Value::CreateFunction("Call", handlerPtr));
}
void RunBindingTest(CefRefPtr<CefBrowser> browser)
{
std::wstring html =
L"<html><body>ClientV8FunctionHandler says:<br><pre>"
L"<script language=\"JavaScript\">"
L"document.writeln(window.cef_test.Dump(false, 1, 7.6654,'bar',"
L" [false,true],[5, 7.654, 1, 'foo', [true, 'bar'], 8]));"
L"document.writeln(window.cef_test.Dump(cef));"
L"document.writeln("
L" window.cef_test.Call(cef.test.test_object, 'GetMessage'));"
L"function my_object() {"
L" var obj = {};"
L" (function() {"
L" obj.GetMessage = function(a) {"
L" return 'Calling a function with value '+a+' on a user object succeeded.';"
L" };"
L" })();"
L" return obj;"
L"};"
L"document.writeln("
L" window.cef_test.Call(my_object, 'GetMessage', 'foobar'));"
L"</script>"
L"</pre></body></html>";
browser->GetMainFrame()->LoadString(html, L"about:blank");
std::string html =
"<html><body>ClientV8FunctionHandler says:<br><pre>"
"<script language=\"JavaScript\">"
"document.writeln(window.cef_test.Dump(false, 1, 7.6654,'bar',"
" [false,true],[5, 7.654, 1, 'foo', [true, 'bar'], 8]));"
"document.writeln(window.cef_test.Dump(cef));"
"document.writeln("
" window.cef_test.Call(cef.test.test_object, 'GetMessage'));"
"function my_object() {"
" var obj = {};"
" (function() {"
" obj.GetMessage = function(a) {"
" return 'Calling a function with value '+a+' on a user object succeeded.';"
" };"
" })();"
" return obj;"
"};"
"document.writeln("
" window.cef_test.Call(my_object, 'GetMessage', 'foobar'));"
"</script>"
"</pre></body></html>";
browser->GetMainFrame()->LoadString(html, "about:blank");
}

View File

@ -16,14 +16,14 @@
// ClientHandler::ClientDownloadListener implementation
void ClientHandler::ClientDownloadListener::NotifyDownloadComplete(
const std::wstring& fileName)
const CefString& fileName)
{
handler_->SetLastDownloadFile(fileName);
handler_->SendNotification(NOTIFY_DOWNLOAD_COMPLETE);
}
void ClientHandler::ClientDownloadListener::NotifyDownloadError(
const std::wstring& fileName)
const CefString& fileName)
{
handler_->SetLastDownloadFile(fileName);
handler_->SendNotification(NOTIFY_DOWNLOAD_ERROR);
@ -90,36 +90,36 @@ CefHandler::RetVal ClientHandler::HandleLoadEnd(CefRefPtr<CefBrowser> browser,
CefHandler::RetVal ClientHandler::HandleLoadError(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, ErrorCode errorCode,
const std::wstring& failedUrl, std::wstring& errorText)
const CefString& failedUrl, CefString& errorText)
{
if(errorCode == ERR_CACHE_MISS)
{
// Usually caused by navigating to a page with POST data via back or
// forward buttons.
errorText = L"<html><head><title>Expired Form Data</title></head>"
L"<body><h1>Expired Form Data</h1>"
L"<h2>Your form request has expired. "
L"Click reload to re-submit the form data.</h2></body>"
L"</html>";
errorText = "<html><head><title>Expired Form Data</title></head>"
"<body><h1>Expired Form Data</h1>"
"<h2>Your form request has expired. "
"Click reload to re-submit the form data.</h2></body>"
"</html>";
}
else
{
// All other messages.
std::wstringstream ss;
ss << L"<html><head><title>Load Failed</title></head>"
L"<body><h1>Load Failed</h1>"
L"<h2>Load of URL " << failedUrl <<
L" failed with error code " << static_cast<int>(errorCode) <<
L".</h2></body>"
L"</html>";
std::stringstream ss;
ss << "<html><head><title>Load Failed</title></head>"
"<body><h1>Load Failed</h1>"
"<h2>Load of URL " << std::string(failedUrl) <<
" failed with error code " << static_cast<int>(errorCode) <<
".</h2></body>"
"</html>";
errorText = ss.str();
}
return RV_HANDLED;
}
CefHandler::RetVal ClientHandler::HandleDownloadResponse(
CefRefPtr<CefBrowser> browser, const std::wstring& mimeType,
const std::wstring& fileName, int64 contentLength,
CefRefPtr<CefBrowser> browser, const CefString& mimeType,
const CefString& fileName, int64 contentLength,
CefRefPtr<CefDownloadHandler>& handler)
{
// Create the handler for the file download.
@ -129,10 +129,10 @@ CefHandler::RetVal ClientHandler::HandleDownloadResponse(
CefHandler::RetVal ClientHandler::HandlePrintHeaderFooter(
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
CefPrintInfo& printInfo, const std::wstring& url, const std::wstring& title,
int currentPage, int maxPages, std::wstring& topLeft,
std::wstring& topCenter, std::wstring& topRight, std::wstring& bottomLeft,
std::wstring& bottomCenter, std::wstring& bottomRight)
CefPrintInfo& printInfo, const CefString& url, const CefString& title,
int currentPage, int maxPages, CefString& topLeft,
CefString& topCenter, CefString& topRight, CefString& bottomLeft,
CefString& bottomCenter, CefString& bottomRight)
{
// Place the page title at top left
topLeft = title;
@ -140,8 +140,8 @@ CefHandler::RetVal ClientHandler::HandlePrintHeaderFooter(
topRight = url;
// Place "Page X of Y" at bottom center
std::wstringstream strstream;
strstream << L"Page " << currentPage << L" of " << maxPages;
std::stringstream strstream;
strstream << "Page " << currentPage << " of " << maxPages;
bottomCenter = strstream.str();
return RV_CONTINUE;
@ -168,37 +168,32 @@ CefHandler::RetVal ClientHandler::HandleBeforeWindowClose(
}
CefHandler::RetVal ClientHandler::HandleConsoleMessage(
CefRefPtr<CefBrowser> browser, const std::wstring& message,
const std::wstring& source, int line)
CefRefPtr<CefBrowser> browser, const CefString& message,
const CefString& source, int line)
{
Lock();
bool first_message = m_LogFile.empty();
if(first_message) {
std::wstringstream ss;
std::stringstream ss;
ss << AppGetWorkingDirectory();
#ifdef _WIN32
ss << L"\\";
ss << "\\";
#else
ss << L"/";
ss << "/";
#endif
ss << L"console.log";
ss << "console.log";
m_LogFile = ss.str();
}
std::wstring logFile = m_LogFile;
std::string logFile = m_LogFile;
Unlock();
FILE* file = NULL;
#ifdef _WIN32
_wfopen_s(&file, logFile.c_str(), L"a, ccs=UTF-8");
#else
file = fopen(WStringToString(logFile).c_str(), "a");
#endif
FILE* file = fopen(logFile.c_str(), "a");
if(file) {
std::wstringstream ss;
ss << L"Message: " << message << L"\r\nSource: " << source <<
L"\r\nLine: " << line << L"\r\n-----------------------\r\n";
fputws(ss.str().c_str(), file);
std::stringstream ss;
ss << "Message: " << std::string(message) << "\r\nSource: " <<
std::string(source) << "\r\nLine: " << line <<
"\r\n-----------------------\r\n";
fputs(ss.str().c_str(), file);
fclose(file);
if(first_message)
@ -232,24 +227,24 @@ void ClientHandler::SetEditHwnd(CefWindowHandle hwnd)
Unlock();
}
std::wstring ClientHandler::GetLogFile()
std::string ClientHandler::GetLogFile()
{
Lock();
std::wstring str = m_LogFile;
std::string str = m_LogFile;
Unlock();
return str;
}
void ClientHandler::SetLastDownloadFile(const std::wstring& fileName)
void ClientHandler::SetLastDownloadFile(const std::string& fileName)
{
Lock();
m_LastDownloadFile = fileName;
Unlock();
}
std::wstring ClientHandler::GetLastDownloadFile()
std::string ClientHandler::GetLastDownloadFile()
{
std::wstring str;
std::string str;
Lock();
str = m_LastDownloadFile;
Unlock();
@ -278,25 +273,25 @@ CefWindowHandle AppGetMainHwnd()
void RunGetSourceTest(CefRefPtr<CefFrame> frame)
{
// Retrieve the current page source and display.
std::wstring source = frame->GetSource();
source = StringReplace(source, L"<", L"&lt;");
source = StringReplace(source, L">", L"&gt;");
std::wstringstream ss;
ss << L"<html><body>Source:" << L"<pre>" << source
<< L"</pre></body></html>";
frame->LoadString(ss.str(), L"http://tests/getsource");
std::string source = frame->GetSource();
source = StringReplace(source, "<", "&lt;");
source = StringReplace(source, ">", "&gt;");
std::stringstream ss;
ss << "<html><body>Source:" << "<pre>" << source
<< "</pre></body></html>";
frame->LoadString(ss.str(), "http://tests/getsource");
}
void RunGetTextTest(CefRefPtr<CefFrame> frame)
{
// Retrieve the current page text and display.
std::wstring text = frame->GetText();
text = StringReplace(text, L"<", L"&lt;");
text = StringReplace(text, L">", L"&gt;");
std::wstringstream ss;
ss << L"<html><body>Text:" << L"<pre>" << text
<< L"</pre></body></html>";
frame->LoadString(ss.str(), L"http://tests/gettext");
std::string text = frame->GetText();
text = StringReplace(text, "<", "&lt;");
text = StringReplace(text, ">", "&gt;");
std::stringstream ss;
ss << "<html><body>Text:" << "<pre>" << text
<< "</pre></body></html>";
frame->LoadString(ss.str(), "http://tests/gettext");
}
void RunRequestTest(CefRefPtr<CefBrowser> browser)
@ -305,7 +300,7 @@ void RunRequestTest(CefRefPtr<CefBrowser> browser)
CefRefPtr<CefRequest> request(CefRequest::CreateRequest());
// Set the request URL
request->SetURL(L"http://tests/request");
request->SetURL("http://tests/request");
// Add post data to the request. The correct method and content-
// type headers will be set by CEF.
@ -320,7 +315,7 @@ void RunRequestTest(CefRefPtr<CefBrowser> browser)
// Add a custom header
CefRequest::HeaderMap headerMap;
headerMap.insert(
std::make_pair(L"X-My-Header", L"My Header Value"));
std::make_pair("X-My-Header", "My Header Value"));
request->SetHeaderMap(headerMap);
// Load the request
@ -330,16 +325,16 @@ void RunRequestTest(CefRefPtr<CefBrowser> browser)
void RunJavaScriptExecuteTest(CefRefPtr<CefBrowser> browser)
{
browser->GetMainFrame()->ExecuteJavaScript(
L"alert('JavaScript execute works!');", L"about:blank", 0);
"alert('JavaScript execute works!');", "about:blank", 0);
}
void RunPopupTest(CefRefPtr<CefBrowser> browser)
{
browser->GetMainFrame()->ExecuteJavaScript(
L"window.open('http://www.google.com');", L"about:blank", 0);
"window.open('http://www.google.com');", "about:blank", 0);
}
void RunLocalStorageTest(CefRefPtr<CefBrowser> browser)
{
browser->GetMainFrame()->LoadURL(L"http://tests/localstorage");
browser->GetMainFrame()->LoadURL("http://tests/localstorage");
}

View File

@ -20,10 +20,10 @@ public:
ClientDownloadListener(ClientHandler* handler) : handler_(handler) {}
// Called when the download is complete.
virtual void NotifyDownloadComplete(const std::wstring& fileName);
virtual void NotifyDownloadComplete(const CefString& fileName);
// Called if the download fails.
virtual void NotifyDownloadError(const std::wstring& fileName);
virtual void NotifyDownloadError(const CefString& fileName);
private:
ClientHandler* handler_;
@ -44,7 +44,7 @@ public:
CefWindowInfo& createInfo, bool popup,
const CefPopupFeatures& popupFeatures,
CefRefPtr<CefHandler>& handler,
std::wstring& url,
CefString& url,
CefBrowserSettings& settings)
{
return RV_CONTINUE;
@ -58,12 +58,12 @@ public:
// ignored.
virtual RetVal HandleAddressChange(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const std::wstring& url);
const CefString& url);
// Event called when the page title changes. The return value is currently
// ignored.
virtual RetVal HandleTitleChange(CefRefPtr<CefBrowser> browser,
const std::wstring& title);
const CefString& title);
// Event called before browser navigation. The client has an opportunity to
// modify the |request| object if desired. Return RV_HANDLED to cancel
@ -97,8 +97,8 @@ public:
virtual RetVal HandleLoadError(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
ErrorCode errorCode,
const std::wstring& failedUrl,
std::wstring& errorText);
const CefString& failedUrl,
CefString& errorText);
// Event called before a resource is loaded. To allow the resource to load
// normally return RV_CONTINUE. To redirect the resource to a new url
@ -108,9 +108,9 @@ public:
// To cancel loading of the resource return RV_HANDLED.
virtual RetVal HandleBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefRequest> request,
std::wstring& redirectUrl,
CefString& redirectUrl,
CefRefPtr<CefStreamReader>& resourceStream,
std::wstring& mimeType,
CefString& mimeType,
int loadFlags);
// Called when a server indicates via the 'Content-Disposition' header that a
@ -122,8 +122,8 @@ public:
// or RV_HANDLED to cancel the file download.
/*--cef()--*/
virtual RetVal HandleDownloadResponse(CefRefPtr<CefBrowser> browser,
const std::wstring& mimeType,
const std::wstring& fileName,
const CefString& mimeType,
const CefString& fileName,
int64 contentLength,
CefRefPtr<CefDownloadHandler>& handler);
@ -139,7 +139,7 @@ public:
// item. |label| contains the default text and may be modified to substitute
// alternate text. The return value is currently ignored.
virtual RetVal HandleGetMenuLabel(CefRefPtr<CefBrowser> browser,
MenuId menuId, std::wstring& label)
MenuId menuId, CefString& label)
{
return RV_CONTINUE;
}
@ -177,21 +177,21 @@ public:
virtual RetVal HandlePrintHeaderFooter(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefPrintInfo& printInfo,
const std::wstring& url,
const std::wstring& title,
const CefString& url,
const CefString& title,
int currentPage, int maxPages,
std::wstring& topLeft,
std::wstring& topCenter,
std::wstring& topRight,
std::wstring& bottomLeft,
std::wstring& bottomCenter,
std::wstring& bottomRight);
CefString& topLeft,
CefString& topCenter,
CefString& topRight,
CefString& bottomLeft,
CefString& bottomCenter,
CefString& bottomRight);
// Run a JS alert message. Return RV_CONTINUE to display the default alert
// or RV_HANDLED if you displayed a custom alert.
virtual RetVal HandleJSAlert(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const std::wstring& message)
const CefString& message)
{
return RV_CONTINUE;
}
@ -201,7 +201,7 @@ public:
// set |retval| to true if the user accepted the confirmation.
virtual RetVal HandleJSConfirm(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const std::wstring& message, bool& retval)
const CefString& message, bool& retval)
{
return RV_CONTINUE;
}
@ -212,10 +212,10 @@ public:
// |result| to the resulting value.
virtual RetVal HandleJSPrompt(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const std::wstring& message,
const std::wstring& defaultValue,
const CefString& message,
const CefString& defaultValue,
bool& retval,
std::wstring& result)
CefString& result)
{
return RV_CONTINUE;
}
@ -254,7 +254,7 @@ public:
// you can optionally modify |text| and then return RV_CONTINUE to allow
// the browser to display the tooltip.
virtual RetVal HandleTooltip(CefRefPtr<CefBrowser> browser,
std::wstring& text)
CefString& text)
{
return RV_CONTINUE;
}
@ -279,8 +279,8 @@ public:
// Called to display a console message. Return RV_HANDLED to stop the message
// from being output to the console.
RetVal HandleConsoleMessage(CefRefPtr<CefBrowser> browser,
const std::wstring& message,
const std::wstring& source, int line);
const CefString& message,
const CefString& source, int line);
// Called to report find results returned by CefBrowser::Find(). |identifer|
// is the identifier passed to CefBrowser::Find(), |count| is the number of
@ -304,10 +304,10 @@ public:
CefRefPtr<CefBrowser> GetBrowser() { return m_Browser; }
CefWindowHandle GetBrowserHwnd() { return m_BrowserHwnd; }
std::wstring GetLogFile();
std::string GetLogFile();
void SetLastDownloadFile(const std::wstring& fileName);
std::wstring GetLastDownloadFile();
void SetLastDownloadFile(const std::string& fileName);
std::string GetLastDownloadFile();
// Send a notification to the application. Notifications should not block the
// caller.
@ -339,11 +339,11 @@ protected:
// True if the user can navigate forwards
bool m_bCanGoForward;
std::wstring m_LogFile;
std::string m_LogFile;
// Support for downloading files.
CefRefPtr<DownloadListener> m_DownloadListener;
std::wstring m_LastDownloadFile;
std::string m_LastDownloadFile;
};
@ -354,7 +354,7 @@ CefRefPtr<CefBrowser> AppGetBrowser();
CefWindowHandle AppGetMainHwnd();
// Returns the application working directory.
std::wstring AppGetWorkingDirectory();
std::string AppGetWorkingDirectory();
// Implementations for various tests.
void RunGetSourceTest(CefRefPtr<CefFrame> frame);

View File

@ -10,7 +10,6 @@
#include "extension_test.h"
#include "scheme_test.h"
#include "string_util.h"
#include "string_util_mac.h"
#import <Cocoa/Cocoa.h>
#include <sstream>
@ -78,7 +77,7 @@ const int kWindowHeight = 600;
if (tempUrl && ![tempUrl scheme])
url = [@"http://" stringByAppendingString:url];
std::wstring urlStr = NSStringToWString(url);
std::string urlStr = [url UTF8String];
g_handler->GetBrowser()->GetMainFrame()->LoadURL(urlStr);
}
@ -92,27 +91,27 @@ const int kWindowHeight = 600;
}
- (void)notifyConsoleMessage:(id)object {
std::wstringstream ss;
ss << L"Console messages will be written to " << g_handler->GetLogFile();
NSString* str = WStringToNSString(ss.str());
std::stringstream ss;
ss << "Console messages will be written to " << g_handler->GetLogFile();
NSString* str = [NSString stringWithUTF8String:(ss.str().c_str())];
[self alert:@"Console Messages" withMessage:str];
[str release];
}
- (void)notifyDownloadComplete:(id)object {
std::wstringstream ss;
ss << L"File \"" << g_handler->GetLastDownloadFile() <<
L"\" downloaded successfully.";
NSString* str = WStringToNSString(ss.str());
std::stringstream ss;
ss << "File \"" << g_handler->GetLastDownloadFile() <<
"\" downloaded successfully.";
NSString* str = [NSString stringWithUTF8String:(ss.str().c_str())];
[self alert:@"File Download" withMessage:str];
[str release];
}
- (void)notifyDownloadError:(id)object {
std::wstringstream ss;
ss << L"File \"" << g_handler->GetLastDownloadFile() <<
L"\" failed to download.";
NSString* str = WStringToNSString(ss.str());
std::stringstream ss;
ss << "File \"" << g_handler->GetLastDownloadFile() <<
"\" failed to download.";
NSString* str = [NSString stringWithUTF8String:(ss.str().c_str())];
[self alert:@"File Download" withMessage:str];
[str release];
}
@ -373,13 +372,14 @@ int main(int argc, char* argv[])
CefHandler::RetVal ClientHandler::HandleAddressChange(
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
const std::wstring& url)
const CefString& url)
{
if(m_BrowserHwnd == browser->GetWindowHandle() && frame->IsMain())
{
// Set the edit window text
NSTextField* textField = (NSTextField*)m_EditHwnd;
NSString* str = WStringToNSString(url);
NSString* str =
[NSString stringWithUTF8String:(std::string(url).c_str())];
[textField setStringValue:str];
[str release];
}
@ -387,11 +387,12 @@ CefHandler::RetVal ClientHandler::HandleAddressChange(
}
CefHandler::RetVal ClientHandler::HandleTitleChange(
CefRefPtr<CefBrowser> browser, const std::wstring& title)
CefRefPtr<CefBrowser> browser, const CefString& title)
{
// Set the frame window title bar
NSWindow* window = (NSWindow*)m_MainHwnd;
NSString* str = WStringToNSString(title);
NSString* str =
[NSString stringWithUTF8String:(std::string(title).c_str())];
[window setTitle:str];
[str release];
return RV_CONTINUE;
@ -399,17 +400,17 @@ CefHandler::RetVal ClientHandler::HandleTitleChange(
CefHandler::RetVal ClientHandler::HandleBeforeResourceLoad(
CefRefPtr<CefBrowser> browser, CefRefPtr<CefRequest> request,
std::wstring& redirectUrl, CefRefPtr<CefStreamReader>& resourceStream,
std::wstring& mimeType, int loadFlags)
CefString& redirectUrl, CefRefPtr<CefStreamReader>& resourceStream,
CefString& mimeType, int loadFlags)
{
std::wstring url = request->GetURL();
if(url == L"http://tests/request") {
std::string url = request->GetURL();
if(url == "http://tests/request") {
// Show the request contents
std::wstring dump;
std::string dump;
DumpRequestContents(request, dump);
resourceStream = CefStreamReader::CreateForData(
(void*)dump.c_str(), dump.size() * sizeof(wchar_t));
mimeType = L"text/plain";
(void*)dump.c_str(), dump.size());
mimeType = "text/plain";
}
return RV_CONTINUE;
}
@ -440,7 +441,7 @@ void ClientHandler::SendNotification(NotificationType type)
// Global functions
std::wstring AppGetWorkingDirectory()
std::string AppGetWorkingDirectory()
{
return StringToWString(szWorkingDir);
return szWorkingDir;
}

Some files were not shown because too many files have changed in this diff Show More