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 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 754 pref_file_path = pref_file_path.Append(chrome::kPreferencesFilename); | 754 pref_file_path = pref_file_path.Append(chrome::kPreferencesFilename); |
| 755 return pref_file_path; | 755 return pref_file_path; |
| 756 } | 756 } |
| 757 | 757 |
| 758 net::URLRequestContextGetter* ProfileImpl::GetRequestContext() { | 758 net::URLRequestContextGetter* ProfileImpl::GetRequestContext() { |
| 759 return io_data_.GetMainRequestContextGetter(); | 759 return io_data_.GetMainRequestContextGetter(); |
| 760 } | 760 } |
| 761 | 761 |
| 762 net::URLRequestContextGetter* ProfileImpl::GetRequestContextForRenderProcess( | 762 net::URLRequestContextGetter* ProfileImpl::GetRequestContextForRenderProcess( |
| 763 int renderer_child_id) { | 763 int renderer_child_id) { |
| 764 ExtensionService* extension_service = | 764 content::RenderProcessHost* rph = content::RenderProcessHost::FromID( |
| 765 extensions::ExtensionSystem::Get(this)->extension_service(); | 765 renderer_child_id); |
| 766 if (extension_service) { | 766 CHECK(rph); |
|
awong
2012/10/29 23:37:40
remove CHECK() since you immediately use it below.
nasko
2012/10/30 00:32:59
Done.
| |
| 767 const extensions::Extension* extension = | 767 content::StoragePartition* storage_partition = rph->GetStoragePartition(); |
| 768 extension_service->GetIsolatedAppForRenderer(renderer_child_id); | 768 |
| 769 if (extension) | 769 // TODO(nasko): Remove this conditional, once browser tag creates a proper |
| 770 return GetRequestContextForStoragePartition(extension->id()); | 770 // storage partition. |
| 771 if (rph->IsGuest()) { | |
| 772 return GetRequestContextForStoragePartition( | |
| 773 storage_partition->GetPath(), true); | |
|
awong
2012/10/29 23:37:40
Add a comment explaining the current behavior. I
nasko
2012/10/30 00:32:59
Done.
| |
| 771 } | 774 } |
| 772 | 775 |
| 773 content::RenderProcessHost* rph = content::RenderProcessHost::FromID( | 776 return storage_partition->GetURLRequestContext(); |
| 774 renderer_child_id); | |
| 775 if (rph && rph->IsGuest()) { | |
| 776 // For guest processes (used by the browser tag), we need to isolate the | |
| 777 // storage. | |
| 778 // TODO(nasko): Until we have proper storage partitions, create a | |
| 779 // non-persistent context using the RPH's id. | |
| 780 std::string id("guest-"); | |
| 781 id.append(base::IntToString(renderer_child_id)); | |
| 782 return GetRequestContextForStoragePartition(id); | |
| 783 } | |
| 784 | |
| 785 return GetRequestContext(); | |
| 786 } | 777 } |
| 787 | 778 |
| 788 net::URLRequestContextGetter* ProfileImpl::GetMediaRequestContext() { | 779 net::URLRequestContextGetter* ProfileImpl::GetMediaRequestContext() { |
| 789 // Return the default media context. | 780 // Return the default media context. |
| 790 return io_data_.GetMediaRequestContextGetter(); | 781 return io_data_.GetMediaRequestContextGetter(); |
| 791 } | 782 } |
| 792 | 783 |
| 793 net::URLRequestContextGetter* | 784 net::URLRequestContextGetter* |
| 794 ProfileImpl::GetMediaRequestContextForRenderProcess( | 785 ProfileImpl::GetMediaRequestContextForRenderProcess( |
| 795 int renderer_child_id) { | 786 int renderer_child_id) { |
| 796 ExtensionService* extension_service = | 787 content::RenderProcessHost* rph = content::RenderProcessHost::FromID( |
| 797 extensions::ExtensionSystem::Get(this)->extension_service(); | 788 renderer_child_id); |
| 798 if (extension_service) { | 789 content::StoragePartition* storage_partition = rph->GetStoragePartition(); |
| 799 const extensions::Extension* extension = | 790 |
| 800 extension_service->GetIsolatedAppForRenderer(renderer_child_id); | 791 // TODO(nasko): Remove this conditional, once browser tag creates a proper |
| 801 if (extension) | 792 // storage partition. |
| 802 return io_data_.GetIsolatedMediaRequestContextGetter(extension->id()); | 793 if (rph->IsGuest()) { |
| 794 return GetRequestContextForStoragePartition( | |
|
awong
2012/10/29 23:37:40
Should this somehow get the MediaRequestContext?
nasko
2012/10/30 00:32:59
Oh, good catch! It should be getting the media con
| |
| 795 storage_partition->GetPath(), true); | |
| 803 } | 796 } |
| 804 | 797 |
| 805 content::RenderProcessHost* rph = content::RenderProcessHost::FromID( | 798 return storage_partition->GetMediaURLRequestContext(); |
| 806 renderer_child_id); | |
| 807 if (rph && rph->IsGuest()) { | |
| 808 // For guest processes (used by the browser tag), we need to isolate the | |
| 809 // storage. | |
| 810 // TODO(nasko): Until we have proper storage partitions, create a | |
| 811 // non-persistent context using the RPH's id. | |
| 812 std::string id("guest-"); | |
| 813 id.append(base::IntToString(renderer_child_id)); | |
| 814 return io_data_.GetIsolatedMediaRequestContextGetter(id); | |
| 815 } | |
| 816 | |
| 817 return io_data_.GetMediaRequestContextGetter(); | |
| 818 } | 799 } |
| 819 | 800 |
| 820 net::URLRequestContextGetter* | 801 net::URLRequestContextGetter* |
| 821 ProfileImpl::GetMediaRequestContextForStoragePartition( | 802 ProfileImpl::GetMediaRequestContextForStoragePartition( |
| 822 const std::string& partition_id) { | 803 const FilePath& partition_path, |
| 823 return io_data_.GetIsolatedMediaRequestContextGetter(partition_id); | 804 bool in_memory) { |
| 805 return io_data_.GetIsolatedMediaRequestContextGetter(partition_path, | |
| 806 in_memory); | |
| 824 } | 807 } |
| 825 | 808 |
| 826 content::ResourceContext* ProfileImpl::GetResourceContext() { | 809 content::ResourceContext* ProfileImpl::GetResourceContext() { |
| 827 return io_data_.GetResourceContext(); | 810 return io_data_.GetResourceContext(); |
| 828 } | 811 } |
| 829 | 812 |
| 830 net::URLRequestContextGetter* ProfileImpl::GetRequestContextForExtensions() { | 813 net::URLRequestContextGetter* ProfileImpl::GetRequestContextForExtensions() { |
| 831 return io_data_.GetExtensionsRequestContextGetter(); | 814 return io_data_.GetExtensionsRequestContextGetter(); |
| 832 } | 815 } |
| 833 | 816 |
| 834 net::URLRequestContextGetter* ProfileImpl::GetRequestContextForStoragePartition( | 817 net::URLRequestContextGetter* ProfileImpl::GetRequestContextForStoragePartition( |
| 835 const std::string& partition_id) { | 818 const FilePath& partition_path, |
| 836 return io_data_.GetIsolatedAppRequestContextGetter(partition_id); | 819 bool in_memory) { |
| 820 return io_data_.GetIsolatedAppRequestContextGetter(partition_path, in_memory); | |
| 837 } | 821 } |
| 838 | 822 |
| 839 net::SSLConfigService* ProfileImpl::GetSSLConfigService() { | 823 net::SSLConfigService* ProfileImpl::GetSSLConfigService() { |
| 840 return ssl_config_service_manager_->Get(); | 824 return ssl_config_service_manager_->Get(); |
| 841 } | 825 } |
| 842 | 826 |
| 843 HostContentSettingsMap* ProfileImpl::GetHostContentSettingsMap() { | 827 HostContentSettingsMap* ProfileImpl::GetHostContentSettingsMap() { |
| 844 if (!host_content_settings_map_.get()) { | 828 if (!host_content_settings_map_.get()) { |
| 845 host_content_settings_map_ = new HostContentSettingsMap(GetPrefs(), false); | 829 host_content_settings_map_ = new HostContentSettingsMap(GetPrefs(), false); |
| 846 } | 830 } |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1165 if (!path.empty()) | 1149 if (!path.empty()) |
| 1166 *cache_path = path; | 1150 *cache_path = path; |
| 1167 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : | 1151 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : |
| 1168 prefs_->GetInteger(prefs::kDiskCacheSize); | 1152 prefs_->GetInteger(prefs::kDiskCacheSize); |
| 1169 } | 1153 } |
| 1170 | 1154 |
| 1171 base::Callback<ChromeURLDataManagerBackend*(void)> | 1155 base::Callback<ChromeURLDataManagerBackend*(void)> |
| 1172 ProfileImpl::GetChromeURLDataManagerBackendGetter() const { | 1156 ProfileImpl::GetChromeURLDataManagerBackendGetter() const { |
| 1173 return io_data_.GetChromeURLDataManagerBackendGetter(); | 1157 return io_data_.GetChromeURLDataManagerBackendGetter(); |
| 1174 } | 1158 } |
| OLD | NEW |