Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exposing flushcookie api. #313

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions CefSharp.Core/Cef.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -316,6 +317,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>
Expand Down
4 changes: 3 additions & 1 deletion CefSharp.Core/CefSharp.Core.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,9 @@
<ClCompile Include="AssemblyInfo.cpp" />
<ClCompile Include="CefAppWrapper.cpp" />
<ClCompile Include="Internals\ClientAdapter.cpp" />
<ClCompile Include="Internals\CookieVisitor.cpp" />
<ClCompile Include="Internals\CefRequestWrapper.cpp" />
<ClCompile Include="Internals\CompletionHandler.cpp" />
<ClCompile Include="Internals\CookieVisitor.cpp" />
<ClCompile Include="Internals\RequestResponse.cpp" />
<ClCompile Include="SchemeHandlerResponse.cpp" />
<ClCompile Include="SchemeHandlerWrapper.cpp" />
Expand All @@ -235,6 +236,7 @@
<ItemGroup>
<ClInclude Include="BrowserSettings.h" />
<ClInclude Include="Cef.h" />
<ClInclude Include="Internals\CompletionHandler.h" />
<ClInclude Include="Wrappers\CefAppWrapper.h" />
<ClInclude Include="Internals\DownloadAdapter.h" />
<ClInclude Include="Internals\ClientAdapter.h" />
Expand Down
12 changes: 9 additions & 3 deletions CefSharp.Core/CefSharp.Core.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
<ClCompile Include="Internals\CefRequestWrapper.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Internals\CookieVisitor.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Internals\ClientAdapter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
Expand All @@ -47,6 +44,12 @@
<ClCompile Include="CefAppWrapper.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Internals\CompletionHandler.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Internals\CookieVisitor.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="vcclr_local.h">
Expand Down Expand Up @@ -115,6 +118,9 @@
<ClInclude Include="CefSettings.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Internals\CompletionHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
Expand Down
18 changes: 18 additions & 0 deletions CefSharp.Core/Internals/CompletionHandler.cpp
Original file line number Diff line number Diff line change
@@ -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();
}
}
27 changes: 27 additions & 0 deletions CefSharp.Core/Internals/CompletionHandler.h
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions CefSharp/CefSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="IComplete.cs" />
<Compile Include="Internals\BitmapInfo.cs" />
<Compile Include="Internals\ManagedCefApp.cs" />
<Compile Include="CefCustomScheme.cs" />
Expand Down
9 changes: 9 additions & 0 deletions CefSharp/IComplete.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Net;

namespace CefSharp
{
public interface IComplete
{
void OnComplete();
}
}