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 "chrome/browser/net/chrome_url_request_context.h" | 5 #include "chrome/browser/net/chrome_url_request_context.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/chrome_thread.h" | 10 #include "chrome/browser/chrome_thread.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 context->http_transaction_factory_ = | 87 context->http_transaction_factory_ = |
88 new net::HttpCache(context->proxy_service_, 0); | 88 new net::HttpCache(context->proxy_service_, 0); |
89 context->cookie_store_ = new net::CookieMonster; | 89 context->cookie_store_ = new net::CookieMonster; |
90 | 90 |
91 return context; | 91 return context; |
92 } | 92 } |
93 | 93 |
94 ChromeURLRequestContext::ChromeURLRequestContext(Profile* profile) | 94 ChromeURLRequestContext::ChromeURLRequestContext(Profile* profile) |
95 : prefs_(profile->GetPrefs()), | 95 : prefs_(profile->GetPrefs()), |
96 is_off_the_record_(profile->IsOffTheRecord()) { | 96 is_off_the_record_(profile->IsOffTheRecord()) { |
97 user_agent_ = webkit_glue::GetUserAgent(); | |
98 | |
99 // Set up Accept-Language and Accept-Charset header values | 97 // Set up Accept-Language and Accept-Charset header values |
100 accept_language_ = net::HttpUtil::GenerateAcceptLanguageHeader( | 98 accept_language_ = net::HttpUtil::GenerateAcceptLanguageHeader( |
101 WideToASCII(prefs_->GetString(prefs::kAcceptLanguages))); | 99 WideToASCII(prefs_->GetString(prefs::kAcceptLanguages))); |
102 accept_charset_ = net::HttpUtil::GenerateAcceptCharsetHeader( | 100 accept_charset_ = net::HttpUtil::GenerateAcceptCharsetHeader( |
103 WideToASCII(prefs_->GetString(prefs::kDefaultCharset))); | 101 WideToASCII(prefs_->GetString(prefs::kDefaultCharset))); |
104 | 102 |
105 cookie_policy_.SetType(net::CookiePolicy::FromInt( | 103 cookie_policy_.SetType(net::CookiePolicy::FromInt( |
106 prefs_->GetInteger(prefs::kCookieBehavior))); | 104 prefs_->GetInteger(prefs::kCookieBehavior))); |
107 | 105 |
108 if (profile->GetExtensionsService()) { | 106 if (profile->GetExtensionsService()) { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 174 |
177 FilePath ChromeURLRequestContext::GetPathForExtension(const std::string& id) { | 175 FilePath ChromeURLRequestContext::GetPathForExtension(const std::string& id) { |
178 ExtensionPaths::iterator iter = extension_paths_.find(id); | 176 ExtensionPaths::iterator iter = extension_paths_.find(id); |
179 if (iter != extension_paths_.end()) { | 177 if (iter != extension_paths_.end()) { |
180 return iter->second; | 178 return iter->second; |
181 } else { | 179 } else { |
182 return FilePath(); | 180 return FilePath(); |
183 } | 181 } |
184 } | 182 } |
185 | 183 |
186 void ChromeURLRequestContext::OnAcceptLanguageChange(std::string accept_language
) { | 184 const std::string& ChromeURLRequestContext::GetUserAgent( |
| 185 const GURL& url) const { |
| 186 return webkit_glue::GetUserAgent(url); |
| 187 } |
| 188 |
| 189 void ChromeURLRequestContext::OnAcceptLanguageChange( |
| 190 std::string accept_language) { |
187 DCHECK(MessageLoop::current() == | 191 DCHECK(MessageLoop::current() == |
188 ChromeThread::GetMessageLoop(ChromeThread::IO)); | 192 ChromeThread::GetMessageLoop(ChromeThread::IO)); |
189 accept_language_ = | 193 accept_language_ = |
190 net::HttpUtil::GenerateAcceptLanguageHeader(accept_language); | 194 net::HttpUtil::GenerateAcceptLanguageHeader(accept_language); |
191 } | 195 } |
192 | 196 |
193 void ChromeURLRequestContext::OnCookiePolicyChange(net::CookiePolicy::Type type)
{ | 197 void ChromeURLRequestContext::OnCookiePolicyChange( |
| 198 net::CookiePolicy::Type type) { |
194 DCHECK(MessageLoop::current() == | 199 DCHECK(MessageLoop::current() == |
195 ChromeThread::GetMessageLoop(ChromeThread::IO)); | 200 ChromeThread::GetMessageLoop(ChromeThread::IO)); |
196 cookie_policy_.SetType(type); | 201 cookie_policy_.SetType(type); |
197 } | 202 } |
198 | 203 |
199 void ChromeURLRequestContext::OnNewExtensions(ExtensionPaths* new_paths) { | 204 void ChromeURLRequestContext::OnNewExtensions(ExtensionPaths* new_paths) { |
200 extension_paths_.insert(new_paths->begin(), new_paths->end()); | 205 extension_paths_.insert(new_paths->begin(), new_paths->end()); |
201 delete new_paths; | 206 delete new_paths; |
202 } | 207 } |
203 | 208 |
204 ChromeURLRequestContext::~ChromeURLRequestContext() { | 209 ChromeURLRequestContext::~ChromeURLRequestContext() { |
205 DCHECK(NULL == prefs_); | 210 DCHECK(NULL == prefs_); |
206 | 211 |
207 NotificationService::current()->Notify(NOTIFY_URL_REQUEST_CONTEXT_RELEASED, | 212 NotificationService::current()->Notify(NOTIFY_URL_REQUEST_CONTEXT_RELEASED, |
208 Source<URLRequestContext>(this), | 213 Source<URLRequestContext>(this), |
209 NotificationService::NoDetails()); | 214 NotificationService::NoDetails()); |
210 | 215 |
211 delete cookie_store_; | 216 delete cookie_store_; |
212 delete http_transaction_factory_; | 217 delete http_transaction_factory_; |
213 | 218 |
214 // Do not delete the proxy service in the case of OTR, as it is owned by the | 219 // Do not delete the proxy service in the case of OTR, as it is owned by the |
215 // original URLRequestContext. | 220 // original URLRequestContext. |
216 if (!is_off_the_record_) | 221 if (!is_off_the_record_) |
217 delete proxy_service_; | 222 delete proxy_service_; |
218 } | 223 } |
OLD | NEW |