Merge pull request #251 from electron/cookies-changed
Support configuring a cookie delegate
This commit is contained in:
commit
4fb32f62f5
2 changed files with 15 additions and 14 deletions
|
@ -179,19 +179,16 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
|
|||
|
||||
storage_.reset(new net::URLRequestContextStorage(url_request_context_.get()));
|
||||
|
||||
std::unique_ptr<net::CookieStore> cookie_store = nullptr;
|
||||
if (in_memory_) {
|
||||
auto cookie_config = content::CookieStoreConfig();
|
||||
cookie_config.cookieable_schemes = delegate_->GetCookieableSchemes();
|
||||
cookie_store = content::CreateCookieStore(cookie_config);
|
||||
} else {
|
||||
auto cookie_config = content::CookieStoreConfig(
|
||||
base_path_.Append(FILE_PATH_LITERAL("Cookies")),
|
||||
content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES,
|
||||
nullptr, nullptr);
|
||||
cookie_config.cookieable_schemes = delegate_->GetCookieableSchemes();
|
||||
cookie_store = content::CreateCookieStore(cookie_config);
|
||||
}
|
||||
auto cookie_path = in_memory_ ?
|
||||
base::FilePath() : base_path_.Append(FILE_PATH_LITERAL("Cookies"));
|
||||
auto cookie_config = content::CookieStoreConfig(
|
||||
cookie_path,
|
||||
content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES,
|
||||
nullptr,
|
||||
delegate_->CreateCookieDelegate());
|
||||
cookie_config.cookieable_schemes = delegate_->GetCookieableSchemes();
|
||||
std::unique_ptr<net::CookieStore> cookie_store =
|
||||
content::CreateCookieStore(cookie_config);
|
||||
storage_->set_cookie_store(std::move(cookie_store));
|
||||
storage_->set_channel_id_service(base::WrapUnique(
|
||||
new net::ChannelIDService(new net::DefaultChannelIDStore(nullptr),
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "base/files/file_path.h"
|
||||
#include "content/public/browser/browser_context.h"
|
||||
#include "content/public/browser/content_browser_client.h"
|
||||
#include "net/cookies/cookie_monster.h"
|
||||
#include "net/http/http_cache.h"
|
||||
#include "net/http/url_security_manager.h"
|
||||
#include "net/url_request/url_request_context_getter.h"
|
||||
|
@ -38,7 +39,10 @@ class URLRequestContextGetter : public net::URLRequestContextGetter {
|
|||
Delegate() {}
|
||||
virtual ~Delegate() {}
|
||||
|
||||
virtual net::NetworkDelegate* CreateNetworkDelegate() { return NULL; }
|
||||
virtual net::NetworkDelegate* CreateNetworkDelegate() { return nullptr; }
|
||||
virtual net::CookieMonsterDelegate* CreateCookieDelegate() {
|
||||
return nullptr;
|
||||
}
|
||||
virtual std::string GetUserAgent();
|
||||
virtual std::unique_ptr<net::URLRequestJobFactory>
|
||||
CreateURLRequestJobFactory(
|
||||
|
|
Loading…
Reference in a new issue