diff options
author | Andras Becsi <andras.becsi@theqtcompany.com> | 2015-06-03 19:00:34 +0200 |
---|---|---|
committer | Andras Becsi <andras.becsi@theqtcompany.com> | 2015-06-16 09:39:22 +0000 |
commit | 8a77cd16793bc91b0f7c267fc579a3041dd55e61 (patch) | |
tree | adeb282e7170f753719a6984252ff2b39aa9dc72 /src/core/url_request_context_getter_qt.cpp | |
parent | 0e006b8ea755ebad01faf3e747e61abdf158289a (diff) |
Add QWebEngineCookieStoreClient core API
This class or its subclass can be set on the
QWebEngineProfile and its API enables intercepting
Chromium's cookies, setting and deleting cookies
in the cookie store.
These functions are asynchronous so if the result
of the task is needed the user can provide a
callback which will be run on the calling thread
when the requested operation finishes.
This does not include a hook for QQuick layer yet,
there we have to figure out what the most convenient
way is from a developer's perspective.
Change-Id: I6a3af071883ce632df7a2fb952da93f306ac3fe2
Reviewed-by: Pierre Rossi <pierre.rossi@theqtcompany.com>
Diffstat (limited to 'src/core/url_request_context_getter_qt.cpp')
-rw-r--r-- | src/core/url_request_context_getter_qt.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/core/url_request_context_getter_qt.cpp b/src/core/url_request_context_getter_qt.cpp index da0dd8ab3..d829666b7 100644 --- a/src/core/url_request_context_getter_qt.cpp +++ b/src/core/url_request_context_getter_qt.cpp @@ -64,11 +64,14 @@ #include "browser_context_adapter.h" #include "custom_protocol_handler.h" #include "custom_url_scheme_handler.h" +#include "cookie_monster_delegate_qt.h" #include "content_client_qt.h" #include "network_delegate_qt.h" #include "proxy_config_service_qt.h" #include "proxy_resolver_qt.h" #include "qrc_protocol_handler_qt.h" +#include "qwebenginecookiestoreclient.h" +#include "qwebenginecookiestoreclient_p.h" #include "type_conversion.h" namespace QtWebEngineCore { @@ -80,6 +83,7 @@ using content::BrowserThread; URLRequestContextGetterQt::URLRequestContextGetterQt(BrowserContextAdapter *browserContext, content::ProtocolHandlerMap *protocolHandlers) : m_ignoreCertificateErrors(false) , m_browserContext(browserContext) + , m_cookieDelegate(new CookieMonsterDelegateQt()) { std::swap(m_protocolHandlers, *protocolHandlers); @@ -186,6 +190,8 @@ void URLRequestContextGetterQt::generateCookieStore() // Unset it first to get a chance to destroy and flush the old cookie store before before opening a new on possibly the same file. m_storage->set_cookie_store(0); + m_cookieDelegate->setCookieMonster(0); + m_cookieDelegate->setClient(m_browserContext->cookieStoreClient()); net::CookieStore* cookieStore = 0; switch (m_browserContext->persistentCookiesPolicy()) { @@ -194,7 +200,8 @@ void URLRequestContextGetterQt::generateCookieStore() content::CreateCookieStore(content::CookieStoreConfig( base::FilePath(), content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES, - NULL, NULL) + NULL, + m_cookieDelegate.get()) ); break; case BrowserContextAdapter::AllowPersistentCookies: @@ -202,7 +209,8 @@ void URLRequestContextGetterQt::generateCookieStore() content::CreateCookieStore(content::CookieStoreConfig( toFilePath(m_browserContext->cookiesPath()), content::CookieStoreConfig::PERSISTANT_SESSION_COOKIES, - NULL, NULL) + NULL, + m_cookieDelegate.get()) ); break; case BrowserContextAdapter::ForcePersistentCookies: @@ -210,11 +218,15 @@ void URLRequestContextGetterQt::generateCookieStore() content::CreateCookieStore(content::CookieStoreConfig( toFilePath(m_browserContext->cookiesPath()), content::CookieStoreConfig::RESTORED_SESSION_COOKIES, - NULL, NULL) + NULL, + m_cookieDelegate.get()) ); break; } m_storage->set_cookie_store(cookieStore); + + net::CookieMonster * const cookieMonster = cookieStore->GetCookieMonster(); + m_cookieDelegate->setCookieMonster(cookieMonster); } void URLRequestContextGetterQt::updateUserAgent() |