| 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/prefs/pref_service.h" | |
| 14 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 15 #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" |
| 16 #include "chrome/common/chrome_notification_types.h" | 16 #include "chrome/common/chrome_notification_types.h" |
| 17 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 18 #include "content/browser/browser_thread.h" | 18 #include "content/browser/browser_thread.h" |
| 19 #include "content/common/notification_service.h" | 19 #include "content/common/notification_service.h" |
| 20 #include "net/base/cookie_store.h" | 20 #include "net/base/cookie_store.h" |
| 21 #include "net/ftp/ftp_transaction_factory.h" |
| 22 #include "net/http/http_transaction_factory.h" |
| 21 #include "net/http/http_util.h" | 23 #include "net/http/http_util.h" |
| 22 #include "webkit/glue/webkit_glue.h" | 24 #include "webkit/glue/webkit_glue.h" |
| 23 | 25 |
| 24 class ChromeURLRequestContextFactory { | 26 class ChromeURLRequestContextFactory { |
| 25 public: | 27 public: |
| 26 ChromeURLRequestContextFactory() {} | 28 ChromeURLRequestContextFactory() {} |
| 27 virtual ~ChromeURLRequestContextFactory() {} | 29 virtual ~ChromeURLRequestContextFactory() {} |
| 28 | 30 |
| 29 // Called to create a new instance (will only be called once). | 31 // Called to create a new instance (will only be called once). |
| 30 virtual scoped_refptr<ChromeURLRequestContext> Create() = 0; | 32 virtual scoped_refptr<ChromeURLRequestContext> Create() = 0; |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 ChromeURLRequestContext::ChromeURLRequestContext() | 356 ChromeURLRequestContext::ChromeURLRequestContext() |
| 355 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)), | 357 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)), |
| 356 is_incognito_(false) { | 358 is_incognito_(false) { |
| 357 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 359 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 358 } | 360 } |
| 359 | 361 |
| 360 void ChromeURLRequestContext::CopyFrom(ChromeURLRequestContext* other) { | 362 void ChromeURLRequestContext::CopyFrom(ChromeURLRequestContext* other) { |
| 361 URLRequestContext::CopyFrom(other); | 363 URLRequestContext::CopyFrom(other); |
| 362 | 364 |
| 363 // Copy ChromeURLRequestContext parameters. | 365 // Copy ChromeURLRequestContext parameters. |
| 366 set_appcache_service(other->appcache_service()); |
| 367 set_blob_storage_context(other->blob_storage_context()); |
| 368 set_file_system_context(other->file_system_context()); |
| 369 set_extension_info_map(other->extension_info_map_); |
| 364 // ChromeURLDataManagerBackend is unique per context. | 370 // ChromeURLDataManagerBackend is unique per context. |
| 365 set_is_incognito(other->is_incognito()); | 371 set_is_incognito(other->is_incognito()); |
| 366 } | 372 } |
| 367 | 373 |
| 368 ChromeURLDataManagerBackend* | 374 ChromeURLDataManagerBackend* |
| 369 ChromeURLRequestContext::chrome_url_data_manager_backend() const { | 375 ChromeURLRequestContext::chrome_url_data_manager_backend() const { |
| 370 return chrome_url_data_manager_backend_; | 376 return chrome_url_data_manager_backend_; |
| 371 } | 377 } |
| 372 | 378 |
| 373 void ChromeURLRequestContext::set_chrome_url_data_manager_backend( | 379 void ChromeURLRequestContext::set_chrome_url_data_manager_backend( |
| 374 ChromeURLDataManagerBackend* backend) { | 380 ChromeURLDataManagerBackend* backend) { |
| 375 DCHECK(backend); | 381 DCHECK(backend); |
| 376 chrome_url_data_manager_backend_ = backend; | 382 chrome_url_data_manager_backend_ = backend; |
| 377 } | 383 } |
| 378 | 384 |
| 379 ChromeURLRequestContext::~ChromeURLRequestContext() { | 385 ChromeURLRequestContext::~ChromeURLRequestContext() { |
| 380 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 386 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 381 | 387 |
| 388 if (appcache_service_.get() && appcache_service_->request_context() == this) |
| 389 appcache_service_->set_request_context(NULL); |
| 390 |
| 382 NotificationService::current()->Notify( | 391 NotificationService::current()->Notify( |
| 383 chrome::NOTIFICATION_URL_REQUEST_CONTEXT_RELEASED, | 392 chrome::NOTIFICATION_URL_REQUEST_CONTEXT_RELEASED, |
| 384 Source<net::URLRequestContext>(this), | 393 Source<net::URLRequestContext>(this), |
| 385 NotificationService::NoDetails()); | 394 NotificationService::NoDetails()); |
| 386 } | 395 } |
| 387 | 396 |
| 388 const std::string& ChromeURLRequestContext::GetUserAgent( | 397 const std::string& ChromeURLRequestContext::GetUserAgent( |
| 389 const GURL& url) const { | 398 const GURL& url) const { |
| 390 return webkit_glue::GetUserAgent(url); | 399 return webkit_glue::GetUserAgent(url); |
| 391 } | 400 } |
| 392 | 401 |
| 393 void ChromeURLRequestContext::OnAcceptLanguageChange( | 402 void ChromeURLRequestContext::OnAcceptLanguageChange( |
| 394 const std::string& accept_language) { | 403 const std::string& accept_language) { |
| 395 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 404 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 396 set_accept_language( | 405 set_accept_language( |
| 397 net::HttpUtil::GenerateAcceptLanguageHeader(accept_language)); | 406 net::HttpUtil::GenerateAcceptLanguageHeader(accept_language)); |
| 398 } | 407 } |
| 399 | 408 |
| 400 void ChromeURLRequestContext::OnDefaultCharsetChange( | 409 void ChromeURLRequestContext::OnDefaultCharsetChange( |
| 401 const std::string& default_charset) { | 410 const std::string& default_charset) { |
| 402 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 411 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 403 set_referrer_charset(default_charset); | 412 set_referrer_charset(default_charset); |
| 404 set_accept_charset( | 413 set_accept_charset( |
| 405 net::HttpUtil::GenerateAcceptCharsetHeader(default_charset)); | 414 net::HttpUtil::GenerateAcceptCharsetHeader(default_charset)); |
| 406 } | 415 } |
| OLD | NEW |