| 284 | } |
| 285 | |
| 286 | std::string CookieManager::ReadCookieFile(const std::wstring& file_name) { |
| 287 | LOG(TRACE) << "Entering CookieManager::ReadCookieFile"; |
| 288 | HANDLE file_handle = ::CreateFile(file_name.c_str(), |
| 289 | GENERIC_READ, |
| 290 | FILE_SHARE_READ | FILE_SHARE_WRITE, |
| 291 | NULL, |
| 292 | OPEN_EXISTING, |
| 293 | 0, |
| 294 | NULL); |
| 295 | // Read the cookie file. Hopefully, we will never have a 2GB cookie file. |
| 296 | DWORD file_size_high = 0; |
| 297 | DWORD file_size_low = ::GetFileSize(file_handle, &file_size_high); |
| 298 | std::vector<char> file_content(file_size_low + 1); |
| 299 | DWORD bytes_read = 0; |
| 300 | ::ReadFile(file_handle, &file_content[0], file_size_low, &bytes_read, NULL); |
| 301 | ::CloseHandle(file_handle); |
| 302 | |
| 303 | // Null-terminate and convert to a string for easier manipulation. |
| 304 | file_content[bytes_read - 1] = '\0'; |
| 305 | std::string cookie_file_contents = &file_content[0]; |
| 306 | return cookie_file_contents; |
| 307 | } |
| 308 | |
| 309 | void CookieManager::ParseCookieList(const std::string& cookie_file_contents, |
| 310 | const bool include_secure_cookies, |