Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1872)

Unified Diff: net/base/cookie_monster.cc

Issue 115204: Add a separate cookie store that's used for extensions.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/base/cookie_monster.cc
===================================================================
--- net/base/cookie_monster.cc (revision 15945)
+++ net/base/cookie_monster.cc (working copy)
@@ -94,6 +94,7 @@
store_(NULL),
last_access_threshold_(
TimeDelta::FromSeconds(kDefaultAccessUpdateThresholdSeconds)) {
+ SetDefaultCookieableSchemes();
}
CookieMonster::CookieMonster(PersistentCookieStore* store)
@@ -101,6 +102,7 @@
store_(store),
last_access_threshold_(
TimeDelta::FromSeconds(kDefaultAccessUpdateThresholdSeconds)) {
+ SetDefaultCookieableSchemes();
}
CookieMonster::~CookieMonster() {
@@ -124,6 +126,13 @@
}
}
+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);
Dean McNamee 2009/05/14 07:34:38 This is so much simpler, thanks.
+}
+
// 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 @@
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 @@
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 @@
DCHECK(!creation_time.is_null());
if (!HasCookieableScheme(url)) {
- DLOG(WARNING) << "Unsupported cookie scheme: " << url.scheme();
return false;
}
@@ -733,7 +741,6 @@
std::string CookieMonster::GetCookiesWithOptions(const GURL& url,
const CookieOptions& options) {
if (!HasCookieableScheme(url)) {
- DLOG(WARNING) << "Unsupported cookie scheme: " << url.scheme();
return std::string();
}

Powered by Google App Engine
This is Rietveld 408576698