Index: chrome/browser/profiles/profile_impl_io_data.cc |
diff --git a/chrome/browser/profiles/profile_impl_io_data.cc b/chrome/browser/profiles/profile_impl_io_data.cc |
index d85b6a307e7b832d3dd021dcb50014cebbdabc31..d3a75c8e7429b82d6e4d13b7cbfd64209e4a6eb6 100644 |
--- a/chrome/browser/profiles/profile_impl_io_data.cc |
+++ b/chrome/browser/profiles/profile_impl_io_data.cc |
@@ -24,6 +24,7 @@ |
#include "chrome/browser/net/chrome_net_log.h" |
#include "chrome/browser/net/chrome_network_delegate.h" |
#include "chrome/browser/net/connect_interceptor.h" |
+#include "chrome/browser/net/cookie_store_util.h" |
#include "chrome/browser/net/http_server_properties_manager.h" |
#include "chrome/browser/net/predictor.h" |
#include "chrome/browser/net/sqlite_server_bound_cert_store.h" |
@@ -32,9 +33,7 @@ |
#include "chrome/common/chrome_switches.h" |
#include "chrome/common/pref_names.h" |
#include "chrome/common/url_constants.h" |
-#include "components/webdata/encryptor/encryptor.h" |
#include "content/public/browser/browser_thread.h" |
-#include "content/public/browser/cookie_crypto_delegate.h" |
#include "content/public/browser/cookie_store_factory.h" |
#include "content/public/browser/notification_service.h" |
#include "content/public/browser/resource_context.h" |
@@ -54,42 +53,6 @@ |
namespace { |
-// Use the operating system's mechanisms to encrypt cookies before writing |
-// them to persistent store. Currently this only is done with desktop OS's |
-// because ChromeOS and Android already protect the entire profile contents. |
-// |
-// TODO(bcwhite): Enable on MACOSX -- requires all Cookie tests to call |
-// Encryptor::UseMockKeychain or will hang waiting for user input. |
-#if defined(OS_WIN) || defined(OS_LINUX) // || defined(OS_MACOSX) |
-class CookieOSCryptoDelegate : public content::CookieCryptoDelegate { |
- public: |
- virtual bool EncryptString(const std::string& plaintext, |
- std::string* ciphertext) OVERRIDE; |
- virtual bool DecryptString(const std::string& ciphertext, |
- std::string* plaintext) OVERRIDE; |
-}; |
- |
-bool CookieOSCryptoDelegate::EncryptString(const std::string& plaintext, |
- std::string* ciphertext) { |
- return Encryptor::EncryptString(plaintext, ciphertext); |
-} |
- |
-bool CookieOSCryptoDelegate::DecryptString(const std::string& ciphertext, |
- std::string* plaintext) { |
- return Encryptor::DecryptString(ciphertext, plaintext); |
-} |
- |
-scoped_ptr<content::CookieCryptoDelegate> CreateCookieCryptoIfUseful() { |
- return scoped_ptr<content::CookieCryptoDelegate>( |
- new CookieOSCryptoDelegate); |
-} |
-#else |
-scoped_ptr<content::CookieCryptoDelegate> CreateCookieCryptoIfUseful() { |
- return scoped_ptr<content::CookieCryptoDelegate>(); |
-} |
-#endif |
- |
- |
net::BackendType ChooseCacheBackendType() { |
const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
if (command_line.HasSwitch(switches::kUseSimpleCacheBackend)) { |
@@ -161,13 +124,13 @@ void ProfileImplIOData::Handle::Init( |
const base::FilePath& profile_path, |
const base::FilePath& infinite_cache_path, |
chrome_browser_net::Predictor* predictor, |
- bool restore_old_session_cookies, |
+ content::CookieStoreConfig::SessionCookieMode session_cookie_mode, |
quota::SpecialStoragePolicy* special_storage_policy) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
DCHECK(!io_data_->lazy_params_); |
DCHECK(predictor); |
- LazyParams* lazy_params = new LazyParams; |
+ LazyParams* lazy_params = new LazyParams(); |
lazy_params->cookie_path = cookie_path; |
lazy_params->server_bound_cert_path = server_bound_cert_path; |
@@ -177,7 +140,7 @@ void ProfileImplIOData::Handle::Init( |
lazy_params->media_cache_max_size = media_cache_max_size; |
lazy_params->extensions_cookie_path = extensions_cookie_path; |
lazy_params->infinite_cache_path = infinite_cache_path; |
- lazy_params->restore_old_session_cookies = restore_old_session_cookies; |
+ lazy_params->session_cookie_mode = session_cookie_mode; |
lazy_params->special_storage_policy = special_storage_policy; |
io_data_->lazy_params_.reset(lazy_params); |
@@ -362,7 +325,8 @@ void ProfileImplIOData::Handle::LazyInitialize() const { |
ProfileImplIOData::LazyParams::LazyParams() |
: cache_max_size(0), |
media_cache_max_size(0), |
- restore_old_session_cookies(false) {} |
+ session_cookie_mode( |
+ content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES) {} |
ProfileImplIOData::LazyParams::~LazyParams() {} |
@@ -370,7 +334,9 @@ ProfileImplIOData::ProfileImplIOData() |
: ProfileIOData(false), |
http_server_properties_manager_(NULL), |
app_cache_max_size_(0), |
- app_media_cache_max_size_(0) {} |
+ app_media_cache_max_size_(0) { |
+} |
+ |
ProfileImplIOData::~ProfileImplIOData() { |
DestroyResourceContext(); |
@@ -385,10 +351,6 @@ void ProfileImplIOData::InitializeInternal( |
IOThread* const io_thread = profile_params->io_thread; |
IOThread::Globals* const io_thread_globals = io_thread->globals(); |
- const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
- bool record_mode = command_line.HasSwitch(switches::kRecordMode) && |
- chrome::kRecordModeEnabled; |
- bool playback_mode = command_line.HasSwitch(switches::kPlaybackMode); |
network_delegate()->set_predictor(predictor_.get()); |
@@ -424,27 +386,33 @@ void ProfileImplIOData::InitializeInternal( |
scoped_refptr<net::CookieStore> cookie_store = NULL; |
net::ServerBoundCertService* server_bound_cert_service = NULL; |
- if (record_mode || playback_mode) { |
+ if (chrome_browser_net::ShouldUseInMemoryCookiesAndCache()) { |
// Don't use existing cookies and use an in-memory store. |
- cookie_store = content::CreateInMemoryCookieStore( |
- profile_params->cookie_monster_delegate.get()); |
+ using content::CookieStoreConfig; |
+ cookie_store = content::CreateCookieStore(CookieStoreConfig( |
+ base::FilePath(), |
+ CookieStoreConfig::EPHEMERAL_SESSION_COOKIES, |
+ NULL, |
+ profile_params->cookie_monster_delegate.get())); |
// Don't use existing server-bound certs and use an in-memory store. |
server_bound_cert_service = new net::ServerBoundCertService( |
new net::DefaultServerBoundCertStore(NULL), |
base::WorkerPool::GetTaskRunner(true)); |
} |
+ |
// setup cookie store |
if (!cookie_store.get()) { |
DCHECK(!lazy_params_->cookie_path.empty()); |
- cookie_store = content::CreatePersistentCookieStore( |
+ content::CookieStoreConfig cookie_config( |
lazy_params_->cookie_path, |
- lazy_params_->restore_old_session_cookies, |
+ lazy_params_->session_cookie_mode, |
lazy_params_->special_storage_policy.get(), |
- profile_params->cookie_monster_delegate.get(), |
- CreateCookieCryptoIfUseful()); |
- cookie_store->GetCookieMonster()->SetPersistSessionCookies(true); |
+ profile_params->cookie_monster_delegate.get()); |
+ cookie_config.crypto_delegate = |
+ chrome_browser_net::GetCookieCryptoDelegate(); |
+ cookie_store = content::CreateCookieStore(cookie_config); |
} |
main_context->set_cookie_store(cookie_store.get()); |
@@ -486,9 +454,10 @@ void ProfileImplIOData::InitializeInternal( |
main_cache->GetSession()); |
#endif |
- if (record_mode || playback_mode) { |
+ if (chrome_browser_net::ShouldUseInMemoryCookiesAndCache()) { |
main_cache->set_mode( |
- record_mode ? net::HttpCache::RECORD : net::HttpCache::PLAYBACK); |
+ chrome_browser_net::IsCookieRecordMode() ? |
+ net::HttpCache::RECORD : net::HttpCache::PLAYBACK); |
} |
main_http_factory_.reset(main_cache); |
@@ -536,13 +505,14 @@ void ProfileImplIOData:: |
extensions_context->set_throttler_manager( |
io_thread_globals->throttler_manager.get()); |
+ content::CookieStoreConfig cookie_config( |
+ lazy_params_->extensions_cookie_path, |
+ lazy_params_->session_cookie_mode, |
+ NULL, NULL); |
+ cookie_config.crypto_delegate = |
+ chrome_browser_net::GetCookieCryptoDelegate(); |
net::CookieStore* extensions_cookie_store = |
- content::CreatePersistentCookieStore( |
- lazy_params_->extensions_cookie_path, |
- lazy_params_->restore_old_session_cookies, |
- NULL, |
- NULL, |
- CreateCookieCryptoIfUseful()); |
+ content::CreateCookieStore(cookie_config); |
// Enable cookies for devtools and extension URLs. |
const char* schemes[] = {chrome::kChromeDevToolsScheme, |
extensions::kExtensionScheme}; |
@@ -581,11 +551,6 @@ ProfileImplIOData::InitializeAppRequestContext( |
base::FilePath cache_path = |
partition_descriptor.path.Append(chrome::kCacheDirname); |
- const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
- bool record_mode = command_line.HasSwitch(switches::kRecordMode) && |
- chrome::kRecordModeEnabled; |
- bool playback_mode = command_line.HasSwitch(switches::kPlaybackMode); |
- |
// Use a separate HTTP disk cache for isolated apps. |
net::HttpCache::BackendFactory* app_backend = NULL; |
if (partition_descriptor.in_memory) { |
@@ -606,15 +571,16 @@ ProfileImplIOData::InitializeAppRequestContext( |
scoped_refptr<net::CookieStore> cookie_store = NULL; |
if (partition_descriptor.in_memory) { |
- cookie_store = content::CreateInMemoryCookieStore(NULL); |
- } else if (record_mode || playback_mode) { |
+ cookie_store = content::CreateCookieStore(content::CookieStoreConfig()); |
+ } else if (chrome_browser_net::ShouldUseInMemoryCookiesAndCache()) { |
// Don't use existing cookies and use an in-memory store. |
// TODO(creis): We should have a cookie delegate for notifying the cookie |
// extensions API, but we need to update it to understand isolated apps |
// first. |
- cookie_store = content::CreateInMemoryCookieStore(NULL); |
+ cookie_store = content::CreateCookieStore(content::CookieStoreConfig()); |
app_http_cache->set_mode( |
- record_mode ? net::HttpCache::RECORD : net::HttpCache::PLAYBACK); |
+ chrome_browser_net::IsCookieRecordMode() ? |
+ net::HttpCache::RECORD : net::HttpCache::PLAYBACK); |
} |
// Use an app-specific cookie store. |
@@ -624,12 +590,13 @@ ProfileImplIOData::InitializeAppRequestContext( |
// TODO(creis): We should have a cookie delegate for notifying the cookie |
// extensions API, but we need to update it to understand isolated apps |
// first. |
- cookie_store = content::CreatePersistentCookieStore( |
+ content::CookieStoreConfig cookie_config( |
cookie_path, |
- false, |
- NULL, |
- NULL, |
- CreateCookieCryptoIfUseful()); |
+ content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES, |
+ NULL, NULL); |
+ cookie_config.crypto_delegate = |
+ chrome_browser_net::GetCookieCryptoDelegate(); |
+ cookie_store = content::CreateCookieStore(cookie_config); |
} |
// Transfer ownership of the cookies and cache to AppRequestContext. |