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

Unified Diff: net/base/cookie_monster.cc

Issue 4630001: Implement Origin cookies. Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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
« no previous file with comments | « net/base/cookie_monster.h ('k') | net/base/cookie_monster_store_test.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/cookie_monster.cc
===================================================================
--- net/base/cookie_monster.cc (revision 65294)
+++ net/base/cookie_monster.cc (working copy)
@@ -649,7 +649,7 @@
const CookieMonster::ParsedCookie& pc,
std::string* result) {
std::string domain_string;
- if (pc.HasDomain())
+ if (pc.HasDomain() && !pc.IsOrigin())
domain_string = pc.Domain();
return GetCookieDomainWithString(url, domain_string, result);
}
@@ -783,12 +783,14 @@
std::string cookie_path = CanonPath(url, pc);
+ bool cookie_secure = pc.IsOrigin() ? url.SchemeIsSecure() : pc.IsSecure();
+
scoped_ptr<CanonicalCookie> cc;
Time cookie_expires = CanonExpiration(pc, creation_time, options);
cc.reset(new CanonicalCookie(pc.Name(), pc.Value(), cookie_domain,
- cookie_path,
- pc.IsSecure(), pc.IsHttpOnly(),
+ cookie_path, cookie_secure,
+ pc.IsHttpOnly(), pc.IsOrigin(),
creation_time, creation_time,
!cookie_expires.is_null(), cookie_expires));
@@ -816,7 +818,8 @@
bool CookieMonster::SetCookieWithDetails(
const GURL& url, const std::string& name, const std::string& value,
const std::string& domain, const std::string& path,
- const base::Time& expiration_time, bool secure, bool http_only) {
+ const base::Time& expiration_time,
+ bool secure, bool http_only, bool origin) {
AutoLock autolock(lock_);
@@ -832,7 +835,7 @@
cc.reset(CanonicalCookie::Create(
url, name, value, domain, path,
creation_time, expiration_time,
- secure, http_only));
+ secure, http_only, origin));
if (!cc.get())
return false;
@@ -1438,6 +1441,9 @@
if (options.exclude_httponly() && cc->IsHttpOnly())
continue;
+ if (options.read_origin() != cc->IsOrigin())
+ continue;
+
// Filter out secure cookies unless we're https.
if (!secure && cc->IsSecure())
continue;
@@ -1521,7 +1527,8 @@
expires_index_(0),
maxage_index_(0),
secure_index_(0),
- httponly_index_(0) {
+ httponly_index_(0),
+ origin_index_(0) {
if (cookie_line.size() > kMaxCookieSize) {
VLOG(1) << "Not parsing cookie, too large: " << cookie_line.size();
@@ -1756,6 +1763,7 @@
static const char kMaxAgeTokenName[] = "max-age";
static const char kSecureTokenName[] = "secure";
static const char kHttpOnlyTokenName[] = "httponly";
+ static const char kOriginTokenName[] = "origin";
// We skip over the first token/value, the user supplied one.
for (size_t i = 1; i < pairs_.size(); ++i) {
@@ -1771,6 +1779,8 @@
secure_index_ = i;
} else if (pairs_[i].first == kHttpOnlyTokenName) {
httponly_index_ = i;
+ } else if (pairs_[i].first == kOriginTokenName) {
+ origin_index_ = i;
} else {
/* some attribute we don't know or don't care about. */
}
@@ -1792,6 +1802,7 @@
return out;
}
+// TODO(abarth): Do we need to initialize the boolean members here?
CookieMonster::CanonicalCookie::CanonicalCookie() {
}
@@ -1801,6 +1812,7 @@
const std::string& path,
bool secure,
bool httponly,
+ bool origin,
const base::Time& creation,
const base::Time& last_access,
bool has_expires,
@@ -1814,7 +1826,8 @@
expiry_date_(expires),
has_expires_(has_expires),
secure_(secure),
- httponly_(httponly) {
+ httponly_(httponly),
+ origin_(origin) {
}
CookieMonster::CanonicalCookie::CanonicalCookie(const GURL& url,
@@ -1826,7 +1839,8 @@
last_access_date_(Time()),
has_expires_(pc.HasExpires()),
secure_(pc.IsSecure()),
- httponly_(pc.IsHttpOnly()) {
+ httponly_(pc.IsHttpOnly()),
+ origin_(pc.IsOrigin()) {
if (has_expires_)
expiry_date_ = CanonExpiration(pc, creation_date_, CookieOptions());
@@ -1865,7 +1879,7 @@
const GURL& url, const std::string& name, const std::string& value,
const std::string& domain, const std::string& path,
const base::Time& creation_time, const base::Time& expiration_time,
- bool secure, bool http_only) {
+ bool secure, bool http_only, bool origin) {
// 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);
@@ -1900,7 +1914,7 @@
canon_path_component.len);
return new CanonicalCookie(parsed_name, parsed_value, cookie_domain,
- cookie_path, secure, http_only,
+ cookie_path, secure, http_only, origin,
creation_time, creation_time,
!expiration_time.is_null(), expiration_time);
}
« no previous file with comments | « net/base/cookie_monster.h ('k') | net/base/cookie_monster_store_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698