summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-11 15:22:15 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-11 15:22:15 +0000
commit10b691f4261e09a0c824ecec44f37ac74fc4dcec (patch)
tree4f00f2cb6a58eb23c04b1f231367d4810229d835 /net
parent7afca868e97f8228878fc6d3db9194c5596ecf22 (diff)
downloadchromium_src-10b691f4261e09a0c824ecec44f37ac74fc4dcec.zip
chromium_src-10b691f4261e09a0c824ecec44f37ac74fc4dcec.tar.gz
chromium_src-10b691f4261e09a0c824ecec44f37ac74fc4dcec.tar.bz2
Remove the force_session cookie option, as it's not used anymore
BUG=133903 TEST=none TBR=sky@chromium.org,wtc@chromium.org Review URL: https://chromiumcodereview.appspot.com/10694093 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146121 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/cookies/cookie_monster.cc39
-rw-r--r--net/cookies/cookie_monster.h14
-rw-r--r--net/cookies/cookie_monster_store_test.cc7
-rw-r--r--net/cookies/cookie_monster_unittest.cc64
-rw-r--r--net/cookies/cookie_options.h10
-rw-r--r--net/url_request/url_request_test_util.cc3
-rw-r--r--net/url_request/url_request_test_util.h1
-rw-r--r--net/url_request/url_request_unittest.cc39
8 files changed, 22 insertions, 155 deletions
diff --git a/net/cookies/cookie_monster.cc b/net/cookies/cookie_monster.cc
index 406dfcb..bdac04c 100644
--- a/net/cookies/cookie_monster.cc
+++ b/net/cookies/cookie_monster.cc
@@ -1192,7 +1192,7 @@ bool CookieMonster::SetCookieWithDetails(
url, name, value, domain, path,
mac_key, mac_algorithm,
creation_time, expiration_time,
- secure, http_only, !expiration_time.is_null()));
+ secure, http_only));
if (!cc.get())
return false;
@@ -1916,13 +1916,10 @@ bool CookieMonster::SetCookieWithCreationTimeAndOptions(
scoped_ptr<CanonicalCookie> cc;
Time cookie_expires = CanonExpiration(pc, creation_time);
- bool session_only = options.force_session() || cookie_expires.is_null();
cc.reset(new CanonicalCookie(url, pc.Name(), pc.Value(), cookie_domain,
cookie_path, mac_key, mac_algorithm,
creation_time, cookie_expires,
- creation_time, pc.IsSecure(), pc.IsHttpOnly(),
- !cookie_expires.is_null(),
- !session_only));
+ creation_time, pc.IsSecure(), pc.IsHttpOnly()));
if (!cc.get()) {
VLOG(kVlogSetCookies) << "WARNING: Failed to allocate CanonicalCookie";
@@ -1949,7 +1946,7 @@ bool CookieMonster::SetCanonicalCookie(scoped_ptr<CanonicalCookie>* cc,
// was to delete the cookie which we've already done.
if (!already_expired || keep_expired_cookies_) {
// See InitializeHistograms() for details.
- if ((*cc)->DoesExpire()) {
+ if ((*cc)->IsPersistent()) {
histogram_expiration_duration_minutes_->Add(
((*cc)->ExpiryDate() - creation_time).InMinutes());
}
@@ -2609,9 +2606,7 @@ void CookieMonster::ParsedCookie::SetupAttributes() {
CookieMonster::CanonicalCookie::CanonicalCookie()
: secure_(false),
- httponly_(false),
- has_expires_(false),
- is_persistent_(false) {
+ httponly_(false) {
SetSessionCookieExpiryTime();
}
@@ -2620,8 +2615,7 @@ CookieMonster::CanonicalCookie::CanonicalCookie(
const std::string& domain, const std::string& path,
const std::string& mac_key, const std::string& mac_algorithm,
const base::Time& creation, const base::Time& expiration,
- const base::Time& last_access, bool secure, bool httponly, bool has_expires,
- bool is_persistent)
+ const base::Time& last_access, bool secure, bool httponly)
: source_(GetCookieSourceFromURL(url)),
name_(name),
value_(value),
@@ -2633,13 +2627,9 @@ CookieMonster::CanonicalCookie::CanonicalCookie(
expiry_date_(expiration),
last_access_date_(last_access),
secure_(secure),
- httponly_(httponly),
- has_expires_(has_expires),
- is_persistent_(is_persistent) {
- if (!has_expires_) {
- DCHECK(!is_persistent_);
+ httponly_(httponly) {
+ if (expiration.is_null())
SetSessionCookieExpiryTime();
- }
}
CookieMonster::CanonicalCookie::CanonicalCookie(const GURL& url,
@@ -2653,10 +2643,8 @@ CookieMonster::CanonicalCookie::CanonicalCookie(const GURL& url,
creation_date_(Time::Now()),
last_access_date_(Time()),
secure_(pc.IsSecure()),
- httponly_(pc.IsHttpOnly()),
- has_expires_(pc.HasExpires()),
- is_persistent_(pc.HasExpires()) {
- if (has_expires_)
+ httponly_(pc.IsHttpOnly()) {
+ if (pc.HasExpires())
expiry_date_ = CanonExpiration(pc, creation_date_);
else
SetSessionCookieExpiryTime();
@@ -2697,7 +2685,6 @@ void CookieMonster::CanonicalCookie::SetSessionCookieExpiryTime() {
// cookie has to be persistent and given a default expiration time.
expiry_date_ = base::Time::Now() +
base::TimeDelta::FromDays(kPersistentSessionCookieExpiryInDays);
- has_expires_ = true;
#endif
}
@@ -2723,7 +2710,7 @@ CookieMonster::CanonicalCookie* CookieMonster::CanonicalCookie::Create(
return (Create(url, pc.Name(), pc.Value(), domain_string, path_string,
mac_key, mac_algorithm, creation_time, expiration_time,
- pc.IsSecure(), pc.IsHttpOnly(), !expiration_time.is_null()));
+ pc.IsSecure(), pc.IsHttpOnly()));
}
CookieMonster::CanonicalCookie* CookieMonster::CanonicalCookie::Create(
@@ -2737,8 +2724,7 @@ CookieMonster::CanonicalCookie* CookieMonster::CanonicalCookie::Create(
const base::Time& creation,
const base::Time& expiration,
bool secure,
- bool http_only,
- bool is_persistent) {
+ bool http_only) {
// Expect valid attribute tokens and values, as defined by the ParsedCookie
// logic, otherwise don't create the cookie.
std::string parsed_name = ParsedCookie::ParseTokenString(name);
@@ -2776,8 +2762,7 @@ CookieMonster::CanonicalCookie* CookieMonster::CanonicalCookie::Create(
return new CanonicalCookie(url, parsed_name, parsed_value, cookie_domain,
cookie_path, mac_key, mac_algorithm, creation,
- expiration, creation, secure, http_only,
- !expiration.is_null(), is_persistent);
+ expiration, creation, secure, http_only);
}
bool CookieMonster::CanonicalCookie::IsOnPath(
diff --git a/net/cookies/cookie_monster.h b/net/cookies/cookie_monster.h
index e0de25a..513e0d8 100644
--- a/net/cookies/cookie_monster.h
+++ b/net/cookies/cookie_monster.h
@@ -680,9 +680,7 @@ class NET_EXPORT CookieMonster::CanonicalCookie {
const base::Time& expiration,
const base::Time& last_access,
bool secure,
- bool httponly,
- bool has_expires,
- bool is_persistent);
+ bool httponly);
// This constructor does canonicalization but not validation.
// The result of this constructor should not be relied on in contexts
@@ -712,8 +710,7 @@ class NET_EXPORT CookieMonster::CanonicalCookie {
const base::Time& creation,
const base::Time& expiration,
bool secure,
- bool http_only,
- bool is_persistent);
+ bool http_only);
const std::string& Source() const { return source_; }
const std::string& Name() const { return name_; }
@@ -724,8 +721,7 @@ class NET_EXPORT CookieMonster::CanonicalCookie {
const std::string& MACAlgorithm() const { return mac_algorithm_; }
const base::Time& CreationDate() const { return creation_date_; }
const base::Time& LastAccessDate() const { return last_access_date_; }
- bool DoesExpire() const { return has_expires_; }
- bool IsPersistent() const { return is_persistent_; }
+ bool IsPersistent() const { return !expiry_date_.is_null(); }
const base::Time& ExpiryDate() const { return expiry_date_; }
bool IsSecure() const { return secure_; }
bool IsHttpOnly() const { return httponly_; }
@@ -734,7 +730,7 @@ class NET_EXPORT CookieMonster::CanonicalCookie {
bool IsHostCookie() const { return !IsDomainCookie(); }
bool IsExpired(const base::Time& current) {
- return has_expires_ && current >= expiry_date_;
+ return !expiry_date_.is_null() && current >= expiry_date_;
}
// Are the cookies considered equivalent in the eyes of RFC 2965.
@@ -789,8 +785,6 @@ class NET_EXPORT CookieMonster::CanonicalCookie {
base::Time last_access_date_;
bool secure_;
bool httponly_;
- bool has_expires_;
- bool is_persistent_;
};
class CookieMonster::Delegate
diff --git a/net/cookies/cookie_monster_store_test.cc b/net/cookies/cookie_monster_store_test.cc
index 91f1b84..ff5bb8a 100644
--- a/net/cookies/cookie_monster_store_test.cc
+++ b/net/cookies/cookie_monster_store_test.cc
@@ -116,9 +116,8 @@ CookieMonster::CanonicalCookie BuildCanonicalCookie(
return CookieMonster::CanonicalCookie(
GURL(), pc.Name(), pc.Value(), key, cookie_path,
pc.MACKey(), pc.MACAlgorithm(),
- creation_time, creation_time, cookie_expires,
- pc.IsSecure(), pc.IsHttpOnly(),
- !cookie_expires.is_null(), !cookie_expires.is_null());
+ creation_time, cookie_expires, creation_time,
+ pc.IsSecure(), pc.IsHttpOnly());
}
void AddCookieToList(
@@ -217,7 +216,7 @@ CookieMonster* CreateMonsterFromStoreForGC(
CookieMonster::CanonicalCookie cc(
GURL(), "a", "1", base::StringPrintf("h%05d.izzle", i), "/path",
mac_key, mac_algorithm, creation_time, expiration_time,
- last_access_time, false, false, true, true);
+ last_access_time, false, false);
store->AddCookie(cc);
}
diff --git a/net/cookies/cookie_monster_unittest.cc b/net/cookies/cookie_monster_unittest.cc
index 84183d7..4f76439 100644
--- a/net/cookies/cookie_monster_unittest.cc
+++ b/net/cookies/cookie_monster_unittest.cc
@@ -1776,7 +1776,7 @@ TEST_F(CookieMonsterTest, SetCookieWithDetails) {
EXPECT_EQ("B", it->Value());
EXPECT_EQ("www.google.izzle", it->Domain());
EXPECT_EQ("/foo", it->Path());
- EXPECT_FALSE(it->DoesExpire());
+ EXPECT_FALSE(it->IsPersistent());
EXPECT_FALSE(it->IsSecure());
EXPECT_FALSE(it->IsHttpOnly());
@@ -2140,35 +2140,6 @@ TEST_F(CookieMonsterTest, MAYBE_GarbageCollectionTriggers) {
}
}
-// This test checks that setting a cookie forcing it to be a session only
-// cookie works as expected.
-TEST_F(CookieMonsterTest, ForceSessionOnly) {
- scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
- CookieOptions options;
-
- // Set a persistent cookie, but force it to be a session cookie.
- options.set_force_session();
- ASSERT_TRUE(SetCookieWithOptions(
- cm, url_google_,
- std::string(kValidCookieLine) + "; expires=Mon, 18-Apr-22 22:50:13 GMT",
- options));
-
- // Get the canonical cookie.
- CookieList cookie_list = GetAllCookies(cm);
- ASSERT_EQ(1U, cookie_list.size());
- ASSERT_FALSE(cookie_list[0].IsPersistent());
-
- // Use a past expiry date to delete the cookie, but force it to session only.
- ASSERT_TRUE(SetCookieWithOptions(
- cm, url_google_,
- std::string(kValidCookieLine) + "; expires=Mon, 18-Apr-1977 22:50:13 GMT",
- options));
-
- // Check that the cookie was deleted.
- cookie_list = GetAllCookies(cm);
- ASSERT_EQ(0U, cookie_list.size());
-}
-
// This test checks that keep expired cookies flag is working.
TEST_F(CookieMonsterTest, KeepExpiredCookies) {
scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
@@ -2602,44 +2573,13 @@ TEST_F(MultiThreadedCookieMonsterTest, ThreadCheckDeleteCanonicalCookie) {
EXPECT_TRUE(callback.result());
}
-TEST_F(CookieMonsterTest, ShortLivedSessionCookies) {
- scoped_refptr<MockPersistentCookieStore> store(
- new MockPersistentCookieStore);
- scoped_refptr<CookieMonster> cm(new CookieMonster(store, NULL));
-
- // Create a short-lived session cookie.
- CookieOptions options;
- options.set_force_session();
- Time current = Time::Now();
- EXPECT_TRUE(SetCookieWithOptions(cm, url_google_,
- std::string(kValidCookieLine) +
- "; max-age=10",
- options));
-
- // FindCookiesForKey asserts that its caller holds this lock.
- base::AutoLock auto_lock(cm->lock_);
-
- // Get cookies before the cookie has expired.
- std::vector<CookieMonster::CanonicalCookie*> cookies;
- cm->FindCookiesForKey(cm->GetKey(url_google_.host()), url_google_,
- CookieOptions(), current, false, &cookies);
- EXPECT_EQ(1U, cookies.size());
-
- // Get cookies after the cookie has expired.
- cookies.clear();
- cm->FindCookiesForKey(cm->GetKey(url_google_.host()), url_google_,
- CookieOptions(), current + TimeDelta::FromSeconds(20),
- false, &cookies);
- EXPECT_EQ(0U, cookies.size());
-}
-
TEST_F(CookieMonsterTest, InvalidExpiryTime) {
CookieMonster::ParsedCookie pc(
std::string(kValidCookieLine) + "; expires=Blarg arg arg");
scoped_ptr<CookieMonster::CanonicalCookie> cookie(
CookieMonster::CanonicalCookie::Create(url_google_, pc));
- ASSERT_FALSE(cookie->DoesExpire());
+ ASSERT_FALSE(cookie->IsPersistent());
}
// Test that CookieMonster writes session cookies into the underlying
diff --git a/net/cookies/cookie_options.h b/net/cookies/cookie_options.h
index a59054a..05c3a19 100644
--- a/net/cookies/cookie_options.h
+++ b/net/cookies/cookie_options.h
@@ -16,23 +16,15 @@ class CookieOptions {
// - reading operations will not return httponly cookies.
// - writing operations will not write httponly cookies.
CookieOptions()
- : exclude_httponly_(true),
- force_session_(false) {
+ : exclude_httponly_(true) {
}
void set_exclude_httponly() { exclude_httponly_ = true; }
void set_include_httponly() { exclude_httponly_ = false; }
bool exclude_httponly() const { return exclude_httponly_; }
- // Forces a cookie to be saved as a session cookie. If the expiration time of
- // the cookie is in the past, i.e. the cookie would end up being deleted, this
- // option is ignored. See CookieMonsterTest.ForceSessionOnly.
- void set_force_session() { force_session_ = true; }
- bool force_session() const { return force_session_; }
-
private:
bool exclude_httponly_;
- bool force_session_;
};
} // namespace net
diff --git a/net/url_request/url_request_test_util.cc b/net/url_request/url_request_test_util.cc
index 55f72cd..45ed7b7 100644
--- a/net/url_request/url_request_test_util.cc
+++ b/net/url_request/url_request_test_util.cc
@@ -475,9 +475,6 @@ bool TestNetworkDelegate::OnCanSetCookie(const net::URLRequest& request,
if (cookie_options_bit_mask_ & NO_SET_COOKIE)
allow = false;
- if (cookie_options_bit_mask_ & FORCE_SESSION)
- options->set_force_session();
-
if (!allow) {
blocked_set_cookie_count_++;
} else {
diff --git a/net/url_request/url_request_test_util.h b/net/url_request/url_request_test_util.h
index 29d9b5f..d1d371f 100644
--- a/net/url_request/url_request_test_util.h
+++ b/net/url_request/url_request_test_util.h
@@ -188,7 +188,6 @@ class TestNetworkDelegate : public net::NetworkDelegate {
enum Options {
NO_GET_COOKIES = 1 << 0,
NO_SET_COOKIE = 1 << 1,
- FORCE_SESSION = 1 << 2,
};
TestNetworkDelegate();
diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc
index 76aaa9d..1fdfc1d 100644
--- a/net/url_request/url_request_unittest.cc
+++ b/net/url_request/url_request_unittest.cc
@@ -3414,45 +3414,6 @@ TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy_Async) {
}
}
-void CheckCookiePolicyCallback(bool* was_run, const CookieList& cookies) {
- EXPECT_EQ(1U, cookies.size());
- EXPECT_FALSE(cookies[0].IsPersistent());
- *was_run = true;
- MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
-}
-
-TEST_F(URLRequestTest, CookiePolicy_ForceSession) {
- LocalHttpTestServer test_server;
- ASSERT_TRUE(test_server.Start());
-
- // Set up a cookie.
- {
- TestNetworkDelegate network_delegate;
- default_context_.set_network_delegate(&network_delegate);
- TestDelegate d;
- network_delegate.set_cookie_options(TestNetworkDelegate::FORCE_SESSION);
- URLRequest req(
- test_server.GetURL(
- "set-cookie?A=1;expires=\"Fri, 05 Feb 2010 23:42:01 GMT\""),
- &d,
- &default_context_);
- req.Start(); // Triggers an asynchronous cookie policy check.
-
- MessageLoop::current()->Run();
-
- EXPECT_EQ(0, network_delegate.blocked_get_cookies_count());
- EXPECT_EQ(0, network_delegate.blocked_set_cookie_count());
- }
- default_context_.set_network_delegate(&default_network_delegate_);
-
- // Now, check the cookie store.
- bool was_run = false;
- default_context_.cookie_store()->GetCookieMonster()->GetAllCookiesAsync(
- base::Bind(&CheckCookiePolicyCallback, &was_run));
- MessageLoop::current()->RunAllPending();
- DCHECK(was_run);
-}
-
// In this test, we do a POST which the server will 302 redirect.
// The subsequent transaction should use GET, and should not send the
// Content-Type header.