| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
| 10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/io_thread.h" | 12 #include "chrome/browser/io_thread.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/profiles/profile_io_data.h" | 14 #include "chrome/browser/profiles/profile_io_data.h" |
| 15 #include "chrome/browser/ui/webui/chrome_url_data_manager_backend.h" | 15 #include "chrome/browser/ui/webui/chrome_url_data_manager_backend.h" |
| 16 #include "chrome/common/chrome_notification_types.h" |
| 16 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 17 #include "content/browser/browser_thread.h" | 18 #include "content/browser/browser_thread.h" |
| 18 #include "content/common/notification_service.h" | 19 #include "content/common/notification_service.h" |
| 19 #include "net/base/cookie_store.h" | 20 #include "net/base/cookie_store.h" |
| 20 #include "net/ftp/ftp_transaction_factory.h" | 21 #include "net/ftp/ftp_transaction_factory.h" |
| 21 #include "net/http/http_transaction_factory.h" | 22 #include "net/http/http_transaction_factory.h" |
| 22 #include "net/http/http_util.h" | 23 #include "net/http/http_util.h" |
| 23 #include "webkit/glue/webkit_glue.h" | 24 #include "webkit/glue/webkit_glue.h" |
| 24 | 25 |
| 25 class ChromeURLRequestContextFactory { | 26 class ChromeURLRequestContextFactory { |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 | 267 |
| 267 void ChromeURLRequestContextGetter::CleanupOnUIThread() { | 268 void ChromeURLRequestContextGetter::CleanupOnUIThread() { |
| 268 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 269 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 269 // Unregister for pref notifications. | 270 // Unregister for pref notifications. |
| 270 DCHECK(!registrar_.IsEmpty()) << "Called more than once!"; | 271 DCHECK(!registrar_.IsEmpty()) << "Called more than once!"; |
| 271 registrar_.RemoveAll(); | 272 registrar_.RemoveAll(); |
| 272 } | 273 } |
| 273 | 274 |
| 274 // NotificationObserver implementation. | 275 // NotificationObserver implementation. |
| 275 void ChromeURLRequestContextGetter::Observe( | 276 void ChromeURLRequestContextGetter::Observe( |
| 276 NotificationType type, | 277 int type, |
| 277 const NotificationSource& source, | 278 const NotificationSource& source, |
| 278 const NotificationDetails& details) { | 279 const NotificationDetails& details) { |
| 279 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 280 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 280 | 281 |
| 281 if (NotificationType::PREF_CHANGED == type) { | 282 if (chrome::NOTIFICATION_PREF_CHANGED == type) { |
| 282 std::string* pref_name_in = Details<std::string>(details).ptr(); | 283 std::string* pref_name_in = Details<std::string>(details).ptr(); |
| 283 PrefService* prefs = Source<PrefService>(source).ptr(); | 284 PrefService* prefs = Source<PrefService>(source).ptr(); |
| 284 DCHECK(pref_name_in && prefs); | 285 DCHECK(pref_name_in && prefs); |
| 285 if (*pref_name_in == prefs::kAcceptLanguages) { | 286 if (*pref_name_in == prefs::kAcceptLanguages) { |
| 286 std::string accept_language = | 287 std::string accept_language = |
| 287 prefs->GetString(prefs::kAcceptLanguages); | 288 prefs->GetString(prefs::kAcceptLanguages); |
| 288 BrowserThread::PostTask( | 289 BrowserThread::PostTask( |
| 289 BrowserThread::IO, FROM_HERE, | 290 BrowserThread::IO, FROM_HERE, |
| 290 NewRunnableMethod( | 291 NewRunnableMethod( |
| 291 this, | 292 this, |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 chrome_url_data_manager_backend_ = backend; | 382 chrome_url_data_manager_backend_ = backend; |
| 382 } | 383 } |
| 383 | 384 |
| 384 ChromeURLRequestContext::~ChromeURLRequestContext() { | 385 ChromeURLRequestContext::~ChromeURLRequestContext() { |
| 385 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 386 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 386 | 387 |
| 387 if (appcache_service_.get() && appcache_service_->request_context() == this) | 388 if (appcache_service_.get() && appcache_service_->request_context() == this) |
| 388 appcache_service_->set_request_context(NULL); | 389 appcache_service_->set_request_context(NULL); |
| 389 | 390 |
| 390 NotificationService::current()->Notify( | 391 NotificationService::current()->Notify( |
| 391 NotificationType::URL_REQUEST_CONTEXT_RELEASED, | 392 chrome::NOTIFICATION_URL_REQUEST_CONTEXT_RELEASED, |
| 392 Source<net::URLRequestContext>(this), | 393 Source<net::URLRequestContext>(this), |
| 393 NotificationService::NoDetails()); | 394 NotificationService::NoDetails()); |
| 394 } | 395 } |
| 395 | 396 |
| 396 const std::string& ChromeURLRequestContext::GetUserAgent( | 397 const std::string& ChromeURLRequestContext::GetUserAgent( |
| 397 const GURL& url) const { | 398 const GURL& url) const { |
| 398 return webkit_glue::GetUserAgent(url); | 399 return webkit_glue::GetUserAgent(url); |
| 399 } | 400 } |
| 400 | 401 |
| 401 void ChromeURLRequestContext::OnAcceptLanguageChange( | 402 void ChromeURLRequestContext::OnAcceptLanguageChange( |
| 402 const std::string& accept_language) { | 403 const std::string& accept_language) { |
| 403 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 404 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 404 set_accept_language( | 405 set_accept_language( |
| 405 net::HttpUtil::GenerateAcceptLanguageHeader(accept_language)); | 406 net::HttpUtil::GenerateAcceptLanguageHeader(accept_language)); |
| 406 } | 407 } |
| 407 | 408 |
| 408 void ChromeURLRequestContext::OnDefaultCharsetChange( | 409 void ChromeURLRequestContext::OnDefaultCharsetChange( |
| 409 const std::string& default_charset) { | 410 const std::string& default_charset) { |
| 410 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 411 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 411 set_referrer_charset(default_charset); | 412 set_referrer_charset(default_charset); |
| 412 set_accept_charset( | 413 set_accept_charset( |
| 413 net::HttpUtil::GenerateAcceptCharsetHeader(default_charset)); | 414 net::HttpUtil::GenerateAcceptCharsetHeader(default_charset)); |
| 414 } | 415 } |
| OLD | NEW |