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

Unified 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: Refactor and address comments. Created 9 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/profiles/profile_impl.cc
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index 3c05a6ab491da611587bf1e3756ca233de67b896..c3c0677a4ecb49a31fdcbc2c3b0bb3a440385b06 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -815,6 +815,17 @@ URLRequestContextGetter* ProfileImpl::GetRequestContext() {
return request_context;
}
+URLRequestContextGetter* ProfileImpl::GetRequestContextForPossibleApp(
+ const Extension* app) {
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableExperimentalAppManifests) &&
+ app != NULL &&
+ app->is_storage_isolated())
+ return GetRequestContextForIsolatedApp(app);
+
+ return GetRequestContext();
+}
+
URLRequestContextGetter* ProfileImpl::GetRequestContextForMedia() {
return io_data_.GetMediaRequestContextGetter();
}
@@ -832,6 +843,35 @@ URLRequestContextGetter* ProfileImpl::GetRequestContextForExtensions() {
return io_data_.GetExtensionsRequestContextGetter();
}
+URLRequestContextGetter* ProfileImpl::GetRequestContextForIsolatedApp(
+ const Extension* installed_app) {
+ // Create a request context specific to this app on demand.
+ FilePath app_path = GetPath().Append(chrome::kIsolatedAppStateDirname);
+ app_path = app_path.AppendASCII(installed_app->id());
+ FilePath cookie_path = app_path.Append(chrome::kCookieFilename);
+ FilePath cache_path = app_path.Append(chrome::kCacheDirname);
+
+ // Create the paths if they don't yet exist.
+ BrowserThread::PostTask(
+ BrowserThread::FILE, FROM_HERE,
+ NewRunnableFunction(&ProfileImpl::CreateIsolatedAppPaths,
+ app_path,
+ cache_path));
+
+ // Initialize the app context IO data on demand.
+ // TODO(creis): Determine the correct cache path and size.
+ io_data_.InitIsolatedApp(installed_app, cookie_path, cache_path, 0);
+
+ return io_data_.GetIsolatedAppRequestContextGetter(installed_app);
+}
+
+void ProfileImpl::CreateIsolatedAppPaths(const FilePath& app_path,
+ const FilePath& cache_path) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+ file_util::CreateDirectory(app_path);
+ file_util::CreateDirectory(cache_path);
+}
+
void ProfileImpl::RegisterExtensionWithRequestContexts(
const Extension* extension) {
// AddRef to ensure the data lives until the other thread gets it. Balanced in

Powered by Google App Engine
This is Rietveld 408576698