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