Index: chrome/browser/profiles/profile_impl.cc |
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc |
index e4495e3e8b5953857d294a9a408b6f0418c150e8..3eac680d24d7dafa21def0c8ddeacbbc2a38b4c1 100644 |
--- a/chrome/browser/profiles/profile_impl.cc |
+++ b/chrome/browser/profiles/profile_impl.cc |
@@ -505,6 +505,14 @@ ProfileImpl::~ProfileImpl() { |
CleanupRequestContext(media_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++) { |
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); |
+ } |
+ |
// HistoryService may call into the BookmarkModel, as such we need to |
// delete HistoryService before the BookmarkModel. The destructor for |
// HistoryService will join with HistoryService's backend thread so that |
@@ -726,6 +734,16 @@ URLRequestContextGetter* ProfileImpl::GetRequestContext() { |
return request_context_; |
} |
+URLRequestContextGetter* ProfileImpl::GetRequestContext(const Extension* app) { |
+ if (CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kEnableExperimentalAppManifests) |
Matt Perry
2011/01/26 20:09:23
chrome style is:
(HasSwitch() &&
app &&
ap
Charlie Reis
2011/03/01 21:33:11
Done.
|
+ && app != NULL |
+ && app->is_storage_isolated()) |
+ return GetRequestContextForIsolatedApp(app); |
+ |
+ return GetRequestContext(); |
+} |
+ |
URLRequestContextGetter* ProfileImpl::GetRequestContextForMedia() { |
if (!media_request_context_) { |
FilePath cache_path = base_cache_path_; |
@@ -763,6 +781,36 @@ URLRequestContextGetter* ProfileImpl::GetRequestContextForExtensions() { |
return extensions_request_context_; |
} |
+URLRequestContextGetter* ProfileImpl::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; |
+ |
+ // Have to create a new context for this app. |
+ FilePath cookie_path = GetPath(); |
+ cookie_path = cookie_path.Append(chrome::kAppStorageDirname); |
+ |
+ // Create the directory if it doesn't yet exist. |
+ if (!file_util::DirectoryExists(cookie_path)) |
+ file_util::CreateDirectory(cookie_path); |
+ cookie_path = cookie_path.Append(installed_app->id() + |
+ chrome::kAppCookiesFileExtension); |
+ |
+ ChromeURLRequestContextGetter* context = |
+ ChromeURLRequestContextGetter::CreateOriginalForIsolatedApp( |
+ this, installed_app, cookie_path); |
+ app_request_context_map_[id] = context; |
+ |
+ return context; |
+} |
+ |
void ProfileImpl::RegisterExtensionWithRequestContexts( |
const Extension* extension) { |
// AddRef to ensure the data lives until the other thread gets it. Balanced in |