| Index: chrome/browser/profiles/profile_impl.cc
|
| diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
|
| index 0f2bf3c159bfffb084c1a0ccddee6a4ea69d0449..73f0a8a47684d55c1e10473e84ad278a02f68c30 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++) {
|
| + 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)
|
| + && 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,37 @@ 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
|
|
|