exposed CefSetCookiePath and CefSetCookie

This commit is contained in:
Davy Brion
2012-04-02 18:25:49 +03:00
parent fe16a3bf1d
commit 558fe101ea
+35 -1
View File
@@ -3,12 +3,17 @@
#include "include/cef_app.h"
#include "include/cef_version.h"
#include "include/cef_runnable.h"
#include "include/cef_task.h"
#include "Settings.h"
#include "SchemeHandler.h"
#include "StringUtil.h"
#include <msclr\marshal_cppstd.h>
using namespace System;
using namespace System::IO;
using namespace System::Collections::Generic;
using namespace msclr::interop;
namespace CefSharp
{
@@ -23,7 +28,13 @@ namespace CefSharp
_boundObjects = gcnew Dictionary<String^, Object^>();
}
internal:
// this method is meant to be called on the IO-thread, which we'll do through CefPostTask
static void IOT_SetCookie(const CefString& url, const CefCookie& cookie)
{
CefSetCookie(url, cookie);
}
internal:
static IDictionary<String^, Object^>^ GetBoundObjects()
{
return _boundObjects;
@@ -103,5 +114,28 @@ namespace CefSharp
CefShutdown();
}
}
static bool SetCookiePath(String^ path)
{
CefString cef_path = toNative(path);
return CefSetCookiePath(cef_path);
}
static void SetCookie(String^ url, String^ domain, String^ name, String^ value, DateTime^ expires)
{
CefString cef_url = toNative(url);
CefCookie cookie;
CefString(&cookie.name).FromString(marshal_as<std::string>(name));
CefString(&cookie.value).FromString(marshal_as<std::string>(value));
CefString(&cookie.domain).FromString(marshal_as<std::string>(domain));
CefString(&cookie.path).FromString("/");
cookie.has_expires = true;
cookie.expires.year = expires->Year;
cookie.expires.month = expires->Month;
cookie.expires.day_of_month = expires->Day;
CefPostTask(TID_IO, NewCefRunnableFunction(IOT_SetCookie, cef_url, cookie));
}
};
}