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

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: compile gdi. 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
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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 bool ProfileImpl::IsOffTheRecord() const {
677 return false; 665 return false;
678 } 666 }
679 667
668 content::CookieStoreConfig ProfileImpl::GetCookieStoreConfig() {
669 // The delegate is stateless so it's silly to create more than one per
670 // profile.
671 if (!cookie_delegate_) {
672 cookie_delegate_ = chrome_browser_net::CreateCookieDelegate(this);
673 }
674
675 if (chrome_browser_net::ShouldUseInMemoryCookiesAndCache()) {
676 return content::CookieStoreConfig::InMemoryWithOptions(
677 GetSpecialStoragePolicy(), cookie_delegate_);
678 }
679
680 #if defined(OS_ANDROID)
681 SessionStartupPref::Type startup_pref_type =
682 SessionStartupPref::GetDefaultStartupType();
683 #else
684 SessionStartupPref::Type startup_pref_type =
685 StartupBrowserCreator::GetSessionStartupPref(
686 *CommandLine::ForCurrentProcess(), this).type;
687 #endif
688
689 content::CookieStoreConfig::SessionCookieMode session_cookie_mode =
690 content::CookieStoreConfig::PERSISTANT_SESSION_COOKIES;
691 if (GetLastSessionExitType() == Profile::EXIT_CRASHED ||
692 startup_pref_type == SessionStartupPref::LAST) {
693 session_cookie_mode = content::CookieStoreConfig::RESTORED_SESSION_COOKIES;
694 }
695
696 return content::CookieStoreConfig::PersistentWithOptions(
697 GetPath().Append(content::kCookieFilename),
698 session_cookie_mode, GetSpecialStoragePolicy(),
699 cookie_delegate_);
700 }
701
680 Profile* ProfileImpl::GetOffTheRecordProfile() { 702 Profile* ProfileImpl::GetOffTheRecordProfile() {
681 if (!off_the_record_profile_) { 703 if (!off_the_record_profile_) {
682 scoped_ptr<Profile> p(CreateOffTheRecordProfile()); 704 scoped_ptr<Profile> p(CreateOffTheRecordProfile());
683 off_the_record_profile_.swap(p); 705 off_the_record_profile_.swap(p);
684 706
685 content::NotificationService::current()->Notify( 707 content::NotificationService::current()->Notify(
686 chrome::NOTIFICATION_PROFILE_CREATED, 708 chrome::NOTIFICATION_PROFILE_CREATED,
687 content::Source<Profile>(off_the_record_profile_.get()), 709 content::Source<Profile>(off_the_record_profile_.get()),
688 content::NotificationService::NoDetails()); 710 content::NotificationService::NoDetails());
689 } 711 }
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 context->RequestMIDISysExPermission(render_process_id, 901 context->RequestMIDISysExPermission(render_process_id,
880 render_view_id, 902 render_view_id,
881 requesting_frame, 903 requesting_frame,
882 callback); 904 callback);
883 } 905 }
884 906
885 content::ResourceContext* ProfileImpl::GetResourceContext() { 907 content::ResourceContext* ProfileImpl::GetResourceContext() {
886 return io_data_.GetResourceContext(); 908 return io_data_.GetResourceContext();
887 } 909 }
888 910
889 net::URLRequestContextGetter* ProfileImpl::GetRequestContextForExtensions() {
890 return io_data_.GetExtensionsRequestContextGetter().get();
891 }
892
893 net::URLRequestContextGetter* 911 net::URLRequestContextGetter*
894 ProfileImpl::CreateRequestContextForStoragePartition( 912 ProfileImpl::CreateRequestContextForStoragePartition(
895 const base::FilePath& partition_path, 913 const base::FilePath& partition_path,
896 bool in_memory, 914 bool in_memory,
897 content::ProtocolHandlerMap* protocol_handlers) { 915 content::ProtocolHandlerMap* protocol_handlers) {
898 return io_data_.CreateIsolatedAppRequestContextGetter( 916 return io_data_.CreateIsolatedAppRequestContextGetter(
899 partition_path, in_memory, protocol_handlers).get(); 917 partition_path, in_memory, protocol_handlers).get();
900 } 918 }
901 919
902 net::SSLConfigService* ProfileImpl::GetSSLConfigService() { 920 net::SSLConfigService* ProfileImpl::GetSSLConfigService() {
(...skipping 21 matching lines...) Expand all
924 942
925 DownloadManagerDelegate* ProfileImpl::GetDownloadManagerDelegate() { 943 DownloadManagerDelegate* ProfileImpl::GetDownloadManagerDelegate() {
926 return DownloadServiceFactory::GetForBrowserContext(this)-> 944 return DownloadServiceFactory::GetForBrowserContext(this)->
927 GetDownloadManagerDelegate(); 945 GetDownloadManagerDelegate();
928 } 946 }
929 947
930 quota::SpecialStoragePolicy* ProfileImpl::GetSpecialStoragePolicy() { 948 quota::SpecialStoragePolicy* ProfileImpl::GetSpecialStoragePolicy() {
931 return GetExtensionSpecialStoragePolicy(); 949 return GetExtensionSpecialStoragePolicy();
932 } 950 }
933 951
952 void ProfileImpl::OverrideCookieStoreMap(
953 bool in_memory,
954 const base::FilePath& partition_path,
955 bool is_default,
956 content::CookieStoreMap* cookie_store_map) {
957 using content::CreateCookieStore;
958 using content::CookieStoreConfig;
959
960 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
961
962 net::CookieStore* cookie_store = NULL;
963 // This is called for each StoragePartition. Currently Extensions
964 // should only execute on the default partition.
965 if (is_default) {
966 if (in_memory) {
967 cookie_store = CreateCookieStore(CookieStoreConfig::InMemory());
968 } else {
969 base::FilePath cookie_path = partition_path.Append(
970 chrome::kExtensionsCookieFilename);
971 cookie_store = CreateCookieStore(
972 CookieStoreConfig::Persistent(
973 cookie_path,
974 GetCookieStoreConfig().session_cookie_mode));
975 }
976
977 static const char* schemes[] = { extensions::kExtensionScheme };
978 cookie_store->GetCookieMonster()->SetCookieableSchemes(schemes, 1);
979 cookie_store_map->SetForScheme(extensions::kExtensionScheme, cookie_store);
980 }
981 }
982
934 bool ProfileImpl::IsSameProfile(Profile* profile) { 983 bool ProfileImpl::IsSameProfile(Profile* profile) {
935 if (profile == static_cast<Profile*>(this)) 984 if (profile == static_cast<Profile*>(this))
936 return true; 985 return true;
937 Profile* otr_profile = off_the_record_profile_.get(); 986 Profile* otr_profile = off_the_record_profile_.get();
938 return otr_profile && profile == otr_profile; 987 return otr_profile && profile == otr_profile;
939 } 988 }
940 989
941 Time ProfileImpl::GetStartTime() const { 990 Time ProfileImpl::GetStartTime() const {
942 return start_time_; 991 return start_time_;
943 } 992 }
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 PrefProxyConfigTracker* ProfileImpl::CreateProxyConfigTracker() { 1224 PrefProxyConfigTracker* ProfileImpl::CreateProxyConfigTracker() {
1176 #if defined(OS_CHROMEOS) 1225 #if defined(OS_CHROMEOS)
1177 if (chromeos::ProfileHelper::IsSigninProfile(this)) { 1226 if (chromeos::ProfileHelper::IsSigninProfile(this)) {
1178 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( 1227 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState(
1179 g_browser_process->local_state()); 1228 g_browser_process->local_state());
1180 } 1229 }
1181 #endif // defined(OS_CHROMEOS) 1230 #endif // defined(OS_CHROMEOS)
1182 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( 1231 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile(
1183 GetPrefs(), g_browser_process->local_state()); 1232 GetPrefs(), g_browser_process->local_state());
1184 } 1233 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698