Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Side by Side Diff: chrome/browser/profiles/profile_impl.cc

Issue 6201005: Initial support for partitioning cookies for isolated apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add ChromeURLRequestContext::Copy. Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 798 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 // TODO(eroman): this isn't terribly useful anymore now that the 809 // TODO(eroman): this isn't terribly useful anymore now that the
810 // net::URLRequestContext is constructed by the IO thread... 810 // net::URLRequestContext is constructed by the IO thread...
811 NotificationService::current()->Notify( 811 NotificationService::current()->Notify(
812 NotificationType::DEFAULT_REQUEST_CONTEXT_AVAILABLE, 812 NotificationType::DEFAULT_REQUEST_CONTEXT_AVAILABLE,
813 NotificationService::AllSources(), NotificationService::NoDetails()); 813 NotificationService::AllSources(), NotificationService::NoDetails());
814 } 814 }
815 815
816 return request_context; 816 return request_context;
817 } 817 }
818 818
819 URLRequestContextGetter* ProfileImpl::GetRequestContextForPossibleApp(
820 const Extension* installed_app) {
821 if (CommandLine::ForCurrentProcess()->HasSwitch(
822 switches::kEnableExperimentalAppManifests) &&
823 installed_app != NULL &&
824 installed_app->is_storage_isolated())
825 return GetRequestContextForIsolatedApp(installed_app);
826
827 return GetRequestContext();
828 }
829
819 URLRequestContextGetter* ProfileImpl::GetRequestContextForMedia() { 830 URLRequestContextGetter* ProfileImpl::GetRequestContextForMedia() {
820 return io_data_.GetMediaRequestContextGetter(); 831 return io_data_.GetMediaRequestContextGetter();
821 } 832 }
822 833
823 FaviconService* ProfileImpl::GetFaviconService(ServiceAccessType sat) { 834 FaviconService* ProfileImpl::GetFaviconService(ServiceAccessType sat) {
824 if (!favicon_service_created_) { 835 if (!favicon_service_created_) {
825 favicon_service_created_ = true; 836 favicon_service_created_ = true;
826 scoped_refptr<FaviconService> service(new FaviconService(this)); 837 scoped_refptr<FaviconService> service(new FaviconService(this));
827 favicon_service_.swap(service); 838 favicon_service_.swap(service);
828 } 839 }
829 return favicon_service_.get(); 840 return favicon_service_.get();
830 } 841 }
831 842
832 URLRequestContextGetter* ProfileImpl::GetRequestContextForExtensions() { 843 URLRequestContextGetter* ProfileImpl::GetRequestContextForExtensions() {
833 return io_data_.GetExtensionsRequestContextGetter(); 844 return io_data_.GetExtensionsRequestContextGetter();
834 } 845 }
835 846
847 URLRequestContextGetter* ProfileImpl::GetRequestContextForIsolatedApp(
848 const Extension* installed_app) {
849 // Create a request context specific to this app on demand.
850 FilePath app_path = GetPath().Append(chrome::kIsolatedAppStateDirname);
willchan no longer on Chromium 2011/03/03 18:16:59 How about add app_path as a parameter to the Handl
Charlie Reis 2011/03/04 22:34:53 Fixed. Much cleaner.
851 app_path = app_path.AppendASCII(installed_app->id());
852 FilePath cookie_path = app_path.Append(chrome::kCookieFilename);
853 FilePath cache_path = app_path.Append(chrome::kCacheDirname);
854
855 // Create the paths if they don't yet exist.
856 BrowserThread::PostTask(
857 BrowserThread::FILE, FROM_HERE,
858 NewRunnableFunction(&ProfileImpl::CreateIsolatedAppPaths,
Matt Perry 2011/03/03 22:59:21 Are these paths accessed only on the file thread?
Charlie Reis 2011/03/04 22:34:53 I was under the impression all file I/O had to be
Charlie Reis 2011/03/04 23:49:41 Hmm, looks like you may be right, Matt: http://bui
Matt Perry 2011/03/04 23:53:53 I think you might just have to do it earlier in st
Charlie Reis 2011/03/08 00:56:48 I'm uneasy about creating the path when the app is
Charlie Reis 2011/03/08 02:34:04 Ugh. It's a known issue and isn't likely to be fi
Charlie Reis 2011/03/08 20:44:41 Chatted with rdsmith@, and we agreed that the dire
859 app_path,
860 cache_path));
861
862 // Initialize the app context IO data on demand.
863 // TODO(creis): Determine the correct cache size.
864 io_data_.InitIsolatedApp(installed_app, cookie_path, cache_path, 0);
865
866 return io_data_.GetIsolatedAppRequestContextGetter(installed_app);
867 }
868
869 void ProfileImpl::CreateIsolatedAppPaths(const FilePath& app_path,
870 const FilePath& cache_path) {
871 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
872 file_util::CreateDirectory(app_path);
873 file_util::CreateDirectory(cache_path);
874 }
875
836 void ProfileImpl::RegisterExtensionWithRequestContexts( 876 void ProfileImpl::RegisterExtensionWithRequestContexts(
837 const Extension* extension) { 877 const Extension* extension) {
838 // AddRef to ensure the data lives until the other thread gets it. Balanced in 878 // AddRef to ensure the data lives until the other thread gets it. Balanced in
839 // OnNewExtensions. 879 // OnNewExtensions.
840 extension->AddRef(); 880 extension->AddRef();
841 BrowserThread::PostTask( 881 BrowserThread::PostTask(
842 BrowserThread::IO, FROM_HERE, 882 BrowserThread::IO, FROM_HERE,
843 NewRunnableMethod(extension_info_map_.get(), 883 NewRunnableMethod(extension_info_map_.get(),
844 &ExtensionInfoMap::AddExtension, 884 &ExtensionInfoMap::AddExtension,
845 extension)); 885 extension));
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
1529 return pref_proxy_config_tracker_; 1569 return pref_proxy_config_tracker_;
1530 } 1570 }
1531 1571
1532 prerender::PrerenderManager* ProfileImpl::GetPrerenderManager() { 1572 prerender::PrerenderManager* ProfileImpl::GetPrerenderManager() {
1533 if (!prerender::PrerenderManager::IsPrerenderingEnabled()) 1573 if (!prerender::PrerenderManager::IsPrerenderingEnabled())
1534 return NULL; 1574 return NULL;
1535 if (!prerender_manager_) 1575 if (!prerender_manager_)
1536 prerender_manager_ = new prerender::PrerenderManager(this); 1576 prerender_manager_ = new prerender::PrerenderManager(this);
1537 return prerender_manager_; 1577 return prerender_manager_;
1538 } 1578 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698