| 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 "net/proxy/proxy_service.h" | 8 #include "net/proxy/proxy_service.h" |
| 9 #include "webkit/glue/webkit_glue.h" | 9 #include "webkit/glue/webkit_glue.h" |
| 10 | 10 |
| 11 TestShellRequestContext::TestShellRequestContext() { | 11 TestShellRequestContext::TestShellRequestContext() { |
| 12 Init(std::wstring(), net::HttpCache::NORMAL, false); | 12 Init(std::wstring(), net::HttpCache::NORMAL, false); |
| 13 } | 13 } |
| 14 | 14 |
| 15 TestShellRequestContext::TestShellRequestContext( | 15 TestShellRequestContext::TestShellRequestContext( |
| 16 const std::wstring& cache_path, | 16 const std::wstring& cache_path, |
| 17 net::HttpCache::Mode cache_mode, | 17 net::HttpCache::Mode cache_mode, |
| 18 bool no_proxy) { | 18 bool no_proxy) { |
| 19 Init(cache_path, cache_mode, no_proxy); | 19 Init(cache_path, cache_mode, no_proxy); |
| 20 } | 20 } |
| 21 | 21 |
| 22 void TestShellRequestContext::Init( | 22 void TestShellRequestContext::Init( |
| 23 const std::wstring& cache_path, | 23 const std::wstring& cache_path, |
| 24 net::HttpCache::Mode cache_mode, | 24 net::HttpCache::Mode cache_mode, |
| 25 bool no_proxy) { | 25 bool no_proxy) { |
| 26 cookie_store_ = new net::CookieMonster(); | 26 cookie_store_ = new net::CookieMonster(); |
| 27 | 27 |
| 28 user_agent_ = webkit_glue::GetUserAgent(); | |
| 29 | |
| 30 // hard-code A-L and A-C for test shells | 28 // hard-code A-L and A-C for test shells |
| 31 accept_language_ = "en-us,en"; | 29 accept_language_ = "en-us,en"; |
| 32 accept_charset_ = "iso-8859-1,*,utf-8"; | 30 accept_charset_ = "iso-8859-1,*,utf-8"; |
| 33 | 31 |
| 34 net::ProxyInfo proxy_info; | 32 net::ProxyInfo proxy_info; |
| 35 proxy_info.UseDirect(); | 33 proxy_info.UseDirect(); |
| 36 proxy_service_ = net::ProxyService::Create(no_proxy ? &proxy_info : NULL); | 34 proxy_service_ = net::ProxyService::Create(no_proxy ? &proxy_info : NULL); |
| 37 | 35 |
| 38 net::HttpCache *cache; | 36 net::HttpCache *cache; |
| 39 if (cache_path.empty()) { | 37 if (cache_path.empty()) { |
| 40 cache = new net::HttpCache(proxy_service_, 0); | 38 cache = new net::HttpCache(proxy_service_, 0); |
| 41 } else { | 39 } else { |
| 42 cache = new net::HttpCache(proxy_service_, cache_path, 0); | 40 cache = new net::HttpCache(proxy_service_, cache_path, 0); |
| 43 } | 41 } |
| 44 cache->set_mode(cache_mode); | 42 cache->set_mode(cache_mode); |
| 45 http_transaction_factory_ = cache; | 43 http_transaction_factory_ = cache; |
| 46 } | 44 } |
| 47 | 45 |
| 48 TestShellRequestContext::~TestShellRequestContext() { | 46 TestShellRequestContext::~TestShellRequestContext() { |
| 49 delete cookie_store_; | 47 delete cookie_store_; |
| 50 delete http_transaction_factory_; | 48 delete http_transaction_factory_; |
| 51 delete proxy_service_; | 49 delete proxy_service_; |
| 52 } | 50 } |
| 53 | 51 |
| 52 const std::string& TestShellRequestContext::GetUserAgent( |
| 53 const GURL& url) const { |
| 54 return webkit_glue::GetUserAgent(url); |
| 55 } |
| OLD | NEW |