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 216ad8cf469e83ee5a1fe8fc6ff9b9c38309d61a..639f541de8ff81e5103a1dcd0522ca5193576357 100644 |
--- a/chrome/browser/profiles/profile_impl_io_data.cc |
+++ b/chrome/browser/profiles/profile_impl_io_data.cc |
@@ -31,6 +31,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_store_factory.h" |
#include "content/public/browser/notification_service.h" |
@@ -49,8 +50,35 @@ |
#include "chrome/app/android/chrome_data_reduction_proxy_android.h" |
#endif |
+// On operating systems that support an encryption API but don't |
+// automatically protect all user data, encrypt the cookie. |
+#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) |
+#define CRYPT_COOKIES |
+#endif |
+ |
namespace { |
+#if defined(CRYPT_COOKIES) |
+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); |
+} |
+#endif // CRYPT_COOKIES |
+ |
+ |
net::BackendType ChooseCacheBackendType() { |
const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
if (command_line.HasSwitch(switches::kUseSimpleCacheBackend)) { |
@@ -389,7 +417,13 @@ 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>(), |
+#if defined(CRYPT_COOKIES) |
+ new CookieOSCryptoDelegate |
+#else |
+ NULL |
+#endif |
+ ); |
cookie_store->GetCookieMonster()->SetPersistSessionCookies(true); |
} |
@@ -485,7 +519,13 @@ void ProfileImplIOData:: |
lazy_params_->restore_old_session_cookies, |
NULL, |
NULL, |
- scoped_refptr<base::SequencedTaskRunner>()); |
+ scoped_refptr<base::SequencedTaskRunner>(), |
+#if defined(CRYPT_COOKIES) |
+ new CookieOSCryptoDelegate |
+#else |
+ NULL |
+#endif |
+ ); |
// Enable cookies for devtools and extension URLs. |
const char* schemes[] = {chrome::kChromeDevToolsScheme, |
extensions::kExtensionScheme}; |
@@ -572,7 +612,13 @@ ProfileImplIOData::InitializeAppRequestContext( |
false, |
NULL, |
NULL, |
- scoped_refptr<base::SequencedTaskRunner>()); |
+ scoped_refptr<base::SequencedTaskRunner>(), |
+#if defined(CRYPT_COOKIES) |
+ new CookieOSCryptoDelegate |
+#else |
+ NULL |
+#endif |
+ ); |
} |
// Transfer ownership of the cookies and cache to AppRequestContext. |