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