any tip will be appreicate.
I just want to study the usage of CefCookieManager,so I test my code in cefSimple project packed wtih Cef3 downloads.I use cef3.1750(win32),vs2013(vc12),windows7
First,I write a class(WXRequestContextHandler) which inherited form CefRequestContextHandler,like this:
- Code: Select all
#include "include/cef_app.h"
#include "include/cef_request_context_handler.h"
#include "include/cef_cookie.h"
class WXRequestContextHandler :public CefRequestContextHandler
{
public:
WXRequestContextHandler(){};
~WXRequestContextHandler(){};
CefRefPtr<CefCookieManager> GetCookieManager() OVERRIDE{
return CefCookieManager::CreateManager("F:\\CefCookie",FALSE);
}
private:
// Include the default reference counting implementation.
IMPLEMENT_REFCOUNTING(WXRequestContextHandler);
};
then Create an instance of this Class,like this:
- Code: Select all
CefRefPtr<CefRequestContext> rc = CefRequestContext::CreateContext(new WXRequestContextHandler());
and Create the browser:
- Code: Select all
CefBrowserHost::CreateBrowser(window_info, handler.get(), url,
browser_settings, rc);
OK,I don't know anymore about the CefCookieManager,so I run the code press F5,and got a exception(triggered in libcef.dll ,access violation 0xc0000005),the cefSimple application crashed.
I noticted the getCookieManager methed was called and when it return the exception will be triggered.but if it return NULL(which means use global cookieManager) the app runs as normal.
Obviously,I think I didn't use the CookieManager::CreateManager Correctly.
My problem is:what is the correct way to use CefCookieManager::CreateManager?
hope help.
advance thank.
Follow is my complete code I revised in CefSimple's simple_app.cpp,just one line code.
- Code: Select all
void SimpleApp::OnContextInitialized() {
REQUIRE_UI_THREAD();
// Information used when creating the native window.
CefWindowInfo window_info;
#if defined(OS_WIN)
// On Windows we need to specify certain flags that will be passed to
// CreateWindowEx().
window_info.SetAsPopup(NULL, "cefsimple");
#endif
// SimpleHandler implements browser-level callbacks.
CefRefPtr<SimpleHandler> handler(new SimpleHandler());
// Specify CEF browser settings here.
CefBrowserSettings browser_settings;
std::string url;
url = "http://www.google.com";
//here is my code
CefRefPtr<CefRequestContext> rc = CefRequestContext::CreateContext(new WXRequestContextHandler());
// Create the first browser window.
CefBrowserHost::CreateBrowser(window_info, handler.get(), url,
browser_settings, rc);
}