| 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 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 | 529 |
| 530 io_data_.Init(cookie_path, server_bound_cert_path, cache_path, | 530 io_data_.Init(cookie_path, server_bound_cert_path, cache_path, |
| 531 cache_max_size, media_cache_path, media_cache_max_size, | 531 cache_max_size, media_cache_path, media_cache_max_size, |
| 532 extensions_cookie_path, GetPath(), infinite_cache_path, | 532 extensions_cookie_path, GetPath(), infinite_cache_path, |
| 533 predictor_, | 533 predictor_, |
| 534 restore_old_session_cookies, | 534 restore_old_session_cookies, |
| 535 GetSpecialStoragePolicy()); | 535 GetSpecialStoragePolicy()); |
| 536 | 536 |
| 537 #if defined(ENABLE_PLUGINS) | 537 #if defined(ENABLE_PLUGINS) |
| 538 ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( | 538 ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( |
| 539 PluginPrefs::GetForProfile(this), | 539 PluginPrefs::GetForProfile(this).get(), |
| 540 io_data_.GetResourceContextNoInit()); | 540 io_data_.GetResourceContextNoInit()); |
| 541 #endif | 541 #endif |
| 542 | 542 |
| 543 // Delay README creation to not impact startup performance. | 543 // Delay README creation to not impact startup performance. |
| 544 BrowserThread::PostDelayedTask( | 544 BrowserThread::PostDelayedTask( |
| 545 BrowserThread::FILE, FROM_HERE, | 545 BrowserThread::FILE, FROM_HERE, |
| 546 base::Bind(&EnsureReadmeFile, GetPath()), | 546 base::Bind(&EnsureReadmeFile, GetPath()), |
| 547 base::TimeDelta::FromMilliseconds(create_readme_delay_ms)); | 547 base::TimeDelta::FromMilliseconds(create_readme_delay_ms)); |
| 548 | 548 |
| 549 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 549 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 | 700 |
| 701 ExtensionService* ProfileImpl::GetExtensionService() { | 701 ExtensionService* ProfileImpl::GetExtensionService() { |
| 702 return extensions::ExtensionSystem::Get(this)->extension_service(); | 702 return extensions::ExtensionSystem::Get(this)->extension_service(); |
| 703 } | 703 } |
| 704 | 704 |
| 705 ExtensionSpecialStoragePolicy* | 705 ExtensionSpecialStoragePolicy* |
| 706 ProfileImpl::GetExtensionSpecialStoragePolicy() { | 706 ProfileImpl::GetExtensionSpecialStoragePolicy() { |
| 707 if (!extension_special_storage_policy_.get()) { | 707 if (!extension_special_storage_policy_.get()) { |
| 708 TRACE_EVENT0("browser", "ProfileImpl::GetExtensionSpecialStoragePolicy") | 708 TRACE_EVENT0("browser", "ProfileImpl::GetExtensionSpecialStoragePolicy") |
| 709 extension_special_storage_policy_ = new ExtensionSpecialStoragePolicy( | 709 extension_special_storage_policy_ = new ExtensionSpecialStoragePolicy( |
| 710 CookieSettings::Factory::GetForProfile(this)); | 710 CookieSettings::Factory::GetForProfile(this).get()); |
| 711 } | 711 } |
| 712 return extension_special_storage_policy_.get(); | 712 return extension_special_storage_policy_.get(); |
| 713 } | 713 } |
| 714 | 714 |
| 715 void ProfileImpl::OnPrefsLoaded(bool success) { | 715 void ProfileImpl::OnPrefsLoaded(bool success) { |
| 716 TRACE_EVENT0("browser", "ProfileImpl::OnPrefsLoaded") | 716 TRACE_EVENT0("browser", "ProfileImpl::OnPrefsLoaded") |
| 717 if (!success) { | 717 if (!success) { |
| 718 if (delegate_) | 718 if (delegate_) |
| 719 delegate_->OnProfileCreated(this, false, false); | 719 delegate_->OnProfileCreated(this, false, false); |
| 720 return; | 720 return; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 } | 809 } |
| 810 | 810 |
| 811 base::FilePath ProfileImpl::GetPrefFilePath() { | 811 base::FilePath ProfileImpl::GetPrefFilePath() { |
| 812 base::FilePath pref_file_path = path_; | 812 base::FilePath pref_file_path = path_; |
| 813 pref_file_path = pref_file_path.Append(chrome::kPreferencesFilename); | 813 pref_file_path = pref_file_path.Append(chrome::kPreferencesFilename); |
| 814 return pref_file_path; | 814 return pref_file_path; |
| 815 } | 815 } |
| 816 | 816 |
| 817 net::URLRequestContextGetter* ProfileImpl::CreateRequestContext( | 817 net::URLRequestContextGetter* ProfileImpl::CreateRequestContext( |
| 818 content::ProtocolHandlerMap* protocol_handlers) { | 818 content::ProtocolHandlerMap* protocol_handlers) { |
| 819 return io_data_.CreateMainRequestContextGetter( | 819 return io_data_ |
| 820 protocol_handlers, | 820 .CreateMainRequestContextGetter(protocol_handlers, |
| 821 g_browser_process->local_state(), | 821 g_browser_process->local_state(), |
| 822 g_browser_process->io_thread()); | 822 g_browser_process->io_thread()).get(); |
| 823 } | 823 } |
| 824 | 824 |
| 825 net::URLRequestContextGetter* ProfileImpl::GetRequestContext() { | 825 net::URLRequestContextGetter* ProfileImpl::GetRequestContext() { |
| 826 return GetDefaultStoragePartition(this)->GetURLRequestContext(); | 826 return GetDefaultStoragePartition(this)->GetURLRequestContext(); |
| 827 } | 827 } |
| 828 | 828 |
| 829 net::URLRequestContextGetter* ProfileImpl::GetRequestContextForRenderProcess( | 829 net::URLRequestContextGetter* ProfileImpl::GetRequestContextForRenderProcess( |
| 830 int renderer_child_id) { | 830 int renderer_child_id) { |
| 831 content::RenderProcessHost* rph = content::RenderProcessHost::FromID( | 831 content::RenderProcessHost* rph = content::RenderProcessHost::FromID( |
| 832 renderer_child_id); | 832 renderer_child_id); |
| 833 | 833 |
| 834 return rph->GetStoragePartition()->GetURLRequestContext(); | 834 return rph->GetStoragePartition()->GetURLRequestContext(); |
| 835 } | 835 } |
| 836 | 836 |
| 837 net::URLRequestContextGetter* ProfileImpl::GetMediaRequestContext() { | 837 net::URLRequestContextGetter* ProfileImpl::GetMediaRequestContext() { |
| 838 // Return the default media context. | 838 // Return the default media context. |
| 839 return io_data_.GetMediaRequestContextGetter(); | 839 return io_data_.GetMediaRequestContextGetter().get(); |
| 840 } | 840 } |
| 841 | 841 |
| 842 net::URLRequestContextGetter* | 842 net::URLRequestContextGetter* |
| 843 ProfileImpl::GetMediaRequestContextForRenderProcess( | 843 ProfileImpl::GetMediaRequestContextForRenderProcess( |
| 844 int renderer_child_id) { | 844 int renderer_child_id) { |
| 845 content::RenderProcessHost* rph = content::RenderProcessHost::FromID( | 845 content::RenderProcessHost* rph = content::RenderProcessHost::FromID( |
| 846 renderer_child_id); | 846 renderer_child_id); |
| 847 content::StoragePartition* storage_partition = rph->GetStoragePartition(); | 847 content::StoragePartition* storage_partition = rph->GetStoragePartition(); |
| 848 | 848 |
| 849 return storage_partition->GetMediaURLRequestContext(); | 849 return storage_partition->GetMediaURLRequestContext(); |
| 850 } | 850 } |
| 851 | 851 |
| 852 net::URLRequestContextGetter* | 852 net::URLRequestContextGetter* |
| 853 ProfileImpl::GetMediaRequestContextForStoragePartition( | 853 ProfileImpl::GetMediaRequestContextForStoragePartition( |
| 854 const base::FilePath& partition_path, | 854 const base::FilePath& partition_path, |
| 855 bool in_memory) { | 855 bool in_memory) { |
| 856 return io_data_.GetIsolatedMediaRequestContextGetter(partition_path, | 856 return io_data_ |
| 857 in_memory); | 857 .GetIsolatedMediaRequestContextGetter(partition_path, in_memory).get(); |
| 858 } | 858 } |
| 859 | 859 |
| 860 content::ResourceContext* ProfileImpl::GetResourceContext() { | 860 content::ResourceContext* ProfileImpl::GetResourceContext() { |
| 861 return io_data_.GetResourceContext(); | 861 return io_data_.GetResourceContext(); |
| 862 } | 862 } |
| 863 | 863 |
| 864 net::URLRequestContextGetter* ProfileImpl::GetRequestContextForExtensions() { | 864 net::URLRequestContextGetter* ProfileImpl::GetRequestContextForExtensions() { |
| 865 return io_data_.GetExtensionsRequestContextGetter(); | 865 return io_data_.GetExtensionsRequestContextGetter().get(); |
| 866 } | 866 } |
| 867 | 867 |
| 868 net::URLRequestContextGetter* | 868 net::URLRequestContextGetter* |
| 869 ProfileImpl::CreateRequestContextForStoragePartition( | 869 ProfileImpl::CreateRequestContextForStoragePartition( |
| 870 const base::FilePath& partition_path, | 870 const base::FilePath& partition_path, |
| 871 bool in_memory, | 871 bool in_memory, |
| 872 content::ProtocolHandlerMap* protocol_handlers) { | 872 content::ProtocolHandlerMap* protocol_handlers) { |
| 873 return io_data_.CreateIsolatedAppRequestContextGetter( | 873 return io_data_.CreateIsolatedAppRequestContextGetter( |
| 874 partition_path, in_memory, protocol_handlers); | 874 partition_path, in_memory, protocol_handlers).get(); |
| 875 } | 875 } |
| 876 | 876 |
| 877 net::SSLConfigService* ProfileImpl::GetSSLConfigService() { | 877 net::SSLConfigService* ProfileImpl::GetSSLConfigService() { |
| 878 // If ssl_config_service_manager_ is null, this typically means that some | 878 // If ssl_config_service_manager_ is null, this typically means that some |
| 879 // BrowserContextKeyedService is trying to create a RequestContext at startup, | 879 // BrowserContextKeyedService is trying to create a RequestContext at startup, |
| 880 // but SSLConfigServiceManager is not initialized until DoFinalInit() which is | 880 // but SSLConfigServiceManager is not initialized until DoFinalInit() which is |
| 881 // invoked after all BrowserContextKeyedServices have been initialized (see | 881 // invoked after all BrowserContextKeyedServices have been initialized (see |
| 882 // http://crbug.com/171406). | 882 // http://crbug.com/171406). |
| 883 DCHECK(ssl_config_service_manager_) << | 883 DCHECK(ssl_config_service_manager_) << |
| 884 "SSLConfigServiceManager is not initialized yet"; | 884 "SSLConfigServiceManager is not initialized yet"; |
| 885 return ssl_config_service_manager_->Get(); | 885 return ssl_config_service_manager_->Get(); |
| 886 } | 886 } |
| 887 | 887 |
| 888 HostContentSettingsMap* ProfileImpl::GetHostContentSettingsMap() { | 888 HostContentSettingsMap* ProfileImpl::GetHostContentSettingsMap() { |
| 889 if (!host_content_settings_map_.get()) { | 889 if (!host_content_settings_map_.get()) { |
| 890 host_content_settings_map_ = new HostContentSettingsMap(GetPrefs(), false); | 890 host_content_settings_map_ = new HostContentSettingsMap(GetPrefs(), false); |
| 891 } | 891 } |
| 892 return host_content_settings_map_.get(); | 892 return host_content_settings_map_.get(); |
| 893 } | 893 } |
| 894 | 894 |
| 895 content::GeolocationPermissionContext* | 895 content::GeolocationPermissionContext* |
| 896 ProfileImpl::GetGeolocationPermissionContext() { | 896 ProfileImpl::GetGeolocationPermissionContext() { |
| 897 return ChromeGeolocationPermissionContextFactory::GetForProfile(this); | 897 return ChromeGeolocationPermissionContextFactory::GetForProfile(this); |
| 898 } | 898 } |
| 899 | 899 |
| 900 content::SpeechRecognitionPreferences* | 900 content::SpeechRecognitionPreferences* |
| 901 ProfileImpl::GetSpeechRecognitionPreferences() { | 901 ProfileImpl::GetSpeechRecognitionPreferences() { |
| 902 #if defined(ENABLE_INPUT_SPEECH) | 902 #if defined(ENABLE_INPUT_SPEECH) |
| 903 return ChromeSpeechRecognitionPreferences::GetForProfile(this); | 903 return ChromeSpeechRecognitionPreferences::GetForProfile(this).get(); |
| 904 #else | 904 #else |
| 905 return NULL; | 905 return NULL; |
| 906 #endif | 906 #endif |
| 907 } | 907 } |
| 908 | 908 |
| 909 DownloadManagerDelegate* ProfileImpl::GetDownloadManagerDelegate() { | 909 DownloadManagerDelegate* ProfileImpl::GetDownloadManagerDelegate() { |
| 910 return DownloadServiceFactory::GetForProfile(this)-> | 910 return DownloadServiceFactory::GetForProfile(this)-> |
| 911 GetDownloadManagerDelegate(); | 911 GetDownloadManagerDelegate(); |
| 912 } | 912 } |
| 913 | 913 |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1150 base::FilePath* cache_path, | 1150 base::FilePath* cache_path, |
| 1151 int* max_size) { | 1151 int* max_size) { |
| 1152 DCHECK(cache_path); | 1152 DCHECK(cache_path); |
| 1153 DCHECK(max_size); | 1153 DCHECK(max_size); |
| 1154 base::FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir)); | 1154 base::FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir)); |
| 1155 if (!path.empty()) | 1155 if (!path.empty()) |
| 1156 *cache_path = path; | 1156 *cache_path = path; |
| 1157 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : | 1157 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : |
| 1158 prefs_->GetInteger(prefs::kDiskCacheSize); | 1158 prefs_->GetInteger(prefs::kDiskCacheSize); |
| 1159 } | 1159 } |
| OLD | NEW |