示例#1
0
void Browser::setCookie(const char* name, const char* value)
{
	ChromiumDLL::CookieI* cookie = CEF_CreateCookie();

	cookie->SetDomain("192.168.211.10");
	cookie->SetPath("/");
	cookie->SetName(name);
	cookie->SetData(value);

	CEF_SetCookie("http://192.168.211.10", cookie);
	cookie->destroy();

	m_pChromeBrowser->refresh();
}
示例#2
0
void SetCookies(const char* freeman, const char* masterchief)
{
	if (!g_bLoaded)
		return;

	if (!CEF_CreateCookie)
	{
		Warning("CEF_CreateCookie is NULL. Failed to set cookies. :(\n");
		return;
	}

	if (!CEF_SetCookie)
	{
		Warning("CEF_SetCookie is NULL. Failed to set cookies. :(\n");
		return;
	}

	ChromiumDLL::CookieI* cookie = CEF_CreateCookie();

	if (!cookie)
	{
		Warning("Cef failed to create cookie. Failed to set cookies. :(\n");
		return;
	}

	cookie->SetDomain(".desura.com");
	cookie->SetPath("/");

	cookie->SetName("freeman");
	cookie->SetData(freeman);

	CEF_SetCookie("http://www.desura.com", cookie);

	cookie->SetName("masterchief");
	cookie->SetData(masterchief);

	CEF_SetCookie("http://www.desura.com", cookie);

	cookie->destroy();
}
示例#3
0
void SetCookies()
{
	if (!g_bLoaded || !GetWebCore())
		return;

	ChromiumDLL::CookieI* cookie = g_pChromiumController->CreateCookie();

	if (!cookie)
	{
		Warning("Cef failed to create cookie. Failed to set cookies. :(\n");
		return;
	}

	gcString urlRoot;

	{
		std::lock_guard<std::mutex> a(g_RootUrlMutex);

		if (GetWebCore())
			g_strRootUrl = GetWebCore()->getUrl(WebCore::Root);

		urlRoot = g_strRootUrl;
	}

	if (urlRoot.find("http://") == 0)
		urlRoot = urlRoot.substr(7);

	if (urlRoot.find("www") == 0)
		urlRoot = urlRoot.substr(3);
	else
		urlRoot = gcString(".") + urlRoot;

	cookie->SetDomain(urlRoot.c_str());
	cookie->SetPath("/");

	std::function<void(const char*, const char*, const char*)> cookieCallback 
		= [&](const char* szRootUrl, const char* szName, const char* szValue)
	{
		cookie->SetName(szName);
		cookie->SetData(szValue);

		g_pChromiumController->SetCookie(szRootUrl, cookie);
	};

	GetWebCore()->setCookies(cookieCallback);
	cookie->destroy();
}