diff options
author | mpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-14 18:46:21 +0000 |
---|---|---|
committer | mpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-14 18:46:21 +0000 |
commit | 47accfd64443e175562abc65769457ffef5d3322 (patch) | |
tree | 27d646d32565934449f56cb77982f7283851aca8 /net/base/cookie_monster.cc | |
parent | 351e70b561dfbf40350cf7607e6af0403e43e64c (diff) | |
download | chromium_src-47accfd64443e175562abc65769457ffef5d3322.zip chromium_src-47accfd64443e175562abc65769457ffef5d3322.tar.gz chromium_src-47accfd64443e175562abc65769457ffef5d3322.tar.bz2 |
Add a separate cookie store that's used for extensions.
Modify CookieMonster to support overriding the "cookieable schemes".
Review URL: http://codereview.chromium.org/115204
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16083 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/cookie_monster.cc')
-rw-r--r-- | net/base/cookie_monster.cc | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/net/base/cookie_monster.cc b/net/base/cookie_monster.cc index 4b5d8e0..470bfc2 100644 --- a/net/base/cookie_monster.cc +++ b/net/base/cookie_monster.cc @@ -94,6 +94,7 @@ CookieMonster::CookieMonster() store_(NULL), last_access_threshold_( TimeDelta::FromSeconds(kDefaultAccessUpdateThresholdSeconds)) { + SetDefaultCookieableSchemes(); } CookieMonster::CookieMonster(PersistentCookieStore* store) @@ -101,6 +102,7 @@ CookieMonster::CookieMonster(PersistentCookieStore* store) store_(store), last_access_threshold_( TimeDelta::FromSeconds(kDefaultAccessUpdateThresholdSeconds)) { + SetDefaultCookieableSchemes(); } CookieMonster::~CookieMonster() { @@ -124,6 +126,13 @@ void CookieMonster::InitStore() { } } +void CookieMonster::SetDefaultCookieableSchemes() { + // Note: file must be the last scheme. + static const char* kDefaultCookieableSchemes[] = { "http", "https", "file" }; + int num_schemes = enable_file_scheme_ ? 3 : 2; + SetCookieableSchemes(kDefaultCookieableSchemes, num_schemes); +} + // The system resolution is not high enough, so we can have multiple // set cookies that result in the same system time. When this happens, we // increment by one Time unit. Let's hope computers don't get too fast. @@ -358,18 +367,11 @@ static Time CanonExpiration(const CookieMonster::ParsedCookie& pc, return Time(); } -static bool HasCookieableScheme(const GURL& url) { - static const char* kCookieableSchemes[] = { "http", "https", "file" }; - static const int kCookieableSchemesLen = arraysize(kCookieableSchemes); - static const int kCookieableSchemesFileIndex = 2; - +bool CookieMonster::HasCookieableScheme(const GURL& url) { // Make sure the request is on a cookie-able url scheme. - for (int i = 0; i < kCookieableSchemesLen; ++i) { + for (size_t i = 0; i < cookieable_schemes_.size(); ++i) { // We matched a scheme. - if (url.SchemeIs(kCookieableSchemes[i])) { - // This is file:// scheme - if (i == kCookieableSchemesFileIndex) - return CookieMonster::enable_file_scheme_; + if (url.SchemeIs(cookieable_schemes_[i].c_str())) { // We've matched a supported scheme. return true; } @@ -380,6 +382,13 @@ static bool HasCookieableScheme(const GURL& url) { return false; } +void CookieMonster::SetCookieableSchemes( + const char* schemes[], size_t num_schemes) { + cookieable_schemes_.clear(); + cookieable_schemes_.insert(cookieable_schemes_.end(), + schemes, schemes + num_schemes); +} + bool CookieMonster::SetCookie(const GURL& url, const std::string& cookie_line) { CookieOptions options; @@ -419,7 +428,6 @@ bool CookieMonster::SetCookieWithCreationTimeWithOptions( DCHECK(!creation_time.is_null()); if (!HasCookieableScheme(url)) { - DLOG(WARNING) << "Unsupported cookie scheme: " << url.scheme(); return false; } @@ -733,7 +741,6 @@ std::string CookieMonster::GetCookies(const GURL& url) { std::string CookieMonster::GetCookiesWithOptions(const GURL& url, const CookieOptions& options) { if (!HasCookieableScheme(url)) { - DLOG(WARNING) << "Unsupported cookie scheme: " << url.scheme(); return std::string(); } |