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

Side by Side Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 2102993002: Fix WebSocket to set first party for cookies (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update testRunner calls to setBlockThirdPartyCookies() Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 4152 matching lines...) Expand 10 before | Expand all | Expand 10 after
4163 // FIXME: If this document came from the file system, the HTML5 4163 // FIXME: If this document came from the file system, the HTML5
4164 // specificiation tells us to read the last modification date from the file 4164 // specificiation tells us to read the last modification date from the file
4165 // system. 4165 // system.
4166 if (!foundDate) 4166 if (!foundDate)
4167 date.setMillisecondsSinceEpochForDateTime(convertToLocalTime(currentTime MS())); 4167 date.setMillisecondsSinceEpochForDateTime(convertToLocalTime(currentTime MS()));
4168 return String::format("%02d/%02d/%04d %02d:%02d:%02d", date.month() + 1, dat e.monthDay(), date.fullYear(), date.hour(), date.minute(), date.second()); 4168 return String::format("%02d/%02d/%04d %02d:%02d:%02d", date.month() + 1, dat e.monthDay(), date.fullYear(), date.hour(), date.minute(), date.second());
4169 } 4169 }
4170 4170
4171 const KURL Document::firstPartyForCookies() const 4171 const KURL Document::firstPartyForCookies() const
4172 { 4172 {
4173 // TODO(mkwst): This doesn't properly handle HTML Import documents.
4174
4173 // If this is an imported document, grab its master document's first-party: 4175 // If this is an imported document, grab its master document's first-party:
4174 if (importsController() && importsController()->master() && importsControlle r()->master() != this) 4176 if (importsController() && importsController()->master() && importsControlle r()->master() != this)
4175 return importsController()->master()->firstPartyForCookies(); 4177 return importsController()->master()->firstPartyForCookies();
4176 4178
4179 if (!frame())
4180 return SecurityOrigin::urlWithUniqueSecurityOrigin();
4181
4177 // TODO(mkwst): This doesn't correctly handle sandboxed documents; we want t o look at their URL, 4182 // TODO(mkwst): This doesn't correctly handle sandboxed documents; we want t o look at their URL,
4178 // but we can't because we don't know what it is. 4183 // but we can't because we don't know what it is.
4179 Frame* top = frame()->tree().top(); 4184 Frame* top = frame()->tree().top();
4180 KURL topDocumentURL = top->isLocalFrame() 4185 KURL topDocumentURL = top->isLocalFrame()
4181 ? toLocalFrame(top)->document()->url() 4186 ? toLocalFrame(top)->document()->url()
4182 : KURL(KURL(), top->securityContext()->getSecurityOrigin()->toString()); 4187 : KURL(KURL(), top->securityContext()->getSecurityOrigin()->toString());
4183 if (SchemeRegistry::shouldTreatURLSchemeAsFirstPartyWhenTopLevel(topDocument URL.protocol())) 4188 if (SchemeRegistry::shouldTreatURLSchemeAsFirstPartyWhenTopLevel(topDocument URL.protocol()))
4184 return topDocumentURL; 4189 return topDocumentURL;
4185 4190
4186 // We're intentionally using the URL of each document rather than the docume nt's SecurityOrigin. 4191 // We're intentionally using the URL of each document rather than the docume nt's SecurityOrigin.
(...skipping 1857 matching lines...) Expand 10 before | Expand all | Expand 10 after
6044 } 6049 }
6045 6050
6046 void showLiveDocumentInstances() 6051 void showLiveDocumentInstances()
6047 { 6052 {
6048 WeakDocumentSet& set = liveDocumentSet(); 6053 WeakDocumentSet& set = liveDocumentSet();
6049 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6054 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6050 for (Document* document : set) 6055 for (Document* document : set)
6051 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data()); 6056 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data());
6052 } 6057 }
6053 #endif 6058 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698