Chromium Code Reviews| 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/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/environment.h" | 10 #include "base/environment.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 #include "chrome/browser/prerender/prerender_manager_factory.h" | 55 #include "chrome/browser/prerender/prerender_manager_factory.h" |
| 56 #include "chrome/browser/profiles/chrome_version_service.h" | 56 #include "chrome/browser/profiles/chrome_version_service.h" |
| 57 #include "chrome/browser/profiles/gaia_info_update_service.h" | 57 #include "chrome/browser/profiles/gaia_info_update_service.h" |
| 58 #include "chrome/browser/profiles/profile_dependency_manager.h" | 58 #include "chrome/browser/profiles/profile_dependency_manager.h" |
| 59 #include "chrome/browser/profiles/profile_destroyer.h" | 59 #include "chrome/browser/profiles/profile_destroyer.h" |
| 60 #include "chrome/browser/profiles/profile_info_cache.h" | 60 #include "chrome/browser/profiles/profile_info_cache.h" |
| 61 #include "chrome/browser/profiles/profile_manager.h" | 61 #include "chrome/browser/profiles/profile_manager.h" |
| 62 #include "chrome/browser/search_engines/template_url_fetcher.h" | 62 #include "chrome/browser/search_engines/template_url_fetcher.h" |
| 63 #include "chrome/browser/sessions/session_service_factory.h" | 63 #include "chrome/browser/sessions/session_service_factory.h" |
| 64 #include "chrome/browser/speech/chrome_speech_recognition_preferences.h" | 64 #include "chrome/browser/speech/chrome_speech_recognition_preferences.h" |
| 65 #include "chrome/browser/storage_partition_details.h" | |
| 65 #include "chrome/browser/sync/profile_sync_service_factory.h" | 66 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 66 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 67 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| 67 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 68 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
| 68 #include "chrome/browser/user_style_sheet_watcher.h" | 69 #include "chrome/browser/user_style_sheet_watcher.h" |
| 69 #include "chrome/browser/visitedlink/visitedlink_event_listener.h" | 70 #include "chrome/browser/visitedlink/visitedlink_event_listener.h" |
| 70 #include "chrome/browser/visitedlink/visitedlink_master.h" | 71 #include "chrome/browser/visitedlink/visitedlink_master.h" |
| 71 #include "chrome/browser/web_resource/promo_resource_service.h" | 72 #include "chrome/browser/web_resource/promo_resource_service.h" |
| 72 #include "chrome/browser/webdata/web_data_service.h" | 73 #include "chrome/browser/webdata/web_data_service.h" |
| 73 #include "chrome/common/chrome_constants.h" | 74 #include "chrome/common/chrome_constants.h" |
| 74 #include "chrome/common/chrome_notification_types.h" | 75 #include "chrome/common/chrome_notification_types.h" |
| (...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 754 pref_file_path = pref_file_path.Append(chrome::kPreferencesFilename); | 755 pref_file_path = pref_file_path.Append(chrome::kPreferencesFilename); |
| 755 return pref_file_path; | 756 return pref_file_path; |
| 756 } | 757 } |
| 757 | 758 |
| 758 net::URLRequestContextGetter* ProfileImpl::GetRequestContext() { | 759 net::URLRequestContextGetter* ProfileImpl::GetRequestContext() { |
| 759 return io_data_.GetMainRequestContextGetter(); | 760 return io_data_.GetMainRequestContextGetter(); |
| 760 } | 761 } |
| 761 | 762 |
| 762 net::URLRequestContextGetter* ProfileImpl::GetRequestContextForRenderProcess( | 763 net::URLRequestContextGetter* ProfileImpl::GetRequestContextForRenderProcess( |
| 763 int renderer_child_id) { | 764 int renderer_child_id) { |
| 765 content::RenderProcessHost* rph = content::RenderProcessHost::FromID( | |
| 766 renderer_child_id); | |
| 767 CHECK(rph); | |
| 768 content::StoragePartition* storage_partition = rph->GetStoragePartition(); | |
|
awong
2012/10/18 22:36:15
If we're already reading out of the StoragePartiti
nasko
2012/10/19 17:29:14
I'm going to keep the guest check temporarily, unt
awong
2012/10/19 21:20:24
It's more to undersatnd when a function is just de
| |
| 769 | |
| 764 ExtensionService* extension_service = | 770 ExtensionService* extension_service = |
| 765 extensions::ExtensionSystem::Get(this)->extension_service(); | 771 extensions::ExtensionSystem::Get(this)->extension_service(); |
| 766 if (extension_service) { | 772 if (extension_service) { |
| 767 const extensions::Extension* extension = | 773 const extensions::Extension* extension = |
| 768 extension_service->GetIsolatedAppForRenderer(renderer_child_id); | 774 extension_service->GetIsolatedAppForRenderer(renderer_child_id); |
| 769 if (extension) | 775 if (extension) |
| 770 return GetRequestContextForStoragePartition(extension->id()); | 776 return GetRequestContextForStoragePartition( |
| 777 storage_partition->GetPath(), | |
| 778 storage_partition->IsInMemoryOnly()); | |
| 771 } | 779 } |
| 772 | 780 |
| 773 content::RenderProcessHost* rph = content::RenderProcessHost::FromID( | 781 if (rph->IsGuest()) { |
| 774 renderer_child_id); | |
| 775 if (rph && rph->IsGuest()) { | |
| 776 // For guest processes (used by the browser tag), we need to isolate the | 782 // For guest processes (used by the browser tag), we need to isolate the |
| 777 // storage. | 783 // storage. |
| 778 // TODO(nasko): Until we have proper storage partitions, create a | 784 // TODO(nasko): Pass the proper value for in_memory when the browser tag |
| 779 // non-persistent context using the RPH's id. | 785 // is wired properly with storage partition. |
| 780 std::string id("guest-"); | 786 return GetRequestContextForStoragePartition( |
| 781 id.append(base::IntToString(renderer_child_id)); | 787 storage_partition->GetPath(), true); |
| 782 return GetRequestContextForStoragePartition(id); | |
| 783 } | 788 } |
| 784 | 789 |
| 785 return GetRequestContext(); | 790 return GetRequestContext(); |
| 786 } | 791 } |
| 787 | 792 |
| 788 net::URLRequestContextGetter* ProfileImpl::GetMediaRequestContext() { | 793 net::URLRequestContextGetter* ProfileImpl::GetMediaRequestContext() { |
| 789 // Return the default media context. | 794 // Return the default media context. |
| 790 return io_data_.GetMediaRequestContextGetter(); | 795 return io_data_.GetMediaRequestContextGetter(); |
| 791 } | 796 } |
| 792 | 797 |
| 793 net::URLRequestContextGetter* | 798 net::URLRequestContextGetter* |
| 794 ProfileImpl::GetMediaRequestContextForRenderProcess( | 799 ProfileImpl::GetMediaRequestContextForRenderProcess( |
| 795 int renderer_child_id) { | 800 int renderer_child_id) { |
| 801 content::RenderProcessHost* rph = content::RenderProcessHost::FromID( | |
|
awong
2012/10/18 22:36:15
Same comment as for GetRequestContextForRenderProc
nasko
2012/10/19 17:29:14
Done.
| |
| 802 renderer_child_id); | |
| 803 CHECK(rph); | |
| 804 content::StoragePartition* storage_partition = rph->GetStoragePartition(); | |
| 805 | |
| 796 ExtensionService* extension_service = | 806 ExtensionService* extension_service = |
| 797 extensions::ExtensionSystem::Get(this)->extension_service(); | 807 extensions::ExtensionSystem::Get(this)->extension_service(); |
| 798 if (extension_service) { | 808 if (extension_service) { |
| 799 const extensions::Extension* extension = | 809 const extensions::Extension* extension = |
| 800 extension_service->GetIsolatedAppForRenderer(renderer_child_id); | 810 extension_service->GetIsolatedAppForRenderer(renderer_child_id); |
| 801 if (extension) | 811 if (extension) { |
| 802 return io_data_.GetIsolatedMediaRequestContextGetter(extension->id()); | 812 StoragePartitionDetails details(storage_partition->GetPath(), |
| 813 storage_partition->IsInMemoryOnly()); | |
|
awong
2012/10/18 22:36:15
Wouldn't it be cleaner to just keep this struct in
nasko
2012/10/19 17:29:14
Done.
| |
| 814 return io_data_.GetIsolatedMediaRequestContextGetter(details); | |
| 815 } | |
| 803 } | 816 } |
| 804 | 817 |
| 805 content::RenderProcessHost* rph = content::RenderProcessHost::FromID( | 818 if (rph->IsGuest()) { |
| 806 renderer_child_id); | |
| 807 if (rph && rph->IsGuest()) { | |
| 808 // For guest processes (used by the browser tag), we need to isolate the | 819 // For guest processes (used by the browser tag), we need to isolate the |
| 809 // storage. | 820 // storage. |
| 810 // TODO(nasko): Until we have proper storage partitions, create a | 821 // TODO(nasko): Pass the proper value for in_memory when the browser tag |
| 811 // non-persistent context using the RPH's id. | 822 // is wired properly with storage partition. |
| 812 std::string id("guest-"); | 823 StoragePartitionDetails details(storage_partition->GetPath(), true); |
| 813 id.append(base::IntToString(renderer_child_id)); | 824 return io_data_.GetIsolatedMediaRequestContextGetter(details); |
| 814 return io_data_.GetIsolatedMediaRequestContextGetter(id); | |
| 815 } | 825 } |
| 816 | 826 |
| 817 return io_data_.GetMediaRequestContextGetter(); | 827 return io_data_.GetMediaRequestContextGetter(); |
| 818 } | 828 } |
| 819 | 829 |
| 820 net::URLRequestContextGetter* | 830 net::URLRequestContextGetter* |
| 821 ProfileImpl::GetMediaRequestContextForStoragePartition( | 831 ProfileImpl::GetMediaRequestContextForStoragePartition( |
| 822 const std::string& partition_id) { | 832 const FilePath& partition_path, |
| 823 return io_data_.GetIsolatedMediaRequestContextGetter(partition_id); | 833 const bool& in_memory) { |
| 834 StoragePartitionDetails details(partition_path, in_memory); | |
| 835 return io_data_.GetIsolatedMediaRequestContextGetter(details); | |
| 824 } | 836 } |
| 825 | 837 |
| 826 content::ResourceContext* ProfileImpl::GetResourceContext() { | 838 content::ResourceContext* ProfileImpl::GetResourceContext() { |
| 827 return io_data_.GetResourceContext(); | 839 return io_data_.GetResourceContext(); |
| 828 } | 840 } |
| 829 | 841 |
| 830 net::URLRequestContextGetter* ProfileImpl::GetRequestContextForExtensions() { | 842 net::URLRequestContextGetter* ProfileImpl::GetRequestContextForExtensions() { |
| 831 return io_data_.GetExtensionsRequestContextGetter(); | 843 return io_data_.GetExtensionsRequestContextGetter(); |
| 832 } | 844 } |
| 833 | 845 |
| 834 net::URLRequestContextGetter* ProfileImpl::GetRequestContextForStoragePartition( | 846 net::URLRequestContextGetter* ProfileImpl::GetRequestContextForStoragePartition( |
| 835 const std::string& partition_id) { | 847 const FilePath& partition_path, |
| 836 return io_data_.GetIsolatedAppRequestContextGetter(partition_id); | 848 const bool& in_memory) { |
| 849 StoragePartitionDetails details(partition_path, in_memory); | |
| 850 return io_data_.GetIsolatedAppRequestContextGetter(details); | |
| 837 } | 851 } |
| 838 | 852 |
| 839 net::SSLConfigService* ProfileImpl::GetSSLConfigService() { | 853 net::SSLConfigService* ProfileImpl::GetSSLConfigService() { |
| 840 return ssl_config_service_manager_->Get(); | 854 return ssl_config_service_manager_->Get(); |
| 841 } | 855 } |
| 842 | 856 |
| 843 HostContentSettingsMap* ProfileImpl::GetHostContentSettingsMap() { | 857 HostContentSettingsMap* ProfileImpl::GetHostContentSettingsMap() { |
| 844 if (!host_content_settings_map_.get()) { | 858 if (!host_content_settings_map_.get()) { |
| 845 host_content_settings_map_ = new HostContentSettingsMap(GetPrefs(), false); | 859 host_content_settings_map_ = new HostContentSettingsMap(GetPrefs(), false); |
| 846 } | 860 } |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1165 if (!path.empty()) | 1179 if (!path.empty()) |
| 1166 *cache_path = path; | 1180 *cache_path = path; |
| 1167 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : | 1181 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : |
| 1168 prefs_->GetInteger(prefs::kDiskCacheSize); | 1182 prefs_->GetInteger(prefs::kDiskCacheSize); |
| 1169 } | 1183 } |
| 1170 | 1184 |
| 1171 base::Callback<ChromeURLDataManagerBackend*(void)> | 1185 base::Callback<ChromeURLDataManagerBackend*(void)> |
| 1172 ProfileImpl::GetChromeURLDataManagerBackendGetter() const { | 1186 ProfileImpl::GetChromeURLDataManagerBackendGetter() const { |
| 1173 return io_data_.GetChromeURLDataManagerBackendGetter(); | 1187 return io_data_.GetChromeURLDataManagerBackendGetter(); |
| 1174 } | 1188 } |
| OLD | NEW |