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

View File

@ -137,8 +137,8 @@ void CefDoMessageLoopWork();
// example.test.increment(); // example.test.increment();
// //
/*--cef()--*/ /*--cef()--*/
bool CefRegisterExtension(const std::wstring& extension_name, bool CefRegisterExtension(const CefString& extension_name,
const std::wstring& javascript_code, const CefString& javascript_code,
CefRefPtr<CefV8Handler> handler); CefRefPtr<CefV8Handler> handler);
@ -147,8 +147,8 @@ bool CefRegisterExtension(const std::wstring& extension_name,
// by CefSchemeHandler instances returned by the factory. Specify an empty // by CefSchemeHandler instances returned by the factory. Specify an empty
// |host_name| value to match all host names. // |host_name| value to match all host names.
/*--cef()--*/ /*--cef()--*/
bool CefRegisterScheme(const std::wstring& scheme_name, bool CefRegisterScheme(const CefString& scheme_name,
const std::wstring& host_name, const CefString& host_name,
CefRefPtr<CefSchemeHandlerFactory> factory); CefRefPtr<CefSchemeHandlerFactory> factory);
@ -215,9 +215,9 @@ public:
// //
// class MyHandler : public CefThreadSafeBase<CefHandler> // 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 // Lock(); // Begin protecting code
// m_title = title; // m_title = title;
@ -354,7 +354,7 @@ public:
/*--cef()--*/ /*--cef()--*/
static bool CreateBrowser(CefWindowInfo& windowInfo, bool popup, static bool CreateBrowser(CefWindowInfo& windowInfo, bool popup,
CefRefPtr<CefHandler> handler, CefRefPtr<CefHandler> handler,
const std::wstring& url); const CefString& url);
// Create a new browser window using the window parameters specified // Create a new browser window using the window parameters specified
// by |windowInfo|. The |popup| parameter should be true if the new window is // by |windowInfo|. The |popup| parameter should be true if the new window is
@ -364,7 +364,7 @@ public:
static CefRefPtr<CefBrowser> CreateBrowserSync(CefWindowInfo& windowInfo, static CefRefPtr<CefBrowser> CreateBrowserSync(CefWindowInfo& windowInfo,
bool popup, bool popup,
CefRefPtr<CefHandler> handler, CefRefPtr<CefHandler> handler,
const std::wstring& url); const CefString& url);
// Returns true if the browser can navigate backwards. // Returns true if the browser can navigate backwards.
/*--cef()--*/ /*--cef()--*/
@ -415,11 +415,11 @@ public:
// Returns the frame with the specified name, or NULL if not found. // Returns the frame with the specified name, or NULL if not found.
/*--cef()--*/ /*--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. // Returns the names of all existing frames.
/*--cef()--*/ /*--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 // Search for |searchText|. |identifier| can be used to have multiple searches
// running simultaniously. |forward| indicates whether to search forward or // 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 // be case-sensitive. |findNext| indicates whether this is the first request
// or a follow-up. // or a follow-up.
/*--cef()--*/ /*--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; bool forward, bool matchCase, bool findNext) =0;
// Cancel all searches that are currently going on. // Cancel all searches that are currently going on.
@ -476,11 +476,11 @@ public:
// Returns this frame's HTML source as a string. // Returns this frame's HTML source as a string.
/*--cef()--*/ /*--cef()--*/
virtual std::wstring GetSource() =0; virtual CefString GetSource() =0;
// Returns this frame's display text as a string. // Returns this frame's display text as a string.
/*--cef()--*/ /*--cef()--*/
virtual std::wstring GetText() =0; virtual CefString GetText() =0;
// Load the request represented by the |request| object. // Load the request represented by the |request| object.
/*--cef()--*/ /*--cef()--*/
@ -488,17 +488,17 @@ public:
// Load the specified |url|. // Load the specified |url|.
/*--cef()--*/ /*--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|. // Load the contents of |string| with the optional dummy target |url|.
/*--cef()--*/ /*--cef()--*/
virtual void LoadString(const std::wstring& string, virtual void LoadString(const CefString& string,
const std::wstring& url) =0; const CefString& url) =0;
// Load the contents of |stream| with the optional dummy target |url|. // Load the contents of |stream| with the optional dummy target |url|.
/*--cef()--*/ /*--cef()--*/
virtual void LoadStream(CefRefPtr<CefStreamReader> stream, 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| // 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. // 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 // error. The |start_line| parameter is the base line number to use for error
// reporting. // reporting.
/*--cef()--*/ /*--cef()--*/
virtual void ExecuteJavaScript(const std::wstring& jsCode, virtual void ExecuteJavaScript(const CefString& jsCode,
const std::wstring& scriptUrl, const CefString& scriptUrl,
int startLine) =0; int startLine) =0;
// Returns true if this is the main frame. // Returns true if this is the main frame.
@ -520,11 +520,11 @@ public:
// Returns this frame's name. // Returns this frame's name.
/*--cef()--*/ /*--cef()--*/
virtual std::wstring GetName() =0; virtual CefString GetName() =0;
// Return the URL currently loaded in this frame. // Return the URL currently loaded in this frame.
/*--cef()--*/ /*--cef()--*/
virtual std::wstring GetURL() =0; virtual CefString GetURL() =0;
}; };
@ -557,7 +557,7 @@ public:
CefWindowInfo& windowInfo, bool popup, CefWindowInfo& windowInfo, bool popup,
const CefPopupFeatures& popupFeatures, const CefPopupFeatures& popupFeatures,
CefRefPtr<CefHandler>& handler, CefRefPtr<CefHandler>& handler,
std::wstring& url, CefString& url,
CefBrowserSettings& settings) =0; CefBrowserSettings& settings) =0;
// Event called after a new window is created. The return value is currently // Event called after a new window is created. The return value is currently
@ -570,13 +570,13 @@ public:
/*--cef()--*/ /*--cef()--*/
virtual RetVal HandleAddressChange(CefRefPtr<CefBrowser> browser, virtual RetVal HandleAddressChange(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, CefRefPtr<CefFrame> frame,
const std::wstring& url) =0; const CefString& url) =0;
// Event called when the page title changes. The return value is currently // Event called when the page title changes. The return value is currently
// ignored. // ignored.
/*--cef()--*/ /*--cef()--*/
virtual RetVal HandleTitleChange(CefRefPtr<CefBrowser> browser, virtual RetVal HandleTitleChange(CefRefPtr<CefBrowser> browser,
const std::wstring& title) =0; const CefString& title) =0;
// Various browser navigation types supported by chrome. // Various browser navigation types supported by chrome.
typedef cef_handler_navtype_t NavType; typedef cef_handler_navtype_t NavType;
@ -618,8 +618,8 @@ public:
virtual RetVal HandleLoadError(CefRefPtr<CefBrowser> browser, virtual RetVal HandleLoadError(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, CefRefPtr<CefFrame> frame,
ErrorCode errorCode, ErrorCode errorCode,
const std::wstring& failedUrl, const CefString& failedUrl,
std::wstring& errorText) =0; CefString& errorText) =0;
// Event called before a resource is loaded. To allow the resource to load // 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 // normally return RV_CONTINUE. To redirect the resource to a new url
@ -632,9 +632,9 @@ public:
/*--cef()--*/ /*--cef()--*/
virtual RetVal HandleBeforeResourceLoad(CefRefPtr<CefBrowser> browser, virtual RetVal HandleBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefRequest> request, CefRefPtr<CefRequest> request,
std::wstring& redirectUrl, CefString& redirectUrl,
CefRefPtr<CefStreamReader>& resourceStream, CefRefPtr<CefStreamReader>& resourceStream,
std::wstring& mimeType, CefString& mimeType,
int loadFlags) =0; int loadFlags) =0;
// Called when a server indicates via the 'Content-Disposition' header that a // 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. // or RV_HANDLED to cancel the file download.
/*--cef()--*/ /*--cef()--*/
virtual RetVal HandleDownloadResponse(CefRefPtr<CefBrowser> browser, virtual RetVal HandleDownloadResponse(CefRefPtr<CefBrowser> browser,
const std::wstring& mimeType, const CefString& mimeType,
const std::wstring& fileName, const CefString& fileName,
int64 contentLength, int64 contentLength,
CefRefPtr<CefDownloadHandler>& handler) =0; CefRefPtr<CefDownloadHandler>& handler) =0;
@ -668,7 +668,7 @@ public:
// alternate text. The return value is currently ignored. // alternate text. The return value is currently ignored.
/*--cef()--*/ /*--cef()--*/
virtual RetVal HandleGetMenuLabel(CefRefPtr<CefBrowser> browser, 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. // Event called when an option is selected from the default context menu.
// Return RV_HANDLED to cancel default handling of the action. // Return RV_HANDLED to cancel default handling of the action.
@ -703,22 +703,22 @@ public:
virtual RetVal HandlePrintHeaderFooter(CefRefPtr<CefBrowser> browser, virtual RetVal HandlePrintHeaderFooter(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, CefRefPtr<CefFrame> frame,
CefPrintInfo& printInfo, CefPrintInfo& printInfo,
const std::wstring& url, const CefString& url,
const std::wstring& title, const CefString& title,
int currentPage, int maxPages, int currentPage, int maxPages,
std::wstring& topLeft, CefString& topLeft,
std::wstring& topCenter, CefString& topCenter,
std::wstring& topRight, CefString& topRight,
std::wstring& bottomLeft, CefString& bottomLeft,
std::wstring& bottomCenter, CefString& bottomCenter,
std::wstring& bottomRight) =0; CefString& bottomRight) =0;
// Run a JS alert message. Return RV_CONTINUE to display the default alert // Run a JS alert message. Return RV_CONTINUE to display the default alert
// or RV_HANDLED if you displayed a custom alert. // or RV_HANDLED if you displayed a custom alert.
/*--cef()--*/ /*--cef()--*/
virtual RetVal HandleJSAlert(CefRefPtr<CefBrowser> browser, virtual RetVal HandleJSAlert(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, 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 // 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 // or RV_HANDLED if you displayed a custom alert. If you handled the alert
@ -726,7 +726,7 @@ public:
/*--cef()--*/ /*--cef()--*/
virtual RetVal HandleJSConfirm(CefRefPtr<CefBrowser> browser, virtual RetVal HandleJSConfirm(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, 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 // 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 // or RV_HANDLED if you displayed a custom prompt. If you handled the prompt
@ -735,10 +735,10 @@ public:
/*--cef()--*/ /*--cef()--*/
virtual RetVal HandleJSPrompt(CefRefPtr<CefBrowser> browser, virtual RetVal HandleJSPrompt(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, CefRefPtr<CefFrame> frame,
const std::wstring& message, const CefString& message,
const std::wstring& defaultValue, const CefString& defaultValue,
bool& retval, bool& retval,
std::wstring& result) =0; CefString& result) =0;
// Event called for adding values to a frame's JavaScript 'window' object. The // Event called for adding values to a frame's JavaScript 'window' object. The
// return value is currently ignored. // return value is currently ignored.
@ -792,14 +792,14 @@ public:
// the browser to display the tooltip. // the browser to display the tooltip.
/*--cef()--*/ /*--cef()--*/
virtual RetVal HandleTooltip(CefRefPtr<CefBrowser> browser, 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 // Called to display a console message. Return RV_HANDLED to stop the message
// from being output to the console. // from being output to the console.
/*--cef()--*/ /*--cef()--*/
virtual RetVal HandleConsoleMessage(CefRefPtr<CefBrowser> browser, virtual RetVal HandleConsoleMessage(CefRefPtr<CefBrowser> browser,
const std::wstring& message, const CefString& message,
const std::wstring& source, int line) =0; const CefString& source, int line) =0;
// Called to report find results returned by CefBrowser::Find(). |identifer| // Called to report find results returned by CefBrowser::Find(). |identifer|
// is the identifier passed to CefBrowser::Find(), |count| is the number of // is the identifier passed to CefBrowser::Find(), |count| is the number of
@ -820,7 +820,7 @@ public:
class CefRequest : public CefBase class CefRequest : public CefBase
{ {
public: public:
typedef std::map<std::wstring,std::wstring> HeaderMap; typedef std::map<CefString,CefString> HeaderMap;
// Create a new CefRequest object. // Create a new CefRequest object.
/*--cef()--*/ /*--cef()--*/
@ -828,16 +828,16 @@ public:
// Fully qualified URL to load. // Fully qualified URL to load.
/*--cef()--*/ /*--cef()--*/
virtual std::wstring GetURL() =0; virtual CefString GetURL() =0;
/*--cef()--*/ /*--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 // Optional request method type, defaulting to POST if post data is provided
// and GET otherwise. // and GET otherwise.
/*--cef()--*/ /*--cef()--*/
virtual std::wstring GetMethod() =0; virtual CefString GetMethod() =0;
/*--cef()--*/ /*--cef()--*/
virtual void SetMethod(const std::wstring& method) =0; virtual void SetMethod(const CefString& method) =0;
// Optional post data. // Optional post data.
/*--cef()--*/ /*--cef()--*/
@ -853,8 +853,8 @@ public:
// Set all values at one time. // Set all values at one time.
/*--cef()--*/ /*--cef()--*/
virtual void Set(const std::wstring& url, virtual void Set(const CefString& url,
const std::wstring& method, const CefString& method,
CefRefPtr<CefPostData> postData, CefRefPtr<CefPostData> postData,
const HeaderMap& headerMap) =0; const HeaderMap& headerMap) =0;
}; };
@ -912,7 +912,7 @@ public:
// The post data element will represent a file. // The post data element will represent a file.
/*--cef()--*/ /*--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 // The post data element will represent bytes. The bytes passed
// in will be copied. // in will be copied.
@ -925,7 +925,7 @@ public:
// Return the file name. // Return the file name.
/*--cef()--*/ /*--cef()--*/
virtual std::wstring GetFile() =0; virtual CefString GetFile() =0;
// Return the number of bytes. // Return the number of bytes.
/*--cef()--*/ /*--cef()--*/
@ -969,7 +969,7 @@ class CefStreamReader : public CefBase
public: public:
// Create a new CefStreamReader object. // Create a new CefStreamReader object.
/*--cef()--*/ /*--cef()--*/
static CefRefPtr<CefStreamReader> CreateForFile(const std::wstring& fileName); static CefRefPtr<CefStreamReader> CreateForFile(const CefString& fileName);
/*--cef()--*/ /*--cef()--*/
static CefRefPtr<CefStreamReader> CreateForData(void* data, size_t size); static CefRefPtr<CefStreamReader> CreateForData(void* data, size_t size);
/*--cef()--*/ /*--cef()--*/
@ -1026,7 +1026,7 @@ class CefStreamWriter : public CefBase
public: public:
// Create a new CefStreamWriter object. // Create a new CefStreamWriter object.
/*--cef()--*/ /*--cef()--*/
static CefRefPtr<CefStreamWriter> CreateForFile(const std::wstring& fileName); static CefRefPtr<CefStreamWriter> CreateForFile(const CefString& fileName);
/*--cef()--*/ /*--cef()--*/
static CefRefPtr<CefStreamWriter> CreateForHandler(CefRefPtr<CefWriteHandler> handler); static CefRefPtr<CefStreamWriter> CreateForHandler(CefRefPtr<CefWriteHandler> handler);
@ -1059,11 +1059,11 @@ public:
// Execute with the specified argument list and return value. Return true if // Execute with the specified argument list and return value. Return true if
// the method was handled. // the method was handled.
/*--cef()--*/ /*--cef()--*/
virtual bool Execute(const std::wstring& name, virtual bool Execute(const CefString& name,
CefRefPtr<CefV8Value> object, CefRefPtr<CefV8Value> object,
const CefV8ValueList& arguments, const CefV8ValueList& arguments,
CefRefPtr<CefV8Value>& retval, CefRefPtr<CefV8Value>& retval,
std::wstring& exception) =0; CefString& exception) =0;
}; };
@ -1087,13 +1087,13 @@ public:
/*--cef()--*/ /*--cef()--*/
static CefRefPtr<CefV8Value> CreateDouble(double value); static CefRefPtr<CefV8Value> CreateDouble(double value);
/*--cef()--*/ /*--cef()--*/
static CefRefPtr<CefV8Value> CreateString(const std::wstring& value); static CefRefPtr<CefV8Value> CreateString(const CefString& value);
/*--cef()--*/ /*--cef()--*/
static CefRefPtr<CefV8Value> CreateObject(CefRefPtr<CefBase> user_data); static CefRefPtr<CefV8Value> CreateObject(CefRefPtr<CefBase> user_data);
/*--cef()--*/ /*--cef()--*/
static CefRefPtr<CefV8Value> CreateArray(); static CefRefPtr<CefV8Value> CreateArray();
/*--cef()--*/ /*--cef()--*/
static CefRefPtr<CefV8Value> CreateFunction(const std::wstring& name, static CefRefPtr<CefV8Value> CreateFunction(const CefString& name,
CefRefPtr<CefV8Handler> handler); CefRefPtr<CefV8Handler> handler);
// Check the value type. // Check the value type.
@ -1125,7 +1125,7 @@ public:
/*--cef()--*/ /*--cef()--*/
virtual double GetDoubleValue() =0; virtual double GetDoubleValue() =0;
/*--cef()--*/ /*--cef()--*/
virtual std::wstring GetStringValue() =0; virtual CefString GetStringValue() =0;
// OBJECT METHODS - These methods are only available on objects. Arrays and // 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. // Returns true if the object has a value with the specified identifier.
/*--cef(capi_name=has_value_bykey)--*/ /*--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)--*/ /*--cef(capi_name=has_value_byindex)--*/
virtual bool HasValue(int index) =0; virtual bool HasValue(int index) =0;
// Delete the value with the specified identifier. // Delete the value with the specified identifier.
/*--cef(capi_name=delete_value_bykey)--*/ /*--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)--*/ /*--cef(capi_name=delete_value_byindex)--*/
virtual bool DeleteValue(int index) =0; virtual bool DeleteValue(int index) =0;
// Returns the value with the specified identifier. // Returns the value with the specified identifier.
/*--cef(capi_name=get_value_bykey)--*/ /*--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)--*/ /*--cef(capi_name=get_value_byindex)--*/
virtual CefRefPtr<CefV8Value> GetValue(int index) =0; virtual CefRefPtr<CefV8Value> GetValue(int index) =0;
// Associate value with the specified identifier. // Associate value with the specified identifier.
/*--cef(capi_name=set_value_bykey)--*/ /*--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)--*/ /*--cef(capi_name=set_value_byindex)--*/
virtual bool SetValue(int index, CefRefPtr<CefV8Value> value) =0; virtual bool SetValue(int index, CefRefPtr<CefV8Value> value) =0;
// Read the keys for the object's values into the specified vector. Integer- // Read the keys for the object's values into the specified vector. Integer-
// based keys will also be returned as strings. // based keys will also be returned as strings.
/*--cef()--*/ /*--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. // Returns the user data, if any, specified when the object was created.
/*--cef()--*/ /*--cef()--*/
@ -1178,7 +1178,7 @@ public:
// Returns the function name. // Returns the function name.
/*--cef()--*/ /*--cef()--*/
virtual std::wstring GetFunctionName() =0; virtual CefString GetFunctionName() =0;
// Returns the function handler or NULL if not a CEF-created function. // Returns the function handler or NULL if not a CEF-created function.
/*--cef()--*/ /*--cef()--*/
@ -1189,7 +1189,7 @@ public:
virtual bool ExecuteFunction(CefRefPtr<CefV8Value> object, virtual bool ExecuteFunction(CefRefPtr<CefV8Value> object,
const CefV8ValueList& arguments, const CefV8ValueList& arguments,
CefRefPtr<CefV8Value>& retval, CefRefPtr<CefV8Value>& retval,
std::wstring& exception) =0; CefString& exception) =0;
}; };
@ -1220,7 +1220,7 @@ public:
// |mime_type| to the mime type for the response. // |mime_type| to the mime type for the response.
/*--cef()--*/ /*--cef()--*/
virtual bool ProcessRequest(CefRefPtr<CefRequest> request, 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. // Cancel processing of the request.
/*--cef()--*/ /*--cef()--*/
@ -1265,7 +1265,7 @@ public:
/*--cef()--*/ /*--cef()--*/
static CefRefPtr<CefXmlReader> Create(CefRefPtr<CefStreamReader> stream, static CefRefPtr<CefXmlReader> Create(CefRefPtr<CefStreamReader> stream,
EncodingType encodingType, EncodingType encodingType,
const std::wstring& URI); const CefString& URI);
// Moves the cursor to the next node in the document. This method must be // 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 // called at least once to set the current cursor position. Returns true if
@ -1284,7 +1284,7 @@ public:
// Returns the error string. // Returns the error string.
/*--cef()--*/ /*--cef()--*/
virtual std::wstring GetError() =0; virtual CefString GetError() =0;
// The below methods retrieve data for the node at the current cursor // The below methods retrieve data for the node at the current cursor
@ -1301,32 +1301,32 @@ public:
// Returns the local name. See // Returns the local name. See
// http://www.w3.org/TR/REC-xml-names/#NT-LocalPart for additional details. // http://www.w3.org/TR/REC-xml-names/#NT-LocalPart for additional details.
/*--cef()--*/ /*--cef()--*/
virtual std::wstring GetLocalName() =0; virtual CefString GetLocalName() =0;
// Returns the namespace prefix. See http://www.w3.org/TR/REC-xml-names/ for // Returns the namespace prefix. See http://www.w3.org/TR/REC-xml-names/ for
// additional details. // additional details.
/*--cef()--*/ /*--cef()--*/
virtual std::wstring GetPrefix() =0; virtual CefString GetPrefix() =0;
// Returns the qualified name, equal to (Prefix:)LocalName. See // Returns the qualified name, equal to (Prefix:)LocalName. See
// http://www.w3.org/TR/REC-xml-names/#ns-qualnames for additional details. // http://www.w3.org/TR/REC-xml-names/#ns-qualnames for additional details.
/*--cef()--*/ /*--cef()--*/
virtual std::wstring GetQualifiedName() =0; virtual CefString GetQualifiedName() =0;
// Returns the URI defining the namespace associated with the node. See // Returns the URI defining the namespace associated with the node. See
// http://www.w3.org/TR/REC-xml-names/ for additional details. // http://www.w3.org/TR/REC-xml-names/ for additional details.
/*--cef()--*/ /*--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 // Returns the base URI of the node. See http://www.w3.org/TR/xmlbase/ for
// additional details. // additional details.
/*--cef()--*/ /*--cef()--*/
virtual std::wstring GetBaseURI() =0; virtual CefString GetBaseURI() =0;
// Returns the xml:lang scope within which the node resides. See // Returns the xml:lang scope within which the node resides. See
// http://www.w3.org/TR/REC-xml/#sec-lang-tag for additional details. // http://www.w3.org/TR/REC-xml/#sec-lang-tag for additional details.
/*--cef()--*/ /*--cef()--*/
virtual std::wstring GetXmlLang() =0; virtual CefString GetXmlLang() =0;
// Returns true if the node represents an empty element. <a/> is considered // Returns true if the node represents an empty element. <a/> is considered
// empty but <a></a> is not. // empty but <a></a> is not.
@ -1339,7 +1339,7 @@ public:
// Returns the text value. // Returns the text value.
/*--cef()--*/ /*--cef()--*/
virtual std::wstring GetValue() =0; virtual CefString GetValue() =0;
// Returns true if the node has attributes. // Returns true if the node has attributes.
/*--cef()--*/ /*--cef()--*/
@ -1351,25 +1351,25 @@ public:
// Returns the value of the attribute at the specified 0-based index. // Returns the value of the attribute at the specified 0-based index.
/*--cef(capi_name=get_attribute_byindex)--*/ /*--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. // Returns the value of the attribute with the specified qualified name.
/*--cef(capi_name=get_attribute_byqname)--*/ /*--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 // Returns the value of the attribute with the specified local name and
// namespace URI. // namespace URI.
/*--cef(capi_name=get_attribute_bylname)--*/ /*--cef(capi_name=get_attribute_bylname)--*/
virtual std::wstring GetAttribute(const std::wstring& localName, virtual CefString GetAttribute(const CefString& localName,
const std::wstring& namespaceURI) =0; const CefString& namespaceURI) =0;
// Returns an XML representation of the current node's children. // Returns an XML representation of the current node's children.
/*--cef()--*/ /*--cef()--*/
virtual std::wstring GetInnerXml() =0; virtual CefString GetInnerXml() =0;
// Returns an XML representation of the current node including its children. // Returns an XML representation of the current node including its children.
/*--cef()--*/ /*--cef()--*/
virtual std::wstring GetOuterXml() =0; virtual CefString GetOuterXml() =0;
// Returns the line number for the current node. // Returns the line number for the current node.
/*--cef()--*/ /*--cef()--*/
@ -1389,13 +1389,13 @@ public:
// Moves the cursor to the attribute with the specified qualified name. // Moves the cursor to the attribute with the specified qualified name.
// Returns true if the cursor position was set successfully. // Returns true if the cursor position was set successfully.
/*--cef(capi_name=move_to_attribute_byqname)--*/ /*--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 // Moves the cursor to the attribute with the specified local name and
// namespace URI. Returns true if the cursor position was set successfully. // namespace URI. Returns true if the cursor position was set successfully.
/*--cef(capi_name=move_to_attribute_bylname)--*/ /*--cef(capi_name=move_to_attribute_bylname)--*/
virtual bool MoveToAttribute(const std::wstring& localName, virtual bool MoveToAttribute(const CefString& localName,
const std::wstring& namespaceURI) =0; const CefString& namespaceURI) =0;
// Moves the cursor to the first attribute in the current element. Returns // Moves the cursor to the first attribute in the current element. Returns
// true if the cursor position was set successfully. // 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 // is true then the search will be case sensitive. Returns true if the cursor
// position was set successfully. // position was set successfully.
/*--cef()--*/ /*--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 // Closes the archive. This should be called directly to ensure that cleanup
// occurs on the correct thread. // occurs on the correct thread.
@ -1450,7 +1450,7 @@ public:
// Returns the name of the file. // Returns the name of the file.
/*--cef()--*/ /*--cef()--*/
virtual std::wstring GetFileName() =0; virtual CefString GetFileName() =0;
// Returns the uncompressed size of the file. // Returns the uncompressed size of the file.
/*--cef()--*/ /*--cef()--*/
@ -1463,7 +1463,7 @@ public:
// Opens the file for reading of uncompressed data. A read password may // Opens the file for reading of uncompressed data. A read password may
// optionally be specified. // optionally be specified.
/*--cef()--*/ /*--cef()--*/
virtual bool OpenFile(const std::wstring& password) =0; virtual bool OpenFile(const CefString& password) =0;
// Closes the file. // Closes the file.
/*--cef()--*/ /*--cef()--*/
@ -1608,14 +1608,10 @@ public:
void Reset() void Reset()
{ {
if(cache_path) cef_string_clear(&cache_path);
cef_string_free(cache_path); cef_string_clear(&user_agent);
if(user_agent) cef_string_clear(&product_version);
cef_string_free(user_agent); cef_string_clear(&locale);
if(product_version)
cef_string_free(product_version);
if(locale)
cef_string_free(locale);
if(extra_plugin_paths) if(extra_plugin_paths)
cef_string_list_free(extra_plugin_paths); cef_string_list_free(extra_plugin_paths);
Init(); Init();
@ -1641,22 +1637,11 @@ public:
{ {
multi_threaded_message_loop = r.multi_threaded_message_loop; multi_threaded_message_loop = r.multi_threaded_message_loop;
if(cache_path) cef_string_copy(r.cache_path.str, r.cache_path.length, &cache_path);
cef_string_free(cache_path); cef_string_copy(r.user_agent.str, r.user_agent.length, &user_agent);
cache_path = r.cache_path ? cef_string_alloc(r.cache_path) : NULL; cef_string_copy(r.product_version.str, r.product_version.length,
&product_version);
if(user_agent) cef_string_copy(r.locale.str, r.locale.length, &locale);
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;
if(extra_plugin_paths) if(extra_plugin_paths)
cef_string_list_free(extra_plugin_paths); cef_string_list_free(extra_plugin_paths);
@ -1701,22 +1686,14 @@ public:
void Reset() void Reset()
{ {
if(standard_font_family) cef_string_clear(&standard_font_family);
cef_string_free(standard_font_family); cef_string_clear(&fixed_font_family);
if(fixed_font_family) cef_string_clear(&serif_font_family);
cef_string_free(fixed_font_family); cef_string_clear(&sans_serif_font_family);
if(serif_font_family) cef_string_clear(&cursive_font_family);
cef_string_free(serif_font_family); cef_string_clear(&fantasy_font_family);
if(sans_serif_font_family) cef_string_clear(&default_encoding);
cef_string_free(sans_serif_font_family); cef_string_clear(&user_style_sheet_location);
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);
Init(); Init();
} }
@ -1740,35 +1717,18 @@ public:
{ {
drag_drop_disabled = r.drag_drop_disabled; drag_drop_disabled = r.drag_drop_disabled;
if(standard_font_family) cef_string_copy(r.standard_font_family.str, r.standard_font_family.length,
cef_string_free(standard_font_family); &standard_font_family);
standard_font_family = r.standard_font_family ? cef_string_copy(r.fixed_font_family.str, r.fixed_font_family.length,
cef_string_alloc(r.standard_font_family) : NULL; &fixed_font_family);
cef_string_copy(r.serif_font_family.str, r.serif_font_family.length,
if(fixed_font_family) &serif_font_family);
cef_string_free(fixed_font_family); cef_string_copy(r.sans_serif_font_family.str,
fixed_font_family = r.fixed_font_family ? r.sans_serif_font_family.length, &sans_serif_font_family);
cef_string_alloc(r.fixed_font_family) : NULL; cef_string_copy(r.cursive_font_family.str, r.cursive_font_family.length,
&cursive_font_family);
if(serif_font_family) cef_string_copy(r.fantasy_font_family.str, r.fantasy_font_family.length,
cef_string_free(serif_font_family); &fantasy_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;
default_font_size = r.default_font_size; default_font_size = r.default_font_size;
default_fixed_font_size = r.default_fixed_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; minimum_logical_font_size = r.minimum_logical_font_size;
remote_fonts_disabled = r.remote_fonts_disabled; remote_fonts_disabled = r.remote_fonts_disabled;
if(default_encoding) cef_string_copy(r.default_encoding.str, r.default_encoding.length,
cef_string_free(default_encoding); &default_encoding);
default_encoding = r.default_encoding ?
cef_string_alloc(r.default_encoding) : NULL;
encoding_detector_enabled = r.encoding_detector_enabled; encoding_detector_enabled = r.encoding_detector_enabled;
javascript_disabled = r.javascript_disabled; javascript_disabled = r.javascript_disabled;
@ -1805,10 +1763,8 @@ public:
hyperlink_auditing_disabled = r.hyperlink_auditing_disabled; hyperlink_auditing_disabled = r.hyperlink_auditing_disabled;
user_style_sheet_enabled = r.user_style_sheet_enabled; user_style_sheet_enabled = r.user_style_sheet_enabled;
if(user_style_sheet_location) cef_string_copy(r.user_style_sheet_location.str,
cef_string_free(user_style_sheet_location); r.user_style_sheet_location.length, &user_style_sheet_location);
user_style_sheet_location = r.user_style_sheet_location ?
cef_string_alloc(r.user_style_sheet_location) : NULL;
author_and_user_styles_disabled = r.author_and_user_styles_disabled; author_and_user_styles_disabled = r.author_and_user_styles_disabled;
local_storage_disabled = r.local_storage_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. // // Call another function.
// example.test.increment(); // example.test.increment();
// //
CEF_EXPORT int cef_register_extension(const wchar_t* extension_name, CEF_EXPORT int cef_register_extension(const cef_string_t* extension_name,
const wchar_t* javascript_code, struct _cef_v8handler_t* handler); const cef_string_t* javascript_code, struct _cef_v8handler_t* handler);
// Register a custom scheme handler factory for the specified |scheme_name| and // 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 // |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 // by cef_scheme_handler_t instances returned by the factory. Specify an NULL
// |host_name| value to match all host names. // |host_name| value to match all host names.
CEF_EXPORT int cef_register_scheme(const wchar_t* scheme_name, CEF_EXPORT int cef_register_scheme(const cef_string_t* scheme_name,
const wchar_t* host_name, struct _cef_scheme_handler_factory_t* factory); const cef_string_t* host_name,
struct _cef_scheme_handler_factory_t* factory);
// CEF maintains multiple internal threads that are used for handling different // 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 // 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. // 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, 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. // Returns the names of all existing frames.
void (CEF_CALLBACK *get_frame_names)(struct _cef_browser_t* self, 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 // be case-sensitive. |findNext| indicates whether this is the first request
// or a follow-up. // or a follow-up.
void (CEF_CALLBACK *find)(struct _cef_browser_t* self, int identifier, 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. // Cancel all searches that are currently going on.
void (CEF_CALLBACK *stop_finding)(struct _cef_browser_t* self, 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 // 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. // 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, 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 // 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 // |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 // 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). // |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, 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 // 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); void (CEF_CALLBACK *view_source)(struct _cef_frame_t* self);
// Returns this frame's HTML source as a string. // Returns this frame's HTML source as a string.
// The resulting string must be freed by calling cef_string_free(). // The resulting string must be freed by calling cef_string_userfree_free().
cef_string_t (CEF_CALLBACK *get_source)(struct _cef_frame_t* self); cef_string_userfree_t (CEF_CALLBACK *get_source)(struct _cef_frame_t* self);
// Returns this frame's display text as a string. // Returns this frame's display text as a string.
// The resulting string must be freed by calling cef_string_free(). // The resulting string must be freed by calling cef_string_userfree_free().
cef_string_t (CEF_CALLBACK *get_text)(struct _cef_frame_t* self); cef_string_userfree_t (CEF_CALLBACK *get_text)(struct _cef_frame_t* self);
// Load the request represented by the |request| object. // Load the request represented by the |request| object.
void (CEF_CALLBACK *load_request)(struct _cef_frame_t* self, void (CEF_CALLBACK *load_request)(struct _cef_frame_t* self,
struct _cef_request_t* request); struct _cef_request_t* request);
// Load the specified |url|. // 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|. // Load the contents of |string| with the optional dummy target |url|.
void (CEF_CALLBACK *load_string)(struct _cef_frame_t* self, 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|. // Load the contents of |stream| with the optional dummy target |url|.
void (CEF_CALLBACK *load_stream)(struct _cef_frame_t* self, 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| // 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 // 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 // error. The |start_line| parameter is the base line number to use for error
// reporting. // reporting.
void (CEF_CALLBACK *execute_java_script)(struct _cef_frame_t* self, 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. // Returns true (1) if this is the main frame.
int (CEF_CALLBACK *is_main)(struct _cef_frame_t* self); 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); int (CEF_CALLBACK *is_focused)(struct _cef_frame_t* self);
// Returns this frame's name. // Returns this frame's name.
// The resulting string must be freed by calling cef_string_free(). // The resulting string must be freed by calling cef_string_userfree_free().
cef_string_t (CEF_CALLBACK *get_name)(struct _cef_frame_t* self); cef_string_userfree_t (CEF_CALLBACK *get_name)(struct _cef_frame_t* self);
// Return the URL currently loaded in this frame. // Return the URL currently loaded in this frame.
// The resulting string must be freed by calling cef_string_free(). // The resulting string must be freed by calling cef_string_userfree_free().
cef_string_t (CEF_CALLBACK *get_url)(struct _cef_frame_t* self); cef_string_userfree_t (CEF_CALLBACK *get_url)(struct _cef_frame_t* self);
} cef_frame_t; } cef_frame_t;
@ -390,13 +394,13 @@ typedef struct _cef_handler_t
// currently ignored. // currently ignored.
enum cef_retval_t (CEF_CALLBACK *handle_address_change)( enum cef_retval_t (CEF_CALLBACK *handle_address_change)(
struct _cef_handler_t* self, struct _cef_browser_t* browser, 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 // Event called when the page title changes. The return value is currently
// ignored. // ignored.
enum cef_retval_t (CEF_CALLBACK *handle_title_change)( enum cef_retval_t (CEF_CALLBACK *handle_title_change)(
struct _cef_handler_t* self, struct _cef_browser_t* browser, 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 // Event called before browser navigation. The client has an opportunity to
// modify the |request| object if desired. Return RV_HANDLED to cancel // 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)( enum cef_retval_t (CEF_CALLBACK *handle_load_error)(
struct _cef_handler_t* self, struct _cef_browser_t* browser, struct _cef_handler_t* self, struct _cef_browser_t* browser,
struct _cef_frame_t* frame, enum cef_handler_errorcode_t errorCode, 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 // 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 // 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. // RV_HANDLED to cancel the file download.
enum cef_retval_t (CEF_CALLBACK *handle_download_response)( enum cef_retval_t (CEF_CALLBACK *handle_download_response)(
struct _cef_handler_t* self, struct _cef_browser_t* browser, struct _cef_handler_t* self, struct _cef_browser_t* browser,
const wchar_t* mimeType, const wchar_t* fileName, int64 contentLength, const cef_string_t* mimeType, const cef_string_t* fileName,
struct _cef_download_handler_t** handler); int64 contentLength, struct _cef_download_handler_t** handler);
// Event called before a context menu is displayed. To cancel display of the // Event called before a context menu is displayed. To cancel display of the
// default context menu return RV_HANDLED. // 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)( enum cef_retval_t (CEF_CALLBACK *handle_print_header_footer)(
struct _cef_handler_t* self, struct _cef_browser_t* browser, struct _cef_handler_t* self, struct _cef_browser_t* browser,
struct _cef_frame_t* frame, struct _cef_print_info_t* printInfo, struct _cef_frame_t* frame, struct _cef_print_info_t* printInfo,
const wchar_t* url, const wchar_t* title, int currentPage, int maxPages, const cef_string_t* url, const cef_string_t* title, int currentPage,
cef_string_t* topLeft, cef_string_t* topCenter, cef_string_t* topRight, int maxPages, cef_string_t* topLeft, cef_string_t* topCenter,
cef_string_t* bottomLeft, cef_string_t* bottomCenter, cef_string_t* topRight, cef_string_t* bottomLeft,
cef_string_t* bottomRight); cef_string_t* bottomCenter, cef_string_t* bottomRight);
// Run a JS alert message. Return RV_CONTINUE to display the default alert or // Run a JS alert message. Return RV_CONTINUE to display the default alert or
// RV_HANDLED if you displayed a custom alert. // RV_HANDLED if you displayed a custom alert.
enum cef_retval_t (CEF_CALLBACK *handle_jsalert)(struct _cef_handler_t* self, enum cef_retval_t (CEF_CALLBACK *handle_jsalert)(struct _cef_handler_t* self,
struct _cef_browser_t* browser, struct _cef_frame_t* frame, 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 // 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 // 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. // set |retval| to true (1) if the user accepted the confirmation.
enum cef_retval_t (CEF_CALLBACK *handle_jsconfirm)( enum cef_retval_t (CEF_CALLBACK *handle_jsconfirm)(
struct _cef_handler_t* self, struct _cef_browser_t* browser, 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 // 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 // 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. // |result| to the resulting value.
enum cef_retval_t (CEF_CALLBACK *handle_jsprompt)(struct _cef_handler_t* self, enum cef_retval_t (CEF_CALLBACK *handle_jsprompt)(struct _cef_handler_t* self,
struct _cef_browser_t* browser, struct _cef_frame_t* frame, struct _cef_browser_t* browser, struct _cef_frame_t* frame,
const wchar_t* message, const wchar_t* defaultValue, int* retval, const cef_string_t* message, const cef_string_t* defaultValue,
cef_string_t* result); int* retval, cef_string_t* result);
// Event called for adding values to a frame's JavaScript 'window' object. The // Event called for adding values to a frame's JavaScript 'window' object. The
// return value is currently ignored. // return value is currently ignored.
@ -576,7 +580,7 @@ typedef struct _cef_handler_t
// from being output to the console. // from being output to the console.
enum cef_retval_t (CEF_CALLBACK *handle_console_message)( enum cef_retval_t (CEF_CALLBACK *handle_console_message)(
struct _cef_handler_t* self, struct _cef_browser_t* browser, 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(). // Called to report find results returned by cef_browser_t::find().
// |identifer| is the identifier passed to cef_browser_t::find(), |count| is // |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; cef_base_t base;
// Fully qualified URL to load. // Fully qualified URL to load.
// The resulting string must be freed by calling cef_string_free(). // The resulting string must be freed by calling cef_string_userfree_free().
cef_string_t (CEF_CALLBACK *get_url)(struct _cef_request_t* self); cef_string_userfree_t (CEF_CALLBACK *get_url)(struct _cef_request_t* self);
void (CEF_CALLBACK *set_url)(struct _cef_request_t* self, const wchar_t* url); 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 // Optional request function type, defaulting to POST if post data is provided
// and GET otherwise. // and GET otherwise.
// The resulting string must be freed by calling cef_string_free(). // The resulting string must be freed by calling cef_string_userfree_free().
cef_string_t (CEF_CALLBACK *get_method)(struct _cef_request_t* self); cef_string_userfree_t (CEF_CALLBACK *get_method)(struct _cef_request_t* self);
void (CEF_CALLBACK *set_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. // Optional post data.
struct _cef_post_data_t* (CEF_CALLBACK *get_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); cef_string_map_t headerMap);
// Set all values at one time. // Set all values at one time.
void (CEF_CALLBACK *set)(struct _cef_request_t* self, const wchar_t* url, void (CEF_CALLBACK *set)(struct _cef_request_t* self, const cef_string_t* url,
const wchar_t* method, struct _cef_post_data_t* postData, const cef_string_t* method, struct _cef_post_data_t* postData,
cef_string_map_t headerMap); cef_string_map_t headerMap);
} cef_request_t; } cef_request_t;
@ -678,7 +683,7 @@ typedef struct _cef_post_data_element_t
// The post data element will represent a file. // The post data element will represent a file.
void (CEF_CALLBACK *set_to_file)(struct _cef_post_data_element_t* self, 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 // The post data element will represent bytes. The bytes passed in will be
// copied. // copied.
@ -690,8 +695,9 @@ typedef struct _cef_post_data_element_t
struct _cef_post_data_element_t* self); struct _cef_post_data_element_t* self);
// Return the file name. // Return the file name.
// The resulting string must be freed by calling cef_string_free(). // The resulting string must be freed by calling cef_string_userfree_free().
cef_string_t (CEF_CALLBACK *get_file)(struct _cef_post_data_element_t* self); cef_string_userfree_t (CEF_CALLBACK *get_file)(
struct _cef_post_data_element_t* self);
// Return the number of bytes. // Return the number of bytes.
size_t (CEF_CALLBACK *get_bytes_count)(struct _cef_post_data_element_t* self); size_t (CEF_CALLBACK *get_bytes_count)(struct _cef_post_data_element_t* self);
@ -758,7 +764,7 @@ typedef struct _cef_stream_reader_t
// Create a new cef_stream_reader_t object. // Create a new cef_stream_reader_t object.
CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_file( 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, CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_data(void* data,
size_t size); size_t size);
CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_handler( 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. // Create a new cef_stream_writer_t object.
CEF_EXPORT cef_stream_writer_t* cef_stream_writer_create_for_file( 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_EXPORT cef_stream_writer_t* cef_stream_writer_create_for_handler(
cef_write_handler_t* 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) // Execute with the specified argument list and return value. Return true (1)
// if the function was handled. // if the function was handled.
int (CEF_CALLBACK *execute)(struct _cef_v8handler_t* self, int (CEF_CALLBACK *execute)(struct _cef_v8handler_t* self,
const wchar_t* name, struct _cef_v8value_t* object, size_t argumentCount, const cef_string_t* name, struct _cef_v8value_t* object,
struct _cef_v8value_t* const* arguments, struct _cef_v8value_t** retval, size_t argumentCount, struct _cef_v8value_t* const* arguments,
cef_string_t* exception); struct _cef_v8value_t** retval, cef_string_t* exception);
} cef_v8handler_t; } 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_bool_value)(struct _cef_v8value_t* self);
int (CEF_CALLBACK *get_int_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); double (CEF_CALLBACK *get_double_value)(struct _cef_v8value_t* self);
// The resulting string must be freed by calling cef_string_free(). // The resulting string must be freed by calling cef_string_userfree_free().
cef_string_t (CEF_CALLBACK *get_string_value)(struct _cef_v8value_t* self); 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 // 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. // Returns true (1) if the object has a value with the specified identifier.
int (CEF_CALLBACK *has_value_bykey)(struct _cef_v8value_t* self, 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); int (CEF_CALLBACK *has_value_byindex)(struct _cef_v8value_t* self, int index);
// Delete the value with the specified identifier. // Delete the value with the specified identifier.
int (CEF_CALLBACK *delete_value_bykey)(struct _cef_v8value_t* self, 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 (CEF_CALLBACK *delete_value_byindex)(struct _cef_v8value_t* self,
int index); int index);
// Returns the value with the specified identifier. // Returns the value with the specified identifier.
struct _cef_v8value_t* (CEF_CALLBACK *get_value_bykey)( 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* (CEF_CALLBACK *get_value_byindex)(
struct _cef_v8value_t* self, int index); struct _cef_v8value_t* self, int index);
// Associate value with the specified identifier. // Associate value with the specified identifier.
int (CEF_CALLBACK *set_value_bykey)(struct _cef_v8value_t* self, 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, int (CEF_CALLBACK *set_value_byindex)(struct _cef_v8value_t* self, int index,
struct _cef_v8value_t* value); struct _cef_v8value_t* value);
@ -909,8 +916,9 @@ typedef struct _cef_v8value_t
// FUNCTION METHODS - These functions are only available on functions. // FUNCTION METHODS - These functions are only available on functions.
// Returns the function name. // Returns the function name.
// The resulting string must be freed by calling cef_string_free(). // The resulting string must be freed by calling cef_string_userfree_free().
cef_string_t (CEF_CALLBACK *get_function_name)(struct _cef_v8value_t* self); 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. // Returns the function handler or NULL if not a CEF-created function.
struct _cef_v8handler_t* (CEF_CALLBACK *get_function_handler)( struct _cef_v8handler_t* (CEF_CALLBACK *get_function_handler)(
@ -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_bool(int value);
CEF_EXPORT cef_v8value_t* cef_v8value_create_int(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_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_object(cef_base_t* user_data);
CEF_EXPORT cef_v8value_t* cef_v8value_create_array(); 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); 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); int (CEF_CALLBACK *has_error)(struct _cef_xml_reader_t* self);
// Returns the error string. // Returns the error string.
// The resulting string must be freed by calling cef_string_free(). // The resulting string must be freed by calling cef_string_userfree_free().
cef_string_t (CEF_CALLBACK *get_error)(struct _cef_xml_reader_t* self); 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 // 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- // Returns the local name. See http://www.w3.org/TR/REC-xml-names/#NT-
// LocalPart for additional details. // LocalPart for additional details.
// The resulting string must be freed by calling cef_string_free(). // The resulting string must be freed by calling cef_string_userfree_free().
cef_string_t (CEF_CALLBACK *get_local_name)(struct _cef_xml_reader_t* self); 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 // Returns the namespace prefix. See http://www.w3.org/TR/REC-xml-names/ for
// additional details. // additional details.
// The resulting string must be freed by calling cef_string_free(). // The resulting string must be freed by calling cef_string_userfree_free().
cef_string_t (CEF_CALLBACK *get_prefix)(struct _cef_xml_reader_t* self); cef_string_userfree_t (CEF_CALLBACK *get_prefix)(
struct _cef_xml_reader_t* self);
// Returns the qualified name, equal to (Prefix:)LocalName. See // Returns the qualified name, equal to (Prefix:)LocalName. See
// http://www.w3.org/TR/REC-xml-names/#ns-qualnames for additional details. // http://www.w3.org/TR/REC-xml-names/#ns-qualnames for additional details.
// The resulting string must be freed by calling cef_string_free(). // The resulting string must be freed by calling cef_string_userfree_free().
cef_string_t (CEF_CALLBACK *get_qualified_name)( cef_string_userfree_t (CEF_CALLBACK *get_qualified_name)(
struct _cef_xml_reader_t* self); struct _cef_xml_reader_t* self);
// Returns the URI defining the namespace associated with the node. See // Returns the URI defining the namespace associated with the node. See
// http://www.w3.org/TR/REC-xml-names/ for additional details. // http://www.w3.org/TR/REC-xml-names/ for additional details.
// The resulting string must be freed by calling cef_string_free(). // The resulting string must be freed by calling cef_string_userfree_free().
cef_string_t (CEF_CALLBACK *get_namespace_uri)( cef_string_userfree_t (CEF_CALLBACK *get_namespace_uri)(
struct _cef_xml_reader_t* self); struct _cef_xml_reader_t* self);
// Returns the base URI of the node. See http://www.w3.org/TR/xmlbase/ for // Returns the base URI of the node. See http://www.w3.org/TR/xmlbase/ for
// additional details. // additional details.
// The resulting string must be freed by calling cef_string_free(). // The resulting string must be freed by calling cef_string_userfree_free().
cef_string_t (CEF_CALLBACK *get_base_uri)(struct _cef_xml_reader_t* self); 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 // Returns the xml:lang scope within which the node resides. See
// http://www.w3.org/TR/REC-xml/#sec-lang-tag for additional details. // http://www.w3.org/TR/REC-xml/#sec-lang-tag for additional details.
// The resulting string must be freed by calling cef_string_free(). // The resulting string must be freed by calling cef_string_userfree_free().
cef_string_t (CEF_CALLBACK *get_xml_lang)(struct _cef_xml_reader_t* self); 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 // Returns true (1) if the node represents an NULL element. <a/> is considered
// NULL but <a></a> is not. // 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); int (CEF_CALLBACK *has_value)(struct _cef_xml_reader_t* self);
// Returns the text value. // Returns the text value.
// The resulting string must be freed by calling cef_string_free(). // The resulting string must be freed by calling cef_string_userfree_free().
cef_string_t (CEF_CALLBACK *get_value)(struct _cef_xml_reader_t* self); cef_string_userfree_t (CEF_CALLBACK *get_value)(
struct _cef_xml_reader_t* self);
// Returns true (1) if the node has attributes. // Returns true (1) if the node has attributes.
int (CEF_CALLBACK *has_attributes)(struct _cef_xml_reader_t* self); int (CEF_CALLBACK *has_attributes)(struct _cef_xml_reader_t* self);
@ -1086,29 +1100,31 @@ typedef struct _cef_xml_reader_t
size_t (CEF_CALLBACK *get_attribute_count)(struct _cef_xml_reader_t* self); size_t (CEF_CALLBACK *get_attribute_count)(struct _cef_xml_reader_t* self);
// Returns the value of the attribute at the specified 0-based index. // Returns the value of the attribute at the specified 0-based index.
// The resulting string must be freed by calling cef_string_free(). // The resulting string must be freed by calling cef_string_userfree_free().
cef_string_t (CEF_CALLBACK *get_attribute_byindex)( cef_string_userfree_t (CEF_CALLBACK *get_attribute_byindex)(
struct _cef_xml_reader_t* self, int index); struct _cef_xml_reader_t* self, int index);
// Returns the value of the attribute with the specified qualified name. // Returns the value of the attribute with the specified qualified name.
// The resulting string must be freed by calling cef_string_free(). // The resulting string must be freed by calling cef_string_userfree_free().
cef_string_t (CEF_CALLBACK *get_attribute_byqname)( cef_string_userfree_t (CEF_CALLBACK *get_attribute_byqname)(
struct _cef_xml_reader_t* self, const wchar_t* qualifiedName); struct _cef_xml_reader_t* self, const cef_string_t* qualifiedName);
// Returns the value of the attribute with the specified local name and // Returns the value of the attribute with the specified local name and
// namespace URI. // namespace URI.
// The resulting string must be freed by calling cef_string_free(). // The resulting string must be freed by calling cef_string_userfree_free().
cef_string_t (CEF_CALLBACK *get_attribute_bylname)( cef_string_userfree_t (CEF_CALLBACK *get_attribute_bylname)(
struct _cef_xml_reader_t* self, const wchar_t* localName, struct _cef_xml_reader_t* self, const cef_string_t* localName,
const wchar_t* namespaceURI); const cef_string_t* namespaceURI);
// Returns an XML representation of the current node's children. // Returns an XML representation of the current node's children.
// The resulting string must be freed by calling cef_string_free(). // The resulting string must be freed by calling cef_string_userfree_free().
cef_string_t (CEF_CALLBACK *get_inner_xml)(struct _cef_xml_reader_t* self); 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. // Returns an XML representation of the current node including its children.
// The resulting string must be freed by calling cef_string_free(). // The resulting string must be freed by calling cef_string_userfree_free().
cef_string_t (CEF_CALLBACK *get_outer_xml)(struct _cef_xml_reader_t* self); cef_string_userfree_t (CEF_CALLBACK *get_outer_xml)(
struct _cef_xml_reader_t* self);
// Returns the line number for the current node. // Returns the line number for the current node.
int (CEF_CALLBACK *get_line_number)(struct _cef_xml_reader_t* self); int (CEF_CALLBACK *get_line_number)(struct _cef_xml_reader_t* self);
@ -1127,13 +1143,13 @@ typedef struct _cef_xml_reader_t
// Moves the cursor to the attribute with the specified qualified name. // Moves the cursor to the attribute with the specified qualified name.
// Returns true (1) if the cursor position was set successfully. // Returns true (1) if the cursor position was set successfully.
int (CEF_CALLBACK *move_to_attribute_byqname)(struct _cef_xml_reader_t* self, int (CEF_CALLBACK *move_to_attribute_byqname)(struct _cef_xml_reader_t* self,
const wchar_t* qualifiedName); const cef_string_t* qualifiedName);
// Moves the cursor to the attribute with the specified local name and // Moves the cursor to the attribute with the specified local name and
// namespace URI. Returns true (1) if the cursor position was set // namespace URI. Returns true (1) if the cursor position was set
// successfully. // successfully.
int (CEF_CALLBACK *move_to_attribute_bylname)(struct _cef_xml_reader_t* self, 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 // Moves the cursor to the first attribute in the current element. Returns
// true (1) if the cursor position was set successfully. // 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 // Create a new cef_xml_reader_t object. The returned object's functions can
// only be called from the thread that created the object. // 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, 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. // 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 // is true (1) then the search will be case sensitive. Returns true (1) if the
// cursor position was set successfully. // cursor position was set successfully.
int (CEF_CALLBACK *move_to_file)(struct _cef_zip_reader_t* self, 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 // Closes the archive. This should be called directly to ensure that cleanup
// occurs on the correct thread. // 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. // The below functions act on the file at the current cursor position.
// Returns the name of the file. // Returns the name of the file.
// The resulting string must be freed by calling cef_string_free(). // The resulting string must be freed by calling cef_string_userfree_free().
cef_string_t (CEF_CALLBACK *get_file_name)(struct _cef_zip_reader_t* self); cef_string_userfree_t (CEF_CALLBACK *get_file_name)(
struct _cef_zip_reader_t* self);
// Returns the uncompressed size of the file. // Returns the uncompressed size of the file.
long (CEF_CALLBACK *get_file_size)(struct _cef_zip_reader_t* self); 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 // Opens the file for reading of uncompressed data. A read password may
// optionally be specified. // optionally be specified.
int (CEF_CALLBACK *open_file)(struct _cef_zip_reader_t* self, int (CEF_CALLBACK *open_file)(struct _cef_zip_reader_t* self,
const wchar_t* password); const cef_string_t* password);
// Closes the file. // Closes the file.
int (CEF_CALLBACK *close_file)(struct _cef_zip_reader_t* self); int (CEF_CALLBACK *close_file)(struct _cef_zip_reader_t* self);

View File

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

View File

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

View File

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

View File

@ -50,28 +50,28 @@ extern "C" {
// a plugin. // a plugin.
typedef struct _cef_plugin_info_t { typedef struct _cef_plugin_info_t {
// The unique name that identifies the plugin. // The unique name that identifies the plugin.
const wchar_t* unique_name; cef_string_t unique_name;
// The friendly display name of the plugin. // The friendly display name of the plugin.
const wchar_t* display_name; cef_string_t display_name;
// The version string of the plugin. // The version string of the plugin.
const wchar_t* version; cef_string_t version;
// A description of the plugin. // 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. // 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 // A pipe (|) delimited list of extension values. Each value is associated
// with the mime type value at the same position. Multiple file extensions // with the mime type value at the same position. Multiple file extensions
// for the same mime type may be delimited with commas (,). // 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 // A pipe (|) delimited list of description values. Each value is associated
// with the mime type value at the same position. // with the mime type value at the same position.
const wchar_t* type_descriptions; cef_string_t type_descriptions;
// Entry point function pointers. // Entry point function pointers.
NP_GetEntryPointsFunc np_getentrypoints; 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 // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are // modification, are permitted provided that the following conditions are
@ -30,57 +30,83 @@
#ifndef _CEF_STRING_H #ifndef _CEF_STRING_H
#define _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 #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
#endif // __cplusplus
#include "cef_export.h" #if defined(CEF_STRING_TYPE_UTF8)
#include <wchar.h> typedef char cef_char_t;
typedef cef_string_utf8_t cef_string_t;
// CEF strings are NUL-terminated wide character strings prefixed with a size typedef cef_string_userfree_utf8_t cef_string_userfree_t;
// value, similar to the Microsoft BSTR type. Use the below API functions for #define cef_string_set cef_string_utf8_set
// allocating, managing and freeing CEF strings. #define cef_string_copy cef_string_utf8_copy
typedef wchar_t* cef_string_t; #define cef_string_clear cef_string_utf8_clear
#define cef_string_userfree_alloc cef_string_userfree_utf8_alloc
// Return the wide character length of the CEF string as allocated by #define cef_string_userfree_free cef_string_userfree_utf8_free
// cef_string_alloc_len(). The returned value does not include the NUL #define cef_string_from_ascii cef_string_utf8_copy
// terminating character. This length may differ from the string length #define cef_string_to_utf8 cef_string_utf8_copy
// as returned by wcslen(). #define cef_string_from_utf8 cef_string_utf8_copy
CEF_EXPORT size_t cef_string_length(cef_string_t str); #define cef_string_to_utf16 cef_string_utf8_to_utf16
#define cef_string_from_utf16 cef_string_utf16_to_utf8
// Allocate and return a new CEF string that is a copy of |str|. If |str| is #define cef_string_to_wide cef_string_utf8_to_wide
// NULL or if allocation fails NULL will be returned. If |str| is of length #define cef_string_from_wide cef_string_wide_to_utf8
// 0 a valid empty CEF string will be returned. #elif defined(CEF_STRING_TYPE_UTF16)
CEF_EXPORT cef_string_t cef_string_alloc(const wchar_t* str); typedef char16_t cef_char_t;
typedef cef_string_userfree_utf16_t cef_string_userfree_t;
// Allocate and return a new CEF string that is a copy of |str|. |len| is the typedef cef_string_utf16_t cef_string_t;
// wide character length of the new CEF string not including the NUL #define cef_string_set cef_string_utf16_set
// terminating character. |str| will be copied without checking for a NUL #define cef_string_copy cef_string_utf16_copy
// terminating character. If |str| is NULL or if allocation fails NULL will #define cef_string_clear cef_string_utf16_clear
// be returned. If |str| is of length 0 a valid empty CEF string will be #define cef_string_userfree_alloc cef_string_userfree_utf16_alloc
// returned. #define cef_string_userfree_free cef_string_userfree_utf16_free
CEF_EXPORT cef_string_t cef_string_alloc_length(const wchar_t* str, #define cef_string_from_ascii cef_string_ascii_to_utf16
size_t len); #define cef_string_to_utf8 cef_string_utf16_to_utf8
#define cef_string_from_utf8 cef_string_utf8_to_utf16
// Reallocate an existing CEF string. The contents of |oldstr| will be #define cef_string_to_utf16 cef_string_utf16_copy
// replaced with the contents of |newstr|; |newstr| may not be NULL. Returns 1 #define cef_string_from_utf16 cef_string_utf16_copy
// on success and 0 on failure. #define cef_string_to_wide cef_string_utf16_to_wide
CEF_EXPORT int cef_string_realloc(cef_string_t* oldstr, const wchar_t* newstr); #define cef_string_from_wide cef_string_wide_to_utf16
#elif defined(CEF_STRING_TYPE_WIDE)
// Reallocate an existing CEF string. If |newstr| is NULL the contents of typedef wchar_t cef_char_t;
// |oldstr| will remain unchanged; otherwise, they will be replaced with the typedef cef_string_wide_t cef_string_t;
// contents of |newstr|. |len| is the new wide character length of the string typedef cef_string_userfree_wide_t cef_string_userfree_t;
// not including the NUL terminating character. Returns 1 on success and 0 #define cef_string_set cef_string_wide_set
// on failure. #define cef_string_copy cef_string_wide_copy
CEF_EXPORT int cef_string_realloc_length(cef_string_t* oldstr, #define cef_string_clear cef_string_wide_clear
const wchar_t* newstr, #define cef_string_userfree_alloc cef_string_userfree_wide_alloc
size_t len); #define cef_string_userfree_free cef_string_userfree_wide_free
#define cef_string_from_ascii cef_string_ascii_to_wide
// Free a CEF string. If |str| is NULL this function does nothing. #define cef_string_to_utf8 cef_string_wide_to_utf8
CEF_EXPORT void cef_string_free(cef_string_t str); #define cef_string_from_utf8 cef_string_utf8_to_wide
#define cef_string_to_utf16 cef_string_wide_to_utf16
#ifdef __cplusplus #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
#endif // _CEF_STRING_H #endif // _CEF_STRING_H

View File

@ -30,14 +30,13 @@
#ifndef _CEF_STRING_LIST_H #ifndef _CEF_STRING_LIST_H
#define _CEF_STRING_LIST_H #define _CEF_STRING_LIST_H
#include "cef_export.h"
#include "cef_string.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include "cef_export.h"
#include "cef_string.h"
#include <wchar.h>
// CEF string maps are a set of key/value string pairs. // CEF string maps are a set of key/value string pairs.
typedef void* cef_string_list_t; 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. // Return the number of elements in the string list.
CEF_EXPORT int cef_string_list_size(cef_string_list_t list); CEF_EXPORT int cef_string_list_size(cef_string_list_t list);
// Return the value at the specified zero-based string list index. // Retrieve the value at the specified zero-based string list index. Returns
CEF_EXPORT cef_string_t cef_string_list_value(cef_string_list_t list, int index); // 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. // Append a new value at the end of the string list.
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);
// Clear the string list. // Clear the string list.
CEF_EXPORT void cef_string_list_clear(cef_string_list_t list); CEF_EXPORT void cef_string_list_clear(cef_string_list_t list);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,28 +3,27 @@
// be found in the LICENSE file. // be found in the LICENSE file.
#include "../include/cef.h" #include "../include/cef.h"
#include "base/utf_string_conversions.h"
#include "webkit/glue/webpreferences.h" #include "webkit/glue/webpreferences.h"
void BrowserToWebSettings(const CefBrowserSettings& cef, WebPreferences& web) void BrowserToWebSettings(const CefBrowserSettings& cef, WebPreferences& web)
{ {
if (cef.standard_font_family) if (cef.standard_font_family.length > 0)
web.standard_font_family = cef.standard_font_family; web.standard_font_family = CefString(&cef.standard_font_family);
else else
web.standard_font_family = L"Times"; web.standard_font_family = L"Times";
if (cef.fixed_font_family) if (cef.fixed_font_family.length > 0)
web.fixed_font_family = cef.fixed_font_family; web.fixed_font_family = CefString(&cef.fixed_font_family);
else else
web.fixed_font_family = L"Courier"; web.fixed_font_family = L"Courier";
if (cef.serif_font_family) if (cef.serif_font_family.length > 0)
web.serif_font_family = cef.serif_font_family; web.serif_font_family = CefString(&cef.serif_font_family);
else else
web.serif_font_family = L"Times"; web.serif_font_family = L"Times";
if (cef.sans_serif_font_family) if (cef.sans_serif_font_family.length > 0)
web.sans_serif_font_family = cef.sans_serif_font_family; web.sans_serif_font_family = CefString(&cef.sans_serif_font_family);
else else
web.sans_serif_font_family = L"Helvetica"; 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 // and fantasy fonts, but it should not matter for layout tests
// as long as they're available. // as long as they're available.
if (cef.cursive_font_family) { if (cef.cursive_font_family.length > 0) {
web.cursive_font_family = cef.cursive_font_family; web.cursive_font_family = CefString(&cef.cursive_font_family);
} else { } else {
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
web.cursive_font_family = L"Apple Chancery"; web.cursive_font_family = L"Apple Chancery";
@ -49,8 +48,8 @@ void BrowserToWebSettings(const CefBrowserSettings& cef, WebPreferences& web)
#endif #endif
} }
if (cef.fantasy_font_family) { if (cef.fantasy_font_family.length > 0) {
web.fantasy_font_family = cef.fantasy_font_family; web.fantasy_font_family = CefString(&cef.fantasy_font_family);
} else { } else {
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
web.fantasy_font_family = L"Papyrus"; web.fantasy_font_family = L"Papyrus";
@ -79,8 +78,8 @@ void BrowserToWebSettings(const CefBrowserSettings& cef, WebPreferences& web)
else else
web.minimum_logical_font_size = 9; web.minimum_logical_font_size = 9;
if (cef.default_encoding) if (cef.default_encoding.length > 0)
web.default_encoding = WideToUTF8(cef.default_encoding); web.default_encoding = CefString(&cef.default_encoding);
else else
web.default_encoding = "ISO-8859-1"; 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; 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 = 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; 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.accelerated_2d_canvas_enabled = !cef.accelerated_2d_canvas_disabled;
web.memory_info_enabled = false; 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; struct WebPreferences;
void BrowserToWebSettings(const CefBrowserSettings& cef, WebPreferences& web); void BrowserToWebSettings(const CefBrowserSettings& cef, WebPreferences& web);
void WebToBrowserSettings(const WebPreferences& web, CefBrowserSettings& cef);
#endif // _CEF_BROWSER_SETTINGS_H #endif // _CEF_BROWSER_SETTINGS_H

View File

@ -22,7 +22,6 @@ MSVC_POP_WARNING();
#include "base/path_service.h" #include "base/path_service.h"
#include "base/scoped_ptr.h" #include "base/scoped_ptr.h"
#include "base/string16.h" #include "base/string16.h"
#include "base/utf_string_conversions.h"
#include "net/base/mime_util.h" #include "net/base/mime_util.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/WebKit/chromium/public/WebString.h" #include "third_party/WebKit/WebKit/chromium/public/WebString.h"
@ -73,8 +72,8 @@ bool IsProtocolSupportedForMedia(const GURL& url) {
std::string GetWebKitLocale() { std::string GetWebKitLocale() {
const CefSettings& settings = _Context->settings(); const CefSettings& settings = _Context->settings();
if (settings.locale) if (settings.locale.length > 0)
return WideToUTF8(settings.locale); return CefString(&settings.locale);
return "en-US"; return "en-US";
} }
@ -104,29 +103,11 @@ void ClearCache()
WebCore::cache()->setDisabled(false); 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() { std::string GetProductVersion() {
const CefSettings& settings = _Context->settings(); const CefSettings& settings = _Context->settings();
if (settings.product_version) if (settings.product_version.length > 0) {
return WideToUTF8(settings.product_version); return CefString(&settings.product_version);
}
return "Chrome/7.0.517.0"; return "Chrome/7.0.517.0";
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -125,20 +125,17 @@ void CefProcessUIThread::Init() {
const CefSettings& settings = _Context->settings(); const CefSettings& settings = _Context->settings();
if (settings.user_agent) if (settings.user_agent.length > 0)
webkit_glue::SetUserAgent(WideToUTF8(settings.user_agent)); webkit_glue::SetUserAgent(CefString(&settings.user_agent));
if (settings.extra_plugin_paths) { if (settings.extra_plugin_paths) {
cef_string_t str; cef_string_t str;
FilePath path; FilePath path;
int size = cef_string_list_size(settings.extra_plugin_paths); int size = cef_string_list_size(settings.extra_plugin_paths);
for(int i = 0; i < size; ++i) { for(int i = 0; i < size; ++i) {
str = cef_string_list_value(settings.extra_plugin_paths, i); if (!cef_string_list_value(settings.extra_plugin_paths, i, &str))
#if defined(OS_WIN) continue;
path = FilePath(str); path = FilePath(CefString(&str));
#else
path = FilePath(WideToUTF8(str));
#endif
NPAPI::PluginList::Singleton()->AddExtraPluginPath(path); 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> #include <vector>
typedef std::vector<std::wstring> StringList; typedef std::vector<CefString> StringList;
CEF_EXPORT cef_string_list_t cef_string_list_alloc() 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(); 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(list);
DCHECK(value);
StringList* impl = (StringList*)list; StringList* impl = (StringList*)list;
DCHECK(index >= 0 && index < (int)impl->size()); DCHECK(index >= 0 && index < (int)impl->size());
if(index < 0 || index >= (int)impl->size()) if(index < 0 || index >= (int)impl->size())
return NULL; return false;
return cef_string_alloc((*impl)[index].c_str()); 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(list);
DCHECK(value);
StringList* impl = (StringList*)list; StringList* impl = (StringList*)list;
std::wstring valstr; impl->push_back(CefString(value));
if(value)
valstr = value;
impl->push_back(valstr);
} }
CEF_EXPORT void cef_string_list_clear(cef_string_list_t list) CEF_EXPORT void cef_string_list_clear(cef_string_list_t list)

View File

@ -7,7 +7,7 @@
#include <map> #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() 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(); return impl->size();
} }
CEF_EXPORT cef_string_t cef_string_map_find(cef_string_map_t map, CEF_EXPORT int cef_string_map_find(cef_string_map_t map,
const wchar_t* key) const cef_string_t* key,
cef_string_t* value)
{ {
DCHECK(map); DCHECK(map);
DCHECK(value);
StringMap* impl = (StringMap*)map; StringMap* impl = (StringMap*)map;
std::wstring keystr; StringMap::const_iterator it = impl->find(CefString(key));
if(key)
keystr = key;
StringMap::const_iterator it = impl->find(keystr);
if(it == impl->end()) if(it == impl->end())
return NULL; 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(map);
DCHECK(key);
StringMap* impl = (StringMap*)map; StringMap* impl = (StringMap*)map;
DCHECK(index >= 0 && index < (int)impl->size()); DCHECK(index >= 0 && index < (int)impl->size());
if(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(); StringMap::const_iterator it = impl->begin();
for(int ct = 0; it != impl->end(); ++it, ct++) { for(int ct = 0; it != impl->end(); ++it, ct++) {
if(ct == index) 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(map);
DCHECK(value);
StringMap* impl = (StringMap*)map; StringMap* impl = (StringMap*)map;
DCHECK(index >= 0 && index < (int)impl->size()); DCHECK(index >= 0 && index < (int)impl->size());
if(index < 0 || index >= (int)impl->size()) if(index < 0 || index >= (int)impl->size())
return NULL; return NULL;
StringMap::const_iterator it = impl->begin(); StringMap::const_iterator it = impl->begin();
for(int ct = 0; it != impl->end(); ++it, ct++) { for(int ct = 0; it != impl->end(); ++it, ct++) {
if(ct == index) if(ct == index) {
return cef_string_alloc(it->second.c_str()); 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, CEF_EXPORT int cef_string_map_append(cef_string_map_t map,
const wchar_t* value) const cef_string_t* key,
const cef_string_t* value)
{ {
DCHECK(map); DCHECK(map);
StringMap* impl = (StringMap*)map; StringMap* impl = (StringMap*)map;
std::wstring keystr, valstr; impl->insert(std::make_pair(CefString(key), CefString(value)));
if(key) return 1;
keystr = key;
if(value)
valstr = value;
impl->insert(std::pair<std::wstring, std::wstring>(keystr, valstr));
} }
CEF_EXPORT void cef_string_map_clear(cef_string_map_t map) 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, void PrintSettings::Init(HDC hdc,
const DEVMODE& dev_mode, const DEVMODE& dev_mode,
const PageRanges& new_ranges, const PageRanges& new_ranges,
const std::wstring& new_device_name, const CefString& new_device_name,
bool print_selection_only, bool print_selection_only,
bool print_to_file) { bool print_to_file) {
DCHECK(hdc); DCHECK(hdc);
printer_name_ = dev_mode.dmDeviceName; printer_name_ = std::wstring(dev_mode.dmDeviceName);
device_name_ = new_device_name; device_name_ = new_device_name;
ranges = new_ranges; ranges = new_ranges;
landscape = dev_mode.dmOrientation == DMORIENT_LANDSCAPE; landscape = dev_mode.dmOrientation == DMORIENT_LANDSCAPE;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -13,43 +13,40 @@
#include "libcef_dll/cpptoc/browser_cpptoc.h" #include "libcef_dll/cpptoc/browser_cpptoc.h"
#include "libcef_dll/cpptoc/frame_cpptoc.h" #include "libcef_dll/cpptoc/frame_cpptoc.h"
#include "libcef_dll/ctocpp/handler_ctocpp.h" #include "libcef_dll/ctocpp/handler_ctocpp.h"
#include "libcef_dll/transfer_util.h"
// GLOBAL FUNCTIONS - Body may be edited by hand. // GLOBAL FUNCTIONS - Body may be edited by hand.
CEF_EXPORT int cef_browser_create(cef_window_info_t* windowInfo, int popup, 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); DCHECK(windowInfo);
CefRefPtr<CefHandler> handlerPtr; CefRefPtr<CefHandler> handlerPtr;
std::wstring urlStr;
CefWindowInfo wi = *windowInfo; CefWindowInfo wi = *windowInfo;
if(handler) if(handler)
handlerPtr = CefHandlerCToCpp::Wrap(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, 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); DCHECK(windowInfo);
CefRefPtr<CefHandler> handlerPtr; CefRefPtr<CefHandler> handlerPtr;
std::wstring urlStr;
CefWindowInfo wi = *windowInfo; CefWindowInfo wi = *windowInfo;
if(handler) if(handler)
handlerPtr = CefHandlerCToCpp::Wrap(handler); handlerPtr = CefHandlerCToCpp::Wrap(handler);
if(url)
urlStr = url;
CefRefPtr<CefBrowser> browserPtr( CefRefPtr<CefBrowser> browserPtr(
CefBrowser::CreateBrowserSync(wi, popup?true:false, handlerPtr, urlStr)); CefBrowser::CreateBrowserSync(wi, popup?true:false, handlerPtr,
CefString(url)));
if(browserPtr.get()) if(browserPtr.get())
return CefBrowserCppToC::Wrap(browserPtr); return CefBrowserCppToC::Wrap(browserPtr);
return NULL; 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, 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); DCHECK(self);
if(!self) if(!self)
return NULL; return NULL;
std::wstring nameStr;
if(name)
nameStr = name;
if(nameStr.empty())
return NULL;
CefRefPtr<CefBrowser> browserPtr = CefBrowserCppToC::Get(self); CefRefPtr<CefBrowser> browserPtr = CefBrowserCppToC::Get(self);
CefRefPtr<CefFrame> framePtr = browserPtr->GetFrame(nameStr); CefRefPtr<CefFrame> framePtr = browserPtr->GetFrame(CefString(name));
if(framePtr.get()) if(framePtr.get())
return CefFrameCppToC::Wrap(framePtr); return CefFrameCppToC::Wrap(framePtr);
return NULL; return NULL;
@ -221,25 +212,19 @@ void CEF_CALLBACK browser_get_frame_names(struct _cef_browser_t* self,
return; return;
CefRefPtr<CefBrowser> browserPtr = CefBrowserCppToC::Get(self); CefRefPtr<CefBrowser> browserPtr = CefBrowserCppToC::Get(self);
std::vector<std::wstring> stringList; std::vector<CefString> stringList;
browserPtr->GetFrameNames(stringList); browserPtr->GetFrameNames(stringList);
size_t size = stringList.size(); transfer_string_list_contents(stringList, names);
for(size_t i = 0; i < size; ++i)
cef_string_list_append(names, stringList[i].c_str());
} }
void CEF_CALLBACK browser_find(struct _cef_browser_t* self, int identifier, 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); DCHECK(self);
if(!self) if(!self)
return; return;
std::wstring searchTextStr; CefBrowserCppToC::Get(self)->Find(identifier, CefString(searchText),
if(searchText)
searchTextStr = searchText;
CefBrowserCppToC::Get(self)->Find(identifier, searchTextStr,
forward?true:false, matchCase?true:false, findNext?true:false); 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(); 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); DCHECK(self);
if(!self) if(!self)
return NULL; return NULL;
std::wstring sourceStr = CefFrameCppToC::Get(self)->GetSource(); CefString sourceStr = CefFrameCppToC::Get(self)->GetSource();
if(!sourceStr.empty()) return sourceStr.DetachToUserFree();
return cef_string_alloc(sourceStr.c_str());
return NULL;
} }
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); DCHECK(self);
if(!self) if(!self)
return NULL; return NULL;
std::wstring textStr = CefFrameCppToC::Get(self)->GetText(); CefString textStr = CefFrameCppToC::Get(self)->GetText();
if(!textStr.empty()) return textStr.DetachToUserFree();
return cef_string_alloc(textStr.c_str());
return NULL;
} }
void CEF_CALLBACK frame_load_request(struct _cef_frame_t* self, 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); 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); DCHECK(self);
if(!self) if(!self)
return; return;
std::wstring urlStr; CefFrameCppToC::Get(self)->LoadURL(CefString(url));
if(url)
urlStr = url;
CefFrameCppToC::Get(self)->LoadURL(urlStr);
} }
void CEF_CALLBACK frame_load_string(struct _cef_frame_t* self, 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); DCHECK(self);
if(!self) if(!self)
return; return;
std::wstring stringStr, urlStr; CefFrameCppToC::Get(self)->LoadString(CefString(string), CefString(url));
if(string)
stringStr = string;
if(url)
urlStr = url;
CefFrameCppToC::Get(self)->LoadString(stringStr, urlStr);
} }
void CEF_CALLBACK frame_load_stream(struct _cef_frame_t* self, 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(self);
DCHECK(stream); DCHECK(stream);
if(!self || !stream) if(!self || !stream)
return; return;
CefRefPtr<CefStreamReader> streamPtr = CefStreamReaderCppToC::Unwrap(stream); CefFrameCppToC::Get(self)->LoadStream(CefStreamReaderCppToC::Unwrap(stream),
std::wstring urlStr; CefString(url));
if(url)
urlStr = url;
CefFrameCppToC::Get(self)->LoadStream(streamPtr, urlStr);
} }
void CEF_CALLBACK frame_execute_java_script(struct _cef_frame_t* self, 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); DCHECK(self);
if(!self) if(!self)
return; return;
std::wstring jsCodeStr, scriptUrlStr; CefFrameCppToC::Get(self)->ExecuteJavaScript(CefString(jsCode),
if(jsCode) CefString(scriptUrl), startLine);
jsCodeStr = jsCode;
if(scriptUrl)
scriptUrlStr = scriptUrl;
CefFrameCppToC::Get(self)->ExecuteJavaScript(jsCodeStr, scriptUrlStr,
startLine);
} }
int CEF_CALLBACK frame_is_main(struct _cef_frame_t* self) 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(); 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); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
std::wstring nameStr = CefFrameCppToC::Get(self)->GetName(); CefString nameStr = CefFrameCppToC::Get(self)->GetName();
if(!nameStr.empty()) return nameStr.DetachToUserFree();
return cef_string_alloc(nameStr.c_str());
return NULL;
} }
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); DCHECK(self);
if(!self) if(!self)
return NULL; return NULL;
std::wstring urlStr = CefFrameCppToC::Get(self)->GetURL(); CefString urlStr = CefFrameCppToC::Get(self)->GetURL();
if(!urlStr.empty()) return urlStr.DetachToUserFree();
return cef_string_alloc(urlStr.c_str());
return NULL;
} }

View File

@ -17,7 +17,6 @@
#include "libcef_dll/ctocpp/request_ctocpp.h" #include "libcef_dll/ctocpp/request_ctocpp.h"
#include "libcef_dll/ctocpp/stream_reader_ctocpp.h" #include "libcef_dll/ctocpp/stream_reader_ctocpp.h"
#include "libcef_dll/ctocpp/v8value_ctocpp.h" #include "libcef_dll/ctocpp/v8value_ctocpp.h"
#include "libcef_dll/transfer_util.h"
// MEMBER FUNCTIONS - Body may be edited by hand. // MEMBER FUNCTIONS - Body may be edited by hand.
@ -54,15 +53,9 @@ enum cef_retval_t CEF_CALLBACK handler_handle_before_created(
if(parentBrowser) if(parentBrowser)
browserPtr = CefBrowserCToCpp::Wrap(parentBrowser); browserPtr = CefBrowserCToCpp::Wrap(parentBrowser);
std::wstring urlStr;
if(*url)
urlStr = *url;
enum cef_retval_t rv = CefHandlerCppToC::Get(self)->HandleBeforeCreated( enum cef_retval_t rv = CefHandlerCppToC::Get(self)->HandleBeforeCreated(
browserPtr, wndInfo, popup?true:false, features, handlerPtr, urlStr, browserPtr, wndInfo, popup?true:false, features, handlerPtr,
browserSettings); CefString(url), browserSettings);
transfer_string_contents(urlStr, url);
if(handlerPtr.get() != origHandler) { if(handlerPtr.get() != origHandler) {
// The handler has been changed. // 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( enum cef_retval_t CEF_CALLBACK handler_handle_address_change(
struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, 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(self);
DCHECK(browser); DCHECK(browser);
@ -105,28 +98,22 @@ enum cef_retval_t CEF_CALLBACK handler_handle_address_change(
if(!self || !browser || !frame) if(!self || !browser || !frame)
return RV_CONTINUE; return RV_CONTINUE;
std::wstring urlStr;
if(url)
urlStr = url;
return CefHandlerCppToC::Get(self)->HandleAddressChange( 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( 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(self);
DCHECK(browser); DCHECK(browser);
if(!self || !browser) if(!self || !browser)
return RV_CONTINUE; return RV_CONTINUE;
std::wstring titleStr;
if(title)
titleStr = title;
return CefHandlerCppToC::Get(self)->HandleTitleChange( return CefHandlerCppToC::Get(self)->HandleTitleChange(
CefBrowserCToCpp::Wrap(browser), titleStr); CefBrowserCToCpp::Wrap(browser), CefString(title));
} }
enum cef_retval_t CEF_CALLBACK handler_handle_before_browse( 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( enum cef_retval_t CEF_CALLBACK handler_handle_load_error(
struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, 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) cef_string_t* errorText)
{ {
DCHECK(self); DCHECK(self);
@ -190,20 +177,9 @@ enum cef_retval_t CEF_CALLBACK handler_handle_load_error(
if(!self || !browser || !errorText || !frame) if(!self || !browser || !errorText || !frame)
return RV_CONTINUE; return RV_CONTINUE;
std::wstring failedUrlStr, errorTextStr; return CefHandlerCppToC::Get(self)->HandleLoadError(
if(failedUrl)
failedUrlStr = failedUrl;
if(*errorText)
errorTextStr = *errorText;
enum cef_retval_t rv = CefHandlerCppToC::Get(self)->HandleLoadError(
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), errorCode, CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), errorCode,
failedUrlStr, errorTextStr); CefString(failedUrl), CefString(errorText));
transfer_string_contents(errorTextStr, errorText);
return rv;
} }
enum cef_retval_t CEF_CALLBACK handler_handle_before_resource_load( 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) if(!self || !browser || !redirectUrl || !resourceStream || !mimeType)
return RV_CONTINUE; return RV_CONTINUE;
std::wstring redirectUrlStr, mimeTypeStr;
CefRefPtr<CefStreamReader> streamPtr; CefRefPtr<CefStreamReader> streamPtr;
if(*redirectUrl)
redirectUrlStr = *redirectUrl;
if(*mimeType)
mimeTypeStr = *mimeType;
enum cef_retval_t rv = CefHandlerCppToC::Get(self)-> enum cef_retval_t rv = CefHandlerCppToC::Get(self)->
HandleBeforeResourceLoad(CefBrowserCToCpp::Wrap(browser), HandleBeforeResourceLoad(CefBrowserCToCpp::Wrap(browser),
CefRequestCToCpp::Wrap(request), redirectUrlStr, streamPtr, mimeTypeStr, CefRequestCToCpp::Wrap(request), CefString(redirectUrl), streamPtr,
loadFlags); CefString(mimeType), loadFlags);
transfer_string_contents(redirectUrlStr, redirectUrl);
transfer_string_contents(mimeTypeStr, mimeType);
if(streamPtr.get()) if(streamPtr.get())
*resourceStream = CefStreamReaderCToCpp::Unwrap(streamPtr); *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( enum cef_retval_t CEF_CALLBACK handler_handle_download_response(
struct _cef_handler_t* self, cef_browser_t* browser, struct _cef_handler_t* self, cef_browser_t* browser,
const wchar_t* mimeType, const wchar_t* fileName, int64 contentLength, const cef_string_t* mimeType, const cef_string_t* fileName,
struct _cef_download_handler_t** handler) int64 contentLength, struct _cef_download_handler_t** handler)
{ {
DCHECK(self); DCHECK(self);
DCHECK(browser); DCHECK(browser);
@ -254,17 +221,11 @@ enum cef_retval_t CEF_CALLBACK handler_handle_download_response(
if(!self || !browser || !mimeType || !fileName) if(!self || !browser || !mimeType || !fileName)
return RV_CONTINUE; return RV_CONTINUE;
std::wstring mimeTypeStr, fileNameStr;
CefRefPtr<CefDownloadHandler> downloadPtr; CefRefPtr<CefDownloadHandler> downloadPtr;
if(mimeType)
mimeTypeStr = mimeType;
if(fileName)
fileNameStr = fileName;
enum cef_retval_t rv = CefHandlerCppToC::Get(self)-> enum cef_retval_t rv = CefHandlerCppToC::Get(self)->
HandleDownloadResponse(CefBrowserCToCpp::Wrap(browser), mimeTypeStr, HandleDownloadResponse(CefBrowserCToCpp::Wrap(browser),
fileNameStr, contentLength, downloadPtr); CefString(mimeType), CefString(fileName), contentLength, downloadPtr);
if(downloadPtr.get()) if(downloadPtr.get())
*handler = CefDownloadHandlerCppToC::Wrap(downloadPtr); *handler = CefDownloadHandlerCppToC::Wrap(downloadPtr);
@ -296,16 +257,8 @@ enum cef_retval_t CEF_CALLBACK handler_handle_get_menu_label(
if(!self || !browser || !label) if(!self || !browser || !label)
return RV_CONTINUE; return RV_CONTINUE;
std::wstring labelStr; return CefHandlerCppToC::Get(self)->HandleGetMenuLabel(
if(*label) CefBrowserCToCpp::Wrap(browser), menuId, CefString(label));
labelStr = *label;
enum cef_retval_t rv = CefHandlerCppToC::Get(self)->HandleGetMenuLabel(
CefBrowserCToCpp::Wrap(browser), menuId, labelStr);
transfer_string_contents(labelStr, label);
return rv;
} }
enum cef_retval_t CEF_CALLBACK handler_handle_menu_action( 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( enum cef_retval_t CEF_CALLBACK handler_handle_print_header_footer(
struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, 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, cef_print_info_t* printInfo, const cef_string_t* url,
int currentPage, int maxPages, cef_string_t* topLeft, const cef_string_t* title, int currentPage, int maxPages,
cef_string_t* topCenter, cef_string_t* topRight, cef_string_t* bottomLeft, cef_string_t* topLeft, cef_string_t* topCenter, cef_string_t* topRight,
cef_string_t* bottomCenter, cef_string_t* bottomRight) cef_string_t* bottomLeft, cef_string_t* bottomCenter,
cef_string_t* bottomRight)
{ {
DCHECK(self); DCHECK(self);
DCHECK(browser); DCHECK(browser);
@ -351,47 +305,19 @@ enum cef_retval_t CEF_CALLBACK handler_handle_print_header_footer(
|| !topRight || !bottomLeft || !bottomCenter || !bottomRight) || !topRight || !bottomLeft || !bottomCenter || !bottomRight)
return RV_CONTINUE; return RV_CONTINUE;
std::wstring urlStr, titleStr;
std::wstring topLeftStr, topCenterStr, topRightStr;
std::wstring bottomLeftStr, bottomCenterStr, bottomRightStr;
CefPrintInfo info = *printInfo; CefPrintInfo info = *printInfo;
if(url) return CefHandlerCppToC::Get(self)->
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)->
HandlePrintHeaderFooter(CefBrowserCToCpp::Wrap(browser), HandlePrintHeaderFooter(CefBrowserCToCpp::Wrap(browser),
CefFrameCToCpp::Wrap(frame), info, urlStr, titleStr, currentPage, CefFrameCToCpp::Wrap(frame), info, CefString(url), CefString(title),
maxPages, topLeftStr, topCenterStr, topRightStr, bottomLeftStr, currentPage, maxPages, CefString(topLeft), CefString(topCenter),
bottomCenterStr, bottomRightStr); CefString(topRight), CefString(bottomLeft), CefString(bottomCenter),
CefString(bottomRight));
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;
} }
enum cef_retval_t CEF_CALLBACK handler_handle_jsalert( enum cef_retval_t CEF_CALLBACK handler_handle_jsalert(
struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, 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(self);
DCHECK(browser); DCHECK(browser);
@ -399,17 +325,14 @@ enum cef_retval_t CEF_CALLBACK handler_handle_jsalert(
if(!self || !browser || !frame) if(!self || !browser || !frame)
return RV_CONTINUE; return RV_CONTINUE;
std::wstring messageStr;
if(message)
messageStr = message;
return CefHandlerCppToC::Get(self)->HandleJSAlert( 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( enum cef_retval_t CEF_CALLBACK handler_handle_jsconfirm(
struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, 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(self);
DCHECK(browser); DCHECK(browser);
@ -418,14 +341,10 @@ enum cef_retval_t CEF_CALLBACK handler_handle_jsconfirm(
if(!self || !browser || !retval || !frame) if(!self || !browser || !retval || !frame)
return RV_CONTINUE; return RV_CONTINUE;
std::wstring messageStr;
if(message)
messageStr = message;
bool ret = false; bool ret = false;
enum cef_retval_t rv = CefHandlerCppToC::Get(self)->HandleJSConfirm( enum cef_retval_t rv = CefHandlerCppToC::Get(self)->HandleJSConfirm(
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), messageStr, CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame),
ret); CefString(message), ret);
*retval = (ret ? 1 : 0); *retval = (ret ? 1 : 0);
return rv; return rv;
@ -433,7 +352,7 @@ enum cef_retval_t CEF_CALLBACK handler_handle_jsconfirm(
enum cef_retval_t CEF_CALLBACK handler_handle_jsprompt( enum cef_retval_t CEF_CALLBACK handler_handle_jsprompt(
struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, 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) cef_string_t* result)
{ {
DCHECK(self); DCHECK(self);
@ -444,23 +363,12 @@ enum cef_retval_t CEF_CALLBACK handler_handle_jsprompt(
if(!self || !browser || !frame || !retval || !result) if(!self || !browser || !frame || !retval || !result)
return RV_CONTINUE; return RV_CONTINUE;
std::wstring messageStr, defaultValueStr, resultStr;
if(message)
messageStr = message;
if(defaultValue)
defaultValueStr = defaultValue;
if(*result)
resultStr = *result;
bool ret = false; bool ret = false;
enum cef_retval_t rv = CefHandlerCppToC::Get(self)->HandleJSPrompt( enum cef_retval_t rv = CefHandlerCppToC::Get(self)->HandleJSPrompt(
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), messageStr, CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame),
defaultValueStr, ret, resultStr); CefString(message), CefString(defaultValue), ret, CefString(result));
*retval = (ret ? 1 : 0); *retval = (ret ? 1 : 0);
transfer_string_contents(resultStr, result);
return rv; return rv;
} }
@ -540,35 +448,22 @@ enum cef_retval_t CEF_CALLBACK handler_handle_tooltip(
if(!self || !browser || !text) if(!self || !browser || !text)
return RV_CONTINUE; return RV_CONTINUE;
std::wstring textStr; return CefHandlerCppToC::Get(self)->HandleTooltip(
if(*text) CefBrowserCToCpp::Wrap(browser), CefString(text));
textStr = *text;
enum cef_retval_t rv = CefHandlerCppToC::Get(self)->HandleTooltip(
CefBrowserCToCpp::Wrap(browser), textStr);
transfer_string_contents(textStr, text);
return rv;
} }
enum cef_retval_t CEF_CALLBACK handler_handle_console_message( enum cef_retval_t CEF_CALLBACK handler_handle_console_message(
struct _cef_handler_t* self, cef_browser_t* browser, const wchar_t* message, struct _cef_handler_t* self, cef_browser_t* browser,
const wchar_t* source, int line) const cef_string_t* message, const cef_string_t* source, int line)
{ {
DCHECK(self); DCHECK(self);
DCHECK(browser); DCHECK(browser);
if(!self || !browser) if(!self || !browser)
return RV_CONTINUE; return RV_CONTINUE;
std::wstring messageStr, sourceStr;
if(message)
messageStr = message;
if(source)
sourceStr = source;
return CefHandlerCppToC::Get(self)->HandleConsoleMessage( 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( 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( 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); DCHECK(self);
if(!self) if(!self)
return; return;
std::wstring fileNameStr; CefPostDataElementCppToC::Get(self)->SetToFile(CefString(fileName));
if(fileName)
fileNameStr = fileName;
CefPostDataElementCppToC::Get(self)->SetToFile(fileNameStr);
} }
void CEF_CALLBACK post_data_element_set_to_bytes( 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(); 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) struct _cef_post_data_element_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return NULL; return NULL;
std::wstring fileNameStr = CefString fileNameStr = CefPostDataElementCppToC::Get(self)->GetFile();
CefPostDataElementCppToC::Get(self)->GetFile(); return fileNameStr.DetachToUserFree();
if(!fileNameStr.empty())
return cef_string_alloc(fileNameStr.c_str());
return NULL;
} }
size_t CEF_CALLBACK post_data_element_get_bytes_count( 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. // 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); DCHECK(self);
if(!self) if(!self)
return NULL; return NULL;
std::wstring urlStr = CefRequestCppToC::Get(self)->GetURL(); CefString urlStr = CefRequestCppToC::Get(self)->GetURL();
if(!urlStr.empty()) return urlStr.DetachToUserFree();
return cef_string_alloc(urlStr.c_str());
return NULL;
} }
void CEF_CALLBACK request_set_url(struct _cef_request_t* self, void CEF_CALLBACK request_set_url(struct _cef_request_t* self,
const wchar_t* url) const cef_string_t* url)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return; return;
std::wstring urlStr; CefRequestCppToC::Get(self)->SetURL(CefString(url));
if(url)
urlStr = url;
CefRequestCppToC::Get(self)->SetURL(urlStr);
} }
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); DCHECK(self);
if(!self) if(!self)
return NULL; return NULL;
std::wstring methodStr = CefRequestCppToC::Get(self)->GetMethod(); CefString methodStr = CefRequestCppToC::Get(self)->GetMethod();
if(!methodStr.empty()) return methodStr.DetachToUserFree();
return cef_string_alloc(methodStr.c_str());
return NULL;
} }
void CEF_CALLBACK request_set_method(struct _cef_request_t* self, void CEF_CALLBACK request_set_method(struct _cef_request_t* self,
const wchar_t* method) const cef_string_t* method)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return; return;
std::wstring methodStr; CefRequestCppToC::Get(self)->SetMethod(CefString(method));
if(method)
methodStr = method;
CefRequestCppToC::Get(self)->SetMethod(methodStr);
} }
struct _cef_post_data_t* CEF_CALLBACK request_get_post_data( 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); CefRequestCppToC::Get(self)->SetHeaderMap(map);
} }
void CEF_CALLBACK request_set(struct _cef_request_t* self, const wchar_t* url, void CEF_CALLBACK request_set(struct _cef_request_t* self,
const wchar_t* method, struct _cef_post_data_t* postData, const cef_string_t* url, const cef_string_t* method,
cef_string_map_t headerMap) struct _cef_post_data_t* postData, cef_string_map_t headerMap)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return; return;
std::wstring urlStr, methodStr;
CefRefPtr<CefPostData> postDataPtr; CefRefPtr<CefPostData> postDataPtr;
CefRequest::HeaderMap map; CefRequest::HeaderMap map;
if(url)
urlStr = url;
if(method)
methodStr = method;
if(postData) if(postData)
postDataPtr = CefPostDataCppToC::Unwrap(postData); postDataPtr = CefPostDataCppToC::Unwrap(postData);
if(headerMap) if(headerMap)
transfer_string_map_contents(headerMap, map); 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/cpptoc/scheme_handler_cpptoc.h"
#include "libcef_dll/ctocpp/request_ctocpp.h" #include "libcef_dll/ctocpp/request_ctocpp.h"
#include "libcef_dll/transfer_util.h"
// MEMBER FUNCTIONS - Body may be edited by hand. // 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) if(!self || !request || !mime_type || !response_length)
return 0; return 0;
std::wstring mimeTypeStr; return CefSchemeHandlerCppToC::Get(self)->ProcessRequest(
if(*mime_type) CefRequestCToCpp::Wrap(request), CefString(mime_type), response_length);
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;
} }
void CEF_CALLBACK scheme_handler_cancel(struct _cef_scheme_handler_t* self) 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. // GLOBAL FUNCTIONS - Body may be edited by hand.
CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_file( CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_file(
const wchar_t* fileName) const cef_string_t* fileName)
{ {
std::wstring filenamestr; CefRefPtr<CefStreamReader> impl =
if(fileName) CefStreamReader::CreateForFile(CefString(fileName));
filenamestr = fileName;
CefRefPtr<CefStreamReader> impl = CefStreamReader::CreateForFile(filenamestr);
if(impl.get()) if(impl.get())
return CefStreamReaderCppToC::Wrap(impl); return CefStreamReaderCppToC::Wrap(impl);
return NULL; return NULL;

View File

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

View File

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

View File

@ -57,13 +57,9 @@ CEF_EXPORT cef_v8value_t* cef_v8value_create_double(double value)
return NULL; 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; CefRefPtr<CefV8Value> impl = CefV8Value::CreateString(CefString(value));
if(value)
valueStr = value;
CefRefPtr<CefV8Value> impl = CefV8Value::CreateString(valueStr);
if(impl.get()) if(impl.get())
return CefV8ValueCppToC::Wrap(impl); return CefV8ValueCppToC::Wrap(impl);
return NULL; return NULL;
@ -89,17 +85,15 @@ CEF_EXPORT cef_v8value_t* cef_v8value_create_array()
return NULL; 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) cef_v8handler_t* handler)
{ {
std::wstring nameStr;
if(name)
nameStr = name;
CefRefPtr<CefV8Handler> handlerPtr; CefRefPtr<CefV8Handler> handlerPtr;
if(handler) if(handler)
handlerPtr = CefV8HandlerCToCpp::Wrap(handler); handlerPtr = CefV8HandlerCToCpp::Wrap(handler);
CefRefPtr<CefV8Value> impl = CefV8Value::CreateFunction(nameStr, handlerPtr); CefRefPtr<CefV8Value> impl =
CefV8Value::CreateFunction(CefString(name), handlerPtr);
if(impl.get()) if(impl.get())
return CefV8ValueCppToC::Wrap(impl); return CefV8ValueCppToC::Wrap(impl);
return NULL; return NULL;
@ -216,30 +210,25 @@ double CEF_CALLBACK v8value_get_double_value(struct _cef_v8value_t* self)
return CefV8ValueCppToC::Get(self)->GetDoubleValue(); 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); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
std::wstring valueStr = CefV8ValueCppToC::Get(self)->GetStringValue(); CefString valueStr = CefV8ValueCppToC::Get(self)->GetStringValue();
if(!valueStr.empty()) return valueStr.DetachToUserFree();
return cef_string_alloc(valueStr.c_str());
return NULL;
} }
int CEF_CALLBACK v8value_has_value_bykey(struct _cef_v8value_t* self, int CEF_CALLBACK v8value_has_value_bykey(struct _cef_v8value_t* self,
const wchar_t* key) const cef_string_t* key)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
std::wstring keyStr; return CefV8ValueCppToC::Get(self)->HasValue(CefString(key));
if(key)
keyStr = key;
return CefV8ValueCppToC::Get(self)->HasValue(keyStr);
} }
int CEF_CALLBACK v8value_has_value_byindex(struct _cef_v8value_t* self, 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, int CEF_CALLBACK v8value_delete_value_bykey(struct _cef_v8value_t* self,
const wchar_t* key) const cef_string_t* key)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
std::wstring keyStr; return CefV8ValueCppToC::Get(self)->DeleteValue(CefString(key));
if(key)
keyStr = key;
return CefV8ValueCppToC::Get(self)->DeleteValue(keyStr);
} }
int CEF_CALLBACK v8value_delete_value_byindex(struct _cef_v8value_t* self, 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* 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); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
std::wstring keyStr;
if(key)
keyStr = key;
CefRefPtr<CefV8Value> valuePtr = CefRefPtr<CefV8Value> valuePtr =
CefV8ValueCppToC::Get(self)->GetValue(keyStr); CefV8ValueCppToC::Get(self)->GetValue(CefString(key));
return CefV8ValueCppToC::Wrap(valuePtr); 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, 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); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
std::wstring keyStr;
if(key)
keyStr = key;
CefRefPtr<CefV8Value> valuePtr = CefV8ValueCppToC::Unwrap(value); 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, 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) if(!self)
return 0; return 0;
std::vector<std::wstring> keysList; std::vector<CefString> keysList;
CefV8ValueCppToC::Get(self)->GetKeys(keysList); CefV8ValueCppToC::Get(self)->GetKeys(keysList);
size_t size = keysList.size(); size_t size = keysList.size();
for(size_t i = 0; i < size; ++i) 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; return size;
} }
@ -366,17 +343,15 @@ int CEF_CALLBACK v8value_get_array_length(struct _cef_v8value_t* self)
return CefV8ValueCppToC::Get(self)->GetArrayLength(); 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); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
std::wstring functionNameStr = CefString functionNameStr = CefV8ValueCppToC::Get(self)->GetFunctionName();
CefV8ValueCppToC::Get(self)->GetFunctionName(); return functionNameStr.DetachToUserFree();
if(!functionNameStr.empty())
return cef_string_alloc(functionNameStr.c_str());
return NULL;
} }
cef_v8handler_t* CEF_CALLBACK v8value_get_function_handler( 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])); argsList.push_back(CefV8ValueCppToC::Unwrap(arguments[i]));
} }
CefRefPtr<CefV8Value> retvalPtr; CefRefPtr<CefV8Value> retvalPtr;
std::wstring exceptionStr;
bool rv = CefV8ValueCppToC::Get(self)->ExecuteFunction(objectPtr, bool rv = CefV8ValueCppToC::Get(self)->ExecuteFunction(objectPtr,
argsList, retvalPtr, exceptionStr); argsList, retvalPtr, CefString(exception));
if(retvalPtr.get() && retval) if(retvalPtr.get() && retval)
*retval = CefV8ValueCppToC::Wrap(retvalPtr); *retval = CefV8ValueCppToC::Wrap(retvalPtr);
if(!exceptionStr.empty() && exception)
*exception = cef_string_alloc(exceptionStr.c_str());
return rv; return rv;
} }

View File

@ -17,13 +17,10 @@
// GLOBAL FUNCTIONS - Body may be edited by hand. // GLOBAL FUNCTIONS - Body may be edited by hand.
CEF_EXPORT cef_xml_reader_t* cef_xml_reader_create(cef_stream_reader_t* stream, 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( CefRefPtr<CefXmlReader> impl = CefXmlReader::Create(
CefStreamReaderCppToC::Unwrap(stream), encodingType, encodingTypeStr); CefStreamReaderCppToC::Unwrap(stream), encodingType, CefString(URI));
if(impl.get()) if(impl.get())
return CefXmlReaderCppToC::Wrap(impl); return CefXmlReaderCppToC::Wrap(impl);
return NULL; return NULL;
@ -59,16 +56,15 @@ int CEF_CALLBACK xml_reader_has_error(struct _cef_xml_reader_t* self)
return CefXmlReaderCppToC::Get(self)->HasError(); 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); DCHECK(self);
if(!self) if(!self)
return NULL; return NULL;
std::wstring retStr = CefXmlReaderCppToC::Get(self)->GetError(); CefString retStr = CefXmlReaderCppToC::Get(self)->GetError();
if(!retStr.empty()) return retStr.DetachToUserFree();
return cef_string_alloc(retStr.c_str());
return NULL;
} }
enum cef_xml_node_type_t CEF_CALLBACK xml_reader_get_type( 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(); 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) struct _cef_xml_reader_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return NULL; return NULL;
std::wstring retStr = CefXmlReaderCppToC::Get(self)->GetLocalName(); CefString retStr = CefXmlReaderCppToC::Get(self)->GetLocalName();
if(!retStr.empty()) return retStr.DetachToUserFree();
return cef_string_alloc(retStr.c_str());
return NULL;
} }
cef_string_t CEF_CALLBACK xml_reader_get_prefix(struct _cef_xml_reader_t* self) cef_string_userfree_t CEF_CALLBACK xml_reader_get_prefix(
{
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(
struct _cef_xml_reader_t* self) struct _cef_xml_reader_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return NULL; return NULL;
std::wstring retStr = CefXmlReaderCppToC::Get(self)->GetQualifiedName(); CefString retStr = CefXmlReaderCppToC::Get(self)->GetPrefix();
if(!retStr.empty()) return retStr.DetachToUserFree();
return cef_string_alloc(retStr.c_str());
return NULL;
} }
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) struct _cef_xml_reader_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return NULL; return NULL;
std::wstring retStr = CefXmlReaderCppToC::Get(self)->GetNamespaceURI(); CefString retStr = CefXmlReaderCppToC::Get(self)->GetQualifiedName();
if(!retStr.empty()) return retStr.DetachToUserFree();
return cef_string_alloc(retStr.c_str());
return NULL;
} }
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) struct _cef_xml_reader_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return NULL; return NULL;
std::wstring retStr = CefXmlReaderCppToC::Get(self)->GetBaseURI(); CefString retStr = CefXmlReaderCppToC::Get(self)->GetNamespaceURI();
if(!retStr.empty()) return retStr.DetachToUserFree();
return cef_string_alloc(retStr.c_str());
return NULL;
} }
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) struct _cef_xml_reader_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return NULL; return NULL;
std::wstring retStr = CefXmlReaderCppToC::Get(self)->GetXmlLang(); CefString retStr = CefXmlReaderCppToC::Get(self)->GetBaseURI();
if(!retStr.empty()) return retStr.DetachToUserFree();
return cef_string_alloc(retStr.c_str()); }
cef_string_userfree_t CEF_CALLBACK xml_reader_get_xml_lang(
struct _cef_xml_reader_t* self)
{
DCHECK(self);
if(!self)
return NULL; 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) 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(); 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); DCHECK(self);
if(!self) if(!self)
return NULL; return NULL;
std::wstring retStr = CefXmlReaderCppToC::Get(self)->GetValue(); CefString retStr = CefXmlReaderCppToC::Get(self)->GetValue();
if(!retStr.empty()) return retStr.DetachToUserFree();
return cef_string_alloc(retStr.c_str());
return NULL;
} }
int CEF_CALLBACK xml_reader_has_attributes(struct _cef_xml_reader_t* self) 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(); 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) struct _cef_xml_reader_t* self, int index)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return NULL; return NULL;
std::wstring retStr = CefXmlReaderCppToC::Get(self)->GetAttribute(index); CefString retStr = CefXmlReaderCppToC::Get(self)->GetAttribute(index);
if(!retStr.empty()) return retStr.DetachToUserFree();
return cef_string_alloc(retStr.c_str());
return NULL;
} }
cef_string_t CEF_CALLBACK xml_reader_get_attribute_byqname( cef_string_userfree_t CEF_CALLBACK xml_reader_get_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(self);
DCHECK(qualifiedName); DCHECK(qualifiedName);
if(!self || !qualifiedName) if(!self || !qualifiedName)
return NULL; return NULL;
std::wstring retStr = CefXmlReaderCppToC::Get(self)->GetAttribute( CefString retStr = CefXmlReaderCppToC::Get(self)->GetAttribute(
qualifiedName); CefString(qualifiedName));
if(!retStr.empty()) return retStr.DetachToUserFree();
return cef_string_alloc(retStr.c_str());
return NULL;
} }
cef_string_t CEF_CALLBACK xml_reader_get_attribute_bylname( cef_string_userfree_t CEF_CALLBACK xml_reader_get_attribute_bylname(
struct _cef_xml_reader_t* self, const wchar_t* localName, struct _cef_xml_reader_t* self, const cef_string_t* localName,
const wchar_t* namespaceURI) const cef_string_t* namespaceURI)
{ {
DCHECK(self); DCHECK(self);
DCHECK(localName); DCHECK(localName);
@ -254,37 +234,31 @@ cef_string_t CEF_CALLBACK xml_reader_get_attribute_bylname(
if(!self || !localName || !namespaceURI) if(!self || !localName || !namespaceURI)
return NULL; return NULL;
std::wstring retStr = CefXmlReaderCppToC::Get(self)->GetAttribute( CefString retStr = CefXmlReaderCppToC::Get(self)->GetAttribute(
localName, namespaceURI); CefString(localName), CefString(namespaceURI));
if(!retStr.empty()) return retStr.DetachToUserFree();
return cef_string_alloc(retStr.c_str());
return NULL;
} }
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) struct _cef_xml_reader_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return NULL; return NULL;
std::wstring retStr = CefXmlReaderCppToC::Get(self)->GetInnerXml(); CefString retStr = CefXmlReaderCppToC::Get(self)->GetInnerXml();
if(!retStr.empty()) return retStr.DetachToUserFree();
return cef_string_alloc(retStr.c_str());
return NULL;
} }
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) struct _cef_xml_reader_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return NULL; return NULL;
std::wstring retStr = CefXmlReaderCppToC::Get(self)->GetOuterXml(); CefString retStr = CefXmlReaderCppToC::Get(self)->GetOuterXml();
if(!retStr.empty()) return retStr.DetachToUserFree();
return cef_string_alloc(retStr.c_str());
return NULL;
} }
int CEF_CALLBACK xml_reader_get_line_number(struct _cef_xml_reader_t* self) 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( 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(self);
DCHECK(qualifiedName); DCHECK(qualifiedName);
if(!self || !qualifiedName) if(!self || !qualifiedName)
return 0; return 0;
return CefXmlReaderCppToC::Get(self)->MoveToAttribute(qualifiedName); return CefXmlReaderCppToC::Get(self)->MoveToAttribute(
CefString(qualifiedName));
} }
int CEF_CALLBACK xml_reader_move_to_attribute_bylname( int CEF_CALLBACK xml_reader_move_to_attribute_bylname(
struct _cef_xml_reader_t* self, const wchar_t* localName, struct _cef_xml_reader_t* self, const cef_string_t* localName,
const wchar_t* namespaceURI) const cef_string_t* namespaceURI)
{ {
DCHECK(self); DCHECK(self);
DCHECK(localName); DCHECK(localName);
@ -327,8 +302,8 @@ int CEF_CALLBACK xml_reader_move_to_attribute_bylname(
if(!self || !localName || !namespaceURI) if(!self || !localName || !namespaceURI)
return 0; return 0;
return CefXmlReaderCppToC::Get(self)->MoveToAttribute(localName, return CefXmlReaderCppToC::Get(self)->MoveToAttribute(CefString(localName),
namespaceURI); CefString(namespaceURI));
} }
int CEF_CALLBACK xml_reader_move_to_first_attribute( 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, 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); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
std::wstring fileNameStr; return CefZipReaderCppToC::Get(self)->MoveToFile(CefString(fileName),
if (fileName)
fileNameStr = fileName;
return CefZipReaderCppToC::Get(self)->MoveToFile(fileNameStr,
caseSensitive ? true : false); caseSensitive ? true : false);
} }
@ -70,16 +66,16 @@ int CEF_CALLBACK zip_reader_close(struct _cef_zip_reader_t* self)
return CefZipReaderCppToC::Get(self)->Close(); 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) struct _cef_zip_reader_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return NULL; return NULL;
std::wstring retStr = CefZipReaderCppToC::Get(self)->GetFileName(); CefString retStr = CefZipReaderCppToC::Get(self)->GetFileName();
if(!retStr.empty()) if(!retStr.empty())
return cef_string_alloc(retStr.c_str()); return retStr.DetachToUserFree();
return NULL; 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, int CEF_CALLBACK zip_reader_open_file(struct _cef_zip_reader_t* self,
const wchar_t* password) const cef_string_t* password)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
std::wstring passwordStr; return CefZipReaderCppToC::Get(self)->OpenFile(CefString(password));
if (password)
passwordStr = password;
return CefZipReaderCppToC::Get(self)->OpenFile(passwordStr);
} }
int CEF_CALLBACK zip_reader_close_file(struct _cef_zip_reader_t* self) 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/cpptoc/handler_cpptoc.h"
#include "libcef_dll/ctocpp/browser_ctocpp.h" #include "libcef_dll/ctocpp/browser_ctocpp.h"
#include "libcef_dll/ctocpp/frame_ctocpp.h" #include "libcef_dll/ctocpp/frame_ctocpp.h"
#include "libcef_dll/transfer_util.h"
// STATIC METHODS - Body may be edited by hand. // STATIC METHODS - Body may be edited by hand.
bool CefBrowser::CreateBrowser(CefWindowInfo& windowInfo, bool popup, 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), return cef_browser_create(&windowInfo, popup, CefHandlerCppToC::Wrap(handler),
url.c_str())?true:false; url.GetStruct())?true:false;
} }
CefRefPtr<CefBrowser> CefBrowser::CreateBrowserSync(CefWindowInfo& windowInfo, 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, cef_browser_t* impl = cef_browser_create_sync(&windowInfo, popup,
CefHandlerCppToC::Wrap(handler), url.c_str()); CefHandlerCppToC::Wrap(handler), url.GetStruct());
if(impl) if(impl)
return CefBrowserCToCpp::Wrap(impl); return CefBrowserCToCpp::Wrap(impl);
return NULL; return NULL;
@ -153,19 +154,19 @@ CefRefPtr<CefFrame> CefBrowserCToCpp::GetFocusedFrame()
return NULL; 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)) if(CEF_MEMBER_MISSING(struct_, get_main_frame))
return NULL; 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) if(frameStruct)
return CefFrameCToCpp::Wrap(frameStruct); return CefFrameCToCpp::Wrap(frameStruct);
return NULL; 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)) if(CEF_MEMBER_MISSING(struct_, get_frame_names))
return; return;
@ -173,24 +174,17 @@ void CefBrowserCToCpp::GetFrameNames(std::vector<std::wstring>& names)
cef_string_list_t list = cef_string_list_alloc(); cef_string_list_t list = cef_string_list_alloc();
struct_->get_frame_names(struct_, list); struct_->get_frame_names(struct_, list);
cef_string_t str; transfer_string_list_contents(list, names);
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);
}
cef_string_list_free(list); 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) bool forward, bool matchCase, bool findNext)
{ {
if(CEF_MEMBER_MISSING(struct_, find)) if(CEF_MEMBER_MISSING(struct_, find))
return; return;
struct_->find(struct_, identifier, searchText.c_str(), forward, struct_->find(struct_, identifier, searchText.GetStruct(), forward,
matchCase, findNext); matchCase, findNext);
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -34,10 +34,10 @@ public:
// CefPostDataElement methods // CefPostDataElement methods
virtual void SetToEmpty(); 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 void SetToBytes(size_t size, const void* bytes);
virtual Type GetType(); virtual Type GetType();
virtual std::wstring GetFile(); virtual CefString GetFile();
virtual size_t GetBytesCount(); virtual size_t GetBytesCount();
virtual size_t GetBytes(size_t size, void* bytes); 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. // 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)) if(CEF_MEMBER_MISSING(struct_, get_url))
return str; return str;
cef_string_t cef_str = struct_->get_url(struct_); cef_string_userfree_t strPtr = struct_->get_url(struct_);
if(cef_str) { str.AttachToUserFree(strPtr);
str = cef_str;
cef_string_free(cef_str);
}
return str; return str;
} }
void CefRequestCToCpp::SetURL(const std::wstring& url) void CefRequestCToCpp::SetURL(const CefString& url)
{ {
if(CEF_MEMBER_MISSING(struct_, set_url)) if(CEF_MEMBER_MISSING(struct_, set_url))
return; 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)) if(CEF_MEMBER_MISSING(struct_, get_method))
return str; return str;
cef_string_t cef_str = struct_->get_method(struct_); cef_string_userfree_t strPtr = struct_->get_method(struct_);
if(cef_str) { str.AttachToUserFree(strPtr);
str = cef_str;
cef_string_free(cef_str);
}
return str; return str;
} }
void CefRequestCToCpp::SetMethod(const std::wstring& method) void CefRequestCToCpp::SetMethod(const CefString& method)
{ {
if(CEF_MEMBER_MISSING(struct_, set_method)) if(CEF_MEMBER_MISSING(struct_, set_method))
return; return;
struct_->set_method(struct_, method.c_str()); struct_->set_method(struct_, method.GetStruct());
} }
CefRefPtr<CefPostData> CefRequestCToCpp::GetPostData() CefRefPtr<CefPostData> CefRequestCToCpp::GetPostData()
@ -128,7 +122,7 @@ void CefRequestCToCpp::SetHeaderMap(const HeaderMap& headerMap)
cef_string_map_free(map); 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) CefRefPtr<CefPostData> postData, const HeaderMap& headerMap)
{ {
if(CEF_MEMBER_MISSING(struct_, set)) 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); 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) if(map)
cef_string_map_free(map); cef_string_map_free(map);

View File

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

View File

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

View File

@ -34,7 +34,7 @@ public:
// CefSchemeHandler methods // CefSchemeHandler methods
virtual bool ProcessRequest(CefRefPtr<CefRequest> request, virtual bool ProcessRequest(CefRefPtr<CefRequest> request,
std::wstring& mime_type, int* response_length); CefString& mime_type, int* response_length);
virtual void Cancel(); virtual void Cancel();
virtual bool ReadResponse(void* data_out, int bytes_to_read, int* bytes_read); 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. // STATIC METHODS - Body may be edited by hand.
CefRefPtr<CefStreamReader> CefStreamReader::CreateForFile( CefRefPtr<CefStreamReader> CefStreamReader::CreateForFile(
const std::wstring& fileName) const CefString& fileName)
{ {
cef_stream_reader_t* impl = cef_stream_reader_t* impl =
cef_stream_reader_create_for_file(fileName.c_str()); cef_stream_reader_create_for_file(fileName.GetStruct());
if(impl) if(impl)
return CefStreamReaderCToCpp::Wrap(impl); return CefStreamReaderCToCpp::Wrap(impl);
return NULL; return NULL;

View File

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

View File

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

View File

@ -31,9 +31,9 @@ public:
virtual ~CefV8HandlerCToCpp() {} virtual ~CefV8HandlerCToCpp() {}
// CefV8Handler methods // 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, const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
std::wstring& exception); CefString& exception);
}; };
#endif // BUILDING_CEF_SHARED #endif // BUILDING_CEF_SHARED

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -4,65 +4,44 @@
#include "transfer_util.h" #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, 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); int size = cef_string_map_size(fromMap);
cef_string_t key, value; CefString key, value;
std::wstring keystr, valuestr;
for(int i = 0; i < size; ++i) { for(int i = 0; i < size; ++i) {
key = cef_string_map_key(fromMap, i); cef_string_map_key(fromMap, i, key.GetWritableStruct());
value = cef_string_map_value(fromMap, i); cef_string_map_value(fromMap, i, value.GetWritableStruct());
if(key) { toMap.insert(std::pair<CefString, CefString>(key, value));
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));
} }
} }
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) cef_string_map_t toMap)
{ {
std::map<std::wstring, std::wstring>::const_iterator it = fromMap.begin(); StringMap::const_iterator it = fromMap.begin();
for(; it != fromMap.end(); ++it) { for(; it != fromMap.end(); ++it)
cef_string_map_append(toMap, it->first.c_str(), it->second.c_str()); cef_string_map_append(toMap, it->first.GetStruct(), it->second.GetStruct());
}
}
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();
}
} }

View File

@ -5,21 +5,23 @@
#ifndef _TRANSFER_UTIL_H #ifndef _TRANSFER_UTIL_H
#define _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 "include/cef_string_map.h"
#include <map> #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. // Copy contents from one map type to another.
typedef std::map<CefString, CefString> StringMap;
void transfer_string_map_contents(cef_string_map_t fromMap, void transfer_string_map_contents(cef_string_map_t fromMap,
std::map<std::wstring, std::wstring>& toMap); StringMap& toMap);
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); 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 #endif // _TRANSFER_UTIL_H

View File

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

View File

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

View File

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

View File

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

View File

@ -16,14 +16,14 @@
// ClientHandler::ClientDownloadListener implementation // ClientHandler::ClientDownloadListener implementation
void ClientHandler::ClientDownloadListener::NotifyDownloadComplete( void ClientHandler::ClientDownloadListener::NotifyDownloadComplete(
const std::wstring& fileName) const CefString& fileName)
{ {
handler_->SetLastDownloadFile(fileName); handler_->SetLastDownloadFile(fileName);
handler_->SendNotification(NOTIFY_DOWNLOAD_COMPLETE); handler_->SendNotification(NOTIFY_DOWNLOAD_COMPLETE);
} }
void ClientHandler::ClientDownloadListener::NotifyDownloadError( void ClientHandler::ClientDownloadListener::NotifyDownloadError(
const std::wstring& fileName) const CefString& fileName)
{ {
handler_->SetLastDownloadFile(fileName); handler_->SetLastDownloadFile(fileName);
handler_->SendNotification(NOTIFY_DOWNLOAD_ERROR); handler_->SendNotification(NOTIFY_DOWNLOAD_ERROR);
@ -90,36 +90,36 @@ CefHandler::RetVal ClientHandler::HandleLoadEnd(CefRefPtr<CefBrowser> browser,
CefHandler::RetVal ClientHandler::HandleLoadError(CefRefPtr<CefBrowser> browser, CefHandler::RetVal ClientHandler::HandleLoadError(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, ErrorCode errorCode, CefRefPtr<CefFrame> frame, ErrorCode errorCode,
const std::wstring& failedUrl, std::wstring& errorText) const CefString& failedUrl, CefString& errorText)
{ {
if(errorCode == ERR_CACHE_MISS) if(errorCode == ERR_CACHE_MISS)
{ {
// Usually caused by navigating to a page with POST data via back or // Usually caused by navigating to a page with POST data via back or
// forward buttons. // forward buttons.
errorText = L"<html><head><title>Expired Form Data</title></head>" errorText = "<html><head><title>Expired Form Data</title></head>"
L"<body><h1>Expired Form Data</h1>" "<body><h1>Expired Form Data</h1>"
L"<h2>Your form request has expired. " "<h2>Your form request has expired. "
L"Click reload to re-submit the form data.</h2></body>" "Click reload to re-submit the form data.</h2></body>"
L"</html>"; "</html>";
} }
else else
{ {
// All other messages. // All other messages.
std::wstringstream ss; std::stringstream ss;
ss << L"<html><head><title>Load Failed</title></head>" ss << "<html><head><title>Load Failed</title></head>"
L"<body><h1>Load Failed</h1>" "<body><h1>Load Failed</h1>"
L"<h2>Load of URL " << failedUrl << "<h2>Load of URL " << std::string(failedUrl) <<
L" failed with error code " << static_cast<int>(errorCode) << " failed with error code " << static_cast<int>(errorCode) <<
L".</h2></body>" ".</h2></body>"
L"</html>"; "</html>";
errorText = ss.str(); errorText = ss.str();
} }
return RV_HANDLED; return RV_HANDLED;
} }
CefHandler::RetVal ClientHandler::HandleDownloadResponse( CefHandler::RetVal ClientHandler::HandleDownloadResponse(
CefRefPtr<CefBrowser> browser, const std::wstring& mimeType, CefRefPtr<CefBrowser> browser, const CefString& mimeType,
const std::wstring& fileName, int64 contentLength, const CefString& fileName, int64 contentLength,
CefRefPtr<CefDownloadHandler>& handler) CefRefPtr<CefDownloadHandler>& handler)
{ {
// Create the handler for the file download. // Create the handler for the file download.
@ -129,10 +129,10 @@ CefHandler::RetVal ClientHandler::HandleDownloadResponse(
CefHandler::RetVal ClientHandler::HandlePrintHeaderFooter( CefHandler::RetVal ClientHandler::HandlePrintHeaderFooter(
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
CefPrintInfo& printInfo, const std::wstring& url, const std::wstring& title, CefPrintInfo& printInfo, const CefString& url, const CefString& title,
int currentPage, int maxPages, std::wstring& topLeft, int currentPage, int maxPages, CefString& topLeft,
std::wstring& topCenter, std::wstring& topRight, std::wstring& bottomLeft, CefString& topCenter, CefString& topRight, CefString& bottomLeft,
std::wstring& bottomCenter, std::wstring& bottomRight) CefString& bottomCenter, CefString& bottomRight)
{ {
// Place the page title at top left // Place the page title at top left
topLeft = title; topLeft = title;
@ -140,8 +140,8 @@ CefHandler::RetVal ClientHandler::HandlePrintHeaderFooter(
topRight = url; topRight = url;
// Place "Page X of Y" at bottom center // Place "Page X of Y" at bottom center
std::wstringstream strstream; std::stringstream strstream;
strstream << L"Page " << currentPage << L" of " << maxPages; strstream << "Page " << currentPage << " of " << maxPages;
bottomCenter = strstream.str(); bottomCenter = strstream.str();
return RV_CONTINUE; return RV_CONTINUE;
@ -168,37 +168,32 @@ CefHandler::RetVal ClientHandler::HandleBeforeWindowClose(
} }
CefHandler::RetVal ClientHandler::HandleConsoleMessage( CefHandler::RetVal ClientHandler::HandleConsoleMessage(
CefRefPtr<CefBrowser> browser, const std::wstring& message, CefRefPtr<CefBrowser> browser, const CefString& message,
const std::wstring& source, int line) const CefString& source, int line)
{ {
Lock(); Lock();
bool first_message = m_LogFile.empty(); bool first_message = m_LogFile.empty();
if(first_message) { if(first_message) {
std::wstringstream ss; std::stringstream ss;
ss << AppGetWorkingDirectory(); ss << AppGetWorkingDirectory();
#ifdef _WIN32 #ifdef _WIN32
ss << L"\\"; ss << "\\";
#else #else
ss << L"/"; ss << "/";
#endif #endif
ss << L"console.log"; ss << "console.log";
m_LogFile = ss.str(); m_LogFile = ss.str();
} }
std::wstring logFile = m_LogFile; std::string logFile = m_LogFile;
Unlock(); Unlock();
FILE* file = NULL; FILE* file = fopen(logFile.c_str(), "a");
#ifdef _WIN32
_wfopen_s(&file, logFile.c_str(), L"a, ccs=UTF-8");
#else
file = fopen(WStringToString(logFile).c_str(), "a");
#endif
if(file) { if(file) {
std::wstringstream ss; std::stringstream ss;
ss << L"Message: " << message << L"\r\nSource: " << source << ss << "Message: " << std::string(message) << "\r\nSource: " <<
L"\r\nLine: " << line << L"\r\n-----------------------\r\n"; std::string(source) << "\r\nLine: " << line <<
fputws(ss.str().c_str(), file); "\r\n-----------------------\r\n";
fputs(ss.str().c_str(), file);
fclose(file); fclose(file);
if(first_message) if(first_message)
@ -232,24 +227,24 @@ void ClientHandler::SetEditHwnd(CefWindowHandle hwnd)
Unlock(); Unlock();
} }
std::wstring ClientHandler::GetLogFile() std::string ClientHandler::GetLogFile()
{ {
Lock(); Lock();
std::wstring str = m_LogFile; std::string str = m_LogFile;
Unlock(); Unlock();
return str; return str;
} }
void ClientHandler::SetLastDownloadFile(const std::wstring& fileName) void ClientHandler::SetLastDownloadFile(const std::string& fileName)
{ {
Lock(); Lock();
m_LastDownloadFile = fileName; m_LastDownloadFile = fileName;
Unlock(); Unlock();
} }
std::wstring ClientHandler::GetLastDownloadFile() std::string ClientHandler::GetLastDownloadFile()
{ {
std::wstring str; std::string str;
Lock(); Lock();
str = m_LastDownloadFile; str = m_LastDownloadFile;
Unlock(); Unlock();
@ -278,25 +273,25 @@ CefWindowHandle AppGetMainHwnd()
void RunGetSourceTest(CefRefPtr<CefFrame> frame) void RunGetSourceTest(CefRefPtr<CefFrame> frame)
{ {
// Retrieve the current page source and display. // Retrieve the current page source and display.
std::wstring source = frame->GetSource(); std::string source = frame->GetSource();
source = StringReplace(source, L"<", L"&lt;"); source = StringReplace(source, "<", "&lt;");
source = StringReplace(source, L">", L"&gt;"); source = StringReplace(source, ">", "&gt;");
std::wstringstream ss; std::stringstream ss;
ss << L"<html><body>Source:" << L"<pre>" << source ss << "<html><body>Source:" << "<pre>" << source
<< L"</pre></body></html>"; << "</pre></body></html>";
frame->LoadString(ss.str(), L"http://tests/getsource"); frame->LoadString(ss.str(), "http://tests/getsource");
} }
void RunGetTextTest(CefRefPtr<CefFrame> frame) void RunGetTextTest(CefRefPtr<CefFrame> frame)
{ {
// Retrieve the current page text and display. // Retrieve the current page text and display.
std::wstring text = frame->GetText(); std::string text = frame->GetText();
text = StringReplace(text, L"<", L"&lt;"); text = StringReplace(text, "<", "&lt;");
text = StringReplace(text, L">", L"&gt;"); text = StringReplace(text, ">", "&gt;");
std::wstringstream ss; std::stringstream ss;
ss << L"<html><body>Text:" << L"<pre>" << text ss << "<html><body>Text:" << "<pre>" << text
<< L"</pre></body></html>"; << "</pre></body></html>";
frame->LoadString(ss.str(), L"http://tests/gettext"); frame->LoadString(ss.str(), "http://tests/gettext");
} }
void RunRequestTest(CefRefPtr<CefBrowser> browser) void RunRequestTest(CefRefPtr<CefBrowser> browser)
@ -305,7 +300,7 @@ void RunRequestTest(CefRefPtr<CefBrowser> browser)
CefRefPtr<CefRequest> request(CefRequest::CreateRequest()); CefRefPtr<CefRequest> request(CefRequest::CreateRequest());
// Set the request URL // 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- // Add post data to the request. The correct method and content-
// type headers will be set by CEF. // type headers will be set by CEF.
@ -320,7 +315,7 @@ void RunRequestTest(CefRefPtr<CefBrowser> browser)
// Add a custom header // Add a custom header
CefRequest::HeaderMap headerMap; CefRequest::HeaderMap headerMap;
headerMap.insert( 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); request->SetHeaderMap(headerMap);
// Load the request // Load the request
@ -330,16 +325,16 @@ void RunRequestTest(CefRefPtr<CefBrowser> browser)
void RunJavaScriptExecuteTest(CefRefPtr<CefBrowser> browser) void RunJavaScriptExecuteTest(CefRefPtr<CefBrowser> browser)
{ {
browser->GetMainFrame()->ExecuteJavaScript( browser->GetMainFrame()->ExecuteJavaScript(
L"alert('JavaScript execute works!');", L"about:blank", 0); "alert('JavaScript execute works!');", "about:blank", 0);
} }
void RunPopupTest(CefRefPtr<CefBrowser> browser) void RunPopupTest(CefRefPtr<CefBrowser> browser)
{ {
browser->GetMainFrame()->ExecuteJavaScript( 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) 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) {} ClientDownloadListener(ClientHandler* handler) : handler_(handler) {}
// Called when the download is complete. // Called when the download is complete.
virtual void NotifyDownloadComplete(const std::wstring& fileName); virtual void NotifyDownloadComplete(const CefString& fileName);
// Called if the download fails. // Called if the download fails.
virtual void NotifyDownloadError(const std::wstring& fileName); virtual void NotifyDownloadError(const CefString& fileName);
private: private:
ClientHandler* handler_; ClientHandler* handler_;
@ -44,7 +44,7 @@ public:
CefWindowInfo& createInfo, bool popup, CefWindowInfo& createInfo, bool popup,
const CefPopupFeatures& popupFeatures, const CefPopupFeatures& popupFeatures,
CefRefPtr<CefHandler>& handler, CefRefPtr<CefHandler>& handler,
std::wstring& url, CefString& url,
CefBrowserSettings& settings) CefBrowserSettings& settings)
{ {
return RV_CONTINUE; return RV_CONTINUE;
@ -58,12 +58,12 @@ public:
// ignored. // ignored.
virtual RetVal HandleAddressChange(CefRefPtr<CefBrowser> browser, virtual RetVal HandleAddressChange(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, CefRefPtr<CefFrame> frame,
const std::wstring& url); const CefString& url);
// Event called when the page title changes. The return value is currently // Event called when the page title changes. The return value is currently
// ignored. // ignored.
virtual RetVal HandleTitleChange(CefRefPtr<CefBrowser> browser, virtual RetVal HandleTitleChange(CefRefPtr<CefBrowser> browser,
const std::wstring& title); const CefString& title);
// Event called before browser navigation. The client has an opportunity to // Event called before browser navigation. The client has an opportunity to
// modify the |request| object if desired. Return RV_HANDLED to cancel // modify the |request| object if desired. Return RV_HANDLED to cancel
@ -97,8 +97,8 @@ public:
virtual RetVal HandleLoadError(CefRefPtr<CefBrowser> browser, virtual RetVal HandleLoadError(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, CefRefPtr<CefFrame> frame,
ErrorCode errorCode, ErrorCode errorCode,
const std::wstring& failedUrl, const CefString& failedUrl,
std::wstring& errorText); CefString& errorText);
// Event called before a resource is loaded. To allow the resource to load // 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 // 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. // To cancel loading of the resource return RV_HANDLED.
virtual RetVal HandleBeforeResourceLoad(CefRefPtr<CefBrowser> browser, virtual RetVal HandleBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefRequest> request, CefRefPtr<CefRequest> request,
std::wstring& redirectUrl, CefString& redirectUrl,
CefRefPtr<CefStreamReader>& resourceStream, CefRefPtr<CefStreamReader>& resourceStream,
std::wstring& mimeType, CefString& mimeType,
int loadFlags); int loadFlags);
// Called when a server indicates via the 'Content-Disposition' header that a // 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. // or RV_HANDLED to cancel the file download.
/*--cef()--*/ /*--cef()--*/
virtual RetVal HandleDownloadResponse(CefRefPtr<CefBrowser> browser, virtual RetVal HandleDownloadResponse(CefRefPtr<CefBrowser> browser,
const std::wstring& mimeType, const CefString& mimeType,
const std::wstring& fileName, const CefString& fileName,
int64 contentLength, int64 contentLength,
CefRefPtr<CefDownloadHandler>& handler); CefRefPtr<CefDownloadHandler>& handler);
@ -139,7 +139,7 @@ public:
// item. |label| contains the default text and may be modified to substitute // item. |label| contains the default text and may be modified to substitute
// alternate text. The return value is currently ignored. // alternate text. The return value is currently ignored.
virtual RetVal HandleGetMenuLabel(CefRefPtr<CefBrowser> browser, virtual RetVal HandleGetMenuLabel(CefRefPtr<CefBrowser> browser,
MenuId menuId, std::wstring& label) MenuId menuId, CefString& label)
{ {
return RV_CONTINUE; return RV_CONTINUE;
} }
@ -177,21 +177,21 @@ public:
virtual RetVal HandlePrintHeaderFooter(CefRefPtr<CefBrowser> browser, virtual RetVal HandlePrintHeaderFooter(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, CefRefPtr<CefFrame> frame,
CefPrintInfo& printInfo, CefPrintInfo& printInfo,
const std::wstring& url, const CefString& url,
const std::wstring& title, const CefString& title,
int currentPage, int maxPages, int currentPage, int maxPages,
std::wstring& topLeft, CefString& topLeft,
std::wstring& topCenter, CefString& topCenter,
std::wstring& topRight, CefString& topRight,
std::wstring& bottomLeft, CefString& bottomLeft,
std::wstring& bottomCenter, CefString& bottomCenter,
std::wstring& bottomRight); CefString& bottomRight);
// Run a JS alert message. Return RV_CONTINUE to display the default alert // Run a JS alert message. Return RV_CONTINUE to display the default alert
// or RV_HANDLED if you displayed a custom alert. // or RV_HANDLED if you displayed a custom alert.
virtual RetVal HandleJSAlert(CefRefPtr<CefBrowser> browser, virtual RetVal HandleJSAlert(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, CefRefPtr<CefFrame> frame,
const std::wstring& message) const CefString& message)
{ {
return RV_CONTINUE; return RV_CONTINUE;
} }
@ -201,7 +201,7 @@ public:
// set |retval| to true if the user accepted the confirmation. // set |retval| to true if the user accepted the confirmation.
virtual RetVal HandleJSConfirm(CefRefPtr<CefBrowser> browser, virtual RetVal HandleJSConfirm(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, CefRefPtr<CefFrame> frame,
const std::wstring& message, bool& retval) const CefString& message, bool& retval)
{ {
return RV_CONTINUE; return RV_CONTINUE;
} }
@ -212,10 +212,10 @@ public:
// |result| to the resulting value. // |result| to the resulting value.
virtual RetVal HandleJSPrompt(CefRefPtr<CefBrowser> browser, virtual RetVal HandleJSPrompt(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, CefRefPtr<CefFrame> frame,
const std::wstring& message, const CefString& message,
const std::wstring& defaultValue, const CefString& defaultValue,
bool& retval, bool& retval,
std::wstring& result) CefString& result)
{ {
return RV_CONTINUE; return RV_CONTINUE;
} }
@ -254,7 +254,7 @@ public:
// you can optionally modify |text| and then return RV_CONTINUE to allow // you can optionally modify |text| and then return RV_CONTINUE to allow
// the browser to display the tooltip. // the browser to display the tooltip.
virtual RetVal HandleTooltip(CefRefPtr<CefBrowser> browser, virtual RetVal HandleTooltip(CefRefPtr<CefBrowser> browser,
std::wstring& text) CefString& text)
{ {
return RV_CONTINUE; return RV_CONTINUE;
} }
@ -279,8 +279,8 @@ public:
// Called to display a console message. Return RV_HANDLED to stop the message // Called to display a console message. Return RV_HANDLED to stop the message
// from being output to the console. // from being output to the console.
RetVal HandleConsoleMessage(CefRefPtr<CefBrowser> browser, RetVal HandleConsoleMessage(CefRefPtr<CefBrowser> browser,
const std::wstring& message, const CefString& message,
const std::wstring& source, int line); const CefString& source, int line);
// Called to report find results returned by CefBrowser::Find(). |identifer| // Called to report find results returned by CefBrowser::Find(). |identifer|
// is the identifier passed to CefBrowser::Find(), |count| is the number of // is the identifier passed to CefBrowser::Find(), |count| is the number of
@ -304,10 +304,10 @@ public:
CefRefPtr<CefBrowser> GetBrowser() { return m_Browser; } CefRefPtr<CefBrowser> GetBrowser() { return m_Browser; }
CefWindowHandle GetBrowserHwnd() { return m_BrowserHwnd; } CefWindowHandle GetBrowserHwnd() { return m_BrowserHwnd; }
std::wstring GetLogFile(); std::string GetLogFile();
void SetLastDownloadFile(const std::wstring& fileName); void SetLastDownloadFile(const std::string& fileName);
std::wstring GetLastDownloadFile(); std::string GetLastDownloadFile();
// Send a notification to the application. Notifications should not block the // Send a notification to the application. Notifications should not block the
// caller. // caller.
@ -339,11 +339,11 @@ protected:
// True if the user can navigate forwards // True if the user can navigate forwards
bool m_bCanGoForward; bool m_bCanGoForward;
std::wstring m_LogFile; std::string m_LogFile;
// Support for downloading files. // Support for downloading files.
CefRefPtr<DownloadListener> m_DownloadListener; CefRefPtr<DownloadListener> m_DownloadListener;
std::wstring m_LastDownloadFile; std::string m_LastDownloadFile;
}; };
@ -354,7 +354,7 @@ CefRefPtr<CefBrowser> AppGetBrowser();
CefWindowHandle AppGetMainHwnd(); CefWindowHandle AppGetMainHwnd();
// Returns the application working directory. // Returns the application working directory.
std::wstring AppGetWorkingDirectory(); std::string AppGetWorkingDirectory();
// Implementations for various tests. // Implementations for various tests.
void RunGetSourceTest(CefRefPtr<CefFrame> frame); void RunGetSourceTest(CefRefPtr<CefFrame> frame);

View File

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