OLD | NEW |
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 Loading... |
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" | |
52 #include "chrome/browser/net/net_pref_observer.h" | 51 #include "chrome/browser/net/net_pref_observer.h" |
53 #include "chrome/browser/net/predictor.h" | 52 #include "chrome/browser/net/predictor.h" |
54 #include "chrome/browser/net/pref_proxy_config_tracker.h" | 53 #include "chrome/browser/net/pref_proxy_config_tracker.h" |
55 #include "chrome/browser/net/proxy_service_factory.h" | 54 #include "chrome/browser/net/proxy_service_factory.h" |
56 #include "chrome/browser/net/ssl_config_service_manager.h" | 55 #include "chrome/browser/net/ssl_config_service_manager.h" |
57 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" | 56 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" |
58 #include "chrome/browser/plugins/plugin_prefs.h" | 57 #include "chrome/browser/plugins/plugin_prefs.h" |
59 #include "chrome/browser/policy/profile_policy_connector.h" | 58 #include "chrome/browser/policy/profile_policy_connector.h" |
60 #include "chrome/browser/policy/profile_policy_connector_factory.h" | 59 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
61 #include "chrome/browser/prefs/browser_prefs.h" | 60 #include "chrome/browser/prefs/browser_prefs.h" |
(...skipping 18 matching lines...) Expand all Loading... |
80 #include "chrome/common/chrome_switches.h" | 79 #include "chrome/common/chrome_switches.h" |
81 #include "chrome/common/chrome_version_info.h" | 80 #include "chrome/common/chrome_version_info.h" |
82 #include "chrome/common/net/url_fixer_upper.h" | 81 #include "chrome/common/net/url_fixer_upper.h" |
83 #include "chrome/common/pref_names.h" | 82 #include "chrome/common/pref_names.h" |
84 #include "chrome/common/startup_metric_utils.h" | 83 #include "chrome/common/startup_metric_utils.h" |
85 #include "chrome/common/url_constants.h" | 84 #include "chrome/common/url_constants.h" |
86 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" | 85 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" |
87 #include "components/user_prefs/pref_registry_syncable.h" | 86 #include "components/user_prefs/pref_registry_syncable.h" |
88 #include "components/user_prefs/user_prefs.h" | 87 #include "components/user_prefs/user_prefs.h" |
89 #include "content/public/browser/browser_thread.h" | 88 #include "content/public/browser/browser_thread.h" |
90 #include "content/public/browser/cookie_store_factory.h" | |
91 #include "content/public/browser/dom_storage_context.h" | 89 #include "content/public/browser/dom_storage_context.h" |
92 #include "content/public/browser/host_zoom_map.h" | 90 #include "content/public/browser/host_zoom_map.h" |
93 #include "content/public/browser/notification_service.h" | 91 #include "content/public/browser/notification_service.h" |
94 #include "content/public/browser/render_process_host.h" | 92 #include "content/public/browser/render_process_host.h" |
95 #include "content/public/browser/storage_partition.h" | 93 #include "content/public/browser/storage_partition.h" |
96 #include "content/public/browser/user_metrics.h" | 94 #include "content/public/browser/user_metrics.h" |
97 #include "content/public/common/content_constants.h" | 95 #include "content/public/common/content_constants.h" |
98 #include "grit/chromium_strings.h" | 96 #include "grit/chromium_strings.h" |
99 #include "grit/generated_resources.h" | 97 #include "grit/generated_resources.h" |
100 #include "ui/base/l10n/l10n_util.h" | 98 #include "ui/base/l10n/l10n_util.h" |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 bool init_background_mode_manager = true; | 490 bool init_background_mode_manager = true; |
493 #if defined(OS_CHROMEOS) | 491 #if defined(OS_CHROMEOS) |
494 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kKeepAliveForTest)) | 492 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kKeepAliveForTest)) |
495 init_background_mode_manager = false; | 493 init_background_mode_manager = false; |
496 #endif | 494 #endif |
497 if (init_background_mode_manager) { | 495 if (init_background_mode_manager) { |
498 if (g_browser_process->background_mode_manager()) | 496 if (g_browser_process->background_mode_manager()) |
499 g_browser_process->background_mode_manager()->RegisterProfile(this); | 497 g_browser_process->background_mode_manager()->RegisterProfile(this); |
500 } | 498 } |
501 | 499 |
| 500 base::FilePath cookie_path = GetPath(); |
| 501 cookie_path = cookie_path.Append(chrome::kCookieFilename); |
502 base::FilePath server_bound_cert_path = GetPath(); | 502 base::FilePath server_bound_cert_path = GetPath(); |
503 server_bound_cert_path = | 503 server_bound_cert_path = |
504 server_bound_cert_path.Append(chrome::kOBCertFilename); | 504 server_bound_cert_path.Append(chrome::kOBCertFilename); |
505 base::FilePath cache_path = base_cache_path_; | 505 base::FilePath cache_path = base_cache_path_; |
506 int cache_max_size; | 506 int cache_max_size; |
507 GetCacheParameters(false, &cache_path, &cache_max_size); | 507 GetCacheParameters(false, &cache_path, &cache_max_size); |
508 cache_path = GetCachePath(cache_path); | 508 cache_path = GetCachePath(cache_path); |
509 | 509 |
510 base::FilePath media_cache_path = base_cache_path_; | 510 base::FilePath media_cache_path = base_cache_path_; |
511 int media_cache_max_size; | 511 int media_cache_max_size; |
512 GetCacheParameters(true, &media_cache_path, &media_cache_max_size); | 512 GetCacheParameters(true, &media_cache_path, &media_cache_max_size); |
513 media_cache_path = GetMediaCachePath(media_cache_path); | 513 media_cache_path = GetMediaCachePath(media_cache_path); |
514 | 514 |
515 base::FilePath extensions_cookie_path = GetPath(); | 515 base::FilePath extensions_cookie_path = GetPath(); |
516 extensions_cookie_path = | 516 extensions_cookie_path = |
517 extensions_cookie_path.Append(chrome::kExtensionsCookieFilename); | 517 extensions_cookie_path.Append(chrome::kExtensionsCookieFilename); |
518 | 518 |
519 base::FilePath infinite_cache_path = GetPath(); | 519 base::FilePath infinite_cache_path = GetPath(); |
520 infinite_cache_path = | 520 infinite_cache_path = |
521 infinite_cache_path.Append(FILE_PATH_LITERAL("Infinite Cache")); | 521 infinite_cache_path.Append(FILE_PATH_LITERAL("Infinite Cache")); |
522 | 522 |
| 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 |
523 InitHostZoomMap(); | 535 InitHostZoomMap(); |
524 | 536 |
525 // Make sure we initialize the ProfileIOData after everything else has been | 537 // Make sure we initialize the ProfileIOData after everything else has been |
526 // initialized that we might be reading from the IO thread. | 538 // initialized that we might be reading from the IO thread. |
527 | 539 |
528 io_data_.Init(server_bound_cert_path, cache_path, | 540 io_data_.Init(cookie_path, server_bound_cert_path, cache_path, |
529 cache_max_size, media_cache_path, media_cache_max_size, | 541 cache_max_size, media_cache_path, media_cache_max_size, |
530 GetPath(), infinite_cache_path, predictor_, | 542 extensions_cookie_path, GetPath(), infinite_cache_path, |
| 543 predictor_, |
| 544 restore_old_session_cookies, |
531 GetSpecialStoragePolicy()); | 545 GetSpecialStoragePolicy()); |
532 | 546 |
533 #if defined(ENABLE_PLUGINS) | 547 #if defined(ENABLE_PLUGINS) |
534 ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( | 548 ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( |
535 PluginPrefs::GetForProfile(this).get(), | 549 PluginPrefs::GetForProfile(this).get(), |
536 io_data_.GetResourceContextNoInit()); | 550 io_data_.GetResourceContextNoInit()); |
537 #endif | 551 #endif |
538 | 552 |
539 // Delay README creation to not impact startup performance. | 553 // Delay README creation to not impact startup performance. |
540 BrowserThread::PostDelayedTask( | 554 BrowserThread::PostDelayedTask( |
541 BrowserThread::FILE, FROM_HERE, | 555 BrowserThread::FILE, FROM_HERE, |
542 base::Bind(&EnsureReadmeFile, GetPath()), | 556 base::Bind(&EnsureReadmeFile, GetPath()), |
543 base::TimeDelta::FromMilliseconds(create_readme_delay_ms)); | 557 base::TimeDelta::FromMilliseconds(create_readme_delay_ms)); |
544 | 558 |
545 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 559 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
546 switches::kDisableRestoreSessionState)) { | 560 switches::kDisableRestoreSessionState)) { |
547 TRACE_EVENT0("browser", "ProfileImpl::SetSaveSessionStorageOnDisk") | 561 TRACE_EVENT0("browser", "ProfileImpl::SetSaveSessionStorageOnDisk") |
548 GetDefaultStoragePartition(this)-> | 562 content::BrowserContext::GetDefaultStoragePartition(this)-> |
549 GetDOMStorageContext()->SetSaveSessionStorageOnDisk(); | 563 GetDOMStorageContext()->SetSaveSessionStorageOnDisk(); |
550 } | 564 } |
551 | 565 |
552 // Creation has been finished. | 566 // Creation has been finished. |
553 if (delegate_) { | 567 if (delegate_) { |
554 TRACE_EVENT0("browser", "ProfileImpl::DoFileInit:DelegateOnProfileCreated") | 568 TRACE_EVENT0("browser", "ProfileImpl::DoFileInit:DelegateOnProfileCreated") |
555 delegate_->OnProfileCreated(this, true, IsNewProfile()); | 569 delegate_->OnProfileCreated(this, true, IsNewProfile()); |
556 } | 570 } |
557 | 571 |
558 content::NotificationService::current()->Notify( | 572 content::NotificationService::current()->Notify( |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 | 666 |
653 base::FilePath ProfileImpl::GetPath() const { | 667 base::FilePath ProfileImpl::GetPath() const { |
654 return path_; | 668 return path_; |
655 } | 669 } |
656 | 670 |
657 scoped_refptr<base::SequencedTaskRunner> ProfileImpl::GetIOTaskRunner() { | 671 scoped_refptr<base::SequencedTaskRunner> ProfileImpl::GetIOTaskRunner() { |
658 return JsonPrefStore::GetTaskRunnerForFile( | 672 return JsonPrefStore::GetTaskRunnerForFile( |
659 GetPath(), BrowserThread::GetBlockingPool()); | 673 GetPath(), BrowserThread::GetBlockingPool()); |
660 } | 674 } |
661 | 675 |
662 void ProfileImpl::OverrideCookieStoreConfigs( | 676 bool ProfileImpl::IsOffTheRecord() const { |
663 const base::FilePath& partition_path, | 677 return false; |
664 bool in_memory_partition, | |
665 bool is_default_partition, | |
666 CookieSchemeMap* configs) { | |
667 using content::CookieStoreConfig; | |
668 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
669 | |
670 // The delegate is stateless so it's silly to create more than one per | |
671 // profile. | |
672 if (!cookie_delegate_) { | |
673 cookie_delegate_ = chrome_browser_net::CreateCookieDelegate(this); | |
674 } | |
675 | |
676 #if defined(OS_ANDROID) | |
677 SessionStartupPref::Type startup_pref_type = | |
678 SessionStartupPref::GetDefaultStartupType(); | |
679 #else | |
680 SessionStartupPref::Type startup_pref_type = | |
681 StartupBrowserCreator::GetSessionStartupPref( | |
682 *CommandLine::ForCurrentProcess(), this).type; | |
683 #endif | |
684 | |
685 CookieStoreConfig::SessionCookieMode session_cookie_mode = | |
686 CookieStoreConfig::PERSISTANT_SESSION_COOKIES; | |
687 if (GetLastSessionExitType() == Profile::EXIT_CRASHED || | |
688 startup_pref_type == SessionStartupPref::LAST) { | |
689 session_cookie_mode = CookieStoreConfig::RESTORED_SESSION_COOKIES; | |
690 } | |
691 | |
692 chrome_browser_net::SetCookieStoreConfigs( | |
693 partition_path, in_memory_partition, is_default_partition, | |
694 session_cookie_mode, GetSpecialStoragePolicy(), cookie_delegate_, | |
695 configs); | |
696 } | 678 } |
697 | 679 |
698 Profile* ProfileImpl::GetOffTheRecordProfile() { | 680 Profile* ProfileImpl::GetOffTheRecordProfile() { |
699 if (!off_the_record_profile_) { | 681 if (!off_the_record_profile_) { |
700 scoped_ptr<Profile> p(CreateOffTheRecordProfile()); | 682 scoped_ptr<Profile> p(CreateOffTheRecordProfile()); |
701 off_the_record_profile_.swap(p); | 683 off_the_record_profile_.swap(p); |
702 | 684 |
703 content::NotificationService::current()->Notify( | 685 content::NotificationService::current()->Notify( |
704 chrome::NOTIFICATION_PROFILE_CREATED, | 686 chrome::NOTIFICATION_PROFILE_CREATED, |
705 content::Source<Profile>(off_the_record_profile_.get()), | 687 content::Source<Profile>(off_the_record_profile_.get()), |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
895 context->RequestMIDISysExPermission(render_process_id, | 877 context->RequestMIDISysExPermission(render_process_id, |
896 render_view_id, | 878 render_view_id, |
897 requesting_frame, | 879 requesting_frame, |
898 callback); | 880 callback); |
899 } | 881 } |
900 | 882 |
901 content::ResourceContext* ProfileImpl::GetResourceContext() { | 883 content::ResourceContext* ProfileImpl::GetResourceContext() { |
902 return io_data_.GetResourceContext(); | 884 return io_data_.GetResourceContext(); |
903 } | 885 } |
904 | 886 |
| 887 net::URLRequestContextGetter* ProfileImpl::GetRequestContextForExtensions() { |
| 888 return io_data_.GetExtensionsRequestContextGetter().get(); |
| 889 } |
| 890 |
905 net::URLRequestContextGetter* | 891 net::URLRequestContextGetter* |
906 ProfileImpl::CreateRequestContextForStoragePartition( | 892 ProfileImpl::CreateRequestContextForStoragePartition( |
907 const base::FilePath& partition_path, | 893 const base::FilePath& partition_path, |
908 bool in_memory, | 894 bool in_memory, |
909 content::ProtocolHandlerMap* protocol_handlers) { | 895 content::ProtocolHandlerMap* protocol_handlers) { |
910 return io_data_.CreateIsolatedAppRequestContextGetter( | 896 return io_data_.CreateIsolatedAppRequestContextGetter( |
911 partition_path, in_memory, protocol_handlers).get(); | 897 partition_path, in_memory, protocol_handlers).get(); |
912 } | 898 } |
913 | 899 |
914 net::SSLConfigService* ProfileImpl::GetSSLConfigService() { | 900 net::SSLConfigService* ProfileImpl::GetSSLConfigService() { |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1187 PrefProxyConfigTracker* ProfileImpl::CreateProxyConfigTracker() { | 1173 PrefProxyConfigTracker* ProfileImpl::CreateProxyConfigTracker() { |
1188 #if defined(OS_CHROMEOS) | 1174 #if defined(OS_CHROMEOS) |
1189 if (chromeos::ProfileHelper::IsSigninProfile(this)) { | 1175 if (chromeos::ProfileHelper::IsSigninProfile(this)) { |
1190 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( | 1176 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( |
1191 g_browser_process->local_state()); | 1177 g_browser_process->local_state()); |
1192 } | 1178 } |
1193 #endif // defined(OS_CHROMEOS) | 1179 #endif // defined(OS_CHROMEOS) |
1194 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( | 1180 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( |
1195 GetPrefs(), g_browser_process->local_state()); | 1181 GetPrefs(), g_browser_process->local_state()); |
1196 } | 1182 } |
OLD | NEW |