OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/environment.h" | 9 #include "base/environment.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 // TODO(eroman): this isn't terribly useful anymore now that the | 808 // TODO(eroman): this isn't terribly useful anymore now that the |
809 // net::URLRequestContext is constructed by the IO thread... | 809 // net::URLRequestContext is constructed by the IO thread... |
810 NotificationService::current()->Notify( | 810 NotificationService::current()->Notify( |
811 NotificationType::DEFAULT_REQUEST_CONTEXT_AVAILABLE, | 811 NotificationType::DEFAULT_REQUEST_CONTEXT_AVAILABLE, |
812 NotificationService::AllSources(), NotificationService::NoDetails()); | 812 NotificationService::AllSources(), NotificationService::NoDetails()); |
813 } | 813 } |
814 | 814 |
815 return request_context; | 815 return request_context; |
816 } | 816 } |
817 | 817 |
| 818 URLRequestContextGetter* ProfileImpl::GetRequestContextForPossibleApp( |
| 819 const Extension* app) { |
| 820 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 821 switches::kEnableExperimentalAppManifests) && |
| 822 app != NULL && |
| 823 app->is_storage_isolated()) |
| 824 return GetRequestContextForIsolatedApp(app); |
| 825 |
| 826 return GetRequestContext(); |
| 827 } |
| 828 |
818 URLRequestContextGetter* ProfileImpl::GetRequestContextForMedia() { | 829 URLRequestContextGetter* ProfileImpl::GetRequestContextForMedia() { |
819 return io_data_.GetMediaRequestContextGetter(); | 830 return io_data_.GetMediaRequestContextGetter(); |
820 } | 831 } |
821 | 832 |
822 FaviconService* ProfileImpl::GetFaviconService(ServiceAccessType sat) { | 833 FaviconService* ProfileImpl::GetFaviconService(ServiceAccessType sat) { |
823 if (!favicon_service_created_) { | 834 if (!favicon_service_created_) { |
824 favicon_service_created_ = true; | 835 favicon_service_created_ = true; |
825 scoped_refptr<FaviconService> service(new FaviconService(this)); | 836 scoped_refptr<FaviconService> service(new FaviconService(this)); |
826 favicon_service_.swap(service); | 837 favicon_service_.swap(service); |
827 } | 838 } |
828 return favicon_service_.get(); | 839 return favicon_service_.get(); |
829 } | 840 } |
830 | 841 |
831 URLRequestContextGetter* ProfileImpl::GetRequestContextForExtensions() { | 842 URLRequestContextGetter* ProfileImpl::GetRequestContextForExtensions() { |
832 return io_data_.GetExtensionsRequestContextGetter(); | 843 return io_data_.GetExtensionsRequestContextGetter(); |
833 } | 844 } |
834 | 845 |
| 846 URLRequestContextGetter* ProfileImpl::GetRequestContextForIsolatedApp( |
| 847 const Extension* installed_app) { |
| 848 // Create a request context specific to this app on demand. |
| 849 FilePath app_path = GetPath().Append(chrome::kIsolatedAppStateDirname); |
| 850 app_path = app_path.AppendASCII(installed_app->id()); |
| 851 FilePath cookie_path = app_path.Append(chrome::kCookieFilename); |
| 852 FilePath cache_path = app_path.Append(chrome::kCacheDirname); |
| 853 |
| 854 // Create the paths if they don't yet exist. |
| 855 BrowserThread::PostTask( |
| 856 BrowserThread::FILE, FROM_HERE, |
| 857 NewRunnableFunction(&ProfileImpl::CreateIsolatedAppPaths, |
| 858 app_path, |
| 859 cache_path)); |
| 860 |
| 861 // Initialize the app context IO data on demand. |
| 862 // TODO(creis): Determine the correct cache path and size. |
| 863 io_data_.InitIsolatedApp(installed_app, cookie_path, cache_path, 0); |
| 864 |
| 865 return io_data_.GetIsolatedAppRequestContextGetter(installed_app); |
| 866 } |
| 867 |
| 868 void ProfileImpl::CreateIsolatedAppPaths(const FilePath& app_path, |
| 869 const FilePath& cache_path) { |
| 870 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 871 file_util::CreateDirectory(app_path); |
| 872 file_util::CreateDirectory(cache_path); |
| 873 } |
| 874 |
835 void ProfileImpl::RegisterExtensionWithRequestContexts( | 875 void ProfileImpl::RegisterExtensionWithRequestContexts( |
836 const Extension* extension) { | 876 const Extension* extension) { |
837 // AddRef to ensure the data lives until the other thread gets it. Balanced in | 877 // AddRef to ensure the data lives until the other thread gets it. Balanced in |
838 // OnNewExtensions. | 878 // OnNewExtensions. |
839 extension->AddRef(); | 879 extension->AddRef(); |
840 BrowserThread::PostTask( | 880 BrowserThread::PostTask( |
841 BrowserThread::IO, FROM_HERE, | 881 BrowserThread::IO, FROM_HERE, |
842 NewRunnableMethod(extension_info_map_.get(), | 882 NewRunnableMethod(extension_info_map_.get(), |
843 &ExtensionInfoMap::AddExtension, | 883 &ExtensionInfoMap::AddExtension, |
844 extension)); | 884 extension)); |
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1528 return pref_proxy_config_tracker_; | 1568 return pref_proxy_config_tracker_; |
1529 } | 1569 } |
1530 | 1570 |
1531 prerender::PrerenderManager* ProfileImpl::GetPrerenderManager() { | 1571 prerender::PrerenderManager* ProfileImpl::GetPrerenderManager() { |
1532 if (!prerender::PrerenderManager::IsPrerenderingEnabled()) | 1572 if (!prerender::PrerenderManager::IsPrerenderingEnabled()) |
1533 return NULL; | 1573 return NULL; |
1534 if (!prerender_manager_) | 1574 if (!prerender_manager_) |
1535 prerender_manager_ = new prerender::PrerenderManager(this); | 1575 prerender_manager_ = new prerender::PrerenderManager(this); |
1536 return prerender_manager_; | 1576 return prerender_manager_; |
1537 } | 1577 } |
OLD | NEW |