问题描述
- Cef3 CefCookieManager的正确用法?
-
研究过CEF3的大牛们?怎样使用CefCookieManager::CreateManager来为浏览器实例分配单独的CookieManager?
我本来以为很简单:
首先生成一个CefRequestContextHandler,重载GetCookieManager,象这样: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); };
然后用CefRequestContext::CreateContext来创建一个CefRequestContext实例。
像这样:CefRefPtr rc = CefRequestContext::CreateContext(new WXRequestContextHandler());
然后创建BROWSER:
CefBrowserHost::CreateBrowser(window_info, handler.get(), url, browser_settings, rc);
结果一运行代码就出现EXCEPTION 访问冲突。只有getCookieManager返回NULL
才正常我想肯定是我的用法错了,那么正确的用法是什么?求指教。
我测试代码是用的CEF3下载包中的cefSimple应用程序,只改了两行代码: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; // Check if a "--url=" value was provided via the command-line. If so, use // that instead of the default URL. CefRefPtr<CefCommandLine> command_line = CefCommandLine::GetGlobalCommandLine(); url = command_line->GetSwitchValue("url"); if (url.empty()) url = "http://www.google.com"; CefRefPtr<CefRequestContext> rc = CefRequestContext::CreateContext(new WXRequestContextHandler()); // Create the first browser window. CefBrowserHost::CreateBrowser(window_info, handler.get(), url, browser_settings, rc); }
我是用的CEF3.175,VS2013,WIN7。
解决方案
问题解决了。
答案
有遇到同样问题的兄弟们可以参考下
解决方案二:
怎么解决的也没说, 参考什么呢?
时间: 2024-12-23 10:27:30