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

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

Powered by Google App Engine
This is Rietveld 408576698