diff options
Diffstat (limited to 'chrome/browser/net')
-rw-r--r-- | chrome/browser/net/chrome_url_request_context.cc | 35 | ||||
-rw-r--r-- | chrome/browser/net/chrome_url_request_context.h | 9 |
2 files changed, 44 insertions, 0 deletions
diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc index 85a33c9..1c18ed4 100644 --- a/chrome/browser/net/chrome_url_request_context.cc +++ b/chrome/browser/net/chrome_url_request_context.cc @@ -16,6 +16,7 @@ #include "chrome/common/chrome_switches.h" #include "chrome/common/notification_service.h" #include "chrome/common/pref_names.h" +#include "chrome/common/url_constants.h" #include "net/ftp/ftp_network_layer.h" #include "net/http/http_cache.h" #include "net/http/http_network_layer.h" @@ -155,6 +156,26 @@ ChromeURLRequestContext* ChromeURLRequestContext::CreateOriginalForMedia( } // static +ChromeURLRequestContext* ChromeURLRequestContext::CreateOriginalForExtensions( + Profile* profile, const FilePath& cookie_store_path) { + DCHECK(!profile->IsOffTheRecord()); + ChromeURLRequestContext* context = new ChromeURLRequestContext(profile); + + // All we care about for extensions is the cookie store. + DCHECK(!cookie_store_path.empty()); + context->cookie_db_.reset(new SQLitePersistentCookieStore( + cookie_store_path.ToWStringHack(), + g_browser_process->db_thread()->message_loop())); + context->cookie_store_ = new net::CookieMonster(context->cookie_db_.get()); + + // Enable cookies for extension URLs only. + const char* schemes[] = {chrome::kExtensionScheme}; + context->cookie_store_->SetCookieableSchemes(schemes, 1); + + return context; +} + +// static ChromeURLRequestContext* ChromeURLRequestContext::CreateOffTheRecord( Profile* profile) { DCHECK(profile->IsOffTheRecord()); @@ -184,6 +205,20 @@ ChromeURLRequestContext* ChromeURLRequestContext::CreateOffTheRecordForMedia( } // static +ChromeURLRequestContext* +ChromeURLRequestContext::CreateOffTheRecordForExtensions(Profile* profile) { + DCHECK(profile->IsOffTheRecord()); + ChromeURLRequestContext* context = new ChromeURLRequestContext(profile); + context->cookie_store_ = new net::CookieMonster; + + // Enable cookies for extension URLs only. + const char* schemes[] = {chrome::kExtensionScheme}; + context->cookie_store_->SetCookieableSchemes(schemes, 1); + + return context; +} + +// static ChromeURLRequestContext* ChromeURLRequestContext::CreateRequestContextForMedia( Profile* profile, const FilePath& disk_cache_path, bool off_the_record) { URLRequestContext* original_context = diff --git a/chrome/browser/net/chrome_url_request_context.h b/chrome/browser/net/chrome_url_request_context.h index 6f392a7..55af609 100644 --- a/chrome/browser/net/chrome_url_request_context.h +++ b/chrome/browser/net/chrome_url_request_context.h @@ -38,6 +38,11 @@ class ChromeURLRequestContext : public URLRequestContext, static ChromeURLRequestContext* CreateOriginalForMedia(Profile *profile, const FilePath& disk_cache_path); + // Create an instance for an original profile for extensions. This is expected + // to get called on UI thread. + static ChromeURLRequestContext* CreateOriginalForExtensions(Profile *profile, + const FilePath& cookie_store_path); + // Create an instance for use with an OTR profile. This is expected to get // called on the UI thread. static ChromeURLRequestContext* CreateOffTheRecord(Profile* profile); @@ -46,6 +51,10 @@ class ChromeURLRequestContext : public URLRequestContext, static ChromeURLRequestContext* CreateOffTheRecordForMedia(Profile* profile, const FilePath& disk_cache_path); + // Create an instance of request context for OTR profile for extensions. + static ChromeURLRequestContext* CreateOffTheRecordForExtensions( + Profile* profile); + // Clean up UI thread resources. This is expected to get called on the UI // thread before the instance is deleted on the IO thread. void CleanupOnUIThread(); |