| 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 4a5958b849d5291598ad29c640e4a0dd249ccccc..4718ae0508953de4fb11fd15c060355aeda689b4 100644
|
| --- a/chrome/browser/profiles/profile_impl_io_data.cc
|
| +++ b/chrome/browser/profiles/profile_impl_io_data.cc
|
| @@ -31,7 +31,9 @@
|
| #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"
|
| @@ -51,6 +53,39 @@
|
|
|
| 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.
|
| +#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX)
|
| +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)) {
|
| @@ -394,7 +429,8 @@ void ProfileImplIOData::InitializeInternal(
|
| lazy_params_->restore_old_session_cookies,
|
| lazy_params_->special_storage_policy.get(),
|
| profile_params->cookie_monster_delegate.get(),
|
| - scoped_refptr<base::SequencedTaskRunner>());
|
| + scoped_refptr<base::SequencedTaskRunner>(),
|
| + CreateCookieCryptoIfUseful());
|
| cookie_store->GetCookieMonster()->SetPersistSessionCookies(true);
|
| }
|
|
|
| @@ -492,7 +528,8 @@ void ProfileImplIOData::
|
| lazy_params_->restore_old_session_cookies,
|
| NULL,
|
| NULL,
|
| - scoped_refptr<base::SequencedTaskRunner>());
|
| + scoped_refptr<base::SequencedTaskRunner>(),
|
| + CreateCookieCryptoIfUseful());
|
| // Enable cookies for devtools and extension URLs.
|
| const char* schemes[] = {chrome::kChromeDevToolsScheme,
|
| extensions::kExtensionScheme};
|
| @@ -579,7 +616,8 @@ ProfileImplIOData::InitializeAppRequestContext(
|
| false,
|
| NULL,
|
| NULL,
|
| - scoped_refptr<base::SequencedTaskRunner>());
|
| + scoped_refptr<base::SequencedTaskRunner>(),
|
| + CreateCookieCryptoIfUseful());
|
| }
|
|
|
| // Transfer ownership of the cookies and cache to AppRequestContext.
|
|
|