summaryrefslogtreecommitdiffstats
path: root/net/base/cookie_monster.cc
diff options
context:
space:
mode:
Diffstat (limited to 'net/base/cookie_monster.cc')
-rw-r--r--net/base/cookie_monster.cc56
1 files changed, 36 insertions, 20 deletions
diff --git a/net/base/cookie_monster.cc b/net/base/cookie_monster.cc
index b9c04a4..05e7355 100644
--- a/net/base/cookie_monster.cc
+++ b/net/base/cookie_monster.cc
@@ -1166,11 +1166,11 @@ bool CookieMonster::SetCookieWithCreationTimeAndOptions(
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(),
- creation_time, creation_time,
- !cookie_expires.is_null(), cookie_expires));
+ cc.reset(new CanonicalCookie(url, pc.Name(),
+ pc.Value(), cookie_domain, cookie_path,
+ pc.IsSecure(), pc.IsHttpOnly(), creation_time,
+ creation_time, !cookie_expires.is_null(),
+ cookie_expires));
if (!cc.get()) {
VLOG(kVlogSetCookies) << "WARNING: Failed to allocate CanonicalCookie";
@@ -1848,7 +1848,8 @@ CookieMonster::CanonicalCookie::CanonicalCookie()
httponly_(false) {
}
-CookieMonster::CanonicalCookie::CanonicalCookie(const std::string& name,
+CookieMonster::CanonicalCookie::CanonicalCookie(const GURL& url,
+ const std::string& name,
const std::string& value,
const std::string& domain,
const std::string& path,
@@ -1858,21 +1859,23 @@ CookieMonster::CanonicalCookie::CanonicalCookie(const std::string& name,
const base::Time& last_access,
bool has_expires,
const base::Time& expires)
- : name_(name),
- value_(value),
- domain_(domain),
- path_(path),
- creation_date_(creation),
- last_access_date_(last_access),
- expiry_date_(expires),
- has_expires_(has_expires),
- secure_(secure),
- httponly_(httponly) {
+ : source_(GetCookieSourceFromURL(url)),
+ name_(name),
+ value_(value),
+ domain_(domain),
+ path_(path),
+ creation_date_(creation),
+ last_access_date_(last_access),
+ expiry_date_(expires),
+ has_expires_(has_expires),
+ secure_(secure),
+ httponly_(httponly) {
}
CookieMonster::CanonicalCookie::CanonicalCookie(const GURL& url,
const ParsedCookie& pc)
- : name_(pc.Name()),
+ : source_(GetCookieSourceFromURL(url)),
+ name_(pc.Name()),
value_(pc.Value()),
path_(CanonPath(url, pc)),
creation_date_(Time::Now()),
@@ -1900,6 +1903,19 @@ CookieMonster::CanonicalCookie::CanonicalCookie(const GURL& url,
CookieMonster::CanonicalCookie::~CanonicalCookie() {
}
+std::string CookieMonster::CanonicalCookie::GetCookieSourceFromURL(
+ const GURL& url) {
+ if (url.SchemeIsFile())
+ return url.spec();
+
+ url_canon::Replacements<char> replacements;
+ replacements.ClearPort();
+ if (url.SchemeIsSecure())
+ replacements.SetScheme("http", url_parse::Component(0, 4));
+
+ return url.GetOrigin().ReplaceComponents(replacements).spec();
+}
+
CookieMonster::CanonicalCookie* CookieMonster::CanonicalCookie::Create(
const GURL& url, const std::string& name, const std::string& value,
const std::string& domain, const std::string& path,
@@ -1938,9 +1954,9 @@ CookieMonster::CanonicalCookie* CookieMonster::CanonicalCookie::Create(
cookie_path = std::string(canon_path.data() + canon_path_component.begin,
canon_path_component.len);
- return new CanonicalCookie(parsed_name, parsed_value, cookie_domain,
- cookie_path, secure, http_only,
- creation_time, creation_time,
+ return new CanonicalCookie(url, parsed_name,
+ parsed_value, cookie_domain, cookie_path, secure,
+ http_only, creation_time, creation_time,
!expiration_time.is_null(), expiration_time);
}