Exposing the cookies flushstore method

This commit is contained in:
brock8503
2014-04-05 17:04:19 -07:00
committed by amaitland
parent 34b405506a
commit f299a002e6
5 changed files with 74 additions and 0 deletions
+19
View File
@@ -10,6 +10,7 @@
#include "Internals/CefSharpApp.h"
#include "Internals/CookieVisitor.h"
#include "Internals/CompletionHandler.h"
#include "Internals/StringUtils.h"
#include "ManagedCefBrowserAdapter.h"
#include "CefSettings.h"
@@ -333,6 +334,24 @@ namespace CefSharp
}
}
/// <summary> Flush the backing store (if any) to disk and execute the specified |handler| on the IO thread when done. Returns </summary>
/// <param name="visitor">A user-provided Cookie Visitor implementation.</param>
/// <return>Returns false if cookies cannot be accessed.</return>
static bool FlushStore(IComplete^ handler)
{
CefRefPtr<CompletionHandler> wrapper = new CompletionHandler(handler);
CefRefPtr<CefCookieManager> manager = CefCookieManager::GetGlobalManager();
if (manager != nullptr)
{
manager->FlushStore(static_cast<CefRefPtr<CefCompletionHandler>>(wrapper));
return true;
}
else
{
return false;
}
}
/// <summary>Shuts down CefSharp and the underlying CEF infrastructure. This method is safe to call multiple times; it will only
/// shut down CEF on the first call (all subsequent calls will be ignored).
/// </summary>
@@ -0,0 +1,18 @@
// Copyright © 2010-2014 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
#pragma once
#include "Stdafx.h"
#include "CompletionHandler.h"
using namespace System::Net;
namespace CefSharp
{
void CompletionHandler::OnComplete()
{
_handler->OnComplete();
}
}
@@ -0,0 +1,27 @@
// Copyright © 2010-2014 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
#pragma once
#include "Stdafx.h"
#include "include/cef_cookie.h"
namespace CefSharp
{
private class CompletionHandler : public CefCompletionHandler
{
private:
gcroot<IComplete^> _handler;
public:
CompletionHandler(IComplete^ handler)
{
_handler = handler;
}
virtual void OnComplete() OVERRIDE;
IMPLEMENT_REFCOUNTING(CompletionHandler);
};
}
+1
View File
@@ -97,6 +97,7 @@
<Compile Include="KeyType.cs" />
<Compile Include="LoadErrorEventHandler.cs" />
<Compile Include="NavStateChangedEventArgs.cs" />
<Compile Include="IComplete.cs" />
<Compile Include="Internals\BitmapInfo.cs" />
<Compile Include="Internals\ManagedCefApp.cs" />
<Compile Include="CefCustomScheme.cs" />
+9
View File
@@ -0,0 +1,9 @@
using System.Net;
namespace CefSharp
{
public interface IComplete
{
void OnComplete();
}
}