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 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 | 502 |
503 transport_security_state_.reset(new net::TransportSecurityState()); | 503 transport_security_state_.reset(new net::TransportSecurityState()); |
504 transport_security_persister_.reset( | 504 transport_security_persister_.reset( |
505 new TransportSecurityPersister(transport_security_state_.get(), | 505 new TransportSecurityPersister(transport_security_state_.get(), |
506 profile_params_->path, | 506 profile_params_->path, |
507 is_incognito())); | 507 is_incognito())); |
508 const std::string& serialized = | 508 const std::string& serialized = |
509 command_line.GetSwitchValueASCII(switches::kHstsHosts); | 509 command_line.GetSwitchValueASCII(switches::kHstsHosts); |
510 transport_security_persister_.get()->DeserializeFromCommandLine(serialized); | 510 transport_security_persister_.get()->DeserializeFromCommandLine(serialized); |
511 | 511 |
| 512 // Take ownership over these parameters. |
| 513 cookie_settings_ = profile_params_->cookie_settings; |
| 514 #if defined(ENABLE_NOTIFICATIONS) |
| 515 notification_service_ = profile_params_->notification_service; |
| 516 #endif |
| 517 extension_info_map_ = profile_params_->extension_info_map; |
| 518 |
| 519 resource_context_->host_resolver_ = io_thread_globals->host_resolver.get(); |
| 520 resource_context_->request_context_ = main_request_context_.get(); |
| 521 |
| 522 if (profile_params_->resource_prefetch_predictor_observer_.get()) { |
| 523 resource_prefetch_predictor_observer_.reset( |
| 524 profile_params_->resource_prefetch_predictor_observer_.release()); |
| 525 } |
| 526 |
| 527 LazyInitializeInternal(profile_params_.get()); |
| 528 |
| 529 profile_params_.reset(); |
| 530 initialized_ = true; |
| 531 } |
| 532 |
| 533 void ProfileIOData::ApplyProfileParamsToContext( |
| 534 ChromeURLRequestContext* context) const { |
| 535 context->set_is_incognito(is_incognito()); |
| 536 context->set_accept_language(profile_params_->accept_language); |
| 537 context->set_accept_charset(profile_params_->accept_charset); |
| 538 context->set_referrer_charset(profile_params_->referrer_charset); |
| 539 context->set_ssl_config_service(profile_params_->ssl_config_service); |
| 540 } |
| 541 |
| 542 void ProfileIOData::SetUpJobFactoryDefaults( |
| 543 net::URLRequestJobFactory* job_factory) const { |
512 // NOTE(willchan): Keep these protocol handlers in sync with | 544 // NOTE(willchan): Keep these protocol handlers in sync with |
513 // ProfileIOData::IsHandledProtocol(). | 545 // ProfileIOData::IsHandledProtocol(). |
514 job_factory_.reset(new net::URLRequestJobFactory); | |
515 if (profile_params_->protocol_handler_registry) { | 546 if (profile_params_->protocol_handler_registry) { |
516 job_factory_->AddInterceptor( | 547 job_factory->AddInterceptor( |
517 new ProtocolHandlerRegistryInterceptor( | 548 new ProtocolHandlerRegistryInterceptor( |
518 profile_params_->protocol_handler_registry)); | 549 profile_params_->protocol_handler_registry)); |
519 } | 550 } |
520 bool set_protocol = job_factory_->SetProtocolHandler( | 551 bool set_protocol = job_factory->SetProtocolHandler( |
521 chrome::kExtensionScheme, | 552 chrome::kExtensionScheme, |
522 CreateExtensionProtocolHandler(is_incognito(), | 553 CreateExtensionProtocolHandler(is_incognito(), |
523 profile_params_->extension_info_map)); | 554 profile_params_->extension_info_map)); |
524 DCHECK(set_protocol); | 555 DCHECK(set_protocol); |
525 set_protocol = job_factory_->SetProtocolHandler( | 556 set_protocol = job_factory->SetProtocolHandler( |
526 chrome::kExtensionResourceScheme, | 557 chrome::kExtensionResourceScheme, |
527 CreateExtensionResourceProtocolHandler()); | 558 CreateExtensionResourceProtocolHandler()); |
528 DCHECK(set_protocol); | 559 DCHECK(set_protocol); |
529 set_protocol = job_factory_->SetProtocolHandler( | 560 set_protocol = job_factory->SetProtocolHandler( |
530 chrome::kChromeUIScheme, | 561 chrome::kChromeUIScheme, |
531 ChromeURLDataManagerBackend::CreateProtocolHandler( | 562 ChromeURLDataManagerBackend::CreateProtocolHandler( |
532 chrome_url_data_manager_backend_.get())); | 563 chrome_url_data_manager_backend_.get())); |
533 DCHECK(set_protocol); | 564 DCHECK(set_protocol); |
534 set_protocol = job_factory_->SetProtocolHandler( | 565 set_protocol = job_factory->SetProtocolHandler( |
535 chrome::kChromeDevToolsScheme, | 566 chrome::kChromeDevToolsScheme, |
536 CreateDevToolsProtocolHandler(chrome_url_data_manager_backend_.get())); | 567 CreateDevToolsProtocolHandler(chrome_url_data_manager_backend_.get())); |
537 DCHECK(set_protocol); | 568 DCHECK(set_protocol); |
538 #if defined(OS_CHROMEOS) | 569 #if defined(OS_CHROMEOS) |
539 if (!is_incognito()) { | 570 if (!is_incognito()) { |
540 set_protocol = job_factory_->SetProtocolHandler( | 571 set_protocol = job_factory->SetProtocolHandler( |
541 chrome::kDriveScheme, new gdata::GDataProtocolHandler()); | 572 chrome::kDriveScheme, new gdata::GDataProtocolHandler()); |
542 DCHECK(set_protocol); | 573 DCHECK(set_protocol); |
543 } | 574 } |
544 #if !defined(GOOGLE_CHROME_BUILD) | 575 #if !defined(GOOGLE_CHROME_BUILD) |
545 // Install the GView request interceptor that will redirect requests | 576 // Install the GView request interceptor that will redirect requests |
546 // of compatible documents (PDF, etc) to the GView document viewer. | 577 // of compatible documents (PDF, etc) to the GView document viewer. |
547 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); | 578 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); |
548 if (parsed_command_line.HasSwitch(switches::kEnableGView)) | 579 if (parsed_command_line.HasSwitch(switches::kEnableGView)) |
549 job_factory_->AddInterceptor(new chromeos::GViewRequestInterceptor); | 580 job_factory->AddInterceptor(new chromeos::GViewRequestInterceptor); |
550 #endif // !defined(GOOGLE_CHROME_BUILD) | 581 #endif // !defined(GOOGLE_CHROME_BUILD) |
551 #endif // defined(OS_CHROMEOS) | 582 #endif // defined(OS_CHROMEOS) |
552 | |
553 // Take ownership over these parameters. | |
554 cookie_settings_ = profile_params_->cookie_settings; | |
555 #if defined(ENABLE_NOTIFICATIONS) | |
556 notification_service_ = profile_params_->notification_service; | |
557 #endif | |
558 extension_info_map_ = profile_params_->extension_info_map; | |
559 | |
560 resource_context_->host_resolver_ = io_thread_globals->host_resolver.get(); | |
561 resource_context_->request_context_ = main_request_context_.get(); | |
562 | |
563 if (profile_params_->resource_prefetch_predictor_observer_.get()) { | |
564 resource_prefetch_predictor_observer_.reset( | |
565 profile_params_->resource_prefetch_predictor_observer_.release()); | |
566 } | |
567 | |
568 LazyInitializeInternal(profile_params_.get()); | |
569 | |
570 profile_params_.reset(); | |
571 initialized_ = true; | |
572 } | |
573 | |
574 void ProfileIOData::ApplyProfileParamsToContext( | |
575 ChromeURLRequestContext* context) const { | |
576 context->set_is_incognito(is_incognito()); | |
577 context->set_accept_language(profile_params_->accept_language); | |
578 context->set_accept_charset(profile_params_->accept_charset); | |
579 context->set_referrer_charset(profile_params_->referrer_charset); | |
580 context->set_ssl_config_service(profile_params_->ssl_config_service); | |
581 } | 583 } |
582 | 584 |
583 void ProfileIOData::ShutdownOnUIThread() { | 585 void ProfileIOData::ShutdownOnUIThread() { |
584 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 586 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
585 enable_referrers_.Destroy(); | 587 enable_referrers_.Destroy(); |
586 #if !defined(OS_CHROMEOS) | 588 #if !defined(OS_CHROMEOS) |
587 enable_metrics_.Destroy(); | 589 enable_metrics_.Destroy(); |
588 #endif | 590 #endif |
589 safe_browsing_enabled_.Destroy(); | 591 safe_browsing_enabled_.Destroy(); |
590 session_startup_pref_.Destroy(); | 592 session_startup_pref_.Destroy(); |
591 #if defined(ENABLE_CONFIGURATION_POLICY) | 593 #if defined(ENABLE_CONFIGURATION_POLICY) |
592 if (url_blacklist_manager_.get()) | 594 if (url_blacklist_manager_.get()) |
593 url_blacklist_manager_->ShutdownOnUIThread(); | 595 url_blacklist_manager_->ShutdownOnUIThread(); |
594 #endif | 596 #endif |
595 bool posted = BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); | 597 bool posted = BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); |
596 if (!posted) | 598 if (!posted) |
597 delete this; | 599 delete this; |
598 } | 600 } |
599 | 601 |
600 void ProfileIOData::set_server_bound_cert_service( | 602 void ProfileIOData::set_server_bound_cert_service( |
601 net::ServerBoundCertService* server_bound_cert_service) const { | 603 net::ServerBoundCertService* server_bound_cert_service) const { |
602 server_bound_cert_service_.reset(server_bound_cert_service); | 604 server_bound_cert_service_.reset(server_bound_cert_service); |
603 } | 605 } |
604 | 606 |
605 void ProfileIOData::DestroyResourceContext() { | 607 void ProfileIOData::DestroyResourceContext() { |
606 resource_context_.reset(); | 608 resource_context_.reset(); |
607 } | 609 } |
OLD | NEW |