mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-05 03:32:37 +00:00
exposed CefSetCookiePath and CefSetCookie
This commit is contained in:
+35
-1
@@ -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));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user