Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Side by Side Diff: chrome/browser/profiles/profile_io_data.cc

Issue 10537056: Replaced static URLRequestFtpJob factory with non-static protocol handler for FTP jobs. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created different factories for the different contexts in profile_impl_io_data and off_the_record Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 492
493 transport_security_state_.reset(new net::TransportSecurityState()); 493 transport_security_state_.reset(new net::TransportSecurityState());
494 transport_security_persister_.reset( 494 transport_security_persister_.reset(
495 new TransportSecurityPersister(transport_security_state_.get(), 495 new TransportSecurityPersister(transport_security_state_.get(),
496 profile_params_->path, 496 profile_params_->path,
497 is_incognito())); 497 is_incognito()));
498 const std::string& serialized = 498 const std::string& serialized =
499 command_line.GetSwitchValueASCII(switches::kHstsHosts); 499 command_line.GetSwitchValueASCII(switches::kHstsHosts);
500 transport_security_persister_.get()->DeserializeFromCommandLine(serialized); 500 transport_security_persister_.get()->DeserializeFromCommandLine(serialized);
501 501
502 // Take ownership over these parameters.
503 cookie_settings_ = profile_params_->cookie_settings;
504 #if defined(ENABLE_NOTIFICATIONS)
505 notification_service_ = profile_params_->notification_service;
506 #endif
507 extension_info_map_ = profile_params_->extension_info_map;
508
509 resource_context_->host_resolver_ = io_thread_globals->host_resolver.get();
510 resource_context_->request_context_ = main_request_context_.get();
511
512 LazyInitializeInternal(profile_params_.get());
513
514 profile_params_.reset();
515 initialized_ = true;
516 }
517
518 void ProfileIOData::ApplyProfileParamsToContext(
519 ChromeURLRequestContext* context) const {
520 context->set_is_incognito(is_incognito());
521 context->set_accept_language(profile_params_->accept_language);
522 context->set_accept_charset(profile_params_->accept_charset);
523 context->set_referrer_charset(profile_params_->referrer_charset);
524 context->set_ssl_config_service(profile_params_->ssl_config_service);
525 }
526
527 void ProfileIOData::SetUpJobFactoryDefaults(
528 net::URLRequestJobFactory* job_factory) const {
502 // NOTE(willchan): Keep these protocol handlers in sync with 529 // NOTE(willchan): Keep these protocol handlers in sync with
503 // ProfileIOData::IsHandledProtocol(). 530 // ProfileIOData::IsHandledProtocol().
504 job_factory_.reset(new net::URLRequestJobFactory);
505 if (profile_params_->protocol_handler_registry) { 531 if (profile_params_->protocol_handler_registry) {
506 job_factory_->AddInterceptor( 532 job_factory->AddInterceptor(
507 new ProtocolHandlerRegistryInterceptor( 533 new ProtocolHandlerRegistryInterceptor(
508 profile_params_->protocol_handler_registry)); 534 profile_params_->protocol_handler_registry));
509 } 535 }
510 bool set_protocol = job_factory_->SetProtocolHandler( 536 bool set_protocol = job_factory->SetProtocolHandler(
511 chrome::kExtensionScheme, 537 chrome::kExtensionScheme,
512 CreateExtensionProtocolHandler(is_incognito(), 538 CreateExtensionProtocolHandler(is_incognito(),
513 profile_params_->extension_info_map)); 539 profile_params_->extension_info_map));
514 DCHECK(set_protocol); 540 DCHECK(set_protocol);
515 set_protocol = job_factory_->SetProtocolHandler( 541 set_protocol = job_factory->SetProtocolHandler(
516 chrome::kExtensionResourceScheme, 542 chrome::kExtensionResourceScheme,
517 CreateExtensionResourceProtocolHandler()); 543 CreateExtensionResourceProtocolHandler());
518 DCHECK(set_protocol); 544 DCHECK(set_protocol);
519 set_protocol = job_factory_->SetProtocolHandler( 545 set_protocol = job_factory->SetProtocolHandler(
520 chrome::kChromeUIScheme, 546 chrome::kChromeUIScheme,
521 ChromeURLDataManagerBackend::CreateProtocolHandler( 547 ChromeURLDataManagerBackend::CreateProtocolHandler(
522 chrome_url_data_manager_backend_.get())); 548 chrome_url_data_manager_backend_.get()));
523 DCHECK(set_protocol); 549 DCHECK(set_protocol);
524 set_protocol = job_factory_->SetProtocolHandler( 550 set_protocol = job_factory->SetProtocolHandler(
525 chrome::kChromeDevToolsScheme, 551 chrome::kChromeDevToolsScheme,
526 CreateDevToolsProtocolHandler(chrome_url_data_manager_backend_.get())); 552 CreateDevToolsProtocolHandler(chrome_url_data_manager_backend_.get()));
527 DCHECK(set_protocol); 553 DCHECK(set_protocol);
528 #if defined(OS_CHROMEOS) 554 #if defined(OS_CHROMEOS)
529 if (!is_incognito()) { 555 if (!is_incognito()) {
530 set_protocol = job_factory_->SetProtocolHandler( 556 set_protocol = job_factory->SetProtocolHandler(
531 chrome::kDriveScheme, new gdata::GDataProtocolHandler()); 557 chrome::kDriveScheme, new gdata::GDataProtocolHandler());
532 DCHECK(set_protocol); 558 DCHECK(set_protocol);
533 } 559 }
534 #if !defined(GOOGLE_CHROME_BUILD) 560 #if !defined(GOOGLE_CHROME_BUILD)
535 // Install the GView request interceptor that will redirect requests 561 // Install the GView request interceptor that will redirect requests
536 // of compatible documents (PDF, etc) to the GView document viewer. 562 // of compatible documents (PDF, etc) to the GView document viewer.
537 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); 563 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
538 if (parsed_command_line.HasSwitch(switches::kEnableGView)) 564 if (parsed_command_line.HasSwitch(switches::kEnableGView))
539 job_factory_->AddInterceptor(new chromeos::GViewRequestInterceptor); 565 job_factory->AddInterceptor(new chromeos::GViewRequestInterceptor);
540 #endif // !defined(GOOGLE_CHROME_BUILD) 566 #endif // !defined(GOOGLE_CHROME_BUILD)
541 #endif // defined(OS_CHROMEOS) 567 #endif // defined(OS_CHROMEOS)
542
543 // Take ownership over these parameters.
544 cookie_settings_ = profile_params_->cookie_settings;
545 #if defined(ENABLE_NOTIFICATIONS)
546 notification_service_ = profile_params_->notification_service;
547 #endif
548 extension_info_map_ = profile_params_->extension_info_map;
549
550 resource_context_->host_resolver_ = io_thread_globals->host_resolver.get();
551 resource_context_->request_context_ = main_request_context_.get();
552
553 LazyInitializeInternal(profile_params_.get());
554
555 profile_params_.reset();
556 initialized_ = true;
557 }
558
559 void ProfileIOData::ApplyProfileParamsToContext(
560 ChromeURLRequestContext* context) const {
561 context->set_is_incognito(is_incognito());
562 context->set_accept_language(profile_params_->accept_language);
563 context->set_accept_charset(profile_params_->accept_charset);
564 context->set_referrer_charset(profile_params_->referrer_charset);
565 context->set_ssl_config_service(profile_params_->ssl_config_service);
566 } 568 }
567 569
568 void ProfileIOData::ShutdownOnUIThread() { 570 void ProfileIOData::ShutdownOnUIThread() {
569 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 571 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
570 enable_referrers_.Destroy(); 572 enable_referrers_.Destroy();
571 #if !defined(OS_CHROMEOS) 573 #if !defined(OS_CHROMEOS)
572 enable_metrics_.Destroy(); 574 enable_metrics_.Destroy();
573 #endif 575 #endif
574 safe_browsing_enabled_.Destroy(); 576 safe_browsing_enabled_.Destroy();
575 session_startup_pref_.Destroy(); 577 session_startup_pref_.Destroy();
576 #if defined(ENABLE_CONFIGURATION_POLICY) 578 #if defined(ENABLE_CONFIGURATION_POLICY)
577 if (url_blacklist_manager_.get()) 579 if (url_blacklist_manager_.get())
578 url_blacklist_manager_->ShutdownOnUIThread(); 580 url_blacklist_manager_->ShutdownOnUIThread();
579 #endif 581 #endif
580 bool posted = BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); 582 bool posted = BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this);
581 if (!posted) 583 if (!posted)
582 delete this; 584 delete this;
583 } 585 }
584 586
585 void ProfileIOData::set_server_bound_cert_service( 587 void ProfileIOData::set_server_bound_cert_service(
586 net::ServerBoundCertService* server_bound_cert_service) const { 588 net::ServerBoundCertService* server_bound_cert_service) const {
587 server_bound_cert_service_.reset(server_bound_cert_service); 589 server_bound_cert_service_.reset(server_bound_cert_service);
588 } 590 }
589 591
590 void ProfileIOData::DestroyResourceContext() { 592 void ProfileIOData::DestroyResourceContext() {
591 resource_context_.reset(); 593 resource_context_.reset();
592 } 594 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698