Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // CookieAccountant implementation. | 5 // CookieAccountant implementation. |
| 6 #include "ceee/ie/plugin/bho/cookie_accountant.h" | 6 #include "ceee/ie/plugin/bho/cookie_accountant.h" |
| 7 | 7 |
| 8 #include <atlbase.h> | 8 #include <atlbase.h> |
| 9 #include <wininet.h> | 9 #include <wininet.h> |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 static const wchar_t kMsHtmlModuleName[] = L"mshtml.dll"; | 28 static const wchar_t kMsHtmlModuleName[] = L"mshtml.dll"; |
| 29 static const char kWinInetModuleName[] = "wininet.dll"; | 29 static const char kWinInetModuleName[] = "wininet.dll"; |
| 30 static const char kInternetSetCookieExAFunctionName[] = "InternetSetCookieExA"; | 30 static const char kInternetSetCookieExAFunctionName[] = "InternetSetCookieExA"; |
| 31 static const char kInternetSetCookieExWFunctionName[] = "InternetSetCookieExW"; | 31 static const char kInternetSetCookieExWFunctionName[] = "InternetSetCookieExW"; |
| 32 | 32 |
| 33 } // namespace | 33 } // namespace |
| 34 | 34 |
| 35 CookieAccountant* CookieAccountant::singleton_instance_ = NULL; | 35 CookieAccountant* CookieAccountant::singleton_instance_ = NULL; |
| 36 | 36 |
| 37 CookieAccountant::~CookieAccountant() { | 37 CookieAccountant::~CookieAccountant() { |
| 38 AutoLock lock(lock_); | |
|
MAD
2010/11/30 22:35:55
I don't think a lock is necessary in the destructo
Cindy Lau
2010/12/01 01:33:15
Done.
| |
| 38 if (internet_set_cookie_ex_a_patch_.is_patched()) | 39 if (internet_set_cookie_ex_a_patch_.is_patched()) |
| 39 internet_set_cookie_ex_a_patch_.Unpatch(); | 40 internet_set_cookie_ex_a_patch_.Unpatch(); |
| 40 if (internet_set_cookie_ex_w_patch_.is_patched()) | 41 if (internet_set_cookie_ex_w_patch_.is_patched()) |
| 41 internet_set_cookie_ex_w_patch_.Unpatch(); | 42 internet_set_cookie_ex_w_patch_.Unpatch(); |
| 42 } | 43 } |
| 43 | 44 |
| 44 ProductionCookieAccountant::ProductionCookieAccountant() { | 45 ProductionCookieAccountant::ProductionCookieAccountant() { |
| 45 } | 46 } |
| 46 | 47 |
| 47 CookieAccountant* CookieAccountant::GetInstance() { | 48 CookieAccountant* CookieAccountant::GetInstance() { |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 continue; // Skip non-cookie headers. | 216 continue; // Skip non-cookie headers. |
| 216 std::string cookie_data = header_line.substr( | 217 std::string cookie_data = header_line.substr( |
| 217 name_pos + std::string(kSetCookieHeaderName).size()); | 218 name_pos + std::string(kSetCookieHeaderName).size()); |
| 218 // TODO(cindylau@chromium.org): Get the URL for the HTTP request from | 219 // TODO(cindylau@chromium.org): Get the URL for the HTTP request from |
| 219 // IHttpNegotiate::BeginningTransaction. | 220 // IHttpNegotiate::BeginningTransaction. |
| 220 RecordCookie(std::string(), cookie_data, current_time); | 221 RecordCookie(std::string(), cookie_data, current_time); |
| 221 } | 222 } |
| 222 } | 223 } |
| 223 | 224 |
| 224 void CookieAccountant::PatchWininetFunctions() { | 225 void CookieAccountant::PatchWininetFunctions() { |
| 226 AutoLock lock(lock_); | |
|
MAD
2010/11/30 22:35:55
I don't think it's a good idea to call Patch from
Cindy Lau
2010/12/01 01:33:15
Okay, I rewrote it not to block other threads comi
MAD
2010/12/01 02:14:43
I think the chances are pretty slim since IE still
Sigurður Ásgeirsson
2010/12/01 14:36:40
is_patched() is an inline accessor to a pointer, w
| |
| 225 if (!internet_set_cookie_ex_a_patch_.is_patched()) { | 227 if (!internet_set_cookie_ex_a_patch_.is_patched()) { |
| 226 DWORD error = internet_set_cookie_ex_a_patch_.Patch( | 228 DWORD error = internet_set_cookie_ex_a_patch_.Patch( |
| 227 kMsHtmlModuleName, kWinInetModuleName, | 229 kMsHtmlModuleName, kWinInetModuleName, |
| 228 kInternetSetCookieExAFunctionName, InternetSetCookieExAPatch); | 230 kInternetSetCookieExAFunctionName, InternetSetCookieExAPatch); |
| 229 DCHECK(error == NO_ERROR || !internet_set_cookie_ex_a_patch_.is_patched()); | 231 DCHECK(error == NO_ERROR || !internet_set_cookie_ex_a_patch_.is_patched()); |
| 230 } | 232 } |
| 231 if (!internet_set_cookie_ex_w_patch_.is_patched()) { | 233 if (!internet_set_cookie_ex_w_patch_.is_patched()) { |
| 232 DWORD error = internet_set_cookie_ex_w_patch_.Patch( | 234 DWORD error = internet_set_cookie_ex_w_patch_.Patch( |
| 233 kMsHtmlModuleName, kWinInetModuleName, | 235 kMsHtmlModuleName, kWinInetModuleName, |
| 234 kInternetSetCookieExWFunctionName, InternetSetCookieExWPatch); | 236 kInternetSetCookieExWFunctionName, InternetSetCookieExWPatch); |
| 235 DCHECK(error == NO_ERROR || !internet_set_cookie_ex_w_patch_.is_patched()); | 237 DCHECK(error == NO_ERROR || !internet_set_cookie_ex_w_patch_.is_patched()); |
| 236 } | 238 } |
| 237 DCHECK(internet_set_cookie_ex_a_patch_.is_patched() || | 239 DCHECK(internet_set_cookie_ex_a_patch_.is_patched() || |
| 238 internet_set_cookie_ex_w_patch_.is_patched()); | 240 internet_set_cookie_ex_w_patch_.is_patched()); |
| 239 } | 241 } |
| OLD | NEW |