OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/net/cookie_store_util.h" | 5 #include "chrome/browser/net/cookie_store_util.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 base::Bind(&GetProfileOnUI, g_browser_process->profile_manager(), | 37 base::Bind(&GetProfileOnUI, g_browser_process->profile_manager(), |
38 profile)) { | 38 profile)) { |
39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
40 DCHECK(profile); | 40 DCHECK(profile); |
41 } | 41 } |
42 | 42 |
43 // net::CookieMonster::Delegate implementation. | 43 // net::CookieMonster::Delegate implementation. |
44 virtual void OnCookieChanged( | 44 virtual void OnCookieChanged( |
45 const net::CanonicalCookie& cookie, | 45 const net::CanonicalCookie& cookie, |
46 bool removed, | 46 bool removed, |
47 net::CookieMonster::Delegate::ChangeCause cause) OVERRIDE { | 47 net::CookieMonster::Delegate::ChangeCause cause) override { |
48 BrowserThread::PostTask( | 48 BrowserThread::PostTask( |
49 BrowserThread::UI, FROM_HERE, | 49 BrowserThread::UI, FROM_HERE, |
50 base::Bind(&ChromeCookieMonsterDelegate::OnCookieChangedAsyncHelper, | 50 base::Bind(&ChromeCookieMonsterDelegate::OnCookieChangedAsyncHelper, |
51 this, cookie, removed, cause)); | 51 this, cookie, removed, cause)); |
52 } | 52 } |
53 | 53 |
54 virtual void OnLoaded() OVERRIDE { | 54 virtual void OnLoaded() override { |
55 BrowserThread::PostTask( | 55 BrowserThread::PostTask( |
56 BrowserThread::UI, FROM_HERE, | 56 BrowserThread::UI, FROM_HERE, |
57 base::Bind(&ChromeCookieMonsterDelegate::OnLoadedAsyncHelper, | 57 base::Bind(&ChromeCookieMonsterDelegate::OnLoadedAsyncHelper, |
58 this)); | 58 this)); |
59 } | 59 } |
60 | 60 |
61 private: | 61 private: |
62 virtual ~ChromeCookieMonsterDelegate() {} | 62 virtual ~ChromeCookieMonsterDelegate() {} |
63 | 63 |
64 static Profile* GetProfileOnUI(ProfileManager* profile_manager, | 64 static Profile* GetProfileOnUI(ProfileManager* profile_manager, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 123 |
124 // Use the operating system's mechanisms to encrypt cookies before writing | 124 // Use the operating system's mechanisms to encrypt cookies before writing |
125 // them to persistent store. Currently this only is done with desktop OS's | 125 // them to persistent store. Currently this only is done with desktop OS's |
126 // because ChromeOS and Android already protect the entire profile contents. | 126 // because ChromeOS and Android already protect the entire profile contents. |
127 // | 127 // |
128 // TODO(bcwhite): Enable on MACOSX -- requires all Cookie tests to call | 128 // TODO(bcwhite): Enable on MACOSX -- requires all Cookie tests to call |
129 // OSCrypt::UseMockKeychain or will hang waiting for user input. | 129 // OSCrypt::UseMockKeychain or will hang waiting for user input. |
130 class CookieOSCryptoDelegate : public content::CookieCryptoDelegate { | 130 class CookieOSCryptoDelegate : public content::CookieCryptoDelegate { |
131 public: | 131 public: |
132 virtual bool EncryptString(const std::string& plaintext, | 132 virtual bool EncryptString(const std::string& plaintext, |
133 std::string* ciphertext) OVERRIDE; | 133 std::string* ciphertext) override; |
134 virtual bool DecryptString(const std::string& ciphertext, | 134 virtual bool DecryptString(const std::string& ciphertext, |
135 std::string* plaintext) OVERRIDE; | 135 std::string* plaintext) override; |
136 }; | 136 }; |
137 | 137 |
138 bool CookieOSCryptoDelegate::EncryptString(const std::string& plaintext, | 138 bool CookieOSCryptoDelegate::EncryptString(const std::string& plaintext, |
139 std::string* ciphertext) { | 139 std::string* ciphertext) { |
140 return OSCrypt::EncryptString(plaintext, ciphertext); | 140 return OSCrypt::EncryptString(plaintext, ciphertext); |
141 } | 141 } |
142 | 142 |
143 bool CookieOSCryptoDelegate::DecryptString(const std::string& ciphertext, | 143 bool CookieOSCryptoDelegate::DecryptString(const std::string& ciphertext, |
144 std::string* plaintext) { | 144 std::string* plaintext) { |
145 return OSCrypt::DecryptString(ciphertext, plaintext); | 145 return OSCrypt::DecryptString(ciphertext, plaintext); |
146 } | 146 } |
147 | 147 |
148 // Using a LazyInstance is safe here because this class is stateless and | 148 // Using a LazyInstance is safe here because this class is stateless and |
149 // requires 0 initialization. | 149 // requires 0 initialization. |
150 base::LazyInstance<CookieOSCryptoDelegate> g_cookie_crypto_delegate = | 150 base::LazyInstance<CookieOSCryptoDelegate> g_cookie_crypto_delegate = |
151 LAZY_INSTANCE_INITIALIZER; | 151 LAZY_INSTANCE_INITIALIZER; |
152 | 152 |
153 } // namespace | 153 } // namespace |
154 | 154 |
155 content::CookieCryptoDelegate* GetCookieCryptoDelegate() { | 155 content::CookieCryptoDelegate* GetCookieCryptoDelegate() { |
156 return g_cookie_crypto_delegate.Pointer(); | 156 return g_cookie_crypto_delegate.Pointer(); |
157 } | 157 } |
158 #else // defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) | 158 #else // defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) |
159 content::CookieCryptoDelegate* GetCookieCryptoDelegate() { | 159 content::CookieCryptoDelegate* GetCookieCryptoDelegate() { |
160 return NULL; | 160 return NULL; |
161 } | 161 } |
162 #endif // defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) | 162 #endif // defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) |
163 | 163 |
164 } // namespace chrome_browser_net | 164 } // namespace chrome_browser_net |
OLD | NEW |