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

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

Issue 11896113: Add chrome-search: access from Instant overlay (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: include nit Created 7 years, 9 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 | Annotate | Revision Log
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 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 extensions::kExtensionScheme, 421 extensions::kExtensionScheme,
422 chrome::kChromeUIScheme, 422 chrome::kChromeUIScheme,
423 chrome::kChromeDevToolsScheme, 423 chrome::kChromeDevToolsScheme,
424 #if defined(OS_CHROMEOS) 424 #if defined(OS_CHROMEOS)
425 chrome::kMetadataScheme, 425 chrome::kMetadataScheme,
426 chrome::kDriveScheme, 426 chrome::kDriveScheme,
427 #endif // defined(OS_CHROMEOS) 427 #endif // defined(OS_CHROMEOS)
428 chrome::kBlobScheme, 428 chrome::kBlobScheme,
429 chrome::kFileSystemScheme, 429 chrome::kFileSystemScheme,
430 chrome::kExtensionResourceScheme, 430 chrome::kExtensionResourceScheme,
431 chrome::kChromeSearchScheme,
431 }; 432 };
432 for (size_t i = 0; i < arraysize(kProtocolList); ++i) { 433 for (size_t i = 0; i < arraysize(kProtocolList); ++i) {
433 if (scheme == kProtocolList[i]) 434 if (scheme == kProtocolList[i])
434 return true; 435 return true;
435 } 436 }
436 return net::URLRequest::IsHandledProtocol(scheme); 437 return net::URLRequest::IsHandledProtocol(scheme);
437 } 438 }
438 439
440 // static
439 bool ProfileIOData::IsHandledURL(const GURL& url) { 441 bool ProfileIOData::IsHandledURL(const GURL& url) {
440 if (!url.is_valid()) { 442 if (!url.is_valid()) {
441 // We handle error cases. 443 // We handle error cases.
442 return true; 444 return true;
443 } 445 }
444 446
445 return IsHandledProtocol(url.scheme()); 447 return IsHandledProtocol(url.scheme());
446 } 448 }
447 449
450 // static
451 void ProfileIOData::InstallProtocolHandlers(
452 net::URLRequestJobFactoryImpl* job_factory,
453 content::ProtocolHandlerMap* protocol_handlers) {
454 for (content::ProtocolHandlerMap::iterator it =
455 protocol_handlers->begin();
456 it != protocol_handlers->end();
457 ++it) {
458 bool set_protocol = job_factory->SetProtocolHandler(
459 it->first, it->second.release());
460 DCHECK(set_protocol);
461 }
462 protocol_handlers->clear();
463 }
464
448 content::ResourceContext* ProfileIOData::GetResourceContext() const { 465 content::ResourceContext* ProfileIOData::GetResourceContext() const {
449 return resource_context_.get(); 466 return resource_context_.get();
450 } 467 }
451 468
452 ChromeURLRequestContext* ProfileIOData::GetMainRequestContext() const { 469 ChromeURLRequestContext* ProfileIOData::GetMainRequestContext() const {
453 DCHECK(initialized_); 470 DCHECK(initialized_);
454 return main_request_context_.get(); 471 return main_request_context_.get();
455 } 472 }
456 473
457 ChromeURLRequestContext* ProfileIOData::GetMediaRequestContext() const { 474 ChromeURLRequestContext* ProfileIOData::GetMediaRequestContext() const {
458 DCHECK(initialized_); 475 DCHECK(initialized_);
459 ChromeURLRequestContext* context = AcquireMediaRequestContext(); 476 ChromeURLRequestContext* context = AcquireMediaRequestContext();
460 DCHECK(context); 477 DCHECK(context);
461 return context; 478 return context;
462 } 479 }
463 480
464 ChromeURLRequestContext* ProfileIOData::GetExtensionsRequestContext() const { 481 ChromeURLRequestContext* ProfileIOData::GetExtensionsRequestContext() const {
465 DCHECK(initialized_); 482 DCHECK(initialized_);
466 return extensions_request_context_.get(); 483 return extensions_request_context_.get();
467 } 484 }
468 485
469 ChromeURLRequestContext* ProfileIOData::GetIsolatedAppRequestContext( 486 ChromeURLRequestContext* ProfileIOData::GetIsolatedAppRequestContext(
470 ChromeURLRequestContext* main_context, 487 ChromeURLRequestContext* main_context,
471 const StoragePartitionDescriptor& partition_descriptor, 488 const StoragePartitionDescriptor& partition_descriptor,
472 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> 489 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
473 protocol_handler_interceptor, 490 protocol_handler_interceptor,
474 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> 491 content::ProtocolHandlerMap* protocol_handlers) const {
475 blob_protocol_handler,
476 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
477 file_system_protocol_handler,
478 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
479 developer_protocol_handler,
480 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
481 chrome_protocol_handler,
482 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
483 chrome_devtools_protocol_handler) const {
484 DCHECK(initialized_); 492 DCHECK(initialized_);
485 ChromeURLRequestContext* context = NULL; 493 ChromeURLRequestContext* context = NULL;
486 if (ContainsKey(app_request_context_map_, partition_descriptor)) { 494 if (ContainsKey(app_request_context_map_, partition_descriptor)) {
487 context = app_request_context_map_[partition_descriptor]; 495 context = app_request_context_map_[partition_descriptor];
488 } else { 496 } else {
489 context = AcquireIsolatedAppRequestContext( 497 context = AcquireIsolatedAppRequestContext(
490 main_context, partition_descriptor, protocol_handler_interceptor.Pass(), 498 main_context, partition_descriptor, protocol_handler_interceptor.Pass(),
491 blob_protocol_handler.Pass(), file_system_protocol_handler.Pass(), 499 protocol_handlers);
492 developer_protocol_handler.Pass(), chrome_protocol_handler.Pass(),
493 chrome_devtools_protocol_handler.Pass());
494 app_request_context_map_[partition_descriptor] = context; 500 app_request_context_map_[partition_descriptor] = context;
495 } 501 }
496 DCHECK(context); 502 DCHECK(context);
497 return context; 503 return context;
498 } 504 }
499 505
500 ChromeURLRequestContext* ProfileIOData::GetIsolatedMediaRequestContext( 506 ChromeURLRequestContext* ProfileIOData::GetIsolatedMediaRequestContext(
501 ChromeURLRequestContext* app_context, 507 ChromeURLRequestContext* app_context,
502 const StoragePartitionDescriptor& partition_descriptor) const { 508 const StoragePartitionDescriptor& partition_descriptor) const {
503 DCHECK(initialized_); 509 DCHECK(initialized_);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 std::string ProfileIOData::GetSSLSessionCacheShard() { 599 std::string ProfileIOData::GetSSLSessionCacheShard() {
594 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 600 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
595 // The SSL session cache is partitioned by setting a string. This returns a 601 // The SSL session cache is partitioned by setting a string. This returns a
596 // unique string to partition the SSL session cache. Each time we create a 602 // unique string to partition the SSL session cache. Each time we create a
597 // new profile, we'll get a fresh SSL session cache which is separate from 603 // new profile, we'll get a fresh SSL session cache which is separate from
598 // the other profiles. 604 // the other profiles.
599 static unsigned ssl_session_cache_instance = 0; 605 static unsigned ssl_session_cache_instance = 0;
600 return StringPrintf("profile/%u", ssl_session_cache_instance++); 606 return StringPrintf("profile/%u", ssl_session_cache_instance++);
601 } 607 }
602 608
603 void ProfileIOData::Init( 609 void ProfileIOData::Init(content::ProtocolHandlerMap* protocol_handlers) const {
604 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
605 blob_protocol_handler,
606 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
607 file_system_protocol_handler,
608 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
609 developer_protocol_handler,
610 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
611 chrome_protocol_handler,
612 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
613 chrome_devtools_protocol_handler) const {
614 // The basic logic is implemented here. The specific initialization 610 // The basic logic is implemented here. The specific initialization
615 // is done in InitializeInternal(), implemented by subtypes. Static helper 611 // is done in InitializeInternal(), implemented by subtypes. Static helper
616 // functions have been provided to assist in common operations. 612 // functions have been provided to assist in common operations.
617 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 613 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
618 DCHECK(!initialized_); 614 DCHECK(!initialized_);
619 615
620 startup_metric_utils::ScopedSlowStartupUMA 616 startup_metric_utils::ScopedSlowStartupUMA
621 scoped_timer("Startup.SlowStartupProfileIODataInit"); 617 scoped_timer("Startup.SlowStartupProfileIODataInit");
622 618
623 // TODO(jhawkins): Remove once crbug.com/102004 is fixed. 619 // TODO(jhawkins): Remove once crbug.com/102004 is fixed.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 681
686 if (profile_params_->resource_prefetch_predictor_observer_.get()) { 682 if (profile_params_->resource_prefetch_predictor_observer_.get()) {
687 resource_prefetch_predictor_observer_.reset( 683 resource_prefetch_predictor_observer_.reset(
688 profile_params_->resource_prefetch_predictor_observer_.release()); 684 profile_params_->resource_prefetch_predictor_observer_.release());
689 } 685 }
690 686
691 #if defined(ENABLE_MANAGED_USERS) 687 #if defined(ENABLE_MANAGED_USERS)
692 managed_mode_url_filter_ = profile_params_->managed_mode_url_filter; 688 managed_mode_url_filter_ = profile_params_->managed_mode_url_filter;
693 #endif 689 #endif
694 690
695 InitializeInternal(profile_params_.get(), 691 InitializeInternal(profile_params_.get(), protocol_handlers);
696 blob_protocol_handler.Pass(),
697 file_system_protocol_handler.Pass(),
698 developer_protocol_handler.Pass(),
699 chrome_protocol_handler.Pass(),
700 chrome_devtools_protocol_handler.Pass());
701 692
702 profile_params_.reset(); 693 profile_params_.reset();
703 initialized_ = true; 694 initialized_ = true;
704 } 695 }
705 696
706 void ProfileIOData::ApplyProfileParamsToContext( 697 void ProfileIOData::ApplyProfileParamsToContext(
707 ChromeURLRequestContext* context) const { 698 ChromeURLRequestContext* context) const {
708 context->set_http_user_agent_settings( 699 context->set_http_user_agent_settings(
709 chrome_http_user_agent_settings_.get()); 700 chrome_http_user_agent_settings_.get());
710 context->set_ssl_config_service(profile_params_->ssl_config_service); 701 context->set_ssl_config_service(profile_params_->ssl_config_service);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 void ProfileIOData::SetCookieSettingsForTesting( 829 void ProfileIOData::SetCookieSettingsForTesting(
839 CookieSettings* cookie_settings) { 830 CookieSettings* cookie_settings) {
840 DCHECK(!cookie_settings_.get()); 831 DCHECK(!cookie_settings_.get());
841 cookie_settings_ = cookie_settings; 832 cookie_settings_ = cookie_settings;
842 } 833 }
843 834
844 void ProfileIOData::set_signin_names_for_testing( 835 void ProfileIOData::set_signin_names_for_testing(
845 SigninNamesOnIOThread* signin_names) { 836 SigninNamesOnIOThread* signin_names) {
846 signin_names_.reset(signin_names); 837 signin_names_.reset(signin_names);
847 } 838 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698