| Index: chrome/browser/net/chrome_url_request_context.cc
|
| diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc
|
| index d06d8060aa21a06929b8d8ad1acab1b28d0070c1..566c5ce4d63ece3e6dbfcc00b689b3c64f2b630b 100644
|
| --- a/chrome/browser/net/chrome_url_request_context.cc
|
| +++ b/chrome/browser/net/chrome_url_request_context.cc
|
| @@ -375,6 +375,83 @@ ChromeURLRequestContext* FactoryForExtensions::Create() {
|
| return context;
|
| }
|
|
|
| +// Factory that creates the ChromeURLRequestContext for a given isolated app.
|
| +class FactoryForIsolatedApp : public ChromeURLRequestContextFactory {
|
| + public:
|
| + FactoryForIsolatedApp(Profile* profile, const Extension* app,
|
| + const FilePath& cookie_store_path, bool incognito)
|
| + : ChromeURLRequestContextFactory(profile),
|
| + cookie_store_path_(cookie_store_path),
|
| + incognito_(incognito),
|
| + original_context_getter_(
|
| + static_cast<ChromeURLRequestContextGetter*>(
|
| + profile->GetOriginalProfile()->GetRequestContext())) {
|
| + }
|
| +
|
| + virtual ChromeURLRequestContext* Create();
|
| +
|
| + private:
|
| + scoped_refptr<const Extension> app_;
|
| + FilePath cookie_store_path_;
|
| + bool incognito_;
|
| + scoped_refptr<ChromeURLRequestContextGetter> original_context_getter_;
|
| +};
|
| +
|
| +ChromeURLRequestContext* FactoryForIsolatedApp::Create() {
|
| + ChromeURLRequestContext* context = new ChromeURLRequestContext;
|
| + ApplyProfileParametersToContext(context);
|
| +
|
| + ChromeURLRequestContext* original_context =
|
| + original_context_getter_->GetIOContext();
|
| +
|
| + IOThread::Globals* io_thread_globals = io_thread()->globals();
|
| +
|
| + // Share the same proxy service, host resolver, cert verifier,
|
| + // and http_auth_handler_factory as the original profile.
|
| + context->set_host_resolver(original_context->host_resolver());
|
| + context->set_cert_verifier(original_context->cert_verifier());
|
| + context->set_proxy_service(original_context->proxy_service());
|
| + context->set_http_auth_handler_factory(
|
| + original_context->http_auth_handler_factory());
|
| +
|
| + net::HttpCache::BackendFactory* backend =
|
| + net::HttpCache::DefaultBackend::InMemory(0);
|
| +
|
| + net::HttpCache* cache =
|
| + new net::HttpCache(context->host_resolver(),
|
| + context->cert_verifier(),
|
| + context->dnsrr_resolver(),
|
| + NULL /* dns_cert_checker */,
|
| + context->proxy_service(),
|
| + context->ssl_config_service(),
|
| + context->http_auth_handler_factory(),
|
| + &io_thread_globals->network_delegate,
|
| + io_thread()->net_log(),
|
| + backend);
|
| +
|
| + // TODO(creis): We care about the rest of storage as well, not just cookies.
|
| + scoped_refptr<SQLitePersistentCookieStore> cookie_db = NULL;
|
| + if (!incognito_) {
|
| + DCHECK(!cookie_store_path_.empty());
|
| + cookie_db = new SQLitePersistentCookieStore(cookie_store_path_);
|
| + }
|
| + net::CookieMonster* cookie_monster =
|
| + new net::CookieMonster(cookie_db.get(), cookie_monster_delegate_);
|
| + context->set_cookie_store(cookie_monster);
|
| + context->set_cookie_policy(
|
| + new ChromeCookiePolicy(host_content_settings_map_));
|
| +
|
| + context->set_http_transaction_factory(cache);
|
| +
|
| + context->set_ftp_transaction_factory(
|
| + new net::FtpNetworkLayer(context->host_resolver()));
|
| +
|
| + appcache_service_->set_request_context(context);
|
| +
|
| + context->set_net_log(io_thread()->net_log());
|
| + return context;
|
| +}
|
| +
|
| // Factory that creates the ChromeURLRequestContext for incognito profile.
|
| class FactoryForOffTheRecord : public ChromeURLRequestContextFactory {
|
| public:
|
| @@ -650,6 +727,16 @@ ChromeURLRequestContextGetter::CreateOriginalForExtensions(
|
|
|
| // static
|
| ChromeURLRequestContextGetter*
|
| +ChromeURLRequestContextGetter::CreateOriginalForIsolatedApp(Profile* profile,
|
| + const Extension* app, const FilePath& cookie_store_path) {
|
| + DCHECK(!profile->IsOffTheRecord());
|
| + return new ChromeURLRequestContextGetter(
|
| + profile,
|
| + new FactoryForIsolatedApp(profile, app, cookie_store_path, false));
|
| +}
|
| +
|
| +// static
|
| +ChromeURLRequestContextGetter*
|
| ChromeURLRequestContextGetter::CreateOffTheRecord(Profile* profile) {
|
| DCHECK(profile->IsOffTheRecord());
|
| return new ChromeURLRequestContextGetter(
|
| @@ -665,6 +752,15 @@ ChromeURLRequestContextGetter::CreateOffTheRecordForExtensions(
|
| profile, new FactoryForExtensions(profile, FilePath(), true));
|
| }
|
|
|
| +// static
|
| +ChromeURLRequestContextGetter*
|
| +ChromeURLRequestContextGetter::CreateOffTheRecordForIsolatedApp(
|
| + Profile* profile, const Extension* app) {
|
| + DCHECK(profile->IsOffTheRecord());
|
| + return new ChromeURLRequestContextGetter(
|
| + profile, new FactoryForIsolatedApp(profile, app, FilePath(), true));
|
| +}
|
| +
|
| void ChromeURLRequestContextGetter::CleanupOnUIThread() {
|
| CheckCurrentlyOnMainThread();
|
| // Unregister for pref notifications.
|
|
|