From 4fc0fed0810419ea71f9439570c89230c107c91a Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Wed, 27 Mar 2013 08:53:35 -0400 Subject: [PATCH] Persist cookies to disk We use Chrome's SQLitePersistentCookieStore to save cookies to a file called "Cookies" within the application support directory. Fixes #5. --- brightray/browser/url_request_context_getter.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/brightray/browser/url_request_context_getter.cc b/brightray/browser/url_request_context_getter.cc index e865f8ce2244..cfaa9a1a1942 100644 --- a/brightray/browser/url_request_context_getter.cc +++ b/brightray/browser/url_request_context_getter.cc @@ -2,11 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE-CHROMIUM file. -#include "url_request_context_getter.h" +#include "browser/url_request_context_getter.h" #include "network_delegate.h" #include "base/string_util.h" #include "base/threading/worker_pool.h" +#include "chrome/browser/net/sqlite_persistent_cookie_store.h" #include "content/public/browser/browser_thread.h" #include "content/public/common/url_constants.h" #include "net/base/cert_verifier.h" @@ -58,7 +59,14 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() url_request_context_->set_network_delegate(network_delegate_.get()); storage_.reset( new net::URLRequestContextStorage(url_request_context_.get())); - storage_->set_cookie_store(new net::CookieMonster(NULL, NULL)); + storage_->set_cookie_store(new net::CookieMonster( + new SQLitePersistentCookieStore( + base_path_.Append(FILE_PATH_LITERAL("Cookies")), + content::BrowserThread::GetMessageLoopProxyForThread(content::BrowserThread::IO), + content::BrowserThread::GetMessageLoopProxyForThread(content::BrowserThread::DB), + false, + nullptr), + NULL)); storage_->set_server_bound_cert_service(new net::ServerBoundCertService( new net::DefaultServerBoundCertStore(NULL), base::WorkerPool::GetTaskRunner(true)));