From bf3fc7a858dfc2643ae0127ea559a1c0908bdbb1 Mon Sep 17 00:00:00 2001 From: anthony taranto Date: Mon, 30 Jul 2012 19:28:12 -0700 Subject: [PATCH] initial work on wrapping cookie visitor api --- CefSharp/CefSharp.h | 8 ++++++++ CefSharp/CefSharp.vcproj | 12 ++++++++++++ CefSharp/CookieVisitor.cpp | 11 +++++++++++ CefSharp/CookieVisitor.h | 24 ++++++++++++++++++++++++ CefSharp/ICookieVisitor.h | 13 +++++++++++++ 5 files changed, 68 insertions(+) create mode 100644 CefSharp/CookieVisitor.cpp create mode 100644 CefSharp/CookieVisitor.h create mode 100644 CefSharp/ICookieVisitor.h diff --git a/CefSharp/CefSharp.h b/CefSharp/CefSharp.h index 0b21ce06d..eb166b1a2 100644 --- a/CefSharp/CefSharp.h +++ b/CefSharp/CefSharp.h @@ -7,6 +7,7 @@ #include "include/cef_runnable.h" #include "include/cef_version.h" #include "include/cef_task.h" +#include "CookieVisitor.h" #include "Settings.h" #include "SchemeHandler.h" #include "StringUtil.h" @@ -119,6 +120,13 @@ namespace CefSharp return true; } + static bool VisitAllCookies(ICookieVisitor^ visitor) + { + CefRefPtr cookieVisitor = new CookieVisitor(visitor); + return CefCookieManager::GetGlobalManager()-> + VisitAllCookies(static_cast>(cookieVisitor)); + } + static bool SetCookie(String^ url, String^ name, String^ value, String^ domain, String^ path, bool secure, bool httponly, bool has_expires, DateTime expires) { msclr::lock l(_sync); diff --git a/CefSharp/CefSharp.vcproj b/CefSharp/CefSharp.vcproj index 10821a114..3340e1204 100644 --- a/CefSharp/CefSharp.vcproj +++ b/CefSharp/CefSharp.vcproj @@ -204,6 +204,10 @@ RelativePath=".\ClientAdapter.cpp" > + + @@ -290,6 +294,14 @@ RelativePath=".\ConsoleMessageEventArgs.h" > + + + + diff --git a/CefSharp/CookieVisitor.cpp b/CefSharp/CookieVisitor.cpp new file mode 100644 index 000000000..7ea2b103c --- /dev/null +++ b/CefSharp/CookieVisitor.cpp @@ -0,0 +1,11 @@ +#include "stdafx.h" + +#include "CookieVisitor.h" + +namespace CefSharp +{ + bool CookieVisitor::Visit(const CefCookie& cookie, int count, int total, bool& deleteCookie) + { + return _visitor->Visit(gcnew Cookie(), count, total, deleteCookie); + } +} \ No newline at end of file diff --git a/CefSharp/CookieVisitor.h b/CefSharp/CookieVisitor.h new file mode 100644 index 000000000..5e9866e4f --- /dev/null +++ b/CefSharp/CookieVisitor.h @@ -0,0 +1,24 @@ +#include "stdafx.h" +#pragma once + +#include "include/cef_cookie.h" +#include "ICookieVisitor.h" + +namespace CefSharp +{ + public class CookieVisitor : public CefCookieVisitor + { + private: + gcroot _visitor; + + public: + CookieVisitor(ICookieVisitor^ visitor) + { + _visitor = visitor; + } + + virtual bool Visit(const CefCookie& cookie, int count, int total, bool& deleteCookie) OVERRIDE; + + IMPLEMENT_REFCOUNTING(CookieVisitor); + }; +} \ No newline at end of file diff --git a/CefSharp/ICookieVisitor.h b/CefSharp/ICookieVisitor.h new file mode 100644 index 000000000..0343f1bc2 --- /dev/null +++ b/CefSharp/ICookieVisitor.h @@ -0,0 +1,13 @@ +#include "stdafx.h" +#pragma once + +using namespace System::Net; + +namespace CefSharp +{ + public interface class ICookieVisitor + { + public: + bool Visit(Cookie^ cookie, int count, int total, bool% deleteCookie); + }; +} \ No newline at end of file