| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/profiles/profile_io_data.h" | 5 #include "chrome/browser/profiles/profile_io_data.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 } | 153 } |
| 154 | 154 |
| 155 } // namespace | 155 } // namespace |
| 156 | 156 |
| 157 void ProfileIOData::InitializeOnUIThread(Profile* profile) { | 157 void ProfileIOData::InitializeOnUIThread(Profile* profile) { |
| 158 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 158 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 159 PrefService* pref_service = profile->GetPrefs(); | 159 PrefService* pref_service = profile->GetPrefs(); |
| 160 | 160 |
| 161 scoped_ptr<ProfileParams> params(new ProfileParams); | 161 scoped_ptr<ProfileParams> params(new ProfileParams); |
| 162 params->path = profile->GetPath(); | 162 params->path = profile->GetPath(); |
| 163 params->is_incognito = profile->IsOffTheRecord(); | |
| 164 params->clear_local_state_on_exit = | 163 params->clear_local_state_on_exit = |
| 165 pref_service->GetBoolean(prefs::kClearSiteDataOnExit); | 164 pref_service->GetBoolean(prefs::kClearSiteDataOnExit); |
| 166 | 165 |
| 167 // Set up Accept-Language and Accept-Charset header values | 166 // Set up Accept-Language and Accept-Charset header values |
| 168 params->accept_language = net::HttpUtil::GenerateAcceptLanguageHeader( | 167 params->accept_language = net::HttpUtil::GenerateAcceptLanguageHeader( |
| 169 pref_service->GetString(prefs::kAcceptLanguages)); | 168 pref_service->GetString(prefs::kAcceptLanguages)); |
| 170 std::string default_charset = | 169 std::string default_charset = |
| 171 pref_service->GetString(prefs::kGlobalDefaultCharset); | 170 pref_service->GetString(prefs::kGlobalDefaultCharset); |
| 172 params->accept_charset = | 171 params->accept_charset = |
| 173 net::HttpUtil::GenerateAcceptCharsetHeader(default_charset); | 172 net::HttpUtil::GenerateAcceptCharsetHeader(default_charset); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 | 239 |
| 241 void ProfileIOData::AppRequestContext::SetHttpTransactionFactory( | 240 void ProfileIOData::AppRequestContext::SetHttpTransactionFactory( |
| 242 net::HttpTransactionFactory* http_factory) { | 241 net::HttpTransactionFactory* http_factory) { |
| 243 http_factory_.reset(http_factory); | 242 http_factory_.reset(http_factory); |
| 244 set_http_transaction_factory(http_factory); | 243 set_http_transaction_factory(http_factory); |
| 245 } | 244 } |
| 246 | 245 |
| 247 ProfileIOData::AppRequestContext::~AppRequestContext() {} | 246 ProfileIOData::AppRequestContext::~AppRequestContext() {} |
| 248 | 247 |
| 249 ProfileIOData::ProfileParams::ProfileParams() | 248 ProfileIOData::ProfileParams::ProfileParams() |
| 250 : is_incognito(false), | 249 : clear_local_state_on_exit(false), |
| 251 clear_local_state_on_exit(false), | |
| 252 io_thread(NULL), | 250 io_thread(NULL), |
| 253 #if defined(ENABLE_NOTIFICATIONS) | 251 #if defined(ENABLE_NOTIFICATIONS) |
| 254 notification_service(NULL), | 252 notification_service(NULL), |
| 255 #endif | 253 #endif |
| 256 profile(NULL) { | 254 profile(NULL) { |
| 257 } | 255 } |
| 258 | 256 |
| 259 ProfileIOData::ProfileParams::~ProfileParams() {} | 257 ProfileIOData::ProfileParams::~ProfileParams() {} |
| 260 | 258 |
| 261 ProfileIOData::ProfileIOData(bool is_incognito) | 259 ProfileIOData::ProfileIOData(bool is_incognito) |
| 262 : initialized_(false), | 260 : initialized_(false), |
| 263 ALLOW_THIS_IN_INITIALIZER_LIST( | 261 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 264 resource_context_(new ResourceContext(this))), | 262 resource_context_(new ResourceContext(this))), |
| 265 initialized_on_UI_thread_(false) { | 263 initialized_on_UI_thread_(false), |
| 264 is_incognito_(is_incognito) { |
| 266 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 265 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 267 } | 266 } |
| 268 | 267 |
| 269 ProfileIOData::~ProfileIOData() { | 268 ProfileIOData::~ProfileIOData() { |
| 270 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) | 269 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) |
| 271 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 270 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 272 | 271 |
| 273 if (main_request_context_) | 272 if (main_request_context_) |
| 274 main_request_context_->AssertNoURLRequests(); | 273 main_request_context_->AssertNoURLRequests(); |
| 275 if (extensions_request_context_) | 274 if (extensions_request_context_) |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 io_thread->net_log(), | 457 io_thread->net_log(), |
| 459 io_thread_globals->proxy_script_fetcher_context.get(), | 458 io_thread_globals->proxy_script_fetcher_context.get(), |
| 460 profile_params_->proxy_config_service.release(), | 459 profile_params_->proxy_config_service.release(), |
| 461 command_line)); | 460 command_line)); |
| 462 | 461 |
| 463 transport_security_state_.reset(new net::TransportSecurityState( | 462 transport_security_state_.reset(new net::TransportSecurityState( |
| 464 command_line.GetSwitchValueASCII(switches::kHstsHosts))); | 463 command_line.GetSwitchValueASCII(switches::kHstsHosts))); |
| 465 transport_security_persister_.reset( | 464 transport_security_persister_.reset( |
| 466 new TransportSecurityPersister(transport_security_state_.get(), | 465 new TransportSecurityPersister(transport_security_state_.get(), |
| 467 profile_params_->path, | 466 profile_params_->path, |
| 468 profile_params_->is_incognito)); | 467 is_incognito())); |
| 469 | 468 |
| 470 // NOTE(willchan): Keep these protocol handlers in sync with | 469 // NOTE(willchan): Keep these protocol handlers in sync with |
| 471 // ProfileIOData::IsHandledProtocol(). | 470 // ProfileIOData::IsHandledProtocol(). |
| 472 job_factory_.reset(new net::URLRequestJobFactory); | 471 job_factory_.reset(new net::URLRequestJobFactory); |
| 473 if (profile_params_->protocol_handler_registry) { | 472 if (profile_params_->protocol_handler_registry) { |
| 474 job_factory_->AddInterceptor( | 473 job_factory_->AddInterceptor( |
| 475 new ProtocolHandlerRegistryInterceptor( | 474 new ProtocolHandlerRegistryInterceptor( |
| 476 profile_params_->protocol_handler_registry)); | 475 profile_params_->protocol_handler_registry)); |
| 477 } | 476 } |
| 478 bool set_protocol = job_factory_->SetProtocolHandler( | 477 bool set_protocol = job_factory_->SetProtocolHandler( |
| 479 chrome::kExtensionScheme, | 478 chrome::kExtensionScheme, |
| 480 CreateExtensionProtocolHandler(profile_params_->is_incognito, | 479 CreateExtensionProtocolHandler(is_incognito(), |
| 481 profile_params_->extension_info_map)); | 480 profile_params_->extension_info_map)); |
| 482 DCHECK(set_protocol); | 481 DCHECK(set_protocol); |
| 483 set_protocol = job_factory_->SetProtocolHandler( | 482 set_protocol = job_factory_->SetProtocolHandler( |
| 484 chrome::kChromeUIScheme, | 483 chrome::kChromeUIScheme, |
| 485 ChromeURLDataManagerBackend::CreateProtocolHandler( | 484 ChromeURLDataManagerBackend::CreateProtocolHandler( |
| 486 chrome_url_data_manager_backend_.get())); | 485 chrome_url_data_manager_backend_.get())); |
| 487 DCHECK(set_protocol); | 486 DCHECK(set_protocol); |
| 488 set_protocol = job_factory_->SetProtocolHandler( | 487 set_protocol = job_factory_->SetProtocolHandler( |
| 489 chrome::kChromeDevToolsScheme, | 488 chrome::kChromeDevToolsScheme, |
| 490 CreateDevToolsProtocolHandler(chrome_url_data_manager_backend_.get())); | 489 CreateDevToolsProtocolHandler(chrome_url_data_manager_backend_.get())); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 508 resource_context_->request_context_ = main_request_context_; | 507 resource_context_->request_context_ = main_request_context_; |
| 509 | 508 |
| 510 LazyInitializeInternal(profile_params_.get()); | 509 LazyInitializeInternal(profile_params_.get()); |
| 511 | 510 |
| 512 profile_params_.reset(); | 511 profile_params_.reset(); |
| 513 initialized_ = true; | 512 initialized_ = true; |
| 514 } | 513 } |
| 515 | 514 |
| 516 void ProfileIOData::ApplyProfileParamsToContext( | 515 void ProfileIOData::ApplyProfileParamsToContext( |
| 517 ChromeURLRequestContext* context) const { | 516 ChromeURLRequestContext* context) const { |
| 518 context->set_is_incognito(profile_params_->is_incognito); | 517 context->set_is_incognito(is_incognito()); |
| 519 context->set_accept_language(profile_params_->accept_language); | 518 context->set_accept_language(profile_params_->accept_language); |
| 520 context->set_accept_charset(profile_params_->accept_charset); | 519 context->set_accept_charset(profile_params_->accept_charset); |
| 521 context->set_referrer_charset(profile_params_->referrer_charset); | 520 context->set_referrer_charset(profile_params_->referrer_charset); |
| 522 context->set_ssl_config_service(profile_params_->ssl_config_service); | 521 context->set_ssl_config_service(profile_params_->ssl_config_service); |
| 523 } | 522 } |
| 524 | 523 |
| 525 void ProfileIOData::ShutdownOnUIThread() { | 524 void ProfileIOData::ShutdownOnUIThread() { |
| 526 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 525 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 527 enable_referrers_.Destroy(); | 526 enable_referrers_.Destroy(); |
| 527 enable_metrics_.Destroy(); |
| 528 clear_local_state_on_exit_.Destroy(); | 528 clear_local_state_on_exit_.Destroy(); |
| 529 safe_browsing_enabled_.Destroy(); | 529 safe_browsing_enabled_.Destroy(); |
| 530 session_startup_pref_.Destroy(); | 530 session_startup_pref_.Destroy(); |
| 531 #if defined(ENABLE_CONFIGURATION_POLICY) | 531 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 532 if (url_blacklist_manager_.get()) | 532 if (url_blacklist_manager_.get()) |
| 533 url_blacklist_manager_->ShutdownOnUIThread(); | 533 url_blacklist_manager_->ShutdownOnUIThread(); |
| 534 #endif | 534 #endif |
| 535 bool posted = BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); | 535 bool posted = BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); |
| 536 if (!posted) | 536 if (!posted) |
| 537 delete this; | 537 delete this; |
| 538 } | 538 } |
| 539 | 539 |
| 540 void ProfileIOData::set_server_bound_cert_service( | 540 void ProfileIOData::set_server_bound_cert_service( |
| 541 net::ServerBoundCertService* server_bound_cert_service) const { | 541 net::ServerBoundCertService* server_bound_cert_service) const { |
| 542 server_bound_cert_service_.reset(server_bound_cert_service); | 542 server_bound_cert_service_.reset(server_bound_cert_service); |
| 543 } | 543 } |
| 544 | 544 |
| 545 void ProfileIOData::DestroyResourceContext() { | 545 void ProfileIOData::DestroyResourceContext() { |
| 546 resource_context_.reset(); | 546 resource_context_.reset(); |
| 547 } | 547 } |
| OLD | NEW |