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

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

Issue 1117203002: Enforce referrer policies for workers (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 7 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 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 , m_isTransitionDocument(false) 458 , m_isTransitionDocument(false)
459 , m_layoutView(0) 459 , m_layoutView(0)
460 #if !ENABLE(OILPAN) 460 #if !ENABLE(OILPAN)
461 , m_weakFactory(this) 461 , m_weakFactory(this)
462 #endif 462 #endif
463 , m_contextDocument(initializer.contextDocument()) 463 , m_contextDocument(initializer.contextDocument())
464 , m_hasFullscreenSupplement(false) 464 , m_hasFullscreenSupplement(false)
465 , m_loadEventDelayCount(0) 465 , m_loadEventDelayCount(0)
466 , m_loadEventDelayTimer(this, &Document::loadEventDelayTimerFired) 466 , m_loadEventDelayTimer(this, &Document::loadEventDelayTimerFired)
467 , m_pluginLoadingTimer(this, &Document::pluginLoadingTimerFired) 467 , m_pluginLoadingTimer(this, &Document::pluginLoadingTimerFired)
468 , m_referrerPolicy(ReferrerPolicyDefault)
469 , m_writeRecursionIsTooDeep(false) 468 , m_writeRecursionIsTooDeep(false)
470 , m_writeRecursionDepth(0) 469 , m_writeRecursionDepth(0)
471 , m_taskRunner(MainThreadTaskRunner::create(this)) 470 , m_taskRunner(MainThreadTaskRunner::create(this))
472 , m_registrationContext(initializer.registrationContext(this)) 471 , m_registrationContext(initializer.registrationContext(this))
473 , m_elementDataCacheClearTimer(this, &Document::elementDataCacheClearTimerFi red) 472 , m_elementDataCacheClearTimer(this, &Document::elementDataCacheClearTimerFi red)
474 , m_timeline(AnimationTimeline::create(this)) 473 , m_timeline(AnimationTimeline::create(this))
475 , m_templateDocumentHost(nullptr) 474 , m_templateDocumentHost(nullptr)
476 , m_didAssociateFormControlsTimer(this, &Document::didAssociateFormControlsT imerFired) 475 , m_didAssociateFormControlsTimer(this, &Document::didAssociateFormControlsT imerFired)
477 , m_hasViewportUnits(false) 476 , m_hasViewportUnits(false)
478 , m_styleRecalcElementCounter(0) 477 , m_styleRecalcElementCounter(0)
(...skipping 2579 matching lines...) Expand 10 before | Expand all | Expand 10 after
3058 else if (equalIgnoringCase(policy, "origin")) 3057 else if (equalIgnoringCase(policy, "origin"))
3059 setReferrerPolicy(ReferrerPolicyOrigin); 3058 setReferrerPolicy(ReferrerPolicyOrigin);
3060 else if (equalIgnoringCase(policy, "origin-when-crossorigin")) 3059 else if (equalIgnoringCase(policy, "origin-when-crossorigin"))
3061 setReferrerPolicy(ReferrerPolicyOriginWhenCrossOrigin); 3060 setReferrerPolicy(ReferrerPolicyOriginWhenCrossOrigin);
3062 else if (equalIgnoringCase(policy, "no-referrer-when-downgrade") || equalIgn oringCase(policy, "default")) 3061 else if (equalIgnoringCase(policy, "no-referrer-when-downgrade") || equalIgn oringCase(policy, "default"))
3063 setReferrerPolicy(ReferrerPolicyNoReferrerWhenDowngrade); 3062 setReferrerPolicy(ReferrerPolicyNoReferrerWhenDowngrade);
3064 else 3063 else
3065 addConsoleMessage(ConsoleMessage::create(RenderingMessageSource, ErrorMe ssageLevel, "Failed to set referrer policy: The value '" + policy + "' is not on e of 'always', 'default', 'never', 'no-referrer', 'no-referrer-when-downgrade', 'origin', 'origin-when-crossorigin', or 'unsafe-url'. This document's referrer p olicy has been left unchanged.")); 3064 addConsoleMessage(ConsoleMessage::create(RenderingMessageSource, ErrorMe ssageLevel, "Failed to set referrer policy: The value '" + policy + "' is not on e of 'always', 'default', 'never', 'no-referrer', 'no-referrer-when-downgrade', 'origin', 'origin-when-crossorigin', or 'unsafe-url'. This document's referrer p olicy has been left unchanged."));
3066 } 3065 }
3067 3066
3068 void Document::setReferrerPolicy(ReferrerPolicy referrerPolicy) 3067 void Document::setReferrerPolicy(ReferrerPolicy policy)
3069 { 3068 {
3070 // FIXME: Can we adopt the CSP referrer policy merge algorithm? Or does the web rely on being able to modify the referrer policy in-flight? 3069 // FIXME: Can we adopt the CSP referrer policy merge algorithm? Or does the web rely on being able to modify the referrer policy in-flight?
3071 UseCounter::count(this, UseCounter::SetReferrerPolicy); 3070 UseCounter::count(this, UseCounter::SetReferrerPolicy);
3072 if (m_referrerPolicy != ReferrerPolicyDefault) 3071 if (referrerPolicy() != ReferrerPolicyDefault)
3073 UseCounter::count(this, UseCounter::ResetReferrerPolicy); 3072 UseCounter::count(this, UseCounter::ResetReferrerPolicy);
3074 3073
3075 m_referrerPolicy = referrerPolicy; 3074 ExecutionContext::setReferrerPolicy(policy);
Mike West 2015/05/01 14:34:29 Isn't `Document` an `ExecutionContext`? Can't we j
estark 2015/05/01 18:19:55 Oh ok, yeah, that works. I wasn't sure if we wante
3076 } 3075 }
3077 3076
3078 String Document::outgoingReferrer() 3077 String Document::outgoingReferrer()
3079 { 3078 {
3080 // See http://www.whatwg.org/specs/web-apps/current-work/#fetching-resources 3079 // See http://www.whatwg.org/specs/web-apps/current-work/#fetching-resources
3081 // for why we walk the parent chain for srcdoc documents. 3080 // for why we walk the parent chain for srcdoc documents.
3082 Document* referrerDocument = this; 3081 Document* referrerDocument = this;
3083 if (LocalFrame* frame = m_frame) { 3082 if (LocalFrame* frame = m_frame) {
3084 while (frame->document()->isSrcdocDocument()) { 3083 while (frame->document()->isSrcdocDocument()) {
3085 // Srcdoc documents must be local within the containing frame. 3084 // Srcdoc documents must be local within the containing frame.
(...skipping 2669 matching lines...) Expand 10 before | Expand all | Expand 10 after
5755 #ifndef NDEBUG 5754 #ifndef NDEBUG
5756 using namespace blink; 5755 using namespace blink;
5757 void showLiveDocumentInstances() 5756 void showLiveDocumentInstances()
5758 { 5757 {
5759 WeakDocumentSet& set = liveDocumentSet(); 5758 WeakDocumentSet& set = liveDocumentSet();
5760 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5759 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5761 for (Document* document : set) 5760 for (Document* document : set)
5762 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data()); 5761 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data());
5763 } 5762 }
5764 #endif 5763 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698