Chromium Code Reviews| 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 2b4473fea847a51d7742f3ae0d50e4dc76bc36d5..955217678779601e7750c6ff1c36f7e2d2c074c2 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() { |
|
Matt Perry
2011/01/26 20:09:23
Any way we could unify this factory with the Facto
Charlie Reis
2011/03/01 21:33:11
I've refactored this to work with the new ProfileI
|
| + 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); |
|
willchan no longer on Chromium
2011/01/26 23:21:52
For an isolated app, we don't use a disk cache? On
Charlie Reis
2011/03/01 21:33:11
Oops, that was incorrectly copied from FactoryForO
|
| + |
| + 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); |
|
willchan no longer on Chromium
2011/01/26 23:21:52
Why are we hijacking the request context used for
Charlie Reis
2011/03/01 21:33:11
Sorry, just incorrectly copied that from FactoryFo
|
| + |
| + context->set_net_log(io_thread()->net_log()); |
| + return context; |
| +} |
| + |
| // Factory that creates the ChromeURLRequestContext for incognito profile. |
| class FactoryForOffTheRecord : public ChromeURLRequestContextFactory { |
| public: |
| @@ -651,6 +728,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( |
| @@ -666,6 +753,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. |