diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-11 15:22:15 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-11 15:22:15 +0000 |
commit | 10b691f4261e09a0c824ecec44f37ac74fc4dcec (patch) | |
tree | 4f00f2cb6a58eb23c04b1f231367d4810229d835 | |
parent | 7afca868e97f8228878fc6d3db9194c5596ecf22 (diff) | |
download | chromium_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
18 files changed, 62 insertions, 218 deletions
diff --git a/chrome/browser/automation/automation_util.cc b/chrome/browser/automation/automation_util.cc index 86bfaec..12057f5 100644 --- a/chrome/browser/automation/automation_util.cc +++ b/chrome/browser/automation/automation_util.cc @@ -263,7 +263,7 @@ void GetCookiesJSON(AutomationProvider* provider, cookie_dict->SetString("domain", cookie.Domain()); cookie_dict->SetBoolean("secure", cookie.IsSecure()); cookie_dict->SetBoolean("http_only", cookie.IsHttpOnly()); - if (cookie.DoesExpire()) + if (cookie.IsPersistent()) cookie_dict->SetDouble("expiry", cookie.ExpiryDate().ToDoubleT()); list->Append(cookie_dict); } @@ -368,7 +368,7 @@ void SetCookieJSON(AutomationProvider* provider, net::CookieMonster::CanonicalCookie::Create( GURL(url), name, value, domain, path, mac_key, mac_algorithm, base::Time(), - base::Time::FromDoubleT(expiry), secure, http_only, expiry != 0)); + base::Time::FromDoubleT(expiry), secure, http_only)); if (!cookie.get()) { reply.SendError("given 'cookie' parameters are invalid"); return; diff --git a/chrome/browser/extensions/api/cookies/cookies_helpers.cc b/chrome/browser/extensions/api/cookies/cookies_helpers.cc index a139d5d..55917d5 100644 --- a/chrome/browser/extensions/api/cookies/cookies_helpers.cc +++ b/chrome/browser/extensions/api/cookies/cookies_helpers.cc @@ -70,8 +70,8 @@ DictionaryValue* CreateCookieValue( IsStringUTF8(cookie.Path()) ? cookie.Path() : ""); result->SetBoolean(keys::kSecureKey, cookie.IsSecure()); result->SetBoolean(keys::kHttpOnlyKey, cookie.IsHttpOnly()); - result->SetBoolean(keys::kSessionKey, !cookie.DoesExpire()); - if (cookie.DoesExpire()) { + result->SetBoolean(keys::kSessionKey, !cookie.IsPersistent()); + if (cookie.IsPersistent()) { result->SetDouble(keys::kExpirationDateKey, cookie.ExpiryDate().ToDoubleT()); } @@ -155,7 +155,7 @@ bool MatchFilter::MatchesCookie( MatchesDomain(cookie.Domain()) && MatchesString(keys::kPathKey, cookie.Path()) && MatchesBoolean(keys::kSecureKey, cookie.IsSecure()) && - MatchesBoolean(keys::kSessionKey, !cookie.DoesExpire()); + MatchesBoolean(keys::kSessionKey, !cookie.IsPersistent()); } bool MatchFilter::MatchesString(const char* key, const std::string& value) { diff --git a/chrome/browser/extensions/api/cookies/cookies_unittest.cc b/chrome/browser/extensions/api/cookies/cookies_unittest.cc index 05cf211..91c80f7 100644 --- a/chrome/browser/extensions/api/cookies/cookies_unittest.cc +++ b/chrome/browser/extensions/api/cookies/cookies_unittest.cc @@ -113,7 +113,7 @@ TEST_F(ExtensionCookiesTest, ExtensionTypeCreation) { GURL(), "ABC", "DEF", "www.foobar.com", "/", std::string(), std::string(), base::Time(), base::Time(), base::Time(), - false, false, false, false); + false, false); scoped_ptr<DictionaryValue> cookie_value1( cookies_helpers::CreateCookieValue( cookie1, "some cookie store")); @@ -141,7 +141,7 @@ TEST_F(ExtensionCookiesTest, ExtensionTypeCreation) { net::CookieMonster::CanonicalCookie cookie2( GURL(), "ABC", "DEF", ".foobar.com", "/", std::string(), std::string(), base::Time(), base::Time::FromDoubleT(10000), base::Time(), - false, false, true, true); + false, false); scoped_ptr<DictionaryValue> cookie_value2( cookies_helpers::CreateCookieValue( cookie2, "some cookie store")); @@ -168,7 +168,7 @@ TEST_F(ExtensionCookiesTest, GetURLFromCanonicalCookie) { GURL(), "ABC", "DEF", "www.foobar.com", "/", std::string(), std::string(), base::Time(), base::Time(), base::Time(), - false, false, false, false); + false, false); EXPECT_EQ("http://www.foobar.com/", cookies_helpers::GetURLFromCanonicalCookie( cookie1).spec()); @@ -177,7 +177,7 @@ TEST_F(ExtensionCookiesTest, GetURLFromCanonicalCookie) { GURL(), "ABC", "DEF", ".helloworld.com", "/", std::string(), std::string(), base::Time(), base::Time(), base::Time(), - true, false, false, false); + true, false); EXPECT_EQ("https://helloworld.com/", cookies_helpers::GetURLFromCanonicalCookie( cookie2).spec()); @@ -210,7 +210,7 @@ TEST_F(ExtensionCookiesTest, DomainMatching) { net::CookieMonster::CanonicalCookie cookie(GURL(), "", "", tests[i].domain, "", "", "", base::Time(), base::Time(), base::Time(), - false, false, false, false); + false, false); EXPECT_EQ(tests[i].matches, filter.MatchesCookie(cookie)); } } @@ -221,7 +221,7 @@ TEST_F(ExtensionCookiesTest, DecodeUTF8WithErrorHandling) { "test.com", "/path\203", "", "", base::Time(), base::Time(), base::Time(), - false, false, false, false); + false, false); scoped_ptr<DictionaryValue> cookie_value( cookies_helpers::CreateCookieValue( cookie, "some cookie store")); diff --git a/chrome/browser/net/sqlite_persistent_cookie_store.cc b/chrome/browser/net/sqlite_persistent_cookie_store.cc index 33ddb35..1d7f241 100644 --- a/chrome/browser/net/sqlite_persistent_cookie_store.cc +++ b/chrome/browser/net/sqlite_persistent_cookie_store.cc @@ -253,7 +253,7 @@ class SQLitePersistentCookieStore::Backend // database can store session cookies as well as persistent cookies. Databases // of version 5 are incompatible with older versions of code. If a database of // version 5 is read by older code, session cookies will be treated as normal -// cookies. +// cookies. Currently, these fields are written, but not read anymore. // // In version 4, we migrated the time epoch. If you open the DB with an older // version on Mac or Linux, the times will look wonky, but the file will likely @@ -627,9 +627,7 @@ bool SQLitePersistentCookieStore::Backend::LoadCookiesForDomains( Time::FromInternalValue(smt.ColumnInt64(5)), // expires_utc Time::FromInternalValue(smt.ColumnInt64(8)), // last_access_utc smt.ColumnInt(6) != 0, // secure - smt.ColumnInt(7) != 0, // httponly - smt.ColumnInt(9) != 0, // has_expires - smt.ColumnInt(10) != 0)); // is_persistent + smt.ColumnInt(7) != 0)); // httponly DLOG_IF(WARNING, cc->CreationDate() > Time::Now()) << L"CreationDate too recent"; cookies_per_origin_[CookieOrigin(cc->Domain(), cc->IsSecure())]++; @@ -854,7 +852,7 @@ void SQLitePersistentCookieStore::Backend::Commit() { add_smt.BindInt(6, po->cc().IsSecure()); add_smt.BindInt(7, po->cc().IsHttpOnly()); add_smt.BindInt64(8, po->cc().LastAccessDate().ToInternalValue()); - add_smt.BindInt(9, po->cc().DoesExpire()); + add_smt.BindInt(9, po->cc().IsPersistent()); add_smt.BindInt(10, po->cc().IsPersistent()); if (!add_smt.Run()) NOTREACHED() << "Could not add a cookie to the DB."; diff --git a/chrome/browser/net/sqlite_persistent_cookie_store_perftest.cc b/chrome/browser/net/sqlite_persistent_cookie_store_perftest.cc index 8087e13..88d614fc 100644 --- a/chrome/browser/net/sqlite_persistent_cookie_store_perftest.cc +++ b/chrome/browser/net/sqlite_persistent_cookie_store_perftest.cc @@ -65,7 +65,7 @@ class SQLitePersistentCookieStorePerfTest : public testing::Test { net::CookieMonster::CanonicalCookie(gurl, base::StringPrintf("Cookie_%d", cookie_num), "1", domain_name, "/", std::string(), std::string(), - t, t, t, false, false, true, true)); + t, t, t, false, false)); } } // Replace the store effectively destroying the current one and forcing it diff --git a/chrome/browser/net/sqlite_persistent_cookie_store_unittest.cc b/chrome/browser/net/sqlite_persistent_cookie_store_unittest.cc index 323c7ed..384332d 100644 --- a/chrome/browser/net/sqlite_persistent_cookie_store_unittest.cc +++ b/chrome/browser/net/sqlite_persistent_cookie_store_unittest.cc @@ -99,7 +99,7 @@ class SQLitePersistentCookieStoreTest : public testing::Test { CookieMonster::CanonicalCookie(GURL(), name, value, domain, path, std::string(), std::string(), creation, creation, creation, - false, false, true, true)); + false, false)); } virtual void SetUp() { @@ -335,8 +335,8 @@ TEST_F(SQLitePersistentCookieStoreTest, TestLoadOldSessionCookies) { store_->AddCookie( CookieMonster::CanonicalCookie( GURL(), "C", "D", "sessioncookie.com", "/", std::string(), - std::string(), base::Time::Now(), base::Time::Now(), - base::Time::Now(), false, false, true, false /*is_persistent*/)); + std::string(), base::Time::Now(), base::Time(), + base::Time::Now(), false, false)); // Force the store to write its data to the disk. DestroyStore(); @@ -362,8 +362,8 @@ TEST_F(SQLitePersistentCookieStoreTest, TestDontLoadOldSessionCookies) { store_->AddCookie( CookieMonster::CanonicalCookie( GURL(), "C", "D", "sessioncookie.com", "/", std::string(), - std::string(), base::Time::Now(), base::Time::Now(), - base::Time::Now(), false, false, true, false /*is_persistent*/)); + std::string(), base::Time::Now(), base::Time(), + base::Time::Now(), false, false)); // Force the store to write its data to the disk. DestroyStore(); @@ -384,45 +384,31 @@ TEST_F(SQLitePersistentCookieStoreTest, TestDontLoadOldSessionCookies) { ASSERT_EQ(0U, cookies.size()); } -TEST_F(SQLitePersistentCookieStoreTest, PersistHasExpiresAndIsPersistent) { +TEST_F(SQLitePersistentCookieStoreTest, PersistIsPersistent) { InitializeStore(true); - static const char kSessionHasExpiresName[] = "session-hasexpires"; - static const char kSessionNoExpiresName[] = "session-noexpires"; + static const char kSessionName[] = "session"; static const char kPersistentName[] = "persistent"; - // Add a session cookie with has_expires = false, and another session cookie - // with has_expires = true. - store_->AddCookie( - CookieMonster::CanonicalCookie( - GURL(), kSessionHasExpiresName, "val", "sessioncookie.com", "/", - std::string(), std::string(), - base::Time::Now() - base::TimeDelta::FromDays(3), base::Time::Now(), - base::Time::Now(), false, false, true /* has_expires */, - false /* is_persistent */)); + // Add a session cookie. store_->AddCookie( CookieMonster::CanonicalCookie( - GURL(), kSessionNoExpiresName, "val", "sessioncookie.com", "/", + GURL(), kSessionName, "val", "sessioncookie.com", "/", std::string(), std::string(), - base::Time::Now() - base::TimeDelta::FromDays(2), base::Time::Now(), - base::Time::Now(), false, false, false /* has_expires */, - false /* is_persistent */)); + base::Time::Now(), base::Time(), base::Time::Now(), + false, false)); // Add a persistent cookie. store_->AddCookie( CookieMonster::CanonicalCookie( GURL(), kPersistentName, "val", "sessioncookie.com", "/", std::string(), std::string(), base::Time::Now() - base::TimeDelta::FromDays(1), base::Time::Now(), - base::Time::Now(), false, false, true /* has_expires */, - true /* is_persistent */)); + base::Time::Now(), false, false)); - // Force the store to write its data to the disk. - DestroyStore(); - - // Create a store that loads session cookies and test that the the DoesExpire - // and IsPersistent attributes are restored. + // Create a store that loads session cookie and test that the the IsPersistent + // attribute is restored. CanonicalCookieVector cookies; CreateAndLoad(true, &cookies); - ASSERT_EQ(3U, cookies.size()); + ASSERT_EQ(2U, cookies.size()); std::map<std::string, CookieMonster::CanonicalCookie*> cookie_map; for (CanonicalCookieVector::const_iterator it = cookies.begin(); @@ -432,19 +418,12 @@ TEST_F(SQLitePersistentCookieStoreTest, PersistHasExpiresAndIsPersistent) { } std::map<std::string, CookieMonster::CanonicalCookie*>::const_iterator it = - cookie_map.find(kSessionHasExpiresName); - ASSERT_TRUE(it != cookie_map.end()); - EXPECT_TRUE(cookie_map[kSessionHasExpiresName]->DoesExpire()); - EXPECT_FALSE(cookie_map[kSessionHasExpiresName]->IsPersistent()); - - it = cookie_map.find(kSessionNoExpiresName); + cookie_map.find(kSessionName); ASSERT_TRUE(it != cookie_map.end()); - EXPECT_FALSE(cookie_map[kSessionNoExpiresName]->DoesExpire()); - EXPECT_FALSE(cookie_map[kSessionNoExpiresName]->IsPersistent()); + EXPECT_FALSE(cookie_map[kSessionName]->IsPersistent()); it = cookie_map.find(kPersistentName); ASSERT_TRUE(it != cookie_map.end()); - EXPECT_TRUE(cookie_map[kPersistentName]->DoesExpire()); EXPECT_TRUE(cookie_map[kPersistentName]->IsPersistent()); STLDeleteElements(&cookies); @@ -506,7 +485,7 @@ TEST_F(SQLitePersistentCookieStoreTest, TestClearOnExitPolicy) { CookieMonster::CanonicalCookie(GURL(), "D", "4", session_origin, "/", std::string(), std::string(), t, t, t, - true, false, true, true)); + true, false)); // First, check that we can override the policy. store_->SetForceKeepSessionState(); diff --git a/chrome/browser/ui/cocoa/content_settings/cookie_details.mm b/chrome/browser/ui/cocoa/content_settings/cookie_details.mm index 1b2a767..c36d084 100644 --- a/chrome/browser/ui/cocoa/content_settings/cookie_details.mm +++ b/chrome/browser/ui/cocoa/content_settings/cookie_details.mm @@ -121,14 +121,14 @@ canEditExpiration:(BOOL)canEditExpiration { if ((self = [super init])) { type_ = kCocoaCookieDetailsTypeCookie; - hasExpiration_ = cookie->DoesExpire(); + hasExpiration_ = cookie->IsPersistent(); canEditExpiration_ = canEditExpiration && hasExpiration_; name_.reset([base::SysUTF8ToNSString(cookie->Name()) retain]); content_.reset([base::SysUTF8ToNSString(cookie->Value()) retain]); path_.reset([base::SysUTF8ToNSString(cookie->Path()) retain]); domain_.reset([origin retain]); - if (cookie->DoesExpire()) { + if (cookie->IsPersistent()) { expires_.reset([base::SysUTF16ToNSString( base::TimeFormatFriendlyDateAndTime(cookie->ExpiryDate())) retain]); } else { diff --git a/chrome/browser/ui/gtk/gtk_chrome_cookie_view.cc b/chrome/browser/ui/gtk/gtk_chrome_cookie_view.cc index 07a3701..bccd044 100644 --- a/chrome/browser/ui/gtk/gtk_chrome_cookie_view.cc +++ b/chrome/browser/ui/gtk/gtk_chrome_cookie_view.cc @@ -478,7 +478,7 @@ void gtk_chrome_cookie_view_display_cookie( UTF16ToUTF8(base::TimeFormatFriendlyDateAndTime( cookie.CreationDate())).c_str()); - std::string expire_text = cookie.DoesExpire() ? + std::string expire_text = cookie.IsPersistent() ? UTF16ToUTF8(base::TimeFormatFriendlyDateAndTime(cookie.ExpiryDate())) : l10n_util::GetStringUTF8(IDS_COOKIES_COOKIE_EXPIRES_SESSION); @@ -490,7 +490,7 @@ void gtk_chrome_cookie_view_display_cookie( GtkTreeIter iter; gtk_list_store_clear(store); - if (cookie.DoesExpire()) { + if (cookie.IsPersistent()) { gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, 0, expire_text.c_str(), -1); } diff --git a/chrome/browser/ui/views/cookie_info_view.cc b/chrome/browser/ui/views/cookie_info_view.cc index 758acf8..0b930d2 100644 --- a/chrome/browser/ui/views/cookie_info_view.cc +++ b/chrome/browser/ui/views/cookie_info_view.cc @@ -68,13 +68,13 @@ void CookieInfoView::SetCookie( created_value_field_->SetText( base::TimeFormatFriendlyDateAndTime(cookie.CreationDate())); - string16 expire_text = cookie.DoesExpire() ? + string16 expire_text = cookie.IsPersistent() ? base::TimeFormatFriendlyDateAndTime(cookie.ExpiryDate()) : l10n_util::GetStringUTF16(IDS_COOKIES_COOKIE_EXPIRES_SESSION); if (editable_expiration_date_) { expire_combo_values_.clear(); - if (cookie.DoesExpire()) + if (cookie.IsPersistent()) expire_combo_values_.push_back(expire_text); expire_combo_values_.push_back( l10n_util::GetStringUTF16(IDS_COOKIES_COOKIE_EXPIRES_SESSION)); diff --git a/chrome/browser/ui/webui/cookies_tree_model_util.cc b/chrome/browser/ui/webui/cookies_tree_model_util.cc index 318148d..64cef46 100644 --- a/chrome/browser/ui/webui/cookies_tree_model_util.cc +++ b/chrome/browser/ui/webui/cookies_tree_model_util.cc @@ -119,7 +119,7 @@ bool CookiesTreeModelUtil::GetCookieTreeNodeDictionary( dict->SetString(kKeyAccessibleToScript, accessible); dict->SetString(kKeyCreated, UTF16ToUTF8( base::TimeFormatFriendlyDateAndTime(cookie.CreationDate()))); - dict->SetString(kKeyExpires, cookie.DoesExpire() ? UTF16ToUTF8( + dict->SetString(kKeyExpires, cookie.IsPersistent() ? UTF16ToUTF8( base::TimeFormatFriendlyDateAndTime(cookie.ExpiryDate())) : l10n_util::GetStringUTF8(IDS_COOKIES_COOKIE_EXPIRES_SESSION)); 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. |