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

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: Update cookie logic in test. 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 658face4e63fec000b78586abc54cfb755e94fac..4da49a1fd5408478e51af809f751e66c79dca543 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"
@@ -155,6 +157,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();
willchan no longer on Chromium 2011/01/26 23:21:52 Looks like you're missing a horizontal whitespace
Charlie Reis 2011/03/01 21:33:11 Done.
+ iter != app_request_context_map_.end();
+ iter++) {
willchan no longer on Chromium 2011/01/26 23:21:52 http://www.corp.google.com/eng/doc/cppguide.xml?ex
Charlie Reis 2011/03/01 21:33:11 Done.
+ CleanupRequestContext(iter->second);
+ }
+
// Clean up all DB files/directories
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
@@ -379,6 +389,16 @@ class OffTheRecordProfileImpl : public Profile,
return request_context_;
}
+ virtual URLRequestContextGetter* GetRequestContext(const Extension* app) {
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableExperimentalAppManifests)
+ && app != NULL
willchan no longer on Chromium 2011/01/26 23:21:52 Put the && on the previous line as stated in http:
Charlie Reis 2011/03/01 21:33:11 Done.
+ && 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_;
@@ -393,6 +413,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,
willchan no longer on Chromium 2011/01/26 23:21:52 http://www.corp.google.com/eng/doc/cppguide.xml?ex
Charlie Reis 2011/03/01 21:33:11 Done.
+ installed_app);
+ app_request_context_map_[id] = context;
+
+ return context;
+ }
+
virtual net::SSLConfigService* GetSSLConfigService() {
return profile_->GetSSLConfigService();
}
@@ -636,6 +676,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,
willchan no longer on Chromium 2011/01/26 23:21:52 http://www.corp.google.com/eng/doc/cppguide.xml?ex
Charlie Reis 2011/03/01 21:33:11 Done.
+ 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