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

Unified Diff: chrome/browser/profiles/profile.cc

Issue 6201005: Initial support for partitioning cookies for isolated apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 11 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.cc
diff --git a/chrome/browser/profiles/profile.cc b/chrome/browser/profiles/profile.cc
index 6705e3b7ae1f0974faea9bb5e678ce3c131e11f0..5c06182d3bff6d3702310ec484e297974aede399 100644
--- a/chrome/browser/profiles/profile.cc
+++ b/chrome/browser/profiles/profile.cc
@@ -31,6 +31,8 @@
#include "chrome/browser/ui/find_bar/find_bar_state.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/common/extensions/extension.h"
#include "chrome/common/json_pref_store.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/pref_names.h"
@@ -153,6 +155,14 @@ class OffTheRecordProfileImpl : public Profile,
CleanupRequestContext(request_context_);
CleanupRequestContext(extensions_request_context_);
+ // Clean up all isolated app request contexts.
+ for (ChromeURLRequestContextGetterMap::iterator iter =
+ app_request_context_map_.begin();
+ iter != app_request_context_map_.end();
+ iter++) {
+ CleanupRequestContext(iter->second);
+ }
+
// Clean up all DB files/directories
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
@@ -377,6 +387,16 @@ class OffTheRecordProfileImpl : public Profile,
return request_context_;
}
+ virtual URLRequestContextGetter* GetRequestContext(const Extension* app) {
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableExperimentalAppManifests)
+ && app != NULL
+ && app->is_storage_isolated())
+ return GetRequestContextForIsolatedApp(app);
+
+ return GetRequestContext();
+ }
+
virtual URLRequestContextGetter* GetRequestContextForMedia() {
// In OTR mode, media request context is the same as the original one.
return request_context_;
@@ -391,6 +411,26 @@ class OffTheRecordProfileImpl : public Profile,
return extensions_request_context_;
}
+ URLRequestContextGetter* GetRequestContextForIsolatedApp(
+ const Extension* installed_app) {
+ CHECK(installed_app);
+ std::string id = installed_app->id();
+
+ // Keep a map of request contexts, one per requested app ID. Once created,
+ // the context will exist for the lifetime of the profile.
+ ChromeURLRequestContextGetterMap::iterator iter =
+ app_request_context_map_.find(id);
+ if (iter != app_request_context_map_.end())
+ return iter->second;
+
+ ChromeURLRequestContextGetter* context =
+ ChromeURLRequestContextGetter::CreateOffTheRecordForIsolatedApp(this,
+ installed_app);
+ app_request_context_map_[id] = context;
+
+ return context;
+ }
+
virtual net::SSLConfigService* GetSSLConfigService() {
return profile_->GetSSLConfigService();
}
@@ -628,6 +668,12 @@ class OffTheRecordProfileImpl : public Profile,
// The context to use for requests made by an extension while in OTR mode.
scoped_refptr<ChromeURLRequestContextGetter> extensions_request_context_;
+ // A map of request contexts, one per isolated app while in OTR mode.
+ typedef base::hash_map<std::string,
+ scoped_refptr<ChromeURLRequestContextGetter> >
+ ChromeURLRequestContextGetterMap;
+ ChromeURLRequestContextGetterMap app_request_context_map_;
+
// The download manager that only stores downloaded items in memory.
scoped_refptr<DownloadManager> download_manager_;

Powered by Google App Engine
This is Rietveld 408576698