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

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

Issue 12546016: Remove the Extensions URLRequestContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change Cookie Override API to not expose the CookieStoreMap. Created 7 years, 4 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
« no previous file with comments | « chrome/browser/profiles/profile_impl.h ('k') | chrome/browser/profiles/profile_impl_io_data.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_impl.h" 5 #include "chrome/browser/profiles/profile_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 30 matching lines...) Expand all
41 #include "chrome/browser/extensions/extension_special_storage_policy.h" 41 #include "chrome/browser/extensions/extension_special_storage_policy.h"
42 #include "chrome/browser/extensions/extension_system.h" 42 #include "chrome/browser/extensions/extension_system.h"
43 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" 43 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h"
44 #include "chrome/browser/geolocation/chrome_geolocation_permission_context_facto ry.h" 44 #include "chrome/browser/geolocation/chrome_geolocation_permission_context_facto ry.h"
45 #include "chrome/browser/history/shortcuts_backend.h" 45 #include "chrome/browser/history/shortcuts_backend.h"
46 #include "chrome/browser/history/top_sites.h" 46 #include "chrome/browser/history/top_sites.h"
47 #include "chrome/browser/media/chrome_midi_permission_context.h" 47 #include "chrome/browser/media/chrome_midi_permission_context.h"
48 #include "chrome/browser/media/chrome_midi_permission_context_factory.h" 48 #include "chrome/browser/media/chrome_midi_permission_context_factory.h"
49 #include "chrome/browser/metrics/metrics_service.h" 49 #include "chrome/browser/metrics/metrics_service.h"
50 #include "chrome/browser/net/chrome_url_request_context.h" 50 #include "chrome/browser/net/chrome_url_request_context.h"
51 #include "chrome/browser/net/cookie_store_util.h"
51 #include "chrome/browser/net/net_pref_observer.h" 52 #include "chrome/browser/net/net_pref_observer.h"
52 #include "chrome/browser/net/predictor.h" 53 #include "chrome/browser/net/predictor.h"
53 #include "chrome/browser/net/pref_proxy_config_tracker.h" 54 #include "chrome/browser/net/pref_proxy_config_tracker.h"
54 #include "chrome/browser/net/proxy_service_factory.h" 55 #include "chrome/browser/net/proxy_service_factory.h"
55 #include "chrome/browser/net/ssl_config_service_manager.h" 56 #include "chrome/browser/net/ssl_config_service_manager.h"
56 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" 57 #include "chrome/browser/plugins/chrome_plugin_service_filter.h"
57 #include "chrome/browser/plugins/plugin_prefs.h" 58 #include "chrome/browser/plugins/plugin_prefs.h"
58 #include "chrome/browser/policy/profile_policy_connector.h" 59 #include "chrome/browser/policy/profile_policy_connector.h"
59 #include "chrome/browser/policy/profile_policy_connector_factory.h" 60 #include "chrome/browser/policy/profile_policy_connector_factory.h"
60 #include "chrome/browser/prefs/browser_prefs.h" 61 #include "chrome/browser/prefs/browser_prefs.h"
(...skipping 18 matching lines...) Expand all
79 #include "chrome/common/chrome_switches.h" 80 #include "chrome/common/chrome_switches.h"
80 #include "chrome/common/chrome_version_info.h" 81 #include "chrome/common/chrome_version_info.h"
81 #include "chrome/common/net/url_fixer_upper.h" 82 #include "chrome/common/net/url_fixer_upper.h"
82 #include "chrome/common/pref_names.h" 83 #include "chrome/common/pref_names.h"
83 #include "chrome/common/startup_metric_utils.h" 84 #include "chrome/common/startup_metric_utils.h"
84 #include "chrome/common/url_constants.h" 85 #include "chrome/common/url_constants.h"
85 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h" 86 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h"
86 #include "components/user_prefs/pref_registry_syncable.h" 87 #include "components/user_prefs/pref_registry_syncable.h"
87 #include "components/user_prefs/user_prefs.h" 88 #include "components/user_prefs/user_prefs.h"
88 #include "content/public/browser/browser_thread.h" 89 #include "content/public/browser/browser_thread.h"
90 #include "content/public/browser/cookie_store_factory.h"
91 #include "content/public/browser/cookie_store_map.h"
89 #include "content/public/browser/dom_storage_context.h" 92 #include "content/public/browser/dom_storage_context.h"
90 #include "content/public/browser/host_zoom_map.h" 93 #include "content/public/browser/host_zoom_map.h"
91 #include "content/public/browser/notification_service.h" 94 #include "content/public/browser/notification_service.h"
92 #include "content/public/browser/render_process_host.h" 95 #include "content/public/browser/render_process_host.h"
93 #include "content/public/browser/storage_partition.h" 96 #include "content/public/browser/storage_partition.h"
94 #include "content/public/browser/user_metrics.h" 97 #include "content/public/browser/user_metrics.h"
95 #include "content/public/common/content_constants.h" 98 #include "content/public/common/content_constants.h"
99 #include "extensions/common/constants.h"
96 #include "grit/chromium_strings.h" 100 #include "grit/chromium_strings.h"
97 #include "grit/generated_resources.h" 101 #include "grit/generated_resources.h"
98 #include "ui/base/l10n/l10n_util.h" 102 #include "ui/base/l10n/l10n_util.h"
99 103
100 #if defined(OS_WIN) 104 #if defined(OS_WIN)
101 #include "chrome/installer/util/install_util.h" 105 #include "chrome/installer/util/install_util.h"
102 #endif 106 #endif
103 107
104 #if defined(OS_CHROMEOS) 108 #if defined(OS_CHROMEOS)
105 #include "chrome/browser/chromeos/enterprise_extension_observer.h" 109 #include "chrome/browser/chromeos/enterprise_extension_observer.h"
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 bool init_background_mode_manager = true; 494 bool init_background_mode_manager = true;
491 #if defined(OS_CHROMEOS) 495 #if defined(OS_CHROMEOS)
492 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kKeepAliveForTest)) 496 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kKeepAliveForTest))
493 init_background_mode_manager = false; 497 init_background_mode_manager = false;
494 #endif 498 #endif
495 if (init_background_mode_manager) { 499 if (init_background_mode_manager) {
496 if (g_browser_process->background_mode_manager()) 500 if (g_browser_process->background_mode_manager())
497 g_browser_process->background_mode_manager()->RegisterProfile(this); 501 g_browser_process->background_mode_manager()->RegisterProfile(this);
498 } 502 }
499 503
500 base::FilePath cookie_path = GetPath();
501 cookie_path = cookie_path.Append(chrome::kCookieFilename);
502 base::FilePath server_bound_cert_path = GetPath(); 504 base::FilePath server_bound_cert_path = GetPath();
503 server_bound_cert_path = 505 server_bound_cert_path =
504 server_bound_cert_path.Append(chrome::kOBCertFilename); 506 server_bound_cert_path.Append(chrome::kOBCertFilename);
505 base::FilePath cache_path = base_cache_path_; 507 base::FilePath cache_path = base_cache_path_;
506 int cache_max_size; 508 int cache_max_size;
507 GetCacheParameters(false, &cache_path, &cache_max_size); 509 GetCacheParameters(false, &cache_path, &cache_max_size);
508 cache_path = GetCachePath(cache_path); 510 cache_path = GetCachePath(cache_path);
509 511
510 base::FilePath media_cache_path = base_cache_path_; 512 base::FilePath media_cache_path = base_cache_path_;
511 int media_cache_max_size; 513 int media_cache_max_size;
512 GetCacheParameters(true, &media_cache_path, &media_cache_max_size); 514 GetCacheParameters(true, &media_cache_path, &media_cache_max_size);
513 media_cache_path = GetMediaCachePath(media_cache_path); 515 media_cache_path = GetMediaCachePath(media_cache_path);
514 516
515 base::FilePath extensions_cookie_path = GetPath(); 517 base::FilePath extensions_cookie_path = GetPath();
516 extensions_cookie_path = 518 extensions_cookie_path =
517 extensions_cookie_path.Append(chrome::kExtensionsCookieFilename); 519 extensions_cookie_path.Append(chrome::kExtensionsCookieFilename);
518 520
519 base::FilePath infinite_cache_path = GetPath(); 521 base::FilePath infinite_cache_path = GetPath();
520 infinite_cache_path = 522 infinite_cache_path =
521 infinite_cache_path.Append(FILE_PATH_LITERAL("Infinite Cache")); 523 infinite_cache_path.Append(FILE_PATH_LITERAL("Infinite Cache"));
522 524
523 #if defined(OS_ANDROID)
524 SessionStartupPref::Type startup_pref_type =
525 SessionStartupPref::GetDefaultStartupType();
526 #else
527 SessionStartupPref::Type startup_pref_type =
528 StartupBrowserCreator::GetSessionStartupPref(
529 *CommandLine::ForCurrentProcess(), this).type;
530 #endif
531 bool restore_old_session_cookies =
532 (GetLastSessionExitType() == Profile::EXIT_CRASHED ||
533 startup_pref_type == SessionStartupPref::LAST);
534
535 InitHostZoomMap(); 525 InitHostZoomMap();
536 526
537 // Make sure we initialize the ProfileIOData after everything else has been 527 // Make sure we initialize the ProfileIOData after everything else has been
538 // initialized that we might be reading from the IO thread. 528 // initialized that we might be reading from the IO thread.
539 529
540 io_data_.Init(cookie_path, server_bound_cert_path, cache_path, 530 io_data_.Init(server_bound_cert_path, cache_path,
541 cache_max_size, media_cache_path, media_cache_max_size, 531 cache_max_size, media_cache_path, media_cache_max_size,
542 extensions_cookie_path, GetPath(), infinite_cache_path, 532 GetPath(), infinite_cache_path, predictor_,
543 predictor_,
544 restore_old_session_cookies,
545 GetSpecialStoragePolicy()); 533 GetSpecialStoragePolicy());
546 534
547 #if defined(ENABLE_PLUGINS) 535 #if defined(ENABLE_PLUGINS)
548 ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( 536 ChromePluginServiceFilter::GetInstance()->RegisterResourceContext(
549 PluginPrefs::GetForProfile(this).get(), 537 PluginPrefs::GetForProfile(this).get(),
550 io_data_.GetResourceContextNoInit()); 538 io_data_.GetResourceContextNoInit());
551 #endif 539 #endif
552 540
553 // Delay README creation to not impact startup performance. 541 // Delay README creation to not impact startup performance.
554 BrowserThread::PostDelayedTask( 542 BrowserThread::PostDelayedTask(
555 BrowserThread::FILE, FROM_HERE, 543 BrowserThread::FILE, FROM_HERE,
556 base::Bind(&EnsureReadmeFile, GetPath()), 544 base::Bind(&EnsureReadmeFile, GetPath()),
557 base::TimeDelta::FromMilliseconds(create_readme_delay_ms)); 545 base::TimeDelta::FromMilliseconds(create_readme_delay_ms));
558 546
559 if (!CommandLine::ForCurrentProcess()->HasSwitch( 547 if (!CommandLine::ForCurrentProcess()->HasSwitch(
560 switches::kDisableRestoreSessionState)) { 548 switches::kDisableRestoreSessionState)) {
561 TRACE_EVENT0("browser", "ProfileImpl::SetSaveSessionStorageOnDisk") 549 TRACE_EVENT0("browser", "ProfileImpl::SetSaveSessionStorageOnDisk")
562 content::BrowserContext::GetDefaultStoragePartition(this)-> 550 GetDefaultStoragePartition(this)->
563 GetDOMStorageContext()->SetSaveSessionStorageOnDisk(); 551 GetDOMStorageContext()->SetSaveSessionStorageOnDisk();
564 } 552 }
565 553
566 // Creation has been finished. 554 // Creation has been finished.
567 if (delegate_) { 555 if (delegate_) {
568 TRACE_EVENT0("browser", "ProfileImpl::DoFileInit:DelegateOnProfileCreated") 556 TRACE_EVENT0("browser", "ProfileImpl::DoFileInit:DelegateOnProfileCreated")
569 delegate_->OnProfileCreated(this, true, IsNewProfile()); 557 delegate_->OnProfileCreated(this, true, IsNewProfile());
570 } 558 }
571 559
572 content::NotificationService::current()->Notify( 560 content::NotificationService::current()->Notify(
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 654
667 base::FilePath ProfileImpl::GetPath() const { 655 base::FilePath ProfileImpl::GetPath() const {
668 return path_; 656 return path_;
669 } 657 }
670 658
671 scoped_refptr<base::SequencedTaskRunner> ProfileImpl::GetIOTaskRunner() { 659 scoped_refptr<base::SequencedTaskRunner> ProfileImpl::GetIOTaskRunner() {
672 return JsonPrefStore::GetTaskRunnerForFile( 660 return JsonPrefStore::GetTaskRunnerForFile(
673 GetPath(), BrowserThread::GetBlockingPool()); 661 GetPath(), BrowserThread::GetBlockingPool());
674 } 662 }
675 663
676 bool ProfileImpl::IsOffTheRecord() const { 664 void ProfileImpl::OverrideCookieStoreConfigs(
677 return false; 665 const base::FilePath& partition_path,
666 bool in_memory_partition,
667 bool is_default_partition,
668 CookieSchemeMap* configs) {
669 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
670 using content::CookieStoreConfig;
671
672 configs->clear();
673
674 bool in_memory = in_memory_partition ||
675 chrome_browser_net::ShouldUseInMemoryCookiesAndCache();
676
677 // The delegate is stateless so it's silly to create more than one per
678 // profile.
679 if (!cookie_delegate_) {
680 cookie_delegate_ = chrome_browser_net::CreateCookieDelegate(this);
681 }
682
683 #if defined(OS_ANDROID)
684 SessionStartupPref::Type startup_pref_type =
685 SessionStartupPref::GetDefaultStartupType();
686 #else
687 SessionStartupPref::Type startup_pref_type =
688 StartupBrowserCreator::GetSessionStartupPref(
689 *CommandLine::ForCurrentProcess(), this).type;
690 #endif
691
692 CookieStoreConfig::SessionCookieMode session_cookie_mode =
693 CookieStoreConfig::PERSISTANT_SESSION_COOKIES;
694 if (GetLastSessionExitType() == Profile::EXIT_CRASHED ||
695 startup_pref_type == SessionStartupPref::LAST) {
696 session_cookie_mode = CookieStoreConfig::RESTORED_SESSION_COOKIES;
697 }
698
699 std::vector<CookieStoreConfig> new_configs;
700 if (in_memory) {
701 (*configs)[kDefaultCookieScheme] =
702 CookieStoreConfig::InMemoryWithOptions(GetSpecialStoragePolicy(),
703 cookie_delegate_);
704 } else {
705 (*configs)[kDefaultCookieScheme] =
706 CookieStoreConfig::PersistentWithOptions(
707 partition_path.Append(content::kCookieFilename),
708 session_cookie_mode,
709 GetSpecialStoragePolicy(),
710 cookie_delegate_);
711 }
712
713 // Only add a cookie store for the kExtensionScheme to the default
714 // partition. Per extensions spec, only kExtensionScheme origins in the
715 // default partition support cookies.
716 if (is_default_partition) {
717 if (in_memory) {
718 (*configs)[extensions::kExtensionScheme] =
719 CookieStoreConfig::InMemory();
720 } else {
721 base::FilePath cookie_path = partition_path.Append(
722 chrome::kExtensionsCookieFilename);
723 (*configs)[extensions::kExtensionScheme] =
724 CookieStoreConfig::Persistent(
725 cookie_path,
726 session_cookie_mode);
727 }
728 }
678 } 729 }
679 730
680 Profile* ProfileImpl::GetOffTheRecordProfile() { 731 Profile* ProfileImpl::GetOffTheRecordProfile() {
681 if (!off_the_record_profile_) { 732 if (!off_the_record_profile_) {
682 scoped_ptr<Profile> p(CreateOffTheRecordProfile()); 733 scoped_ptr<Profile> p(CreateOffTheRecordProfile());
683 off_the_record_profile_.swap(p); 734 off_the_record_profile_.swap(p);
684 735
685 content::NotificationService::current()->Notify( 736 content::NotificationService::current()->Notify(
686 chrome::NOTIFICATION_PROFILE_CREATED, 737 chrome::NOTIFICATION_PROFILE_CREATED,
687 content::Source<Profile>(off_the_record_profile_.get()), 738 content::Source<Profile>(off_the_record_profile_.get()),
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 context->RequestMIDISysExPermission(render_process_id, 930 context->RequestMIDISysExPermission(render_process_id,
880 render_view_id, 931 render_view_id,
881 requesting_frame, 932 requesting_frame,
882 callback); 933 callback);
883 } 934 }
884 935
885 content::ResourceContext* ProfileImpl::GetResourceContext() { 936 content::ResourceContext* ProfileImpl::GetResourceContext() {
886 return io_data_.GetResourceContext(); 937 return io_data_.GetResourceContext();
887 } 938 }
888 939
889 net::URLRequestContextGetter* ProfileImpl::GetRequestContextForExtensions() {
890 return io_data_.GetExtensionsRequestContextGetter().get();
891 }
892
893 net::URLRequestContextGetter* 940 net::URLRequestContextGetter*
894 ProfileImpl::CreateRequestContextForStoragePartition( 941 ProfileImpl::CreateRequestContextForStoragePartition(
895 const base::FilePath& partition_path, 942 const base::FilePath& partition_path,
896 bool in_memory, 943 bool in_memory,
897 content::ProtocolHandlerMap* protocol_handlers) { 944 content::ProtocolHandlerMap* protocol_handlers) {
898 return io_data_.CreateIsolatedAppRequestContextGetter( 945 return io_data_.CreateIsolatedAppRequestContextGetter(
899 partition_path, in_memory, protocol_handlers).get(); 946 partition_path, in_memory, protocol_handlers).get();
900 } 947 }
901 948
902 net::SSLConfigService* ProfileImpl::GetSSLConfigService() { 949 net::SSLConfigService* ProfileImpl::GetSSLConfigService() {
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 PrefProxyConfigTracker* ProfileImpl::CreateProxyConfigTracker() { 1222 PrefProxyConfigTracker* ProfileImpl::CreateProxyConfigTracker() {
1176 #if defined(OS_CHROMEOS) 1223 #if defined(OS_CHROMEOS)
1177 if (chromeos::ProfileHelper::IsSigninProfile(this)) { 1224 if (chromeos::ProfileHelper::IsSigninProfile(this)) {
1178 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( 1225 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState(
1179 g_browser_process->local_state()); 1226 g_browser_process->local_state());
1180 } 1227 }
1181 #endif // defined(OS_CHROMEOS) 1228 #endif // defined(OS_CHROMEOS)
1182 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( 1229 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile(
1183 GetPrefs(), g_browser_process->local_state()); 1230 GetPrefs(), g_browser_process->local_state());
1184 } 1231 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_impl.h ('k') | chrome/browser/profiles/profile_impl_io_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698