| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "webkit/tools/test_shell/test_shell_request_context.h" | 5 #include "webkit/tools/test_shell/test_shell_request_context.h" |
| 6 | 6 |
| 7 #include "net/base/cookie_monster.h" | 7 #include "net/base/cookie_monster.h" |
| 8 #include "webkit/glue/webkit_glue.h" | 8 #include "webkit/glue/webkit_glue.h" |
| 9 | 9 |
| 10 TestShellRequestContext::TestShellRequestContext() { | 10 TestShellRequestContext::TestShellRequestContext() { |
| 11 Init(std::wstring(), net::HttpCache::NORMAL); | 11 Init(std::wstring(), net::HttpCache::NORMAL); |
| 12 } | 12 } |
| 13 | 13 |
| 14 TestShellRequestContext::TestShellRequestContext( | 14 TestShellRequestContext::TestShellRequestContext( |
| 15 const std::wstring& cache_path, | 15 const std::wstring& cache_path, |
| 16 net::HttpCache::Mode cache_mode) { | 16 net::HttpCache::Mode cache_mode) { |
| 17 Init(cache_path, cache_mode); | 17 Init(cache_path, cache_mode); |
| 18 } | 18 } |
| 19 | 19 |
| 20 void TestShellRequestContext::Init( | 20 void TestShellRequestContext::Init( |
| 21 const std::wstring& cache_path, | 21 const std::wstring& cache_path, |
| 22 net::HttpCache::Mode cache_mode) { | 22 net::HttpCache::Mode cache_mode) { |
| 23 cookie_store_ = new net::CookieMonster(); | 23 cookie_store_ = new net::CookieMonster(); |
| 24 | 24 |
| 25 user_agent_ = webkit_glue::GetUserAgent(); | |
| 26 | |
| 27 // hard-code A-L and A-C for test shells | 25 // hard-code A-L and A-C for test shells |
| 28 accept_language_ = "en-us,en"; | 26 accept_language_ = "en-us,en"; |
| 29 accept_charset_ = "iso-8859-1,*,utf-8"; | 27 accept_charset_ = "iso-8859-1,*,utf-8"; |
| 30 | 28 |
| 31 net::HttpCache *cache; | 29 net::HttpCache *cache; |
| 32 if (cache_path.empty()) { | 30 if (cache_path.empty()) { |
| 33 cache = new net::HttpCache(NULL, 0); | 31 cache = new net::HttpCache(NULL, 0); |
| 34 } else { | 32 } else { |
| 35 cache = new net::HttpCache(NULL, cache_path, 0); | 33 cache = new net::HttpCache(NULL, cache_path, 0); |
| 36 } | 34 } |
| 37 cache->set_mode(cache_mode); | 35 cache->set_mode(cache_mode); |
| 38 http_transaction_factory_ = cache; | 36 http_transaction_factory_ = cache; |
| 39 } | 37 } |
| 40 | 38 |
| 41 TestShellRequestContext::~TestShellRequestContext() { | 39 TestShellRequestContext::~TestShellRequestContext() { |
| 42 delete cookie_store_; | 40 delete cookie_store_; |
| 43 delete http_transaction_factory_; | 41 delete http_transaction_factory_; |
| 44 } | 42 } |
| 45 | 43 |
| 44 const std::string& TestShellRequestContext::GetUserAgent( |
| 45 const GURL& url) const { |
| 46 return webkit_glue::GetUserAgent(url); |
| 47 } |
| OLD | NEW |